public abstract class IdPattern extends TypedPattern implements IPattern
Property
objects). These IDs are used
to identify the parts of that shape and to call the update and layout methods
for the shapes with IDs. Clients do not need to search through the shape
hierarchy to find the shapes to update and layout.
Besides IDs this pattern base implementation also supports tagging
PictogramElement
s with an index property that allows to number a
sequence of children using the same ID, e.g. a list of attributes inside a
class.
TYPE_CUSTOM, TYPE_DROPDOWN, TYPE_DROPDOWN_READ_ONLY, TYPE_MULTILINETEXT, TYPE_NONE, TYPE_TEXT
Constructor and Description |
---|
IdPattern()
Default constructor for a new IdPattern.
|
IdPattern(IPatternConfiguration patternConfiguration)
Constructor taking some pattern configuration data for the created
IdPattern.
|
Modifier and Type | Method and Description |
---|---|
PictogramElement |
add(IAddContext context)
Adds a
PictogramElement representation for the given context to
the diagram. |
boolean |
canAdd(IAddContext context)
Checks if adding is possible using this pattern in the given context.
|
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 , but the recommended method to override for
IdPattern is
canDirectEdit(IDirectEditingContext, String) . |
boolean |
canLayout(ILayoutContext context)
Checks if layouting a shape is possible using this pattern in the given
context.
|
boolean |
canUpdate(IUpdateContext context)
Checks if updating a shape is possible using this pattern in the given
context.
|
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.
|
int |
getEditingType()
The Graphiti framework calls this method to decide which UI to show up
for direct editing.
|
java.lang.String |
getInitialValue(IDirectEditingContext context)
Provides the initial value for display in the newly opened text editing
UI component.
|
boolean |
layout(ILayoutContext context)
Layouts a
PictogramElement representation given in the context. |
void |
setValue(java.lang.String value,
IDirectEditingContext context)
Set the new value after direct editing is finished.
|
boolean |
update(IUpdateContext context)
Updates a
PictogramElement representation given in the context. |
IReason |
updateNeeded(IUpdateContext context)
Checks if an updates is needed for a
PictogramElement
representation given in the context. |
canCreate, canDelete, canMoveShape, canRemove, canResizeShape, completeInfo, completeInfo, completeValue, create, delete, getCreateDescription, getCreateImageId, getCreateLargeImageId, getCreateName, getPossibleValues, getProposalSupport, getResizeConfiguration, getValueProposals, hasDoneChanges, isAutoCompletionEnabled, isCompletionAvailable, isDeleteAbort, isMainBusinessObjectApplicable, isPaletteApplicable, isRemoveAbort, moveShape, postDelete, postRemove, preDelete, preRemove, remove, resizeShape, stretchFieldToFitText
getFeatureProvider, setFeatureProvider
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
completeInfo, completeInfo, getCreateDescription, getCreateName, getResizeConfiguration, hasDoneChanges, isMainBusinessObjectApplicable, isPaletteApplicable, setFeatureProvider
getCreateImageId, getCreateLargeImageId
canDelete, delete, isDeleteAbort, postDelete, preDelete
canRemove, isRemoveAbort, postRemove, preRemove, remove
canResizeShape, resizeShape
canMoveShape, moveShape
completeValue, getPossibleValues, getProposalSupport, getValueProposals, isAutoCompletionEnabled, isCompletionAvailable, stretchFieldToFitText
public IdPattern()
IPatternConfiguration
instance
from their subclass constructor.public IdPattern(IPatternConfiguration patternConfiguration)
patternConfiguration
- The configuration data to usepublic boolean canAdd(IAddContext context)
AbstractPattern.isMainBusinessObjectApplicable(Object)
.canAdd
in interface IAdd
canAdd
in interface IPattern
canAdd
in class AbstractBasePattern
context
- An IAddContext
describing the add operation.true
in case adding is possible, false
otherwise.public PictogramElement add(IAddContext context)
PictogramElement
representation for the given context to
the diagram. The default implementation delegates to
doAdd(IAddContext)
(which clients should primarily override) and
updates and layouts the returned PictogramElement
afterwards.add
in interface IAdd
add
in interface IPattern
add
in class AbstractBasePattern
context
- An IAddContext
describing the add operation.PictogramElement
tree.public boolean canLayout(ILayoutContext context)
AbstractPattern.isMainBusinessObjectApplicable(Object)
and if the
PictogramElement
given in the context is controlled by an ID
pattern.canLayout
in interface ILayout
canLayout
in class AbstractPattern
context
- An ILayoutContext
describing the layout operation.true
in case layouting is possible,
false
otherwise.public boolean layout(ILayoutContext context)
PictogramElement
representation given in the context.
The default implementation delegates to
layout(IdLayoutContext, String)
(which clients should primarily
override) to actually update individual PictogramElement
s. This
delegation is done for any PictogramElement
tagged with an ID in
the following order:
PictogramElement
given in the context itselfGraphicsAlgorithm
of the PictogramElement
in the
contextPictogramElement
children of the PictogramElement
in the contextGraphicsAlgorithm
children of the
GraphicsAlgorithm
of the PictogramElement
in the context.
For this the method
layoutGraphicsAlgorithmChildren(GraphicsAlgorithm, IdLayoutContext)
is called which in term calles itself and this method recursively.layout
in interface ILayout
layout
in class AbstractPattern
context
- An ILayoutContext
describing the layout operation.true
in case the layout operation did changes to the
diagram, false
otherwise.public boolean canUpdate(IUpdateContext context)
AbstractPattern.isMainBusinessObjectApplicable(Object)
and if the
PictogramElement
given in the context is controlled by an ID
pattern.canUpdate
in interface IUpdate
canUpdate
in class AbstractPattern
context
- An IUpdateContext
describing the update operation.true
in case updating is possible,
false
otherwise.public IReason updateNeeded(IUpdateContext context)
PictogramElement
representation given in the context. The default implementation delegates
to updateNeeded(IdUpdateContext, String)
(which clients should
primarily override) to actually update individual
PictogramElement
s. This delegation is done for any
PictogramElement
tagged with an ID in the following order:
PictogramElement
given in the context itselfGraphicsAlgorithm
of the PictogramElement
in the
contextPictogramElement
children of the PictogramElement
in the contextGraphicsAlgorithm
children of the
GraphicsAlgorithm
of the PictogramElement
in the context.
For this the method
updateNeededGraphicsAlgorithmChildren(GraphicsAlgorithm, IdUpdateContext)
is called which in term calls itself and this method recursively.updateNeeded
in interface IUpdate
updateNeeded
in class AbstractPattern
context
- An IUpdateContext
describing the update operation.IReason
indicating true
and a
String
reason in case the update operation is needed, an
IReason
indicating false
otherwise.public boolean update(IUpdateContext context)
PictogramElement
representation given in the context.
The default implementation only delegates to
update(IUpdateContext, boolean)
setting the parameter innerCall
to false
.update
in interface IUpdate
update
in class AbstractPattern
context
- An IUpdateContext
describing the update operation.true
in case the update operation did changes to the
diagram, false
otherwise.public int getEditingType()
IDirectEditing.getEditingType()
. The default
implementation return IDirectEditing.TYPE_NONE
, other valid type
are defined by the TYPE_* constants in IDirectEditing
.getEditingType
in interface IDirectEditing
getEditingType
in class AbstractPattern
public boolean canDirectEdit(IDirectEditingContext context)
IDirectEditingContext
, but the recommended method to override for
IdPattern
is
canDirectEdit(IDirectEditingContext, String)
. Corresponds to the
method
AbstractDirectEditingFeature.canDirectEdit(IDirectEditingContext)
. The default implementation checks if the pattern is responsible for the
shape and an ID is set; in that case it delegates to
canDirectEdit(IDirectEditingContext, String)
.canDirectEdit
in interface IDirectEditing
canDirectEdit
in class AbstractPattern
context
- A context object describing the direct edit request.true
in case direct editing shall be allowed,
false
otherwise.IFeature.canExecute(org.eclipse.graphiti.features.context.IContext)
public java.lang.String getInitialValue(IDirectEditingContext context)
IDirectEditing.getInitialValue(IDirectEditingContext)
. The default implementation checks if the pattern is responsible for the
shape and an ID is set; in that case it delegates to
getInitialValue(IDirectEditingContext, String)
.getInitialValue
in interface IDirectEditing
getInitialValue
in class AbstractPattern
context
- A context object describing the direct edit request.public java.lang.String checkValueValid(java.lang.String value, IDirectEditingContext context)
AbstractDirectEditingFeature.checkValueValid(String, IDirectEditingContext)
. The default implementation checks if the pattern is responsible for the
shape and an ID is set; in that case it delegates to
checkValueValid(String, IDirectEditingContext, String)
.checkValueValid
in interface IDirectEditing
checkValueValid
in class AbstractPattern
value
- The new value to checkcontext
- A context object describing the direct edit request.null
in case of a valid value, a string describing
the reason for being not valid otherwise.public void setValue(java.lang.String value, IDirectEditingContext context)
AbstractDirectEditingFeature.setValue(String, IDirectEditingContext)
. The default implementation checks if the pattern is responsible for the
shape and an ID is set; in that case it delegates to
setValue(String, IDirectEditingContext, String)
.setValue
in interface IDirectEditing
setValue
in class AbstractPattern
value
- The new value to be setcontext
- A context object describing the direct edit request.