amber.server.component
Class ComponentHandler

java.lang.Object
  |
  +--java.awt.Component
        |
        +--amber.server.component.ComponentHandler
All Implemented Interfaces:
ApplicationInterface, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
AudioHandler, ButtonHandler, CheckboxHandler, CheckboxPanelHandler, ChoiceHandler, ComplexListHandler, GenericEventHandler, GenericHandler, ImageHandler, LabelHandler, LinkHandler, ListHandler, MenuComponentHandler, PanelHandler, TextComponentHandler, TreeListHandler

public abstract class ComponentHandler
extends java.awt.Component
implements java.io.Serializable, java.awt.ItemSelectable, ApplicationInterface

This class handles the requirements for the manipulation of the packets moving to and from the actual components themselves.

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

Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  java.lang.String actionCommand
          String containing the action command name.
protected  boolean active
          This variable enables/disables the ComponentHandler.
static int ApplicationId
          This constant defines that this is the client application ID.
static int CancelReturn
          Constant which defines the return value of the queryMessageBox function.
protected  AmberOutputStream dataEncoder
           
static long DefaultTimeout
          The default timeout waiting for a packet.
protected  boolean enabledState
          This flag maintains the enabled state of the control.
protected  java.io.ByteArrayOutputStream encoderBytes
          The data encoding data stream that is used by all components to send information.
protected  int id
          The ID of the corresponding remote component at the browser.
static int InvalidId
          This constant defines that the component ID is invalid.
static int MaximumId
          This constant defines the maximum possible component ID allowed.
static int NoReturn
           
static int OkCancelType
           
static int OkReturn
           
static int OkType
          Constant used to define the type of MessageBox displayed by the queryMessageBox function.
static int OkYesReturn
           
protected  ApplicationInterface parentPage
          The Page Handler which will send the packets for this handler.
protected  java.util.Vector responsePackets
          Vector containing response packets.
protected  long timeoutValue
          The amount of time the component handler will wait for a response to a command.
static int UnchangeableInvalidId
          This constant defines that the component ID is invalid.
protected  boolean visibleState
          This flag maintains the visible state of the control.
static int YesNoCancelType
           
static int YesNoType
           
static int 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
ComponentHandler()
          Default constructor.
ComponentHandler(ApplicationInterface pageHandler)
          The initialising constructor.
ComponentHandler(int id, ApplicationInterface pageHandler)
          The initialising constructor.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener l)
           
 void addComponentListener(java.awt.event.ComponentListener l)
           
protected  void addEventMask(int newEvents)
          Adds in the specified events to the current event mask.
 void addFocusListener(java.awt.event.FocusListener l)
           
 void addItemListener(java.awt.event.ItemListener l)
           
 void addKeyListener(java.awt.event.KeyListener l)
           
 void addMouseListener(java.awt.event.MouseListener l)
           
 void addMouseMotionListener(java.awt.event.MouseMotionListener l)
           
 void addNotify()
          This function is analogous to the addNotify function in component.
 void addReceivedPacket(Packet packet)
          Called by the ReceiveThread when a packet has been received.
 void addTextListener(java.awt.event.TextListener l)
           
 void addWindowListener(ComponentWindowListener l)
          Add a window listener to this component.
 int booleanToInt(boolean value)
           
protected  PacketData createDataInput(Packet packet)
          This function creates a data input stream from the data in the packet.
 void directPacket(Packet packet)
          Called by the thread which needs to have the packet directed to a specific location.
 void displayMessageBox(java.lang.String title, java.lang.String caption)
          This function causes the corresponding component to display a modeless MessageBox type control.
protected  void fireWindowActivated(ComponentWindowEvent e)
           
protected  void fireWindowClosed(ComponentWindowEvent e)
           
protected  void fireWindowClosing(ComponentWindowEvent e)
           
protected  void fireWindowDeactivated(ComponentWindowEvent e)
           
protected  void fireWindowDeiconified(ComponentWindowEvent e)
           
protected  void fireWindowEvent(PacketData packet)
          This function creates a ComponentWindowEvent for the corresponding packet and sends it to all listeners.
protected  void fireWindowIconified(ComponentWindowEvent e)
           
protected  void fireWindowOpened(ComponentWindowEvent e)
           
 void forceComponentGetUrl(java.lang.String urlString)
          This function tells the component to get the specified URL.
 void forceComponentGetUrl(java.lang.String urlString, java.lang.String location)
          This function tells the component to get the specified URL.
 void forwardEventPacket(Packet packet)
          Called by the EventThread when a packet has been received.
protected  java.awt.event.ActionEvent generateActionEvent(int eventType, PacketData packet)
          This function generates an action event from the input packet.
protected  java.awt.event.FocusEvent generateFocusEvent(int eventType, PacketData packet)
          This function generates a focus event from the input packet.
protected  java.awt.event.ItemEvent generateItemEvent(int eventType, PacketData packet)
          This function generates an item event from the input packet.
protected  java.awt.event.KeyEvent generateKeyEvent(int eventType, PacketData packet)
          This function generates a key event from the input packet.
