package edu.calpoly.cpe205.fetter; import javax.swing.*; import java.util.*; import java.io.*; import java.lang.reflect.*; import java.lang.*; import java.awt.*; import javax.swing.event.*; import java.awt.event.*; /** * This is the entry class which constructs and displays the program. */ // Author: Phillip Hansen // Version History: // Nov 18, 2000 - added psuedo code and description public class ETA { /** * Initializes the main components and establishes the links between them. *
* @param isInspector true if main components that are being initialed
* are for an ObjectInspector, false otherwise
* Pre-conditions: none
* Post-conditions: links between the view and model have been established
*/
protected ETA(boolean isInspector) {
// CALL instantiateMVC
instantiateMVC();
// CALL setView of model with view
model.setView(view);
// CALL setModel of view with model
view.setModel(model);
if (!isInspector) {
// CALL getOutOutputStream of view
// CREATE PrintStream from OutputStream
// SET out to the PrintStream
out = new PrintStream(view.getOutOutputStream()); //Create output stream
//for Output tab in program
// CALL getErrOutputStream of view
// CREATE PrintStream from OutputStream
// SET err to the PrintStream
err = new PrintStream(view.getErrOutputStream()); //Create output stream
//for Error log output in program
// CALL getLogOutputStream of view
// CREATE PrintStream from OutputStream
// SET log to the PrintStream
log = new PrintStream(view.getLogOutputStream()); //Create output stream
//for log output in program
view.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent evt)
{
System.exit(0);
}
});
}
view.layoutGUI();
}
/**
* Makes the GUI visible
*
* Pre-conditions: none
* Post-conditions: program exits without problems
* @param args command line arguments, which are ignored
*/
public static void main(String[] args)
{
// CALL setVisible on view with true
theETA.view.setVisible(true);
}
/**
* Constructs the view and the model
*
* Pre-conditions: none
* Post-conditions: none
*/
protected void instantiateMVC()
{
//Construct view
view = new ETAMainView(); //Contruct view as ETAMainView instance
//Construct model
model = new ETAMainModel(); //Contruct model as ETAMainModel instance
}
/**
* Reference to ETA
*/
protected static ETA theETA = new ETA(false); //Reference to ETA
/**
* Reference to ETAViewAbstract
*/
protected ETAViewAbstract view; //Reference to ETAViewAbstract
/**
* Reference to ETAMainModel
*/
protected ETAMainModel model; //Reference to ETAMainModel
/**
* Stream for displaying information on the output panel
*/
public static PrintStream out; //Stream for displaying information on the output panel
/**
* Stream for displaying errors on the output panel
*/
public static PrintStream err; //Stream for displaying errors on the output panel
/**
*Will be used to keep a log of user actions so that they could be reproduced at a later time
*/
public static PrintStream log; //Log of user actions
/** @link dependency */
/*#ETAMainView lnkETAMainView;*/
}