CICS® Transaction Gateway Programming Reference V3.1

com.ibm.ctg.epi
Class EPIBasicScreenHandler

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--com.ibm.ctg.epi.EPIBasicScreenHandler

public class EPIBasicScreenHandler
extends java.awt.Panel
implements TerminalEventListener, java.awt.event.ActionListener, java.awt.event.FocusListener, java.awt.event.TextListener

This class is an all-purpose screen handler that deals with any screen by displaying the fields as Textfields and Labels in a Panel.

See Also:
Serialized Form

Inner Class Summary
(package private)  class EPIBasicScreenHandler.GeneralScreenHandler
          This is the ScreenHandler inner class.
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
Field Summary
protected  java.awt.GridBagConstraints c
          GridBagConstraints used when inserting new components into the display panel, which has a GridBagLayout.
protected  Field cursored
          the Field which currently contains the screen cursor.
protected  AID exitKey
          the AID key that will be used to try to exit a running transaction.
protected  ScreenHandler handler
          Reference to ScreenHandler inner class.
protected  int minHeight
          minimum height of this panel.
protected  int minWidth
          minimum width of this panel.
protected  int screenWidth
          the width of the screen in columns
 
Fields inherited from class java.awt.Container
component, containerListener, layoutMgr, ncomponents
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, componentListener, componentListenerK, componentOrientation, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Constructor Summary
EPIBasicScreenHandler()
          Constructs the EPIBasicScreenHandler.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
          Handle an actionPerfomed event.
protected  void addField(Field f)
          Creates a component for a new field and add it to the user interface.
 void addScreenEventListener(ScreenEventListener l)
          The specified ScreenEventListener will be called when this ScreenHandler gains control of the screen and again when it loses control.
protected  void clearDisplay()
          Clears the display
protected  java.awt.Component createComponent(Field f)
          Returns a new component to be mapped to the field, or null if none is required.
 void exceptionOccurred(TerminalEvent evt)
          Handles a terminal exception event.
 void exitScreen()
          Exit the screen.
 void focusGained(java.awt.event.FocusEvent foc)
          Handles the focus gained event by setting the screen cursor to the relevant field.
 void focusLost(java.awt.event.FocusEvent foc)
          Handles the focus lost event by doing nothing.
 AID getAID()
          Returns the AID that will be sent to CICS.
 Field getCursorPosition()
          Returns the Field which contains the screen cursor.
 AID getExitKey()
          Returns the AID that will be used to exit any transaction that is running when the terminal is disconnected.
protected  Field getField(java.awt.Component comp)
          Returns the field associated with a component
 java.awt.Dimension getMaximumSize()
          Returns the maximum dimensions of this panel, ensuring that the width and height are at least as large as the minimum width and height settings.
 int getMinimumHeight()
          Returns the minimum height setting
 java.awt.Dimension getMinimumSize()
          Returns the minimum dimensions of this panel, ensuring that the width and height are at least as large as the minimum width and height settings.
 int getMinimumWidth()
          Returns the minimum width setting
 java.awt.Dimension getPreferredSize()
          Returns the preferred dimensions of this panel, ensuring that the width and height are at least as large as the minimum width and height settings.
 void handleScreen(TerminalEvent evt)
          Handle a newly arrived screen.
 boolean isHandling()
          Returns true if the ScreenHandler is handling.
 void removeScreenEventListener(ScreenEventListener l)
          Remove this ScreenEventListener from the internal list.
 void send()
          Send the screen to CICS.
 void setAID(AID aid)
          Set the AID to send back to CICS.
 void setCursorPosition(Field f)
          Sets the screen cursor to the beginning of this Field.
 void setExitKey(AID aid)
          Sets the AID that will be used to exit any transaction that is running when the terminal is disconnected.
