org.eclipse.graphiti.pattern
Class RemoveFeatureForPattern

java.lang.Object
  extended by org.eclipse.graphiti.features.impl.AbstractFeature
      extended by org.eclipse.graphiti.features.impl.DefaultRemoveFeature
          extended by org.eclipse.graphiti.pattern.RemoveFeatureForPattern
All Implemented Interfaces:
ICustomAbortableUndoRedoFeature, ICustomUndoableFeature, ICustomUndoRedoFeature, IFeature, IFeatureProviderHolder, IRemoveFeature, IRemove, IDescription, IName

public class RemoveFeatureForPattern
extends DefaultRemoveFeature
implements ICustomUndoableFeature, ICustomAbortableUndoRedoFeature

This feature wraps the remove functionality of a pattern for calls of the Graphiti framework. Clients should not need to use this class directly.

Since:
0.8.0

Field Summary
private  IFeatureForPattern delegate
           
 
Constructor Summary
RemoveFeatureForPattern(IFeatureProvider featureProvider, IPattern pattern)
          Creates a new RemoveFeatureForPattern.
 
Method Summary
 boolean canRedo(IContext context)
          Decides if the processed feature can be re-done.
 boolean canRemove(IRemoveContext context)
          Checks if given object could be removed.
 boolean canUndo(IContext context)
          Decides if the current feature can be undone - this is the undo of the execute operation.
 boolean hasDoneChanges()
          Is queried by the framework after a feature has been executed to find out if this feature should appear in the undo stack of e.g.
 boolean isAbort()
          The Graphiti framework will call this method after ICustomUndoRedoFeature.preUndo(org.eclipse.graphiti.features.context.IContext)/ ICustomUndoRedoFeature.preRedo(org.eclipse.graphiti.features.context.IContext) have been called and before the actual undo/redo operation is triggered.
 boolean isRemoveAbort()
          The Graphiti framework will call this method after IRemove.preRemove(IRemoveContext) has been called and before the actual remove is done.
 void postRedo(IContext context)
          This method will be called by the Graphiti framework after the EMF undo has finished.
 void postRemove(IRemoveContext context)
          called after remove call.
 void postUndo(IContext context)
          This method will be called by the Graphiti framework after the EMF undo is finished.
 void preRedo(IContext context)
          This method will be called by the Graphiti framework before the EMF undo has triggered.
 void preRemove(IRemoveContext context)
          called prior to remove call.
 void preUndo(IContext context)
          This method will be called by the Graphiti framework before the EMF undo is triggered.
 void redo(IContext context)
          Deprecated. use postRedo(IContext) instead
 void remove(IRemoveContext context)
          Remove the given object.
 void undo(IContext context)
          Deprecated. use postUndo(IContext) instead
 
Methods inherited from class org.eclipse.graphiti.features.impl.DefaultRemoveFeature
canExecute, execute, getDescription, getName, removeAllConnections, removeAllConnections
 
Methods inherited from class org.eclipse.graphiti.features.impl.AbstractFeature
addGraphicalRepresentation, getAllBusinessObjectsForPictogramElement, getBusinessObjectForPictogramElement, getDiagram, getDiagramBehavior, getFeatureProvider, getProgressCallback, getUserDecision, isAvailable, layoutPictogramElement, link, link, manageColor, manageColor, manageDefaultFont, manageFont, manageFont, setProgressCallback, toString, updatePictogramElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.graphiti.features.IFeature
isAvailable
 
Methods inherited from interface org.eclipse.graphiti.features.IFeatureProviderHolder
getFeatureProvider
 

Field Detail

delegate

private IFeatureForPattern delegate
Constructor Detail

RemoveFeatureForPattern

public RemoveFeatureForPattern(IFeatureProvider featureProvider,
                               IPattern pattern)
Creates a new RemoveFeatureForPattern.

Parameters:
featureProvider - the feature provider
pattern - the pattern
Method Detail

canRemove

public boolean canRemove(IRemoveContext context)
Description copied from interface: IRemove
Checks if given object could be removed.

Specified by:
canRemove in interface IRemove
Overrides:
canRemove in class DefaultRemoveFeature
Parameters:
context - contains object to remove
Returns:
true if remove is possible

preRemove

public void preRemove(IRemoveContext context)
Description copied from interface: IRemove
called prior to remove call.

Specified by:
preRemove in interface IRemove
Overrides:
preRemove in class DefaultRemoveFeature
Parameters:
context - the context

isRemoveAbort

public boolean isRemoveAbort()
Description copied from interface: IRemove
The Graphiti framework will call this method after IRemove.preRemove(IRemoveContext) has been called and before the actual remove is done. In case this method returns true, the operation will be cancelled by the Graphiti framework by throwing an OperationCanceledException that causes am EMF revert of the operation.

Implementing classes might e.g. set a flag in IRemove.preRemove(IRemoveContext) as cancellation indication and check that that flag here.

Specified by:
isRemoveAbort in interface IRemove
Overrides:
isRemoveAbort in class DefaultRemoveFeature
Returns:
true in case you want to cancel the current operation, false otherwise.
Since:
0.12

remove

public void remove(IRemoveContext context)
Description copied from interface: IRemove
Remove the given object.

Specified by:
remove in interface IRemove
Overrides:
remove in class DefaultRemoveFeature
Parameters:
context - contains object to remove

postRemove

public void postRemove(IRemoveContext context)
Description copied from interface: IRemove
called after remove call.

