Newer
Older
/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
* ludovic.apvrille AT enst.fr
* This software is a computer program whose purpose is to allow the
* edition of TURTLE analysis, design and deployment diagrams, to
* allow the generation of RT-LOTOS or Java code from this diagram,
* and at last to allow the analysis of formal validation traces
* obtained from external tools, e.g. RTL from LAAS-CNRS and CADP
* from INRIA Rhone-Alpes.
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package ui;
import common.ConfigurationTTool;
import myutil.TraceManager;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Class JToolBarMainTurtle
* Main toolbar of the ttool main window
* Creation: 09/12/2003
* @author Ludovic APVRILLE
*/
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
public class JToolBarMainTurtle extends JToolBar implements ActionListener {
// Avatar
JButton avatarSimu, avatarFVUPPAAL, avatarFVProVerif, avatarFVStaticAnalysis, avatarCodeGeneration, avatarMC;
// Other
JButton genrtlotos, genlotos, genuppaal, gendesign, dse;
JButton checkcode, simulation, validation;
JButton oneClickrtlotos, onclicklotos, gensystemc, simusystemc, gentml, genC, genjava, nc,externalSearch, internalSearch;
JTextField search;
MainGUI mgui;
public JToolBarMainTurtle(MainGUI _mgui) {
super();
mgui = _mgui;
buildToolBar(mgui);
}
// Menus
private void buildToolBar(MainGUI mgui) {
JButton button;
button = add(mgui.actions[TGUIAction.ACT_NEW]);
button.addMouseListener(mgui.mouseHandler);
button = add(mgui.actions[TGUIAction.ACT_OPEN]);
button.addMouseListener(mgui.mouseHandler);
button = add(mgui.actions[TGUIAction.ACT_SAVE]);
button.addMouseListener(mgui.mouseHandler);
//button = add(mgui.actions[TGUIAction.ACT_SAVE_AS]);
//button.addMouseListener(mgui.mouseHandler);
addSeparator();
button = add(mgui.actions[TGUIAction.ACT_IMPORT_LIB]);
button.addMouseListener(mgui.mouseHandler);
button = add(mgui.actions[TGUIAction.ACT_EXPORT_LIB]);
button.addMouseListener(mgui.mouseHandler);
addSeparator();
button = add(mgui.actions[TGUIAction.ACT_CUT]);
button.addMouseListener(mgui.mouseHandler);
button = add(mgui.actions[TGUIAction.ACT_COPY]);
button.addMouseListener(mgui.mouseHandler);
button = add(mgui.actions[TGUIAction.ACT_PASTE]);
button.addMouseListener(mgui.mouseHandler);
button = add(mgui.actions[TGUIAction.ACT_DELETE]);
button.addMouseListener(mgui.mouseHandler);
button = add(mgui.actions[TGUIAction.MOVE_ENABLED]);
button.addMouseListener(mgui.mouseHandler);
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
addSeparator();
button = add(mgui.actions[TGUIAction.ACT_BACKWARD]);
button.addMouseListener(mgui.mouseHandler);
button = add(mgui.actions[TGUIAction.ACT_FORWARD]);
button.addMouseListener(mgui.mouseHandler);
addSeparator();
button = add(mgui.actions[TGUIAction.ACT_ZOOM_LESS]);
button.addMouseListener(mgui.mouseHandler);
button = add(mgui.actions[TGUIAction.ACT_SHOW_ZOOM]);
button.addMouseListener(mgui.mouseHandler);
button = add(mgui.actions[TGUIAction.ACT_ZOOM_MORE]);
button.addMouseListener(mgui.mouseHandler);
//button.setMinimumSize(button.getSize());
addSeparator();
/*button = add(mgui.actions[TGUIAction.ACT_FIRST_DIAG]);
button.addMouseListener(mgui.mouseHandler);
button = add(mgui.actions[TGUIAction.ACT_BACK_DIAG]);
button.addMouseListener(mgui.mouseHandler);
button = add(mgui.actions[TGUIAction.ACT_NEXT_DIAG]);
button.addMouseListener(mgui.mouseHandler);
button = add(mgui.actions[TGUIAction.ACT_LAST_DIAG]);
button.addMouseListener(mgui.mouseHandler);*/
addSeparator();
addSeparator();
button = add(mgui.actions[TGUIAction.ACT_MODEL_CHECKING]);
button.addMouseListener(mgui.mouseHandler);
addSeparator();
if (MainGUI.experimentalOn) {
gendesign = add(mgui.actions[TGUIAction.ACT_GEN_DESIGN]);
gendesign.addMouseListener(mgui.mouseHandler);
}
addSeparator();
avatarSimu = add(mgui.actions[TGUIAction.ACT_AVATAR_SIM]);
avatarSimu.addMouseListener(mgui.mouseHandler);
dse = add(mgui.actions[TGUIAction.ACT_DSE]);
dse.addMouseListener(mgui.mouseHandler);
addSeparator();
//if (MainGUI.experimentalOn) {
avatarMC = add(mgui.actions[TGUIAction.ACT_AVATAR_MODEL_CHECKER]);
avatarMC.addMouseListener(mgui.mouseHandler);
//}
avatarFVUPPAAL = add(mgui.actions[TGUIAction.ACT_AVATAR_FV_UPPAAL]);
avatarFVUPPAAL.addMouseListener(mgui.mouseHandler);
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
genuppaal = add(mgui.actions[TGUIAction.ACT_GEN_UPPAAL]);
genuppaal.addMouseListener(mgui.mouseHandler);
}
if (MainGUI.proverifOn) {
avatarFVProVerif = add(mgui.actions[TGUIAction.ACT_AVATAR_FV_PROVERIF]);
avatarFVProVerif.addMouseListener(mgui.mouseHandler);
}
avatarFVStaticAnalysis = add(mgui.actions[TGUIAction.ACT_AVATAR_FV_STATICANALYSIS]);
avatarFVStaticAnalysis.addMouseListener(mgui.mouseHandler);
addSeparator();
avatarCodeGeneration = add(mgui.actions[TGUIAction.ACT_AVATAR_EXECUTABLE_GENERATION]);
avatarCodeGeneration.addMouseListener(mgui.mouseHandler);
addSeparator();
genrtlotos = add(mgui.actions[TGUIAction.ACT_GEN_RTLOTOS]);
genrtlotos.addMouseListener(mgui.mouseHandler);
if (MainGUI.systemcOn) {
genlotos = add(mgui.actions[TGUIAction.ACT_GEN_LOTOS]);
genlotos.addMouseListener(mgui.mouseHandler);
/*addSeparator();
button = add(mgui.actions[TGUIAction.ACT_GEN_AUTS]);
button.addMouseListener(mgui.mouseHandler);
button = add(mgui.actions[TGUIAction.ACT_GEN_AUT]);
button.addMouseListener(mgui.mouseHandler);*/
} else if (MainGUI.lotosOn) {
genlotos = add(mgui.actions[TGUIAction.ACT_GEN_LOTOS]);
genlotos.addMouseListener(mgui.mouseHandler);
}
addSeparator();
checkcode = add(mgui.actions[TGUIAction.ACT_CHECKCODE]);
checkcode.addMouseListener(mgui.mouseHandler);
simulation = add(mgui.actions[TGUIAction.ACT_SIMULATION]);
simulation.addMouseListener(mgui.mouseHandler);
validation = add(mgui.actions[TGUIAction.ACT_VALIDATION]);
validation.addMouseListener(mgui.mouseHandler);
addSeparator();
oneClickrtlotos = add(mgui.actions[TGUIAction.ACT_ONECLICK_RTLOTOS_RG]);
oneClickrtlotos.addMouseListener(mgui.mouseHandler);
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
if (MainGUI.lotosOn) {
onclicklotos = add(mgui.actions[TGUIAction.ACT_ONECLICK_LOTOS_RG]);
onclicklotos.addMouseListener(mgui.mouseHandler);
}
addSeparator();
if (MainGUI.systemcOn) {
gensystemc = add(mgui.actions[TGUIAction.ACT_GEN_SYSTEMC]);
gensystemc.addMouseListener(mgui.mouseHandler);
simusystemc = add(mgui.actions[TGUIAction.ACT_SIMU_SYSTEMC]);
simusystemc.addMouseListener(mgui.mouseHandler);
addSeparator();
gentml = add(mgui.actions[TGUIAction.ACT_GEN_TMLTXT]);
gentml.addMouseListener(mgui.mouseHandler);
addSeparator();
genC = add(mgui.actions[TGUIAction.ACT_GEN_CCODE]);
genC.addMouseListener(mgui.mouseHandler);
addSeparator();
}
addSeparator();
genjava = add(mgui.actions[TGUIAction.ACT_GEN_JAVA]);
genjava.addMouseListener(mgui.mouseHandler);
//button = add(mgui.actions[TGUIAction.ACT_SIMU_JAVA]);
//button.addMouseListener(mgui.mouseHandler);
addSeparator();
if (MainGUI.ncOn) {
nc = add(mgui.actions[TGUIAction.ACT_NC]);
nc.addMouseListener(mgui.mouseHandler);
}
addSeparator();
if ((ConfigurationTTool.ExternalCommand1.length() > 0) && (ConfigurationTTool.ExternalCommand1Host.length() > 0)) {
button = add(mgui.actions[TGUIAction.EXTERNAL_ACTION_1]);
button.addMouseListener(mgui.mouseHandler);
button.setToolTipText(ConfigurationTTool.ExternalCommand1);
addSeparator();
}
if ((ConfigurationTTool.ExternalCommand2.length() > 0) && (ConfigurationTTool.ExternalCommand2Host.length() > 0)) {
button = add(mgui.actions[TGUIAction.EXTERNAL_ACTION_2]);
button.addMouseListener(mgui.mouseHandler);
button.setToolTipText(ConfigurationTTool.ExternalCommand2);
addSeparator();
}
addSeparator();
showAvatarActions(false);
search = new JTextField("", 10);
search.setEnabled(false);
add(search);
search.addActionListener(this);
search.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent documentEvent) {
if (search.getText().length()>0){
internalSearch.setEnabled(true);
}else
internalSearch.setEnabled(false);
}
@Override
public void removeUpdate(DocumentEvent documentEvent) {
if (search.getText().length()>0){
internalSearch.setEnabled(true);
}else
internalSearch.setEnabled(false);
}
@Override
public void changedUpdate(DocumentEvent documentEvent) {
}
});
//@author : Huy TRUONG
//add external search button into menu bar
internalSearch = add(mgui.actions[TGUIAction.ACT_INTERNAL_SEARCH]);
internalSearch.addMouseListener(mgui.mouseHandler);
externalSearch = add(mgui.actions[TGUIAction.ACT_EXTERNAL_SEARCH]);
externalSearch.addMouseListener(mgui.mouseHandler);
//--
}
public void showAvatarActions(boolean b) {
//TraceManager.addDev("Show avatar options with b = " + b);
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
avatarSimu.setVisible(b);
avatarFVUPPAAL.setVisible(b);
if (avatarFVProVerif != null) {
avatarFVProVerif.setVisible(b);
}
//avatarFVStaticAnalysis.setVisible(b);
avatarFVStaticAnalysis.setVisible(b);
avatarCodeGeneration.setVisible(b);
if (genrtlotos != null) {
genrtlotos.setVisible(!b);
}
if (genlotos != null) {
genlotos.setVisible(!b);
}
if (genuppaal != null) {
genuppaal.setVisible(!b);
}
if (checkcode != null) {
checkcode.setVisible(!b);
}
if (simulation != null) {
simulation.setVisible(!b);
}
if (validation != null) {
validation.setVisible(!b);
}
if (oneClickrtlotos != null) {
oneClickrtlotos.setVisible(!b);
}
if (onclicklotos != null) {
onclicklotos.setVisible(!b);
}
if (gensystemc != null) {
gensystemc.setVisible(!b);
}
if (simusystemc != null) {
simusystemc.setVisible(!b);
}
if (gentml != null) {
gentml.setVisible(!b);
}
if (genC != null) {
genC.setVisible(!b);
}
if (genjava != null) {
genjava.setVisible(!b);
}
if (nc != null) {
nc.setVisible(!b);
}
if (gendesign != null) {
gendesign.setVisible(!b);
}
}
public void showDiplodocusActions(boolean b) {
//TraceManager.addDev("Show diplodocus options with b = " + b);
avatarSimu.setVisible(!b);
avatarFVUPPAAL.setVisible(!b);
avatarFVStaticAnalysis.setVisible(!b);
if (avatarFVProVerif != null) {
avatarFVProVerif.setVisible(b);
}
avatarCodeGeneration.setVisible(!b);
if (genrtlotos != null) {
genrtlotos.setVisible(!b);
}
if (genlotos != null) {
genlotos.setVisible(!b);
if (genuppaal != null) {
genuppaal.setVisible(b);
}
if (checkcode != null) {
checkcode.setVisible(!b);
}
if (simulation != null) {
simulation.setVisible(!b);
}
if (validation != null) {
validation.setVisible(!b);
}
if (oneClickrtlotos != null) {
oneClickrtlotos.setVisible(!b);
}
if (onclicklotos != null) {
onclicklotos.setVisible(!b);
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
if (gensystemc != null) {
gensystemc.setVisible(b);
}
if (simusystemc != null) {
simusystemc.setVisible(b);
}
if (gentml != null) {
gentml.setVisible(b);
}
if (genC != null) {
genC.setVisible(b);
}
if (genjava != null) {
genjava.setVisible(!b);
}
if (nc != null) {
nc.setVisible(!b);
}
if (gendesign != null) {
gendesign.setVisible(!b);
}
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == search) {
String text = search.getText();
TraceManager.addDev("Searching elements with" + text);
if (text.length()>0) {
search.setEnabled(false);
mgui.search(text);
search.setEnabled(true);
}
}
}
public void activateSearch(boolean enabled) {
search.setEnabled(enabled);
}
} // Class