com.sas.visuals
Class PropertyEditorHost

com.sas.visuals.PropertyEditorHost
All Implemented Interfaces:
ContainerInterface, com.sas.awt.print.PrintableInterface, VisualInterface, com.sas.beans.PropertyChangeSource, com.sas.beans.VetoableChangeSource, com.sas.ComponentInterface, com.sas.DesignTimeDropTargetInterface, com.sas.LinkPropertiesInterface, com.sas.ModelInterface, ValidatorInterface, com.sas.ViewInterface, MultipleValueEventSourceInterface, java.awt.event.ActionListener, java.awt.event.ComponentListener, java.awt.event.FocusListener, java.awt.event.ItemListener, java.awt.event.MouseListener, java.awt.event.WindowListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.ObjectInputValidation, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class PropertyEditorHost
implements java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.FocusListener, java.awt.event.ItemListener, java.beans.PropertyChangeListener, java.awt.event.WindowListener, java.awt.event.ComponentListener

PropertyEditorHost provides a user interface for a PropertyEditor. It may provide either a TextField or ComboBox depending on the return codes from getTags and getAsText. It may also provide a paint area for PropertyEditors which return true from isPaintable. It will also provide a "..." button for PropertyEditors which return true from supportsCustomEditor.

The PropertyEditorHost also listens for PropertyChangeEvents coming from the PropertyEditor. When a PropertyChangeEvent is received, the UI controls in the PropertyEditorHost are updated based on information from the PropertyEditor.

Note: It is the containers responsibility to call updateTextValue when the window containing the PropertyEditorHost is closed. Particularly, property sheet's should call it when they receive a windowClosing event since the PEHost is not given a focusLost event in that case. Also, customizer panels which use the PEHost should call updateTextValue when their customizerClosing method is called.

Note: The PropertyEditorHost's serialVersionUID might change in future versions of the class. Do not serialize the PropertyEditorHost.

See Also:
Serialized Form

Field Summary
protected  boolean alwaysShowControls
          Determines whether the editting controls are always shown or whether they are only shown when the PEHost has focus.
protected  java.lang.Object bean
           
protected  Choice choice
          The Choice for user input if getAsText does not return null.
protected  PushButton customButton
          The Button to allow access to the custom editor if supportsCustomEditor returns true.
protected  java.awt.Window customEditorWindow
           
protected  boolean dontSetFocus
           
protected  AutoSizingGridLayout editLayout
          This is the LayoutManager used by the PEHost when it has focus.
protected  com.sas.visuals.PropertyEditorPaintArea editPaintArea
          The paintArea for paint space if isPaintable returns true when the PEHost has focus.
protected  java.awt.Panel editPanel
           
protected  com.sas.visuals.PEHostLabel editValueLabel
          The Label which displays the value of the property when the PEHost has focus.
protected  boolean ignoreFocusLost
           
protected  int index
           
protected  boolean indexed
           
protected  AutoSizingGridLayout layout
          This is the LayoutManager used by the PEHost.
protected  boolean masked
           
protected  int maximumValueFieldWidth
           
protected  java.lang.String[] oldTags
           
protected  com.sas.visuals.PropertyEditorPaintArea paintArea
          The paintArea for paint space if isPaintable returns true.
protected  java.lang.String property
           
protected  java.beans.PropertyEditor propertyEditor
          The PropertyEditor to provide a UI for.
protected  java.lang.Class propertyType
           
protected  java.lang.Object propertyValue
           
protected  boolean readOnly
           
protected  com.sas.visuals.PEHostTextField textField
          The TextField for user input if getAsText does not return null and getTags returns true.
protected  com.sas.visuals.PEHostLabel valueLabel
          The Label which displays the value of the property.
protected  java.awt.Panel viewPanel
           
protected  boolean writeOnly
           
 
Fields inherited from class com.sas.awt.Panel
RB_KEY
 
