From 68fe0aed4ffe605bbd09206f1771438c630c31c9 Mon Sep 17 00:00:00 2001
From: Ludovic Apvrille <ludovic.apvrille@telecom-paristech.fr>
Date: Tue, 15 Mar 2016 14:34:33 +0000
Subject: [PATCH] Commit on deplo. diag modif.

---
 modeling/testavatar.xml     | 102 +++++++++++++-------------
 src/ui/ADDPanel.java        | 142 ++++++++++++++++++------------------
 src/ui/GTURTLEModeling.java |   8 +-
 src/ui/MainGUI.java         |  14 ++++
 4 files changed, 142 insertions(+), 124 deletions(-)

diff --git a/modeling/testavatar.xml b/modeling/testavatar.xml
index 07dd0418d3..612a8e76bc 100644
--- a/modeling/testavatar.xml
+++ b/modeling/testavatar.xml
@@ -784,50 +784,14 @@
 
 
 
-<Modeling type="ADD" nameTab="Deployment" >
+<Modeling type="ADD" nameTab="Deployment1" >
 <ADDDiagramPanel name="Deployment Diagram" minX="10" maxX="2500" minY="10" maxY="1500" attributes="0" masterClockFrequency="200" >
-<COMPONENT type="5361" id="378" >
-<cdparam x="506" y="404" />
+<COMPONENT type="5361" id="326" >
+<cdparam x="464" y="404" />
 <sizeparam width="200" height="200" minWidth="100" minHeight="50" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" />
 <infoparam name="Timer0" value="name" />
-<TGConnectingPoint num="0" id="379" />
-<TGConnectingPoint num="1" id="380" />
-<TGConnectingPoint num="2" id="381" />
-<TGConnectingPoint num="3" id="382" />
-<TGConnectingPoint num="4" id="383" />
-<TGConnectingPoint num="5" id="384" />
-<TGConnectingPoint num="6" id="385" />
-<TGConnectingPoint num="7" id="386" />
-<TGConnectingPoint num="8" id="387" />
-<TGConnectingPoint num="9" id="388" />
-<TGConnectingPoint num="10" id="389" />
-<TGConnectingPoint num="11" id="390" />
-<TGConnectingPoint num="12" id="391" />
-<TGConnectingPoint num="13" id="392" />
-<TGConnectingPoint num="14" id="393" />
-<TGConnectingPoint num="15" id="394" />
-<TGConnectingPoint num="16" id="395" />
-<TGConnectingPoint num="17" id="396" />
-<TGConnectingPoint num="18" id="397" />
-<TGConnectingPoint num="19" id="398" />
-<TGConnectingPoint num="20" id="399" />
-<TGConnectingPoint num="21" id="400" />
-<TGConnectingPoint num="22" id="401" />
-<TGConnectingPoint num="23" id="402" />
-<extraparam>
-<info stereotype="Timer" nodeName="Timer0" />
-<attributes index="0"  nIrq="0" />
-</extraparam>
-</COMPONENT>
-
-<COMPONENT type="5355" id="326" >
-<cdparam x="736" y="325" />
-<sizeparam width="200" height="200" minWidth="100" minHeight="35" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
-<hidden value="false" />
-<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" />
-<infoparam name="Memory0" value="name" />
 <TGConnectingPoint num="0" id="302" />
 <TGConnectingPoint num="1" id="303" />
 <TGConnectingPoint num="2" id="304" />
@@ -853,17 +817,17 @@
 <TGConnectingPoint num="22" id="324" />
 <TGConnectingPoint num="23" id="325" />
 <extraparam>
-<info stereotype="RAM" nodeName="Memory0" />
-<attributes byteDataSize="4"  index="0" />
+<info stereotype="Timer" nodeName="Timer0" />
+<attributes index="0"  nIrq="0" />
 </extraparam>
 </COMPONENT>
 
-<COMPONENT type="5363" id="351" >
-<cdparam x="653" y="90" />
-<sizeparam width="250" height="50" minWidth="100" minHeight="50" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<COMPONENT type="5355" id="351" >
+<cdparam x="854" y="301" />
+<sizeparam width="200" height="200" minWidth="100" minHeight="35" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" />
-<infoparam name="Bus0" value="name" />
+<infoparam name="Memory0" value="name" />
 <TGConnectingPoint num="0" id="327" />
 <TGConnectingPoint num="1" id="328" />
 <TGConnectingPoint num="2" id="329" />
@@ -889,17 +853,17 @@
 <TGConnectingPoint num="22" id="349" />
 <TGConnectingPoint num="23" id="350" />
 <extraparam>
-<info stereotype="VGMN" nodeName="Bus0" />
-<attributes index="0"  nbOfAttachedInitiators="0"  nbOfAttachedTargets="0"  minLatency="0"  fifoDepth="0" />
+<info stereotype="RAM" nodeName="Memory0" />
+<attributes byteDataSize="4"  index="0" />
 </extraparam>
 </COMPONENT>
 
