com.jbbres.lib.actions.tools.swing
Class AbstractVariableComboBox<C>

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JComboBox
                  extended by com.jbbres.lib.actions.tools.swing.AbstractVariableComboBox<C>
Type Parameters:
C - - the type that the variables can contain.
All Implemented Interfaces:
VariableServiceListener, WorkflowDefinitionListener, com.jbbres.lib.PropertiesOwner, java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ListDataListener
Direct Known Subclasses:
JDateComboBox, JFileComboBox, JImageComboBox, JVComboBox

public abstract class AbstractVariableComboBox<C>
extends javax.swing.JComboBox
implements WorkflowDefinitionListener, VariableServiceListener, com.jbbres.lib.PropertiesOwner, java.awt.event.ActionListener

An abstract JComboBox to display Variable instances within an Action UI

All sub-classes of AbstractVariableComboBox can display the Variable instances available in the workflow. The class parameter C allows to restrict the variables to a specific type of data. For example, if an instance of AbstractVariableComboBox is declared as

 class JFileComboBox extends AbstractVariableComboBox<File>
 
the JFileComboBox will only display variables that can store or return a File object.

If variables are added or removed from the workflow, the box is automatically updated.

The combo box can also contain objects (instance of C) that will remain "static" (in opposition to the variables, whose value can change). A combo box displaying File variable, can also list a serie of File object that are not variable. Use the addStaticItem(Object) to add a static object to the combo box. Static items appears at the beginning of the list.

The combo box can also contain instances of VComboBoxPersonalizedItem . When a VComboBoxPersonalizedItem item, the action (on a javax.swing.Action sense) associated to it is triggered. VComboBoxPersonalizedItem items appear at the end of the list.


Release Notes:

