com.isti.util.menu
Class IstiMenuLoader

java.lang.Object
  extended by com.isti.util.ErrorMessageMgr
      extended by com.isti.util.IstiXmlUtils
          extended by com.isti.util.IstiXmlLoader
              extended by com.isti.util.menu.IstiMenuLoader
All Implemented Interfaces:
ErrorMsgMgrIntf

public class IstiMenuLoader
extends IstiXmlLoader

Class IstiMenuLoader implements a XML menu loader.


Nested Class Summary
protected static class IstiMenuLoader.MenuBarMenuItem
          Menu bar menu item.
protected static class IstiMenuLoader.SpaceMenuItem
          Space menu item.
 
Nested classes/interfaces inherited from class com.isti.util.IstiXmlUtils
IstiXmlUtils.RootElement
 
Field Summary
static java.lang.String TOP_MENU_BAR_NAME
          The name string for the top menu bar.
 
Fields inherited from class com.isti.util.IstiXmlUtils
ISO_8859_1_ENCODING_FORMAT, loadFileOpenedFlag, rootElement, useDocumentFlag, UTF_8_ENCODING_FORMAT, XML_FILE_EXTENSION, XML_STYLESHEET, XML_STYLESHEET_PROCESSING_INSTRUCTION, xmlBuilderObj, xmlFileOutputterObj, xmlFixedStrOutputterObj, xmlStrOutputterObj
 
Constructor Summary
IstiMenuLoader()
          Constructs a XML menu loader with no default ActionListener.
IstiMenuLoader(java.awt.event.ActionListener l)
          Constructs a XML menu loader.
 
Method Summary
protected  java.awt.event.ActionListener addActionListener(java.lang.Object menuItem, java.lang.String handlerString)
          Adds an action listener to the menu item
protected  void addMenuItem(java.lang.Object menuItem, java.lang.Object parentObject)
          Adds the menu item to the parent.
protected  void addMenuSeparator(java.lang.Object parentObject)
          Appends a new separator to the end of the menu
 java.awt.Frame createFrameWithMenuBar(java.lang.Object topMenuObject)
          Creates a Frame with the specified top menu object.
 java.awt.Frame createFrameWithMenuBar(java.lang.Object topMenuObject, int width, int height)
          Creates a Frame with the specified top menu object and resizes this component so that it has width width and height.
protected  java.lang.Object findMenuItem(java.awt.Component menuObject, java.lang.String name)
          Finds a menu item.
protected  java.lang.Object findMenuItem(java.awt.MenuBar menuObject, java.lang.String name)
          Finds a menu item.
protected  java.lang.Object findMenuItem(java.awt.MenuComponent menuObject, java.lang.String name)
          Finds a menu item.
protected  java.lang.Object findMenuItem(javax.swing.MenuElement menuObject, java.lang.String name)
          Finds a menu item.
protected  java.lang.Object findMenuItem(java.awt.Menu menuObject, java.lang.String name)
          Finds a menu item.
 java.lang.Object findMenuItem(java.lang.Object menuObject, java.lang.String name)
          Finds a menu item.
 java.lang.Object findMenuItem(java.lang.String name)
          Finds a menu item.
 java.lang.Object getChildMenuObject(int childIndex, java.lang.Object parentObject)
          Gets the child menu object.
 java.lang.Object getTopMenuBarObject()
          Gets the top menu bar object.
 java.lang.Object getTopMenuObject()
          Gets the top menu object.
 java.lang.Object getTopMenuObject(int index)
          Gets the top menu object.
 java.lang.Object getTopMenuObject(java.lang.String name)
          Gets the top menu object.
 boolean loadFile(java.lang.String fileName)
          Loads the XML file.
protected  java.lang.Object loadMenuItem(java.lang.String name, java.lang.Object parentObject, org.jdom.Element parentElement)
          Loads a menu item.
protected  java.lang.Object processElement(org.jdom.Element element, java.lang.Object parentObject, org.jdom.Element parentElement)
          Processes the element for this document.
protected  void processElementAttributes(org.jdom.Element element, java.lang.Object menuItem)
          Processes element attributes.
protected  void processErrorMessage(java.lang.String str)
          Processes an error message.
 void setDefaultActionListener(java.awt.event.ActionListener l)
          Sets the default ActionListener for the menu.
 java.lang.Object updateMenuItemShown(java.lang.Object menuObject, java.lang.String name, boolean showItemFlag)
          Updates the "visible" status of the given menu item.
 java.lang.Object updateMenuItemShown(java.lang.String name, boolean showItemFlag)
          Updates the "visible" status of the given menu item.
 
Methods inherited from class com.isti.util.IstiXmlLoader
processChildElement, processChildElement, processChildren
 
Methods inherited from class com.isti.util.IstiXmlUtils
addXmlFileExtension, clearErrorMessage, convertFromEscapedCodes, createCdata, createRootElement, ctrlCharsFromEscapedCodes, ctrlCharsToEscapedCodes, ctrlCharsToEscapedCodes, elementToFixedString, elementToString, elementToString, findElement, findElement, getAnyNSChild, getChildDataFixedStr, getChildDataStr, getChildDataStr, getChildDataStr, getComponentForClass, getEncodedString, getErrorFlag, getErrorMessage, getLoadFileOpenedFlag, getRootElement, loadFile, loadFile, loadStream, loadStream, loadStream, loadStream, saveToFile, saveToFile, saveToStream, saveToStream, setDocumentStylesheet, setElementNamespace, setElementNamespace, setErrorMessage, setFileLineSeparator, setFileOmitDeclaration, setFileOmitEncoding, setFileOutExpandEmptyElements, setFileOutIndent, setFileOutNewlines, setFileOutTextTrim, setLoadExternalDTDFeature, setRootElement, setStrOutExpandEmptyElements, setStrOutIndent, setStrOutNewlines, setStrOutTextTrim, stringToElement
 
Methods inherited from class com.isti.util.ErrorMessageMgr
clearErrorMessageString, clearFetchedErrorMessage, enterErrorMessageString, getErrorMessageFlag, getErrorMessageString, getUnfetchedMessageFlag, setErrorMessageString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TOP_MENU_BAR_NAME

public static final java.lang.String TOP_MENU_BAR_NAME
The name string for the top menu bar.

See Also:
Constant Field Values
Constructor Detail

IstiMenuLoader

public IstiMenuLoader()
Constructs a XML menu loader with no default ActionListener. The setDefaultActionListener method should be called or a Handler should be provided in the XML.


IstiMenuLoader

public IstiMenuLoader(java.awt.event.ActionListener l)
Constructs a XML menu loader.

Parameters:
l - the default ActionListener
See Also:
setDefaultActionListener for ActionListener details.
Method Detail

getChildMenuObject

public java.lang.Object getChildMenuObject(int childIndex,
                                           java.lang.Object parentObject)
Gets the child menu object.

Parameters:
childIndex - index of child element to return.
parentObject - the parent object for the element.
Returns:
the child menu object.

createFrameWithMenuBar

public java.awt.Frame createFrameWithMenuBar(java.lang.Object topMenuObject)
Creates a Frame with the specified top menu object.

Parameters:
topMenuObject - the top menu object to be added to the frame.
Returns:
the top menu object or null if error. Use getErrorMessage to determine error.
See Also:
getErrorMessage, clearErrorMessage

createFrameWithMenuBar

public java.awt.Frame createFrameWithMenuBar(java.lang.Object topMenuObject,
                                             int width,
                                             int height)
Creates a Frame with the specified top menu object and resizes this component so that it has width width and height.

Parameters:
topMenuObject - the top menu object to be added to the frame.
width - The new width of this component in pixels.
height - The new height of this component in pixels.
Returns:
the top menu object or null if error. Use getErrorMessage to determine error.
See Also:
getErrorMessage, clearErrorMessage

getTopMenuBarObject

public java.lang.Object getTopMenuBarObject()
Gets the top menu bar object.

Returns:
the top menu bar object.
See Also:
TOP_MENU_BAR_NAME

getTopMenuObject

public java.lang.Object getTopMenuObject()
Gets the top menu object.

Returns:
the top menu object.

getTopMenuObject

public java.lang.Object getTopMenuObject(int index)
Gets the top menu object.

Parameters:
index - index of top menu object to return.
Returns:
the top menu object.

getTopMenuObject

public java.lang.Object getTopMenuObject(java.lang.String name)
Gets the top menu object.

Parameters:
name - the name of the menu object to be found
Returns:
the top menu object.

loadFile

public boolean loadFile(java.lang.String fileName)
Loads the XML file.

Parameters:
fileName - the name of the XML file to load.
Returns:
true if the file was loaded

processErrorMessage

