org.eclipse.graphiti.pattern
Class DirectEditingFeatureForPattern

java.lang.Object
  extended by org.eclipse.graphiti.features.impl.AbstractFeature
      extended by org.eclipse.graphiti.features.impl.AbstractDirectEditingFeature
          extended by org.eclipse.graphiti.pattern.DirectEditingFeatureForPattern
All Implemented Interfaces:
ICustomUndoableFeature, IDirectEditingFeature, IFeature, IFeatureProviderHolder, IDirectEditing, IDescription, IName

public class DirectEditingFeatureForPattern
extends AbstractDirectEditingFeature
implements ICustomUndoableFeature

This feature wraps the direct editing functionality of a pattern for calls of the Graphiti framework. Clients should not need to use this class directly.


Field Summary
private  IDirectEditing delegate
           
 
Fields inherited from class org.eclipse.graphiti.features.impl.AbstractDirectEditingFeature
EMPTY_STRING_ARRAY
 
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
DirectEditingFeatureForPattern(IFeatureProvider featureProvider, IDirectEditing pattern)
          Creates a new DirectEditingFeatureForPattern.
 
Method Summary
 boolean canDirectEdit(IDirectEditingContext context)
          Checks if the feature can perform direct editing on the context handed over.
 boolean canRedo(IContext context)
          Decides if the processed feature can be re-done.
 boolean canUndo(IContext context)
          Decides if the current feature can be undone - this is the undo of the execute operation.
 java.lang.String checkValueValid(java.lang.String value, IDirectEditingContext context)
          This method will be called by clients many times to see if current value is valid and could be set.
 java.lang.String completeValue(java.lang.String value, int caretPos, java.lang.String choosenValue, IDirectEditingContext context)
          Framework calls this method to let the feature calculate the new value.
 int getEditingType()
          Framework calls this method to decide which UI to show up.
 java.lang.String getInitialValue(IDirectEditingContext context)
          Provides the initial value for the 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.
 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 isAutoCompletionEnabled()
          Checks if auto completion is enabled.
 boolean isCompletionAvailable()
          Checks if completion is available.
 void redo(IContext context)
          This method will be called to actually do the work needed for redo.
 void setValue(java.lang.String value, IDirectEditingContext context)
          Set the new value.
 boolean stretchFieldToFitText()
          Stretch input field to fit its contents.
 void undo(IContext context)
          This method will be called to actually do the work needed for undo.
 
Methods inherited from class org.eclipse.graphiti.features.impl.AbstractDirectEditingFeature
canExecute, execute, getName, hasDoneChanges, setValueChanged
 
Methods inherited from class org.eclipse.graphiti.features.impl.AbstractFeature
addGraphicalRepresentation, getAllBusinessObjectsForPictogramElement, getBusinessObjectForPictogramElement, getDescription, getDiagram, getDiagramEditor, getFeatureProvider, getProgressCallback, getUserDecision, isAvailable, layoutPictogramElement, link, link, manageColor, manageColor, setProgressCallback, toString, updatePictogramElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.graphiti.features.IFeature
isAvailable
 
Methods inherited from interface org.eclipse.graphiti.IDescription
getDescription
 
Methods inherited from interface org.eclipse.graphiti.features.IFeatureProviderHolder
getFeatureProvider
 

Field Detail

delegate

private IDirectEditing delegate
Constructor Detail

DirectEditingFeatureForPattern

public DirectEditingFeatureForPattern(IFeatureProvider featureProvider,
                                      IDirectEditing pattern)
Creates a new DirectEditingFeatureForPattern.

Parameters:
featureProvider - the feature provider
pattern - the pattern
Method Detail

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
Overrides:
canDirectEdit in class AbstractDirectEditingFeature
Parameters:
context - the context
Returns:
This method is equivalent to
See Also:
IFeature.canExecute(org.eclipse.graphiti.features.context.IContext)

checkValueValid

public java.lang.String checkValueValid(java.lang.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
Overrides:
checkValueValid in class AbstractDirectEditingFeature
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 java.lang.String completeValue(java.lang.String value,
                                      int caretPos,
                                      java.lang.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
Overrides:
completeValue in class AbstractDirectEditingFeature
Parameters:
value - current value
caretPos - current cursor position
choosenValue - value choosen by user
context - the context
Returns:
the new value

getPossibleValues

public java.lang.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
Overrides:
getPossibleValues in class AbstractDirectEditingFeature
Parameters:
context - the context
Returns:
the possible values for the combo box.

getValueProposals

public java.lang.String[] getValueProposals(java.lang.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
Overrides:
getValueProposals in class AbstractDirectEditingFeature
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
Overrides:
isAutoCompletionEnabled in class AbstractDirectEditingFeature
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
Overrides:
isCompletionAvailable in class AbstractDirectEditingFeature
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
Overrides:
stretchFieldToFitText in class AbstractDirectEditingFeature
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 java.lang.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(java.lang.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
Overrides:
setValue in class AbstractDirectEditingFeature
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
Overrides:
getProposalSupport in class AbstractDirectEditingFeature
Returns:
the special implementation to support Objects in code completion and combo box

canUndo

public boolean canUndo(IContext context)
Description copied from interface: IFeature
Decides if the current feature can be undone - this is the undo of the execute operation.

Specified by:
canUndo in interface ICustomUndoableFeature
Specified by:
canUndo in interface IFeature
Overrides:
canUndo in class AbstractFeature
Parameters:
context - this is the general input for this method
Returns:
true if the feature can be undone, false if not
See Also:
IContext

undo

public void undo(IContext context)
Description copied from interface: ICustomUndoableFeature
This method will be called to actually do the work needed for undo. Customers may revert their non-EMF changes done by the feature here.

Specified by:
undo in interface ICustomUndoableFeature
Parameters:
context - this is the instance of the IContext object that was in use when executing the feature
Since:
0.8

canRedo

public boolean canRedo(IContext context)
Description copied from interface: ICustomUndoableFeature
Decides if the processed feature can be re-done.

Note that as soon as any feature reports false here, also all consecutive entries in the command stack are no longer reachable for redo.

Specified by:
canRedo in interface ICustomUndoableFeature
Parameters:
context - this is the instance of the IContext object that was in use when executing the feature
Returns:
true if the feature can be re-done, false if not
Since:
0.8

redo

public void redo(IContext context)
Description copied from interface: ICustomUndoableFeature
This method will be called to actually do the work needed for redo. Customers may re-apply their non-EMF changes done by the feature here. (Usually it might be sufficient to delegate to the execution method of the feature.)

Specified by:
redo in interface ICustomUndoableFeature
Parameters:
context - this is the instance of the IContext object that was in use when executing the feature
Since:
0.8


Copyright (c) SAP AG 2005, 2012.