// file: TextTree.java
//

// import java libraries
//
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class TreeBox extends JPanel {

    // the tree that will keep up with all the descriptions related to
    // the actins performed on the bug
    //
    public static TextTree  treePanel = null;

    public static TreeUpdate treeUpdate = null;

    public static final int NEW_BUG = 1;
    public static final int LOAD_BUG = 2;

    // container for entering new text to be added to the tree
    //
    public JEditorPane description_entry = null;
    private JScrollPane descriptionView = null;
    // ---------------------------------------------------
    //
    // declare class constructors
    //
    // ---------------------------------------------------

    // method: TextTree
    //
    // arguments: none
    // returns  : none
    //
    // default class constructor
    //

    public TreeBox(String userName, Font newFont, int mode, Bug bug) {

	this.setLayout(new CardLayout());

	// create a tree to mount in our panel
	//
	treePanel  = new TextTree(userName, newFont, bug);

	// create the update panel to go in the card layout
	//
	treeUpdate = new TreeUpdate(userName, newFont, bug);

	
	// intitalize the Editor Pane to plain text and to have nothing 
	// currently displayed in it and to a specific size
	//
	description_entry = new JEditorPane("text/plain", "");
	//description_entry.setPreferredSize(new Dimension(620,150));
	description_entry.setFont(newFont);

	// create a border around the editor pane
        //
        //description_entry.setBorder(BorderFactory.createEtchedBorder());

	descriptionView = new JScrollPane(description_entry);
	descriptionView.setPreferredSize(new Dimension(580,300));
	descriptionView.setFont(newFont);

	// create a border around the scroll pane
        //
        descriptionView.setBorder(BorderFactory.createEtchedBorder());


	// add the panels to the card layout
	//
	this.add(treePanel, "Tree");
	this.add(treeUpdate, "Update");
	this.add(descriptionView, "New");

	if (mode == NEW_BUG) {
	    CardLayout cl = (CardLayout)(getLayout());
	    cl.show(this, "New");  
	}
	else {
	    CardLayout cl = (CardLayout)(getLayout());
	    cl.show(this, "Tree");  
	}
    }

}












