-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathController.java
More file actions
206 lines (179 loc) · 4.67 KB
/
Controller.java
File metadata and controls
206 lines (179 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class Controller extends JFrame implements ActionListener
{
public static Board current;
public String label;
// c_ prefix indicates "create"
private JButton c_new;
private JButton c_bubble, c_data_store, c_extr_entity,
c_output, c_arrow;
private JButton delete, rename;
private JButton move_down, move_up;
private JButton balance, dictionary, print, refresh;
public Controller()
{
Container c = getContentPane();
setSize(150,350);
c.setLayout(new FlowLayout(FlowLayout.CENTER,10,10));
//************************************************************//
c_new = new JButton(new ImageIcon("images/New.jpg"));
c_new.addActionListener(this);
c.add(c_new);
print = new JButton(new ImageIcon("images/Print.jpg"));
print.addActionListener(this);
c.add(print);
c_bubble = new JButton(new ImageIcon("images/Bubble.jpg"));
c_bubble.addActionListener(this);
c.add(c_bubble);
c_data_store =
new JButton(new ImageIcon("images/DataStore.jpg"));
c_data_store.addActionListener(this);
c.add(c_data_store);
c_extr_entity =
new JButton(new ImageIcon("images/ExtrEntity.jpg"));
c_extr_entity.addActionListener(this);
c.add(c_extr_entity);
c_output = new JButton(new ImageIcon("images/Output.jpg"));
c_output.addActionListener(this);
c.add(c_output);
c_arrow = new JButton(new ImageIcon("images/Arrow.jpg"));
c_arrow.addActionListener(this);
c.add(c_arrow);
rename = new JButton(new ImageIcon("images/Rename.jpg"));
rename.addActionListener(this);
c.add(rename);
move_down = new JButton(new ImageIcon("images/Move_down.jpg"));
move_down.addActionListener(this);
c.add(move_down);
move_up = new JButton(new ImageIcon("images/Move_up.jpg"));
move_up.addActionListener(this);
c.add(move_up);
balance = new JButton(new ImageIcon("images/Balance.jpg"));
balance.addActionListener(this);
c.add(balance);
dictionary =
new JButton(new ImageIcon("images/Dictionary.jpg"));
dictionary.addActionListener(this);
c.add(dictionary);
delete = new JButton(new ImageIcon("images/Delete.jpg"));
delete.addActionListener(this);
c.add(delete);
refresh = new JButton(new ImageIcon("images/Refresh.jpg"));
refresh.addActionListener(this);
c.add(refresh);
//***********************************************************//
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent event) {
System.exit(0);
}
});
setVisible(true);
}
public void actionPerformed(ActionEvent ae)
{
Object s = ae.getSource();
if (s == c_new)
{
new RequestLabel(this,"Context Diagram");
current = new Board(label);
}
else if (current != null)
{
String level = current.current.getLevel();
if (s == print)
{
new PrintUtilities(current.current).print();
}
else if (s == c_bubble)
{
if (!level.equals("-1"))
{
new RequestLabel(this,"Bubble");
current.drawBubble(label);
}
else
{
new Error(this,
"Cannot draw Bubble in Context Diagram");
}
}
else if (s == c_data_store)
{
new RequestLabel(this,"Data Store");
current.drawDataStore(label);
}
else if (s == c_arrow)
{
new RequestLabel(this,"Data Arrow");
current.drawArrow(label);
}
else if (s == rename)
{
Symbol sym=current.current.selected;
if (sym != null)
{
new RequestLabel(this,"Symbol");
sym.reLabel(label);
current.current.repaint();
}
}
else if (s == move_down)
{
current.moveDown();
}
else if (s == move_up)
{
current.moveUp();
}
else if (s == delete)
{
current.delete();
}
else if (s == refresh)
{
current.current.repaint();
}
else if (s == dictionary)
{
ArrayList al = current.dataDictionary();
String obj[][] = new String[al.size()][2];
int size = al.size();
Object o[] = al.toArray();
for(int i=0;i<size;++i)
{
obj[i][0] = ""+o[i];
obj[i][1] = "";
}
new DataDictionary(obj);
}
else if (s == balance)
{
new Error(this,current.checkBalance());
}
else if (level.equals("-1"))
{
if (s == c_extr_entity)
{
new RequestLabel(this,"External Entity");
current.drawExtEntity(label);
}
else if (s == c_output)
{
new RequestLabel(this,"Output");
current.drawOutput(label);
}
}
else
{
new Error(this,"Cannot draw in non-context diagram");
}
}
}
public static void main(String arg[])
{
new Controller();
}
}