Specified by:
postRemove in interface IRemove
Overrides:
postRemove in class DefaultRemoveFeature
Parameters:
context - the context

isAbort

public boolean isAbort()
Description copied from interface: ICustomAbortableUndoRedoFeature
The Graphiti framework will call this method after ICustomUndoRedoFeature.preUndo(org.eclipse.graphiti.features.context.IContext)/ ICustomUndoRedoFeature.preRedo(org.eclipse.graphiti.features.context.IContext) have been called and before the actual undo/redo operation is triggered. In case this method returns true, the operation will be cancelled by the Graphiti framework by throwing an OperationCanceledException that causes am EMF revert of the operation.

Implementing classes might e.g. set a flag in ICustomUndoRedoFeature.preUndo(org.eclipse.graphiti.features.context.IContext)/ ICustomUndoRedoFeature.preRedo(org.eclipse.graphiti.features.context.IContext) as cancellation indication and check that that flag here.

Specified by:
isAbort in interface ICustomAbortableUndoRedoFeature
Returns:
true in case you want to cancel the current operation, false otherwise.
Since:
0.12

canUndo

public boolean canUndo(IContext context)
Description copied from interface: IFeature
Decides if the current feature can be undone - this is the undo of the execute operation.

Specified by:
canUndo in interface ICustomUndoableFeature
Specified by:
canUndo in interface ICustomUndoRedoFeature
Specified by:
canUndo in interface IFeature
Overrides:
canUndo in class AbstractFeature
Parameters:
context - this is the general input for this method
Returns:
true if the feature can be undone, false if not
See Also:
IContext

preUndo

public void preUndo(IContext context)
Description copied from interface: ICustomUndoRedoFeature
This method will be called by the Graphiti framework before the EMF undo is triggered. Customers may revert their non-EMF changes done by the feature here or in ICustomUndoRedoFeature.postUndo(IContext).

Specified by:
preUndo in interface ICustomUndoRedoFeature
Parameters:
context - this is the instance of the IContext object that was in use when executing the feature
Since:
0.12

postUndo

public void postUndo(IContext context)
Description copied from interface: ICustomUndoRedoFeature
This method will be called by the Graphiti framework after the EMF undo is finished. Customers may revert their non-EMF changes done by the feature here or in ICustomUndoRedoFeature.preUndo(IContext).

Specified by:
postUndo in interface ICustomUndoRedoFeature
Parameters:
context - this is the instance of the IContext object that was in use when executing the feature
Since:
0.12

undo

public void undo(IContext context)
Deprecated. use postUndo(IContext) instead

Description copied from interface: ICustomUndoableFeature
This method will be called to actually do the work needed for undo. Customers may revert their non-EMF changes done by the feature here.

Specified by:
undo in interface ICustomUndoableFeature
Parameters:
context - this is the instance of the IContext object that was in use when executing the feature

canRedo

public boolean canRedo(IContext context)
Description copied from interface: ICustomUndoableFeature
Decides if the processed feature can be re-done.

Note that as soon as any feature reports false here, also all consecutive entries in the command stack are no longer reachable for redo.

Specified by:
canRedo in interface ICustomUndoableFeature
Specified by:
canRedo in interface ICustomUndoRedoFeature
Parameters:
context - this is the instance of the IContext object that was in use when executing the feature
Returns:
true if the feature can be re-done, false if not

preRedo

public void preRedo(IContext context)
Description copied from interface: ICustomUndoRedoFeature
This method will be called by the Graphiti framework before the EMF undo has triggered. Customers may re-apply their non-EMF changes done by the feature here or in ICustomUndoRedoFeature.postRedo(IContext). (Usually it might be sufficient to delegate to the execution method of the feature.)

Specified by:
preRedo in interface ICustomUndoRedoFeature
Parameters:
context - this is the instance of the IContext object that was in use when executing the feature
Since:
0.12

postRedo

public void postRedo(IContext context)
Description copied from interface: ICustomUndoRedoFeature
This method will be called by the Graphiti framework after the EMF undo has finished. Customers may re-apply their non-EMF changes done by the feature here or in ICustomUndoRedoFeature.preRedo(IContext). (Usually it might be sufficient to delegate to the execution method of the feature.)

Specified by:
postRedo in interface ICustomUndoRedoFeature
Parameters:
context - this is the instance of the IContext object that was in use when executing the feature
Since:
0.12

redo

public void redo(IContext context)
Deprecated. use postRedo(IContext) instead

Description copied from interface: ICustomUndoableFeature
This method will be called to actually do the work needed for redo. Customers may re-apply their non-EMF changes done by the feature here. (Usually it might be sufficient to delegate to the execution method of the feature.)

Specified by:
redo in interface ICustomUndoableFeature
Parameters:
context - this is the instance of the IContext object that was in use when executing the feature

hasDoneChanges

public boolean hasDoneChanges()
Description copied from interface: IFeature
Is queried by the framework after a feature has been executed to find out if this feature should appear in the undo stack of e.g. an editor. By default all features should appear there (see implementation in AbstractFeature), but features may decide to override this behavior. Note that this is a dynamic attribute of the feature that is queried each time after the feature has been executed.

IMPORTANT NOTE: The implementor of the feature is responsible for correctly implementing this method! It might lead to inconsistencies in the command stack if this method returns false although the feature did changes.

Specified by:
hasDoneChanges in interface IFeature
Overrides:
hasDoneChanges in class AbstractFeature
Returns:
true if the feature should appear in the undo stack, false otherwise


Copyright (c) SAP AG 2005, 2012.