org.eclipse.graphiti.pattern
Class AbstractPattern

java.lang.Object
  extended by org.eclipse.graphiti.pattern.AbstractBasePattern
      extended by org.eclipse.graphiti.pattern.AbstractPattern
All Implemented Interfaces:
IFeatureProviderHolder, IAdd, ICreate, ICreateInfo, IDelete, IDirectEditing, ILayout, IMoveShape, IRemove, IResizeShape, IUpdate, IPattern
Direct Known Subclasses:
TypedPattern

public abstract class AbstractPattern
extends AbstractBasePattern
implements IPattern

This is the base class AbstractConnectionPattern that clients writing a pattern for a shape domain object should subclass.


Field Summary
protected static String[] EMPTY_STRING_ARRAY
          An empty string array used in direct editing.
private  IPatternConfiguration patternConfiguration
           
private  IDeleteFeature wrappedDeleteFeature
          To avoid code duplication, this base class uses a wrapped default implementation of an IDeleteFeature to provide the default deletion behaviour.
private  IRemoveFeature wrappedRemoveFeature
          To avoid code duplication, this base class uses a wrapped default implementation of an IRemoveFeature to provide the default removal behavior.
 
Fields inherited from interface org.eclipse.graphiti.func.ICreate
EMPTY
 
Fields inherited from interface org.eclipse.graphiti.func.IDirectEditing
TYPE_CUSTOM, TYPE_DROPDOWN, TYPE_DROPDOWN_READ_ONLY, TYPE_MULTILINETEXT, TYPE_NONE, TYPE_TEXT
 
Constructor Summary
AbstractPattern()
          Creates a new AbstractPattern.
AbstractPattern(IPatternConfiguration patternConfiguration)
          Creates a new AbstractPattern holding the given IPatternConfiguration.
 
Method Summary
protected  void addGraphicalRepresentation(IAreaContext context, Object newObject)
          Adds the graphical representation of the given new Object with the information in the given IAreaContext.
protected  boolean avoidNegativeCoordinates()
          Clients can override to indicate that moving to negative coordinates should be possible.
 boolean canCreate(ICreateContext context)
          Clients must override this method to indicate that the pattern can be used to create domain objects as defined in the given ICreateContext.
 boolean canDelete(IDeleteContext context)
          Clients can override to modify the default behavior if the pattern can (and wants to) handle a delete request.
 boolean canDirectEdit(IDirectEditingContext context)
          Clients can override this method to indicate that the pattern allows direct editing for the shape described in the passed IDirectEditingContext.
 boolean canLayout(ILayoutContext context)
          Clients may override this method to indicate that the pattern can be used to layout a shape for a domain objects as defined in the given ILayoutContext.
 boolean canMoveShape(IMoveShapeContext context)
          Clients may override this method to indicate that the pattern can be used to move the shape of a domain objects as defined in the given IMoveShapeContext.
 boolean canRemove(IRemoveContext context)
          Clients can override to modify the default behavior if the pattern can (and wants to) handle a remove request.
 boolean canResizeShape(IResizeShapeContext context)
          Clients may override this method to indicate that the pattern can be used to resize the shape of a domain objects as defined in the given IResizeShapeContext.
 boolean canUpdate(IUpdateContext context)
          Clients may override this method to indicate that the pattern can be used to update the shape of a domain objects as defined in the given IUpdateContext.
 String checkValueValid(String value, IDirectEditingContext context)
          This method will be called by the framework to check if the passed String is valid as new value for the shape.
 void completeInfo(IDirectEditingInfo info, Object bo)
          Clients can override to complete the IDirectEditingInfo info.
 void completeInfo(IDirectEditingInfo info, Object bo, String keyProperty)
          Clients can override to complete the IDirectEditingInfo info.
 String completeValue(String value, int caretPos, String chosenValue, IDirectEditingContext context)
          Can be overridden by clients to define completion functionality for direct editing.
 Object[] create(ICreateContext context)
          Clients must override this method to implement the functionality to create a new domain object as defined in the given ICreateContext .
protected  IDeleteFeature createDeleteFeature(IDeleteContext context)
          Creates the IDeleteFeature instance that handles the deletion of business objects and diagram elements.
