/**
 * 
 * You can add code anywhere in this file - except in the areas that are
 * written by the editor. You should not change the relative ordering of
 * the code.
 * 
 * You can remove this comment block or replace it with another.
 * 
 * @see        
 * @version    
 * @author    
 */

import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import java.io.*;
import java.net.*;
import java.util.*;
import com.supercede.forms.*;

public class StatusForm extends SuperCedeDialog implements Serializable
{
    private Thread rptThread = null;
    public void SetRptThread (Thread rptTh){
        rptThread = rptTh;
    }
    public boolean RptInterrupted () {
        if (rptThread == null)
            return true;
        else
            return false;
    }
    void statusFormPreInit()
    {
        // You can add code anywhere in this method.
        // This method is called PRIOR to form initialization.
        // NOTE: The form has NOT been initialized yet. Do not modify the form itself in this method.
    }

    void statusFormPostInit()
    {
        // You can add code anywhere in this method.
        // This method is called AFTER form initialization.
        setLocation (150,150);
    }

    public boolean statusFormWindowClosing(WindowEvent arg0)
    {
        // Put event handler code here. Return false for normal processing, true to override

        return false;
    }

    public boolean statusFormWindowClosed(WindowEvent arg0)
    {
        // Put event handler code here. Return false for normal processing, true to override

        return false;
    }
    
    // Allow outsiders to change the status line.
    public void SetStatusLine (String stat) {
        labelStatus.setText (stat);
    }

    public void buttonCancelActionPerformed(ActionEvent arg0)
    {
        // Stop the Report thread (database)
        if (rptThread != null) {
            rptThread.stop ();
            rptThread = null;
            // Exit the status screen
            SuperCedeWindowClosing (null);
        } else {
            setVisible (false);
            System.exit (2);
        }
    }

    // SuperCede Begin 2.0 Form Members
    // Do not remove the Begin and End markers.
    // The editor will rewrite the contents of this section each time the form is saved.

    // References to Beans within the Form.

    Button buttonHASPstatus;
    Label labelStatus;
    Button buttonCancel;

    private void SuperCedeConstructor() throws IOException, ClassNotFoundException, ClassCastException, SuperCedeInvalidStateException
    {
        // Construct the actual connectors to give to our base class.

        Vector connectors = new Vector(3);
        connectors.addElement(new StatusFormWindowClosingConnector0(this));
        connectors.addElement(new StatusFormWindowClosedConnector1(this));
        connectors.addElement(new StatusFormEventConnector2(this));

        super.initializeThis(connectors);

        // Make references to Beans within the Form.

        int i = 0;

        buttonHASPstatus = (Button) getComponent(i++);
        labelStatus = (Label) getComponent(i++);
        buttonCancel = (Button) getComponent(i++);
    }

    public StatusForm(Frame parent) throws IOException, ClassNotFoundException, ClassCastException, SuperCedeInvalidStateException
    {
        super(parent);

        statusFormPreInit();
        SuperCedeConstructor();
        statusFormPostInit();
    }

    public void SuperCedeWindowClosing(WindowEvent arg0)
    {
        if (statusFormWindowClosing(arg0) == false)
        {
            dispose();
        }
    }

    public void SuperCedeWindowClosed(WindowEvent arg0)
    {
        statusFormWindowClosed(arg0);
    }

    // SuperCede End 2.0 Form Members
}

// SuperCede Begin 2.0 Form Connectors
// Do not remove the Begin and End markers.
// The editor will rewrite the contents of this section each time the form is saved.
// Connections for StatusForm:
//    StatusFormWindowClosingConnector0: from StatusForm.windowClosing to StatusForm.SuperCedeWindowClosing
//    StatusFormWindowClosedConnector1: from StatusForm.windowClosed to StatusForm.SuperCedeWindowClosed
//    StatusFormEventConnector2: from buttonCancel.actionPerformed to StatusForm.buttonCancelActionPerformed

final class StatusFormWindowClosingConnector0 extends WindowAdapter implements SuperCedeConnector, Serializable
{
    private StatusForm target;

    public StatusFormWindowClosingConnector0(StatusForm target)
    {
        this.target = target;
    }

    public void windowClosing(WindowEvent arg0)
    {
        target.SuperCedeWindowClosing(arg0);
    }
}

final class StatusFormWindowClosedConnector1 extends WindowAdapter implements SuperCedeConnector, Serializable
{
    private StatusForm target;

    public StatusFormWindowClosedConnector1(StatusForm target)
    {
        this.target = target;
    }

    public void windowClosed(WindowEvent arg0)
    {
        target.SuperCedeWindowClosed(arg0);
    }
}

final class StatusFormEventConnector2 implements SuperCedeConnector, Serializable, java.awt.event.ActionListener
{
    private StatusForm target;

    public StatusFormEventConnector2(StatusForm target)
    {
        this.target = target;
    }

    public void actionPerformed(ActionEvent arg0)
    {
        target.buttonCancelActionPerformed(arg0);
    }
}

// The following line must be the last line in the file.
// SuperCede End 2.0 Form Connectors
