org.eclipse.graphiti.pattern
Class AbstractPattern

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

public abstract class AbstractPattern
extends AbstractBasePattern
implements IPattern

The Class AbstractPattern.


Field Summary
protected static String[] EMPTY_STRING_ARRAY
          An empty string array used in direct editing.
private  IPatternConfiguration patternConfiguration
           
private  IDeleteFeature wrappedDeleteFeature
          To avoid code duplication, this base class uses a wrapped default implementation of an IDeleteFeature to provide the default deletion behaviour.
private  IRemoveFeature wrappedRemoveFeature
          To avoid code duplication, this base class uses a wrapped default implementation of an IRemoveFeature to provide the default removal behavior.
 
Fields inherited from interface org.eclipse.graphiti.func.ICreate
EMPTY
 
Fields inherited from interface org.eclipse.graphiti.func.IDirectEditing
TYPE_CHECK, TYPE_COLOR, TYPE_DIALOG, TYPE_DROPDOWN, TYPE_DROPDOWN_READ_ONLY, TYPE_MULTILINETEXT, TYPE_NONE, TYPE_TEXT
 
Constructor Summary
AbstractPattern(IPatternConfiguration patternConfiguration)
          Creates a new AbstractPattern.
 
Method Summary
protected  void addGraphicalRepresentation(IAreaContext context, Object newObject)
          Adds the graphical representation.
protected  boolean avoidNegativeCoordinates()
           
 boolean canCreate(ICreateContext context)
          Checks if business object can be created for the given context.
 boolean canDelete(IDeleteContext context)
          Can delete.
 boolean canDirectEdit(IDirectEditingContext context)
          Checks if the feature can perform direct editing on the context handed over.
 boolean canLayout(ILayoutContext context)
          Checks whether the current pictogram element of the given context can be layouted.
 boolean canMoveShape(IMoveShapeContext context)
          Can move shape.
 boolean canRemove(IRemoveContext context)
          Checks if given object could be removed.
 boolean canResizeShape(IResizeShapeContext context)
          Can resize shape.
 boolean canUpdate(IUpdateContext context)
          Checks whether the values of the current pictogram element of the given context can be updated.
 String checkValueValid(String value, IDirectEditingContext context)
          This method will be called by clients many times to see if current value is valid and could be set.
 void completeInfo(IDirectEditingInfo info, Object bo)
          Complete the directEditing info.
 void completeInfo(IDirectEditingInfo info, Object bo, String keyProperty)
          Complete the directEditing info.
 String completeValue(String value, int caretPos, String choosenValue, IDirectEditingContext context)
          Framework calls this method to let the feature calculate the new value.
 Object[] create(ICreateContext context)
          Creates the business object for the given context.
protected  IDeleteFeature createDeleteFeature(IDeleteContext context)
          Creates the IDeleteFeature instance that handles the deletion of business objects and diagram elements.
protected  IRemoveFeature createRemoveFeature(IRemoveContext context)
          Creates the IRemoveFeature instance that handles the removal of diagram elements.
 void delete(IDeleteContext context)
          Delete.
private  List<Anchor> getAnchors(ContainerShape containerShape)
           
 String getCreateDescription()
          Gets the create description.
 String getCreateImageId()
          Gets the create image id.
 String getCreateLargeImageId()
          Gets the create large image id.
 String getCreateName()
          Gets the create name.
 int getEditingType()
          Framework calls this method to decide which UI to show up.
protected  String getImage(IStructureMapping structureMapping, PictogramLink link)
          Gets the image.
 String getInitialValue(IDirectEditingContext context)
          Provides the initial value for the opened text editing UI component.
protected  IPatternConfiguration getPatternConfiguration()
          Gets the pattern configuration.
 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)
          Provides configuration object, which describes the resize behavior.
protected  String getText(IStructureMapping structureMapping, PictogramLink link)
          Gets the text.
 String[] getValueProposals(String value, int caretPos, IDirectEditingContext context)
          This proposals will be used for the completion list of a simple text cell editor.
