org.eclipse.graphiti.features.impl
Class AbstractDirectEditingFeature

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

public abstract class AbstractDirectEditingFeature
extends AbstractFeature
implements IDirectEditingFeature

The Class AbstractDirectEditingFeature.


Field Summary
protected static java.lang.String[] EMPTY_STRING_ARRAY
          The Constant EMPTY_STRING_ARRAY.
private static java.lang.String NAME
           
private  boolean valueChanged
          Used to track if direct editing did really change anything.
 
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
AbstractDirectEditingFeature(IFeatureProvider fp)
          Creates a new AbstractDirectEditingFeature.
 
Method Summary
 boolean canDirectEdit(IDirectEditingContext context)
          Checks if the feature can perform direct editing on the context handed over.
 boolean canExecute(IContext context)
          Decides if the current feature can execute with the given context.
 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.
 void execute(IContext context)
          Executes the current feature with the given context.
 java.lang.String getName()
          Gets the name.
 java.lang.String[] getPossibleValues(IDirectEditingContext context)
          This value will be used if the cell editor is 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 hasDoneChanges()
          Returns true only if the direct editing feature really has changed anything.
 boolean isAutoCompletionEnabled()
          Checks if auto completion is enabled.
 boolean isCompletionAvailable()
          Checks if completion is available.
 void setValueChanged()
          Called by the framework (@see DirectEditingFeatureCommandWithContext) to indicate that this direct editing feature execution has really changed something.
 boolean stretchTextfieldToFitText()
          Stretch textfield to fit text.
 
Methods inherited from class org.eclipse.graphiti.features.impl.AbstractFeature
addGraphicalRepresentation, canUndo, 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.func.IDirectEditing
getEditingType, getInitialValue, setValue
 
Methods inherited from interface org.eclipse.graphiti.features.IFeature
canUndo, isAvailable
 
Methods inherited from interface org.eclipse.graphiti.IDescription
getDescription
 
Methods inherited from interface org.eclipse.graphiti.features.IFeatureProviderHolder
getFeatureProvider
 

Field Detail

EMPTY_STRING_ARRAY

protected static final java.lang.String[] EMPTY_STRING_ARRAY
The Constant EMPTY_STRING_ARRAY.


valueChanged

private boolean valueChanged
Used to track if direct editing did really change anything.


NAME

private static final java.lang.String NAME
Constructor Detail

AbstractDirectEditingFeature

public AbstractDirectEditingFeature(IFeatureProvider fp)
Creates a new AbstractDirectEditingFeature.

Parameters:
fp - the fp
Method Detail

canExecute

public boolean canExecute(IContext context)
Description copied from interface: IFeature
Decides if the current feature can execute with the given context.

Specified by:
canExecute in interface IFeature
Parameters:
context - this is the general input for this method
Returns:
true if the feature can be executed, false if not
See Also:
IContext

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:
IDirecEditingFeature.canExecute()

execute

public void execute(IContext context)
Description copied from interface: IFeature
Executes the current feature with the given context.

Specified by:
execute in interface IFeature
Parameters:
context - this is the general input for this method
See Also:
IContext

hasDoneChanges

public boolean hasDoneChanges()
Returns true only if the direct editing feature really has changed anything. This is indicated by the execution of the feature in the DirectEditingFeatureCommandWithContext.execute method

Specified by:
hasDoneChanges in interface IFeature
Overrides:
hasDoneChanges in class AbstractFeature
Returns:
true if the feature should appear in the undo stack, false otherwise
See Also:
org.eclipse.graphiti.features.impl.AbstractFeature#isUndoable()

setValueChanged

public final void setValueChanged()
Called by the framework (@see DirectEditingFeatureCommandWithContext) to indicate that this direct editing feature execution has really changed something. Only in this case there should be an entry in the undo stack and the editor should get dirty.


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
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
Parameters:
value - current value
caretPos - current cursor position
context - the context
Returns:
the proposed values

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
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
Parameters:
value - current value
caretPos - current cursor position
choosenValue - value choosen by user
context - the context
Returns:
the new value

stretchTextfieldToFitText

public boolean stretchTextfieldToFitText()
Description copied from interface: IDirectEditing
Stretch textfield to fit text. This functionality only applies to TYPE_TEXT.

Specified by:
stretchTextfieldToFitText in interface IDirectEditing
Returns:
true if the text field should exactly fit the inserted text

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

getName

public java.lang.String getName()
Description copied from interface: IName
Gets the name.

Specified by:
getName in interface IName
Overrides:
getName in class AbstractFeature
Returns:
the name


Copyright (c) SAP AG 2005, 2010.