Constructor Summary
PropertyEditorHost()
          The constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
          actionPerformed is an event handler for the TextField used to enter the property value and the Button which is used to bring up the custom editor.
 void addNotify()
           
 void componentHidden(java.awt.event.ComponentEvent evt)
           
 void componentMoved(java.awt.event.ComponentEvent evt)
           
 void componentResized(java.awt.event.ComponentEvent evt)
           
 void componentShown(java.awt.event.ComponentEvent evt)
           
protected  void createControls()
          Create the controls for the UI.
protected  void createEdittingControls()
          Create the controls necessary to change the value of the property.
protected  void enableSubcomponents(boolean enabled)
           
 void focusGained(java.awt.event.FocusEvent evt)
           
 void focusLost(java.awt.event.FocusEvent evt)
           
protected  java.lang.String getAsText()
           
protected  java.awt.Frame getContainingFrame()
          Determine the frame containing the PEHost.
protected  java.lang.String getLabelAsText()
           
 int getMaximumValueFieldWidth()
          Returns the maximum width of the Label and/or TextField used to display the property value.
 java.beans.PropertyEditor getPropertyEditor()
          Returns the property editor "displayed" by this PropertyEditorHost.
 void handleException(java.lang.Exception e)
          Note: this is here to handle old code calling and passing in an Exception.
 void handleException(java.lang.Throwable e)
          This method puts up a MessageBox when an exception is caught.
 void initialize()
          Do common setup that should occur after property sets.
protected  void inspectProperty()
           
 boolean isAlwaysShowControls()
          Returns whether the editting and ... controls are always visible or are created on an as-needed basis.
 boolean isFocusTraversable()
          Enable focus traversal if the PEHost is edittable.
 void itemStateChanged(java.awt.event.ItemEvent evt)
          itemStateChanged is the event handler for the Choice used to display property value tags.
 void mouseClicked(java.awt.event.MouseEvent evt)
           
 void mouseEntered(java.awt.event.MouseEvent evt)
           
 void mouseExited(java.awt.event.MouseEvent evt)
           
 void mousePressed(java.awt.event.MouseEvent evt)
           
 void mouseReleased(java.awt.event.MouseEvent evt)
           
 void propertyChange(java.beans.PropertyChangeEvent e)
          propertyChange is the event handler for PropertyChangeEvents from the PropertyEditor.
protected  void readTags(java.lang.String[] tags)
           
protected  void removeEventHandlers()
           
 void removeNotify()
           
 void setAlwaysShowControls(boolean show)
          Sets whether the editting and ... controls are always visible or are created on an as-needed basis.
 void setEnabled(boolean enabled)
          setEnabled() is the set accessor method for the Enabled attribute.
 void setMaximumValueFieldWidth(int width)
          Sets the maximum width of the Label and/or TextField used to display the property value.
 void setProperty(java.lang.Object bean, java.lang.String property)
           
 void setProperty(java.lang.Object bean, java.lang.String property, int index)
           
 void setPropertyEditor(java.beans.PropertyEditor propertyEditor)
          Sets the PropertyEditor to provide a UI for.
 void setPropertyValue(java.lang.Object value)
           
 void setPropertyValue(java.lang.Object value, java.lang.Class propertyType)
           
 void showCustomEditor()
          showCustomEditor creates a dialog to display the custom editor if the custom editor is not a subclass of Dialog or Frame.
 void updateTextValue()
          This method updates the PropertyEditor value based on the entered text.
 void updateValue()
          This method updates the UI controls based on the new value of the property.
 void windowActivated(java.awt.event.WindowEvent evt)
           
 void windowClosed(java.awt.event.WindowEvent evt)
           
 void windowClosing(java.awt.event.WindowEvent evt)
           
 void windowDeactivated(java.awt.event.WindowEvent evt)
           
 void windowDeiconified(java.awt.event.WindowEvent evt)
           
 void windowIconified(java.awt.event.WindowEvent evt)
           
 void windowOpened(java.awt.event.WindowEvent evt)
           
 
