/*
 * NotesMan.java
 *
 * Created on January 20, 2005, 1:41 PM
 */
package usda.weru.mcrew;

/**
 * This class allows the user to write notes at the file level for all the .MAN files.
 * So when data is being viewed in the main MCREW table, notes by earlier users can be
 * retrived and viewed in this screen
 * @author manmohan
 */
public class NotesMan extends usda.weru.mcrew.gui.NotesMan_n {

    private static final long serialVersionUID = 1L;

    /**
     * Title for the frame that holds the notes being displayed.
     */
    public String title;
    /**
     * This is the class that holds and manages the data for the application. The notes for
     * the .MAN(management) file in the application reside or will be accessed from here.
     */
    public ManageData data;
    /**
     * Minimum width of the management notes screen.
     */
    public final int WIDTH = 500;
    /**
     * Minimum height of the management notes screen.
     */
    public final int HEIGHT = 300;
    /**
     * This tells us if the Notes frame is presently instantiated
     */
    public boolean notesPresent = false;
    /**
     * This tells us which mcrew object this NotesMan object refers to. 
     */
    public TablePanel mcrewRef;

    /**
     * Creates a new instance of NotesMan
     */
    public NotesMan() {

    }

    /**
     * Single argument constructor that sets the title for the frame in which the
     * GUI sits.
     * @param t The frame title string.
     */
    public NotesMan(String t) {

        this();
        setTitle(t);
    }

    /**
     * Two argument constructor that sets the title for the frame in which the GUI sits and
     * the reference to the object that holds the data to be displayed in the GUI.
     * @param t The frame title string.
     * @param d The reference to the object that holds management file related notes to be
     * displayed.
     */
    public NotesMan(String t, ManageData d) {
        super();
        setTitle(t);
        data = d;
        JTA_Notes.setText(d.getWepsManFileNotes());
    }

    /**
     * Three argument constructor that creates a new instance of NotesMan and sets 
     * the title for the frame in which the GUI sits,
     * the reference to the object that holds the data to be displayed in the text area of
     * the GUI and a reference to its parent MCREW component
     * @param t The frame title string.
     * @param d The reference to the object that holds management file related notes to be
     * displayed.
     * @param parent The reference to MCREW object that holds these together.
     */
    public NotesMan(String t, ManageData d, TablePanel parent) {
        super(parent.getCoordinator(), true); //This is a modal dialog
        setTitle(t);
        data = d;
        mcrewRef = parent;
        JTA_Notes.setText(d.getWepsManFileNotes());
    }

    @Override
    public void JBSave_actionPerformed(java.awt.event.ActionEvent evt) {
        data.setWepsManFileNotes(JTA_Notes.getText());
        notesPresent = false;
        mcrewRef.setDataChanged(true);
        this.dispose();
    }

    @Override
    public void JBCancel_actionPerformed(java.awt.event.ActionEvent evt) {
        notesPresent = false;
        this.dispose();
    }

}
