com.metamatrix.toolbox.ui.widget.property
Class MultivaluedPropertyComponent

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.metamatrix.toolbox.ui.widget.property.MultivaluedPropertyComponent
All Implemented Interfaces:
PropertyComponent, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible
Direct Known Subclasses:
ObjectReferencePropertyComponent

public class MultivaluedPropertyComponent
extends javax.swing.JPanel
implements PropertyComponent

MultivaluedPropertyComponent is a compound JPanel for displaying and editing values for multi-valued properties. It is also an example of how PropertyComponent can be implemented and used as complex property renderer/editor.

Since:
2.0
Version:
2.0
Author:
Steve Jacobs, John P. A. Verhaeg
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  javax.swing.Box buttonBox
           
protected  java.awt.event.FocusListener focusListener
           
 
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 com.metamatrix.toolbox.ui.widget.property.PropertyComponent
EMPTY_STRING
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MultivaluedPropertyComponent(PropertyDefinition def, java.lang.Object data, boolean readOnly, int index, PropertiedObject object, PropertiedObjectEditor editor)
           
 
Method Summary
 void addActionListener(java.awt.event.ActionListener listener)
           
protected  void addButtonPressed()
           
 void addFocusListener(java.awt.event.FocusListener listener)
           
 void editingStarted()
          Notify this component that it has been activated and should enable any controls necessary for editing property values.
 void editingStopped()
          Notification to this component that keyboard/mouse focus has moved away from the component and it should deselect any items and deactivate any editing controls.
protected  void fireFocusEvent(java.awt.event.FocusEvent event)
           
protected  java.lang.String getInputValue()
           
protected  java.util.List getList()
           
 ListWidget getListWidget()
           
 java.lang.Object getNullValue()
          Get the null value for this PropertyComponent.
protected  ButtonWidget getRemoveButton()
           
 javax.swing.JComponent getSingleRowComponent()
          create a single-row JComponent from this component when needed.
 java.lang.String getSingleRowString()
          create a String from this component when needed.
 java.lang.Object getValue()
          Get the value being displayed by this component.
protected  void initializeMultivaluedPropertyComponent()
           
 boolean isCurrentValueEqualTo(java.lang.Object value)
          Return whether or not the specified value Object is equal to this component's currently displayed value.
 boolean isFocusTraversable()
           
protected  void moreButtonPressed()
          called by the moreButton's action processor method.
protected  void processFocusLostEvent(java.awt.event.FocusEvent event)
           
 void removeActionListener(java.awt.event.ActionListener listener)
           
protected  void removeButtonPressed()
           
 void removeFocusListener(java.awt.event.FocusListener listener)
           
 void removePropertyValidationListener(PropertyValidationListener listener)
          Remove the PropertyValidationListener for this component.
 void setEnabled(boolean flag)
          Set whether or not this component should be enabled to allow user editing of the value(s).
 void setPropertyValidationListener(PropertyValidationListener listener)
          Set a listener on this component that will receive request to validate property values as they are entered.
 void setValidity(boolean flag)
          Set a visual indication that this component's displayed value is or is not valid in the current context.
protected  void updateList()
           
 
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, 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, 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, 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, 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

buttonBox

protected javax.swing.Box buttonBox

focusListener

protected java.awt.event.FocusListener focusListener
Constructor Detail

MultivaluedPropertyComponent

public MultivaluedPropertyComponent(PropertyDefinition def,
                                    java.lang.Object data,
                                    boolean readOnly,
                                    int index,
                                    PropertiedObject object,
                                    PropertiedObjectEditor editor)
Since:
2.0
Method Detail

addButtonPressed

protected void addButtonPressed()
Since:
2.0

getInputValue

protected java.lang.String getInputValue()

moreButtonPressed

protected void moreButtonPressed()
called by the moreButton's action processor method. The moreButton is generated when there are "allowable values" available for this PropertyDefinition. May be overridden by subclasses to provide different functionality.

Since:
3.0

addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Specified by:
addActionListener in interface PropertyComponent
Since:
2.0

addFocusListener

public void addFocusListener(java.awt.event.FocusListener listener)
Specified by:
addFocusListener in interface PropertyComponent
Overrides:
addFocusListener in class java.awt.Component
Since:
2.0

fireFocusEvent

protected void fireFocusEvent(java.awt.event.FocusEvent event)
Since:
2.0

getList

protected java.util.List getList()
Since:
2.0

getListWidget

public ListWidget getListWidget()
Since:
2.0

getRemoveButton

protected ButtonWidget getRemoveButton()
Returns:
The remove button (if present)
Since:
2.0