protected  java.awt.event.MouseEvent generateMouseEvent(int eventType, PacketData packet)
          This function generates a mouse event from the input packet.
 java.lang.String getActionCommand()
          Returns the action command string contained in the action event should an action occur.
 java.awt.Rectangle getBounds()
          Returns the bounds of the component at the remote client.
 java.lang.String getComponentStructure()
          This function dumps component information about this page.
 java.lang.String getDefaultParameters()
          This function returns the default parameters string required by the component.
 int getEventMask()
          This function returns the current value of the event mask defining which events generated by the remote component will transmit events.
 FontCharacteristics getFontCharacteristics()
          This function returns the font characteristics for the current font in the client object.
 FontCharacteristics getFontCharacteristics(java.lang.String text)
          This function returns the font characteristics for the current font in the client object.
 FontCharacteristics getFontCharacteristics(java.lang.String text, java.awt.Font font)
          This function returns the font characteristics for the specified font in the client object.
 FontCharacteristics getFontCharacteristics(java.lang.String text, java.lang.String fontName, int fontStyle, int fontSize)
          This function returns the font characteristics for the specified font in the client object.
 int getFontStyle()
          This returns the current style for the component.
 int getId()
          This function gets the component ID.
 java.awt.Point getLocation()
          Returns the location of the component at the remote client.
 Log getLog()
          Returns the Log object.
 ApplicationInterface getModalObject()
          Returns the current object which is receiving all input packets.
abstract  java.lang.String getPanelType()
          This function returns the panel component to use with this class.
 ApplicationInterface getParentApplication()
          This function gets the current page handler.
 ContainerHandler getParentContainer()
          Get the parent container for this component.
 CoreInterface getParentServer()
          Returns the original server which started this ApplicationInterface.
protected  PendingResponsePacket getResponsePacket(byte id, boolean filled)
          This function is used to locate a packet which is expected.
 java.lang.Object[] getSelectedObjects()
           
 java.awt.Dimension getSize()
          Returns the size of the component at the remote client.
 long getTimeout()
          This function gets how long the component waits for a response to a command.
 int getValidId()
          This function allocates a valid unused ID from a pool of ID's held within the Application.
 int getX()
           
 int getY()
           
protected  void handleMessages()
          This function is called inside setComponentModal ( true ) It handles the input messaging which is performed normally by the ApplicationInterface if this function is not called NO INPUT PACKETS WILL BE PROCESSED.
protected  void handlePacket(PacketData packet)
          This function handles base component commands.
protected  void internalForwardPacket(Packet packet)
          Called by the internal processing loop to work out who to send the packet to.
protected  java.awt.Rectangle internalGetBounds()
           
 boolean intToBoolean(int value)
           
 boolean isActive()
          This function returns the enabled/disabled state of the ComponentHandler.
 boolean isApplicationActive()
          Returns the state of the parent application.
protected  boolean isComponentModal()
          This function returns if the component is modal.
 boolean isConnected()
          This function returns the state of the application handler.
 boolean isEnabled()
          Returns if the component is enabled.
 boolean isMyId(int inId)
          Checks that the unique ID passed to this page is handled by this ComponentHandler.
 boolean isVisible()
          Returns if the component is visible.
protected  void processActionEvent(java.awt.event.ActionEvent e)
          Processes action events occurring on this component by dispatching them to any registered listeners.
protected  void processComponentEvent(java.awt.event.ComponentEvent e)
          Processes component events occurring on this component by dispatching them to any registered listeners.
 void processCurrentPacket(Packet packet)
          This function receives the packet given to it by the ApplicationInterface.
protected  void processEvent(java.awt.AWTEvent e)
          Processes events on this button.
protected  void processFocusEvent(java.awt.event.FocusEvent e)
          Processes focus events occurring on this component by dispatching them to any registered listeners.
protected  void processItemEvent(java.awt.event.ItemEvent e)
          Processes item events occurring on this component by dispatching them to any registered listeners.
protected  void processKeyEvent(java.awt.event.KeyEvent e)
          Processes key events occurring on this component by dispatching them to any registered listeners.
protected  void processMouseEvent(java.awt.event.MouseEvent e)
          Processes mouse events occurring on this component by dispatching them to any registered listeners.
protected  void processMouseMotionEvent(java.awt.event.MouseEvent e)
          Processes mouse motion events occurring on this component by dispatching them to any registered listeners.
protected  void processNormalResponse(PacketData packet)
           
protected  void processTextEvent(java.awt.event.TextEvent e)
          Processes text events occurring on this component by dispatching them to any registered listeners.
 int queryMessageBox(java.lang.String title, java.lang.String caption, int type)
          This function causes the corresponding component to display a modal MessageBox type control.
 void removeActionListener(java.awt.event.ActionListener l)
           
 void removeComponentListener(java.awt.event.ComponentListener l)
           
protected  void removeEventMask(int newEvents)
          Removes the specified events from the current event mask.
 void removeFocusListener(java.awt.event.FocusListener l)
           
 void removeItemListener(java.awt.event.ItemListener l)
           
 void removeKeyListener(java.awt.event.KeyListener l)
           
 void removeMouseListener(java.awt.event.MouseListener l)
           
 void removeMouseMotionListener(java.awt.event.MouseMotionListener l)
           
 void removeNotify()
          This function is the opposite of addNotify.
 void removeTextListener(java.awt.event.TextListener l)
           
 void removeWindowListener(ComponentWindowListener l)
          Remove a specified window listener.
 void requestFocus()
          This function requests that this component get the input focus.
 void resetState()
          This function resets the component to a default state.
 void restart(java.net.Socket newConnection)
          This function restarts the functioning of the ApplicationInterface.
 void sendPacket(Packet packet)
          This function is sends the created packet to the ApplicationInterface for transmission.
