org.peace_tools.core
Class ServerConnectionTester

java.lang.Object
  extended by org.peace_tools.core.ServerConnectionTester
All Implemented Interfaces:
java.awt.event.ActionListener, java.lang.Runnable, java.util.EventListener

public class ServerConnectionTester
extends java.lang.Object
implements java.awt.event.ActionListener, java.lang.Runnable


Field Summary
private  java.lang.Thread connThread
          The background thread that is attempting to connect to the remote server.
private  javax.swing.JDialog dialog
          The dialog that is being used to display some message and progress information to the user.
private static java.lang.String ERROR_MSG
          An error message that is formatted (to fill in server name) and displayed to the user informing him about the problem that occurred when attempting to connect to the server.
private static java.lang.String INFO_MSG
          A simple message that is formatted (to fill in server name) and displayed to the user informing him of the progress being made.
private  javax.swing.JProgressBar progressBar
          The roving (indeterminate mode) progress bar to illustrate that some work is being done (and to ensure that the GUI is not hanging).
private static java.lang.String PURPOSE_MSG
          A simple message that is formatted (to fill in server name) and set as the purpose for the session/connection.
private  Server server
          The server to which this class is attempting to establish is a connection to verify that the GUI can actually connect to the server.
 
Constructor Summary
ServerConnectionTester(MainFrame mainFrame, Server server)
          The constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Handle user clicking the "Interrupt" button.
private  javax.swing.JDialog createDialog(javax.swing.JFrame parent)
          Helper method to create the dialog to be displayed.
 void run()
          The background thread method that performs the connection test.
 void start()
          Starts the background thread to test connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

server

private final Server server
The server to which this class is attempting to establish is a connection to verify that the GUI can actually connect to the server.


progressBar

private javax.swing.JProgressBar progressBar
The roving (indeterminate mode) progress bar to illustrate that some work is being done (and to ensure that the GUI is not hanging).


connThread

private java.lang.Thread connThread
The background thread that is attempting to connect to the remote server. This thread is created in the constructor.


dialog

private javax.swing.JDialog dialog
The dialog that is being used to display some message and progress information to the user. This dialog is created in the constructor but is displayed and disposed in the background thread.


INFO_MSG

private static final java.lang.String INFO_MSG
A simple message that is formatted (to fill in server name) and displayed to the user informing him of the progress being made.

See Also:
Constant Field Values

ERROR_MSG

private static final java.lang.String ERROR_MSG
An error message that is formatted (to fill in server name) and displayed to the user informing him about the problem that occurred when attempting to connect to the server.

See Also:
Constant Field Values

PURPOSE_MSG

private static final java.lang.String PURPOSE_MSG
A simple message that is formatted (to fill in server name) and set as the purpose for the session/connection.

See Also:
Constant Field Values
Constructor Detail

ServerConnectionTester

public ServerConnectionTester(MainFrame mainFrame,
                              Server server)
The constructor. The constructor coordinates the task of creating the informative dialog. The actual task of creating the tester thread is performed by the start() method.

Parameters:
mainFrame - The main frame that logically owns this class.
server - The server with which a connection is to be established.
Method Detail

start

public void start()
Starts the background thread to test connection. This method must be used to start up the background connection thread that attempts to establish a connection with the remote server.


run

public void run()
The background thread method that performs the connection test. This method is invoked from a separate background thread. This method is responsible for performing the core operations pertaining to testing the connection to the server.

Specified by:
run in interface java.lang.Runnable

createDialog

private javax.swing.JDialog createDialog(javax.swing.JFrame parent)
Helper method to create the dialog to be displayed. This method is a helper method that was introduced to streamline the constructor. It creates a JDialog containing a message, a progress bar, and an "Interrupt" button. This dialog is displayed just before the connection with the server is attempted.

Parameters:
parent - The frame that logically owns this dialog.
Returns:
The dialog to be displayed to the user.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Handle user clicking the "Interrupt" button. This action listener handles the case when the user clicks on the interrupt button. This method essentially interrupts the background thread that is attempting to connect to the remote server.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - The action event associated with the button click. This event is not really used.