protected  void internalMove(IMoveShapeContext context)
          Internal move.
 boolean isAutoCompletionEnabled()
          Checks if auto completion is enabled.
 boolean isCompletionAvailable()
          Checks if completion is available.
abstract  boolean isMainBusinessObjectApplicable(Object mainBusinessObject)
          This method must be implemented by the pattern user.
 boolean isPaletteApplicable()
          Determines whether the pattern supports the creation of new business objects from the palette.
protected abstract  boolean isPatternControlled(PictogramElement pictogramElement)
          This method must be implemented by the pattern developer / provider.
protected abstract  boolean isPatternRoot(PictogramElement pictogramElement)
          This method must be implemented by the pattern developer / provider.
 boolean layout(ILayoutContext context)
          Layoutes the pictogram element.
protected  void layoutPictogramElement(PictogramElement pe)
          Layout pictogram element.
protected  void moveAllBendpoints(IMoveShapeContext context)
          Move all bendpoints within a container shape.
 void moveShape(IMoveShapeContext context)
          Move shape.
 void postDelete(IDeleteContext context)
          Post delete.
protected  void postMoveShape(IMoveShapeContext context)
          Post move shape.
 void postRemove(IRemoveContext context)
          called after remove call.
 void preDelete(IDeleteContext context)
          Pre delete.
protected  void preMoveShape(IMoveShapeContext context)
          Pre move shape.
 void preRemove(IRemoveContext context)
          called prior to remove call.
 void remove(IRemoveContext context)
          Remove the given object.
 void resizeShape(IResizeShapeContext context)
          Resize shape.
protected  void setPatternConfiguration(IPatternConfiguration patternConfiguration)
          Sets the pattern configuration.
 void setValue(String value, IDirectEditingContext context)
          Set the new value.
 boolean stretchFieldToFitText()
          Stretch input field to fit its contents.
 boolean update(IUpdateContext context)
          Updates the pictogram element.
 IReason updateNeeded(IUpdateContext context)
          Check whether the values in the pictogram element are up to date, that means whether the graphics algorithm of this pictogram element contain the latest values from the business objects.
protected  void updatePictogramElement(PictogramElement pe)
          Update pictogram element.
 
Methods inherited from class org.eclipse.graphiti.pattern.AbstractBasePattern
add, canAdd, getBusinessObjectForPictogramElement, getDiagram, getDiagramEditor, getFeatureProvider, getMappingProvider, link, link, manageColor, manageColor, setFeatureProvider
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.graphiti.pattern.IPattern
add, canAdd, setFeatureProvider
 

Field Detail

EMPTY_STRING_ARRAY

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


patternConfiguration

private IPatternConfiguration patternConfiguration

wrappedDeleteFeature

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


wrappedRemoveFeature

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

Constructor Detail

AbstractPattern

public AbstractPattern(IPatternConfiguration patternConfiguration)
Creates a new AbstractPattern.

Parameters:
patternConfiguration - the pattern configuration
Method Detail

isPaletteApplicable

public boolean isPaletteApplicable()
Description copied from interface: IPattern
Determines whether the pattern supports the creation of new business objects from the palette. Setting this to false will suppress the creation of a palette item for this pattern.

Specified by:
isPaletteApplicable in interface IPattern
Returns:
true if the pattern supports the ICreate methods and a palette item should be generated

canCreate

public boolean canCreate(ICreateContext context)
Description copied from interface: ICreate
Checks if business object can be created for the given context.

Specified by:
canCreate in interface ICreate
Parameters:
context - the context
Returns:
true if create is possible.

canLayout

public boolean canLayout(ILayoutContext context)
Description copied from interface: ILayout
Checks whether the current pictogram element of the given context can be layouted.

Specified by:
canLayout in interface ILayout
Parameters:
context - the context
Returns:
true if update is possible

canMoveShape

public boolean canMoveShape(IMoveShapeContext context)
Description copied from interface: IMoveShape
Can move shape.