protected  PacketData sendPacketAndBlock(Packet packet, byte responseId)
          This function is similar to sendPacket in that it sends the created packet to the PageHandle for transmission.
protected  void sendPendingPackets()
          This function is rarely called by outside classes.
 void setActionCommand(java.lang.String name)
          Sets the action command string contained in the action event should an action occur.
 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.
 void setBackground(java.awt.Color background)
          This function tells the component to set the specified drawing colours.
protected  void setComponentModal(boolean state)
          This function allows the component to take over the handling of receiving events and received packets.
 void setConnectedState(boolean state)
          This function will force the application to go active/inactive.
 void setCursor(java.awt.Cursor cursor)
          This function sets the cursor to the specified type.
 void setEnabled(boolean state)
          This function tells the component to become enabled/disabled.
 void setEventMask(int eventMask)
          This function alters the events which the component listens to.
 void setFont(java.awt.Font font)
          This function tells the component to set the font.
 void setFont(java.lang.String name, int style, int size)
          This function tells the component to set the font.
 void setFontStyle(int style)
          This function tells the component to set the font style only.
 void setForeground(java.awt.Color foreground)
          This function tells the component to set the specified drawing colours.
 void setForegroundBackground(java.awt.Color foreground, java.awt.Color background)
          This function tells the component to set the specified drawing colours.
 void setId(int newId)
          This function sets the component ID.
 void setLog(Log logFile)
          Sets the Log for this ApplicationInterface.
 void setModalObject(ApplicationInterface object)
          Sets the current object which is to receive all input packets.
 void setParentApplication(ApplicationInterface page)
          This function sets the current page handler.
 void setParentContainer(ContainerHandler handler)
          Set the parent container for this component.
 void setParentServer(CoreInterface server)
          Sets the original server which started this ApplicationInterface.
 void setTimeout(long milliseconds)
          This function specifies how long to wait for the component to respond to a command.
 void setVisible(boolean state)
          This function tells the component to become visible/invisible.
 void setX(int newX)
           
 void setY(int newY)
           
 void shutDown()
          This function attempts to shut down the page handler gracefully.
 void shutDownClient()
          This function will force the client to shut down.
 void shutDownClient(java.lang.String message)
          This function will force the client to shut down.
 void start(java.net.Socket newConnection)
          This function initiates the functioning of the ApplicationInterface.
 
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, getName, 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, paramString, 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, setName, setSize, setSize, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DefaultTimeout

public static final long DefaultTimeout
The default timeout waiting for a packet. Currently 20s.

UnchangeableInvalidId

