org.openide.explorer.propertysheet
Class PropertyPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byorg.openide.explorer.propertysheet.PropertyPanel
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Serializable

public class PropertyPanel
extends JComponent
implements Accessible

A visual component for editing individual properties. It takes an instance of PropertyModel and displays an editor component for it.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int PREF_CUSTOM_EDITOR
          Constant defining a preference for rendering the value.
static int PREF_INPUT_STATE
          Constant defining a preference for rendering the value.
static int PREF_READ_ONLY
          Constant defining a preference for rendering the value.
static int PREF_TABLEUI
          Constant defining a preference for a borderless UI suitable for use in a table
static String PROP_MODEL
          Name of the 'model' property.
static String PROP_PREFERENCES
          Name of the 'preferences' property.
static String PROP_PROPERTY_EDITOR
          Deprecated. - the property editor is re-fetched from the underlying property object as needed. It is up to the property object to cache or not cache the property editor. This property will no longer be fired.
static String PROP_STATE
          Name of property 'state' that describes the state of the embeded PropertyEditor.
 
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
PropertyPanel()
          Creates new PropertyPanel backed by a dummy property
PropertyPanel(Node.Property p)
          Create a new property panel for displaying/editing the specified property
PropertyPanel(Node.Property p, int preferences)
          Create a new property panel for the specified property with the specified preferences.
PropertyPanel(Object bean, String propertyName, int preferences)
          Creates new PropertyPanel with DefaultPropertyModel
PropertyPanel(PropertyModel model, int preferences)
          Creates a new PropertyPanel.
 
Method Summary
 void addNotify()
          Overridden to install the inner component that will display the property
protected  void firePropertyChange(String nm, Object old, Object nue)
          Overridden to catch changes in those client properties that are relevant to PropertyPanel
 AccessibleContext getAccessibleContext()
           
 Dimension getMinimumSize()
          Overridden to return the preferred size
 PropertyModel getModel()
          Get the property model associated with this property panel.
 int getPreferences()
          Returns the preferences set for this property panel.
 Dimension getPreferredSize()
           
 Node.Property getProperty()
          Fetch the property that this PropertyPanel displays.
 PropertyEditor getPropertyEditor()
          Deprecated. The property panel does not cache the property editor, and depending on its state, it may not consistently return the same property editor instance on repeated calls. The current implementation will do so for editable states, but there is no guarantee this will remain so in the future.
 Object getState()
          Getter for the state of the property editor.
 boolean isFocusable()
          Overridden to return false in cases that the preferences specify a read-only state
 boolean isChangeImmediate()
          Getter for property changeImmediate.
protected  void processFocusEvent(FocusEvent fe)
           
 void removeNotify()
          Overridden to dispose the component that actually displays the property and any state information associated with it
 void requestFocus()
          Overridden to do nothing in a read only state, since some custom property editors (File chooser) are capable of receiving focus even if they are disabled, effectively making focus disappear
 void setBackground(Color c)
           
 void setEnabled(boolean enabled)
          Sets whether or not this component is enabled.
 void setForeground(Color c)
           
 void setChangeImmediate(boolean changeImmediate)
          Setter for property changeImmediate.
 void setModel(PropertyModel model)
          Setter for property model.
 void setPreferences(int preferences)
          Setter for visual preferences in displaying of the value of the property.
 void setProperty(Node.Property p)
          Set or change the property this PropertyPanel will display
 String toString()
          Overridden to provide information from the embedded property renderer if not in custom editor mode
 void updateValue()
          If the editor is ExPropertyEditor it tries to change the getState property to PropertyEnv.STATE_VALID state.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintComponent, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printComponent, printChildren, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, checkImage, checkImage, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PREF_READ_ONLY

public static final int PREF_READ_ONLY
Constant defining a preference for rendering the value. Value should be displayed in read-only mode.

See Also:
Constant Field Values

PREF_CUSTOM_EDITOR

public static final int PREF_CUSTOM_EDITOR
Constant defining a preference for rendering the value. Value should be displayed in custom editor.

See Also:
Constant Field Values

PREF_INPUT_STATE

public static final int PREF_INPUT_STATE
Constant defining a preference for rendering the value. Value should be displayed in editor only.

See Also:
Constant Field Values

PREF_TABLEUI

public static final int PREF_TABLEUI
Constant defining a preference for a borderless UI suitable for use in a table

See Also:
Constant Field Values

PROP_PREFERENCES

public static final String PROP_PREFERENCES
Name of the 'preferences' property.

See Also:
Constant Field Values

PROP_MODEL

public static final String PROP_MODEL
Name of the 'model' property.

See Also:
Constant Field Values

PROP_PROPERTY_EDITOR

public static final String PROP_PROPERTY_EDITOR
Deprecated. - the property editor is re-fetched from the underlying property object as needed. It is up to the property object to cache or not cache the property editor. This property will no longer be fired.

Name of the read-only property 'propertyEditor'.

See Also:
Constant Field Values

PROP_STATE

public static final String PROP_STATE
Name of property 'state' that describes the state of the embeded PropertyEditor.

Since:
2.20
See Also:
org.openide.explorer.propertysheet.PropertyEnv.getState, Constant Field Values
Constructor Detail

PropertyPanel

public PropertyPanel()
Creates new PropertyPanel backed by a dummy property


PropertyPanel

public PropertyPanel(Object bean,
                     String propertyName,
                     int preferences)
Creates new PropertyPanel with DefaultPropertyModel

Parameters:
preferences - the preferences that affect how this propertypanel will operate
bean - The instance of bean
propertyName - The name of the property to be displayed

