amber.server.component
Class MenuBarHandler

java.lang.Object
  |
  +--java.awt.Component
        |
        +--amber.server.component.ComponentHandler
              |
              +--amber.server.component.MenuComponentHandler
                    |
                    +--amber.server.component.MenuBarHandler
All Implemented Interfaces:
ApplicationInterface, BaseMenu, java.awt.image.ImageObserver, java.awt.ItemSelectable, MenuContainer, java.awt.MenuContainer, java.io.Serializable

public class MenuBarHandler
extends MenuComponentHandler
implements BaseMenu, MenuContainer, java.io.Serializable

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

The remote client class also responds to information stored in the parameters field of the XYConstraints object when this handler is added to a panel. The allowed parameters are separated in the string by '|' characters. Any unused trailing parameters are optional and will assume default values, however the parameter order is fixed.

For example, if the component takes 4 parameters which are ints, a valid parameter string would be:

"1|2|3"

In this case the fourth parameter would assume the default value.

The parameter elements for this component are:

Component Parameters
NameTypeDescriptionRepeatsDefault
Menu TypeintFor this class the value MUST BE 1No0

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

Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Fields inherited from class amber.server.component.MenuComponentHandler
name, parent
 
Fields inherited from class amber.server.component.ComponentHandler
actionCommand, 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
MenuBarHandler()
          Default constructor.
MenuBarHandler(ApplicationInterface pageHandler)
          The initialising constructor.
MenuBarHandler(int id, ApplicationInterface pageHandler)
          The initialising constructor.
 
Method Summary
 MenuHandler add(MenuHandler menu)
          Adds the specified menu to the menu bar.
 void deleteShortcut(java.awt.MenuShortcut shortcut)
          Deletes the specified menu shortcut.
protected  void forwardPacket(Packet packet)
          Called by the ReceiveThread when a packet has been received.
 int getBaseOffset()
          This function returns the base offset that all menu components off this menu must reference.
 java.lang.String getDefaultParameters()
          This function returns the default parameters string required by the component.
 int getIdOffset(int id)
          This function returns what the input ID would be if it were offset by the base offset.
 MenuHandler getMenu(int index)
          Gets the specified menu.
 int getMenuCount()
          Gets the number of menus on the menu bar.
 java.lang.String getPanelType()
          This function returns the panel component to use with this class.
 MenuItemHandler getShortcutMenuItem(java.awt.MenuShortcut shortcut)
          Gets the instance of MenuItemHandler associated with the specified MenuShortcut object, or null if none has been specified.
 boolean isMyId(int inId)
          Checks that the unique ID passed to this component is handled by this ComponentHandler.
 void processCurrentPacket(Packet packet)
          This function receives the packet given to it by the ApplicationInterface.
 void remove(int index)
          Removes the menu located at the specified index from this menu bar.
 void remove(MenuComponentHandler mi)
          Removes the menu specified from this menu bar.
 int removeIdOffset(int id)
          This function returns what the input ID would be if it were not offset by the base offset.
 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.
 java.util.Enumeration shortcuts()
          Gets an enumeration of all menu shortcuts that this menu bar manages.
 
Methods inherited from class amber.server.component.MenuComponentHandler
getId, getIdBaseOffset, getMenuParent, getName, getTopMenuParent, paramString, 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, 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, isEnabled, 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, setEnabled, 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
 

Constructor Detail

MenuBarHandler

public MenuBarHandler()
Default constructor.

MenuBarHandler

public MenuBarHandler(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.

MenuBarHandler

public MenuBarHandler(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.
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

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 MenuHandler add(MenuHandler menu)
Adds the specified menu to the menu bar.
Parameters:
menu - The MenuHandler to be added.
Returns:
MenuHandler which was added.

remove

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

remove

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

getMenuCount

public int getMenuCount()
Gets the number of menus on the menu bar.
Returns:
int containing the number of menus on the menu bar.

getMenu

public MenuHandler getMenu(int index)
Gets the specified menu.
Parameters:
index - int position of the menu to be returned.
Returns:
MenuHandler which is the menu at the specified index of this menu bar.

shortcuts

public java.util.Enumeration shortcuts()
Gets an enumeration of all menu shortcuts that this menu bar manages.
Returns:
Enumeration containing the menu shortcuts that this menu bar is managing.

getShortcutMenuItem

public MenuItemHandler getShortcutMenuItem(java.awt.MenuShortcut shortcut)
Gets the instance of MenuItemHandler associated with the specified MenuShortcut object, or null if none has been specified.
Parameters:
shortcut - MenuShortcut containing the specified menu shortcut.
Returns:
MenuItemHandler which matches the MenuShortcut.

deleteShortcut

public void deleteShortcut(java.awt.MenuShortcut shortcut)
Deletes the specified menu shortcut.
Parameters:
shortcut - The MenuShortcut to delete.

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.

getBaseOffset

public int getBaseOffset()
This function returns the base offset that all menu components off this menu must reference.
Specified by:
getBaseOffset in interface BaseMenu
Returns:
int containing the base offset.

getIdOffset

public int getIdOffset(int id)
This function returns what the input ID would be if it were offset by the base offset.
Specified by:
getIdOffset in interface BaseMenu
Parameters:
id - int ID value to offset.
Returns:
int containing the ID value offset by the base offset.

removeIdOffset

public int removeIdOffset(int id)
This function returns what the input ID would be if it were not offset by the base offset.
Specified by:
removeIdOffset in interface BaseMenu
Parameters:
id - int ID value including offset.
Returns:
int containing the ID value with no base offset.

getDefaultParameters

public java.lang.String getDefaultParameters()
This function returns the default parameters string required by the component. This is rarely used but may be overridden for a panel component to always have a particular type of parameter when creating the component at the client. This is overriden to tell the client to create a MenuBar component.
Overrides:
getDefaultParameters in class ComponentHandler
Returns:
String containing the parameters value to use.

getPanelType

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


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.