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 myutil.GraphicLib;
import myutil.TraceManager;
import ui.avatarad.AvatarADPanel;
import ui.avatarcd.AvatarCDPanel;
import ui.iod.InteractionOverviewDiagramPanel;
import ui.iod.InteractionOverviewDiagramToolBar;
import ui.ucd.*;
import ui.util.IconManager;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.util.Iterator;
import java.util.LinkedList;
* Class AnalysisPanel
* Managenemt of analysis panels
* Creation: 14/01/2005
* @version 1.0 14/01/2005
* @author Ludovic APVRILLE
* @see MainGUI
*/
public class AnalysisPanel extends TURTLEPanel {
public InteractionOverviewDiagramPanel iodp;
public AnalysisPanel(MainGUI _mgui) {
super(_mgui);
// Issue #41 Ordering of tabbed panes
tabbedPane = GraphicLib.createDraggableEnhancedTabbedPane(this);//new JTabbedPane();
//tabbedPane = GraphicLib.createTabbedPane();//new JTabbedPane();
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
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
318
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
cl = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e){
mgui.paneAnalysisAction(e);
}
};
tabbedPane.addChangeListener(cl);
tabbedPane.addMouseListener(new TURTLEPanelPopupListener(this, mgui));
}
public void init() {
// Class Diagram toolbar
InteractionOverviewDiagramToolBar toolBarIOD = new InteractionOverviewDiagramToolBar(mgui);
toolbars.add(toolBarIOD);
toolBarPanel = new JPanel();
toolBarPanel.setLayout(new BorderLayout());
//Class diagram
iodp = new InteractionOverviewDiagramPanel(mgui, toolBarIOD);
iodp.setName("Interaction Overview Diagram");
iodp.tp = this;
tdp = iodp;
panels.add(iodp);
JScrollDiagramPanel jsp = new JScrollDiagramPanel(iodp);
iodp.jsp = jsp;
jsp.setWheelScrollingEnabled(true);
jsp.getVerticalScrollBar().setUnitIncrement(MainGUI.INCREMENT);
toolBarPanel.add(toolBarIOD, BorderLayout.NORTH);
toolBarPanel.add(jsp, BorderLayout.CENTER);
tabbedPane.addTab("Interaction Overview Diagram", IconManager.imgic17, toolBarPanel, "Opens interaction overview diagram");
tabbedPane.setSelectedIndex(0);
//jsp.setVisible(true);
}
public boolean addSequenceDiagram(String s) {
JPanel toolBarPanel = new JPanel();
toolBarPanel.setLayout(new BorderLayout());
ui.sd.SequenceDiagramToolBar toolBarSequence = new ui.sd.SequenceDiagramToolBar(mgui);
toolbars.add(toolBarSequence);
ui.sd2.SequenceDiagramPanel sdp = new ui.sd2.SequenceDiagramPanel(mgui, toolBarSequence);
sdp.setName(s);
sdp.tp = this;
panels.add(sdp);
JScrollDiagramPanel jsp = new JScrollDiagramPanel(sdp);
sdp.jsp = jsp;
jsp.setWheelScrollingEnabled(true);
jsp.getVerticalScrollBar().setUnitIncrement(MainGUI.INCREMENT);
toolBarPanel.add(toolBarSequence, BorderLayout.NORTH);
toolBarPanel.add(jsp, BorderLayout.CENTER);
tabbedPane.addTab(s, IconManager.imgic18, toolBarPanel, "Open the sequence diagram of " + s);
return true;
}
public boolean addSequenceDiagramZV(String s) {
JPanel toolBarPanel = new JPanel();
toolBarPanel.setLayout(new BorderLayout());
ui.sd2.SequenceDiagramToolBar toolBarSequence = new ui.sd2.SequenceDiagramToolBar(mgui);
toolbars.add(toolBarSequence);
ui.sd2.SequenceDiagramPanel sdp = new ui.sd2.SequenceDiagramPanel(mgui, toolBarSequence);
sdp.setName(s);
sdp.tp = this;
panels.add(sdp);
JScrollDiagramPanel jsp = new JScrollDiagramPanel(sdp);
sdp.jsp = jsp;
jsp.setWheelScrollingEnabled(true);
jsp.getVerticalScrollBar().setUnitIncrement( MainGUI.INCREMENT);
toolBarPanel.add(toolBarSequence, BorderLayout.NORTH);
toolBarPanel.add(jsp, BorderLayout.CENTER);
tabbedPane.addTab(s, IconManager.imgic18, toolBarPanel, "Open the sequence diagram of " + s);
return true;
}
public boolean addIODiagram(String s) {
InteractionOverviewDiagramToolBar toolBarIOD = new InteractionOverviewDiagramToolBar(mgui);
toolbars.add(toolBarIOD);
toolBarPanel = new JPanel();
toolBarPanel.setLayout(new BorderLayout());
iodp = new InteractionOverviewDiagramPanel(mgui, toolBarIOD);
iodp.setName(s);
iodp.tp = this;
tdp = iodp;
panels.add(iodp);
JScrollDiagramPanel jsp = new JScrollDiagramPanel(iodp);
iodp.jsp = jsp;
jsp.setWheelScrollingEnabled(true);
jsp.getVerticalScrollBar().setUnitIncrement( MainGUI.INCREMENT);
toolBarPanel.add(toolBarIOD, BorderLayout.NORTH);
toolBarPanel.add(jsp, BorderLayout.CENTER);
tabbedPane.addTab(s, IconManager.imgic17, toolBarPanel, "Opens interaction overview diagram");
return true;
}
public boolean addUseCaseDiagram(String s) {
JPanel toolBarPanel = new JPanel();
toolBarPanel.setLayout(new BorderLayout());
UseCaseDiagramToolBar toolBarUC = new UseCaseDiagramToolBar(mgui);
toolbars.add(toolBarUC);
UseCaseDiagramPanel ucdp = new UseCaseDiagramPanel(mgui, toolBarUC);
ucdp.setName(s);
ucdp.tp = this;
panels.add(ucdp);
JScrollDiagramPanel jsp = new JScrollDiagramPanel(ucdp);
ucdp.jsp = jsp;
jsp.setWheelScrollingEnabled(true);
jsp.getVerticalScrollBar().setUnitIncrement( MainGUI.INCREMENT);
toolBarPanel.add(toolBarUC, BorderLayout.NORTH);
toolBarPanel.add(jsp, BorderLayout.CENTER);
tabbedPane.addTab(s, IconManager.imgic19, toolBarPanel, "Open the use case diagram of " + s);
return true;
}
/*public boolean addAvatarContextDiagram(String s) {
JPanel toolBarPanel = new JPanel();
toolBarPanel.setLayout(new BorderLayout());
AvatarCDToolBar toolBarACD = new AvatarCDToolBar(mgui);
toolbars.add(toolBarACD);
AvatarCDPanel acdp = new AvatarCDPanel(mgui, toolBarACD);
acdp.setName(s);
acdp.tp = this;
panels.add(acdp);
JScrollDiagramPanel jsp = new JScrollDiagramPanel(acdp);
acdp.jsp = jsp;
jsp.setWheelScrollingEnabled(true);
jsp.getVerticalScrollBar().setUnitIncrement(mgui.INCREMENT);
toolBarPanel.add(toolBarACD, BorderLayout.NORTH);
toolBarPanel.add(jsp, BorderLayout.CENTER);
tabbedPane.addTab(s, IconManager.imgic80, toolBarPanel, "Open the context diagram of " + s);
return true;
}*/
/*public boolean addAvatarActivityDiagram(String s) {
JPanel toolBarPanel = new JPanel();
toolBarPanel.setLayout(new BorderLayout());
AvatarADToolBar toolBarAAD = new AvatarADToolBar(mgui);
toolbars.add(toolBarAAD);
AvatarADPanel aadp = new AvatarADPanel(mgui, toolBarAAD);
aadp.setName(s);
aadp.tp = this;
panels.add(aadp);
JScrollDiagramPanel jsp = new JScrollDiagramPanel(aadp);
aadp.jsp = jsp;
jsp.setWheelScrollingEnabled(true);
jsp.getVerticalScrollBar().setUnitIncrement(mgui.INCREMENT);
toolBarPanel.add(toolBarAAD, BorderLayout.NORTH);
toolBarPanel.add(jsp, BorderLayout.CENTER);
tabbedPane.addTab(s, IconManager.imgic80, toolBarPanel, "Open the activity diagram of " + s);
return true;
}*/
public String saveHeaderInXml(String extensionToName) {
if (extensionToName == null) {
return "<Modeling type=\"Analysis\" nameTab=\"" + mgui.getTabName(this) + "\" >\n";
}
return "<Modeling type=\"Analysis\" nameTab=\"" + mgui.getTabName(this) + extensionToName + "\" >\n";
}
public String saveTailInXml() {
return "</Modeling>\n\n\n";
}
public String toString() {
return "TURTLE Analysis: " + mgui.getTitleAt(this);
}
public boolean removeEnabled(int index) {
return (panels.elementAt(index) instanceof ui.sd.SequenceDiagramPanel) || (panels.elementAt(index) instanceof ui.sd2.SequenceDiagramPanel) || (panels.elementAt(index) instanceof UseCaseDiagramPanel) || (panels.elementAt(index) instanceof AvatarCDPanel) || (panels.elementAt(index) instanceof AvatarADPanel) || ((panels.elementAt(index) instanceof InteractionOverviewDiagramPanel) & index != 0);
}
public boolean renameEnabled(int index) {
return (panels.elementAt(index) instanceof ui.sd.SequenceDiagramPanel) || (panels.elementAt(index) instanceof ui.sd2.SequenceDiagramPanel) || (panels.elementAt(index) instanceof UseCaseDiagramPanel) || (panels.elementAt(index) instanceof AvatarCDPanel) || (panels.elementAt(index) instanceof AvatarADPanel) || ((panels.elementAt(index) instanceof InteractionOverviewDiagramPanel) & index != 0);
}
public boolean isUCDEnabled() {
return true;
}
public boolean isSDEnabled() {
return true;
}
public boolean isAvatarCDEnabled() {
return false;
//return true;
}
public boolean isAvatarADEnabled() {
return false;
}
public void addInstancesToLastSD(UseCaseDiagramPanel _ucdp) {
TraceManager.addDev("Adding instances to last SD");
TDiagramPanel panel = panels.get(panels.size()-1);
if (!(panel instanceof ui.sd2.SequenceDiagramPanel)) {
return;
}
//TraceManager.addDev("Adding instances to last SD Step 2");
Iterator<TGComponent> iterator = _ucdp.getComponentList().iterator();
TGComponent tgc;
// To determine whether an actor is on the left, or on the right
int middleX = 0;
int cptTotal = 0;
String systemName;
UCDBorder border = _ucdp.getFirstUCDBorder();
if (border != null) {
middleX = border.getX() + border.getWidth()/2;
systemName = border.getValue();
} else {
systemName = "System";
while(iterator.hasNext()) {
tgc = iterator.next();
if ((tgc instanceof UCDActor) || (tgc instanceof UCDActorBox)) {
middleX = middleX + tgc.getX();
cptTotal ++;
}
}
middleX = middleX / cptTotal;
}
//TraceManager.addDev("Adding instances to last SD Step 3");
// Classify actors
java.util.List<TGComponent> actors = new LinkedList<TGComponent>();
iterator = _ucdp.getComponentList().iterator();
int i;
while(iterator.hasNext()) {
tgc = iterator.next();
if ((tgc instanceof UCDActor) || (tgc instanceof UCDActorBox)) {
for(i=0; i<actors.size(); i++) {
if (actors.get(i).getX() > tgc.getX()) {
break;
}
}
// added at index i
actors.add(i, tgc);
}
}
//TraceManager.addDev("Adding instances to last SD Step 3 nb of actors = " + actors.size());
int initX = 100;
int initY = 100;
int stepX = 150;
ui.sd2.SDInstance sdi;
boolean systemAdded = false;
// Add actors (and the system)
for(TGComponent elt: actors) {
if (elt.getX() > middleX && !systemAdded) {
sdi = (ui.sd2.SDInstance)(TGComponentManager.addComponent(initX, initY, TGComponentManager.SD_INSTANCE, panel));
sdi.setValue(systemName);
sdi.setActor(false);
panel.addComponent(sdi, initX, initY, false, true);
initX += stepX;
systemAdded = true;
}
sdi = (ui.sd2.SDInstance)(TGComponentManager.addComponent(initX, initY, TGComponentManager.SD_INSTANCE, panel));
sdi.setValue(elt.getValue());
sdi.setActor(true);
panel.addComponent(sdi, initX, initY, false, true);
initX += stepX;
}
if (!systemAdded) {
sdi = (ui.sd2.SDInstance)(TGComponentManager.addComponent(initX, initY, TGComponentManager.SD_INSTANCE, panel));
sdi.setValue(systemName);
sdi.setActor(false);
panel.addComponent(sdi, initX, initY, false, true);
initX += stepX;
systemAdded = true;
}
while(initX > panel.getMaxX()) {
panel.setMaxX(panel.getMaxX() + panel.getIncrement());
panel.updateSize();
}
panel.repaint();
TraceManager.addDev("initX = " + initX + " nb of components:" + panel.getComponentList().size());
}
}