org.ceryle.ui.help
Class HelpDialog

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by javax.swing.JDialog
                      extended by org.ceryle.ui.help.HelpDialog
All Implemented Interfaces:
KeyListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants

public class HelpDialog
extends JDialog
implements KeyListener

Extends JDialog providing a Help dialog box.

The abstract class HelpAction is used as a base class for help actions, each defined to provide some type of functionality related to displaying help content or manipulating displays. The addAction(HelpAction,String,String) method is used to add embedded actions to each HelpAction, should it contain any script directives.

Since:
JDK1.4
Version:
$Id: HelpDialog.java,v 3.31 2007-06-20 01:28:23 altheim Exp $
Author:
Murray Altheim
See Also:
Serialized Form

Nested Class Summary
 class HelpDialog.ALinkListener
           
 class HelpDialog.DialogDisposer
           
 
Nested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialog
 
Nested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  JButton btn_close
           
protected  JButton btn_end
           
protected  JButton btn_hide
           
protected  JButton btn_index
           
protected  JButton btn_next
           
protected  JButton btn_prev
           
static int COLS
          The number of columns in the text area.
static String evalNid
          The node ID for the evaluation.
static String helpCID
          The collection ID for help.
static int HLP_CLOSE
          Constant indicating a close help action (-1).
static int HLP_END
          Constant indicating an end action.
static int HLP_EVAL
          Constant indicating an evaluation action.
static int HLP_INDEX
          Constant indicating an index action.
static int HLP_INTRO
          Constant indicating an intro action.
static int HLP_NEXT
          Constant indicating a next action.
static int HLP_PREV
          Constant indicating a previous action.
static int HLP_TOPIC
          Constant indicating a help topic action.
 int hmargin
          "Document mode" horizontal margin (in pixels).
static String introNid
          The node ID for the introduction.
protected  JLabel m_counter
           
protected  JEditorPane m_text
           
protected  JLabel m_title
           
protected  JPanel northPanel
           
static int ROWS
          The number of rows in the text area.
 int vmargin
          "Document mode" vertical margin (in pixels).
static String welcomeNid
          The node ID for the help intro text.
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
HelpDialog(Desktop desktop)
          Constructor for a help dialog box, which will be shown immediately.
HelpDialog(Desktop desktop, boolean showOnCreate)
          Constructor for a help dialog box.
 
Method Summary
 void addAction(HelpAction action, String keyword, String parameter)
          Add an embedded HelpAction with the given keyword and optional parameter to the provided HelpAction.
protected  String createID()
          Create a new ID.
 JPanel createSelectorPanel()
          Return the selector button panel containing the Intro, Evaluation and select Topic buttons.
static String getHelpCID()
          Return the ID of the help Collection.
 HelpProcess getHelpProcess()
          Return the current HelpProcess, null if none is running.
 void helpAction(int action)
          Traffic director/button handler.
 boolean isDocumentMode()
          Returns true if the help text body style is in "document" mode, with larger serif font and a white background for greater readability.
 void keyPressed(KeyEvent event)
           
 void keyReleased(KeyEvent event)
           
 void keyTyped(KeyEvent event)
           
protected  void openEvaluation()
          Starts the evaluation script.
protected  void openIntroduction()
          Starts the introductory script.
 void openTopic()
          Displays a dialog to allow selection from among any available help topic scripts (the collection indicated by helpCID).
 void openTopic(String nid)
          Displays the help topic indicated by the provided document ID from the Help Collection (the collection indicated by helpCID).
 void openTopic(String cid, String nid)
          Displays the help topic indicated by the provided Collection and Document IDs.
 void openTopic(XNodeID xid)
          Displays the help topic indicated by the provided XNodeID.
protected  void setActive(boolean active, HelpProcess helpProcess)
          Sets the mode to enable a help, evaluation or help topic sequence.
protected  void setBodyText(int style, String content)
          Set the body text and its base style (this is the main text in the center of the dialog).
protected  void setCountMessage(String message)
          Sets the text of the rightmost text to the provided String.
protected  void setDocumentMode(boolean mode)
          Sets the help text body style as help text (when false) or (when true) larger, in "Document Mode", with a white background and the Help font for greater readability.
protected  void setID(String id, String title)
          Set the action ID.
protected  void setTitleText(String s)
          Set the title text.
 void updateShowTips(boolean showtips)
          Update the Show Tips at Startup setting.
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Dialog
addNotify, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

welcomeNid

public static String welcomeNid
The node ID for the help intro text. Default is "welcome".


introNid

public static String introNid
The node ID for the introduction. Default is "intro".


evalNid

public static String evalNid
The node ID for the evaluation. Default is "evaluation".


HLP_CLOSE

public static final int HLP_CLOSE
Constant indicating a close help action (-1).

See Also:
Constant Field Values

HLP_INTRO

public static final int HLP_INTRO
Constant indicating an intro action.

See Also:
Constant Field Values

HLP_EVAL

public static final int HLP_EVAL
Constant indicating an evaluation action.

See Also:
Constant Field Values

HLP_TOPIC

public static final int HLP_TOPIC
Constant indicating a help topic action.

See Also:
Constant Field Values

HLP_INDEX

public static final int HLP_INDEX
Constant indicating an index action.

See Also:
Constant Field Values

HLP_PREV

public static final int HLP_PREV
Constant indicating a previous action.

See Also:
Constant Field Values

HLP_NEXT

public static final int HLP_NEXT
Constant indicating a next action.

See Also:
Constant Field Values

HLP_END

public static final int HLP_END
Constant indicating an end action.