protected void processErrorMessage(java.lang.String str)
Processes an error message. NOTE: Override this function to process error messages.

Parameters:
str - the error message.

setDefaultActionListener

public final void setDefaultActionListener(java.awt.event.ActionListener l)
Sets the default ActionListener for the menu.

Parameters:
l - the default ActionListener which may be a standard ActionListener or an IstiMenuListener such as IstiMenuHandler.

processElement

protected java.lang.Object processElement(org.jdom.Element element,
                                          java.lang.Object parentObject,
                                          org.jdom.Element parentElement)
Processes the element for this document.

Specified by:
processElement in class IstiXmlLoader
Parameters:
element - the element to process
parentObject - the parent object for the element
parentElement - the parent element for the element.
Returns:
an object for the element or null if no object is needed.

processElementAttributes

protected void processElementAttributes(org.jdom.Element element,
                                        java.lang.Object menuItem)
Processes element attributes.

Parameters:
element - the element to process
menuItem - the menu item

addActionListener

protected java.awt.event.ActionListener addActionListener(java.lang.Object menuItem,
                                                          java.lang.String handlerString)
Adds an action listener to the menu item

Parameters:
menuItem - the menu item
handlerString - the string representation of the handler
Returns:
the action listener

addMenuItem

protected void addMenuItem(java.lang.Object menuItem,
                           java.lang.Object parentObject)
Adds the menu item to the parent.

Parameters:
menuItem - the menu item
parentObject - the parent object for the menu item

addMenuSeparator

protected void addMenuSeparator(java.lang.Object parentObject)
Appends a new separator to the end of the menu

Parameters:
parentObject - the parent object for the element

loadMenuItem

protected java.lang.Object loadMenuItem(java.lang.String name,
                                        java.lang.Object parentObject,
                                        org.jdom.Element parentElement)
Loads a menu item.

Parameters:
name - the name of the menu item to add.
parentObject - the parent object for the element
parentElement - the parent element for the element.
Returns:
the object for the menu item.

findMenuItem

public java.lang.Object findMenuItem(java.lang.String name)
Finds a menu item.

Parameters:
name - the name of the item to be found
Returns:
the object for the menu item.

findMenuItem

public java.lang.Object findMenuItem(java.lang.Object menuObject,
                                     java.lang.String name)
Finds a menu item.

Parameters:
menuObject - the menu object to start with
name - the name of the item to be found
Returns:
the object for the menu item.

updateMenuItemShown

public java.lang.Object updateMenuItemShown(java.lang.String name,
                                            boolean showItemFlag)
Updates the "visible" status of the given menu item.

Parameters:
name - the name of the item to be found.
showItemFlag - true for item visible; false for item hidden.
Returns:
the object for the menu item or null if not found.

updateMenuItemShown

public java.lang.Object updateMenuItemShown(java.lang.Object menuObject,
                                            java.lang.String name,
                                            boolean showItemFlag)
Updates the "visible" status of the given menu item.

Parameters:
menuObject - the menu object to start with.
name - the name of the item to be found.
showItemFlag - true for item visible; false for item hidden.
Returns:
the object for the menu item or null if not found.

findMenuItem

protected java.lang.Object findMenuItem(java.awt.MenuComponent menuObject,
                                        java.lang.String name)
Finds a menu item.

Parameters:
menuObject - the menu object to start with
name - the name of the item to be found
Returns:
the object for the menu item.

findMenuItem

protected java.lang.Object findMenuItem(java.awt.Component menuObject,
                                        java.lang.String name)
Finds a menu item.

Parameters:
menuObject - the menu object to start with
name - the name of the item to be found
Returns:
the object for the menu item.

findMenuItem

protected java.lang.Object findMenuItem(javax.swing.MenuElement menuObject,
                                        java.lang.String name)
Finds a menu item.

Parameters:
menuObject - the menu object to start with
name - the name of the item to be found
Returns:
the object for the menu item.

findMenuItem

protected java.lang.Object findMenuItem(java.awt.MenuBar menuObject,
                                        java.lang.String name)
Finds a menu item.

Parameters:
menuObject - the menu object to start with
name - the name of the item to be found
Returns:
the object for the menu item.

findMenuItem

protected java.lang.Object findMenuItem(java.awt.Menu menuObject,
                                        java.lang.String name)
Finds a menu item.

Parameters:
menuObject - the menu object to start with
name - the name of the item to be found
Returns:
the object for the menu item.