public abstract class AbstractPattern extends AbstractBasePattern implements IPattern
TYPE_CUSTOM, TYPE_DROPDOWN, TYPE_DROPDOWN_READ_ONLY, TYPE_MULTILINETEXT, TYPE_NONE, TYPE_TEXT
Constructor and Description |
---|
AbstractPattern()
Creates a new
AbstractPattern . |
AbstractPattern(IPatternConfiguration patternConfiguration)
Creates a new
AbstractPattern holding the given
IPatternConfiguration . |
Modifier and Type | Method and Description |
---|---|
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 . |
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.
|
void |
completeInfo(IDirectEditingInfo info,
java.lang.Object bo)
Clients can override to complete the
IDirectEditingInfo info. |
void |
completeInfo(IDirectEditingInfo info,
java.lang.Object bo,
java.lang.String keyProperty)
Clients can override to complete the
IDirectEditingInfo info. |
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.
|
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 given
ICreateContext
. |
void |
delete(IDeleteContext context)
Clients can override to modify the default delete behavior.
|
java.lang.String |
getCreateDescription()
Client should override to return a string description of the type of
domain object that is created with this pattern.
|
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.
|
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.
|
java.lang.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.
|
java.lang.String |
getInitialValue(IDirectEditingContext context)
Provides the initial value for display in the newly opened text editing
UI component.
|
java.lang.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.
|
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.
|
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.
|
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(java.lang.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.
|
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 . |
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.
|
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.
|
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 . |
void |
setValue(java.lang.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. |
add, canAdd, getFeatureProvider, setFeatureProvider
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
add, canAdd, setFeatureProvider
public AbstractPattern(IPatternConfiguration patternConfiguration)
AbstractPattern
holding the given
IPatternConfiguration
.patternConfiguration
- The pattern configuration to use within this pattern instance
of null
in case no configuration is needed.public AbstractPattern()
AbstractPattern
. This is a convenience method for
patterns working without any configuration.public boolean isPaletteApplicable()
isPaletteApplicable
in interface IPattern
true
in case a palette entry shall be created,
false
otherwise.public boolean canCreate(ICreateContext context)
ICreateContext
. Corresponds to the method
ICreate.canCreate(ICreateContext)
. The default
implementation simply returns false
.public boolean canLayout(ILayoutContext context)
ILayoutContext
. Corresponds to the method
ILayout.canLayout(ILayoutContext)
. The default
implementation checks if the PictogramElement
in the given
context isPatternControlled(PictogramElement)
.public boolean canMoveShape(IMoveShapeContext context)
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.canMoveShape
in interface IMoveShape
context
- The context holding information on the domain object to be
moved.true
in case this pattern can move a shape for such
a domain object, false
otherwise.public boolean canResizeShape(IResizeShapeContext context)
IResizeShapeContext
. Corresponds to the method
DefaultResizeShapeFeature.canResizeShape(IResizeShapeContext)
.
The default implementation checks if the PictogramElement
in the
given context fulfills isPatternRoot(PictogramElement)
.canResizeShape
in interface IResizeShape
context
- The context holding information on the domain object to be
resized.true
in case this pattern can resize a shape for
such a domain object, false
otherwise.public boolean canUpdate(IUpdateContext context)
IUpdateContext
. Corresponds to the method
IUpdate.canUpdate(IUpdateContext)
. The default
implementation checks if the PictogramElement
in the given
context isPatternControlled(PictogramElement)
.public java.lang.Object[] create(ICreateContext context)
ICreateContext
. Corresponds to the method
ICreate.create(ICreateContext)
. The default
implementation simply does nothing and returns an empty object array.public java.lang.String getCreateDescription()
null
which indicates that no tooltip shall be displayed.getCreateDescription
in interface ICreateInfo
getCreateDescription
in interface IPattern
String
holding the tooltippublic java.lang.String getCreateImageId()
null
which indicates that no icon shall be displayed.getCreateImageId
in interface ICreateInfo
String
holding the id of the icon as defined in the
AbstractImageProvider.public java.lang.String getCreateLargeImageId()
null
which indicates that no icon shall be displayed.getCreateLargeImageId
in interface ICreateInfo
String
holding the id of the large icon as defined in
the AbstractImageProvider.public java.lang.String getCreateName()
null
which results in an empty
entry in the palette.getCreateName
in interface ICreateInfo
getCreateName
in interface IPattern
String
holding the name of the domain object.public abstract boolean isMainBusinessObjectApplicable(java.lang.Object mainBusinessObject)
isMainBusinessObjectApplicable
in interface IPattern
mainBusinessObject
- The object to check if it is the main domain object of the
pattern.true
in case the pattern has the given domain object
as its main domain object, false
otherwise.public boolean layout(ILayoutContext context)
ILayoutContext
. Corresponds to the method
ILayout.layout(ILayoutContext)
. The default
implementation simply does nothing and returns false
as
indication of this.public void moveShape(IMoveShapeContext context)
IMoveShapeContext
. Corresponds to the method
DefaultMoveShapeFeature.moveShape(IMoveShapeContext)
.moveShape
in interface IMoveShape
context
- The context holding information on the domain object to be
moved.public void resizeShape(IResizeShapeContext context)
IResizeShapeContext
. Corresponds to the method
DefaultResizeShapeFeature.resizeShape(IResizeShapeContext)
.resizeShape
in interface IResizeShape
context
- The context holding information on the domain object to be
resized.public boolean update(IUpdateContext context)
IUpdateContext
. Corresponds to the method
IUpdate.update(IUpdateContext)
.public IReason updateNeeded(IUpdateContext context)
IUpdateContext
needs to be triggered. Corresponds to the method
IUpdate.updateNeeded(IUpdateContext)
.updateNeeded
in interface IUpdate
context
- The context holding information on the domain object to be
updated.public void completeInfo(IDirectEditingInfo info, java.lang.Object bo)
IDirectEditingInfo
info.
This information is needed to switch automatically into the direct
editing mode. (e.g. after creation of a new object).completeInfo
in interface IPattern
info
- The direct editing infobo
- The domain objectpublic void completeInfo(IDirectEditingInfo info, java.lang.Object bo, java.lang.String keyProperty)
IDirectEditingInfo
info.
This information is needed to switch automatically into the direct
editing mode. (e.g. after creation of a new object)completeInfo
in interface IPattern
info
- The direct editing infobo
- The domain objectkeyProperty
- The key propertypublic IResizeConfiguration getResizeConfiguration(IResizeShapeContext context)
DefaultResizeConfiguration
, which allows bothe the horizontal and
vertical resize of a shape.getResizeConfiguration
in interface IPattern
context
- Context object holding information about the shape to be
resized.IResizeConfiguration
defining the resize
behavior.public boolean canDelete(IDeleteContext context)
createDeleteFeature(IDeleteContext)
and asks the result's
canDelete method.public void preDelete(IDeleteContext context)
public void delete(IDeleteContext context)
createDeleteFeature(IDeleteContext)
and
triggers the result's delete method.public void postDelete(IDeleteContext context)
postDelete
in interface IDelete
context
- The context describing the delete requestpublic boolean canRemove(IRemoveContext context)
createRemoveFeature(IRemoveContext)
and asks the result's
canRemove method.public void preRemove(IRemoveContext context)
public void remove(IRemoveContext context)
createRemoveFeature(IRemoveContext)
and
triggers the result's remove method.public void postRemove(IRemoveContext context)
postRemove
in interface IRemove
context
- The context describing the remove requestpublic boolean canDirectEdit(IDirectEditingContext context)
IDirectEditingContext
. Corresponds to the method
AbstractDirectEditingFeature.canDirectEdit(IDirectEditingContext)
. The default implementation simply returns false
.canDirectEdit
in interface IDirectEditing
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 checkValueValid(java.lang.String value, IDirectEditingContext context)
AbstractDirectEditingFeature.checkValueValid(String, IDirectEditingContext)
.checkValueValid
in interface IDirectEditing
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 java.lang.String completeValue(java.lang.String value, int caretPos, java.lang.String chosenValue, IDirectEditingContext context)
AbstractDirectEditingFeature.completeValue(String, int, String, IDirectEditingContext)
. The default implementation simply returns the parameter chosenValue.completeValue
in interface IDirectEditing
value
- The current valuecaretPosition
- The current cursor positionchoosenValue
- The value chosen by usercontext
- A context object describing the direct edit request.public java.lang.String[] getPossibleValues(IDirectEditingContext context)
AbstractDirectEditingFeature.getPossibleValues(IDirectEditingContext)
. The default implementation returns an empty string array.getPossibleValues
in interface IDirectEditing
context
- A context object describing the direct edit request.public java.lang.String[] getValueProposals(java.lang.String value, int caretPos, IDirectEditingContext context)
AbstractDirectEditingFeature.getValueProposals(String, int, IDirectEditingContext)
. The default implementation returns an empty string array.getValueProposals
in interface IDirectEditing
value
- The current valuecaretPosition
- The current cursor positioncontext
- A context object describing the direct edit request.public boolean isAutoCompletionEnabled()
AbstractDirectEditingFeature.isAutoCompletionEnabled()
. The
default implementation simply returns false
.isAutoCompletionEnabled
in interface IDirectEditing
true
, if proposals should appear automatically,
false
otherwise.public boolean isCompletionAvailable()
AbstractDirectEditingFeature.isCompletionAvailable()
. The default
implementation simply returns false
.isCompletionAvailable
in interface IDirectEditing
true
if completion is / proposals are available at
all, false
otherwise.public boolean stretchFieldToFitText()
AbstractDirectEditingFeature.stretchFieldToFitText()
. The default
implementation simply returns false
.stretchFieldToFitText
in interface IDirectEditing
true
if the field should exactly fit the contents,
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
public java.lang.String getInitialValue(IDirectEditingContext context)
IDirectEditing.getInitialValue(IDirectEditingContext)
. The default implementation always returns an empty string.getInitialValue
in interface IDirectEditing
context
- A context object describing the direct edit request.public void setValue(java.lang.String value, IDirectEditingContext context)
AbstractDirectEditingFeature.setValue(String, IDirectEditingContext)
. The default implementation does nothing.setValue
in interface IDirectEditing
value
- The new value to be setcontext
- A context object describing the direct edit request.public IProposalSupport getProposalSupport()
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.
getProposalSupport
in interface IDirectEditing
public boolean hasDoneChanges(java.lang.Class<?> actionType)
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.
hasDoneChanges
in interface IPattern
actionType
- the followings types are currently supported:
IDelete.class, IRemove.class
true
if the last action of the pattern from this
action type should appear in the undo stack, false
otherwisepublic boolean isDeleteAbort()
IDelete
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.
isDeleteAbort
in interface IDelete
true
in case you want to cancel the current
operation, false
otherwise.public boolean isRemoveAbort()
IRemove
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.
isRemoveAbort
in interface IRemove
true
in case you want to cancel the current
operation, false
otherwise.