See Also:
Constant Field Values

ROWS

public static int ROWS
The number of rows in the text area.


COLS

public static int COLS
The number of columns in the text area.


hmargin

public int hmargin
"Document mode" horizontal margin (in pixels).


vmargin

public int vmargin
"Document mode" vertical margin (in pixels).


helpCID

public static String helpCID
The collection ID for help. Default is "help".


northPanel

protected JPanel northPanel

m_title

protected JLabel m_title

m_counter

protected JLabel m_counter

m_text

protected JEditorPane m_text

btn_index

protected JButton btn_index

btn_prev

protected JButton btn_prev

btn_next

protected JButton btn_next

btn_end

protected JButton btn_end

btn_hide

protected JButton btn_hide

btn_close

protected JButton btn_close
Constructor Detail

HelpDialog

public HelpDialog(Desktop desktop)
Constructor for a help dialog box, which will be shown immediately.


HelpDialog

public HelpDialog(Desktop desktop,
                  boolean showOnCreate)
Constructor for a help dialog box. If showOnCreate is true, the dialog will be immediately shown.

Method Detail

createSelectorPanel

public JPanel createSelectorPanel()
Return the selector button panel containing the Intro, Evaluation and select Topic buttons.


updateShowTips

public void updateShowTips(boolean showtips)
Update the Show Tips at Startup setting.


getHelpCID

public static String getHelpCID()
Return the ID of the help Collection.


getHelpProcess

public HelpProcess getHelpProcess()
Return the current HelpProcess, null if none is running.


setID

protected void setID(String id,
                     String title)
Set the action ID. This serves the purpose of indicating which help action is currently being processed (which is written to the log). The title is written to the log and does not affect the displayed title, which is set via setTitleText(String).


setTitleText

protected void setTitleText(String s)
Set the title text. This is the large font text at the north side of the dialog. If null, the title panel is hidden.


isDocumentMode

public boolean isDocumentMode()
Returns true if the help text body style is in "document" mode, with larger serif font and a white background for greater readability.


setDocumentMode

protected void setDocumentMode(boolean mode)
Sets the help text body style as help text (when false) or (when true) larger, in "Document Mode", with a white background and the Help font for greater readability.


setCountMessage

protected void setCountMessage(String message)
Sets the text of the rightmost text to the provided String. This is generally mean to convey content like "1 of 7". A value of null clears the display.


helpAction

public void helpAction(int action)
Traffic director/button handler. The action must be one of the HLP_* constants.


openIntroduction

protected void openIntroduction()
Starts the introductory script.


openEvaluation

protected void openEvaluation()
Starts the evaluation script.


openTopic

public void openTopic()
Displays a dialog to allow selection from among any available help topic scripts (the collection indicated by helpCID).


openTopic

public void openTopic(String nid)
Displays the help topic indicated by the provided document ID from the Help Collection (the collection indicated by helpCID).


openTopic

public void openTopic(XNodeID xid)
Displays the help topic indicated by the provided XNodeID.


openTopic

public void openTopic(String cid,
                      String nid)
Displays the help topic indicated by the provided Collection and Document IDs.


setBodyText

protected void setBodyText(int style,
                           String content)
Set the body text and its base style (this is the main text in the center of the dialog). This uses a Thread to pop the text as according to the EventQueue. If style is -1, no changes occur to the display style.


setActive

protected void setActive(boolean active,
                         HelpProcess helpProcess)
                  throws HelpException
Sets the mode to enable a help, evaluation or help topic sequence.

Throws:
HelpException - if the mode is set improperly (e.g., there is already a sequence in progress)

addAction

public void addAction(HelpAction action,
                      String keyword,
                      String parameter)
Add an embedded HelpAction with the given keyword and optional parameter to the provided HelpAction.

Provided a String, parses the String and adds an embedded HelpAction to the provided HelpActions's list. This class may be extended to provide additional assignments of HelpAction subclasses. The actual parsing is done either by the HelpAction.parseToAction(HelpAction,String) method within HelpAction or by a overriding of that method within a HelpAction subclass.

The available HelpActions are currently defined as the following, a single token keyword followed by whitespace, then some optional content.

DISPLAY text
displays text (HTML content okay) in the Help window
DIALOG ["boolean" | "string"] text
displays a user dialog (HTML content okay), requesting either a boolean (yes/no) or string result
OPENDOC systemId
opens a new DocumentView with the content based on the URL systemId
OPENGRAPH systemId
opens a new GraphView with the content based on the URL systemId
OPENPROJECT systemId
opens a new ProjectView with the content based on the URL systemId
OPEN systemId
opens the document specified by the provided URL (uses a ResourceOpener, whose behaviour is based on the supplied parameters)
CLOSE systemId
closes any existing View having a URL systemId. If systemId is "*", closes all.
FRONT systemId
brings the existing View having a URL systemId to the front
MINIMIZE systemId
minimizes the existing View having a URL systemId
GRAPHSELECT id
selects the GraphNode whose ID is id
WAIT n
waits n seconds before proceeding to the next action
SHOW
shows the help window
HIDE
hides the help window
LOG text
logs a message


createID

protected String createID()
Create a new ID. This is only guaranteed to be unique within this HelpDialog object's domain.


keyPressed

public void keyPressed(KeyEvent event)
Specified by:
keyPressed in interface KeyListener

keyReleased

public void keyReleased(KeyEvent event)
Specified by:
keyReleased in interface KeyListener

keyTyped

public void keyTyped(KeyEvent event)
Specified by:
keyTyped in interface KeyListener


The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.