-<COMPONENT type="5351" id="376" >
-<cdparam x="245" y="94" />
-<sizeparam width="250" height="200" minWidth="150" minHeight="100" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<COMPONENT type="5363" id="376" >
+<cdparam x="671" y="87" />
+<sizeparam width="250" height="50" minWidth="100" minHeight="50" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
 <hidden value="false" />
 <cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" />
-<infoparam name="CPU0" value="name" />
+<infoparam name="Bus0" value="name" />
 <TGConnectingPoint num="0" id="352" />
 <TGConnectingPoint num="1" id="353" />
 <TGConnectingPoint num="2" id="354" />
@@ -925,6 +889,42 @@
 <TGConnectingPoint num="22" id="374" />
 <TGConnectingPoint num="23" id="375" />
 <extraparam>
+<info stereotype="VGMN" nodeName="Bus0" />
+<attributes index="0"  nbOfAttachedInitiators="0"  nbOfAttachedTargets="0"  minLatency="0"  fifoDepth="0" />
+</extraparam>
+</COMPONENT>
+
+<COMPONENT type="5351" id="401" >
+<cdparam x="203" y="93" />
+<sizeparam width="250" height="200" minWidth="150" minHeight="100" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" />
+<hidden value="false" />
+<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" />
+<infoparam name="CPU0" value="name" />
+<TGConnectingPoint num="0" id="377" />
+<TGConnectingPoint num="1" id="378" />
+<TGConnectingPoint num="2" id="379" />
+<TGConnectingPoint num="3" id="380" />
+<TGConnectingPoint num="4" id="381" />
+<TGConnectingPoint num="5" id="382" />
+<TGConnectingPoint num="6" id="383" />
+<TGConnectingPoint num="7" id="384" />
+<TGConnectingPoint num="8" id="385" />
+<TGConnectingPoint num="9" id="386" />
+<TGConnectingPoint num="10" id="387" />
+<TGConnectingPoint num="11" id="388" />
+<TGConnectingPoint num="12" id="389" />
+<TGConnectingPoint num="13" id="390" />
+<TGConnectingPoint num="14" id="391" />
+<TGConnectingPoint num="15" id="392" />
+<TGConnectingPoint num="16" id="393" />
+<TGConnectingPoint num="17" id="394" />
+<TGConnectingPoint num="18" id="395" />
+<TGConnectingPoint num="19" id="396" />
+<TGConnectingPoint num="20" id="397" />
+<TGConnectingPoint num="21" id="398" />
+<TGConnectingPoint num="22" id="399" />
+<TGConnectingPoint num="23" id="400" />
+<extraparam>
 <info stereotype="CPU" nodeName="CPU0" />
 <attributes nbOfIrq="6"  iCacheWays="0"  iCacheSets="0"  iCacheWords="0"  dCacheWays="0"  dCacheSets="0"  dCacheWords="0" />
 </extraparam>
diff --git a/src/ui/ADDPanel.java b/src/ui/ADDPanel.java
index 3420e76bbf..e4f99484a4 100755
--- a/src/ui/ADDPanel.java
+++ b/src/ui/ADDPanel.java
@@ -1,49 +1,49 @@
 /**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 ADDPanel
- * Managenemt of Avatar architecture panels
- * Creation: 01/07/2014
- * @version 1.0 01/07/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 ADDPanel
+   * Managenemt of Avatar architecture panels
+   * Creation: 01/07/2014
+   * @version 1.0 01/07/2014
+   * @author Ludovic APVRILLE
+   * @see MainGUI
+   */
+
 package ui;
 
 import java.awt.*;
@@ -53,40 +53,40 @@ import java.util.*;
 import ui.avatardd.*;
 
 public class ADDPanel extends TURTLEPanel {
-    public ADDDiagramPanel tmladd; 
+    public ADDDiagramPanel tmladd;
     public Vector validated, ignored;
-    
+
     public ADDPanel(MainGUI _mgui) {
         super(_mgui);
         tabbedPane = new JTabbedPane();
         cl = new ChangeListener() {
-            public void stateChanged(ChangeEvent e){
-                mgui.paneDesignAction(e);
-            }
-        };
+                public void stateChanged(ChangeEvent e){
+                    mgui.paneDesignAction(e);
+                }
+            };
         tabbedPane.addChangeListener(cl);
         tabbedPane.addMouseListener(new TURTLEPanelPopupListener(this, mgui));
     }
-    
+
     public void init() {
-         addDeploymentPanelDiagram("Deployment Diagram");
- 
+        addDeploymentPanelDiagram("Deployment Diagram");
+
     }
