amber.server.component
Class MenuHandler

java.lang.Object
  |
  +--java.awt.Component
        |
        +--amber.server.component.ComponentHandler
              |
              +--amber.server.component.MenuComponentHandler
                    |
                    +--amber.server.component.MenuItemHandler
                          |
                          +--amber.server.component.MenuHandler
All Implemented Interfaces:
ApplicationInterface, java.awt.image.ImageObserver, java.awt.ItemSelectable, MenuContainer, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
PopupMenuHandler

public class MenuHandler
extends MenuItemHandler
implements MenuContainer, java.io.Serializable

This class corresponds to a standard java.awt.Menu component. It differs in terms of being Amber aware. For this reason the component communicates with the remote client to perform the standard operations.

Version:
1.0.0
Author:
Dr. David J. Knowles
See Also:
BaseComponent, Serialized Form

Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  java.util.Vector items
           
protected  boolean tearOff
           
 
Fields inherited from class amber.server.component.MenuItemHandler
actionCommand, enabled, label
 
Fields inherited from class amber.server.component.MenuComponentHandler
name, parent
 
Fields inherited from class amber.server.component.ComponentHandler
active, ApplicationId, CancelReturn, dataEncoder, DefaultTimeout, enabledState, encoderBytes, id, InvalidId, MaximumId, NoReturn, OkCancelType, OkReturn, OkType, OkYesReturn, parentPage, responsePackets, timeoutValue, UnchangeableInvalidId, visibleState, YesNoCancelType, YesNoType, YesReturn
 
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
MenuHandler()
          Default constructor.
MenuHandler(ApplicationInterface pageHandler)
          The initialising constructor.
MenuHandler(ApplicationInterface pageHandler, java.lang.String label)
          The initialising constructor.
MenuHandler(ApplicationInterface pageHandler, java.lang.String label, boolean tearOff)
          The initialising constructor.
MenuHandler(int id, ApplicationInterface pageHandler)
          The initialising constructor.
MenuHandler(int id, ApplicationInterface pageHandler, java.lang.String label)
          The initialising constructor.
MenuHandler(int id, ApplicationInterface pageHandler, java.lang.String label, boolean tearOff)
          The initialising constructor.
 
Method Summary
 void add(int id, ApplicationInterface parentPage, java.lang.String label)
          Adds an item with the specified label to this menu.
 MenuItemHandler add(MenuItemHandler mi)
          Adds the specified menu item to this menu.
 void addSeparator()
          Adds a separator line, or a hypen, to the menu at the current position.
 void deleteShortcut()
          Delete any MenuShortcut object associated with this menu item.
 void deleteShortcut(java.awt.MenuShortcut shortcut)
          This function looks at all the items in the menu checking for a match to the input MenuShortcut.
protected  void forwardPacket(Packet packet)
          Called by the ReceiveThread when a packet has been received.
 MenuItemHandler getItem(int index)
          Gets the item located at the specified index of this menu.
 int getItemCount()
          Get the number of items in this menu.
 java.lang.String getPanelType()
          This function returns the panel component to use with this class.
protected  MenuItemHandler getShortcutMenuItem(java.awt.MenuShortcut s)
          This is a helper function which will return the MenuItem in this menu which matches the MenuShortcut.
 void insert(int id, ApplicationInterface parentPage, java.lang.String label, int index)
          Inserts a menu item with the specified label into this menu at the specified position.
 void insert(MenuItemHandler item, int index)
          Inserts a menu item into this menu at the specified position.
 void insertSeparator(int index)
          Inserts a separator at the specified position.
 boolean isMyId(int inId)
          Checks that the unique ID passed to this component is handled by this ComponentHandler.
 boolean isTearOff()
          Indicates whether this menu is a tear-off menu.
 java.lang.String paramString()
          Gets the parameter string representing the state of this menu.
 void processCurrentPacket(Packet packet)
          This function receives the packet given to it by the ApplicationInterface.
 void remove(int index)
          Removes the menu item at the specified index from this menu.
 void remove(MenuComponentHandler item)
          Removes the specified menu item from this menu.
 void removeAll()
          Removes all items from this menu.
 void resetState()
          This function resets the component to a default state.
 void setActive(boolean state)
          This function tells the ComponentHandler that there is a corresponding remote component to communicate with and that the link is active.
 
Methods inherited from class amber.server.component.MenuItemHandler
getLabel, getShortcut, isEnabled, setEnabled, setLabel, setShortcut
 
Methods inherited from class amber.server.component.MenuComponentHandler
getId, getIdBaseOffset, getMenuParent, getName, getTopMenuParent, removeIdBaseOffset, sendPacket, sendPacketAndBlock, setName, toString
 