Specified by:
canMoveShape in interface IMoveShape
Parameters:
context - the context
Returns:
true, if successful

canResizeShape

public boolean canResizeShape(IResizeShapeContext context)
Description copied from interface: IResizeShape
Can resize shape.

Specified by:
canResizeShape in interface IResizeShape
Parameters:
context - the context
Returns:
true, if successful

canUpdate

public boolean canUpdate(IUpdateContext context)
Description copied from interface: IUpdate
Checks whether the values of the current pictogram element of the given context can be updated.

Specified by:
canUpdate in interface IUpdate
Parameters:
context - the context
Returns:
true if update is possible

create

public Object[] create(ICreateContext context)
Description copied from interface: ICreate
Creates the business object for the given context.

Specified by:
create in interface ICreate
Parameters:
context - the context
Returns:
the newly created objects

getCreateDescription

public String getCreateDescription()
Description copied from interface: IPattern
Gets the create description.

Specified by:
getCreateDescription in interface ICreateInfo
Specified by:
getCreateDescription in interface IPattern
Returns:
description for UI representation

getCreateImageId

public String getCreateImageId()
Description copied from interface: ICreateInfo
Gets the create image id.

Specified by:
getCreateImageId in interface ICreateInfo
Returns:
image for UI representation

getCreateLargeImageId

public String getCreateLargeImageId()
Description copied from interface: ICreateInfo
Gets the create large image id.

Specified by:
getCreateLargeImageId in interface ICreateInfo
Returns:
large image for UI representation

getCreateName

public String getCreateName()
Description copied from interface: IPattern
Gets the create name.

Specified by:
getCreateName in interface ICreateInfo
Specified by:
getCreateName in interface IPattern
Returns:
name for UI representation

isMainBusinessObjectApplicable

public abstract boolean isMainBusinessObjectApplicable(Object mainBusinessObject)
Description copied from interface: IPattern
This method must be implemented by the pattern user. The main pictogram element of the pattern is linked with the main business object.

Specified by:
isMainBusinessObjectApplicable in interface IPattern
Parameters:
mainBusinessObject - the main business object
Returns:
True, if this pattern is responsible for the main business object

layout

public boolean layout(ILayoutContext context)
Description copied from interface: ILayout
Layoutes the pictogram element.

Specified by:
layout in interface ILayout
Parameters:
context - the context
Returns:
true, if update process was successfull

moveShape

public final void moveShape(IMoveShapeContext context)
Description copied from interface: IMoveShape
Move shape.

Specified by:
moveShape in interface IMoveShape
Parameters:
context - the context

postMoveShape

protected void postMoveShape(IMoveShapeContext context)
Post move shape.

Parameters:
context - the move shape context

preMoveShape

protected void preMoveShape(IMoveShapeContext context)
Pre move shape.

Parameters:
context - the move shape context

internalMove

protected void internalMove(IMoveShapeContext context)
Internal move.

Parameters:
context - the move shape context

moveAllBendpoints

protected void moveAllBendpoints(IMoveShapeContext context)
Move all bendpoints within a container shape.

Parameters:
context - the move shape context

getAnchors

private List<Anchor> getAnchors(ContainerShape containerShape)

resizeShape

public void resizeShape(IResizeShapeContext context)
Description copied from interface: IResizeShape
Resize shape.

Specified by:
resizeShape in interface IResizeShape
Parameters:
context - the context

update

public boolean update(IUpdateContext context)
Description copied from interface: IUpdate
Updates the pictogram element. It copies the latest values from the business model to the graphics algorithm of this pictogram elements.

Specified by:
update in interface IUpdate
Parameters:
context - the context
Returns:
true, if update process was successfull

updateNeeded

public IReason updateNeeded(IUpdateContext context)
Description copied from interface: IUpdate
Check whether the values in the pictogram element are up to date, that means whether the graphics algorithm of this pictogram element contain the latest values from the business objects.

Specified by:
updateNeeded in interface IUpdate
Parameters:
context - the context
Returns:
true if parts of the pictogram model needs to be updated with the latest values from the business model

