-
Notifications
You must be signed in to change notification settings - Fork 9
/
ActivityEditDialog.java
252 lines (221 loc) · 7.79 KB
/
ActivityEditDialog.java
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.Border;
import java.util.EventObject;
import java.util.Vector;
import java.io.*;
/******************************
* Copyright (c) 2003,2019 Kevin Lano
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
* *****************************/
/* Package: GUI */
public class ActivityEditDialog extends JDialog
{ private JPanel bottom;
private JButton okButton, cancelButton;
private ActivityDialogPanel dialogPanel;
private String defaultName;
private String defaultType;
private String defaultParams;
private String defaultPre;
private String defaultPost;
private boolean defaultQuery = true;
private String defaultStereotypes;
private String newName;
private String newType;
private String newParams;
private String newPre;
private String newPost;
private boolean newQuery = true;
private String newStereotypes;
public ActivityEditDialog(JFrame owner)
{ super(owner, true);
setTitle("Edit Activity Properties");
okButton = new JButton("Ok");
cancelButton = new JButton("Cancel");
ButtonHandler bHandler = new ButtonHandler();
okButton.addActionListener(bHandler);
cancelButton.addActionListener(bHandler);
bottom = new JPanel();
bottom.add(okButton);
bottom.add(cancelButton);
bottom.setBorder(BorderFactory.createEtchedBorder());
dialogPanel = new ActivityDialogPanel();
getContentPane().setLayout(new BorderLayout());
getContentPane().add(bottom, BorderLayout.SOUTH);
getContentPane().add(dialogPanel, BorderLayout.CENTER);
}
public void setOldFields(String nme, String type, String params,
String pre, String post, boolean query)
{ defaultName = nme;
defaultType = type;
defaultParams = params;
defaultPre = pre;
defaultPost = post;
defaultQuery = query;
dialogPanel.setOldFields(nme,type,params,pre,post,query);
}
public void setFields(String nme, String type, String params,
String pre, String post, boolean query,
String stereo)
{ newName = nme;
newType = type;
newParams = params;
newPre = pre;
newPost = post;
newQuery = query;
newStereotypes = stereo;
}
public String getName() { return newName; }
public String getActivityType() { return newType; }
public String getParams() { return newParams; }
public String getPre() { return newPre; }
public String getPost() { return newPost; }
public boolean getQuery() { return newQuery; }
public String getStereotypes() { return newStereotypes; }
class ActivityDialogPanel extends JPanel
{ private JLabel nameLabel;
JTextField nameField; /* name */
private JLabel typeLabel;
JComboBox typeField;
private JLabel paramsLabel;
JTextField paramsField;
private JLabel preLabel;
JTextArea preField;
JScrollPane scroller1, scroller2;
private JLabel postLabel;
JTextArea postField;
JCheckBox queryBox, updateBox;
private JPanel queryPanel;
private ButtonGroup queryGroup; /* query or not */
private JLabel stereotypesLabel;
JComboBox stereotypesField;
public ActivityDialogPanel()
{ nameLabel = new JLabel("Operation name:");
nameField = new JTextField();
/* typeLabel = new JLabel("Type:");
typeField = new JComboBox();
typeField.addItem("none");
typeField.addItem("Sequence");
typeField.addItem("Set");
typeField.addItem("int");
typeField.addItem("double");
typeField.addItem("boolean");
typeField.addItem("String");
typeField.setEditable(true);
paramsLabel = new JLabel("Parameters, eg: x T y S ");
paramsField = new JTextField();
preLabel = new JLabel("Pre:");
preField = new JTextArea(30,6);
preField.setLineWrap(true); */
postLabel = new JLabel("Code:");
postField = new JTextArea(30,6);
postField.setLineWrap(true);
/* queryPanel = new JPanel();
queryBox = new JCheckBox("Query",true);
updateBox = new JCheckBox("Update");
queryPanel.add(queryBox);
queryPanel.add(updateBox);
queryPanel.setBorder(
BorderFactory.createTitledBorder("Query or update"));
queryGroup = new ButtonGroup();
queryGroup.add(queryBox);
queryGroup.add(updateBox);
stereotypesLabel = new JLabel("Stereotype:");
stereotypesField = new JComboBox();
stereotypesField.addItem("none");
stereotypesField.addItem("abstract");
stereotypesField.addItem("sequential");
stereotypesField.addItem("static");
stereotypesField.addItem("leaf");
stereotypesField.addItem("explicit"); */
add(nameLabel);
add(nameField);
// add(typeLabel);
// add(typeField);
// add(paramsLabel);
// add(paramsField);
// add(preLabel);
scroller1 = new JScrollPane(preField,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scroller1.setPreferredSize(new Dimension(300,300));
// add(scroller1);
add(postLabel);
scroller2 = new JScrollPane(postField,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scroller2.setPreferredSize(new Dimension(300,300));
add(scroller2);
// add(queryPanel);
// add(stereotypesLabel);
// add(stereotypesField);
}
public void setOldFields(String nme, String type, String params,
String pre, String post, boolean query)
{ nameField.setText(nme);
// typeField.setText(type);
// paramsField.setText(params);
// preField.setText(pre);
postField.setText(post);
// if (query)
// { queryBox.setSelected(true); }
// else
// { updateBox.setSelected(true); }
}
public Dimension getPreferredSize()
{ return new Dimension(450,400); }
public Dimension getMinimumSize()
{ return new Dimension(450,400); }
public void doLayout()
{
nameLabel.setBounds(10,10,120,30);
nameField.setBounds(130,15,270,20);
// typeLabel.setBounds(10,40,120,30);
// typeField.setBounds(130,45,270,20);
// paramsLabel.setBounds(10,70,120,30);
// paramsField.setBounds(130,75,270,20);
// preLabel.setBounds(10,100,120,30);
// scroller1.setBounds(130,105,270,80);
postLabel.setBounds(10,190,120,30);
scroller2.setBounds(130,195,270,180);
// queryPanel.setBounds(10,280,400,50);
// stereotypesLabel.setBounds(10,330,120,30);
// stereotypesField.setBounds(130,335,270,20);
}
public void reset()
{ nameField.setText("");
// typeField.setText("");
// paramsField.setText("");
// preField.setText("");
postField.setText("");
// queryBox.setSelected(true);
}
} /* inner class */
class ButtonHandler implements ActionListener
{ public void actionPerformed(ActionEvent ev)
{ JButton button = (JButton) ev.getSource();
String label = button.getText();
if ("Ok".equals(label))
{ setFields(dialogPanel.nameField.getText(),
"",
"",
"",
dialogPanel.postField.getText(),
true,
"");
}
else
{ setFields(null,null,null,
null,null,true,null);
}
dialogPanel.reset();
setVisible(false);
}
}
}