com.threerings.editor.swing
Class PropertyEditor

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.samskivert.swing.CollapsiblePanel
                      extended by com.threerings.editor.swing.BasePropertyEditor
                          extended by com.threerings.editor.swing.PropertyEditor
All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible
Direct Known Subclasses:
ArrayListEditor, BooleanEditor, ChoiceEditor, Color4fEditor, ColorizationEditor, ConfigEditor, ConfigReferenceEditor, EnumEditor, FileEditor, MaskEditor, NumberEditor, ObjectEditor, QuaternionEditor, StringEditor, Transform2DEditor, Transform3DEditor, Vector2fEditor, Vector3fEditor

public abstract class PropertyEditor
extends BasePropertyEditor

Edits a single object property.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected static HashMap<String,Class<? extends PropertyEditor>> _classesByName
          Maps names to editor classes.
protected static HashMap<Class<?>,Class<? extends PropertyEditor>> _classesByType
          Maps types to editor classes.
protected  EditorContext _ctx
          Provides access to common services.
protected  Property[] _lineage
          The ancestors of the property (if any), followed by the property itself.
protected  Object _object
          The object being edited.
protected  Property _property
          The property being edited.
 
Fields inherited from class com.threerings.editor.swing.BasePropertyEditor
_collapseIcon, _expandIcon, _highlight, _highlighted, _highlightIcon, _msgmgr, _msgs, BASE_BACKGROUND, DEFAULT_BACKGROUND, PANEL_BUTTON_SIZE, SHADE_DECREMENT
 
Fields inherited from class com.samskivert.swing.CollapsiblePanel
_content, _downIcon, _trigger, _upIcon
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PropertyEditor()
           
 
Method Summary
static PropertyEditor createEditor(EditorContext ctx, Property property, Property[] ancestors)
          Creates a property editor for the specified object property.
protected  void didInit()
          Override to perform custom initialization.
protected static Object getDefaultInstance(Class<?> type, Object outer)
          Returns a default instance for the supplied type, either by instantiating it with its no-arg constructor or by obtaining some type-specific default;
protected  double getMaximum()
          Gets the maximum value by walking up the lineage.
protected  int getMaxSize()
          Gets the maximum size by walking up the lineage.
protected  double getMinimum()
          Gets the minimum value by walking up the lineage.
protected  int getMinSize()
          Gets the minimum size by walking up the lineage.
protected  String getMode()
          Gets the mode string by walking up the lineage.
 Object getObject()
          Returns a reference to the object being edited.
 Property getProperty()
          Returns a reference to the edited property.
protected  int getPropertyColor()
          Returns the base color for this property.
protected  String getPropertyLabel()
          Returns the name of the property, translating it if a translation exists.
protected  double getScale()
          Gets the scale by walking up the lineage.
protected  double getStep()
          Gets the step by walking up the lineage.
protected  String getUnits()
          Gets the units string by walking up the lineage.
 void init(EditorContext ctx, Property property, Property[] ancestors)
          Initializes the editor with its object and property references.
protected static boolean isTableCellType(Class<?> type)
          Checks whether the supplied type can be edited in the cell of a table.
static void registerEditorClass(Class<?> type, Class<? extends PropertyEditor> clazz)
          Adds a custom editor class for properties of the given type.
static void registerEditorClass(String name, Class<? extends PropertyEditor> clazz)
          Adds a custom editor by name.
 void setObject(Object object)
          Sets the object being edited.
abstract  void update()
          Updates the state of the editor from the object.
 
Methods inherited from class com.threerings.editor.swing.BasePropertyEditor
actionPerformed, addChangeListener, copyPropertyPath, createButton, darkenColor, fireStateChanged, getBackgroundColor, getColor, getColor, getColor, getDarkerBackground, getLabel, getLabel, getLabel, getLabel, getLabels, getLabels, getLabels, getMousePath, getMousePath, getPropertyColor, loadIcon, makeCollapsible, removeChangeListener, updateBorder
 
Methods inherited from class com.samskivert.swing.CollapsiblePanel
getContent, isCollapsed, setCollapsed, setGap, setTrigger, setTriggerContainer, setTriggerContainer, setTriggerContainer
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_ctx

protected EditorContext _ctx
Provides access to common services.


_property

protected Property _property
The property being edited.


_lineage

protected Property[] _lineage
The ancestors of the property (if any), followed by the property itself.


_object

protected Object _object
The object being edited.


_classesByName

protected static HashMap<String,Class<? extends PropertyEditor>> _classesByName
Maps names to editor classes.


_classesByType

protected static HashMap<Class<?>,Class<? extends PropertyEditor>> _classesByType
Maps types to editor classes.

Constructor Detail

PropertyEditor

public PropertyEditor()
Method Detail

createEditor

public static PropertyEditor createEditor(EditorContext ctx,
                                          Property property,
                                          Property[] ancestors)
Creates a property editor for the specified object property.

Parameters:
ancestors - the ancestor properties from which to inherit constraints, if any.

registerEditorClass

public static void registerEditorClass(Class<?> type,
                                       Class<? extends PropertyEditor> clazz)
Adds a custom editor class for properties of the given type.


registerEditorClass

public static void registerEditorClass(String name,
                                       Class<? extends PropertyEditor> clazz)
Adds a custom editor by name.


init

public void init(EditorContext ctx,
                 Property property,
                 Property[] ancestors)
Initializes the editor with its object and property references.


getProperty

public Property getProperty()
Returns a reference to the edited property.


setObject

public void setObject(Object object)
Sets the object being edited.


getObject

public Object getObject()
Returns a reference to the object being edited.


update

public abstract void update()
Updates the state of the editor from the object.


didInit

protected void didInit()
Override to perform custom initialization.


getPropertyLabel

protected String getPropertyLabel()
Returns the name of the property, translating it if a translation exists.


getPropertyColor

protected int getPropertyColor()
Returns the base color for this property.


getMode

protected String getMode()
Gets the mode string by walking up the lineage.


getUnits

protected String getUnits()
Gets the units string by walking up the lineage.


getMinimum

protected double getMinimum()
Gets the minimum value by walking up the lineage.


getMaximum

protected double getMaximum()
Gets the maximum value by walking up the lineage.


getStep

protected double getStep()
Gets the step by walking up the lineage.


getScale

protected double getScale()
Gets the scale by walking up the lineage.


getMinSize

protected int getMinSize()
Gets the minimum size by walking up the lineage.


getMaxSize

protected int getMaxSize()
Gets the maximum size by walking up the lineage.


isTableCellType

protected static boolean isTableCellType(Class<?> type)
Checks whether the supplied type can be edited in the cell of a table.


getDefaultInstance

protected static Object getDefaultInstance(Class<?> type,
                                           Object outer)
Returns a default instance for the supplied type, either by instantiating it with its no-arg constructor or by obtaining some type-specific default;