Package org.eclipse.graphiti.ui.features
Class DefaultDeleteFeature
java.lang.Object
org.eclipse.graphiti.features.impl.AbstractFeature
org.eclipse.graphiti.ui.features.DefaultDeleteFeature
- All Implemented Interfaces:
IDeleteFeature,IFeature,IFeatureProviderHolder,IDelete,IDescription,IName
- Direct Known Subclasses:
DeleteFeatureForPattern
The Graphiti default implementation of the
Before the deletion process starts the tool user will be asked if he really wants to delete; the popup appears only once for multi object deletions.
IDeleteFeature. It cares
about removing the shape(s) representing the deleted domain object(s) from
the diagram (by delegating to the IRemoveFeature provided by the
IFeatureProvider. After that the EMF domain objects will be deleted
using standard EMF functionality.Before the deletion process starts the tool user will be asked if he really wants to delete; the popup appears only once for multi object deletions.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanDelete(IDeleteContext context) Can delete hook.booleancanExecute(IContext context) Decides if the current feature can execute with the given context.voiddelete(IDeleteContext context) Hook to implement the actual delete functionality.protected voidStandard functionality to delete one domain object.protected voiddeleteBusinessObjects(Object[] businessObjects) Standard functionality to delete all given domain objects.voidExecutes the current feature with the given context.protected StringgetDeleteName(IDeleteContext context) Returns the delete name which will be used for the delete dialog.Gets the description.getName()Hook to return the name of the delete operation e.g for display in the context menu.protected booleangetUserDecision(IDeleteContext context) Shows a dialog which asks the user to confirm the deletion of one or more elements.booleanIs 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.booleanThe Graphiti framework will call this method afterIDelete.preDelete(IDeleteContext)has been called and before the actual delete is done.voidpostDelete(IDeleteContext context) Post delete hook that can be implemented by users to perform any operations that need to be done after the standard delete functionality ends.voidpreDelete(IDeleteContext context) Pre delete hook that can be implemented by users to perform any operations that need to be done before the standard delete functionality starts.protected voidsetDoneChanges(boolean doneChanges) Can be called by users (in subclasses ofDefaultDeleteFeature) to tell the framework that changes have been done that should reflect on the command stack.Methods inherited from class org.eclipse.graphiti.features.impl.AbstractFeature
addGraphicalRepresentation, canUndo, getAllBusinessObjectsForPictogramElement, getBusinessObjectForPictogramElement, getDiagram, getDiagramBehavior, getFeatureProvider, getProgressCallback, getUserDecision, isAvailable, layoutPictogramElement, link, link, manageColor, manageColor, manageDefaultFont, manageFont, manageFont, setProgressCallback, toString, updatePictogramElementMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.graphiti.features.IFeature
canUndo, isAvailableMethods inherited from interface org.eclipse.graphiti.features.IFeatureProviderHolder
getFeatureProvider
-
Constructor Details
-
DefaultDeleteFeature
Creates a newDefaultDeleteFeature.- Parameters:
fp- the feature provider
-
-
Method Details
-
canDelete
Description copied from interface:IDeleteCan delete hook. Needs to be implemented in order to decide if a feature can (and wants to) handle a delete request. -
delete
Description copied from interface:IDeleteHook to implement the actual delete functionality. -
deleteBusinessObjects
Standard functionality to delete all given domain objects.- Parameters:
businessObjects- the domain objects to delete
-
deleteBusinessObject
Standard functionality to delete one domain object. Will delegate forEObjects toEcoreUtil.delete(EObject, boolean); non-EMF objects will be ignored.- Parameters:
bo- the domain object to delete
-
preDelete
Description copied from interface:IDeletePre delete hook that can be implemented by users to perform any operations that need to be done before the standard delete functionality starts. Be sure to callDefaultDeleteFeature#setDoneChanges(boolean)in case you modify any EMF objects to enable that the command stack gets updated. -
isDeleteAbort
public boolean isDeleteAbort()Description copied from interface:IDeleteThe Graphiti framework will call this method afterIDelete.preDelete(IDeleteContext)has been called and before the actual delete is done. In case this method returnstrue, the operation will be cancelled by the Graphiti framework by throwing anOperationCanceledExceptionthat causes am EMF revert of the operation.Implementing classes might e.g. set a flag in
IDelete.preDelete(IDeleteContext)as cancellation indication and check that that flag here.- Specified by:
isDeleteAbortin interfaceIDelete- Returns:
truein case you want to cancel the current operation,falseotherwise.- Since:
- 0.12
-
postDelete
Description copied from interface:IDeletePost delete hook that can be implemented by users to perform any operations that need to be done after the standard delete functionality ends.- Specified by:
postDeletein interfaceIDelete- Parameters:
context- the context
-
canExecute
Description copied from interface:IFeatureDecides if the current feature can execute with the given context.- Specified by:
canExecutein interfaceIFeature- Parameters:
context- this is the general input for this method- Returns:
- true if the feature can be executed, false if not
- See Also:
-
execute
Description copied from interface:IFeatureExecutes the current feature with the given context. -
getName
Hook to return the name of the delete operation e.g for display in the context menu. The standard implementation simply returns "Delete".- Specified by:
getNamein interfaceIName- Overrides:
getNamein classAbstractFeature- Returns:
- The diplay name of the operation
-
getDescription
Description copied from interface:IDescriptionGets the description.- Specified by:
getDescriptionin interfaceIDescription- Overrides:
getDescriptionin classAbstractFeature- Returns:
- the description
-
hasDoneChanges
public boolean hasDoneChanges()Description copied from interface:IFeatureIs 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 inAbstractFeature), 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
falsealthough the feature did changes.- Specified by:
hasDoneChangesin interfaceIFeature- Overrides:
hasDoneChangesin classAbstractFeature- Returns:
trueif the feature should appear in the undo stack,falseotherwise
-
setDoneChanges
protected void setDoneChanges(boolean doneChanges) Can be called by users (in subclasses ofDefaultDeleteFeature) to tell the framework that changes have been done that should reflect on the command stack. The method is called by the standard implementation indelete(IDeleteContext)right after the first shape has been removed from the diagram.- Parameters:
doneChanges-truein case modifications have been made,falseotherwise- Since:
- 0.9
-
getUserDecision
Shows a dialog which asks the user to confirm the deletion of one or more elements.- Parameters:
context- delete context- Returns:
trueto delete element(s);falseto cancel delete
-
getDeleteName
Returns the delete name which will be used for the delete dialog. E.g. "file test.java". The default implementation returnsnullto indicate that the popup text refers to "this object".- Parameters:
context- the delete context- Returns:
- the delete name, or
nullto indicate no special name shall be used - Since:
- 0.8
-