com.jbbres.lib.actions.tools.elements
Class AbstractActionUI

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.jbbres.lib.actions.tools.elements.AbstractActionUI
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public abstract class AbstractActionUI
extends javax.swing.JPanel

This abstract class provides default implementations for an Action user interface.

To create a concrete ActionUI as a subclass of AbstractActionUI you need only provide implementations for the following two methods:

protected Parameters getUIParameters()
protected void setUIParameters(Parameters parameters)

These two methods, which are not part of the original ActionUI interface, generates and sets the parameters associated to the User Interface.
The Parameters object that the getUIParameters() method returns is used by Action(s) to store the state of the action within the .wkfl file when the user saves the workflow. The same object is given to the setUIParameters(Parameters) method when the user opens a .wkfl file, so the User Interface can be reconstructed at a similar state as it was when the workflow had been saved.
The Parameters object is also given to the action service as an argument of the ActionService.execute(Object, Parameters) method. The service will use the parameters provided to know what settings the user want to apply to the action when it is executed.

The User Interface Component objects should be added to the content pane of the class. The content pane is a JPanel object that you can access by calling the getContentPane() method.


Using an AbstractActionUI object is a great way to let users define the behaviour of the action they are willing to use. However, this setting is defined by the user when he creates the workflow. If the workflow is meant to be re-used with different settings every time it is executed, the user will have to update them manually within the workflow every time, which will depreciate its experience of the application.

To get around this problem, AbstractActionUI includes a Show When Run feature. If this feature is turned on, when Action(s) executes the workflow it displays the user interface for the action when execution reaches that point. The workflow user – as opposed to the workflow creator – can then make the required settings before the action proceeds.

The User Interface of actions using the Show When Run feature includes an additional section with a “Show when running the workflow check box in their top section. When a user clicks this control, this section expands to expose a Prompt text field.
If the check box is selected and the workflow is run, the action displays its User Interface in a separate window. The input value in the prompt text field is used as title of the window.
The user makes selections and fills in information in this window and clicks OK to have the action proceed.

The setShowWhenRunAvailable(boolean) method activates or deactivates the Show When Run feature for the User Interface. It is also possible to define the default state of the “Show when running the workflow check box by using the setShownWhenRun(boolean) method, and the default value of the prompt with the setPrompt(String) method. Alternatively, the Show When Run feature can be set within the action property list.


Release Notes:

v1.1.0:

  • Improvements in the "shown when run" management
  • Change location of the prompt text field
  • Since:
    1.0.0
    Version:
    1.1.0
    Author:
    Jean-Baptiste Bres
    See Also:
    Serialized Form

    Nested Class Summary
     
    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
     
    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
    AbstractActionUI(AbstractAction parent)
              Instantiates a new UI.
     
    Method Summary
     void addActionUIListener(ActionUIListener l)
              Adds an ActionUIListener to the User Interface.
     void firePromptChanged()
              Invokes the promptChanged(ActionUIEvent) method of all the listeners.
     void fireShowWhenRunOptionChanged()
              Invokes the showWhenRunOptionChanged(ActionUIEvent) method of all the listeners.
     ActionService getActionService()
              Returns the action service associated to this UI.
     ActionUIListener[] getActionUIListeners()
              Returns all the listeners to the User Interface.
     javax.swing.JPanel getContentPane()
              Returns the content pane object for this User Interface.
     ActionDescription getDescription()
              Returns the action description.
     Parameters getParameters()
              Returns the current settings of the UI.
     AbstractAction getParentAction()
              Returns the parent action.
     java.lang.String getPrompt()
              Returns the "Show When Run" prompt text.
     Workflow getWorkflow()
              Returns the workflow that this UI belongs to.
     boolean isPromptAvailable()
              Checks if the user can input a personalized "Show When Run" prompt text.
     boolean isShownWhenRun()
              When the Show When Run feature is on, this method returns the current state of the "Show When Running the Workflow" check box.
     void removeActionUIListener(ActionUIListener l)
              Removes an ActionUIListener to the User Interface.
     void setEnabled(boolean b)
               
     void setParameters(Parameters parameters)
              Restores the UI settings.
     void setPrompt(java.lang.String text)
              Sets the "Show When Run" prompt text.
     void setPromptAvailable(boolean showPrompt)
              Allows the user to input a personalized "Show When Run" prompt text.
     void setShownWhenRun(boolean b)
              Changes the states of the "Show When Running the Workflow" check box.
     
    Methods inherited from class javax.swing.JPanel
    getAccessibleContext, getUI, getUIClassID, setUI, 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
     

    Constructor Detail

    AbstractActionUI

    public AbstractActionUI(AbstractAction parent)
    Instantiates a new UI.

    Parameters:
    parent - - the action that this UI is representing
    Method Detail

    getParentAction

    public AbstractAction getParentAction()
    Returns the parent action.

    Returns:
    the parent action

    getDescription

    public ActionDescription getDescription()
    Returns the action description.

    Returns:
    the action description

    getWorkflow

    public Workflow getWorkflow()
    Returns the workflow that this UI belongs to.

    Returns:
    the workflow that this UI belongs to.

    getActionService

    public ActionService getActionService()
    Returns the action service associated to this UI.

    Returns:
    the action service associated to this UI.

    getParameters

    public Parameters getParameters()
    Returns the current settings of the UI. The settings can be stored in a file and restore calling the setParameters(Parameters) method.

    If the UI has no specific settings, this method returns null.

    Returns:
    the current settings of the UI
    See Also:
    setParameters(Parameters)

    setParameters

    public void setParameters(Parameters parameters)
                       throws InvalidParametersException
    Restores the UI settings.

    Parameters:
    parameters - - the settings to be restored. Can be null
    Throws:
    InvalidParametersException - Raised when the parameters received are incorrect and cannot be mapped.
    See Also:
    getParameters()

    getContentPane

    public javax.swing.JPanel getContentPane()
    Returns the content pane object for this User Interface.

    Returns:
    the content pane object for this User Interface.

    isShownWhenRun

    public boolean isShownWhenRun()
    When the Show When Run feature is on, this method returns the current state of the "Show When Running the Workflow" check box.
    If the Show When Run feature is off, this method returns false

    Returns:
    true if the Show When Run feature is on and the "Show When Running the Workflow" check box is selected; false otherwise
    See Also:
    setShownWhenRun(boolean)

    setShownWhenRun

    public void setShownWhenRun(boolean b)
    Changes the states of the "Show When Running the Workflow" check box.

    Parameters:
    b - - the new states of the "Show When Running the Workflow" check box
    See Also:
    isShownWhenRun()

    getPrompt

    public java.lang.String getPrompt()
    Returns the "Show When Run" prompt text.

    Returns:
    the "Show When Run" prompt text.
    See Also:
    setPrompt(String), isPromptAvailable()

    setPrompt

    public void setPrompt(java.lang.String text)
    Sets the "Show When Run" prompt text.

    Parameters:
    text - - the new "Show When Run" prompt text.
    See Also:
    getPrompt(), setPromptAvailable(boolean)

    setPromptAvailable

    public void setPromptAvailable(boolean showPrompt)
    Allows the user to input a personalized "Show When Run" prompt text.

    Parameters:
    showPrompt - - true if the "Show When Run" prompt text field should be visible. false otherwise.
    See Also:
    isPromptAvailable()

    isPromptAvailable

    public boolean isPromptAvailable()
    Checks if the user can input a personalized "Show When Run" prompt text.

    Returns:
    true if the user can input a personalized "Show When Run" prompt text; false otherwise.
    See Also:
    setPromptAvailable(boolean)

    setEnabled

    public void setEnabled(boolean b)
    Overrides:
    setEnabled in class javax.swing.JComponent

    addActionUIListener

    public void addActionUIListener(ActionUIListener l)
    Adds an ActionUIListener to the User Interface.

    Parameters:
    l - - the listener

    removeActionUIListener

    public void removeActionUIListener(ActionUIListener l)
    Removes an ActionUIListener to the User Interface.

    Parameters:
    l - - the listener

    getActionUIListeners

    public ActionUIListener[] getActionUIListeners()
    Returns all the listeners to the User Interface.

    Returns:
    The listeners to to the User Interface.

    fireShowWhenRunOptionChanged

    public void fireShowWhenRunOptionChanged()
    Invokes the showWhenRunOptionChanged(ActionUIEvent) method of all the listeners.


    firePromptChanged

    public void firePromptChanged()
    Invokes the promptChanged(ActionUIEvent) method of all the listeners.



    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.