addGraphicalRepresentation

protected void addGraphicalRepresentation(IAreaContext context,
                                          Object newObject)
Adds the graphical representation.

Parameters:
context - the area context
newObject - the new object

avoidNegativeCoordinates

protected boolean avoidNegativeCoordinates()
Returns:
true if moving to negative coordinates should not be possible

getImage

protected String getImage(IStructureMapping structureMapping,
                          PictogramLink link)
Gets the image.

Parameters:
structureMapping - the structure mapping
link - the pictogram link
Returns:
the image

getText

protected String getText(IStructureMapping structureMapping,
                         PictogramLink link)
Gets the text.

Parameters:
structureMapping - the structure mapping
link - the pictogram link
Returns:
the text

isPatternControlled

protected abstract boolean isPatternControlled(PictogramElement pictogramElement)
This method must be implemented by the pattern developer / provider.

Parameters:
pictogramElement - the pictogram element
Returns:
true, if is pattern controlled

isPatternRoot

protected abstract boolean isPatternRoot(PictogramElement pictogramElement)
This method must be implemented by the pattern developer / provider.

Parameters:
pictogramElement - the pictogram element
Returns:
true, if is pattern root

layoutPictogramElement

protected void layoutPictogramElement(PictogramElement pe)
Layout pictogram element.

Parameters:
pe - the pictogram element

updatePictogramElement

protected void updatePictogramElement(PictogramElement pe)
Update pictogram element.

Parameters:
pe - the pictogram element

setPatternConfiguration

protected void setPatternConfiguration(IPatternConfiguration patternConfiguration)
Sets the pattern configuration.

Parameters:
patternConfiguration - the new patternConfiguration

getPatternConfiguration

protected IPatternConfiguration getPatternConfiguration()
Gets the pattern configuration.

Returns:
the patternConfiguration

completeInfo

public void completeInfo(IDirectEditingInfo info,
                         Object bo)
Description copied from interface: IPattern
Complete the directEditing info. This information is needed to switch automatically into the direct editing mode. (e.g. after creation of a new object)

Specified by:
completeInfo in interface IPattern
Parameters:
info - the directEditing info
bo - the business object

completeInfo

public void completeInfo(IDirectEditingInfo info,
                         Object bo,
                         String keyProperty)
Description copied from interface: IPattern
Complete the directEditing info. This information is needed to switch automatically into the direct editing mode. (e.g. after creation of a new object)

Specified by:
completeInfo in interface IPattern
Parameters:
info - the directEditing info
bo - the business object
keyProperty - the key property

getResizeConfiguration

public IResizeConfiguration getResizeConfiguration(IResizeShapeContext context)
Description copied from interface: IPattern
Provides configuration object, which describes the resize behavior.

Specified by:
getResizeConfiguration in interface IPattern
Parameters:
context - the resizing context
Returns:
the resize configuration object

createDeleteFeature

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

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

canDelete

public boolean canDelete(IDeleteContext context)
Description copied from interface: IDelete
Can delete.

Specified by:
canDelete in interface IDelete
Parameters:
context - the context
Returns:
true, if successful

preDelete

public void preDelete(IDeleteContext context)
Description copied from interface: IDelete
Pre delete.

Specified by:
preDelete in interface IDelete
Parameters:
context - the context

delete

public void delete(IDeleteContext context)
Description copied from interface: IDelete
Delete.

Specified by:
delete in interface IDelete
Parameters:
context - the context

postDelete

public void postDelete(IDeleteContext context)
Description copied from interface: IDelete
Post delete.

Specified by:
postDelete in interface IDelete
Parameters:
context - the context

createRemoveFeature

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

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

canRemove

public boolean canRemove(IRemoveContext context)
Description copied from interface: IRemove
Checks if given object could be removed.

Specified by:
canRemove in interface IRemove
Parameters:
context - contains object to remove
Returns:
true if remove is possible

preRemove

public void preRemove(IRemoveContext context)
Description copied from interface: IRemove
called prior to remove call.

