From b1766adfb9c4f9890ebfd1c343822d030c7748d3 Mon Sep 17 00:00:00 2001 From: Ludovic Apvrille <ludovic.apvrille@telecom-paristech.fr> Date: Tue, 19 Jan 2016 15:07:47 +0000 Subject: [PATCH] Patching bug on moving diagram from first position to the second, and vice versa --- src/ui/AttackTreePanel.java | 4 + src/ui/AvatarAnalysisPanel.java | 486 ++++++++++++++------------- src/ui/AvatarMADsPanel.java | 6 +- src/ui/AvatarRequirementPanel.java | 6 +- src/ui/TURTLEPanel.java | 4 + src/ui/TURTLEPanelPopupListener.java | 330 +++++++++--------- src/ui/ucd/UseCaseDiagramPanel.java | 206 ++++++------ 7 files changed, 534 insertions(+), 508 deletions(-) diff --git a/src/ui/AttackTreePanel.java b/src/ui/AttackTreePanel.java index e14ff3435c..3825bfe93e 100755 --- a/src/ui/AttackTreePanel.java +++ b/src/ui/AttackTreePanel.java @@ -125,6 +125,10 @@ public class AttackTreePanel extends TURTLEPanel { return mgui.getTitleAt(this) + " (SysML Parametric Diagram)"; } + public boolean canFirstDiagramBeMoved() { + return true; + } + public boolean removeEnabled(int index) { if (panels.size() > 1) { return true; diff --git a/src/ui/AvatarAnalysisPanel.java b/src/ui/AvatarAnalysisPanel.java index 9ca07b6dc3..8182f2dbe2 100755 --- a/src/ui/AvatarAnalysisPanel.java +++ b/src/ui/AvatarAnalysisPanel.java @@ -1,48 +1,48 @@ /**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. - -/** -* Class AvatarAnalysisPanel -* Managenemt of AVATAR analysis panels -* Creation: 14/02/2014 -* @version 1.0 14/02/2014 -* @author Ludovic APVRILLE -* @see MainGUI -*/ + 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 + */ package ui; @@ -59,57 +59,57 @@ import ui.avatarad.*; import myutil.*; public class AvatarAnalysisPanel extends TURTLEPanel { - + public AvatarAnalysisPanel(MainGUI _mgui) { super(_mgui); tabbedPane = new JTabbedPane(); cl = new ChangeListener() { - public void stateChanged(ChangeEvent e){ - mgui.paneAnalysisAction(e); - } - }; + public void stateChanged(ChangeEvent e){ + mgui.paneAnalysisAction(e); + } + }; tabbedPane.addChangeListener(cl); tabbedPane.addMouseListener(new TURTLEPanelPopupListener(this, mgui)); } - + public void init() { mgui.changeMade(null, TDiagramPanel.NEW_COMPONENT); /*// 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(mgui.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); */ + 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(mgui.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()); - - SequenceDiagramToolBar toolBarSequence = new SequenceDiagramToolBar(mgui); + + SequenceDiagramToolBar toolBarSequence = new SequenceDiagramToolBar(mgui); toolbars.add(toolBarSequence); - + SequenceDiagramPanel sdp = new SequenceDiagramPanel(mgui, toolBarSequence); sdp.setName(s); sdp.tp = this; panels.add(sdp); - JScrollDiagramPanel jsp = new JScrollDiagramPanel(sdp); + JScrollDiagramPanel jsp = new JScrollDiagramPanel(sdp); sdp.jsp = jsp; jsp.setWheelScrollingEnabled(true); jsp.getVerticalScrollBar().setUnitIncrement(mgui.INCREMENT); @@ -120,241 +120,245 @@ public class AvatarAnalysisPanel extends TURTLEPanel { //sdp.setVisible(true); //jsp.setVisible(true); //tabbedPane.setSelectedIndex(panels.size()-1); - + 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(mgui.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 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(mgui.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); + + 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); + JScrollDiagramPanel jsp = new JScrollDiagramPanel(ucdp); ucdp.jsp = jsp; jsp.setWheelScrollingEnabled(true); jsp.getVerticalScrollBar().setUnitIncrement(mgui.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) { + + public boolean addAvatarContextDiagram(String s) { JPanel toolBarPanel = new JPanel(); toolBarPanel.setLayout(new BorderLayout()); - - AvatarCDToolBar toolBarACD = new AvatarCDToolBar(mgui); + + 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); + 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.imgic600, 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); + 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.imgic5048, toolBarPanel, "Open the activity diagram of " + s); - + return true; } - - + + public String saveHeaderInXml() { return "<Modeling type=\"Avatar Analysis\" nameTab=\"" + mgui.getTabName(this) + "\" >\n"; } - + public String saveTailInXml() { return "</Modeling>\n\n\n"; } - + public String toString() { return "AVATAR Analysis: " + mgui.getTitleAt(this); } - + public boolean removeEnabled(int index) { - return true; + 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)){ - return true; - } - return false;*/ + return true; + } + return false;*/ } - + public boolean renameEnabled(int index) { - return true; + 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)){ - return true; - } - return false;*/ + return true; + } + return false;*/ } - + public boolean isUCDEnabled() { return true; - } - - public boolean isSDEnabled() { + } + + public boolean isSDEnabled() { return true; - } - + } + public boolean isAvatarCDEnabled() { return true; - } - - public boolean isAvatarADEnabled() { + } + + public boolean isAvatarADEnabled() { return true; - } - - public void addInstancesToLastSD(UseCaseDiagramPanel _ucdp) { - TraceManager.addDev("Adding instances to last SD"); - - TDiagramPanel panel = (TDiagramPanel)(panels.get(panels.size()-1)); - if (!(panel instanceof SequenceDiagramPanel)) { - return; - } - - //TraceManager.addDev("Adding instances to last SD Step 2"); - - ListIterator iterator = _ucdp.getComponentList().listIterator(); - 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 = (TGComponent)(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 - LinkedList <TGComponent> actors = new LinkedList(); - iterator = _ucdp.getComponentList().listIterator(); - int i; - while(iterator.hasNext()) { - tgc = (TGComponent)(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; - SDInstance sdi; - boolean systemAdded = false; - // Add actors (and the system) - for(TGComponent elt: actors) { - if (elt.getX() > middleX && !systemAdded) { - sdi = (SDInstance)(TGComponentManager.addComponent(initX, initY, TGComponentManager.SD_INSTANCE, panel)); - sdi.setValue(systemName); - sdi.setName(systemName); - sdi.setActor(false); - panel.addComponent(sdi, initX, initY, false, true); - initX += stepX; - systemAdded = true; - } - sdi = (SDInstance)(TGComponentManager.addComponent(initX, initY, TGComponentManager.SD_INSTANCE, panel)); - sdi.setValue(elt.getValue()); - sdi.setName(elt.getValue()); - sdi.setActor(true); - panel.addComponent(sdi, initX, initY, false, true); - initX += stepX; - } - - if (!systemAdded) { - sdi = (SDInstance)(TGComponentManager.addComponent(initX, initY, TGComponentManager.SD_INSTANCE, panel)); - 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()); - } -} \ No newline at end of file + } + + public boolean canFirstDiagramBeMoved() { + return true; + } + + public void addInstancesToLastSD(UseCaseDiagramPanel _ucdp) { + TraceManager.addDev("Adding instances to last SD"); + + TDiagramPanel panel = (TDiagramPanel)(panels.get(panels.size()-1)); + if (!(panel instanceof SequenceDiagramPanel)) { + return; + } + + //TraceManager.addDev("Adding instances to last SD Step 2"); + + ListIterator iterator = _ucdp.getComponentList().listIterator(); + 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 = (TGComponent)(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 + LinkedList <TGComponent> actors = new LinkedList(); + iterator = _ucdp.getComponentList().listIterator(); + int i; + while(iterator.hasNext()) { + tgc = (TGComponent)(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; + SDInstance sdi; + boolean systemAdded = false; + // Add actors (and the system) + for(TGComponent elt: actors) { + if (elt.getX() > middleX && !systemAdded) { + sdi = (SDInstance)(TGComponentManager.addComponent(initX, initY, TGComponentManager.SD_INSTANCE, panel)); + sdi.setValue(systemName); + sdi.setName(systemName); + sdi.setActor(false); + panel.addComponent(sdi, initX, initY, false, true); + initX += stepX; + systemAdded = true; + } + sdi = (SDInstance)(TGComponentManager.addComponent(initX, initY, TGComponentManager.SD_INSTANCE, panel)); + sdi.setValue(elt.getValue()); + sdi.setName(elt.getValue()); + sdi.setActor(true); + panel.addComponent(sdi, initX, initY, false, true); + initX += stepX; + } + + if (!systemAdded) { + sdi = (SDInstance)(TGComponentManager.addComponent(initX, initY, TGComponentManager.SD_INSTANCE, panel)); + 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()); + } +} diff --git a/src/ui/AvatarMADsPanel.java b/src/ui/AvatarMADsPanel.java index 4119aaa8c0..3be35dd185 100644 --- a/src/ui/AvatarMADsPanel.java +++ b/src/ui/AvatarMADsPanel.java @@ -149,6 +149,10 @@ public class AvatarMADsPanel extends TURTLEPanel { public boolean isAvatarMADEnabled() { return true; } + + public boolean canFirstDiagramBeMoved() { + return true; + } public boolean removeEnabled(int index) { return true; @@ -157,4 +161,4 @@ public class AvatarMADsPanel extends TURTLEPanel { public boolean renameEnabled(int index) { return true; } -} \ No newline at end of file +} diff --git a/src/ui/AvatarRequirementPanel.java b/src/ui/AvatarRequirementPanel.java index e6c4bab689..384b5b480d 100755 --- a/src/ui/AvatarRequirementPanel.java +++ b/src/ui/AvatarRequirementPanel.java @@ -157,6 +157,10 @@ public class AvatarRequirementPanel extends TURTLEPanel { public String toString() { return mgui.getTitleAt(this) + " (SysML Requirement and Parametric Diagrams)"; } + + public boolean canFirstDiagramBeMoved() { + return true; + } public boolean removeEnabled(int index) { if (panels.size() > 1) { @@ -201,4 +205,4 @@ public class AvatarRequirementPanel extends TURTLEPanel { } -} \ No newline at end of file +} diff --git a/src/ui/TURTLEPanel.java b/src/ui/TURTLEPanel.java index 74d1ea9243..c9d8020ddb 100755 --- a/src/ui/TURTLEPanel.java +++ b/src/ui/TURTLEPanel.java @@ -262,6 +262,10 @@ public abstract class TURTLEPanel implements GenericTree { } } + public boolean canFirstDiagramBeMoved() { + return false; + } + public boolean removeEnabled(int index) { return false; } diff --git a/src/ui/TURTLEPanelPopupListener.java b/src/ui/TURTLEPanelPopupListener.java index 6205738933..d162a3d6f8 100755 --- a/src/ui/TURTLEPanelPopupListener.java +++ b/src/ui/TURTLEPanelPopupListener.java @@ -1,48 +1,48 @@ /**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. - -/** - * Class TURTLEPanelPopupListener - * Management of TURTLE panels - * Creation: 14/01/2005 - * @version 1.0 14/01/2005 - * @author Ludovic APVRILLE - * @see MainGUI - */ + 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 TURTLEPanelPopupListener + * Management of TURTLE panels + * Creation: 14/01/2005 + * @version 1.0 14/01/2005 + * @author Ludovic APVRILLE + * @see MainGUI + */ package ui; @@ -58,17 +58,17 @@ public class TURTLEPanelPopupListener extends MouseAdapter /* popup menus onto t private TURTLEPanel tp; private JPopupMenu menu; protected MainGUI mgui; - - private JMenuItem rename, remove, moveRight, moveLeft, sort, newucd, newsd, newsdfromucd, newreq, - newebrdd, newprosmd, newavatarrd, newavatarpd, newavatarcd, newavatarad, newavatarmad; + + private JMenuItem rename, remove, moveRight, moveLeft, sort, newucd, newsd, newsdfromucd, newreq, + newebrdd, newprosmd, newavatarrd, newavatarpd, newavatarcd, newavatarad, newavatarmad; private JMenuItem newatd; - + public TURTLEPanelPopupListener(TURTLEPanel _tp, MainGUI _mgui) { tp = _tp; mgui = _mgui; createMenu(); } - + public void mousePressed(MouseEvent e) { checkForPopup(e); } @@ -78,7 +78,7 @@ public class TURTLEPanelPopupListener extends MouseAdapter /* popup menus onto t public void mouseClicked(MouseEvent e) { checkForPopup(e); } - + private void checkForPopup(MouseEvent e) { if(e.isPopupTrigger()) { Component c = e.getComponent(); @@ -86,7 +86,7 @@ public class TURTLEPanelPopupListener extends MouseAdapter /* popup menus onto t menu.show(c, e.getX(), e.getY()); } } - + private void createMenu() { rename = createMenuItem("Rename"); remove = createMenuItem("Remove"); @@ -94,18 +94,18 @@ public class TURTLEPanelPopupListener extends MouseAdapter /* popup menus onto t moveRight = createMenuItem("Move to the right"); sort = createMenuItem("Sort"); newucd = createMenuItem("New Use Case Diagram"); - newsd = createMenuItem("New Sequence Diagram"); - newsdfromucd = createMenuItem("New Sequence Diagram (from Use Case Diagram)"); + newsd = createMenuItem("New Sequence Diagram"); + newsdfromucd = createMenuItem("New Sequence Diagram (from Use Case Diagram)"); newreq = createMenuItem("New Requirement Diagram"); - newebrdd = createMenuItem("New Event-Based Requirement Description Diagram"); + newebrdd = createMenuItem("New Event-Based Requirement Description Diagram"); newprosmd = createMenuItem("New ProActive State Machine Diagram"); - newatd = createMenuItem("New Attack Tree Diagram"); - newavatarrd = createMenuItem("New AVATAR Requirement Diagram"); - newavatarpd = createMenuItem("New AVATAR Property Diagram"); - newavatarcd = createMenuItem("New Context Diagram"); - newavatarad = createMenuItem("New Activity Diagram"); - newavatarmad = createMenuItem("New AVATAR Modeling Assumptions Diagram"); - + newatd = createMenuItem("New Attack Tree Diagram"); + newavatarrd = createMenuItem("New AVATAR Requirement Diagram"); + newavatarpd = createMenuItem("New AVATAR Property Diagram"); + newavatarcd = createMenuItem("New Context Diagram"); + newavatarad = createMenuItem("New Activity Diagram"); + newavatarmad = createMenuItem("New AVATAR Modeling Assumptions Diagram"); + menu = new JPopupMenu("TURTLE panel"); menu.add(moveLeft); menu.add(moveRight); @@ -116,133 +116,139 @@ public class TURTLEPanelPopupListener extends MouseAdapter /* popup menus onto t menu.add(sort); menu.addSeparator(); menu.add(newucd); - if (mgui.isAvatarOn()) { - menu.add(newavatarcd); - menu.add(newavatarad); - } - menu.add(newsd); - menu.add(newsdfromucd); + if (mgui.isAvatarOn()) { + menu.add(newavatarcd); + menu.add(newavatarad); + } + menu.add(newsd); + menu.add(newsdfromucd); menu.addSeparator(); menu.add(newreq); - menu.add(newebrdd); - menu.add(newatd); + menu.add(newebrdd); + menu.add(newatd); menu.addSeparator(); menu.add(newprosmd); - if (mgui.isAvatarOn()) { - menu.addSeparator(); - menu.add(newavatarmad); - menu.add(newavatarrd); - menu.add(newavatarpd); - } + if (mgui.isAvatarOn()) { + menu.addSeparator(); + menu.add(newavatarmad); + menu.add(newavatarrd); + menu.add(newavatarpd); + } } - + private JMenuItem createMenuItem(String s) { JMenuItem item = new JMenuItem(s); item.setActionCommand(s); item.addActionListener(listener); return item; } - + private void updateMenu(int index) { //System.out.println("UpdateMenu index=" + index); - if (index < 2) { - moveLeft.setEnabled(false); - } else { - moveLeft.setEnabled(true); + if (tp.canFirstDiagramBeMoved()) { + if (index < 1) { + moveLeft.setEnabled(false); + } else { + moveLeft.setEnabled(true); + } + + if (index + 1 < tp.panels.size()) { + moveRight.setEnabled(true); + } else { + moveRight.setEnabled(false); + } + } else { + if (index < 2) { + moveLeft.setEnabled(false); + } else { + moveLeft.setEnabled(true); + } + + if ((index + 1 < tp.panels.size()) && (index > 0)) { + moveRight.setEnabled(true); + } else { + moveRight.setEnabled(false); + } } - - if ((index + 1 < tp.panels.size()) && (index > 0)) { - moveRight.setEnabled(true); - } else { - moveRight.setEnabled(false); - } - + // remove! - + remove.setEnabled(tp.removeEnabled(index)); rename.setEnabled(tp.renameEnabled(index)); - + if (tp.tabbedPane.getTabCount() < 3) { sort.setEnabled(false); } else { - sort.setEnabled(true); + sort.setEnabled(true); } - + newucd.setEnabled(tp.isUCDEnabled()); - newsd.setEnabled(tp.isSDEnabled()); - newsdfromucd.setEnabled(tp.isSDEnabled() && (mgui.getCurrentTDiagramPanel() instanceof UseCaseDiagramPanel)); + newsd.setEnabled(tp.isSDEnabled()); + newsdfromucd.setEnabled(tp.isSDEnabled() && (mgui.getCurrentTDiagramPanel() instanceof UseCaseDiagramPanel)); newreq.setEnabled(tp.isReqEnabled()); - newebrdd.setEnabled(tp.isReqEnabled()); + newebrdd.setEnabled(tp.isReqEnabled()); newprosmd.setEnabled(tp.isProSMDEnabled()); newatd.setEnabled(tp.isATDEnabled()); - newavatarrd.setEnabled(tp.isAvatarRDEnabled()); - newavatarpd.setEnabled(tp.isAvatarPDEnabled()); - newavatarcd.setEnabled(tp.isAvatarCDEnabled()); - newavatarad.setEnabled(tp.isAvatarADEnabled()); - newavatarmad.setEnabled(tp.isAvatarMADEnabled()); + newavatarrd.setEnabled(tp.isAvatarRDEnabled()); + newavatarpd.setEnabled(tp.isAvatarPDEnabled()); + newavatarcd.setEnabled(tp.isAvatarCDEnabled()); + newavatarad.setEnabled(tp.isAvatarADEnabled()); + newavatarmad.setEnabled(tp.isAvatarMADEnabled()); } - - private Action listener = new AbstractAction() { - - public void actionPerformed(ActionEvent e) { - JMenuItem item = (JMenuItem)e.getSource(); - String ac = item.getActionCommand(); - if(ac.equals("Rename")) { - tp.requestRenameTab(tp.tabbedPane.getSelectedIndex()); - } else if (ac.equals("Remove")) { - tp.requestRemoveTab(tp.tabbedPane.getSelectedIndex()); - } else if (ac.equals("Move to the left")) { - tp.requestMoveLeftTab(tp.tabbedPane.getSelectedIndex()); - } else if (ac.equals("Move to the right")) { - tp.requestMoveRightTab(tp.tabbedPane.getSelectedIndex()); - } else if (ac.equals("Sort")) { - GraphicLib.sortJTabbedPane(tp.tabbedPane, tp.panels, 1, tp.tabbedPane.getTabCount()); - mgui.changeMade(null, -1); - } else if (ac.equals("New Use Case Diagram")) { - mgui.createUniqueUseCaseDiagram(tp, "Use Case Diagram"); - mgui.changeMade(null, -1); - } else if (ac.equals("New Sequence Diagram")) { - mgui.createUniqueSequenceDiagram(tp, "MyScenario"); - mgui.changeMade(null, -1); - } else if (item == newsdfromucd) { - mgui.createSequenceDiagramFromUCD(tp, "ScenarioFromUCD", (UseCaseDiagramPanel)(mgui.getCurrentTDiagramPanel())); - mgui.changeMade(null, -1); - } else if (ac.equals("New Requirement Diagram")) { - mgui.createRequirementDiagram(tp, "Requirement Diagram"); - mgui.changeMade(null, -1); - } else if (ac.equals("New Attack Tree Diagram")) { - mgui.createAttackTreeDiagram(tp, "Attack Tree"); - mgui.changeMade(null, -1); - } else if (ac.equals("New Event-Based Requirement Description Diagram")) { - mgui.createEBRDD(tp, "EBRDD"); - mgui.changeMade(null, -1); - } else if (ac.equals("New ProActive State Machine Diagram")) { - mgui.createProActiveSMD(tp, "ProActive SMD"); - mgui.changeMade(null, -1); - } else if (e.getSource() == newavatarrd) { - mgui.createAvatarRD(tp, "AVATAR RD"); - mgui.changeMade(null, -1); - } else if (e.getSource() == newavatarpd) { - mgui.createAvatarPD(tp, "AVATAR PD"); - mgui.changeMade(null, -1); - } else if (e.getSource() == newavatarcd) { - mgui.createUniqueAvatarCD(tp, "Context Diagram"); - mgui.changeMade(null, -1); - } else if (e.getSource() == newavatarad) { - mgui.createUniqueAvatarAD(tp, "Activity Diagram"); - mgui.changeMade(null, -1); - } else if (e.getSource() == newavatarmad) { - mgui.createAvatarMAD(tp, "Modeling Assumptions Diagram"); - mgui.changeMade(null, -1); - } - } - }; -} - - - - - - + private Action listener = new AbstractAction() { + public void actionPerformed(ActionEvent e) { + JMenuItem item = (JMenuItem)e.getSource(); + String ac = item.getActionCommand(); + if(ac.equals("Rename")) { + tp.requestRenameTab(tp.tabbedPane.getSelectedIndex()); + } else if (ac.equals("Remove")) { + tp.requestRemoveTab(tp.tabbedPane.getSelectedIndex()); + } else if (ac.equals("Move to the left")) { + tp.requestMoveLeftTab(tp.tabbedPane.getSelectedIndex()); + } else if (ac.equals("Move to the right")) { + tp.requestMoveRightTab(tp.tabbedPane.getSelectedIndex()); + } else if (ac.equals("Sort")) { + GraphicLib.sortJTabbedPane(tp.tabbedPane, tp.panels, 1, tp.tabbedPane.getTabCount()); + mgui.changeMade(null, -1); + } else if (ac.equals("New Use Case Diagram")) { + mgui.createUniqueUseCaseDiagram(tp, "Use Case Diagram"); + mgui.changeMade(null, -1); + } else if (ac.equals("New Sequence Diagram")) { + mgui.createUniqueSequenceDiagram(tp, "MyScenario"); + mgui.changeMade(null, -1); + } else if (item == newsdfromucd) { + mgui.createSequenceDiagramFromUCD(tp, "ScenarioFromUCD", (UseCaseDiagramPanel)(mgui.getCurrentTDiagramPanel())); + mgui.changeMade(null, -1); + } else if (ac.equals("New Requirement Diagram")) { + mgui.createRequirementDiagram(tp, "Requirement Diagram"); + mgui.changeMade(null, -1); + } else if (ac.equals("New Attack Tree Diagram")) { + mgui.createAttackTreeDiagram(tp, "Attack Tree"); + mgui.changeMade(null, -1); + } else if (ac.equals("New Event-Based Requirement Description Diagram")) { + mgui.createEBRDD(tp, "EBRDD"); + mgui.changeMade(null, -1); + } else if (ac.equals("New ProActive State Machine Diagram")) { + mgui.createProActiveSMD(tp, "ProActive SMD"); + mgui.changeMade(null, -1); + } else if (e.getSource() == newavatarrd) { + mgui.createAvatarRD(tp, "AVATAR RD"); + mgui.changeMade(null, -1); + } else if (e.getSource() == newavatarpd) { + mgui.createAvatarPD(tp, "AVATAR PD"); + mgui.changeMade(null, -1); + } else if (e.getSource() == newavatarcd) { + mgui.createUniqueAvatarCD(tp, "Context Diagram"); + mgui.changeMade(null, -1); + } else if (e.getSource() == newavatarad) { + mgui.createUniqueAvatarAD(tp, "Activity Diagram"); + mgui.changeMade(null, -1); + } else if (e.getSource() == newavatarmad) { + mgui.createAvatarMAD(tp, "Modeling Assumptions Diagram"); + mgui.changeMade(null, -1); + } + } + }; +} diff --git a/src/ui/ucd/UseCaseDiagramPanel.java b/src/ui/ucd/UseCaseDiagramPanel.java index 15d0372f5e..402095d299 100755 --- a/src/ui/ucd/UseCaseDiagramPanel.java +++ b/src/ui/ucd/UseCaseDiagramPanel.java @@ -1,48 +1,48 @@ /**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. - -/** - * Class UseCasePanel - * Panel for drawing a use case diagram - * Creation: 18/02/2005 - * @version 1.0 18/02/2005 - * @author Ludovic APVRILLE - * @see - */ + 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 UseCasePanel + * Panel for drawing a use case diagram + * Creation: 18/02/2005 + * @version 1.0 18/02/2005 + * @author Ludovic APVRILLE + * @see + */ package ui.ucd; @@ -51,107 +51,107 @@ import java.util.*; import ui.*; public class UseCaseDiagramPanel extends TDiagramPanel { - + public UseCaseDiagramPanel(MainGUI mgui, TToolBar _ttb) { super(mgui, _ttb); /*TDiagramMouseManager tdmm = new TDiagramMouseManager(this); - addMouseListener(tdmm); - addMouseMotionListener(tdmm);*/ + addMouseListener(tdmm); + addMouseMotionListener(tdmm);*/ } - + public boolean actionOnDoubleClick(TGComponent tgc) { //System.out.println("Action"); /*if (tgc instanceof TCDTClass) { - TCDTClass t = (TCDTClass)tgc; - return mgui.newTClassName(t.oldValue, t.getValue()); - } else if (tgc instanceof TCDActivityDiagramBox) { - if (tgc.getFather() instanceof TCDTClass) { - mgui.selectTab(tgc.getFather().getValue()); - } else if (tgc.getFather() instanceof TCDTObject) { - TCDTObject to = (TCDTObject)(tgc.getFather()); - TCDTClass t = to.getMasterTClass(); - if (t != null) { - mgui.selectTab(t.getValue()); - } - } - return false; // because no change made on any diagram - }*/ + TCDTClass t = (TCDTClass)tgc; + return mgui.newTClassName(t.oldValue, t.getValue()); + } else if (tgc instanceof TCDActivityDiagramBox) { + if (tgc.getFather() instanceof TCDTClass) { + mgui.selectTab(tgc.getFather().getValue()); + } else if (tgc.getFather() instanceof TCDTObject) { + TCDTObject to = (TCDTObject)(tgc.getFather()); + TCDTClass t = to.getMasterTClass(); + if (t != null) { + mgui.selectTab(t.getValue()); + } + } + return false; // because no change made on any diagram + }*/ return false; } - + public boolean actionOnAdd(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { - TCDTClass tgcc = (TCDTClass)(tgc); - mgui.addTClass(tgcc.getClassName()); - return true; - }*/ + TCDTClass tgcc = (TCDTClass)(tgc); + mgui.addTClass(tgcc.getClassName()); + return true; + }*/ return false; } - + public boolean actionOnRemove(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { - TCDTClass tgcc = (TCDTClass)(tgc); - mgui.removeTClass(tgcc.getClassName()); - resetAllInstancesOf(tgcc); - return true; - }*/ + TCDTClass tgcc = (TCDTClass)(tgc); + mgui.removeTClass(tgcc.getClassName()); + resetAllInstancesOf(tgcc); + return true; + }*/ return false; } - + public boolean actionOnValueChanged(TGComponent tgc) { /*if (tgc instanceof TCDTClass) { - return actionOnDoubleClick(tgc); - }*/ + return actionOnDoubleClick(tgc); + }*/ return false; } - + public String getXMLHead() { return "<UseCaseDiagramPanel name=\"" + name + "\"" + sizeParam() + " >"; } - + public String getXMLTail() { return "</UseCaseDiagramPanel>"; } - + public String getXMLSelectedHead() { return "<UseCaseDiagramPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; } - + public String getXMLSelectedTail() { return "</UseCaseDiagramPanelCopy>"; } - + public String getXMLCloneHead() { return "<UseCaseDiagramPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; } - + public String getXMLCloneTail() { return "</UseCaseDiagramPanelCopy>"; } - + public void makePostLoadingProcessing() throws MalformedModelingException { TGComponent tgc; - + /*for(int i=0; i<componentList.size(); i++) { - tgc = (TGComponent)(componentList.elementAt(i)); - if (tgc instanceof TCDTObject) { - ((TCDTObject)tgc).postLoadingProcessing(); + tgc = (TGComponent)(componentList.elementAt(i)); + if (tgc instanceof TCDTObject) { + ((TCDTObject)tgc).postLoadingProcessing(); + } + }*/ + } + + public UCDBorder getFirstUCDBorder() { + TGComponent tgc; + + ListIterator iterator = getComponentList().listIterator(); + while(iterator.hasNext()) { + tgc = (TGComponent)(iterator.next()); + if (tgc instanceof UCDBorder) { + return (UCDBorder)tgc; } - }*/ + } + + return null; } - - public UCDBorder getFirstUCDBorder() { - TGComponent tgc; - - ListIterator iterator = getComponentList().listIterator(); - while(iterator.hasNext()) { - tgc = (TGComponent)(iterator.next()); - if (tgc instanceof UCDBorder) { - return (UCDBorder)tgc; - } - } - - return null; - } - -} \ No newline at end of file + +} -- GitLab