ca.uhn.hl7v2.app
Class TestPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by ca.uhn.hl7v2.app.TestPanel
All Implemented Interfaces:
ConnectionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class TestPanel
extends javax.swing.JPanel
implements ConnectionListener

A user interface for testing communications with an HL7 server. The UI contains a window with 4 main panels. One can enter message text into the first panel, press a "parse" button so that the message is displayed in a tree in the second panel, press "send" to send the message to a remote server and display the response in a tree in the third panel, and press "encode" to write the inbound message as text in the fourth panel. To use, run from the command line with no arguments, like this:

java -classpath . ca.uhn.hl7v2.app.TestPanel

Exceptions generated during parsing or server communication are logged in the working directory and displayed in a dialog box.

Author:
Bryan Tripp
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
TestPanel()
          Creates a new instance of TestPanel
 
Method Summary
 void connect(java.lang.String host, int port)
          Sets up a connection to a remote server that uses the minimal lower layer protocol, and this TestPanel's GenericParser.
 void connect(java.lang.String host, int inboundPort, int outboundPort)
          Sets up a connection to a remote server that uses the minimal lower layer protocol, and this TestPanel's GenericParser.
 void connectionDiscarded(Connection connection)
          Notifies the listener that a new connection is closed and is being discarded.
 void connectionReceived(Connection connection)
          Notification that a new Connection has arrived at an HL7Service.
 void encodeInbound()
          Encodes the message that is currently displayed in the tree into a traditionally encoded message string and displays in the inbound message text box.
 void encodeOutbound()
          Encodes the message that is currently displayed in the outbound tree into a traditionally encoded message string and displays in a new window.
protected  Parser getParser()
          Returns this TestPanel's underlying GenericParser.
 MessageTypeRouter getRouter()
          Returns the MessageTypeRouter associated with this TestPanel.
static void main(java.lang.String[] args)
           
static void openTextWindow(java.lang.String title, java.lang.String text)
          Opens a new window for displaying text (intended for displaying encoded messages.
 void parseOutbound()
          Attempts to parse the contents of the outbound message text box into a message object and display in the outbound message tree.
 void sendAndRecieve()
          Sends the message that is currently displayed in the outbound tree to the remote system that is currently connected.
 void showException(java.lang.Exception e)
          Displays an exception in a standard way.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestPanel

public TestPanel()
          throws HL7Exception
Creates a new instance of TestPanel

Throws:
HL7Exception
Method Detail

getParser

protected Parser getParser()
Returns this TestPanel's underlying GenericParser. This method is needed by the HL7Service that the panel uses, so that it can share the parser and use whatever encoding it is using.


showException

public void showException(java.lang.Exception e)
Displays an exception in a standard way. All exceptions for TestPanel are routed here. Currently this prints to std err, and displays an error dialog, but it could be changed.


parseOutbound

public void parseOutbound()
                   throws HL7Exception,
                          EncodingNotSupportedException
Attempts to parse the contents of the outbound message text box into a message object and display in the outbound message tree.

Throws:
HL7Exception
EncodingNotSupportedException

connect

public void connect(java.lang.String host,
                    int port)
             throws java.io.IOException,
                    LLPException
Sets up a connection to a remote server that uses the minimal lower layer protocol, and this TestPanel's GenericParser.

Throws:
java.io.IOException
LLPException

connect

public void connect(java.lang.String host,
                    int inboundPort,
                    int outboundPort)
             throws java.io.IOException,
                    LLPException
Sets up a connection to a remote server that uses the minimal lower layer protocol, and this TestPanel's GenericParser.

Throws:
java.io.IOException
LLPException

connectionReceived

public void connectionReceived(Connection connection)
Notification that a new Connection has arrived at an HL7Service.

Specified by:
connectionReceived in interface ConnectionListener

connectionDiscarded

public void connectionDiscarded(Connection connection)
Description copied from interface: ConnectionListener
Notifies the listener that a new connection is closed and is being discarded.

Specified by:
connectionDiscarded in interface ConnectionListener

getRouter

public MessageTypeRouter getRouter()
Returns the MessageTypeRouter associated with this TestPanel. Every Connection that a TestPanel uses routes unsolicited messages through this MessageTypeRouter. Applications can be registered with the router using registerApplication().


sendAndRecieve

public void sendAndRecieve()
                    throws HL7Exception,
                           LLPException,
                           java.io.IOException
Sends the message that is currently displayed in the outbound tree to the remote system that is currently connected.

Throws:
HL7Exception
LLPException
java.io.IOException

encodeInbound

public void encodeInbound()
                   throws HL7Exception
Encodes the message that is currently displayed in the tree into a traditionally encoded message string and displays in the inbound message text box.

Throws:
HL7Exception

encodeOutbound

public void encodeOutbound()
                    throws HL7Exception
Encodes the message that is currently displayed in the outbound tree into a traditionally encoded message string and displays in a new window.

Throws:
HL7Exception

openTextWindow

public static void openTextWindow(java.lang.String title,
                                  java.lang.String text)
Opens a new window for displaying text (intended for displaying encoded messages.


main

public static void main(java.lang.String[] args)


Copyright © 2001-2011 University Health Network. All Rights Reserved.