protected  IRemoveFeature createRemoveFeature(IRemoveContext context)
          Creates the IRemoveFeature instance that handles the removal of diagram elements.
 void delete(IDeleteContext context)
          Clients can override to modify the default delete behavior.
private  List<Anchor> getAnchors(ContainerShape containerShape)
           
 String getCreateDescription()
          Client should override to return a string description of the type of domain object that is created with this pattern.
 String getCreateImageId()
          Client should override to return a string id of the the image icon for the domain object that is created with this pattern.
 String getCreateLargeImageId()
          Client should override to return a string id of the the large image icon for the domain object that is created with this pattern.
 String getCreateName()
          Client should override to return the name of the domain object that is created with this pattern.
 int getEditingType()
          The Graphiti framework calls this method to decide which UI to show up for direct editing.
 String getInitialValue(IDirectEditingContext context)
          Provides the initial value for display in the newly opened text editing UI component.
protected  IPatternConfiguration getPatternConfiguration()
          Returns the IPatternConfiguration instance used within this pattern or null in case none is used.
 String[] getPossibleValues(IDirectEditingContext context)
          This value will be used if the cell editor is a combo box.
 IProposalSupport getProposalSupport()
          The direct editing mode contains controls for code completion and the selection from a combo box.
 IResizeConfiguration getResizeConfiguration(IResizeShapeContext context)
          Clients may override to modify the resize behavior.
 String[] getValueProposals(String value, int caretPos, IDirectEditingContext context)
          This proposals will be used for the completion list of a simple text cell editor.
 boolean hasDoneChanges(Class<?> actionType)
          Is queried by the framework after a pattern has been executed to find out if this pattern should appear in the undo stack.
protected  void internalMove(IMoveShapeContext context)
          Default implementation of the move functionality.
 boolean isAutoCompletionEnabled()
          Checks if auto completion is enabled.
 boolean isCompletionAvailable()
          Checks if completion is available.
 boolean isDeleteAbort()
          The Graphiti framework will call this method after IDelete.preDelete(IDeleteContext) has been called and before the actual delete is done.
abstract  boolean isMainBusinessObjectApplicable(Object mainBusinessObject)
          Clients must override this method to indicate that the pattern uses the given domain object as its main domain object.
 boolean isPaletteApplicable()
          Is queried by the Graphiti framework to check if the pattern should create a new domain object entry in the editor palette.
protected abstract  boolean isPatternControlled(PictogramElement pictogramElement)
          This method must be implemented by clients to indicate that the given PictogramElement is controlled by this pattern.
protected abstract  boolean isPatternRoot(PictogramElement pictogramElement)
          This method must be implemented by clients to indicate that the given PictogramElement is the root shape of this pattern.
 boolean isRemoveAbort()
          The Graphiti framework will call this method after IRemove.preRemove(IRemoveContext) has been called and before the actual remove is done.
 boolean layout(ILayoutContext context)
          Clients can override this method to implement the functionality to layout a shape for the given domain object as defined in the given ILayoutContext .
protected  void layoutPictogramElement(PictogramElement pe)
          Helper method that triggers a layout of the given PictogramElement.
protected  void moveAllBendpoints(IMoveShapeContext context)
          Default implementation of the move functionality to move all bendpoints within a container shape.
 void moveShape(IMoveShapeContext context)
          Clients can override this method to implement the functionality to move a shape for the given domain object as defined in the given IMoveShapeContext .
 void postDelete(IDeleteContext context)
          Clients can override to add actions after the default delete behavior is triggered.
protected  void postMoveShape(IMoveShapeContext context)
          Hook clients can override to add additional steps after the move of the shape happened.
 void postRemove(IRemoveContext context)
          Clients can override to add actions after the default remove behavior is triggered.
 void preDelete(IDeleteContext context)
          Clients can override to add actions before the default delete behavior is triggered.
protected  void preMoveShape(IMoveShapeContext context)
          Hook clients can override to add additional steps before the move of the shape happens.
 void preRemove(IRemoveContext context)
          Clients can override to add actions before the default remove behavior is triggered.
 void remove(IRemoveContext context)
          Clients can override to modify the default remove behavior.
 void resizeShape(IResizeShapeContext context)
          Clients can override this method to implement the functionality to resize a shape for the given domain object as defined in the given IResizeShapeContext .
protected  void setPatternConfiguration(IPatternConfiguration patternConfiguration)
          Sets the IPatternConfiguration instance to be used with this pattern.
 void setValue(String value, IDirectEditingContext context)
          Set the new value after direct editing is finished.
 boolean stretchFieldToFitText()
          Defines if the input field should be streched to fit its contents.
 boolean update(IUpdateContext context)
          Clients can override this method to implement the functionality to update a shape for the given domain object as defined in the given IUpdateContext.
 IReason updateNeeded(IUpdateContext context)
          Clients can override this method to indicate if an update of a shape for the given domain object as defined in the given IUpdateContext needs to be triggered.
protected  void updatePictogramElement(PictogramElement pe)
          Helper method that triggers an update of the given PictogramElement.
 
Methods inherited from class org.eclipse.graphiti.pattern.AbstractBasePattern
add, canAdd, getBusinessObjectForPictogramElement, getDiagram, getDiagramBehavior, getFeatureProvider, getMappingProvider, link, link, manageColor, manageColor, manageFont, manageFont, setFeatureProvider
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.graphiti.pattern.IPattern
add, canAdd, setFeatureProvider
 

Field Detail

EMPTY_STRING_ARRAY

protected static final String[] EMPTY_STRING_ARRAY
An empty string array used in direct editing.


patternConfiguration

private IPatternConfiguration patternConfiguration

wrappedDeleteFeature

private IDeleteFeature wrappedDeleteFeature
To avoid code duplication, this base class uses a wrapped default implementation of an IDeleteFeature to provide the default deletion behaviour. Subclasses may decide to either override createDeleteFeature(IDeleteContext) to provide another IDeleteFeature implementation or override and extend the individual IDelete methods or return a IDeleteFeature by overriding the method DefaultFeatureProviderWithPatterns.getDeleteFeature(IDeleteContext) .


wrappedRemoveFeature

private IRemoveFeature wrappedRemoveFeature
To avoid code duplication, this base class uses a wrapped default implementation of an IRemoveFeature to provide the default removal behavior. Subclasses may decide to either override createRemoveFeature(IRemoveContext) to provide another IRemoveFeature implementation or override and extend the individual IRemove methods or return a IRemoveFeature by overriding the method DefaultFeatureProviderWithPatterns.getRemoveFeature(IRemoveContext) .

Constructor Detail

AbstractPattern

public AbstractPattern(IPatternConfiguration patternConfiguration)
Creates a new AbstractPattern holding the given IPatternConfiguration.

Parameters:
patternConfiguration - The pattern configuration to use within this pattern instance of null in case no configuration is needed.

AbstractPattern

public AbstractPattern()
Creates a new AbstractPattern. This is a convenience method for patterns working without any configuration.

Since:
0.10
Method Detail

isPaletteApplicable

public boolean isPaletteApplicable()
Is queried by the Graphiti framework to check if the pattern should create a new domain object entry in the editor palette.

Specified by:
isPaletteApplicable in interface IPattern
Returns:
true in case a palette entry shall be created, false otherwise.

canCreate

public boolean canCreate(ICreateContext context)
Clients must override this method to indicate that the pattern can be used to create domain objects as defined in the given ICreateContext. Corresponds to the method ICreate.canCreate(ICreateContext) . The default implementation simply returns false.

Specified by:
canCreate in interface ICreate
Parameters:
context - The context holding information on the domain object to be created.
Returns:
true in case this pattern can create such a domain object, false otherwise.

canLayout

public boolean canLayout(ILayoutContext context)
Clients may override this method to indicate that the pattern can be used to layout a shape for a domain objects as defined in the given ILayoutContext. Corresponds to the method ILayout.canLayout(ILayoutContext). The default implementation checks if the PictogramElement in the given context isPatternControlled(PictogramElement).

Specified by:
canLayout in interface ILayout
Parameters:
context - The context holding information on the domain object to be layouted.
Returns:
true in case this pattern can layout a shape for such a domain object, false otherwise.

canMoveShape

public boolean canMoveShape(IMoveShapeContext context)
Clients may override this method to indicate that the pattern can be used to move the shape of a domain objects as defined in the given IMoveShapeContext. Corresponds to the method DefaultMoveShapeFeature.canMoveShape(IMoveShapeContext). The default implementation checks if the PictogramElement in the given context isPatternControlled(PictogramElement) and the source and target containers of the shape are the same.

Specified by:
canMoveShape in interface IMoveShape
Parameters:
context - The context holding information on the domain object to be moved.
Returns:
true in case this pattern can move a shape for such a domain object, false otherwise.

canResizeShape

public boolean canResizeShape(IResizeShapeContext context)
Clients may override this method to indicate that the pattern can be used to resize the shape of a domain objects as defined in the given IResizeShapeContext. Corresponds to the method DefaultResizeShapeFeature.canResizeShape(IResizeShapeContext). The default implementation checks if the PictogramElement in the given context fulfills isPatternRoot(PictogramElement).

Specified by:
canResizeShape in interface IResizeShape
Parameters:
context - The context holding information on the domain object to be resized.
Returns:
true in case this pattern can resize a shape for such a domain object, false otherwise.

canUpdate

public boolean canUpdate(IUpdateContext context)
Clients may override this method to indicate that the pattern can be used to update the shape of a domain objects as defined in the given IUpdateContext. Corresponds to the method IUpdate.canUpdate(IUpdateContext). The default implementation checks if the PictogramElement in the given context isPatternControlled(PictogramElement).

Specified by:
canUpdate in interface IUpdate
Parameters:
context - The context holding information on the domain object to be updated.
Returns:
true in case this pattern can update a shape for such a domain object, false otherwise.

create

public Object[] create(ICreateContext context)
Clients must override this method to implement the functionality to create a new domain object as defined in the given ICreateContext . Corresponds to the method ICreate.create(ICreateContext). The default implementation simply does nothing and returns an empty object array.

Specified by:
create in interface ICreate
Parameters:
context - The context holding information on the domain object to be created.
Returns:
An array of the newly create domain objects.

getCreateDescription

public String getCreateDescription()
Client should override to return a string description of the type of domain object that is created with this pattern. The Graphiti framework uses this information to fill a tooltip for the creation tool entry in the palette. The default implementation simply returns null which indicates that no tooltip shall be displayed.

Specified by:
getCreateDescription in interface ICreateInfo
Specified by:
getCreateDescription in interface IPattern
Returns:
A String holding the tooltip

getCreateImageId

public String getCreateImageId()
Client should override to return a string id of the the image icon for the domain object that is created with this pattern. The Graphiti framework uses this information to add an icon to the creation tool entry in the palette. The default implementation simply returns null which indicates that no icon shall be displayed.

Specified by:
getCreateImageId in interface ICreateInfo
Returns:
A String holding the id of the icon as defined in the AbstractImageProvider.

getCreateLargeImageId

public String getCreateLargeImageId()
Client should override to return a string id of the the large image icon for the domain object that is created with this pattern. The Graphiti framework uses this information to add a large icon to the creation tool entry in the palette. The default implementation simply returns null which indicates that no icon shall be displayed.

Specified by:
getCreateLargeImageId in interface ICreateInfo
Returns:
A String holding the id of the large icon as defined in the AbstractImageProvider.

getCreateName

public String getCreateName()
Client should override to return the name of the domain object that is created with this pattern. The Graphiti framework uses this information to fill the text for the creation tool entry in the palette. The default implementation simply returns null which results in an empty entry in the palette.

Specified by:
getCreateName in interface ICreateInfo
Specified by:
getCreateName in interface IPattern
Returns:
A String holding the name of the domain object.

isMainBusinessObjectApplicable

public abstract boolean isMainBusinessObjectApplicable(Object mainBusinessObject)
Clients must override this method to indicate that the pattern uses the given domain object as its main domain object.

Specified by:
isMainBusinessObjectApplicable in interface IPattern
Parameters:
mainBusinessObject - The object to check if it is the main domain object of the pattern.
Returns:
true in case the pattern has the given domain object as its main domain object, false otherwise.

layout

public boolean layout(ILayoutContext context)
Clients can override this method to implement the functionality to layout a shape for the given domain object as defined in the given ILayoutContext . Corresponds to the method ILayout.layout(ILayoutContext). The default implementation simply does nothing and returns false as indication of this.

Specified by:
layout in interface ILayout
Parameters:
context - The context holding information on the domain object to be layouted.
Returns:
Should return true in case a layout happened and false in case none happened. Is used by the Graphiti framework for performance optimization.

moveShape

