Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.team.ui.synchronize
Class ModelParticipantAction

java.lang.Object
  extended by 

org.eclipse.core.commands.common.EventManager
      extended by 

org.eclipse.jface.action.AbstractAction
          extended by 

org.eclipse.jface.action.Action
              extended by 

org.eclipse.ui.actions.BaseSelectionListenerAction
                  extended by 
org.eclipse.team.ui.synchronize.ModelParticipantAction
All Implemented Interfaces:
IAction, ISelectionChangedListener

public abstract class ModelParticipantAction
extends BaseSelectionListenerAction

Model provider actions for use with a ModelSynchronizeParticipant.

Since:
3.2

Field Summary
 
Fields inherited from interface org.eclipse.jface.action. IAction
AS_CHECK_BOX, AS_DROP_DOWN_MENU, AS_PUSH_BUTTON, AS_RADIO_BUTTON, AS_UNSPECIFIED, CHECKED, DESCRIPTION, ENABLED, HANDLED, IMAGE, RESULT, TEXT, TOOL_TIP_TEXT
 
Constructor Summary
ModelParticipantAction ( String text, ISynchronizePageConfiguration configuration)
          Create the model participant action.
 
Method Summary
protected   SaveableComparison getActiveSaveable ()
          Return the currently active saveable.
protected   ISynchronizePageConfiguration getConfiguration ()
          Return the page configuration.
protected   ISynchronizationContext getSynchronizationContext ()
          Return the synchronization context associated with this action.
protected   SaveableComparison getTargetSaveable ()
          Return the saveable that is the target of this operation.
protected  void handleTargetSaveableChange ()
          Check to see if the target saveable differs from the currently active saveable.
static void handleTargetSaveableChange ( Shell shell, SaveableComparison targetSaveable, SaveableComparison activeSaveable, boolean allowCancel, IProgressMonitor monitor)
          Convenience method that prompts if the currently active saveable is dirty and either saves or reverts the saveable depending on the users input.
protected abstract  boolean isEnabledForSelection ( IStructuredSelection selection)
          Return whether the action is enabled for the given selection
protected  boolean isVisible ( IDiff node)
          Return whether the given node is visible in the page based on the mode in the configuration.
static boolean promptToSaveChanges ( Shell shell, SaveableComparison saveable, boolean allowCancel)
          Convenience method that prompts to save changes in the given dirty model.
 void selectionChanged ( ISelection selection)
          Set the selection of this action to the given selection
protected  void setActiveSaveable ( SaveableComparison saveable)
          Set the active saveable.
 void updateEnablement ()
          Method called when the action is about to be shown in a context menu.
protected  boolean updateSelection ( IStructuredSelection selection)
          Updates this action in response to the given selection.
 
Methods inherited from class org.eclipse.ui.actions. BaseSelectionListenerAction
clearCache, getStructuredSelection, runWithEvent, selectionChanged, selectionChanged
 
Methods inherited from class org.eclipse.jface.action. Action
convertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, isHandled, notifyResult, removeAcceleratorText, removeMnemonics, run, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipText
 
Methods inherited from class org.eclipse.jface.action. AbstractAction
addPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListener
 
Methods inherited from class org.eclipse.core.commands.common. EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.jface.action. IAction
addPropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

ModelParticipantAction

public ModelParticipantAction(
String text,
                              
ISynchronizePageConfiguration configuration)
Create the model participant action.

Parameters:
text - the label of the action or null
configuration - the configuration for the page that is surfacing the action
Method Detail

getConfiguration

protected 
ISynchronizePageConfiguration getConfiguration()
Return the page configuration.

Returns:
the page configuration

selectionChanged

public void selectionChanged(
ISelection selection)
Set the selection of this action to the given selection

Parameters:
selection - the selection

updateSelection

protected boolean updateSelection(
IStructuredSelection selection)
Description copied from class: BaseSelectionListenerAction
Updates this action in response to the given selection.

The BaseSelectionListenerAction implementation of this method returns true. Subclasses may extend to react to selection changes; however, if the super method returns false, the overriding method must also return false.

Overrides:
updateSelection in class BaseSelectionListenerAction
Parameters:
selection - the new selection
Returns:
true if the action should be enabled for this selection, and false otherwise

isEnabledForSelection

protected abstract boolean isEnabledForSelection(
IStructuredSelection selection)
Return whether the action is enabled for the given selection

Parameters:
selection - the selection
Returns:
whether the action is enabled for the given selection

getSynchronizationContext

protected 
ISynchronizationContext getSynchronizationContext()
Return the synchronization context associated with this action.

Returns:
the synchronization context associated with this action

isVisible

protected boolean isVisible(
IDiff node)
Return whether the given node is visible in the page based on the mode in the configuration.

Parameters:
node - a diff node
Returns:
whether the given node is visible in the page

handleTargetSaveableChange

protected void handleTargetSaveableChange()
                                   throws 
InvocationTargetException,
                                          
InterruptedException
Check to see if the target saveable differs from the currently active saveable. If it does, prompt to save changes in the active saveable if it is dirty.

Throws:
InterruptedException
InvocationTargetException

handleTargetSaveableChange

public static void handleTargetSaveableChange(
Shell shell,
                                              
SaveableComparison targetSaveable,
                                              
SaveableComparison activeSaveable,
                                              boolean allowCancel,
                                              
IProgressMonitor monitor)
                                       throws 
CoreException,
                                              
InterruptedException
Convenience method that prompts if the currently active saveable is dirty and either saves or reverts the saveable depending on the users input.

Parameters:
shell - a parent shell
targetSaveable - the new saveable
activeSaveable - the current saveable
allowCancel - whether canceling the action is an option
monitor - a progress monitor
Throws:
CoreException
InterruptedException

promptToSaveChanges

public static boolean promptToSaveChanges(
Shell shell,
                                          
SaveableComparison saveable,
                                          boolean allowCancel)
                                   throws 
InterruptedException
Convenience method that prompts to save changes in the given dirty model.

Parameters:
shell - a shell
saveable - a dirty saveable model
allowCancel - whether canceling the action is an option
Returns:
whether the user choose to save (true) or revert (false() the model
Throws:
InterruptedException - thrown if the user choose to cancel

getActiveSaveable

protected 
SaveableComparison getActiveSaveable()
Return the currently active saveable. By default, the active saveable is obtained from the synchronization page configuration.

Returns:
the currently active saveable (or null if no buffer is active).

setActiveSaveable

protected void setActiveSaveable(
SaveableComparison saveable)
Set the active saveable. By default to active saveable is stored with the synchronize page configuration.

Parameters:
saveable - the saveable that is now active (or null if no saveable is active).

getTargetSaveable

protected 
SaveableComparison getTargetSaveable()
Return the saveable that is the target of this operation. By default, null is returned.

Returns:
the saveable that is the target of this operation

updateEnablement

public void updateEnablement()
Method called when the action is about to be shown in a context menu. This method recalculates the enablement for the current selection and uses that to set the enablement.


Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire