Class AbstractPattern
- java.lang.Object
-
- org.eclipse.graphiti.pattern.AbstractBasePattern
-
- 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
Fields Modifier and Type Field Description protected static java.lang.String[]EMPTY_STRING_ARRAYAn empty string array used in direct editing.-
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
Constructors Constructor Description AbstractPattern()Creates a newAbstractPattern.AbstractPattern(IPatternConfiguration patternConfiguration)Creates a newAbstractPatternholding the givenIPatternConfiguration.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddGraphicalRepresentation(IAreaContext context, java.lang.Object newObject)Adds the graphical representation of the given newObjectwith the information in the givenIAreaContext.protected booleanavoidNegativeCoordinates()Clients can override to indicate that moving to negative coordinates should be possible.booleancanCreate(ICreateContext context)Clients must override this method to indicate that the pattern can be used to create domain objects as defined in the givenICreateContext.booleancanDelete(IDeleteContext context)Clients can override to modify the default behavior if the pattern can (and wants to) handle a delete request.booleancanDirectEdit(IDirectEditingContext context)Clients can override this method to indicate that the pattern allows direct editing for the shape described in the passedIDirectEditingContext.booleancanLayout(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 givenILayoutContext.booleancanMoveShape(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 givenIMoveShapeContext.booleancanRemove(IRemoveContext context)Clients can override to modify the default behavior if the pattern can (and wants to) handle a remove request.booleancanResizeShape(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 givenIResizeShapeContext.booleancanUpdate(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 givenIUpdateContext.java.lang.StringcheckValueValid(java.lang.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.voidcompleteInfo(IDirectEditingInfo info, java.lang.Object bo)Clients can override to complete theIDirectEditingInfoinfo.voidcompleteInfo(IDirectEditingInfo info, java.lang.Object bo, java.lang.String keyProperty)Clients can override to complete theIDirectEditingInfoinfo.java.lang.StringcompleteValue(java.lang.String value, int caretPos, java.lang.String chosenValue, IDirectEditingContext context)Can be overridden by clients to define completion functionality for direct editing.java.lang.Object[]create(ICreateContext context)Clients must override this method to implement the functionality to create a new domain object as defined in the givenICreateContext.protected IDeleteFeaturecreateDeleteFeature(IDeleteContext context)Creates theIDeleteFeatureinstance that handles the deletion of business objects and diagram elements.protected IRemoveFeaturecreateRemoveFeature(IRemoveContext context)Creates theIRemoveFeatureinstance that handles the removal of diagram elements.voiddelete(IDeleteContext context)Clients can override to modify the default delete behavior.java.lang.StringgetCreateDescription()Client should override to return a string description of the type of domain object that is created with this pattern.java.lang.StringgetCreateImageId()Client should override to return a string id of the the image icon for the domain object that is created with this pattern.java.lang.StringgetCreateLargeImageId()Client should override to return a string id of the the large image icon for the domain object that is created with this pattern.java.lang.StringgetCreateName()Client should override to return the name of the domain object that is created with this pattern.intgetEditingType()The Graphiti framework calls this method to decide which UI to show up for direct editing.java.lang.StringgetInitialValue(IDirectEditingContext context)Provides the initial value for display in the newly opened text editing UI component.protected IPatternConfigurationgetPatternConfiguration()Returns theIPatternConfigurationinstance used within this pattern ornullin case none is used.java.lang.String[]getPossibleValues(IDirectEditingContext context)This value will be used if the cell editor is a combo box.IProposalSupportgetProposalSupport()The direct editing mode contains controls for code completion and the selection from a combo box.IResizeConfigurationgetResizeConfiguration(IResizeShapeContext context)Clients may override to modify the resize behavior.java.lang.String[]getValueProposals(java.lang.String value, int caretPos, IDirectEditingContext context)This proposals will be used for the completion list of a simple text cell editor.booleanhasDoneChanges(java.lang.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 voidinternalMove(IMoveShapeContext context)Default implementation of the move functionality.booleanisAutoCompletionEnabled()Checks if auto completion is enabled.booleanisCompletionAvailable()Checks if completion is available.booleanisDeleteAbort()The Graphiti framework will call this method afterIDelete.preDelete(IDeleteContext)has been called and before the actual delete is done.abstract booleanisMainBusinessObjectApplicable(java.lang.Object mainBusinessObject)Clients must override this method to indicate that the pattern uses the given domain object as its main domain object.booleanisPaletteApplicable()Is queried by the Graphiti framework to check if the pattern should create a new domain object entry in the editor palette.protected abstract booleanisPatternControlled(PictogramElement pictogramElement)This method must be implemented by clients to indicate that the givenPictogramElementis controlled by this pattern.protected abstract booleanisPatternRoot(PictogramElement pictogramElement)This method must be implemented by clients to indicate that the givenPictogramElementis the root shape of this pattern.booleanisRemoveAbort()The Graphiti framework will call this method afterIRemove.preRemove(IRemoveContext)has been called and before the actual remove is done.booleanlayout(ILayoutContext context)Clients can override this method to implement the functionality to layout a shape for the given domain object as defined in the givenILayoutContext.protected voidlayoutPictogramElement(PictogramElement pe)Helper method that triggers a layout of the givenPictogramElement.protected voidmoveAllBendpoints(IMoveShapeContext context)Default implementation of the move functionality to move all bendpoints within a container shape.voidmoveShape(IMoveShapeContext context)Clients can override this method to implement the functionality to move a shape for the given domain object as defined in the givenIMoveShapeContext.voidpostDelete(IDeleteContext context)Clients can override to add actions after the default delete behavior is triggered.protected voidpostMoveShape(IMoveShapeContext context)Hook clients can override to add additional steps after the move of the shape happened.voidpostRemove(IRemoveContext context)Clients can override to add actions after the default remove behavior is triggered.voidpreDelete(IDeleteContext context)Clients can override to add actions before the default delete behavior is triggered.protected voidpreMoveShape(IMoveShapeContext context)Hook clients can override to add additional steps before the move of the shape happens.voidpreRemove(IRemoveContext context)Clients can override to add actions before the default remove behavior is triggered.voidremove(IRemoveContext context)Clients can override to modify the default remove behavior.voidresizeShape(IResizeShapeContext context)Clients can override this method to implement the functionality to resize a shape for the given domain object as defined in the givenIResizeShapeContext.protected voidsetPatternConfiguration(IPatternConfiguration patternConfiguration)Sets theIPatternConfigurationinstance to be used with this pattern.voidsetValue(java.lang.String value, IDirectEditingContext context)Set the new value after direct editing is finished.booleanstretchFieldToFitText()Defines if the input field should be streched to fit its contents.booleanupdate(IUpdateContext context)Clients can override this method to implement the functionality to update a shape for the given domain object as defined in the givenIUpdateContext.IReasonupdateNeeded(IUpdateContext context)Clients can override this method to indicate if an update of a shape for the given domain object as defined in the givenIUpdateContextneeds to be triggered.protected voidupdatePictogramElement(PictogramElement pe)Helper method that triggers an update of the givenPictogramElement.-
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
-
-
-
-
Constructor Detail
-
AbstractPattern
public AbstractPattern(IPatternConfiguration patternConfiguration)
Creates a newAbstractPatternholding the givenIPatternConfiguration.- Parameters:
patternConfiguration- The pattern configuration to use within this pattern instance ofnullin case no configuration is needed.
-
AbstractPattern
public AbstractPattern()
Creates a newAbstractPattern. 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:
isPaletteApplicablein interfaceIPattern- Returns:
truein case a palette entry shall be created,falseotherwise.
-
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 givenICreateContext. Corresponds to the methodICreate.canCreate(ICreateContext). The default implementation simply returnsfalse.
-
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 givenILayoutContext. Corresponds to the methodILayout.canLayout(ILayoutContext). The default implementation checks if thePictogramElementin the given contextisPatternControlled(PictogramElement).
-
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 givenIMoveShapeContext. Corresponds to the methodDefaultMoveShapeFeature.canMoveShape(IMoveShapeContext). The default implementation checks if thePictogramElementin the given contextisPatternControlled(PictogramElement)and the source and target containers of the shape are the same.- Specified by:
canMoveShapein interfaceIMoveShape- Parameters:
context- The context holding information on the domain object to be moved.- Returns:
truein case this pattern can move a shape for such a domain object,falseotherwise.
-
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 givenIResizeShapeContext. Corresponds to the methodDefaultResizeShapeFeature.canResizeShape(IResizeShapeContext). The default implementation checks if thePictogramElementin the given context fulfillsisPatternRoot(PictogramElement).- Specified by:
canResizeShapein interfaceIResizeShape- Parameters:
context- The context holding information on the domain object to be resized.- Returns:
truein case this pattern can resize a shape for such a domain object,falseotherwise.
-
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 givenIUpdateContext. Corresponds to the methodIUpdate.canUpdate(IUpdateContext). The default implementation checks if thePictogramElementin the given contextisPatternControlled(PictogramElement).
-
create
public java.lang.Object[] create(ICreateContext context)
Clients must override this method to implement the functionality to create a new domain object as defined in the givenICreateContext. Corresponds to the methodICreate.create(ICreateContext). The default implementation simply does nothing and returns an empty object array.
-
getCreateDescription
public java.lang.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 returnsnullwhich indicates that no tooltip shall be displayed.- Specified by:
getCreateDescriptionin interfaceICreateInfo- Specified by:
getCreateDescriptionin interfaceIPattern- Returns:
- A
Stringholding the tooltip
-
getCreateImageId
public java.lang.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 returnsnullwhich indicates that no icon shall be displayed.- Specified by:
getCreateImageIdin interfaceICreateInfo- Returns:
- A
Stringholding the id of the icon as defined in the AbstractImageProvider.
-
getCreateLargeImageId
public java.lang.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 returnsnullwhich indicates that no icon shall be displayed.- Specified by:
getCreateLargeImageIdin interfaceICreateInfo- Returns:
- A
Stringholding the id of the large icon as defined in the AbstractImageProvider.
-
getCreateName
public java.lang.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 returnsnullwhich results in an empty entry in the palette.- Specified by:
getCreateNamein interfaceICreateInfo- Specified by:
getCreateNamein interfaceIPattern- Returns:
- A
Stringholding the name of the domain object.
-
isMainBusinessObjectApplicable
public abstract boolean isMainBusinessObjectApplicable(java.lang.Object mainBusinessObject)
Clients must override this method to indicate that the pattern uses the given domain object as its main domain object.- Specified by:
isMainBusinessObjectApplicablein interfaceIPattern- Parameters:
mainBusinessObject- The object to check if it is the main domain object of the pattern.- Returns:
truein case the pattern has the given domain object as its main domain object,falseotherwise.
-
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 givenILayoutContext. Corresponds to the methodILayout.layout(ILayoutContext). The default implementation simply does nothing and returnsfalseas indication of this.
-
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 givenIMoveShapeContext. Corresponds to the methodDefaultMoveShapeFeature.moveShape(IMoveShapeContext).- Specified by:
moveShapein interfaceIMoveShape- 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.
-
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 givenIResizeShapeContext. Corresponds to the methodDefaultResizeShapeFeature.resizeShape(IResizeShapeContext).- Specified by:
resizeShapein interfaceIResizeShape- 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 givenIUpdateContext. Corresponds to the methodIUpdate.update(IUpdateContext).
-
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 givenIUpdateContextneeds to be triggered. Corresponds to the methodIUpdate.updateNeeded(IUpdateContext).- Specified by:
updateNeededin interfaceIUpdate- 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, java.lang.Object newObject)
Adds the graphical representation of the given newObjectwith the information in the givenIAreaContext.- Parameters:
context- The area context defining where the new object should placednewObject- 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:
truein case moving a shape to negative coordinates should be possible,falseotherwise.
-
isPatternControlled
protected abstract boolean isPatternControlled(PictogramElement pictogramElement)
This method must be implemented by clients to indicate that the givenPictogramElementis controlled by this pattern.- Parameters:
pictogramElement- The pictogram element to check- Returns:
truein case the pictogram element is controlled by this pattern,falseotherwise.
-
isPatternRoot
protected abstract boolean isPatternRoot(PictogramElement pictogramElement)
This method must be implemented by clients to indicate that the givenPictogramElementis the root shape of this pattern.- Parameters:
pictogramElement- The pictogram element to check- Returns:
truein case the pictogram element is the root shape of this pattern,falseotherwise.
-
layoutPictogramElement
protected void layoutPictogramElement(PictogramElement pe)
Helper method that triggers a layout of the givenPictogramElement. The default implementation queries the feature provider and tries to find a functionality either in the pattern of an additionalAbstractLayoutFeaturethat 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 givenPictogramElement. The default implementation queries the feature provider and tries to find a functionality either in the pattern of an additionalAbstractUpdateFeaturethat can handle the request and triggers the operation.- Parameters:
pe- The pictogram element to update
-
setPatternConfiguration
protected void setPatternConfiguration(IPatternConfiguration patternConfiguration)
Sets theIPatternConfigurationinstance to be used with this pattern.- Parameters:
patternConfiguration- The new patternConfiguration
-
getPatternConfiguration
protected IPatternConfiguration getPatternConfiguration()
Returns theIPatternConfigurationinstance used within this pattern ornullin case none is used.- Returns:
- The patternConfiguration instance or
nullit there is none set
-
completeInfo
public void completeInfo(IDirectEditingInfo info, java.lang.Object bo)
Clients can override to complete theIDirectEditingInfoinfo. This information is needed to switch automatically into the direct editing mode. (e.g. after creation of a new object).- Specified by:
completeInfoin interfaceIPattern- Parameters:
info- The direct editing infobo- The domain object
-
completeInfo
public void completeInfo(IDirectEditingInfo info, java.lang.Object bo, java.lang.String keyProperty)
Clients can override to complete theIDirectEditingInfoinfo. This information is needed to switch automatically into the direct editing mode. (e.g. after creation of a new object)- Specified by:
completeInfoin interfaceIPattern- Parameters:
info- The direct editing infobo- The domain objectkeyProperty- The key property
-
getResizeConfiguration
public IResizeConfiguration getResizeConfiguration(IResizeShapeContext context)
Clients may override to modify the resize behavior. The default implementation returns a new instance ofDefaultResizeConfiguration, which allows bothe the horizontal and vertical resize of a shape.- Specified by:
getResizeConfigurationin interfaceIPattern- Parameters:
context- Context object holding information about the shape to be resized.- Returns:
- An instance of
IResizeConfigurationdefining the resize behavior.
-
createDeleteFeature
protected IDeleteFeature createDeleteFeature(IDeleteContext context)
Creates theIDeleteFeatureinstance that handles the deletion of business objects and diagram elements. The default implementation just creates an adaptedDefaultDeleteFeature. Concrete pattern implementations may either override this method to provide their own subclass ofDefaultDeleteFeatureor override and extend the individual methods provided byIDelete.The difference of the delete feature returned here to the standard
DefaultDeleteFeatureis simply that the instance returned here cares about the delegation to the pattern'spreDelete(IDeleteContext),isDeleteAbort()andpostDelete(IDeleteContext)methods. Clients overriding this method should re-implement that pattern, in case the delegation is desired.- Parameters:
context- the deletion context- Returns:
- the
IDeleteFeatureinstance 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 callscreateDeleteFeature(IDeleteContext)and asks the result's canDelete method.
-
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.
-
delete
public void delete(IDeleteContext context)
Clients can override to modify the default delete behavior. The default implementation callscreateDeleteFeature(IDeleteContext)and triggers the result's delete method.
-
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:
postDeletein interfaceIDelete- Parameters:
context- The context describing the delete request
-
createRemoveFeature
protected IRemoveFeature createRemoveFeature(IRemoveContext context)
Creates theIRemoveFeatureinstance that handles the removal of diagram elements. The default implementation just creates an adaptedDefaultRemoveFeature. Concrete pattern implementations may either override this method to provide their own subclass ofDefaultRemoveFeatureor override and extend the individual methods provided byIRemove.The difference of the remove feature returned here to the standard
DefaultRemoveFeatureis simply that the instance returned here cares about the delegation to the pattern'spreRemove(IRemoveContext),isRemoveAbort()andpostRemove(IRemoveContext)methods. Clients overriding this method should re-implement that pattern, in case the delegation is desired.- Parameters:
context- the removal context- Returns:
- the
IRemoveFeatureinstance 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 callscreateRemoveFeature(IRemoveContext)and asks the result's canRemove method.
-
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.
-
remove
public void remove(IRemoveContext context)
Clients can override to modify the default remove behavior. The default implementation callscreateRemoveFeature(IRemoveContext)and triggers the result's remove method.
-
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:
postRemovein interfaceIRemove- 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 passedIDirectEditingContext. Corresponds to the methodAbstractDirectEditingFeature.canDirectEdit(IDirectEditingContext). The default implementation simply returnsfalse.- Specified by:
canDirectEditin interfaceIDirectEditing- Parameters:
context- A context object describing the direct edit request.- Returns:
truein case direct editing shall be allowed,falseotherwise.- See Also:
IFeature.canExecute(org.eclipse.graphiti.features.context.IContext)
-
checkValueValid
public java.lang.String checkValueValid(java.lang.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 methodAbstractDirectEditingFeature.checkValueValid(String, IDirectEditingContext).- Specified by:
checkValueValidin interfaceIDirectEditing- Parameters:
value- The new value to checkcontext- A context object describing the direct edit request.- Returns:
nullin case of a valid value, a string describing the reason for being not valid otherwise.
-
completeValue
public java.lang.String completeValue(java.lang.String value, int caretPos, java.lang.String chosenValue, IDirectEditingContext context)Can be overridden by clients to define completion functionality for direct editing. Corresponds toAbstractDirectEditingFeature.completeValue(String, int, String, IDirectEditingContext). The default implementation simply returns the parameter chosenValue.- Specified by:
completeValuein interfaceIDirectEditing- Parameters:
value- The current valuecaretPosition- The current cursor positionchoosenValue- The value chosen by usercontext- A context object describing the direct edit request.- Returns:
- The new value
-
getPossibleValues
public java.lang.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 methodAbstractDirectEditingFeature.getPossibleValues(IDirectEditingContext). The default implementation returns an empty string array.- Specified by:
getPossibleValuesin interfaceIDirectEditing- Parameters:
context- A context object describing the direct edit request.- Returns:
- The possible values for the combo box.
-
getValueProposals
public java.lang.String[] getValueProposals(java.lang.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 methodAbstractDirectEditingFeature.getValueProposals(String, int, IDirectEditingContext). The default implementation returns an empty string array.- Specified by:
getValueProposalsin interfaceIDirectEditing- Parameters:
value- The current valuecaretPosition- The current cursor positioncontext- 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 methodAbstractDirectEditingFeature.isAutoCompletionEnabled(). The default implementation simply returnsfalse.- Specified by:
isAutoCompletionEnabledin interfaceIDirectEditing- Returns:
true, if proposals should appear automatically,falseotherwise.
-
isCompletionAvailable
public boolean isCompletionAvailable()
Checks if completion is available. This functionality only applies to TYPE_TEXT. Corresponds to methodAbstractDirectEditingFeature.isCompletionAvailable(). The default implementation simply returnsfalse.- Specified by:
isCompletionAvailablein interfaceIDirectEditing- Returns:
trueif completion is / proposals are available at all,falseotherwise.
-
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 methodAbstractDirectEditingFeature.stretchFieldToFitText(). The default implementation simply returnsfalse.- Specified by:
stretchFieldToFitTextin interfaceIDirectEditing- Returns:
trueif the field should exactly fit the contents,falseotherwise.
-
getEditingType
public int getEditingType()
The Graphiti framework calls this method to decide which UI to show up for direct editing. Corresponds to the methodIDirectEditing.getEditingType(). The default implementation returnIDirectEditing.TYPE_NONE, other valid type are defined by the TYPE_* constants inIDirectEditing.- Specified by:
getEditingTypein interfaceIDirectEditing- Returns:
- The desired editing type
-
getInitialValue
public java.lang.String getInitialValue(IDirectEditingContext context)
Provides the initial value for display in the newly opened text editing UI component. Corresponds to the methodIDirectEditing.getInitialValue(IDirectEditingContext). The default implementation always returns an empty string.- Specified by:
getInitialValuein interfaceIDirectEditing- 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(java.lang.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 methodAbstractDirectEditingFeature.setValue(String, IDirectEditingContext). The default implementation does nothing.- Specified by:
setValuein interfaceIDirectEditing- Parameters:
value- The new value to be setcontext- 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 methodAbstractDirectEditingFeature.getProposalSupport(). The default implementation returnsnullto enable the standard string-based direct editing functionality.- Specified by:
getProposalSupportin interfaceIDirectEditing- Returns:
- The special implementation to support Objects in code completion and combo box
- Since:
- 0.8
-
hasDoneChanges
public boolean hasDoneChanges(java.lang.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
falsealthough the pattern did changes.- Specified by:
hasDoneChangesin interfaceIPattern- Parameters:
actionType- the followings types are currently supported:IDelete.class, IRemove.class- Returns:
trueif the last action of the pattern from this action type should appear in the undo stack,falseotherwise- Since:
- 0.9
-
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
-
isRemoveAbort
public boolean isRemoveAbort()
Description copied from interface:IRemoveThe Graphiti framework will call this method afterIRemove.preRemove(IRemoveContext)has been called and before the actual remove 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
IRemove.preRemove(IRemoveContext)as cancellation indication and check that that flag here.- Specified by:
isRemoveAbortin interfaceIRemove- Returns:
truein case you want to cancel the current operation,falseotherwise.- Since:
- 0.12
-
-