public void moveShape(IMoveShapeContext context)
Clients can override this method to implement the functionality to move a shape for the given domain object as defined in the given IMoveShapeContext . Corresponds to the method DefaultMoveShapeFeature.moveShape(IMoveShapeContext).

Specified by:
moveShape in interface IMoveShape
Parameters:
context - The context holding information on the domain object to be moved.

postMoveShape

protected void postMoveShape(IMoveShapeContext context)
Hook clients can override to add additional steps after the move of the shape happened.

Parameters:
context - The context holding information on the domain object that was moved.

preMoveShape

protected void preMoveShape(IMoveShapeContext context)
Hook clients can override to add additional steps before the move of the shape happens.

Parameters:
context - The context holding information on the domain object to be moved.

internalMove

protected void internalMove(IMoveShapeContext context)
Default implementation of the move functionality. Moves shapes to new coordinates and adapts parents in case this is needed.

Parameters:
context - The context holding information on the domain object to be moved.

moveAllBendpoints

protected void moveAllBendpoints(IMoveShapeContext context)
Default implementation of the move functionality to move all bendpoints within a container shape.

Parameters:
context - The context holding information on the domain object to be moved.

getAnchors

private List<Anchor> getAnchors(ContainerShape containerShape)

resizeShape

public void resizeShape(IResizeShapeContext context)
Clients can override this method to implement the functionality to resize a shape for the given domain object as defined in the given IResizeShapeContext . Corresponds to the method DefaultResizeShapeFeature.resizeShape(IResizeShapeContext).

Specified by:
resizeShape in interface IResizeShape
Parameters:
context - The context holding information on the domain object to be resized.

update

public boolean update(IUpdateContext context)
Clients can override this method to implement the functionality to update a shape for the given domain object as defined in the given IUpdateContext. Corresponds to the method IUpdate.update(IUpdateContext).

Specified by:
update in interface IUpdate
Parameters:
context - The context holding information on the domain object to be updated.
Returns:
true, if update process was successfull

updateNeeded

public IReason updateNeeded(IUpdateContext context)
Clients can override this method to indicate if an update of a shape for the given domain object as defined in the given IUpdateContext needs to be triggered. Corresponds to the method IUpdate.updateNeeded(IUpdateContext).

Specified by:
updateNeeded in interface IUpdate
Parameters:
context - The context holding information on the domain object to be updated.
Returns:
true if parts of the pictogram model needs to be updated with the latest values from the business model

addGraphicalRepresentation

protected void addGraphicalRepresentation(IAreaContext context,
                                          Object newObject)
Adds the graphical representation of the given new Object with the information in the given IAreaContext.

Parameters:
context - The area context defining where the new object should placed
newObject - The new object instance itself

avoidNegativeCoordinates

protected boolean avoidNegativeCoordinates()
Clients can override to indicate that moving to negative coordinates should be possible. The default implementation prohibits this by returning false.

Returns:
true in case moving a shape to negative coordinates should be possible, false otherwise.

isPatternControlled

protected abstract boolean isPatternControlled(PictogramElement pictogramElement)
This method must be implemented by clients to indicate that the given PictogramElement is controlled by this pattern.

Parameters:
pictogramElement - The pictogram element to check
Returns:
true in case the pictogram element is controlled by this pattern, false otherwise.

isPatternRoot

protected abstract boolean isPatternRoot(PictogramElement pictogramElement)
This method must be implemented by clients to indicate that the given PictogramElement is the root shape of this pattern.

Parameters:
pictogramElement - The pictogram element to check
Returns:
true in case the pictogram element is the root shape of this pattern, false otherwise.

layoutPictogramElement

protected void layoutPictogramElement(PictogramElement pe)
Helper method that triggers a layout of the given PictogramElement. The default implementation queries the feature provider and tries to find a functionality either in the pattern of an additional AbstractLayoutFeature that can handle the request and triggers the operation.

Parameters:
pe - The pictogram element to layout

updatePictogramElement

protected void updatePictogramElement(PictogramElement pe)
Helper method that triggers an update of the given PictogramElement. The default implementation queries the feature provider and tries to find a functionality either in the pattern of an additional AbstractUpdateFeature that can handle the request and triggers the operation.

Parameters:
pe - The pictogram element to update

setPatternConfiguration

protected void setPatternConfiguration(IPatternConfiguration patternConfiguration)
Sets the IPatternConfiguration instance to be used with this pattern.