getValue

public java.lang.Object getValue()
Get the value being displayed by this component. This value will be obtained from the PropertyChangeAdapter immediately prior to and after editing. After the user has stopped editing the value, the isEqualTo() method will be called allowing this component to determine if the user has changed the value.

Specified by:
getValue in interface PropertyComponent
Returns:
the property's value. May be a single object or a Collection.

isFocusTraversable

public boolean isFocusTraversable()
Overrides:
isFocusTraversable in class java.awt.Component
Since:
2.0

processFocusLostEvent

protected void processFocusLostEvent(java.awt.event.FocusEvent event)
Since:
2.0

initializeMultivaluedPropertyComponent

protected void initializeMultivaluedPropertyComponent()
Since:
2.0

removeButtonPressed

protected void removeButtonPressed()
Since:
2.0

setEnabled

public void setEnabled(boolean flag)
Set whether or not this component should be enabled to allow user editing of the value(s).

Specified by:
setEnabled in interface PropertyComponent
Overrides:
setEnabled in class javax.swing.JComponent
Parameters:
flag - true if the component should enable editing.

getNullValue

public java.lang.Object getNullValue()
Get the null value for this PropertyComponent. Since MultivaluedProperties are always set to an empty Collection, there need be no null value.

Specified by:
getNullValue in interface PropertyComponent
Returns:
the Object that should be compared to the getValue() result to detect null. Implementations of this method may return null.

setPropertyValidationListener

public void setPropertyValidationListener(PropertyValidationListener listener)

Set a listener on this component that will receive request to validate property values as they are entered. An example would be a custom component that allows a user to type in an entry that should be validated keystroke-by-keystroke. Such a component would route KeyListener.keyReleased() events to the PropertyValidationListener.checkValue(Object) method. The result of the checkValue call will be communicated to this component via the setValidity(boolean) method.

Not all components require validation; therefore it is permissable for such components to no-op this method.

Specified by:
setPropertyValidationListener in interface PropertyComponent
Parameters:
listener - the PropertyValidationListener that this object should call if validation is required.

removePropertyValidationListener

public void removePropertyValidationListener(PropertyValidationListener listener)

Remove the PropertyValidationListener for this component. This method will be called immediately after editing has stopped on this component. Implementations that no-op the setPropertyValidationListener method may no-op this method as well.

Specified by:
removePropertyValidationListener in interface PropertyComponent
Parameters:
listener - the PropertyValidationListener to be removed from this object.

setValidity

public void setValidity(boolean flag)
Set a visual indication that this component's displayed value is or is not valid in the current context. PropertyValidationListener calls this method after a request to checkValidity of a specified value. The method may also be called if an invalid entry exists after editing has completed. An example would be a collection of values that are required to be unique, but contain a repeated value.

Specified by:
setValidity in interface PropertyComponent
Parameters:
flag - true if the value is valid, false if it is invalid.

isCurrentValueEqualTo

public boolean isCurrentValueEqualTo(java.lang.Object value)
Return whether or not the specified value Object is equal to this component's currently displayed value. This method is called by PropertyChangeAdapter and allows the value comparison logic to reside within the custom component, rather than requiring custom components to hardcode comparison logic in the adapter.

Specified by:
isCurrentValueEqualTo in interface PropertyComponent
Parameters:
value - an Object that was previously obtained from this component's getValue method.
Returns:
true if the specified Object is the same as the value currently being displayed in this component, false if it is not. Returning true will cause the new value to be "set" on the target propertied object.

editingStarted

public void editingStarted()
Notify this component that it has been activated and should enable any controls necessary for editing property values.

Specified by:
editingStarted in interface PropertyComponent

editingStopped

public void editingStopped()
Notification to this component that keyboard/mouse focus has moved away from the component and it should deselect any items and deactivate any editing controls.

Specified by:
editingStopped in interface PropertyComponent

getSingleRowComponent

public javax.swing.JComponent getSingleRowComponent()
create a single-row JComponent from this component when needed.

Specified by:
getSingleRowComponent in interface PropertyComponent

getSingleRowString

public java.lang.String getSingleRowString()
create a String from this component when needed.

Specified by:
getSingleRowString in interface PropertyComponent

removeActionListener

public void removeActionListener(java.awt.event.ActionListener listener)
Since:
2.0

removeFocusListener

public void removeFocusListener(java.awt.event.FocusListener listener)
Overrides:
removeFocusListener in class java.awt.Component
Since:
2.0

updateList

protected void updateList()
Since:
2.0


Copyright © 2009. All Rights Reserved.