protected  void setField(java.awt.Component comp, Field f)
          Sets the field associated with a component
 void setMinimumHeight(int h)
          Sets the minimum height setting
 void setMinimumWidth(int w)
          Sets the minimum width setting
 void terminalConnected(TerminalEvent evt)
          Handles a terminal connect event.
 void terminalDisconnected(TerminalEvent evt)
          Handles a terminal disconnect event.
 void textValueChanged(java.awt.event.TextEvent evt)
          Handles the text value changed event by setting the text in the relevant field.
protected  void updateField(java.awt.Component comp, Field f)
          Update the field on the basis of it's associated component, eg: for a TextField, the field's text is set from the TextField's contents.
 
Methods inherited from class java.awt.Panel
, addNotify, constructComponentName
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyOrientation, countComponents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getInsets, getLayout, getMouseEventTarget, getWindow, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPrint, list, list, locate, minimumSize, nextFocus, paint, paintComponents, paramString, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusOwner, setFont, setLayout, transferFocus, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

screenWidth

protected int screenWidth
the width of the screen in columns

c

protected java.awt.GridBagConstraints c
GridBagConstraints used when inserting new components into the display panel, which has a GridBagLayout.

handler

protected ScreenHandler handler
Reference to ScreenHandler inner class. EPIBasicScreenHandler extends Panel. To enable it to act like a ScreenHandler it contains a small inner class that extends ScreenHandler.

minWidth

protected int minWidth
minimum width of this panel.

minHeight

protected int minHeight
minimum height of this panel.

exitKey

protected AID exitKey
the AID key that will be used to try to exit a running transaction.

cursored

protected Field cursored
the Field which currently contains the screen cursor.
Constructor Detail

EPIBasicScreenHandler

public EPIBasicScreenHandler()
Constructs the EPIBasicScreenHandler. Initialises the GridBagConstraints and creates a screen handler to handle terminal events.
Method Detail

getMinimumWidth

public int getMinimumWidth()
Returns the minimum width setting
Returns:
the minimum width

getMinimumHeight

public int getMinimumHeight()
Returns the minimum height setting
Returns:
the minimum height

setMinimumWidth

public void setMinimumWidth(int w)
Sets the minimum width setting
Parameters:
w - the minimum width

setMinimumHeight

public void setMinimumHeight(int h)
Sets the minimum height setting
Parameters:
h - the minimum height

getMinimumSize

public java.awt.Dimension getMinimumSize()
Returns the minimum dimensions of this panel, ensuring that the width and height are at least as large as the minimum width and height settings.
Returns:
the minimum size of this panel
Overrides:
getMinimumSize in class java.awt.Container

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred dimensions of this panel, ensuring that the width and height are at least as large as the minimum width and height settings.
Returns:
the preferred size of this panel
Overrides:
getPreferredSize in class java.awt.Container

getMaximumSize

public java.awt.Dimension getMaximumSize()
Returns the maximum dimensions of this panel, ensuring that the width and height are at least as large as the minimum width and height settings.
Returns:
the maximum size of this panel
Overrides:
getMaximumSize in class java.awt.Container

setExitKey

public void setExitKey(AID aid)
Sets the AID that will be used to exit any transaction that is running when the terminal is disconnected.
Parameters:
aid - the AID

getExitKey

public AID getExitKey()
Returns the AID that will be used to exit any transaction that is running when the terminal is disconnected.
Returns:
the exit AID

addScreenEventListener

public void addScreenEventListener(ScreenEventListener l)
The specified ScreenEventListener will be called when this ScreenHandler gains control of the screen and again when it loses control. The ScreenEventListener object is added to a list of ScreenEventListeners managed by this ScreenHandler, it can be removed with removeScreenEventListener. Note: the JavaBeans specification does not require listeners to run in any particular order.
Parameters:
l - the ScreenEventListener
See Also:
removeScreenEventListener(com.ibm.ctg.epi.ScreenEventListener)

removeScreenEventListener

public void removeScreenEventListener(ScreenEventListener l)
Remove this ScreenEventListener from the internal list.
Parameters:
l - the ScreenEventListener
See Also:
addScreenEventListener(com.ibm.ctg.epi.ScreenEventListener)