-    
+
     public boolean addDeploymentPanelDiagram(String s) {
         ADDDiagramToolBar toolBar = new ADDDiagramToolBar(mgui);
         toolbars.add(toolBar);
-        
+
         toolBarPanel = new JPanel();
         toolBarPanel.setLayout(new BorderLayout());
-        
-        //Class	diagram
+
+        //Class diagram
         tmladd = new ADDDiagramPanel(mgui, toolBar);
         tmladd.setName("Deployment Diagram");
         tmladd.tp = this;
         tdp = tmladd;
         panels.add(tmladd); // Always first in list
-        JScrollDiagramPanel jsp	= new JScrollDiagramPanel(tmladd);
+        JScrollDiagramPanel jsp = new JScrollDiagramPanel(tmladd);
         tmladd.jsp = jsp;
         jsp.setWheelScrollingEnabled(true);
         jsp.getVerticalScrollBar().setUnitIncrement(mgui.INCREMENT);
@@ -94,26 +94,26 @@ public class ADDPanel extends TURTLEPanel {
         toolBarPanel.add(jsp, BorderLayout.CENTER);
         tabbedPane.addTab("Deployment Diagram", IconManager.imgic60, toolBarPanel, "Opens deployment diagram");
         tabbedPane.setSelectedIndex(0);
-      
+
         return true;
-    } 
-    
+    }
+
     public String saveHeaderInXml() {
-        return "<Modeling type=\"ADD\" nameTab=\"" + mgui.getTabName(this) + "\" >\n"; 
+        return "<Modeling type=\"ADD\" nameTab=\"" + mgui.getTabName(this) + "\" >\n";
     }
-    
+
     public String saveTailInXml() {
         return "</Modeling>\n\n\n";
     }
-    
+
     public String toString() {
         return mgui.getTitleAt(this) + " (deployment diagram)";
     }
-	
-	public void renameDeployment(String oldName, String newName) {
-		/*if (tmladd != null) {
-			tmladd.renameDeployment(oldName, newName);
-		}*/
-	}
-    
+
+    public void renameDeployment(String oldName, String newName) {
+        /*if (tmladd != null) {
+          tmladd.renameDeployment(oldName, newName);
+          }*/
+    }
+
 }
diff --git a/src/ui/GTURTLEModeling.java b/src/ui/GTURTLEModeling.java
index cf3de0ef52..cbd1b42608 100755
--- a/src/ui/GTURTLEModeling.java
+++ b/src/ui/GTURTLEModeling.java
@@ -4918,8 +4918,12 @@ public class GTURTLEModeling {
         TraceManager.addDev("ADD 3.1");
 
         if (tdp == null) {
-            TraceManager.addDev("ADD 3.2");
-            throw new MalformedModelingException();
+	    // Try to get the first diagram of the panel
+	    tdp = mgui.getAvatarADDPanelByIndex(indexAnalysis, indexTab);
+	    if (tdp == null) {
+		TraceManager.addDev("ADD 3.2");
+		throw new MalformedModelingException();
+	    }
         }
         tdp.removeAll();
         TraceManager.addDev("ADD 4");
diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java
index ccd2289fb7..fd95edb5fa 100755
--- a/src/ui/MainGUI.java
+++ b/src/ui/MainGUI.java
@@ -6359,6 +6359,11 @@ public  class MainGUI implements ActionListener, WindowListener, KeyListener, Pe
         return getAvatarADDPanel(tp, indexTab, s);
     }
 
+     public ADDDiagramPanel getAvatarADDPanelByIndex(int index, int indexTab) {
+        TURTLEPanel tp = (TURTLEPanel)(tabs.elementAt(index));
+        return getAvatarADDPanelByIndex(tp, indexTab);
+    }
+
 
     public AvatarPDPanel getAvatarPDPanel(TURTLEPanel tp, int indexTab, String s) {
         if(tp.tabbedPane.getTitleAt(indexTab).equals(s)) {
@@ -6376,6 +6381,15 @@ public  class MainGUI implements ActionListener, WindowListener, KeyListener, Pe
         return null;
     }
 
+    public ADDDiagramPanel getAvatarADDPanelByIndex(TURTLEPanel tp, int indexTab) {
+        //TraceManager.addDev("index=" + indexTab + " s=" + s + "title=" +tp.tabbedPane.getTitleAt(indexTab));
+
+        //if(tp.tabbedPane.getTitleAt(indexTab).equals(s)) {
+            return (ADDDiagramPanel)(tp.panelAt(indexTab));
+	    //}
+        
+    }
+
     public AvatarCDPanel getAvatarCDPanel(int index, int indexTab, String s) {
         TURTLEPanel tp = (TURTLEPanel)(tabs.elementAt(index));
         return getAvatarCDPanel(tp, indexTab, s);
-- 
GitLab