com.bluemarsh.jswat
Class Main

java.lang.Object
  |
  +--com.bluemarsh.jswat.Main

public class Main
extends java.lang.Object

Class Main is the bootstrap for JSwat when launched from the command line or via a shortcut. It creates a Session and an instance of a UIAdapter, which is responsible for providing the user interface. This class has several methods for managing the open Sessions, such as creating new ones and terminating old ones.

Author:
Nathan Fiedler

Field Summary
protected static java.lang.Class adapterClass
          The class of the UIAdapter to be used when creating new Sessions.
protected static java.util.Vector openSessions
          List of the open Sessions.
protected static JSwat swat
          Reference to single instance of JSwat.
 
Constructor Summary
Main()
           
 
Method Summary
static void endSession(Session session)
          Terminate the given Session.
static boolean init(java.io.InputStream appis)
          Performs basic program initialization.
static void main(java.lang.String[] args)
          Main method for JSwat program.
protected static void migrateOldFiles(java.io.File dir)
          Migrate the old JSwat files from the user's home directory to the given directory.
static Session newSession()
          Create a new Session and user interface.
static void setUIAdapter(java.lang.Class adapter)
          Sets the concrete implementatioin class of UIAdapter to be used when creating new Sessions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

adapterClass

protected static java.lang.Class adapterClass
The class of the UIAdapter to be used when creating new Sessions.

openSessions

protected static java.util.Vector openSessions
List of the open Sessions.

swat

protected static JSwat swat
Reference to single instance of JSwat.
Constructor Detail

Main

public Main()
Method Detail

endSession

public static void endSession(Session session)
Terminate the given Session.
Parameters:
session - Session to be ended.

init

public static boolean init(java.io.InputStream appis)
Performs basic program initialization. Creates an instance of the JSwat class, loads the application preferences, and migrates the old settings files to the new location.
Parameters:
appis - JSwat preferences file as a stream. This method reads the application preferences from this stream and merges them with the preferences in the user's home directory.
Returns:
true if initialization successful, false otherwise (which generally means a critical failure occurred).

main

public static void main(java.lang.String[] args)
Main method for JSwat program. Gets things started. Note that this returns to the JVM but the app still runs. It is an event- driven application and thus will not exit until we call System.exit().
Parameters:
args - list of command-line arguments.

migrateOldFiles

protected static void migrateOldFiles(java.io.File dir)
Migrate the old JSwat files from the user's home directory to the given directory.
Parameters:
dir - new jswat files directory (created if necessary).

newSession

public static Session newSession()
Create a new Session and user interface.
Returns:
new instance of Session, or null if error.

setUIAdapter

public static void setUIAdapter(java.lang.Class adapter)
Sets the concrete implementatioin class of UIAdapter to be used when creating new Sessions. The UI adapter must implement a public constructor that takes a single argument of type Session.
Parameters:
adpater - class of UIAdapter.