Methods inherited from class amber.server.component.ComponentHandler
addActionListener, addComponentListener, addEventMask, addFocusListener, addItemListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addReceivedPacket, addTextListener, addWindowListener, booleanToInt, createDataInput, directPacket, displayMessageBox, fireWindowActivated, fireWindowClosed, fireWindowClosing, fireWindowDeactivated, fireWindowDeiconified, fireWindowEvent, fireWindowIconified, fireWindowOpened, forceComponentGetUrl, forceComponentGetUrl, forwardEventPacket, generateActionEvent, generateFocusEvent, generateItemEvent, generateKeyEvent, generateMouseEvent, getActionCommand, getBounds, getComponentStructure, getDefaultParameters, getEventMask, getFontCharacteristics, getFontCharacteristics, getFontCharacteristics, getFontCharacteristics, getFontStyle, getLocation, getLog, getModalObject, getParentApplication, getParentContainer, getParentServer, getResponsePacket, getSelectedObjects, getSize, getTimeout, getValidId, getX, getY, handleMessages, handlePacket, internalForwardPacket, internalGetBounds, intToBoolean, isActive, isApplicationActive, isComponentModal, isConnected, isVisible, processActionEvent, processComponentEvent, processEvent, processFocusEvent, processItemEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processNormalResponse, processTextEvent, queryMessageBox, removeActionListener, removeComponentListener, removeEventMask, removeFocusListener, removeItemListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removeTextListener, removeWindowListener, requestFocus, restart, sendPendingPackets, setActionCommand, setBackground, setComponentModal, setConnectedState, setCursor, setEventMask, setFont, setFont, setFontStyle, setForeground, setForegroundBackground, setId, setLog, setModalObject, setParentApplication, setParentContainer, setParentServer, setTimeout, setVisible, setX, setY, shutDown, shutDownClient, shutDownClient, start
 
Methods inherited from class java.awt.Component
action, add, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getParent, getPeer, getPreferredSize, getSize, getToolkit, getTreeLock, getWidth, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, remove, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setSize, setSize, show, show, size, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface amber.server.component.MenuContainer
getFont
 

Field Detail

items

protected java.util.Vector items

tearOff

protected boolean tearOff
Constructor Detail

MenuHandler

public MenuHandler()
Default constructor.

MenuHandler

public MenuHandler(ApplicationInterface pageHandler)
The initialising constructor. This constructor dynamically requests a valid ID value from the ApplicationInterface.
Parameters:
pageHandler - The handle to the main ApplicationInterface which handles the functions of page overall. residing on the browser.

MenuHandler

public MenuHandler(ApplicationInterface pageHandler,
                   java.lang.String label)
The initialising constructor. This constructor dynamically requests a valid ID value from the ApplicationInterface.
Parameters:
pageHandler - The handle to the main ApplicationInterface which handles the functions of page overall. residing on the browser.
label - The label for this menu item.

MenuHandler

public MenuHandler(ApplicationInterface pageHandler,
                   java.lang.String label,
                   boolean tearOff)
The initialising constructor. This constructor dynamically requests a valid ID value from the ApplicationInterface.
Parameters:
pageHandler - The handle to the main ApplicationInterface which handles the functions of page overall. residing on the browser.
label - The label for this menu item.
tearOff - boolean when true the menu becomes tear off if supported by the Java run time.

MenuHandler

public MenuHandler(int id,
                   ApplicationInterface pageHandler)
The initialising constructor.
Parameters:
id - The int containing the id of the corresponding remote component residing on the browser.
pageHandler - The handle to the main ApplicationInterface which handles the functions of page overall.

MenuHandler

public MenuHandler(int id,
                   ApplicationInterface pageHandler,
                   java.lang.String label)
The initialising constructor.
Parameters:
id - The int containing the id of the corresponding remote component residing on the browser.
pageHandler - The handle to the main ApplicationInterface which handles the functions of page overall.
label - The label for this menu item.

MenuHandler

public MenuHandler(int id,
                   ApplicationInterface pageHandler,
                   java.lang.String label,
                   boolean tearOff)
The initialising constructor.
Parameters:
id - The int containing the id of the corresponding remote component residing on the browser.
pageHandler - The handle to the main ApplicationInterface which handles the functions of page overall.
label - The label for this menu item.
tearOff - boolean when true the menu becomes tear off if supported by the Java run time.
Method Detail

resetState

public void resetState()
This function resets the component to a default state. It is used to resynchronize the visual and internal versions of the component. IT SHOULD NEVER BE CALLED BY THE APPLICATION CODE.
Overrides:
resetState in class ComponentHandler

isTearOff

public boolean isTearOff()
Indicates whether this menu is a tear-off menu.
Returns:
boolean true if this is a tear-off menu.

getItemCount

public int getItemCount()
Get the number of items in this menu.
Returns:
int containing the number of items in this menu.

getItem