Parameters:
patternConfiguration - The new patternConfiguration

getPatternConfiguration

protected IPatternConfiguration getPatternConfiguration()
Returns the IPatternConfiguration instance used within this pattern or null in case none is used.

Returns:
The patternConfiguration instance or null it there is none set

completeInfo

public void completeInfo(IDirectEditingInfo info,
                         Object bo)
Clients can override to complete the IDirectEditingInfo info. This information is needed to switch automatically into the direct editing mode. (e.g. after creation of a new object).

Specified by:
completeInfo in interface IPattern
Parameters:
info - The direct editing info
bo - The domain object

completeInfo

public void completeInfo(IDirectEditingInfo info,
                         Object bo,
                         String keyProperty)
Clients can override to complete the IDirectEditingInfo info. This information is needed to switch automatically into the direct editing mode. (e.g. after creation of a new object)

Specified by:
completeInfo in interface IPattern
Parameters:
info - The direct editing info
bo - The domain object
keyProperty - The key property

getResizeConfiguration

public IResizeConfiguration getResizeConfiguration(IResizeShapeContext context)
Clients may override to modify the resize behavior. The default implementation returns a new instance of DefaultResizeConfiguration, which allows bothe the horizontal and vertical resize of a shape.

Specified by:
getResizeConfiguration in interface IPattern
Parameters:
context - Context object holding information about the shape to be resized.
Returns:
An instance of IResizeConfiguration defining the resize behavior.

createDeleteFeature

protected IDeleteFeature createDeleteFeature(IDeleteContext context)
Creates the IDeleteFeature instance that handles the deletion of business objects and diagram elements. The default implementation just creates an adapted DefaultDeleteFeature. Concrete pattern implementations may either override this method to provide their own subclass of DefaultDeleteFeature or override and extend the individual methods provided by IDelete.

The difference of the delete feature returned here to the standard DefaultDeleteFeature is simply that the instance returned here cares about the delegation to the pattern's preDelete(IDeleteContext), isDeleteAbort() and postDelete(IDeleteContext) methods. Clients overriding this method should re-implement that pattern, in case the delegation is desired.

Parameters:
context - the deletion context
Returns:
the IDeleteFeature instance to use for this pattern
See Also:
canDelete(IDeleteContext), preDelete(IDeleteContext), isDeleteAbort(), delete(IDeleteContext), postDelete(IDeleteContext)

canDelete

public boolean canDelete(IDeleteContext context)
Clients can override to modify the default behavior if the pattern can (and wants to) handle a delete request. The default implementation calls createDeleteFeature(IDeleteContext) and asks the result's canDelete method.

Specified by:
canDelete in interface IDelete
Parameters:
context - The context describing the delete request
Returns:
true, if the pattern can perform the delete operation, false otherwise

preDelete

public void preDelete(IDeleteContext context)
Clients can override to add actions before the default delete behavior is triggered. The default implementation does nothing and is called from the registered delete feature.

Specified by:
preDelete in interface IDelete
Parameters:
context - The context describing the delete request

delete

public void delete(IDeleteContext context)
Clients can override to modify the default delete behavior. The default implementation calls createDeleteFeature(IDeleteContext) and triggers the result's delete method.

Specified by:
delete in interface IDelete
Parameters:
context - The context describing the delete request

postDelete

public void postDelete(IDeleteContext context)
Clients can override to add actions after the default delete behavior is triggered. The default implementation does nothing and is called from the registered delete feature.

Specified by:
postDelete in interface IDelete
Parameters:
context - The context describing the delete request

createRemoveFeature

protected IRemoveFeature createRemoveFeature(IRemoveContext context)
Creates the IRemoveFeature instance that handles the removal of diagram elements. The default implementation just creates an adapted DefaultRemoveFeature. Concrete pattern implementations may either override this method to provide their own subclass of DefaultRemoveFeature or override and extend the individual methods provided by IRemove.

The difference of the remove feature returned here to the standard DefaultRemoveFeature is simply that the instance returned here cares about the delegation to the pattern's preRemove(IRemoveContext), isRemoveAbort() and postRemove(IRemoveContext) methods. Clients overriding this method should re-implement that pattern, in case the delegation is desired.