v1.1.0:

  • Added new methods from WorkflowDefinitionListener
  • Since:
    1.0.0
    Version:
    1.1.0
    Author:
    Jean-Baptiste Bres
    See Also:
    VComboBoxPersonalizedItem, Serialized Form

    Nested Class Summary
     
    Nested classes/interfaces inherited from class javax.swing.JComboBox
    javax.swing.JComboBox.KeySelectionManager
     
    Nested classes/interfaces inherited from class javax.swing.JComponent
    javax.swing.JComponent.AccessibleJComponent
     
    Nested classes/interfaces inherited from class java.awt.Component
    java.awt.Component.BaselineResizeBehavior
     
    Field Summary
    static java.lang.String PROPERTY_PERSONALIZED_ITEM_PROPERTIES
              The property key for the personalized item properties.
    static java.lang.String PROPERTY_SELECTED_INDEX
              The property key for the selected index.
     
    Fields inherited from class javax.swing.JComponent
    TOOL_TIP_TEXT_KEY, 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
    AbstractVariableComboBox(Workflow workflow)
              Creates a new box.
     
    Method Summary
     void actionMoved(WorkflowDefinitionEvent e)
              Invoked when an action is moved from its current position to a new position.
     void actionPerformed(java.awt.event.ActionEvent e)
               
     void addItem(java.lang.Object item)
              Adds an item to the item list.
     void addPersonalizedItem(VComboBoxPersonalizedItem<C> item)
              Adds an ComboVariablePersonalizedItem from the box.
     void addStaticItem(C item)
              Adds a static item in the box.
     void elementAdded(WorkflowDefinitionEvent e)
              Invoked when a new element is added to the workflow.
     void elementRemoved(WorkflowDefinitionEvent e)
              Invoked when an element is removed from the workflow.
     VComboBoxPersonalizedItem<?>[] getAllPersonalizedItems()
              Returns all the personalized items available in the list.
     java.lang.Object[] getAllStaticItems()
              Returns all the static items available in the list.
     Variable[] getAllVariables()
              Returns all the variables available in the list.
     java.util.Properties getProperties()
               
     C getSelectedValue()
              Returns the value of the current selected item.
     void notificationReceived(WorkflowDefinitionEvent e)
              Invoked when a notification is received.
     void removeItem(java.lang.Object item)
              Removes an item from the item list.
     void removePersonalizedItem(VComboBoxPersonalizedItem<C> item)
              Removes an ComboVariablePersonalizedItem from the box list.
     void removeStaticItem(C item)
              Removes a static item from the box list.
     void setProperties(java.util.Properties properties)
               
     void setWorkflow(Workflow workflow)
              Sets the workflow whom variables are displayed in this box.
     java.lang.Class<C> variableClass()
              In order to match and cast the input and output object from one element to the other, Actions need to know from what class is the input object, but Java does not provide functionality to do so where you are dealing with parametrised class ( <C> ).
     void variableInstanceNameChanged(VariableServiceEvent e)
              Invoked when the variable instance name is changed.
     void variableValueChanged(VariableServiceEvent e)
              Invoked when the variable value is changed.
     
    Methods inherited from class javax.swing.JComboBox
    addActionListener, addItemListener, addPopupMenuListener, configureEditor, contentsChanged, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getAccessibleContext, getAction, getActionCommand, getActionListeners, getEditor, getItemAt, getItemCount, getItemListeners, getKeySelectionManager, getMaximumRowCount, getModel, getPopupMenuListeners, getPrototypeDisplayValue, getRenderer, getSelectedIndex, getSelectedItem, getSelectedObjects, getUI, getUIClassID, hidePopup, insertItemAt, intervalAdded, intervalRemoved, isEditable, isLightWeightPopupEnabled, isPopupVisible, processKeyEvent, removeActionListener, removeAllItems, removeItemAt, removeItemListener, removePopupMenuListener, selectWithKeyChar, setAction, setActionCommand, setEditable, setEditor, setEnabled, setKeySelectionManager, setLightWeightPopupEnabled, setMaximumRowCount, setModel, setPopupVisible, setPrototypeDisplayValue, setRenderer, setSelectedIndex, setSelectedItem, setUI, showPopup, updateUI
     
    Methods inherited from class javax.swing.JComponent
    addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
     
    Methods inherited from class java.awt.Container
    add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
     
    Methods inherited from class java.awt.Component
    action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, 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
    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
     

    Field Detail

    PROPERTY_SELECTED_INDEX

    public static final java.lang.String PROPERTY_SELECTED_INDEX
    The property key for the selected index.

    See Also:
    Constant Field Values

    PROPERTY_PERSONALIZED_ITEM_PROPERTIES

    public static final java.lang.String PROPERTY_PERSONALIZED_ITEM_PROPERTIES
    The property key for the personalized item properties.

    See Also:
    Constant Field Values
    Constructor Detail

    AbstractVariableComboBox

    public AbstractVariableComboBox(Workflow workflow)
    Creates a new box.

    Parameters:
    workflow - - workflow associated to the box. Can be null, however the variables will not be available before the workflow is set by the setWorkflow function.
    Method Detail

    addItem

    public void addItem(java.lang.Object item)
    Adds an item to the item list.
    If the item is not an Variable, this method has no effect.

    Overrides:
    addItem in class javax.swing.JComboBox
    Parameters:
    item - the item

    removeItem

    public void removeItem(java.lang.Object item)
    Removes an item from the item list.

    Overrides:
    removeItem in class javax.swing.JComboBox
    Parameters:
    item - the item

    addPersonalizedItem

    public void addPersonalizedItem(VComboBoxPersonalizedItem<C> item)
    Adds an ComboVariablePersonalizedItem from the box. The ComboVariablePersonalizedItem are displayed at the end of the selection list. If the user click on it, the itemSelected method of the action is called.

    Parameters:
    item - - item to be added.
    See Also:
    removePersonalizedItem(VComboBoxPersonalizedItem)

    removePersonalizedItem

    public void removePersonalizedItem(VComboBoxPersonalizedItem<C> item)
    Removes an ComboVariablePersonalizedItem from the box list.

    Parameters:
    item - - item to be removed
    See Also:
    addPersonalizedItem(VComboBoxPersonalizedItem)

    addStaticItem

    public void addStaticItem(C item)
    Adds a static item in the box. The static items are not variable and are displayed at the beginning of the list.

    Parameters:
    item - - item to be added.
    See Also:
    removeStaticItem(Object)

    removeStaticItem

    public void removeStaticItem(C item)
    Removes a static item from the box list.

    Parameters:
    item - - item to be removed
    See Also:
    addStaticItem(Object)

    getSelectedValue

    public C getSelectedValue()
    Returns the value of the current selected item.
    If the combo box is editable, then this value may not have been added to the combo box with addItem, insertItemAt or the data constructors.
    If the selected item is an action, this method returns null.

    If you want to access to the object selected (for example the variable or the action selected), use getSelectedItem.

    Returns:
    The value of the current selected item

    getAllVariables

    public Variable[] getAllVariables()
    Returns all the variables available in the list.

    Returns:
    All the variables available in the list.

    getAllPersonalizedItems

    public VComboBoxPersonalizedItem<?>[] getAllPersonalizedItems()
    Returns all the personalized items available in the list.

    Returns:
    All the personalized items available in the list.

    getAllStaticItems

    public java.lang.Object[] getAllStaticItems()
    Returns all the static items available in the list.

    Returns:
    All the static items available in the list.

    setWorkflow

    public void setWorkflow(Workflow workflow)
    Sets the workflow whom variables are displayed in this box.

    Parameters:
    workflow - - worflow

    variableClass

    public final java.lang.Class<C> variableClass()
    In order to match and cast the input and output object from one element to the other, Actions need to know from what class is the input object, but Java does not provide functionality to do so where you are dealing with parametrised class ( <C> ).
    To solve this, all instance of JAbstractComboVariable are required to provide a the class of the object that the watched variables might store via this function.

    This function has simply to return the class of stored object. For example if your class is watching Variable<String>, the code of this function should be:

    return String.class;

    Returns:
    the class of watched objects

    getProperties

    public java.util.Properties getProperties()
    Specified by:
    getProperties in interface com.jbbres.lib.PropertiesOwner

    setProperties

    public void setProperties(java.util.Properties properties)
    Specified by:
    setProperties in interface com.jbbres.lib.PropertiesOwner

    actionMoved

    public void actionMoved(WorkflowDefinitionEvent e)
    Description copied from interface: WorkflowDefinitionListener
    Invoked when an action is moved from its current position to a new position.

    Specified by:
    actionMoved in interface WorkflowDefinitionListener
    Parameters:
    e - the event

    elementAdded

    public void elementAdded(WorkflowDefinitionEvent e)
    Description copied from interface: WorkflowDefinitionListener
    Invoked when a new element is added to the workflow.

    Specified by:
    elementAdded in interface WorkflowDefinitionListener
    Parameters:
    e - the event

    elementRemoved

    public void elementRemoved(WorkflowDefinitionEvent e)
    Description copied from interface: WorkflowDefinitionListener
    Invoked when an element is removed from the workflow.

    Specified by:
    elementRemoved in interface WorkflowDefinitionListener
    Parameters:
    e - the event

    notificationReceived

    public void notificationReceived(WorkflowDefinitionEvent e)
    Description copied from interface: WorkflowDefinitionListener
    Invoked when a notification is received.

    Notification are messages that can be send to the workflow during the workflow definition process. They contain useful information for the user in order to improve or correct his/her workflow.

    Specified by:
    notificationReceived in interface WorkflowDefinitionListener
    Parameters:
    e - the event

    variableValueChanged

    public void variableValueChanged(VariableServiceEvent e)
    Description copied from interface: VariableServiceListener
    Invoked when the variable value is changed.

    Specified by:
    variableValueChanged in interface VariableServiceListener
    Parameters:
    e - - the event

    variableInstanceNameChanged

    public void variableInstanceNameChanged(VariableServiceEvent e)
    Description copied from interface: VariableServiceListener
    Invoked when the variable instance name is changed.

    Specified by:
    variableInstanceNameChanged in interface VariableServiceListener
    Parameters:
    e - - the event

    actionPerformed

    public void actionPerformed(java.awt.event.ActionEvent e)
    Specified by:
    actionPerformed in interface java.awt.event.ActionListener
    Overrides:
    actionPerformed in class javax.swing.JComboBox


    To file bugs or suggest feature enhancements, visit the app.jbbres.com Bug Reporter website.

    Additional documentation available online at http://app.jbbres.com/actions/developers.

    Copyright � 2009-2011 app.jbbres.com. All Rights Reserved.