org.eclipse.graphiti.pattern

## Class DirectEditingFeatureForPattern

- java.lang.Object
- - org.eclipse.graphiti.features.impl.AbstractFeature
  - - org.eclipse.graphiti.features.impl.AbstractDirectEditingFeature
    - - org.eclipse.graphiti.pattern.DirectEditingFeatureForPattern

All Implemented Interfaces:
  ICustomAbortableUndoRedoFeature, ICustomUndoableFeature, ICustomUndoRedoFeature, IDirectEditingFeature, IFeature, IFeatureProviderHolder, IDirectEditing, IDescription, IName

    public class DirectEditingFeatureForPattern
    extends AbstractDirectEditingFeature
    implements ICustomUndoableFeature, ICustomAbortableUndoRedoFeature

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

### 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

Constructors
Constructor and Description
`DirectEditingFeatureForPattern(IFeatureProvider featureProvider, IDirectEditing pattern)` Creates a new `DirectEditingFeatureForPattern`.

### Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods
`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.
`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.
`String` `completeValue(String value, int caretPos, 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.
`String` `getInitialValue(IDirectEditingContext context)` Provides the initial value for the opened text editing UI component.
`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.
`String[]` `getValueProposals(String value, int caretPos, IDirectEditingContext context)` This proposals will be used for the completion list of a simple text cell editor.
`boolean` `isAbort()` The Graphiti framework will call this method after `ICustomUndoRedoFeature.preUndo(org.eclipse.graphiti.features.context.IContext)`/ `ICustomUndoRedoFeature.preRedo(org.eclipse.graphiti.features.context.IContext)` have been called and before the actual undo/redo operation is triggered.
`boolean` `isAutoCompletionEnabled()` Checks if auto completion is enabled.
`boolean` `isCompletionAvailable()` Checks if completion is available.
`void` `postRedo(IContext context)` This method will be called by the Graphiti framework after the EMF undo has finished.
`void` `postUndo(IContext context)` This method will be called by the Graphiti framework after the EMF undo is finished.
`void` `preRedo(IContext context)` This method will be called by the Graphiti framework before the EMF undo has triggered.
`void` `preUndo(IContext context)` This method will be called by the Graphiti framework before the EMF undo is triggered.
`void` `redo(IContext context)` Deprecated. use `postRedo(IContext)` instead
`void` `setValue(String value, IDirectEditingContext context)` Set the new value.
`boolean` `stretchFieldToFitText()` Stretch input field to fit its contents.
`void` `undo(IContext context)` Deprecated. use `postUndo(IContext)` instead

### 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

`getDescription, getFeatureProvider, isAvailable, manageFont, manageFont, setProgressCallback, toString`

### Methods inherited from class java.lang.Object

`equals, 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`

### 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 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`
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 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`
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 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 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`
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 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`
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

#### isAbort

    public boolean isAbort()

Description copied from interface: `ICustomAbortableUndoRedoFeature`
The Graphiti framework will call this method after `ICustomUndoRedoFeature.preUndo(org.eclipse.graphiti.features.context.IContext)`/ `ICustomUndoRedoFeature.preRedo(org.eclipse.graphiti.features.context.IContext)` have been called and before the actual undo/redo operation is triggered. 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 `ICustomUndoRedoFeature.preUndo(org.eclipse.graphiti.features.context.IContext)`/ `ICustomUndoRedoFeature.preRedo(org.eclipse.graphiti.features.context.IContext)` as cancellation indication and check that that flag here.

Specified by:
  `isAbort` in interface `ICustomAbortableUndoRedoFeature`
Returns:
  `true` in case you want to cancel the current operation, `false` otherwise.
Since:
  0.12

#### 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 `ICustomUndoRedoFeature`
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`

#### preUndo

    public void preUndo(IContext context)

Description copied from interface: `ICustomUndoRedoFeature`
This method will be called by the Graphiti framework before the EMF undo is triggered. Customers may revert their non-EMF changes done by the feature here or in `ICustomUndoRedoFeature.postUndo(IContext)`.

Specified by:
  `preUndo` in interface `ICustomUndoRedoFeature`
Parameters:
  `context` - this is the instance of the `IContext` object that was in use when executing the feature
Since:
  0.12

#### postUndo

    public void postUndo(IContext context)

Description copied from interface: `ICustomUndoRedoFeature`
This method will be called by the Graphiti framework after the EMF undo is finished. Customers may revert their non-EMF changes done by the feature here or in `ICustomUndoRedoFeature.preUndo(IContext)`.

Specified by:
  `postUndo` in interface `ICustomUndoRedoFeature`
Parameters:
  `context` - this is the instance of the `IContext` object that was in use when executing the feature
Since:
  0.12

#### undo

    public void undo(IContext context)

Deprecated. use `postUndo(IContext)` instead
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`
Specified by:
  `canRedo` in interface `ICustomUndoRedoFeature`
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

#### preRedo

    public void preRedo(IContext context)

Description copied from interface: `ICustomUndoRedoFeature`
This method will be called by the Graphiti framework before the EMF undo has triggered. Customers may re-apply their non-EMF changes done by the feature here or in `ICustomUndoRedoFeature.postRedo(IContext)`. (Usually it might be sufficient to delegate to the execution method of the feature.)

Specified by:
  `preRedo` in interface `ICustomUndoRedoFeature`
Parameters:
  `context` - this is the instance of the `IContext` object that was in use when executing the feature
Since:
  0.12

#### postRedo

    public void postRedo(IContext context)

Description copied from interface: `ICustomUndoRedoFeature`
This method will be called by the Graphiti framework after the EMF undo has finished. Customers may re-apply their non-EMF changes done by the feature here or in `ICustomUndoRedoFeature.preRedo(IContext)`. (Usually it might be sufficient to delegate to the execution method of the feature.)

Specified by:
  `postRedo` in interface `ICustomUndoRedoFeature`
Parameters:
  `context` - this is the instance of the `IContext` object that was in use when executing the feature
Since:
  0.12

#### redo

    public void redo(IContext context)

Deprecated. use `postRedo(IContext)` instead
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