Parameters:
context - the removal context
Returns:
the IRemoveFeature instance to use for this pattern
See Also:
canRemove(IRemoveContext), preRemove(IRemoveContext), isRemoveAbort(), remove(IRemoveContext), postRemove(IRemoveContext)

canRemove

public boolean canRemove(IRemoveContext context)
Clients can override to modify the default behavior if the pattern can (and wants to) handle a remove request. The default implementation calls createRemoveFeature(IRemoveContext) and asks the result's canRemove method.

Specified by:
canRemove in interface IRemove
Parameters:
context - The context describing the remove request
Returns:
true, if the pattern can perform the delete operation, false otherwise

preRemove

public void preRemove(IRemoveContext context)
Clients can override to add actions before the default remove behavior is triggered. The default implementation does nothing and is called from the registered remove feature.

Specified by:
preRemove in interface IRemove
Parameters:
context - The context describing the remove request

remove

public void remove(IRemoveContext context)
Clients can override to modify the default remove behavior. The default implementation calls createRemoveFeature(IRemoveContext) and triggers the result's remove method.

Specified by:
remove in interface IRemove
Parameters:
context - The context describing the remove request

postRemove

public void postRemove(IRemoveContext context)
Clients can override to add actions after the default remove behavior is triggered. The default implementation does nothing and is called from the registered remove feature.

Specified by:
postRemove in interface IRemove
Parameters:
context - The context describing the remove request

canDirectEdit

public boolean canDirectEdit(IDirectEditingContext context)
Clients can override this method to indicate that the pattern allows direct editing for the shape described in the passed IDirectEditingContext. Corresponds to the method AbstractDirectEditingFeature.canDirectEdit(IDirectEditingContext) . The default implementation simply returns false.

Specified by:
canDirectEdit in interface IDirectEditing
Parameters:
context - A context object describing the direct edit request.
Returns:
true in case direct editing shall be allowed, false otherwise.
See Also:
IFeature.canExecute(org.eclipse.graphiti.features.context.IContext)

checkValueValid

public String checkValueValid(String value,
                              IDirectEditingContext context)
This method will be called by the framework to check if the passed String is valid as new value for the shape. This method's response time should be small since the method is queried after each change of the value in the direct edit UI. The default implementation simply returns null to indicate that all values are valid. In case of a not valid value, the returned string shall indicate the reason why the value is not valid. Corresponds to the method AbstractDirectEditingFeature.checkValueValid(String, IDirectEditingContext) .

Specified by:
checkValueValid in interface IDirectEditing
Parameters:
value - The new value to check
context - A context object describing the direct edit request.
Returns:
null in case of a valid value, a string describing the reason for being not valid otherwise.

completeValue

public String completeValue(String value,
                            int caretPos,
                            String chosenValue,
                            IDirectEditingContext context)
Can be overridden by clients to define completion functionality for direct editing. Corresponds to AbstractDirectEditingFeature.completeValue(String, int, String, IDirectEditingContext) . The default implementation simply returns the parameter chosenValue.

Specified by:
completeValue in interface IDirectEditing
Parameters:
value - The current value
caretPosition - The current cursor position
choosenValue - The value chosen by user
context - A context object describing the direct edit request.
Returns:
The new value

getPossibleValues

public String[] getPossibleValues(IDirectEditingContext context)
This value will be used if the cell editor is a combo box. This functionality only applies to TYPE_DROPDOWN. Corresponds to the method AbstractDirectEditingFeature.getPossibleValues(IDirectEditingContext) . The default implementation returns an empty string array.

Specified by:
getPossibleValues in interface IDirectEditing
Parameters:
context - A context object describing the direct edit request.
Returns:
The possible values for the combo box.

getValueProposals

public String[] getValueProposals(String value,
                                  int caretPos,
                                  IDirectEditingContext context)
This proposals will be used for the completion list of a simple text cell editor. This functionality only applies to TYPE_TEXT. Corresponds to the method AbstractDirectEditingFeature.getValueProposals(String, int, IDirectEditingContext) . The default implementation returns an empty string array.

Specified by:
getValueProposals in interface IDirectEditing
Parameters:
value - The current value
caretPosition - The current cursor position
context - A context object describing the direct edit request.
Returns:
The proposed values

isAutoCompletionEnabled