PropertyPanel

public PropertyPanel(PropertyModel model,
                     int preferences)
Creates a new PropertyPanel. While not quite deprecated, do not use this constructor if your intention is to display a Node.Property object; use the constructor that takes a Node.Property object directly instead.

Parameters:
model - The model to display
See Also:
PropertyModel

PropertyPanel

public PropertyPanel(Node.Property p,
                     int preferences)
Create a new property panel for the specified property with the specified preferences.

Parameters:
p -
preferences -

PropertyPanel

public PropertyPanel(Node.Property p)
Create a new property panel for displaying/editing the specified property

Parameters:
p - A Property object for this node to represent
See Also:
Node.Property
Method Detail

setBackground

public void setBackground(Color c)

setForeground

public void setForeground(Color c)

firePropertyChange

protected void firePropertyChange(String nm,
                                  Object old,
                                  Object nue)
Overridden to catch changes in those client properties that are relevant to PropertyPanel


isFocusable

public boolean isFocusable()
Overridden to return false in cases that the preferences specify a read-only state


requestFocus

public void requestFocus()
Overridden to do nothing in a read only state, since some custom property editors (File chooser) are capable of receiving focus even if they are disabled, effectively making focus disappear


processFocusEvent

protected void processFocusEvent(FocusEvent fe)

addNotify

public void addNotify()
Overridden to install the inner component that will display the property


removeNotify

public void removeNotify()
Overridden to dispose the component that actually displays the property and any state information associated with it


getPreferredSize

public Dimension getPreferredSize()

getMinimumSize

public Dimension getMinimumSize()
Overridden to return the preferred size


getPreferences

public int getPreferences()
Returns the preferences set for this property panel. The preferences determine such things as read-only mode and whether an inline or custom editor is displayed

Returns:
The preferences

setPreferences

public void setPreferences(int preferences)
Setter for visual preferences in displaying of the value of the property.

Parameters:
preferences - PREF_XXXX constants

getModel

public PropertyModel getModel()
Get the property model associated with this property panel. Note that while the PropertyModel usages of PropertyPanel are not yet deprecated, the preferred and more efficient use of PropertyPanel is directly with a Node.Property instance rather than a PropertyModel.

Returns:
Value of property model.

setModel

public void setModel(PropertyModel model)
Setter for property model. Note that while the PropertyModel usages of PropertyPanel are not yet deprecated, the preferred and more efficient use of PropertyPanel is directly with a Node.Property instance rather than a PropertyModel. The PropertyPanel will either construct a wrapper Node.Property instance or find the underlying Node.Property instance, and use that to drive its infrastructure. The only remaining use case for PropertyModel here is if the component needs to listen for changes in the underlying value which do not originate in this PropertyPanel.

Parameters:
model - New model.

setProperty

public final void setProperty(Node.Property p)
Set or change the property this PropertyPanel will display

Parameters:
p - the Property

getProperty

public final Node.Property getProperty()
Fetch the property that this PropertyPanel displays. For cases where the PropertyPanel was initialized with an instance of PropertyModel, the return value of this method is not officially defined.

Returns:
the property

getState

public final Object getState()
Getter for the state of the property editor. The editor can be in not valid states just if it implements the ExPropertyEditor and changes state by the setState method of the PropertyEnv environment.

Returns:
PropertyEnv.STATE_VALID if the editor is not the ExPropertyEditor one or other constant from PropertyEnv.STATE_* that was assigned to PropertyEnv
Since:
2.20

updateValue

public void updateValue()
If the editor is ExPropertyEditor it tries to change the getState property to PropertyEnv.STATE_VALID state. This may be vetoed, in such case a warning is presented to the user and the getState will still return the original value (different from STATE_VALID).

Also updates the value if org.openide.explorer.propertysheet.editors.EnhancedCustomPropertyEditor is used.


getPropertyEditor

public PropertyEditor getPropertyEditor()
Deprecated. The property panel does not cache the property editor, and depending on its state, it may not consistently return the same property editor instance on repeated calls. The current implementation will do so for editable states, but there is no guarantee this will remain so in the future.

Getter for current property editor depending on the model. It may be null if it is not possible to obtain a property editor.

Note: When not in custom editor mode, PropertyPanel does not cache the editor supplied by the property. If the PropertyPanel was initialized from an instance of (deprecated) DefaultPropertyModel, a different instance of the property editor may be constructed and returned for each call. Client code must take this into account. . For cases of initialization via a Node.Property object, it is up to the supplied Property to cache or not cache the property editor returned from getPropertyEditor() as suits its needs.

Returns:
the property editor or null

setEnabled

public void setEnabled(boolean enabled)
Sets whether or not this component is enabled. all panel components gets disabled when enabled parameter is set false

Parameters:
enabled - flag defining the action.

isChangeImmediate

public boolean isChangeImmediate()
Getter for property changeImmediate. If this is true the changes made in the property editor are immediately propagated to the value of the property (to the property model).

Returns:
Value of property changeImmediate.

setChangeImmediate

public void setChangeImmediate(boolean changeImmediate)
Setter for property changeImmediate. IF this is true the changes made in the property editor are immediately propagated to the value of the property (to the property model).

Parameters:
changeImmediate - New value of property changeImmediate.

toString

public String toString()
Overridden to provide information from the embedded property renderer if not in custom editor mode


getAccessibleContext

public AccessibleContext getAccessibleContext()
Specified by:
getAccessibleContext in interface Accessible


Built on December 1 2003.  |  Portions Copyright 1997-2003 Sun Microsystems, Inc. All rights reserved.