terminalConnected

public void terminalConnected(TerminalEvent evt)
Handles a terminal connect event.
Specified by:
terminalConnected in interface TerminalEventListener
Parameters:
evt - the terminal event

terminalDisconnected

public void terminalDisconnected(TerminalEvent evt)
Handles a terminal disconnect event.
Specified by:
terminalDisconnected in interface TerminalEventListener
Parameters:
evt - the terminal event

exceptionOccurred

public void exceptionOccurred(TerminalEvent evt)
Handles a terminal exception event.
Specified by:
exceptionOccurred in interface TerminalEventListener
Parameters:
evt - the terminal event

handleScreen

public void handleScreen(TerminalEvent evt)
Handle a newly arrived screen. Unless the TerminalEvent has already been handled this screen handler translates the fields of the screen into GUI components and maps input back to the relevant fields.
Specified by:
handleScreen in interface TerminalEventListener
Parameters:
evt - the terminal event

isHandling

public boolean isHandling()
Returns true if the ScreenHandler is handling.
Returns:
true if handling, false otherwise

setAID

public void setAID(AID aid)
Set the AID to send back to CICS.
Parameters:
aid - the AID

getAID

public AID getAID()
Returns the AID that will be sent to CICS.
Returns:
the aid

send

public void send()
Send the screen to CICS.

getCursorPosition

public Field getCursorPosition()
Returns the Field which contains the screen cursor.
Returns:
the field where the cursor is

setCursorPosition

public void setCursorPosition(Field f)
Sets the screen cursor to the beginning of this Field.
Parameters:
f - the field where the cursor should be moved to

getField

protected final Field getField(java.awt.Component comp)
Returns the field associated with a component
Parameters:
comp - the component
Returns:
the field, or null if there is none

setField

protected final void setField(java.awt.Component comp,
                              Field f)
Sets the field associated with a component
Parameters:
comp - the component
f - the field

createComponent

protected java.awt.Component createComponent(Field f)
Returns a new component to be mapped to the field, or null if none is required. This method decides what sort of component, if any, is created for a field. It can be overridden if you want to display fields in a different way.
Parameters:
f - the field
Returns:
the new component, or null

updateField

protected void updateField(java.awt.Component comp,
                           Field f)
Update the field on the basis of it's associated component, eg: for a TextField, the field's text is set from the TextField's contents. You might want to override this method if you were using components other than TextFields and Labels.
Parameters:
comp - the component

focusGained

public void focusGained(java.awt.event.FocusEvent foc)
Handles the focus gained event by setting the screen cursor to the relevant field.
Specified by:
focusGained in interface java.awt.event.FocusListener
Parameters:
foc - the focus event

focusLost

public void focusLost(java.awt.event.FocusEvent foc)
Handles the focus lost event by doing nothing.
Specified by:
focusLost in interface java.awt.event.FocusListener
Parameters:
foc - the focus event

textValueChanged

public void textValueChanged(java.awt.event.TextEvent evt)
Handles the text value changed event by setting the text in the relevant field.
Specified by:
textValueChanged in interface java.awt.event.TextListener
Parameters:
evt - the text event

clearDisplay

protected void clearDisplay()
Clears the display

addField

protected void addField(Field f)
Creates a component for a new field and add it to the user interface. createComponent is called to create a component to map to the field. This method then places the new component into the panel.
Parameters:
f - the field

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
Handle an actionPerfomed event. If the event comes from a component that is mapped to a field, then the associated Field is updated (by calling updateField, the AID set to enter, and the screen sent to CICS. Otherwise the action command received is assumed to be an AID, which is set if valid, then the screen is sent to CICS.
Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
evt - the action event

exitScreen

public void exitScreen()
Exit the screen. This method is called when the exit screen terminal request is received. It sets the AID to the exit AID and sends the current screen to CICS.

© Copyright IBM Corp. 1994, 1999