public boolean isAutoCompletionEnabled()
Checks if auto completion is enabled. This functionality only applies to TYPE_TEXT. Corresponds to method AbstractDirectEditingFeature.isAutoCompletionEnabled(). The default implementation simply returns false.

Specified by:
isAutoCompletionEnabled in interface IDirectEditing
Returns:
true, if proposals should appear automatically, false otherwise.

isCompletionAvailable

public boolean isCompletionAvailable()
Checks if completion is available. This functionality only applies to TYPE_TEXT. Corresponds to method AbstractDirectEditingFeature.isCompletionAvailable(). The default implementation simply returns false.

Specified by:
isCompletionAvailable in interface IDirectEditing
Returns:
true if completion is / proposals are available at all, false otherwise.

stretchFieldToFitText

public boolean stretchFieldToFitText()
Defines if the input field should be streched to fit its contents. This functionality applies to TYPE_TEXT, TYPE_DROPDOWN and TYPE_DROPDOWN_READ_ONLY. Corresponds to method AbstractDirectEditingFeature.stretchFieldToFitText(). The default implementation simply returns false.

Specified by:
stretchFieldToFitText in interface IDirectEditing
Returns:
true if the field should exactly fit the contents, false otherwise.

getEditingType

public int getEditingType()
The Graphiti framework calls this method to decide which UI to show up for direct editing. Corresponds to the method IDirectEditing.getEditingType(). The default implementation return IDirectEditing.TYPE_NONE, other valid type are defined by the TYPE_* constants in IDirectEditing.

Specified by:
getEditingType in interface IDirectEditing
Returns:
The desired editing type

getInitialValue

public String getInitialValue(IDirectEditingContext context)
Provides the initial value for display in the newly opened text editing UI component. Corresponds to the method IDirectEditing.getInitialValue(IDirectEditingContext) . The default implementation always returns an empty string.

Specified by:
getInitialValue in interface IDirectEditing
Parameters:
context - A context object describing the direct edit request.
Returns:
The initial string value to be displayed for editing by the user.

setValue

public void setValue(String value,
                     IDirectEditingContext context)
Set the new value after direct editing is finished. The value comes from the text editing UI component. Corresponds to the method AbstractDirectEditingFeature.setValue(String, IDirectEditingContext) . The default implementation does nothing.

Specified by:
setValue in interface IDirectEditing
Parameters:
value - The new value to be set
context - A context object describing the direct edit request.

getProposalSupport

public IProposalSupport getProposalSupport()
The direct editing mode contains controls for code completion and the selection from a combo box. In both cases the standard implementation supports only strings.

If the client wants to work with Objects he must provide an implementation of IProposalSupport. In this case the following methods of the pattern are ignored:


* String checkValueValid(String value, IDirectEditingContext context);
* String completeValue(String value, int caretPosition, String choosenValue, IDirectEditingContext context);
* String[] getPossibleValues(IDirectEditingContext context);
* String[] getValueProposals(String value, int caretPosition, IDirectEditingContext context);
* void setValue(String value, IDirectEditingContext context);

Corresponds to the method AbstractDirectEditingFeature.getProposalSupport(). The default implementation returns null to enable the standard string-based direct editing functionality.

Specified by:
getProposalSupport in interface IDirectEditing
Returns:
The special implementation to support Objects in code completion and combo box
Since:
0.8

hasDoneChanges

public boolean hasDoneChanges(Class<?> actionType)
Is queried by the framework after a pattern has been executed to find out if this pattern should appear in the undo stack. By default all patterns should appear there (see implementation in AbstractPattern), but single pattern functionality may decide to override this behavior. Note that this is a dynamic attribute of the pattern that is queried each time after the pattern functionality has been executed.

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

Specified by:
hasDoneChanges in interface IPattern
Parameters:
actionType - the followings types are currently supported: IDelete.class, IRemove.class
Returns:
true if the last action of the pattern from this action type should appear in the undo stack, false otherwise
Since:
0.9

isDeleteAbort

public boolean isDeleteAbort()
Description copied from interface: IDelete
The Graphiti framework will call this method after IDelete.preDelete(IDeleteContext) has been called and before the actual delete 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 IDelete.preDelete(IDeleteContext) as cancellation indication and check that that flag here.

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

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
Returns:
true in case you want to cancel the current operation, false otherwise.
Since:
0.12


Copyright (c) SAP AG 2005, 2012.