Specified by:
preRemove in interface IRemove
Parameters:
context - the context

remove

public void remove(IRemoveContext context)
Description copied from interface: IRemove
Remove the given object.

Specified by:
remove in interface IRemove
Parameters:
context - contains object to remove

postRemove

public void postRemove(IRemoveContext context)
Description copied from interface: IRemove
called after remove call.

Specified by:
postRemove in interface IRemove
Parameters:
context - the context

canDirectEdit

public boolean canDirectEdit(IDirectEditingContext context)
Description copied from interface: IDirectEditing
Checks if the feature can perform direct editing on the context handed over.

Specified by:
canDirectEdit in interface IDirectEditing
Parameters:
context - the context
Returns:
This method is equivalent to
See Also:
IFeature.canExecute(org.eclipse.graphiti.features.context.IContext)

checkValueValid

public String checkValueValid(String value,
                              IDirectEditingContext context)
Description copied from interface: IDirectEditing
This method will be called by clients many times to see if current value is valid and could be set.

Specified by:
checkValueValid in interface IDirectEditing
Parameters:
value - the value
context - the context
Returns:
null if value is okay and could be set; any text means value is not valid; text is reason for invalidality

completeValue

public String completeValue(String value,
                            int caretPos,
                            String choosenValue,
                            IDirectEditingContext context)
Description copied from interface: IDirectEditing
Framework calls this method to let the feature calculate the new value.

Specified by:
completeValue in interface IDirectEditing
Parameters:
value - current value
caretPos - current cursor position
choosenValue - value choosen by user
context - the context
Returns:
the new value

getPossibleValues

public String[] getPossibleValues(IDirectEditingContext context)
Description copied from interface: IDirectEditing
This value will be used if the cell editor is a combo box. This functionality only applies to TYPE_DROPDOWN.

Specified by:
getPossibleValues in interface IDirectEditing
Parameters:
context - the context
Returns:
the possible values for the combo box.

getValueProposals

public String[] getValueProposals(String value,
                                  int caretPos,
                                  IDirectEditingContext context)
Description copied from interface: IDirectEditing
This proposals will be used for the completion list of a simple text cell editor. This functionality only applies to TYPE_TEXT.

Specified by:
getValueProposals in interface IDirectEditing
Parameters:
value - current value
caretPos - current cursor position
context - the context
Returns:
the proposed values

isAutoCompletionEnabled

public boolean isAutoCompletionEnabled()
Description copied from interface: IDirectEditing
Checks if auto completion is enabled. This functionality only applies to TYPE_TEXT.

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

isCompletionAvailable

public boolean isCompletionAvailable()
Description copied from interface: IDirectEditing
Checks if completion is available. This functionality only applies to TYPE_TEXT.

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

stretchFieldToFitText

public boolean stretchFieldToFitText()
Description copied from interface: IDirectEditing
Stretch input field to fit its contents. This functionality applies to TYPE_TEXT, TYPE_DROPDOWN and TYPE_DROPDOWN_READ_ONLY.

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

getEditingType

public int getEditingType()
Description copied from interface: IDirectEditing
Framework calls this method to decide which UI to show up.

Specified by:
getEditingType in interface IDirectEditing
Returns:
the editing type

getInitialValue

public String getInitialValue(IDirectEditingContext context)
Description copied from interface: IDirectEditing
Provides the initial value for the opened text editing UI component.

Specified by:
getInitialValue in interface IDirectEditing
Parameters:
context - the context
Returns:
the initial value

setValue

public void setValue(String value,
                     IDirectEditingContext context)
Description copied from interface: IDirectEditing
Set the new value. The value comes from the text editing UI component.

Specified by:
setValue in interface IDirectEditing
Parameters:
value - the value
context - the context

getProposalSupport

public IProposalSupport getProposalSupport()
Description copied from interface: IDirectEditing
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 customer wants to work with Objects he must provide an implementation of IProposalSupport. In this case the following methods of IDirectEditing 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);

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


Copyright (c) SAP AG 2005, 2010.