Methods inherited from class com.sas.awt.Panel
getDefaultHeight, getDefaultWidth, getExtendedBeanInfo, remove, remove, removeAll, setDefaultHeight, setDefaultValues, setDefaultWidth
 
Methods inherited from class com.sas.awt.PanelContainerComponent
clone, dragEnter, dragLeave, dragOver, drop, getContainerInterfaceSupportInfo, getErrorHandler, getInsets, getValidator, isIDEDnDDropBarrier, isIDEDnDDropTarget, isValid, setContainerInterfaceSupportInfo, setErrorHandler, setIDEDnDDropBarrier, setIDEDnDDropTarget, setInsets, setInsets, setValidator, superAddNotify, superGetInsets, superRemoveNotify, superSetDefaultValues
 
Methods inherited from class com.sas.awt.PanelVisualComponent
addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachModel, attachView, computePreferredSize, detachModel, detachView, dumpComponent, firePropertyChange, firePropertyChange, fireVetoableChange, getBackgroundColor, getBorder, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getFont, getForegroundColor, getHeight, getHorizontalPosition, getLinkInfo, getMinimumSize, getModelInterface, getPageBounds, getPreferredSize, getPrePainter, getPrintOptionsPanel, getRequiredInterfaces, getVerticalPosition, getViewInterfaceSupportInfo, getVisualInterfaceSupportInfo, getWidth, initializeComponent, isDesignTime, isEnabled, isFocus, isLinked, isTransparent, isVisible, pageExists, paint, print, printFinalize, printInitialize, queryLinks, queryLinks, refresh, removeAllLinks, removeInterfaceTraps, removeLink, removePropertyChangeListener, removeVetoableChangeListener, setBackgroundColor, setBorder, setBounds, setComponentDescription, setComponentSupportInfo, setFocus, setFont, setForegroundColor, setHeight, setHorizontalPosition, setLinkInfo, setModelInterface, setPreferredSize, setPrePainter, setRequiredInterfaces, setTransparent, setVerticalPosition, setViewInterfaceSupportInfo, setVisible, setVisualInterfaceSupportInfo, setWidth, superGetFont, superGetMinimumSize, superGetPreferredSize, superIsEnabled, superIsVisible, superPaint, superSetBounds, superSetEnabled, superSetFont, superSetVisible, superUpdate, supportsListenerInterface, supportsRequiredInterfaces, trapInterfaceEvents, update, validateObject
 
Methods inherited from interface com.sas.awt.ContainerInterface
getComponents, getLayout, invalidate, setLayout, validate
 
Methods inherited from interface com.sas.awt.VisualInterface
computePreferredSize, getBackgroundColor, getBorder, getFont, getForegroundColor, getHeight, getHorizontalPosition, getMinimumSize, getPreferredSize, getPrePainter, getVerticalPosition, getVisualInterfaceSupportInfo, getWidth, isEnabled, isFocus, isTransparent, isVisible, setBackgroundColor, setBorder, setBounds, setFocus, setFont, setForegroundColor, setHeight, setHorizontalPosition, setPreferredSize, setPrePainter, setTransparent, setVerticalPosition, setVisible, setVisualInterfaceSupportInfo, setWidth, superGetFont, superGetMinimumSize, superGetPreferredSize, superIsEnabled, superIsVisible, superPaint, superSetBounds, superSetEnabled, superSetFont, superSetVisible, superUpdate
 

Field Detail

bean

protected java.lang.Object bean

property

protected java.lang.String property

index

protected int index

indexed

protected boolean indexed

readOnly

protected boolean readOnly

writeOnly

protected boolean writeOnly

masked

protected boolean masked

propertyValue

protected java.lang.Object propertyValue

propertyType

protected java.lang.Class propertyType

propertyEditor

protected java.beans.PropertyEditor propertyEditor
The PropertyEditor to provide a UI for.

See Also:
setPropertyEditor(java.beans.PropertyEditor)

valueLabel

