org.eclipse.gmf.runtime.lite.edit.parts.labels
Class AbstractFeatureBasedLabelTextDisplayer

java.lang.Object
  extended by org.eclipse.gmf.runtime.lite.edit.parts.labels.AbstractLabelTextDisplayer
      extended by org.eclipse.gmf.runtime.lite.edit.parts.labels.AbstractFeatureBasedLabelTextDisplayer
All Implemented Interfaces:
ILabelTextDisplayer, org.eclipse.jface.viewers.ICellEditorValidator
Direct Known Subclasses:
MessageFormatLabelTextDisplayer, NativeLabelTextDisplayer, PrintfLabelTextDisplayer, RegexpParser

public abstract class AbstractFeatureBasedLabelTextDisplayer
extends AbstractLabelTextDisplayer
implements org.eclipse.jface.viewers.ICellEditorValidator

An implementation of ILabelTextDisplayer that is based on a number of structural features of the source object.


Field Summary
protected static String EMPTY_STRING
           
 
Constructor Summary
AbstractFeatureBasedLabelTextDisplayer(org.eclipse.emf.ecore.EStructuralFeature... features)
           
 
Method Summary
protected abstract  String buildDisplayText(Object[] featureValues)
          Returns the text to be displayed by this label processor for the given values.
protected abstract  String buildEditText(Object[] featureValues)
          Returns the initial edit text to be displayed by this label processor for the given values.
 org.eclipse.emf.common.command.Command getApplyCommand(org.eclipse.emf.ecore.EObject source, String newValue)
          By default, labels are not editable.
 String getDisplayText(org.eclipse.emf.ecore.EObject source)
          Returns the text a label for the given source object should display.
 String getEditText(org.eclipse.emf.ecore.EObject source)
          By default, the edit text is the same as the display text.
protected  org.eclipse.emf.ecore.EStructuralFeature[] getFeatures()
          Returns the features used by this displayer.
 org.eclipse.jface.viewers.ICellEditorValidator getValidator()
          By default, no validation is performed.
protected  Object getValidNewValue(org.eclipse.emf.ecore.EStructuralFeature structuralFeature, Object value)
          Allows the parsed value to be replaced (e.g., to match the type of the structural feature).
protected  Object getValidValue(org.eclipse.emf.ecore.EStructuralFeature feature, Object value)
          Allows the given value to be replaced.
protected  Object[] getValues(org.eclipse.emf.ecore.EObject source)
           
 boolean isAffectingEvent(org.eclipse.emf.common.notify.Notification notification)
          Returns whether the given notification may cause a source to require update of the label.
 String isValid(Object value)
           
protected abstract  Object[] parseEditedValues(String newString)
          Returns the values that should be set to the corresponding features.
protected  boolean shouldReplaceEmptyStringsWithNulls(org.eclipse.emf.ecore.EStructuralFeature structuralFeature)
          Returns whether empty strings should be replaced with nulls when applied.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_STRING

protected static final String EMPTY_STRING
See Also:
Constant Field Values
Constructor Detail

AbstractFeatureBasedLabelTextDisplayer

public AbstractFeatureBasedLabelTextDisplayer(org.eclipse.emf.ecore.EStructuralFeature... features)
Method Detail

getDisplayText

public String getDisplayText(org.eclipse.emf.ecore.EObject source)
Description copied from interface: ILabelTextDisplayer
Returns the text a label for the given source object should display.

Specified by:
getDisplayText in interface ILabelTextDisplayer

getEditText

public String getEditText(org.eclipse.emf.ecore.EObject source)
Description copied from class: AbstractLabelTextDisplayer
By default, the edit text is the same as the display text. Clients may reimplement.

Specified by:
getEditText in interface ILabelTextDisplayer
Overrides:
getEditText in class AbstractLabelTextDisplayer

getValues

protected Object[] getValues(org.eclipse.emf.ecore.EObject source)

getValidValue

protected Object getValidValue(org.eclipse.emf.ecore.EStructuralFeature feature,
                               Object value)
Allows the given value to be replaced. By default, null strings are converted to empty strings, no other replacements are performed. Subclasses may extend or reimplement.


isAffectingEvent

public boolean isAffectingEvent(org.eclipse.emf.common.notify.Notification notification)
Description copied from interface: ILabelTextDisplayer
Returns whether the given notification may cause a source to require update of the label.

Specified by:
isAffectingEvent in interface ILabelTextDisplayer

getApplyCommand

public org.eclipse.emf.common.command.Command getApplyCommand(org.eclipse.emf.ecore.EObject source,
                                                              String newValue)
Description copied from class: AbstractLabelTextDisplayer
By default, labels are not editable. Clients may reimplement.

Specified by:
getApplyCommand in interface ILabelTextDisplayer
Overrides:
getApplyCommand in class AbstractLabelTextDisplayer

getValidator

public org.eclipse.jface.viewers.ICellEditorValidator getValidator()
Description copied from class: AbstractLabelTextDisplayer
By default, no validation is performed. Clients may reimplement.

Specified by:
getValidator in interface ILabelTextDisplayer
Overrides:
getValidator in class AbstractLabelTextDisplayer

isValid

public String isValid(Object value)
Specified by:
isValid in interface org.eclipse.jface.viewers.ICellEditorValidator

getValidNewValue

protected Object getValidNewValue(org.eclipse.emf.ecore.EStructuralFeature structuralFeature,
                                  Object value)
                           throws IllegalArgumentException
Allows the parsed value to be replaced (e.g., to match the type of the structural feature).

Throws:
IllegalArgumentException - if the value cannot be parsed for the type of the given structural feature.

shouldReplaceEmptyStringsWithNulls

protected boolean shouldReplaceEmptyStringsWithNulls(org.eclipse.emf.ecore.EStructuralFeature structuralFeature)
Returns whether empty strings should be replaced with nulls when applied.


getFeatures

protected org.eclipse.emf.ecore.EStructuralFeature[] getFeatures()
Returns the features used by this displayer.


buildDisplayText

protected abstract String buildDisplayText(Object[] featureValues)
Returns the text to be displayed by this label processor for the given values.


buildEditText

protected abstract String buildEditText(Object[] featureValues)
Returns the initial edit text to be displayed by this label processor for the given values.


parseEditedValues

protected abstract Object[] parseEditedValues(String newString)
                                       throws IllegalArgumentException
Returns the values that should be set to the corresponding features.

Throws:
IllegalArgumentException - If the given string is invalid.


Copyright © 2012. All Rights Reserved.