1 package main;
2
3 import intellego.Intellego;
4 import util.*;
5 import interfaces.*;
6 import real.*;
7
8 import java.awt.*;
9 import java.lang.*;
10 import java.awt.event.*;
11 import javax.swing.*;
12 import java.io.*;
13
14
19 public class MainInterface extends JFrame
20 {
21 private static JDesktopPane mainPane;
23
26 public MainInterface()
27 {
28 super("Intellego");
29
30 int inset = 50;
32 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
33 setBounds(inset, inset, screenSize.width - inset*2, screenSize.height-inset*2);
34
35 addWindowListener(new WindowAdapter()
37 {
38 public void windowClosing(WindowEvent e)
39 {
40 Intellego.addToLog("MainInterface.init(): System quitting");
41 System.exit(0);
42 }
43 });
44
45 mainPane=new JDesktopPane();
47
48 setContentPane(mainPane);
49 setJMenuBar(createMenuBar());
50 }
51
52
55 public static void createCodeEditorFrame()
56 {
57 CodeEditor frame = new CodeEditor();
58 frame.setVisible(true);
59 mainPane.add(frame);
60 try
61 {
62 frame.setSelected(true);
63 }
64 catch (Exception e)
65 {
66 Intellego.addToLog("MainInterface.createFrame(): Failed to create internal code editor frame properly: "+e);
67 }
68 }
69
70
73 public static void createSimulatorFrame()
74 {
75 SimUI frame = new SimUI();
76 frame.setVisible(true);
77 mainPane.add(frame);
78 try
79 {
80 frame.setSelected(true);
81 }
82 catch (Exception e)
83 {
84 Intellego.addToLog("MainInterface.createFrame(): Failed to create internal simulator frame properly: "+e);
85 }
86 }
87
88
93 public static void createSimulatorFrame(String className)
94 {
95 SimUI frame = new SimUI(className);
96 frame.setVisible(true);
97 mainPane.add(frame);
98 try
99 {
100 frame.setSelected(true);
101 }
102 catch (Exception e)
103 {
104 Intellego.addToLog("MainInterface.createFrame(): Failed to create internal simulator frame properly: "+e);
105 }
106 }
107
108
113 public static ExternalMessager createExternalMessagerFrame()
114 {
115 ExternalMessager frame = new ExternalMessager();
116 frame.setVisible(true);
117 mainPane.add(frame);
118 try
119 {
120 frame.setSelected(true);
121 }
122 catch (Exception e)
123 {
124 Intellego.addToLog("MainInterface.createFrame(): Failed to create internal frame properly: "+e);
125 }
126 return frame;
127 }
128
129
134 private JMenuBar createMenuBar()
135 {
136 JMenuBar menuBar = new JMenuBar();
137
138 JMenu toolsMenu = new JMenu("Tools");
139 JMenuItem codeEditor = new JMenuItem("Code Editor");
140 JMenuItem simulator = new JMenuItem("Simulator");
141
142 codeEditor.addActionListener(new ActionListener()
143 {
144 public void actionPerformed(ActionEvent e)
145 {
146 createCodeEditorFrame();
147 }
148 });
149
150 simulator.addActionListener(new ActionListener()
151 {
152 public void actionPerformed(ActionEvent e)
153 {
154 createSimulatorFrame();
155 }
156 });
157
158 toolsMenu.add(codeEditor);
159 toolsMenu.add(simulator);
160
161 menuBar.add(toolsMenu);
162
163 return menuBar;
164 }
165
166
171 public static void displayMessage(String message)
172 {
173 IntellegoDialog dialog=new IntellegoDialog(message);
175 }
176 }
177