protected com.sas.visuals.PEHostLabel valueLabel
The Label which displays the value of the property.


editValueLabel

protected com.sas.visuals.PEHostLabel editValueLabel
The Label which displays the value of the property when the PEHost has focus.


textField

protected com.sas.visuals.PEHostTextField textField
The TextField for user input if getAsText does not return null and getTags returns true.


choice

protected Choice choice
The Choice for user input if getAsText does not return null.


paintArea

protected com.sas.visuals.PropertyEditorPaintArea paintArea
The paintArea for paint space if isPaintable returns true.


editPaintArea

protected com.sas.visuals.PropertyEditorPaintArea editPaintArea
The paintArea for paint space if isPaintable returns true when the PEHost has focus.


customButton

protected PushButton customButton
The Button to allow access to the custom editor if supportsCustomEditor returns true.


layout

protected AutoSizingGridLayout layout
This is the LayoutManager used by the PEHost.


editLayout

protected AutoSizingGridLayout editLayout
This is the LayoutManager used by the PEHost when it has focus.


alwaysShowControls

protected boolean alwaysShowControls
Determines whether the editting controls are always shown or whether they are only shown when the PEHost has focus.


customEditorWindow

protected java.awt.Window customEditorWindow

viewPanel

protected java.awt.Panel viewPanel

editPanel

protected java.awt.Panel editPanel

ignoreFocusLost

protected boolean ignoreFocusLost

dontSetFocus

protected boolean dontSetFocus

maximumValueFieldWidth

protected int maximumValueFieldWidth

oldTags

protected java.lang.String[] oldTags
Constructor Detail

PropertyEditorHost

public PropertyEditorHost()
The constructor.

Method Detail

initialize

public void initialize()
Do common setup that should occur after property sets. Also do setup that needs to occur after deserialization.

Specified by:
initialize in interface com.sas.ComponentInterface
Overrides:
initialize in class PanelVisualComponent
See Also:
ComponentInterface.initialize()

getPropertyEditor

public java.beans.PropertyEditor getPropertyEditor()
Returns the property editor "displayed" by this PropertyEditorHost.


getMaximumValueFieldWidth

public int getMaximumValueFieldWidth()
Returns the maximum width of the Label and/or TextField used to display the property value.


setMaximumValueFieldWidth

public void setMaximumValueFieldWidth(int width)
Sets the maximum width of the Label and/or TextField used to display the property value.


isAlwaysShowControls

public boolean isAlwaysShowControls()
Returns whether the editting and ... controls are always visible or are created on an as-needed basis.


setAlwaysShowControls

public void setAlwaysShowControls(boolean show)
Sets whether the editting and ... controls are always visible or are created on an as-needed basis.

NOTE: Currently, changing this value after the controls have been created will not work properly.


setPropertyEditor

public void setPropertyEditor(java.beans.PropertyEditor propertyEditor)
Sets the PropertyEditor to provide a UI for.

See Also:
createControls()

setPropertyValue

public void setPropertyValue(java.lang.Object value,
                             java.lang.Class propertyType)

setPropertyValue

public void setPropertyValue(java.lang.Object value)

setProperty

public void setProperty(java.lang.Object bean,
                        java.lang.String property)

setProperty

public void setProperty(java.lang.Object bean,
                        java.lang.String property,
                        int index)

inspectProperty

protected void inspectProperty()

removeEventHandlers

protected void removeEventHandlers()

createControls

protected void createControls()
Create the controls for the UI.


getLabelAsText

protected java.lang.String getLabelAsText()

getAsText

protected java.lang.String getAsText()

readTags

protected void readTags(java.lang.String[] tags)

createEdittingControls

protected void createEdittingControls()
Create the controls necessary to change the value of the property.


updateValue

public void updateValue()
This method updates the UI controls based on the new value of the property.


handleException

public void handleException(java.lang.Exception e)
Note: this is here to handle old code calling and passing in an Exception.


handleException