public static final int UnchangeableInvalidId
This constant defines that the component ID is invalid. Unlike InvalidId this ID will never change and will always remain invalid. This value is one less than the server ID (the ID the server is allocated (0xFFFF = -1).

InvalidId

public static final int InvalidId
This constant defines that the component ID is invalid. The component ID may be changed dynamically when the component is first used to a valid ID.

ApplicationId

public static final int ApplicationId
This constant defines that this is the client application ID. In general this ID is not used however it is available to allow some direct control of the application itself.

MaximumId

public static final int MaximumId
This constant defines the maximum possible component ID allowed.

OkType

public static final int OkType
Constant used to define the type of MessageBox displayed by the queryMessageBox function.

OkCancelType

public static final int OkCancelType

YesNoType

public static final int YesNoType

YesNoCancelType

public static final int YesNoCancelType

CancelReturn

public static final int CancelReturn
Constant which defines the return value of the queryMessageBox function.

OkYesReturn

public static final int OkYesReturn

OkReturn

public static final int OkReturn

YesReturn

public static final int YesReturn

NoReturn

public static final int NoReturn

id

protected int id
The ID of the corresponding remote component at the browser.

responsePackets

protected java.util.Vector responsePackets
Vector containing response packets.

parentPage

protected ApplicationInterface parentPage
The Page Handler which will send the packets for this handler.

timeoutValue

protected long timeoutValue
The amount of time the component handler will wait for a response to a command.

encoderBytes

protected java.io.ByteArrayOutputStream encoderBytes
The data encoding data stream that is used by all components to send information. THIS MUST BE USED FOR ENCODING INFORMATION TO THE CLIENT!! Owing to the way Java works it is not meaningful to have a corresponding input object statically created.

dataEncoder

protected AmberOutputStream dataEncoder

actionCommand

protected java.lang.String actionCommand
String containing the action command name.

active

protected boolean active
This variable enables/disables the ComponentHandler. While it will continue to respond to incoming events all outgoing messages will be invisibly suppressed.

visibleState

protected boolean visibleState
This flag maintains the visible state of the control.

enabledState

protected boolean enabledState
This flag maintains the enabled state of the control.
Constructor Detail

ComponentHandler

public ComponentHandler()
Default constructor.

ComponentHandler

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

ComponentHandler

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

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.
Parameters:
packet - Packet containing the packet to handle.
Throws:
ComponentHandlerException - containing the error information.

getResponsePacket

protected PendingResponsePacket getResponsePacket(byte id,
                                                  boolean filled)
This function is used to locate a packet which is expected.
Parameters:
id - byte which is the expected return packet command.
filled - boolean when true only objects which have packets are searched otherwise objects without packets.
Returns:
PendingResponsePacket which matches this command and has no packet already associated.

handlePacket

protected void handlePacket(PacketData packet)
                     throws ComponentHandlerException
This function handles base component commands. This code may generate events if there is a requirement for the ApplicationInterface to handle the packet.
Parameters:
packet - Packet containing the packet to handle.
Throws:
ComponentHandlerException - containing the error information.

processNormalResponse

protected void processNormalResponse(PacketData packet)
                              throws ComponentHandlerException

generateActionEvent

protected java.awt.event.ActionEvent generateActionEvent(int eventType,
                                                         PacketData packet)
                                                  throws ComponentHandlerException
This function generates an action event from the input packet.
Parameters:
eventType - int containing the event type. While this information is contained in the packet it is more convenient to preprocess it in this form.
packet - PacketData containing the packet to handle.
Returns:
KeyEvent created from the packet.
Throws:
ComponentHandlerException - containing any error.

generateItemEvent

protected java.awt.event.ItemEvent generateItemEvent(int eventType,
                                                     PacketData packet)
                                              throws ComponentHandlerException
This function generates an item event from the input packet.
Parameters:
eventType - int containing the event type. While this information is contained in the packet it is more convenient to preprocess it in this form.
packet - PacketData containing the packet to handle.
Returns:
KeyEvent created from the packet.
Throws:
ComponentHandlerException - containing any error.

generateKeyEvent

protected java.awt.event.KeyEvent generateKeyEvent(int eventType,
                                                   PacketData packet)
                                            throws ComponentHandlerException
This function generates a key event from the input packet.
Parameters:
eventType - int containing the event type. While this information is contained in the packet it is more convenient to preprocess it in this form.
packet - PacketData containing the packet to handle.
Returns:
KeyEvent created from the packet.
Throws:
ComponentHandlerException - containing any error.

generateMouseEvent

protected java.awt.event.MouseEvent generateMouseEvent(int eventType,
                                                       PacketData packet)
                                                throws ComponentHandlerException
This function generates a mouse event from the input packet.
Parameters:
eventType - int containing the event type. While this information is contained in the packet it is more convenient to preprocess it in this form.
packet - PacketData containing the packet to handle.
Returns:
MouseEvent created from the packet.
Throws:
ComponentHandlerException - containing any error.

generateFocusEvent

protected java.awt.event.FocusEvent generateFocusEvent(int eventType,
                                                       PacketData packet)
                                                throws ComponentHandlerException
This function generates a focus event from the input packet.
Parameters:
eventType - int containing the event type. While this information is contained in the packet it is more convenient to preprocess it in this form.
packet - PacketData containing the packet to handle.
Returns:
FocusEvent created from the packet.
Throws:
ComponentHandlerException - containing any error.

getParentApplication

public ApplicationInterface getParentApplication()
This function gets the current page handler.
Returns:
ApplicationInterface handle to the handler for the page.

isApplicationActive

public boolean isApplicationActive()
Returns the state of the parent application. This determines if the application is connected to the remote client.
Returns:
boolean true if the application is connected.

isConnected

public boolean isConnected()
This function returns the state of the application handler. If the application is connected and can message to the server then this function returns true.
Specified by:
isConnected in interface ApplicationInterface
Returns:
boolean connection state.

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.

getParentContainer

public ContainerHandler getParentContainer()
Get the parent container for this component.
Returns:
ContainerHandler which is the parent of this Component.

setParentContainer

public void setParentContainer(ContainerHandler handler)
Set the parent container for this component.
Parameters:
ContainerHandler - which is the parent of this Component.

setParentApplication

public void setParentApplication(ApplicationInterface page)
This function sets the current page handler.
Parameters:
page - ApplicationInterface handle to the handler for the page.

sendPacket

public void sendPacket(Packet packet)
                throws ApplicationHandlerException
This function is sends the created packet to the ApplicationInterface for transmission. The packet will only be sent if the component is active.
Specified by:
sendPacket in interface ApplicationInterface
Parameters:
packet - Packet containing the packet to send.
Throws:
ApplicationHandlerException - containing transmission errors.

sendPacketAndBlock

protected PacketData sendPacketAndBlock(Packet packet,
                                        byte responseId)
                                 throws ComponentHandlerException
This function is similar to sendPacket in that it sends the created packet to the PageHandle for transmission. This function also sets a mutex block to ensure that the component waits before receiving the response.
Parameters:
packet - Packet containing the packet to send.
responseId - byte response value expected.
Returns:
PacketData which is the responding packet. A failed transmission/response returns null.
Throws:
java.server.exception.ComponentHandlerException - containing transmission errors.

setId

public void setId(int newId)
This function sets the component ID.
Parameters:
newId - int containing the id to set the component handler to.

getId

public int getId()
This function gets the component ID.
Returns:
int containing the id of the component handler.

isMyId

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

addNotify

public void addNotify()
This function is analogous to the addNotify function in component. it is called when the component is activated. Thus any code placed in this function can be guaranteed that there exists a valid connection to the remote client.
Overrides:
addNotify in class java.awt.Component
See Also:
removeNotify(), Component.addNotify()

removeNotify

public void removeNotify()
This function is the opposite of addNotify. When called the component will be inactive and unable to message to the remote client. All commands sent to the remote client will be queued for transmission when the client is activated again. function
Overrides:
removeNotify in class java.awt.Component
See Also:
addNotify(), Component.removeNotify()

createDataInput

protected PacketData createDataInput(Packet packet)
This function creates a data input stream from the data in the packet.
Parameters:
packet - Packet containing the data to decode.
Returns:
PacketData object for the corresponding data.

forceComponentGetUrl

public void forceComponentGetUrl(java.lang.String urlString)
                          throws ComponentHandlerException
This function tells the component to get the specified URL.
Parameters:
urlString - String containing the URL to force the component to get.
Throws:
ComponentHandlerException - containing the error information.

forceComponentGetUrl

public void forceComponentGetUrl(java.lang.String urlString,
                                 java.lang.String location)
                          throws ComponentHandlerException
This function tells the component to get the specified URL.
Parameters:
urlString - String containing the URL to force the component to get.
location - String containing the location for the browser to put the URL.
Throws:
ComponentHandlerException - containing the error information.

setForeground

public void setForeground(java.awt.Color foreground)
This function tells the component to set the specified drawing colours.
Overrides:
setForeground in class java.awt.Component
Parameters:
foreground - Color containing the specified foreground colour.

setBackground

public void setBackground(java.awt.Color background)
This function tells the component to set the specified drawing colours.
Overrides:
setBackground in class java.awt.Component
Parameters:
background - Color containing the specified background colour.

setForegroundBackground

public void setForegroundBackground(java.awt.Color foreground,
                                    java.awt.Color background)
                             throws ComponentHandlerException
This function tells the component to set the specified drawing colours.
Parameters:
foreground - Color containing the specified foreground colour.
background - Color containing the specified background colour.
Throws:
ComponentHandlerException - containing the error information.

setFont

public void setFont(java.awt.Font font)
This function tells the component to set the font.
Overrides:
setFont in class java.awt.Component
Parameters:
font - Font containing the specified font.
Throws:
java.lang.RuntimeException - containing the error information.

getFontStyle

public int getFontStyle()
This returns the current style for the component.
Returns:
the font style currently in use.

setFontStyle

public void setFontStyle(int style)
                  throws ComponentHandlerException
This function tells the component to set the font style only. Any other font characteristics are left unchanged.
Parameters:
style - int containing the style of the font.
Throws:
java.lang.RuntimeException - containing the error information.
See Also:
Font.PLAIN, Font.BOLD, Font.ITALIC

setFont

public void setFont(java.lang.String name,
                    int style,
                    int size)
             throws ComponentHandlerException
This function tells the component to set the font.
Parameters:
name - String containing the name of the font.
style - int containing the style of the font.
size - int containing the size of the font.
Throws:
java.lang.RuntimeException - containing the error information.

getFontCharacteristics

public FontCharacteristics getFontCharacteristics()
This function returns the font characteristics for the current font in the client object.
Returns:
the FontCharacteristics object containing gleaned information on the font metrics. Returns null if the font is not accessible.

getFontCharacteristics

public FontCharacteristics getFontCharacteristics(java.lang.String text)
This function returns the font characteristics for the current font in the client object.
Parameters:
text - This text is a String on which the length is to be computed. This allows the string width of a text string to be determined.
Returns:
the FontCharacteristics object containing gleaned information on the font metrics. Returns null if the font is not accessible.

getFontCharacteristics

public FontCharacteristics getFontCharacteristics(java.lang.String text,
                                                  java.awt.Font font)
This function returns the font characteristics for the specified font in the client object.
Parameters:
text - This text is a String on which the length is to be computed. This allows the string width of a text string to be determined.
font - The font to use when determining the characteristics.
Returns:
the FontCharacteristics object containing gleaned information on the font metrics. Returns null if the font is not accessible.

getFontCharacteristics

public FontCharacteristics getFontCharacteristics(java.lang.String text,
                                                  java.lang.String fontName,
                                                  int fontStyle,
                                                  int fontSize)
This function returns the font characteristics for the specified font in the client object.
Parameters:
text - This text is a String on which the length is to be computed. This allows the string width of a text string to be determined.
fontName - The String name of the font to use when determining the characteristics.
fontStyle - The int style of the font to use when determining the characteristics.
fontSize - The int size of the font to use when determining the characteristics.
Returns:
the FontCharacteristics object containing gleaned information on the font metrics. Returns null if the font is not accessible.

isEnabled

public boolean isEnabled()
Returns if the component is enabled.
Overrides:
isEnabled in class java.awt.Component
Returns:
boolean enabled state of the component.

setEnabled

public void setEnabled(boolean state)
This function tells the component to become enabled/disabled.
Overrides:
setEnabled in class java.awt.Component
Parameters:
state - boolean containing the enabled state for the control.
Throws:
java.lang.RuntimeException - containing the error information. This exception is used to avoid conflict with the base Component function.

isVisible

public boolean isVisible()
Returns if the component is visible.
Overrides:
isVisible in class java.awt.Component
Returns:
boolean visible state of the component.

setVisible

public void setVisible(boolean state)
This function tells the component to become visible/invisible.
Overrides:
setVisible in class java.awt.Component
Parameters:
enabled - boolean containing the visible state for the control.
Throws:
java.lang.RuntimeException - containing the error information. This exception is used to avoid conflict with the base Component function.

requestFocus

public void requestFocus()
This function requests that this component get the input focus. The component must be visible on the screen for this request to be granted
Overrides:
requestFocus in class java.awt.Component
Throws:
java.lang.RuntimeException - containing the error information. This exception is used to avoid conflict with the base Component function.

getTimeout

public long getTimeout()
This function gets how long the component waits for a response to a command.
Returns:
long containing the number of milliseconds to wait.

setTimeout

public void setTimeout(long milliseconds)
This function specifies how long to wait for the component to respond to a command.
Parameters:
milliseconds - long containing the number of milliseconds to wait.

displayMessageBox

public void displayMessageBox(java.lang.String title,
                              java.lang.String caption)
This function causes the corresponding component to display a modeless MessageBox type control.
Parameters:
title - String containing the title of the MessageBox.
caption - String containing the caption of the MessageBox.

queryMessageBox

public int queryMessageBox(java.lang.String title,
                           java.lang.String caption,
                           int type)
This function causes the corresponding component to display a modal MessageBox type control.
Parameters:
title - String containing the title of the MessageBox.
caption - String containing the caption of the MessageBox.
type - int defining the type of message box to display. These values correspond to the constants in this class.
Returns:
int with the return value. As for the type these constants are defined in ComponentHandler.
See Also:
RMessageBox

setCursor

public void setCursor(java.awt.Cursor cursor)
This function sets the cursor to the specified type.
Overrides:
setCursor in class java.awt.Component
Parameters:
cursor - Cursor containing the type of cursor to set.

setConnectedState

public void setConnectedState(boolean state)
This function will force the application to go active/inactive. An inactive application is assumed to be not connected to the remote client. Should a reconnection occur the application is re-activated.
Specified by:
setConnectedState in interface ApplicationInterface

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. When inactive all outgoing messages will be invisibly stored pending activation.
Parameters:
state - boolean state which when true enables the component. This is the default.
Throws:
ComponentHandlerException - with any errors.

sendPendingPackets

protected void sendPendingPackets()
                           throws ComponentHandlerException
This function is rarely called by outside classes. It attempts to resend pending packets. It does nothing if the component is not active.
Throws:
ComponentHandlerException - with any errors.

isActive

public boolean isActive()
This function returns the enabled/disabled state of the ComponentHandler. While it will continue to respond to incoming events all outgoing messages will be invisibly suppressed.
Returns:
boolean state which when true enables the component.

getEventMask

public int getEventMask()
This function returns the current value of the event mask defining which events generated by the remote component will transmit events.
Returns:
int containing the mask defining which events to respond to.
See Also:
RConstants

setEventMask

public void setEventMask(int eventMask)
                  throws ComponentHandlerException
This function alters the events which the component listens to. This is used to suppress events generated by the remote component to reduce network traffic.
Parameters:
eventMask - int containing the mask defining which events to respond to. The value of this parameter is defined by the EventMask constants in the RConstants object.
Throws:
ComponentHandlerException - containing the error information.
See Also:
RConstants

setActionCommand

public void setActionCommand(java.lang.String name)
Sets the action command string contained in the action event should an action occur.
Parameters:
name - String name to use.

getActionCommand

public java.lang.String getActionCommand()
Returns the action command string contained in the action event should an action occur.
Returns:
String name to use.

intToBoolean

public boolean intToBoolean(int value)

booleanToInt

public int booleanToInt(boolean value)

addEventMask

protected void addEventMask(int newEvents)
Adds in the specified events to the current event mask. Will update the remote component as necessary. If removing the standard events, the Mask values in RConstant must be used rather than the ID values.
Parameters:
newEvents - New Event mask bits to add to the current event mask.
See Also:
RConstants

removeEventMask

protected void removeEventMask(int newEvents)
Removes the specified events from the current event mask. Will update the remote component as necessary. If removing the standard events, the Mask values in RConstant must be used rather than the ID values.
Parameters:
newEvents - New Event mask bits to remove from the current event mask.
See Also:
RConstants

addFocusListener

public void addFocusListener(java.awt.event.FocusListener l)
Overrides:
addFocusListener in class java.awt.Component

removeFocusListener

public void removeFocusListener(java.awt.event.FocusListener l)
Overrides:
removeFocusListener in class java.awt.Component

addKeyListener

public void addKeyListener(java.awt.event.KeyListener l)
Overrides:
addKeyListener in class java.awt.Component

removeKeyListener

public void removeKeyListener(java.awt.event.KeyListener l)
Overrides:
removeKeyListener in class java.awt.Component

addMouseListener

public void addMouseListener(java.awt.event.MouseListener l)
Overrides:
addMouseListener in class java.awt.Component

removeMouseListener

public void removeMouseListener(java.awt.event.MouseListener l)
Overrides:
removeMouseListener in class java.awt.Component

addMouseMotionListener

public void addMouseMotionListener(java.awt.event.MouseMotionListener l)
Overrides:
addMouseMotionListener in class java.awt.Component

removeMouseMotionListener

public void removeMouseMotionListener(java.awt.event.MouseMotionListener l)
Overrides:
removeMouseMotionListener in class java.awt.Component

removeActionListener

public void removeActionListener(java.awt.event.ActionListener l)

addActionListener

public void addActionListener(java.awt.event.ActionListener l)

removeTextListener

public void removeTextListener(java.awt.event.TextListener l)

addTextListener

public void addTextListener(java.awt.event.TextListener l)

removeItemListener

public void removeItemListener(java.awt.event.ItemListener l)
Specified by:
removeItemListener in interface java.awt.ItemSelectable

addItemListener

public void addItemListener(java.awt.event.ItemListener l)
Specified by:
addItemListener in interface java.awt.ItemSelectable

removeComponentListener

public void removeComponentListener(java.awt.event.ComponentListener l)
Overrides:
removeComponentListener in class java.awt.Component

addComponentListener

public void addComponentListener(java.awt.event.ComponentListener l)
Overrides:
addComponentListener in class java.awt.Component

getSelectedObjects

public java.lang.Object[] getSelectedObjects()
Specified by:
getSelectedObjects in interface java.awt.ItemSelectable

setX

public void setX(int newX)

getX

public int getX()
Overrides:
getX in class java.awt.Component

setY

public void setY(int newY)

getY

public int getY()
Overrides:
getY in class java.awt.Component

fireWindowEvent

protected void fireWindowEvent(PacketData packet)
                        throws ComponentHandlerException
This function creates a ComponentWindowEvent for the corresponding packet and sends it to all listeners.
Parameters:
packet - PacketData containing the window event.
Throws:
ComponentHandlerException - with any errors.

removeWindowListener

public void removeWindowListener(ComponentWindowListener l)
Remove a specified window listener. It is important to note that this is a non-standard event. This is owing to the problem that the source for the WindowEvent must be a Window which this ComponentHandler is not.
Parameters:
l - ComponentWindowListener to remove.

addWindowListener

public void addWindowListener(ComponentWindowListener l)
Add a window listener to this component. It is important to note that this is a non-standard event. This is owing to the problem that the source for the WindowEvent must be a Window which this ComponentHandler is not.
Parameters:
l - ComponentWindowListener to respond to these windows events.

getComponentStructure

public java.lang.String getComponentStructure()
This function dumps component information about this page. This is very important in marrying the remote objects to their respective ComponentHandlers. This is written to the internal Log object.

setComponentModal

protected void setComponentModal(boolean state)
This function allows the component to take over the handling of receiving events and received packets. When this is the case the application is shut out of the received message loop. Once the component has been set modal the function then enters the handleMessages function which waits for messages and directs them to the correct recipient. The function is protected to stop the call being abused by external code.
Parameters:
state - boolean state of the modal system. The component becomes modal when the state is true.

setModalObject

public void setModalObject(ApplicationInterface object)
Sets the current object which is to receive all input packets.
Specified by:
setModalObject in interface ApplicationInterface
Parameters:
object - ApplicationInterface which is the modal object.

getModalObject

public ApplicationInterface getModalObject()
Returns the current object which is receiving all input packets.
Specified by:
getModalObject in interface ApplicationInterface
Returns:
ApplicationInterface which is the modal object.

isComponentModal

protected boolean isComponentModal()
This function returns if the component is modal.
Returns:
boolean state of the modal system. The component is modal when the state is true.

handleMessages

protected void handleMessages()
This function is called inside setComponentModal ( true ) It handles the input messaging which is performed normally by the ApplicationInterface if this function is not called NO INPUT PACKETS WILL BE PROCESSED.

forwardEventPacket

public void forwardEventPacket(Packet packet)
                        throws ApplicationException
Called by the EventThread when a packet has been received. This function examines the packet and passes it to the appropriate handler.
Specified by:
forwardEventPacket in interface ApplicationInterface
Parameters:
packet - Packet to forward to the specified component.

directPacket

public void directPacket(Packet packet)
                  throws ApplicationException
Called by the thread which needs to have the packet directed to a specific location.
Specified by:
directPacket in interface ApplicationInterface
Parameters:
packet - Packet to forward to the specified component.

internalForwardPacket

protected void internalForwardPacket(Packet packet)
                              throws ApplicationException
Called by the internal processing loop to work out who to send the packet to.
Parameters:
packet - Packet to forward to the specified component.

start

public void start(java.net.Socket newConnection)
           throws java.lang.IllegalThreadStateException
This function initiates the functioning of the ApplicationInterface. This function is required as the page handler will not immediately start operation until it is handed the socket by the main handling system.
Specified by:
start in interface ApplicationInterface
Parameters:
newConnection - The Socket which is connected to the page in operation. If null uses the connection already set.
Throws:
java.lang.IllegalThreadStateException - containing any problems.

restart

public void restart(java.net.Socket newConnection)
             throws java.lang.IllegalThreadStateException
This function restarts the functioning of the ApplicationInterface. This function is called when an application has lost the connection which is then reestablished.
Specified by:
restart in interface ApplicationInterface
Parameters:
newConnection - The Socket which is connected to the page in operation. If null uses the connection already set.
Throws:
java.lang.IllegalThreadStateException - containing any problems.

addReceivedPacket

public void addReceivedPacket(Packet packet)
Called by the ReceiveThread when a packet has been received. This function adds the packet to the Vector of pending packets. The run method of the ApplicationInterface class will dispatch the packet in the run method.
Specified by:
addReceivedPacket in interface ApplicationInterface
Parameters:
packet - Packet to forward to the specified component.

getParentServer

public CoreInterface getParentServer()
Returns the original server which started this ApplicationInterface.
Specified by:
getParentServer in interface ApplicationInterface
Returns:
CoreInterface which is the parent server.

setParentServer

public void setParentServer(CoreInterface server)
Sets the original server which started this ApplicationInterface.
Specified by:
setParentServer in interface ApplicationInterface
Parameters:
server - CoreInterface which is the parent server.

getLog

public Log getLog()
Returns the Log object.
Specified by:
getLog in interface ApplicationInterface
Returns:
Log which is the Logging object.

setLog

public void setLog(Log logFile)
Sets the Log for this ApplicationInterface.
Specified by:
setLog in interface ApplicationInterface
Parameters:
logFile - Log object for logging.

getValidId

public int getValidId()
               throws ApplicationHandlerException
This function allocates a valid unused ID from a pool of ID's held within the Application. This function is typically called from a component when it is created. The ID's start unaltered at a base of 200.
Specified by:
getValidId in interface ApplicationInterface
Returns:
int containing the valid ID.
Throws:
ApplicationHandlerException - should the component ID overflow the maximum allowed.

shutDown

public void shutDown()
This function attempts to shut down the page handler gracefully. If the program is already shut down it does nothing.
Specified by:
shutDown in interface ApplicationInterface

shutDownClient

public void shutDownClient()
                    throws ApplicationHandlerException
This function will force the client to shut down. The function waits for the client to respond that it has shut down before returning.
Specified by:
shutDownClient in interface ApplicationInterface
Throws:
ApplicationHandlerException - should there be a messaging error.

shutDownClient

public void shutDownClient(java.lang.String message)
                    throws ApplicationHandlerException
This function will force the client to shut down. The function waits for the client to respond that it has shut down before returning.
Specified by:
shutDownClient in interface ApplicationInterface
Parameters:
message - String optional message which the client will display in a message box when the client is closed. A null value sends no message and silently shuts down the client.
Throws:
ApplicationHandlerException - should there be a messaging error.

getBounds

public java.awt.Rectangle getBounds()
Returns the bounds of the component at the remote client. Should there be no connection the function returns the server idea of what the component bounds are. This bounds are relative to the parent.
Overrides:
getBounds in class java.awt.Component
Returns:
A rectangle indicating this component's bounds.

getLocation

public java.awt.Point getLocation()
Returns the location of the component at the remote client. Should there be no connection the function returns the server idea of what the component location is. This location is relative to the parent.
Overrides:
getLocation in class java.awt.Component
Returns:
A Point containing the top-left corner of the component's location.

getSize

public java.awt.Dimension getSize()
Returns the size of the component at the remote client. Should there be no connection the function returns the server idea of what the component size is. This location is relative to the parent.
Overrides:
getSize in class java.awt.Component
Returns:
A Dimension containing the size of the component.

internalGetBounds

protected java.awt.Rectangle internalGetBounds()

fireWindowOpened

protected void fireWindowOpened(ComponentWindowEvent e)

fireWindowClosing

protected void fireWindowClosing(ComponentWindowEvent e)

fireWindowClosed

protected void fireWindowClosed(ComponentWindowEvent e)

fireWindowIconified

protected void fireWindowIconified(ComponentWindowEvent e)

fireWindowDeiconified

protected void fireWindowDeiconified(ComponentWindowEvent e)

fireWindowActivated

protected void fireWindowActivated(ComponentWindowEvent e)

fireWindowDeactivated

protected void fireWindowDeactivated(ComponentWindowEvent e)

processEvent

protected void processEvent(java.awt.AWTEvent e)
Processes events on this button. If an event is an instance of ActionEvent, TextEvent, ItemEvent, this method invokes the corresponding process function. Otherwise, it invokes the super processEvent in component to handle any other events.
Overrides:
processEvent in class java.awt.Component
Parameters:
e - AWTEvent to process.

processComponentEvent

protected void processComponentEvent(java.awt.event.ComponentEvent e)
Processes component events occurring on this component by dispatching them to any registered listeners.
Overrides:
processComponentEvent in class java.awt.Component
Parameters:
e - ComponentEvent to process.

processActionEvent

protected void processActionEvent(java.awt.event.ActionEvent e)
Processes action events occurring on this component by dispatching them to any registered listeners.
Parameters:
e - ActionEvent to process.

processTextEvent

protected void processTextEvent(java.awt.event.TextEvent e)
Processes text events occurring on this component by dispatching them to any registered listeners.
Parameters:
e - TextEvent to process.

processItemEvent

protected void processItemEvent(java.awt.event.ItemEvent e)
Processes item events occurring on this component by dispatching them to any registered listeners.
Parameters:
e - ItemEvent to process.

processFocusEvent

protected void processFocusEvent(java.awt.event.FocusEvent e)
Processes focus events occurring on this component by dispatching them to any registered listeners.
Overrides:
processFocusEvent in class java.awt.Component
Parameters:
e - FocusEvent to process.

processKeyEvent

protected void processKeyEvent(java.awt.event.KeyEvent e)
Processes key events occurring on this component by dispatching them to any registered listeners.
Overrides:
processKeyEvent in class java.awt.Component
Parameters:
e - KeyEvent to process.

processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent e)
Processes mouse events occurring on this component by dispatching them to any registered listeners.
Overrides:
processMouseEvent in class java.awt.Component
Parameters:
e - MouseEvent to process.

processMouseMotionEvent

protected void processMouseMotionEvent(java.awt.event.MouseEvent e)
Processes mouse motion events occurring on this component by dispatching them to any registered listeners.
Overrides:
processMouseMotionEvent in class java.awt.Component
Parameters:
e - MouseEvent to process.

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.
Returns:
String containing the parameters value to use.

getPanelType

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


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.