package JAcademy;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.*;
import java.beans.PropertyVetoException;
import java.io.*;
import javax.swing.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.InternalFrameListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import javax.swing.JMenuItem;
import javax.swing.JSplitPane;
import javax.swing.JScrollPane;
import javax.swing.JPanel;
import javax.swing.JDesktopPane;
import javax.swing.BoxLayout;
import javax.swing.JToolBar;
import JAcademy.Popupmenu.TreePopupHandler;
import JAcademy.Proc.*;
import JAcademy.Index.*;
import JAcademy.ProjectPackage.*;
import javax.swing.JTabbedPane;
import javax.swing.JTextPane;
import JAcademy.Debug.WatchDialog;
import JAcademy.Debug.Console.JConsole;
import JAcademy.Editor.FileInternalFrame;
import javax.swing.JMenu;
public class MainFrame extends JFrame implements ActionListener,InternalFrameListener,CaretListener,MouseListener{
private static final long serialVersionUID = 1L;
public boolean debugging=false;
private JPanel jContentPane = null;
private JMenu FileMenu = null;
private JMenu ProjectMenu = null;
private JMenu HelpMenu = null;
private JMenuItem itemMenuOpen = null;
private JMenuItem itemMenuSave = null;
private JMenuItem itemMenuExit = null;
private JMenuItem itemMenuNew = null;
private JMenuItem itemMenuSaveAs = null;
private JMenuItem itemMenuClose = null;
private JMenuItem itemMenuNewProject = null;
private JMenuItem itemMenuOpenProject = null;
private JMenuItem itemMenuSaveProject = null;
private JMenuItem itemMenuCloseProject = null;
private JMenuItem itemMenuIndex = null;
private JMenuBar MBar = null;
private JToolBar ToolBar = null;
private JTree FileTree = null;
private DefaultTreeModel FileTreeModel=null;
private JButton ButtonNewFile = null;
private JButton ButtonOpenFile = null;
private JButton ButtonJavaCompile = null;
private JButton ButtonJavaRun = null;
private JButton ButtonSaveFile = null;
private IndexFrame indexFrame = null;
private JFileChooser openFile;
private JFileChooser saveFile;
private JFileChooser openProject;
private String CurrentPath="";
private JButton ButtonExit = null;
private String dirPath="";
private String filename="";
public Project CurProj = null; // @jve:decl-index=0:
public DefaultMutableTreeNode root;
private JMenuItem itemMenuSearch = null;
private String CurrentWord ="";
private JSplitPane jSplitPane = null;
private JSplitPane jSplitHPane = null;
private JScrollPane jScrollLPane = null;
private JScrollPane jScrollPaneB = null;
private JDesktopPane jDesktopPane = null;
Vector<FileInternalFrame> vfileframe; // @jve:decl-index=0:
private JPanel ToolBarPanel = null;
private JToolBar DebugToolBar = null;
private JButton DebugButton = null;
private JButton StepButton = null;
private JButton StepInButton = null;
private JButton StopButton = null;
private ProjectDialog projDialog = null;
private JMenuItem ItemMenuSetProject = null;
public RunProcess DebugProc; // @jve:decl-index=0:
private JTabbedPane jOutputPane = null;
private JTextPane TextOutputPane = null; // @jve:decl-index=0:visual-constraint="365,-6"
private JConsole TextDebugPane = null;
private JScrollPane DebugScrollPane = null;
public TreePopupHandler TreeHandler=null;
private FileTreeRender filetreeRender=null;
public stateBar stateData; // @jve:decl-index=0:
private WatchDialog watchdialog=null;
private changeDisplay disDialog=null;
private JMenu DisplayMenu = null;
private JMenuItem itemMenuDisplay = null;
/**
* This is the default constructor
*/
public MainFrame() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
vfileframe=new Vector<FileInternalFrame>();
vfileframe.addElement(new FileInternalFrame(this));
indexFrame=new IndexFrame();
openFile=new JFileChooser(this.CurrentPath);
saveFile=new JFileChooser(this.CurrentPath);
openProject=new JFileChooser(this.CurrentPath);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
TreeHandler=new TreePopupHandler(this.getFileTree(),this);
filetreeRender=new FileTreeRender(this);
this.getFileTree().setCellRenderer(filetreeRender);
this.projDialog=new ProjectDialog(this);
this.watchdialog=new WatchDialog(this);
ArrayList<disp> myDisp = new ArrayList<disp>();
myDisp.add(new disp());
myDisp.add(new disp());
disDialog=new changeDisplay(this);
this.setSize(740, 630);
this.setContentPane(getJContentPane());
this.setJMenuBar(getMBar());
this.setTitle("JAcademy");
this.setVisible(true);
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
jContentPane.add(getToolBarPanel(), BorderLayout.NORTH);
jContentPane.add(getJSplitPane(), BorderLayout.CENTER);
//================================My add ============================//
stateData = new stateBar() ;
jContentPane.add(stateData,BorderLayout.SOUTH);
//================================My add ============================//
}
return jContentPane;
}
/**
* This method initializes FileMenu
*
* @return javax.swing.JMenu
*/
private JMenu getFileMenu() {
if (FileMenu == null) {
FileMenu = new JMenu();
FileMenu.setText("文件");
FileMenu.add(getItemMenuNew());
FileMenu.add(getItemMenuOpen());
FileMenu.add(getItemMenuSave());
FileMenu.add(getItemMenuSaveAs());
FileMenu.add(getItemMenuClose());
FileMenu.add(getItemMenuExit());
}
return FileMenu;
}
/**
* This method initializes ProjectMenu
*
* @return javax.swing.JMenu
*/
private JMenu getProjectMenu() {
if (ProjectMenu == null) {
ProjectMenu = new JMenu();
ProjectMenu.setText("工程");
ProjectMenu.add(getItemMenuNewProject());
ProjectMenu.add(getItemMenuOpenProject());
ProjectMenu.add(getItemMenuSaveProject());
ProjectMenu.add(getItemMenuSetProject());
ProjectMenu.add(getItemMenuCloseProject());
}
return ProjectMenu;
}
/**
* This method initializes HelpMenu
*
* @return javax.swing.JMenu
*/
private JMenu getHelpMenu() {
if (HelpMenu == null) {
HelpMenu = new JMenu();
HelpMenu.setText("帮助");
HelpMenu.add(getItemMenuIndex());
HelpMenu.add(getItemMenuSearch());
}
return HelpMenu;
}
/**
* This method initializes itemMenuOpen
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getItemMenuOpen() {
if (itemMenuOpen == null) {
itemMenuOpen = new JMenuItem();
itemMenuOpen.setText("打开");
itemMenuOpen.addActionListener(this);
}
return itemMenuOpen;
}
/**
* This method initializes itemMenuSave
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getItemMenuSave() {
if (itemMenuSave == null) {
itemMenuSave = new JMenuItem();
itemMenuSave.setText("保存");
itemMenuSave.addActionListener(this);
}
return itemMenuSave;
}
/**
* This method initializes itemMenuExit
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getItemMenuExit() {
if (itemMenuExit == null) {
itemMenuExit = new JMenuItem();
itemMenuExit.setText("退出");
itemMenuExit.addActionListener(this);
}
return itemMenuExit;
}
/**
*