public void handleException(java.lang.Throwable e)
This method puts up a MessageBox when an exception is caught.

Subclasses should override this method if they wish to provide different error handling.

PropertySheets using the PEHost may call this method to get consistent error handling.


updateTextValue

public void updateTextValue()
This method updates the PropertyEditor value based on the entered text. It catches any exceptions thrown during the setAsText() call and puts up a MessageBox if an exception is caught.


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
actionPerformed is an event handler for the TextField used to enter the property value and the Button which is used to bring up the custom editor.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent evt)
itemStateChanged is the event handler for the Choice used to display property value tags. Whenever the selection changes, the value is retrieved from the Choice and set on the PropertyEditor.

Specified by:
itemStateChanged in interface java.awt.event.ItemListener

showCustomEditor

public void showCustomEditor()
showCustomEditor creates a dialog to display the custom editor if the custom editor is not a subclass of Dialog or Frame. If it is a subclass of Dialog or Frame, is just displays it.

Subclasses may want to override this method and bring up the custom editor some other way.


getContainingFrame

protected java.awt.Frame getContainingFrame()
Determine the frame containing the PEHost. If it is not contained by a frame, a default (non-visible) frame is created and returned.


propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
propertyChange is the event handler for PropertyChangeEvents from the PropertyEditor. Each of the controls in the PropertyEditor host is updated based on data from the PropertyEditor.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class PanelVisualComponent
See Also:
PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)

windowOpened

public void windowOpened(java.awt.event.WindowEvent evt)
Specified by:
windowOpened in interface java.awt.event.WindowListener

windowClosing

public void windowClosing(java.awt.event.WindowEvent evt)
Specified by:
windowClosing in interface java.awt.event.WindowListener

windowClosed

public void windowClosed(java.awt.event.WindowEvent evt)
Specified by:
windowClosed in interface java.awt.event.WindowListener

windowIconified

public void windowIconified(java.awt.event.WindowEvent evt)
Specified by:
windowIconified in interface java.awt.event.WindowListener

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent evt)
Specified by:
windowDeiconified in interface java.awt.event.WindowListener

windowActivated

public void windowActivated(java.awt.event.WindowEvent evt)
Specified by:
windowActivated in interface java.awt.event.WindowListener

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent evt)
Specified by:
windowDeactivated in interface java.awt.event.WindowListener

focusGained

public void focusGained(java.awt.event.FocusEvent evt)
Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent evt)
Specified by:
focusLost in interface java.awt.event.FocusListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent evt)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent evt)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent evt)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent evt)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent evt)
Specified by:
mouseExited in interface java.awt.event.MouseListener

isFocusTraversable

public boolean isFocusTraversable()
Enable focus traversal if the PEHost is edittable.

Overrides:
isFocusTraversable in class java.awt.Component

addNotify

public void addNotify()
Specified by:
addNotify in interface ContainerInterface
Overrides:
addNotify in class PanelContainerComponent

removeNotify

public void removeNotify()
Specified by:
removeNotify in interface ContainerInterface
Overrides:
removeNotify in class PanelContainerComponent

componentResized

public void componentResized(java.awt.event.ComponentEvent evt)
Specified by:
componentResized in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent evt)
Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent evt)
Specified by:
componentShown in interface java.awt.event.ComponentListener

componentHidden

public void componentHidden(java.awt.event.ComponentEvent evt)
Specified by:
componentHidden in interface java.awt.event.ComponentListener

enableSubcomponents

protected void enableSubcomponents(boolean enabled)

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: VisualInterface
setEnabled() is the set accessor method for the Enabled attribute. Pass in true to enable the component. Pass in false to disable the component.

Specified by:
setEnabled in interface VisualInterface
Overrides:
setEnabled in class PanelVisualComponent
Parameters:
enabled - Whether the component should be enabled.
See Also:
VisualInterface.setEnabled(boolean)



Copyright © 2009 SAS Institute Inc. All Rights Reserved.