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 SynchronizeModelAction

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.SynchronizeModelAction
All Implemented Interfaces:
IAction, ISelectionChangedListener

public abstract class SynchronizeModelAction
extends BaseSelectionListenerAction

This action provides utilities for performing operations on selections that contain ISynchronizeModelElement instances. Subclasses can use this support to filter the selection in order to determine action enablement and generate the input for a SynchronizeModelOperation.

Since:
3.0
See Also:
SyncInfo, SyncInfoSet, SynchronizeModelOperation

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
protected SynchronizeModelAction ( String text, ISynchronizePageConfiguration configuration)
          Create an action with the given text and configuration.
protected SynchronizeModelAction ( String text, ISynchronizePageConfiguration configuration, ISelectionProvider selectionProvider)
          Create an action with the given text and configuration.
 
Method Summary
protected  boolean confirmSaveOfDirtyEditor ()
          Returns whether the user should be prompted to save dirty editors.
  ISynchronizePageConfiguration getConfiguration ()
          Returns the configuration showing this action.
protected   IDiffElement[] getFilteredDiffElements ()
          Return the selected diff element for which this action is enabled.
protected   IDiffElement[] getSelectedDiffElements ()
          This method returns all instances of IDiffElement that are in the current selection.
protected abstract   SynchronizeModelOperation getSubscriberOperation ( ISynchronizePageConfiguration configuration, IDiffElement[] elements)
          Return the subscriber operation associated with this action.
protected   FastSyncInfoFilter getSyncInfoFilter ()
          Filter uses to filter the user selection to contain only those elements for which this action is enabled.
protected  void handle ( Exception e)
          Generic error handling code that uses an error dialog to show the error to the user.
protected  void initialize ( ISynchronizePageConfiguration configuration, ISelectionProvider selectionProvider)
          Method invoked from the constructor.
protected  boolean needsToSaveDirtyEditors ()
          Return whether dirty editor should be saved before this action is run.
 void run ()
          The default implementation of this IAction method does nothing.
protected  void runOperation ()
          Create and run the operation for this action.
 boolean saveAllEditors (boolean confirm)
          Save all dirty editors in the workbench that are open on files that may be affected by this operation.
 void selectionChanged ( ISelection selection)
          Set the selection of this action to the given selection
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, 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

SynchronizeModelAction

protected SynchronizeModelAction(
String text,
                                 
ISynchronizePageConfiguration configuration)
Create an action with the given text and configuration. By default, the action registers for selection change with the selection provider from the configuration's site.

Parameters:
text - the action's text
configuration - the actions synchronize page configuration

SynchronizeModelAction

protected SynchronizeModelAction(
String text,
                                 
ISynchronizePageConfiguration configuration,
                                 
ISelectionProvider selectionProvider)
Create an action with the given text and configuration. By default, the action registers for selection change with the given selection provider.

Parameters:
text - the action's text
configuration - the actions synchronize page configuration
selectionProvider - a selection provider
Method Detail

initialize

protected void initialize(
ISynchronizePageConfiguration configuration,
                          
ISelectionProvider selectionProvider)
Method invoked from the constructor. The default implementation registers the action as a selection change listener. Subclasses may override.

Parameters:
configuration - the synchronize page configuration
selectionProvider - a selection provider

run

public void run()
Description copied from class: Action
The default implementation of this IAction method does nothing. Subclasses should override this method if they do not need information from the triggering event, or override runWithEvent(Event) if they do.

Specified by:
run in interface IAction
Overrides:
run in class Action

runOperation

protected void runOperation()
                     throws 
InvocationTargetException,
                            
InterruptedException
Create and run the operation for this action. By default, the operation is created by calling getSubscriberOperation and then run. Subclasses may override.

Throws:
InvocationTargetException
InterruptedException
Since:
3.1

needsToSaveDirtyEditors

protected boolean needsToSaveDirtyEditors()
Return whether dirty editor should be saved before this action is run. Default is true.

Returns:
whether dirty editor should be saved before this action is run

confirmSaveOfDirtyEditor

protected boolean confirmSaveOfDirtyEditor()
Returns whether the user should be prompted to save dirty editors. The default is true.

Returns:
whether the user should be prompted to save dirty editors

getSubscriberOperation

protected abstract 
SynchronizeModelOperation getSubscriberOperation(
ISynchronizePageConfiguration configuration,
                                                                    
IDiffElement[] elements)
Return the subscriber operation associated with this action. This operation will be run when the action is run. Subclass may implement this method and provide an operation subclass or may override the run(IAction) method directly if they choose not to implement a SynchronizeModelOperation.

Parameters:
configuration - the synchronize page configuration for the page to which this action is associated
elements - the selected diff element for which this action is enabled.
Returns:
the subscriber operation to be run by this action.

handle

protected void handle(
Exception e)
Generic error handling code that uses an error dialog to show the error to the user. Subclasses can use this method and/or override it.

Parameters:
e - the exception that occurred.

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

getSelectedDiffElements

protected final 
IDiffElement[] getSelectedDiffElements()
This method returns all instances of IDiffElement that are in the current selection.

Returns:
the selected elements

getSyncInfoFilter

protected 
FastSyncInfoFilter getSyncInfoFilter()
Filter uses to filter the user selection to contain only those elements for which this action is enabled. Default filter includes all out-of-sync elements in the current selection. Subclasses may override.

Returns:
a sync info filter which selects all out-of-sync resources.

getFilteredDiffElements

protected final 
IDiffElement[] getFilteredDiffElements()
Return the selected diff element for which this action is enabled.

Returns:
the list of selected diff elements for which this action is enabled.

selectionChanged

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

Parameters:
selection - the selection

getConfiguration

public 
ISynchronizePageConfiguration getConfiguration()
Returns the configuration showing this action.

Returns:
the configuration showing this action.

saveAllEditors

public final boolean saveAllEditors(boolean confirm)
Save all dirty editors in the workbench that are open on files that may be affected by this operation. Opens a dialog to prompt the user if confirm is true. Return true if successful. Return false if the user has canceled the command. Must be called from the UI thread.

Parameters:
confirm - prompt the user if true
Returns:
boolean false if the operation was canceled.

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