public MenuItemHandler getItem(int index)
Gets the item located at the specified index of this menu.
Parameters:
index - The position of the item to be returned.
Returns:
MenuItemHandler which is the item located at the specified index.

setActive

public void setActive(boolean state)
               throws ComponentHandlerException
This function tells the ComponentHandler that there is a corresponding remote component to communicate with and that the link is active. When active all pending packets are flushed to the remote component.
Overrides:
setActive in class ComponentHandler
Parameters:
state - boolean state which when true enables the component. This is the default.
Throws:
ComponentHandlerException - with any errors.

add

public MenuItemHandler add(MenuItemHandler mi)
Adds the specified menu item to this menu. If the menu item has been part of another menu, remove it from that menu.
Parameters:
mi - The MenuItemHandler menu item to be added.
Returns:
MenuItemHandler which was added.

add

public void add(int id,
                ApplicationInterface parentPage,
                java.lang.String label)
Adds an item with the specified label to this menu.
Parameters:
id - The int containing the id of the corresponding remote component residing on the browser.
pageHandler - The handle to the main ApplicationInterface which handles the functions of page overall.
label - The string text label of the item.

insert

public void insert(MenuItemHandler item,
                   int index)
Inserts a menu item into this menu at the specified position.
Parameters:
item - The MenuItemHandler to be inserted.
index - int position at which the menu item should be inserted.
Throws:
java.lang.IllegalArgumentException - if the value of the index is invalid.

insert

public void insert(int id,
                   ApplicationInterface parentPage,
                   java.lang.String label,
                   int index)
Inserts a menu item with the specified label into this menu at the specified position.
Parameters:
id - The int containing the id of the corresponding remote component residing on the browser.
pageHandler - The handle to the main ApplicationInterface which handles the functions of page overall.
label - String text for the MenuItemHandler.
index - int index position at which the menu item should be inserted.

addSeparator

public void addSeparator()
Adds a separator line, or a hypen, to the menu at the current position.

insertSeparator

public void insertSeparator(int index)
Inserts a separator at the specified position.
Parameters:
index - int position at which the menu separator should be inserted.
Throws:
java.lang.IllegalArgumentException - if the value of the index is invalid.

remove

public void remove(int index)
Removes the menu item at the specified index from this menu.
Parameters:
index - int position of the item to be removed.

remove

public void remove(MenuComponentHandler item)
Removes the specified menu item from this menu.
Specified by:
remove in interface MenuContainer
Parameters:
item - The MenuComponentHandler item to be removed from the menu

removeAll

public void removeAll()
Removes all items from this menu.

getShortcutMenuItem

protected MenuItemHandler getShortcutMenuItem(java.awt.MenuShortcut s)
This is a helper function which will return the MenuItem in this menu which matches the MenuShortcut.
Overrides:
getShortcutMenuItem in class MenuItemHandler
Parameters:
s - MenuShortcut which is to be matched.
Returns:
MenuItemHandler if there is such a MenuShortcut in this Menu or null.

deleteShortcut

public void deleteShortcut(java.awt.MenuShortcut shortcut)
This function looks at all the items in the menu checking for a match to the input MenuShortcut. Should it match it deletes the shortcut. It will not recurse into submenus.
Parameters:
shortcut - MenuShortcut to remove from the item.

deleteShortcut

public void deleteShortcut()
Description copied from class: MenuItemHandler
Delete any MenuShortcut object associated with this menu item.
Overrides:
deleteShortcut in class MenuItemHandler

paramString

public java.lang.String paramString()
Gets the parameter string representing the state of this menu. This string is useful for debugging.
Overrides:
paramString in class MenuItemHandler
Following copied from class: amber.server.component.MenuItemHandler
Returns:
String which is the parameter string of this menu item.

isMyId

public boolean isMyId(int inId)
Checks that the unique ID passed to this component is handled by this ComponentHandler.
Overrides:
isMyId in class MenuComponentHandler
Parameters:
id - int component handler ID.
Returns:
boolean if this is the correct ComponentHandler.

processCurrentPacket

public void processCurrentPacket(Packet packet)
                          throws ComponentHandlerException
This function receives the packet given to it by the ApplicationInterface. It then calls the component handling routines to handle the requirements of the packet and generate any events which may be required.
Overrides:
processCurrentPacket in class ComponentHandler
Parameters:
packet - Packet containing the packet to handle.
Throws:
ComponentHandlerException - containing the error information.

forwardPacket

protected void forwardPacket(Packet packet)
                      throws ComponentHandlerException
Called by the ReceiveThread when a packet has been received. This function examines the packet and passes it to the appropriate handler.
Parameters:
packet - Packet to forward to the specified component.

getPanelType

public java.lang.String getPanelType()
This function returns the panel component to use with this class.
Overrides:
getPanelType in class MenuItemHandler
Returns:
String containing the panel type to use.


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.