IValueEditor Interface

IValueEditor Interface

This Package | All Packages

public interface IValueEditor

The IValueEditor interface represents the implementation of an editor for values of a given type. The primary use of value editors is to edit property values in a property inspector. A class provides a value editor by implementing a public static inner class named "Editor" which in turn implements the IValueEditor interface. This method of implementation allows the value editor to be separated from the class itself in situations where the value editor is not required (such as when the class is deployed). The following example shows a class called Color and its associated value editor:


  public class Color
  {
    // Members of class Color

    public static class Editor implements IValueEditor
    {
      // Implementations of IValueEditor methods
    }
  }

When a class implements a value editor, the value editor implementation is automatically inherited by subclasses that don't implement their own value editors.

To create an instance of a value editor, the component manager first looks for a constructor that takes a single argument of type java.lang.Class. If such a constructor exists, it is called with the actual Class object for which the value editor is being created. Otherwise, the component manager calls the parameterless constructor of the value editor class.

The ComponentManager provides the ability to register value editors for a particular type through the registerValueEditorClass() method. This is useful for value editors that aren't implemented as inner classes.

The core.ValueEditor class provides a default implementation of the IValueEditor interface. Value editors may choose to inherit from ValueEditor instead of implementing the entire IValueEditor interface.

Fields
Name Description
STYLE_DROPDOWNARROW Bit mask for getStyle() method.
STYLE_EDITVALUE Bit mask for getStyle() method.
STYLE_IMMEDIATE Bit mask for getStyle() method.
STYLE_NOARRAYEXPANSION Topic under construction.
STYLE_NOVALUEFROMTEXT Bit mask for getStyle() method.
STYLE_PAINTVALUE Bit mask for getStyle() method.
STYLE_PROPERTIES Bit mask for getStyle() method.
STYLE_SHOWFIELDS Bit mask for getStyle() method.
STYLE_VALUES Bit mask for getStyle() method.

Methods
Name Description
editValue(IValueAccess valueAccess) Topic under construction.
getConstantName(Object value) Returns the fully qualified name of a constant that represents the given value, or returns null if there is no constant for the value.
getStyle() Returns the style flags for the value editor.
getSubProperties(Object value) Returns the subproperties to be displayed under the object.
getTextFromValue(Object value) Converts the given value to a text string.
getValueFromText(String text) Converts the given text string to a value.
getValues() Returns a list of possible values for the value editor's type.
paintValue(Object value, Graphics g, Rectangle rect) Paints a representation of the given value in the given Rectangle of the given Graphics.

Fields

IValueEditor.STYLE_DROPDOWNARROW

Syntax
public static final int STYLE_DROPDOWNARROW;
Description
Bit mask for getStyle() method. Indicates that if STYLE_EDITVALUE is returned, a drop-down arrow should be shown instead of an ellipsis button.

IValueEditor.STYLE_EDITVALUE

Syntax
public static final int STYLE_EDITVALUE;
Description
Bit mask for getStyle() method. Indicates that the value editor implements the editValue() method. This style typically causes a property editor to display an ellipsis button for properties of the value editor's type.

IValueEditor.STYLE_IMMEDIATE

Syntax
public static final int STYLE_IMMEDIATE;
Description
Bit mask for getStyle() method. Indicates that values of this type are suitable for updating even when the new value is incomplete. This style typically causes a property editor to update the underlying property after each change made in the editor (for example, as each character is typed in an edit box).

IValueEditor.STYLE_NOARRAYEXPANSION

Syntax
public static final int STYLE_NOARRAYEXPANSION;
Description
Topic under construction.

IValueEditor.STYLE_NOVALUEFROMTEXT

Syntax
public static final int STYLE_NOVALUEFROMTEXT;
Description
Bit mask for getStyle() method. Indicates that the value editor does not implement the getValueFromText() method. This style typically causes a property editor to disallow typing in the edit box for properties of the value editor's type.

IValueEditor.STYLE_PAINTVALUE

Syntax
public static final int STYLE_PAINTVALUE;
Description
Bit mask for getStyle() method. Indicates that the value editor implements the paintValue() method. This style typically causes a property editor to paint a representation of properties of the value editor's type.

IValueEditor.STYLE_PROPERTIES

Syntax
public static final int STYLE_PROPERTIES;
Description
Bit mask for getStyle() method. Indicates that values of this type can have their constructor args browseable as properties.

IValueEditor.STYLE_SHOWFIELDS

Syntax
public static final int STYLE_SHOWFIELDS;
Description
Bit mask for getStyle() method. Indicates that a browser should show the fields of the component being edited.

IValueEditor.STYLE_VALUES

Syntax
public static final int STYLE_VALUES;
Description
Bit mask for getStyle() method. Indicates that the value editor implements the getValues() method. This style typically causes a property editor to display a drop-down list for properties of the value editor's type.

Methods

IValueEditor.editValue

Syntax
public void editValue( IValueAccess valueAccess );
Description

Topic under construction.

IValueEditor.getConstantName

Syntax
public String getConstantName( Object value );
Description

Returns the fully qualified name of a constant that represents the given value, or returns null if there is no constant for the value. The returned value must consist of a fully qualified class name followed by a period followed by the identifier of a public static final field of the given class, for example, "wfc.ui.Color.BLACK". This method is typically used by a design-time environment that generates source code to initialize a component's properties.

IValueEditor.getStyle

Syntax
public int getStyle();
Description

Returns the style flags for the value editor. The returned value must be a combination of the STYLE_XXX bit masks defined in this interface.

IValueEditor.getSubProperties

Syntax
public SubProperty[] getSubProperties( Object value );
Description

Returns the subproperties to be displayed under the object.

IValueEditor.getTextFromValue

Syntax
public String getTextFromValue( Object value );
Description

Converts the given value to a text string. The return value may be null if the value cannot be converted to a text string.

IValueEditor.getValueFromText

Syntax
public Object getValueFromText( String text );
Description

Converts the given text string to a value. This method is not called if the value editor specifies the STYLE_NOVALUEFROMTEXT style.

IValueEditor.getValues

Syntax
public Object[] getValues();
Description

Returns a list of possible values for the value editor's type. To display these values in a drop-down list, a property editor typically calls getTextFromValue() for each of the values in the list.

IValueEditor.paintValue

Syntax
public void paintValue( Object value, Graphics g, Rectangle rect );
Description

Paints a representation of the given value in the given Rectangle of the given Graphics. This method is called only if the value editor specifies the STYLE_PAINTVALUE style.