|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.graphiti.pattern.AbstractBasePattern
org.eclipse.graphiti.pattern.AbstractPattern
org.eclipse.graphiti.pattern.TypedPattern
org.eclipse.graphiti.pattern.id.IdPattern
public abstract class IdPattern
Base class for ID patterns. The basic idea behind is to tag single parts of a
pattern shape with IDs (using 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.
Field Summary | |
---|---|
protected static String |
PROPERTY_KEY_ID
The property key that is used to tag individual PictogramElement s
with a specific ID to identify them later during e.g. |
protected static String |
PROPERTY_KEY_INDEX
The property key that is used to tag individual PictogramElement s
with a specific index beyond the ID to identify them later during e.g. |
protected static String |
PROPERTY_VALUE_PATTERN_TYPE_ID
The property key that stores the information that a PictogramElement is the root object of a IdPattern
subclass. |
Fields inherited from class org.eclipse.graphiti.pattern.TypedPattern |
---|
PROPERTY_KEY_PATTERN_TYPE |
Fields inherited from class org.eclipse.graphiti.pattern.AbstractPattern |
---|
EMPTY_STRING_ARRAY |
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 | |
---|---|
IdPattern()
Default constructor for a new IdPattern. |
|
IdPattern(IPatternConfiguration patternConfiguration)
Constructor taking some pattern configuration data for the created IdPattern. |
Method Summary | |
---|---|
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) . |
protected boolean |
canDirectEdit(IDirectEditingContext context,
String id)
Clients can override this method to indicate that the pattern allows direct editing for the shape described in the passed IDirectEditingContext holding the given ID. |
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. |
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. |
protected String |
checkValueValid(String value,
IDirectEditingContext context,
String id)
This method will be called by the framework to check if the passed String is valid as new value for the shape. |
protected abstract PictogramElement |
doAdd(IAddContext context)
Clients should primarily override this method and implement their add functionality here. |
protected PropertyContainer |
findById(PictogramElement pictogramElement,
String idToFind)
Searches for a PictogramElement that has the given ID starting
from the given PictogramElement . |
private PropertyContainer |
findByIdInGraphicsAlgorithmChildren(GraphicsAlgorithm graphicsAlgorithm,
String idToFind)
|
int |
getEditingType()
The Graphiti framework calls this method to decide which UI to show up for direct editing. |
protected String |
getId(PropertyContainer container)
Returns any ID that has been set for the given PictogramElement ;
it can be any PropertyContainer , especially Shape s or
GraphicsAlgorithm s are allowed. |
protected int |
getIndex(PropertyContainer container)
Returns any index that has been set for the given PictogramElement ; it can be any PropertyContainer ,
especially Shape s or GraphicsAlgorithm s are allowed. |
String |
getInitialValue(IDirectEditingContext context)
Provides the initial value for display in the newly opened text editing UI component. |
protected String |
getInitialValue(IDirectEditingContext context,
String id)
Provides the initial value for display in the newly opened text editing UI component. |
protected boolean |
isPatternControlled(PictogramElement pictogramElement)
Checks if the PictogramElement is controlled by the pattern. |
protected boolean |
isPatternRoot(PictogramElement pictogramElement)
Checks if the given PictogramElement is the root object of this
pattern. |
protected abstract boolean |
layout(IdLayoutContext context,
String id)
Clients should primarily override this method and implement their layout functionality here. |
boolean |
layout(ILayoutContext context)
Layouts a PictogramElement representation given in the context. |
protected boolean |
layoutGraphicsAlgorithmChildren(GraphicsAlgorithm graphicsAlgorithm,
IdLayoutContext context)
This method implements the part of the layout that deals with the GraphicsAlgorithm children, see #layout(IdLayoutContext) . |
protected void |
setId(PropertyContainer container,
String id)
Set the ID property ( PROPERTY_KEY_ID ) for the given
PictogramElement ; it can be any PropertyContainer
,especially Shape s or GraphicsAlgorithm s are allowed. |
protected void |
setIndex(PropertyContainer container,
int index)
Set the index property ( PROPERTY_KEY_ID ) for the given
PictogramElement ; it can be any PropertyContainer
,especially Shape s or GraphicsAlgorithm s are allowed. |
void |
setValue(String value,
IDirectEditingContext context)
Set the new value after direct editing is finished. |
protected void |
setValue(String value,
IDirectEditingContext context,
String id)
Set the new value after direct editing is finished. |
protected abstract boolean |
update(IdUpdateContext context,
String id)
Clients should primarily override this method and implement their update functionality here. |
boolean |
update(IUpdateContext context)
Updates a PictogramElement representation given in the context. |
protected boolean |
update(IUpdateContext context,
boolean innerCall)
Updates a PictogramElement representation given in the context
recursively. |
protected boolean |
updateGraphicsAlgorithmChildren(GraphicsAlgorithm graphicsAlgorithm,
IdUpdateContext context)
This method implements the part of the update that deals with the GraphicsAlgorithm children, see
update(IUpdateContext, boolean) . |
protected abstract IReason |
updateNeeded(IdUpdateContext context,
String id)
Clients should primarily override this method and implement their update check functionality here. |
IReason |
updateNeeded(IUpdateContext context)
Checks if an updates is needed for a PictogramElement
representation given in the context. |
protected IReason |
updateNeededGraphicsAlgorithmChildren(GraphicsAlgorithm graphicsAlgorithm,
IdUpdateContext context)
This method implements the part of the update needed check that deals with the GraphicsAlgorithm children, see
updateNeeded(IUpdateContext) . |
Methods inherited from class org.eclipse.graphiti.pattern.TypedPattern |
---|
getPatternType, setPatternType |
Methods inherited from class org.eclipse.graphiti.pattern.AbstractBasePattern |
---|
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 |
---|
completeInfo, completeInfo, getCreateDescription, getCreateName, getResizeConfiguration, hasDoneChanges, isMainBusinessObjectApplicable, isPaletteApplicable, setFeatureProvider |
Methods inherited from interface org.eclipse.graphiti.func.ICreate |
---|
canCreate, create |
Methods inherited from interface org.eclipse.graphiti.func.ICreateInfo |
---|
getCreateImageId, getCreateLargeImageId |
Methods inherited from interface org.eclipse.graphiti.func.IDelete |
---|
canDelete, delete, isDeleteAbort, postDelete, preDelete |
Methods inherited from interface org.eclipse.graphiti.func.IRemove |
---|
canRemove, isRemoveAbort, postRemove, preRemove, remove |
Methods inherited from interface org.eclipse.graphiti.func.IResizeShape |
---|
canResizeShape, resizeShape |
Methods inherited from interface org.eclipse.graphiti.func.IMoveShape |
---|
canMoveShape, moveShape |
Methods inherited from interface org.eclipse.graphiti.func.IDirectEditing |
---|
completeValue, getPossibleValues, getProposalSupport, getValueProposals, isAutoCompletionEnabled, isCompletionAvailable, stretchFieldToFitText |
Field Detail |
---|
protected static final String PROPERTY_VALUE_PATTERN_TYPE_ID
PictogramElement
is the root object of a IdPattern
subclass. The value is set by the add(IAddContext)
method.
protected static final String PROPERTY_KEY_ID
PictogramElement
s
with a specific ID to identify them later during e.g. update or layout.
protected static final String PROPERTY_KEY_INDEX
PictogramElement
s
with a specific index beyond the ID to identify them later during e.g.
update or layout. This can e.g. be used for lists of shapes like the
attributes of a class.
Constructor Detail |
---|
public IdPattern()
IPatternConfiguration
instance
from their subclass constructor.
public IdPattern(IPatternConfiguration patternConfiguration)
patternConfiguration
- The configuration data to useMethod Detail |
---|
protected boolean isPatternControlled(PictogramElement pictogramElement)
PictogramElement
is controlled by the pattern. The
default implementation simply checks if the domain object linked to the
given PictogramElement
is the one that is controlled by this
pattern, see AbstractPattern.isMainBusinessObjectApplicable(Object)
. Especially
the default implementation does not traverse up the hierarchy to find a
suitable parent.
isPatternControlled
in class AbstractPattern
pictogramElement
- The PictogramElement
to check
true
in case the pattern controls the given
PictogramElement
, false
otherwise.protected boolean isPatternRoot(PictogramElement pictogramElement)
PictogramElement
is the root object of this
pattern. The default implementation checks if the domain object linked to
the given PictogramElement
is the one that is controlled by this
pattern, see AbstractPattern.isMainBusinessObjectApplicable(Object)
. It also
checks if the object is controlled by an ID pattern by checking the
according property (TypedPattern.PROPERTY_KEY_PATTERN_TYPE
).
isPatternRoot
in class AbstractPattern
pictogramElement
- The PictogramElement
to check
true
in case the given PictogramElement
is
the root shape of this pattern, false
otherwise.protected void setId(PropertyContainer container, String id)
PROPERTY_KEY_ID
) for the given
PictogramElement
; it can be any PropertyContainer
,especially Shape
s or GraphicsAlgorithm
s are allowed. The
used ID string can later be used to identify the shape, e.g. in the
update or layout methods.
container
- The PictogramElement
to set the ID property forid
- The String
ID to set.protected String getId(PropertyContainer container)
PictogramElement
;
it can be any PropertyContainer
, especially Shape
s or
GraphicsAlgorithm
s are allowed.
container
- The PictogramElement
to get the ID property from
String
representing the value of the property or
null
in case the property is not set, see
setId(PropertyContainer, String)
.protected PropertyContainer findById(PictogramElement pictogramElement, String idToFind)
PictogramElement
that has the given ID starting
from the given PictogramElement
. First the given element is
checked, then its GraphicsAlgorithm
; after that the
PictogramElement
children are checked recursively and last the
GraphicsAlgorithm
children also recursively. The first
PictogramElement
that has the given ID is returned, in case none
is found in the tree spanned by the given PictogramElement
,
null
is returned.
pictogramElement
- The PictogramElement
at which the search shall start,
any Shape
s or GraphicsAlgorithm
s on top of
this element are ignored.idToFind
- A String
representing the ID to search for
PictogramElement
that has the given ID property, in
case none id found null
.private PropertyContainer findByIdInGraphicsAlgorithmChildren(GraphicsAlgorithm graphicsAlgorithm, String idToFind)
protected void setIndex(PropertyContainer container, int index)
PROPERTY_KEY_ID
) for the given
PictogramElement
; it can be any PropertyContainer
,especially Shape
s or GraphicsAlgorithm
s are allowed. The
used index can later - together with the ID string - be used to identify
the concrete shape in case of a list of shapes, e.g. in the update or
layout methods.
container
- The PictogramElement
to set the index property forid
- The Integer
index to set.protected int getIndex(PropertyContainer container)
PictogramElement
; it can be any PropertyContainer
,
especially Shape
s or GraphicsAlgorithm
s are allowed.
container
- The PictogramElement
to get the index property from
Integer
representing the value of the property or -1
in case the property is not set, see
setIndex(PropertyContainer, int)
.public 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.protected abstract PictogramElement doAdd(IAddContext context)
add(IAddContext)
.
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.protected boolean layoutGraphicsAlgorithmChildren(GraphicsAlgorithm graphicsAlgorithm, IdLayoutContext context)
GraphicsAlgorithm
children, see #layout(IdLayoutContext)
.
Clients should primarily override
layout(IdLayoutContext, String)
which is called for all found
PictogramElement
s and GraphicsAlgorithm
s as described
above that have an ID.
graphicsAlgorithm
- The GraphicsAlgorithm
to layout.context
- An ILayoutContext
describing the layout operation.
true
in case the layout operation did changes to the
diagram, false
otherwise.protected abstract boolean layout(IdLayoutContext context, String id)
layout(ILayoutContext)
for each of the PictogramElement
s
and GraphicsAlgorithm
s that have been tagged with an ID.
context
- An IdLayoutContext
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.protected IReason updateNeededGraphicsAlgorithmChildren(GraphicsAlgorithm graphicsAlgorithm, IdUpdateContext context)
GraphicsAlgorithm
children, see
updateNeeded(IUpdateContext)
. Clients should primarily override
updateNeeded(IdUpdateContext, String)
which is called for all
found PictogramElement
s and GraphicsAlgorithm
s as
described above that have an ID.
graphicsAlgorithm
- The GraphicsAlgorithm
to perform the update check for.context
- An IdUpdateContext
describing the update operation.
IReason
indicating true
and a
String
reason in case the update operation is needed, an
IReason
indicating false
otherwise.protected abstract IReason updateNeeded(IdUpdateContext context, String id)
updateNeeded(IUpdateContext)
for each of the
PictogramElement
s and GraphicsAlgorithm
s that have been
tagged with an ID.
context
- An IdUpdateContext
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.protected boolean update(IUpdateContext context, boolean innerCall)
PictogramElement
representation given in the context
recursively. The default implementation delegates to
update(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
updateGraphicsAlgorithmChildren(GraphicsAlgorithm, IdUpdateContext)
is called which in term calls itself and this method recursively.
context
- An IUpdateContext
describing the update operation.
true
in case the update operation did changes to the
diagram, false
otherwise.protected boolean updateGraphicsAlgorithmChildren(GraphicsAlgorithm graphicsAlgorithm, IdUpdateContext context)
GraphicsAlgorithm
children, see
update(IUpdateContext, boolean)
. Clients should primarily
override update(IdUpdateContext, String)
which is called for all
found PictogramElement
s and GraphicsAlgorithm
s as
described above that have an ID.
graphicsAlgorithm
- The GraphicsAlgorithm
to update.context
- An IdUpdateContext
describing the update operation.
true
in case the update operation did changes to the
diagram, false
otherwise.protected abstract boolean update(IdUpdateContext context, String id)
update(IUpdateContext, boolean)
for each of the
PictogramElement
s and GraphicsAlgorithm
s that have been
tagged with an ID.
context
- An IdUpdateContext
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)
protected boolean canDirectEdit(IDirectEditingContext context, String id)
IDirectEditingContext
holding the given ID. Corresponds to the
method
AbstractDirectEditingFeature.canDirectEdit(IDirectEditingContext)
. The default implementation simply returns false
.
context
- A context object describing the direct edit request.id
- The ID to check direct editing for
true
in case direct editing shall be allowed,
false
otherwise.public 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.
protected String getInitialValue(IDirectEditingContext context, String id)
IDirectEditing.getInitialValue(IDirectEditingContext)
. The default implementation always returns an empty string.
context
- A context object describing the direct edit request.id
- The ID of the shape to get the initial value for
public String checkValueValid(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.protected String checkValueValid(String value, IDirectEditingContext context, String id)
AbstractDirectEditingFeature.checkValueValid(String, IDirectEditingContext)
.
value
- The new value to checkcontext
- A context object describing the direct edit request.id
- The ID of the shape to check the value for
null
in case of a valid value, a string describing
the reason for being not valid otherwise.public void setValue(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.protected void setValue(String value, IDirectEditingContext context, String id)
AbstractDirectEditingFeature.setValue(String, IDirectEditingContext)
. The default implementation does nothing.
value
- The new value to be setcontext
- A context object describing the direct edit request.id
- The ID of the shape to set the value for
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |