Newer
Older
/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille

Ludovic Apvrille
committed
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
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.
/**
* Class AvatarAnalysisPanel
* Managenemt of AVATAR analysis panels
* Creation: 14/02/2014
* @version 1.0 14/02/2014
* @author Ludovic APVRILLE
* @see MainGUI
*/
import myutil.GraphicLib;
import myutil.TraceManager;
import ui.avatarad.AvatarADPanel;
import ui.avatarad.AvatarADToolBar;
import ui.avatarcd.AvatarCDPanel;
import ui.avatarcd.AvatarCDToolBar;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.util.Iterator;
import java.util.LinkedList;
public class AvatarAnalysisPanel extends TURTLEPanel {

Ludovic Apvrille
committed
public AvatarAnalysisPanel(MainGUI _mgui) {
super(_mgui);
// Issue #41 Ordering of tabbed panes
tabbedPane = GraphicLib.createTabbedPane();//new JTabbedPane();
@Override
public void stateChanged(ChangeEvent e){
mgui.paneAnalysisAction(e);
}
};
tabbedPane.addChangeListener(cl);
tabbedPane.addMouseListener(new TURTLEPanelPopupListener(this, mgui));
}

Ludovic Apvrille
committed
mgui.changeMade(null, TDiagramPanel.NEW_COMPONENT);

Ludovic Apvrille
committed
public boolean addSequenceDiagram(String s) {
JPanel toolBarPanel = new JPanel();
toolBarPanel.setLayout(new BorderLayout());

Ludovic Apvrille
committed
ui.sd.SequenceDiagramToolBar toolBarSequence = new ui.sd.SequenceDiagramToolBar(mgui);

Ludovic Apvrille
committed
ui.sd.SequenceDiagramPanel sdp = new ui.sd.SequenceDiagramPanel(mgui, toolBarSequence);
sdp.setName(s);
sdp.tp = this;
panels.add(sdp);

Ludovic Apvrille
committed
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);
//tabbedPane.setVisible(true);
//sdp.setVisible(true);
//jsp.setVisible(true);
//tabbedPane.setSelectedIndex(panels.size()-1);

Ludovic Apvrille
committed

Ludovic Apvrille
committed

Ludovic Apvrille
committed
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);

Ludovic Apvrille
committed
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);
//tabbedPane.setVisible(true);
//sdp.setVisible(true);
//jsp.setVisible(true);
//tabbedPane.setSelectedIndex(panels.size()-1);

Ludovic Apvrille
committed

Ludovic Apvrille
committed

Ludovic Apvrille
committed
public boolean addUseCaseDiagram(String s) {
JPanel toolBarPanel = new JPanel();
toolBarPanel.setLayout(new BorderLayout());

Ludovic Apvrille
committed
UseCaseDiagramToolBar toolBarUC = new UseCaseDiagramToolBar(mgui);

Ludovic Apvrille
committed
UseCaseDiagramPanel ucdp = new UseCaseDiagramPanel(mgui, toolBarUC);
ucdp.setName(s);
ucdp.tp = this;
panels.add(ucdp);

Ludovic Apvrille
committed
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);

Ludovic Apvrille
committed

Ludovic Apvrille
committed
public boolean addAvatarContextDiagram(String s) {
JPanel toolBarPanel = new JPanel();
toolBarPanel.setLayout(new BorderLayout());

Ludovic Apvrille
committed
AvatarCDToolBar toolBarACD = new AvatarCDToolBar(mgui);

Ludovic Apvrille
committed
AvatarCDPanel acdp = new AvatarCDPanel(mgui, toolBarACD);
acdp.setName(s);
acdp.tp = this;
panels.add(acdp);

Ludovic Apvrille
committed
JScrollDiagramPanel jsp = new JScrollDiagramPanel(acdp);
acdp.jsp = jsp;
jsp.setWheelScrollingEnabled(true);
jsp.getVerticalScrollBar().setUnitIncrement( MainGUI.INCREMENT);
toolBarPanel.add(toolBarACD, BorderLayout.NORTH);
toolBarPanel.add(jsp, BorderLayout.CENTER);
tabbedPane.addTab(s, IconManager.imgic600, toolBarPanel, "Open the context diagram of " + s);

Ludovic Apvrille
committed

Ludovic Apvrille
committed
public boolean addAvatarActivityDiagram(String s) {
JPanel toolBarPanel = new JPanel();
toolBarPanel.setLayout(new BorderLayout());

Ludovic Apvrille
committed
AvatarADToolBar toolBarAAD = new AvatarADToolBar(mgui);
toolbars.add(toolBarAAD);

Ludovic Apvrille
committed
AvatarADPanel aadp = new AvatarADPanel(mgui, toolBarAAD);
aadp.setName(s);
aadp.tp = this;
panels.add(aadp);

Ludovic Apvrille
committed
JScrollDiagramPanel jsp = new JScrollDiagramPanel(aadp);
aadp.jsp = jsp;
jsp.setWheelScrollingEnabled(true);
jsp.getVerticalScrollBar().setUnitIncrement( MainGUI.INCREMENT);
toolBarPanel.add(toolBarAAD, BorderLayout.NORTH);
toolBarPanel.add(jsp, BorderLayout.CENTER);
tabbedPane.addTab(s, IconManager.imgic5048, toolBarPanel, "Open the activity diagram of " + s);

Ludovic Apvrille
committed

Ludovic Apvrille
committed
public String saveHeaderInXml(String extensionToName) {
if (extensionToName == null) {
return "<Modeling type=\"Avatar Analysis\" nameTab=\"" + mgui.getTabName(this) + "\" >\n";
}
return "<Modeling type=\"Avatar Analysis\" nameTab=\"" + mgui.getTabName(this) + extensionToName + "\" >\n";

Ludovic Apvrille
committed
public String saveTailInXml() {
return "</Modeling>\n\n\n";
}

Ludovic Apvrille
committed
public String toString() {
return "AVATAR Analysis: " + mgui.getTitleAt(this);
}

Ludovic Apvrille
committed

Ludovic Apvrille
committed
return true;
/*if ((panels.elementAt(index) instanceof SequenceDiagramPanel) ||(panels.elementAt(index) instanceof UseCaseDiagramPanel) ||(panels.elementAt(index) instanceof AvatarCDPanel)||(panels.elementAt(index) instanceof AvatarADPanel) || ((panels.elementAt(index) instanceof InteractionOverviewDiagramPanel) & index != 0)){

Ludovic Apvrille
committed
return true;
}
return false;*/

Ludovic Apvrille
committed

Ludovic Apvrille
committed
return true;
/*if ((panels.elementAt(index) instanceof SequenceDiagramPanel) ||(panels.elementAt(index) instanceof UseCaseDiagramPanel) ||(panels.elementAt(index) instanceof AvatarCDPanel)||(panels.elementAt(index) instanceof AvatarADPanel)|| ((panels.elementAt(index) instanceof InteractionOverviewDiagramPanel) & index != 0)){

Ludovic Apvrille
committed
return true;
}
return false;*/

Ludovic Apvrille
committed

Ludovic Apvrille
committed
}
public boolean isSDEnabled() {

Ludovic Apvrille
committed
}
public boolean isAvatarCDEnabled() {
return true;

Ludovic Apvrille
committed
}
public boolean isAvatarADEnabled() {

Ludovic Apvrille
committed
}
public boolean canFirstDiagramBeMoved() {

Ludovic Apvrille
committed
}
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)) {

Ludovic Apvrille
committed
return;
}
//TraceManager.addDev("Adding instances to last SD Step 2");
Iterator<TGComponent> iterator = _ucdp.getComponentList().iterator();

Ludovic Apvrille
committed
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()) {

Ludovic Apvrille
committed
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();

Ludovic Apvrille
committed
int i;
while(iterator.hasNext()) {

Ludovic Apvrille
committed
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;

Ludovic Apvrille
committed
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.SDZV_INSTANCE, panel));

Ludovic Apvrille
committed
sdi.setValue(systemName);
sdi.setName(systemName);
sdi.setActor(false);
panel.addComponent(sdi, initX, initY, false, true);
initX += stepX;
systemAdded = true;
}
sdi = (ui.sd2.SDInstance)(TGComponentManager.addComponent(initX, initY, TGComponentManager.SDZV_INSTANCE, panel));

Ludovic Apvrille
committed
sdi.setValue(elt.getValue());
sdi.setName(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.SDZV_INSTANCE, panel));

Ludovic Apvrille
committed
sdi.setValue(systemName);
sdi.setName(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());
}
}