From dba8971128b0f2de6acffdc554caac2e539da40e Mon Sep 17 00:00:00 2001
From: Daniela Genius <genius@debussy.soc.lip6.fr>
Date: Thu, 17 May 2018 19:56:19 +0200
Subject: [PATCH] merge syscams

---
 .../SysCAMSSpecification.java                 |   150 +
 .../syscamstranslator/SysCAMSTBlockDE.java    |    72 +
 .../syscamstranslator/SysCAMSTBlockTDF.java   |    82 +
 .../syscamstranslator/SysCAMSTCluster.java    |    63 +
 .../syscamstranslator/SysCAMSTComponent.java  |    58 +
 .../SysCAMSTConnectingPoint.java              |    72 +
 .../syscamstranslator/SysCAMSTConnector.java  |    65 +
 .../SysCAMSTPortConverter.java                |   112 +
 .../syscamstranslator/SysCAMSTPortDE.java     |   112 +
 .../syscamstranslator/SysCAMSTPortTDF.java    |   112 +
 src/main/java/ui/ActionPerformer.java         |    22 +-
 src/main/java/ui/TGUIAction.java              |    16 +-
 src/main/java/ui/syscams/SysCAMSBlockDE.java  |    67 +
 src/main/java/ui/syscams/SysCAMSBlockTDF.java |    76 +
 .../ui/syscams/SysCAMSChannelFacility.java    |   180 +
 .../ui/syscams/SysCAMSChannelOutPort.java     |    68 +
 .../SysCAMSComponentTaskDiagramPanel.java     |  1261 ++
 .../SysCAMSComponentTaskDiagramToolBar.java   |   124 +
 .../ui/syscams/SysCAMSCompositeComponent.java |   633 +
 .../java/ui/syscams/SysCAMSCompositePort.java |   325 +
 src/main/java/ui/syscams/SysCAMSFork.java     |   111 +
 src/main/java/ui/syscams/SysCAMSJoin.java     |   115 +
 src/main/java/ui/syscams/SysCAMSPath.java     |   360 +
 .../syscams/SysCAMSPortConnectingPoint.java   |    64 +
 .../java/ui/syscams/SysCAMSPortConnector.java |   139 +
 .../java/ui/syscams/SysCAMSPortConverter.java |    57 +
 src/main/java/ui/syscams/SysCAMSPortDE.java   |    62 +
 src/main/java/ui/syscams/SysCAMSPortTDF.java  |    62 +
 .../ui/syscams/SysCAMSPrimitiveComponent.java |   620 +
 .../java/ui/syscams/SysCAMSPrimitivePort.java |   878 ++
 .../ui/syscams/SysCAMSRecordComponent.java    |   420 +
 .../SysCAMSReferencePortConnectingPoint.java  |   122 +
 .../SysCAMSRemoteCompositeComponent.java      |   596 +
 .../SysCAMSRemotePortCompositeComponent.java  |   138 +
 src/main/java/ui/util/IconManager.java        |    17 +-
 .../java/ui/window/JDialogSysCAMSBlockDE.java |   196 +
 .../ui/window/JDialogSysCAMSBlockTDF.java     |   238 +
 .../window/JDialogSysCAMSPortConverter.java   |   301 +
 .../java/ui/window/JDialogSysCAMSPortDE.java  |   297 +
 .../java/ui/window/JDialogSysCAMSPortTDF.java |   297 +
 src/main/resources/ui/GTURTLEModeling.java    | 10035 ++++++++++++++++
 src/main/resources/ui/MainGUI.java            |  9127 ++++++++++++++
 src/main/resources/ui/TDiagramPanel.java      |  3643 ++++++
 src/main/resources/ui/TGUIAction.java         |  1326 ++
 .../resources/ui/syscams/SysCAMSBlockDE.java  |    67 +
 .../resources/ui/syscams/SysCAMSBlockTDF.java |    76 +
 .../ui/syscams/SysCAMSChannelFacility.java    |   180 +
 .../ui/syscams/SysCAMSChannelOutPort.java     |    68 +
 .../SysCAMSComponentTaskDiagramPanel.java     |  1261 ++
 .../SysCAMSComponentTaskDiagramToolBar.java   |   124 +
 .../ui/syscams/SysCAMSCompositeComponent.java |   633 +
 .../ui/syscams/SysCAMSCompositePort.java      |   325 +
 .../resources/ui/syscams/SysCAMSFork.java     |   111 +
 .../resources/ui/syscams/SysCAMSJoin.java     |   115 +
 .../resources/ui/syscams/SysCAMSPath.java     |   360 +
 .../syscams/SysCAMSPortConnectingPoint.java   |    64 +
 .../ui/syscams/SysCAMSPortConnector.java      |   139 +
 .../ui/syscams/SysCAMSPortConverter.java      |    57 +
 .../resources/ui/syscams/SysCAMSPortDE.java   |    62 +
 .../resources/ui/syscams/SysCAMSPortTDF.java  |    62 +
 .../ui/syscams/SysCAMSPrimitiveComponent.java |   620 +
 .../ui/syscams/SysCAMSPrimitivePort.java      |   878 ++
 .../ui/syscams/SysCAMSRecordComponent.java    |   420 +
 .../SysCAMSReferencePortConnectingPoint.java  |   122 +
 .../SysCAMSRemoteCompositeComponent.java      |   596 +
 .../SysCAMSRemotePortCompositeComponent.java  |   138 +
 .../resources/ui/util/camsconverterportE.gif  |   Bin 0 -> 132 bytes
 .../resources/ui/util/camsconverterportN.gif  |   Bin 0 -> 111 bytes
 .../resources/ui/util/camsconverterportS.gif  |   Bin 0 -> 111 bytes
 .../resources/ui/util/camsconverterportW.gif  |   Bin 0 -> 132 bytes
 src/main/resources/ui/util/camsdeport.gif     |   Bin 0 -> 119 bytes
 src/main/resources/ui/util/camstdfport.gif    |   Bin 0 -> 132 bytes
 72 files changed, 39359 insertions(+), 10 deletions(-)
 create mode 100644 src/main/java/syscamstranslator/SysCAMSSpecification.java
 create mode 100644 src/main/java/syscamstranslator/SysCAMSTBlockDE.java
 create mode 100644 src/main/java/syscamstranslator/SysCAMSTBlockTDF.java
 create mode 100644 src/main/java/syscamstranslator/SysCAMSTCluster.java
 create mode 100644 src/main/java/syscamstranslator/SysCAMSTComponent.java
 create mode 100644 src/main/java/syscamstranslator/SysCAMSTConnectingPoint.java
 create mode 100644 src/main/java/syscamstranslator/SysCAMSTConnector.java
 create mode 100644 src/main/java/syscamstranslator/SysCAMSTPortConverter.java
 create mode 100644 src/main/java/syscamstranslator/SysCAMSTPortDE.java
 create mode 100644 src/main/java/syscamstranslator/SysCAMSTPortTDF.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSBlockDE.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSBlockTDF.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSChannelFacility.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSChannelOutPort.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSComponentTaskDiagramPanel.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSCompositeComponent.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSCompositePort.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSFork.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSJoin.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSPath.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSPortConnectingPoint.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSPortConnector.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSPortConverter.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSPortDE.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSPortTDF.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSPrimitiveComponent.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSPrimitivePort.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSRecordComponent.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSReferencePortConnectingPoint.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSRemoteCompositeComponent.java
 create mode 100644 src/main/java/ui/syscams/SysCAMSRemotePortCompositeComponent.java
 create mode 100644 src/main/java/ui/window/JDialogSysCAMSBlockDE.java
 create mode 100644 src/main/java/ui/window/JDialogSysCAMSBlockTDF.java
 create mode 100644 src/main/java/ui/window/JDialogSysCAMSPortConverter.java
 create mode 100644 src/main/java/ui/window/JDialogSysCAMSPortDE.java
 create mode 100644 src/main/java/ui/window/JDialogSysCAMSPortTDF.java
 create mode 100755 src/main/resources/ui/GTURTLEModeling.java
 create mode 100644 src/main/resources/ui/MainGUI.java
 create mode 100755 src/main/resources/ui/TDiagramPanel.java
 create mode 100755 src/main/resources/ui/TGUIAction.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSBlockDE.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSBlockTDF.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSChannelFacility.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSChannelOutPort.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSComponentTaskDiagramPanel.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSCompositeComponent.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSCompositePort.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSFork.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSJoin.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSPath.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSPortConnectingPoint.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSPortConnector.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSPortConverter.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSPortDE.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSPortTDF.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSPrimitiveComponent.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSPrimitivePort.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSRecordComponent.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSReferencePortConnectingPoint.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSRemoteCompositeComponent.java
 create mode 100644 src/main/resources/ui/syscams/SysCAMSRemotePortCompositeComponent.java
 create mode 100644 src/main/resources/ui/util/camsconverterportE.gif
 create mode 100644 src/main/resources/ui/util/camsconverterportN.gif
 create mode 100644 src/main/resources/ui/util/camsconverterportS.gif
 create mode 100644 src/main/resources/ui/util/camsconverterportW.gif
 create mode 100644 src/main/resources/ui/util/camsdeport.gif
 create mode 100644 src/main/resources/ui/util/camstdfport.gif

diff --git a/src/main/java/syscamstranslator/SysCAMSSpecification.java b/src/main/java/syscamstranslator/SysCAMSSpecification.java
new file mode 100644
index 0000000000..e188ae7d11
--- /dev/null
+++ b/src/main/java/syscamstranslator/SysCAMSSpecification.java
@@ -0,0 +1,150 @@
+/* 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 syscamstranslator;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Creation: 07/05/2018
+ * @version 1.0 07/05/2018
+ * @author Irina Kit Yan LEE
+*/
+
+public class SysCAMSSpecification{
+    private List<SysCAMSTComponent> components;
+    private List<SysCAMSTConnector> connectors;
+		
+    public SysCAMSSpecification(List<SysCAMSTComponent> _components, List<SysCAMSTConnector> _connectors){
+		components = _components ;
+		connectors = _connectors ;
+	}
+    
+    public List<SysCAMSTComponent> getComponents(){
+      return components;
+    }
+
+    public List<SysCAMSTConnector> getConnectors(){
+      return connectors;
+    }
+
+    public LinkedList<SysCAMSTBlockTDF> getAllBlockTDF(){
+		LinkedList<SysCAMSTBlockTDF> blocksTDF = new LinkedList<SysCAMSTBlockTDF>();
+		for (SysCAMSTComponent blockTDF : components) {
+			if (blockTDF instanceof SysCAMSTBlockTDF) {
+				blocksTDF.add((SysCAMSTBlockTDF) blockTDF);
+			}
+		}
+		return blocksTDF;
+    }
+    
+    public LinkedList<SysCAMSTBlockDE> getAllBlockDE(){
+    	LinkedList<SysCAMSTBlockDE> blocksDE = new LinkedList<SysCAMSTBlockDE>();
+    	for (SysCAMSTComponent blockDE : components) {
+    		if (blockDE instanceof SysCAMSTBlockDE) {
+    			blocksDE.add((SysCAMSTBlockDE) blockDE);
+    		}
+    	}
+    	return blocksDE;
+    }
+    
+    public LinkedList<SysCAMSTCluster> getAllCluster(){
+    	LinkedList<SysCAMSTCluster> clusters = new LinkedList<SysCAMSTCluster>();
+    	for (SysCAMSTComponent cluster : components) {
+    		if (cluster instanceof SysCAMSTCluster) {
+    			clusters.add((SysCAMSTCluster) cluster);
+    		}
+    	}
+    	return clusters;
+    }
+    
+    public LinkedList<SysCAMSTPortConverter> getAllPortConverter(){
+    	LinkedList<SysCAMSTPortConverter> portsConv = new LinkedList<SysCAMSTPortConverter>();
+    	for (SysCAMSTComponent portConv : components) {
+    		if (portConv instanceof SysCAMSTPortConverter) {
+    			portsConv.add((SysCAMSTPortConverter) portConv);
+    		}
+    	}
+    	return portsConv;
+    }
+    
+    public LinkedList<SysCAMSTPortTDF> getAllPortTDF(){
+    	LinkedList<SysCAMSTPortTDF> portsTDF = new LinkedList<SysCAMSTPortTDF>();
+    	for (SysCAMSTComponent portTDF : components) {
+    		if (portTDF instanceof SysCAMSTPortTDF) {
+    			portsTDF.add((SysCAMSTPortTDF) portTDF);
+    		}
+    	}
+    	return portsTDF;
+    }
+    
+    public LinkedList<SysCAMSTPortDE> getAllPortDE(){
+    	LinkedList<SysCAMSTPortDE> portsDE = new LinkedList<SysCAMSTPortDE>();
+    	for (SysCAMSTComponent portDE : components) {
+    		if (portDE instanceof SysCAMSTPortDE) {
+    			portsDE.add((SysCAMSTPortDE) portDE);
+    		}
+    	}
+    	return portsDE;
+    }
+   
+    public int getNbBlockTDF(){
+      return (getAllBlockTDF()).size();
+    }
+
+    public int getNbBlocDE(){
+      return (getAllBlockDE()).size();
+    }
+
+    public int getNbCluster(){
+      return (getAllCluster()).size();
+    } 
+    
+    public int getNbPortConverter(){
+      return (getAllPortConverter()).size();
+    }
+
+    public int getNbPortTDF(){
+      return (getAllPortTDF()).size();
+    }
+
+    public int getNbPortDE(){
+      return (getAllPortDE()).size();
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/syscamstranslator/SysCAMSTBlockDE.java b/src/main/java/syscamstranslator/SysCAMSTBlockDE.java
new file mode 100644
index 0000000000..6696aa5d1f
--- /dev/null
+++ b/src/main/java/syscamstranslator/SysCAMSTBlockDE.java
@@ -0,0 +1,72 @@
+/* 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 syscamstranslator;
+
+/**
+ * Creation: 07/05/2018
+ * @version 1.0 07/05/2018
+ * @author Irina Kit Yan LEE
+*/
+
+public class SysCAMSTBlockDE extends SysCAMSTComponent {
+
+	private String blockDEName;
+	private int period;
+	
+	public SysCAMSTBlockDE(String _blockDEName, int _period) {
+		blockDEName = _blockDEName;
+		period = _period;
+	}
+
+	public int getPeriod() {
+		return period;
+	}
+
+	public void setPeriod(int _period) {
+		period = _period;
+	}
+
+	public String getBlockDEName() {
+		return blockDEName;
+	}
+
+	public void setBlockDEName(String _blockDEName) {
+		blockDEName = _blockDEName;
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/syscamstranslator/SysCAMSTBlockTDF.java b/src/main/java/syscamstranslator/SysCAMSTBlockTDF.java
new file mode 100644
index 0000000000..d7d449fd1d
--- /dev/null
+++ b/src/main/java/syscamstranslator/SysCAMSTBlockTDF.java
@@ -0,0 +1,82 @@
+/* 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 syscamstranslator;
+
+/**
+ * Creation: 07/05/2018
+ * @version 1.0 07/05/2018
+ * @author Irina Kit Yan LEE
+*/
+
+public class SysCAMSTBlockTDF extends SysCAMSTComponent {
+
+	private String blockTDFName;
+	private int period;
+	private String processCode;
+	
+	public SysCAMSTBlockTDF(String _blockTDFName, int _period, String _processCode) {
+		blockTDFName = _blockTDFName;
+		period = _period;
+		processCode = _processCode;
+	}
+
+	public int getPeriod() {
+		return period;
+	}
+
+	public void setPeriod(int _period) {
+		period = _period;
+	}
+
+	public String getProcessCode() {
+		return processCode;
+	}
+
+	public void setProcessCode(String _processCode) {
+		processCode = _processCode;
+	}
+
+	public String getBlockTDFName() {
+		return blockTDFName;
+	}
+
+	public void setBlockTDFName(String _blockTDFName) {
+		blockTDFName = _blockTDFName;
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/syscamstranslator/SysCAMSTCluster.java b/src/main/java/syscamstranslator/SysCAMSTCluster.java
new file mode 100644
index 0000000000..0d82f3673e
--- /dev/null
+++ b/src/main/java/syscamstranslator/SysCAMSTCluster.java
@@ -0,0 +1,63 @@
+/* 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 syscamstranslator;
+
+/**
+ * Creation: 07/05/2018
+ * @version 1.0 07/05/2018
+ * @author Irina Kit Yan LEE
+*/
+
+public class SysCAMSTCluster extends SysCAMSTComponent {
+
+	private String clusterName;
+	
+	public SysCAMSTCluster(String _clusterName) {
+		super();
+		clusterName = _clusterName;
+	}
+
+	public String getClusterName() {
+		return clusterName;
+	}
+
+	public void setClusterName(String _clusterName) {
+		clusterName = _clusterName;
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/syscamstranslator/SysCAMSTComponent.java b/src/main/java/syscamstranslator/SysCAMSTComponent.java
new file mode 100644
index 0000000000..5a4b606380
--- /dev/null
+++ b/src/main/java/syscamstranslator/SysCAMSTComponent.java
@@ -0,0 +1,58 @@
+/* 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 syscamstranslator;
+
+/**
+ * Creation: 07/05/2018
+ * @version 1.0 07/05/2018
+ * @author Irina Kit Yan LEE
+*/
+
+public class SysCAMSTComponent {
+
+	public String name;
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String _name) {
+		name = _name;
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/syscamstranslator/SysCAMSTConnectingPoint.java b/src/main/java/syscamstranslator/SysCAMSTConnectingPoint.java
new file mode 100644
index 0000000000..194e01efd7
--- /dev/null
+++ b/src/main/java/syscamstranslator/SysCAMSTConnectingPoint.java
@@ -0,0 +1,72 @@
+/* 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 syscamstranslator;
+
+/**
+ * Creation: 07/05/2018
+ * @version 1.0 07/05/2018
+ * @author Irina Kit Yan LEE
+*/
+
+public class SysCAMSTConnectingPoint{
+    
+	SysCAMSTConnector ownerConnector ;
+    SysCAMSTComponent ownerComponent;
+    
+    public SysCAMSTConnectingPoint( SysCAMSTComponent _ownerComponent)
+    {
+      ownerComponent = _ownerComponent;
+    }
+
+    SysCAMSTConnector getConnector(){
+      return ownerConnector;
+    }
+
+    public SysCAMSTComponent getComponent(){
+      return ownerComponent;
+    }
+
+    void setConnector(SysCAMSTConnector _connector){
+      ownerConnector = _connector;
+    }
+    
+    boolean ConnectingPointIsFree(){
+      return  ownerConnector == null;
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/syscamstranslator/SysCAMSTConnector.java b/src/main/java/syscamstranslator/SysCAMSTConnector.java
new file mode 100644
index 0000000000..96ea213429
--- /dev/null
+++ b/src/main/java/syscamstranslator/SysCAMSTConnector.java
@@ -0,0 +1,65 @@
+/* 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 syscamstranslator;
+
+/**
+ * Creation: 07/05/2018
+ * @version 1.0 07/05/2018
+ * @author Irina Kit Yan LEE
+*/
+
+public class SysCAMSTConnector{
+    
+    private SysCAMSTConnectingPoint connectingPoint1;
+    private SysCAMSTConnectingPoint connectingPoint2;
+
+    public SysCAMSTConnector(SysCAMSTConnectingPoint _connectingPoint1, SysCAMSTConnectingPoint _connectingPoint2){
+      
+      connectingPoint1 = _connectingPoint1;
+      connectingPoint2 = _connectingPoint2; 
+    }
+
+    public SysCAMSTConnectingPoint get_p1(){
+      return connectingPoint1;
+    }
+
+    public SysCAMSTConnectingPoint get_p2(){
+      return connectingPoint2;
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/syscamstranslator/SysCAMSTPortConverter.java b/src/main/java/syscamstranslator/SysCAMSTPortConverter.java
new file mode 100644
index 0000000000..a367d8cfa0
--- /dev/null
+++ b/src/main/java/syscamstranslator/SysCAMSTPortConverter.java
@@ -0,0 +1,112 @@
+/* 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 syscamstranslator;
+
+/**
+ * Creation: 07/05/2018
+ * @version 1.0 07/05/2018
+ * @author Irina Kit Yan LEE
+*/
+
+public class SysCAMSTPortConverter extends SysCAMSTComponent {
+
+	private String name;
+	private int period;
+	private int rate;
+	private int delay;
+	private String origin;
+	private String ConvType;
+	
+	public SysCAMSTPortConverter(String _name, int _period, int _rate, int _delay, String _origin, String _ConvType) {
+		name = _name;
+		period = _period;
+		rate = _rate;
+		delay = _delay;
+		origin = _origin;
+		ConvType = _ConvType;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String _name) {
+		name = _name;
+	}
+
+	public int getPeriod() {
+		return period;
+	}
+
+	public void setPeriod(int _period) {
+		period = _period;
+	}
+
+	public int getRate() {
+		return rate;
+	}
+
+	public void setRate(int _rate) {
+		rate = _rate;
+	}
+
+	public int getDelay() {
+		return delay;
+	}
+
+	public void setDelay(int _delay) {
+		delay = _delay;
+	}
+
+	public String getOrigin() {
+		return origin;
+	}
+
+	public void setOrigin(String _origin) {
+		origin = _origin;
+	}
+
+	public String getConvType() {
+		return ConvType;
+	}
+
+	public void setConvType(String _ConvType) {
+		ConvType = _ConvType;
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/syscamstranslator/SysCAMSTPortDE.java b/src/main/java/syscamstranslator/SysCAMSTPortDE.java
new file mode 100644
index 0000000000..f1ec45a4f7
--- /dev/null
+++ b/src/main/java/syscamstranslator/SysCAMSTPortDE.java
@@ -0,0 +1,112 @@
+/* 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 syscamstranslator;
+
+/**
+ * Creation: 07/05/2018
+ * @version 1.0 07/05/2018
+ * @author Irina Kit Yan LEE
+*/
+
+public class SysCAMSTPortDE extends SysCAMSTComponent {
+
+	private String name;
+	private int period;
+	private int rate;
+	private int delay;
+	private String origin;
+	private String DEType;
+	
+	public SysCAMSTPortDE(String _name, int _period, int _rate, int _delay, String _origin, String _DEType) {
+		name = _name;
+		period = _period;
+		rate = _rate;
+		delay = _delay;
+		origin = _origin;
+		DEType = _DEType;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String _name) {
+		name = _name;
+	}
+
+	public int getPeriod() {
+		return period;
+	}
+
+	public void setPeriod(int _period) {
+		period = _period;
+	}
+
+	public int getRate() {
+		return rate;
+	}
+
+	public void setRate(int _rate) {
+		rate = _rate;
+	}
+
+	public int getDelay() {
+		return delay;
+	}
+
+	public void setDelay(int _delay) {
+		delay = _delay;
+	}
+
+	public String getOrigin() {
+		return origin;
+	}
+
+	public void setOrigin(String _origin) {
+		origin = _origin;
+	}
+
+	public String getDEType() {
+		return DEType;
+	}
+
+	public void setDEType(String _DEType) {
+		DEType = _DEType;
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/syscamstranslator/SysCAMSTPortTDF.java b/src/main/java/syscamstranslator/SysCAMSTPortTDF.java
new file mode 100644
index 0000000000..03145f137b
--- /dev/null
+++ b/src/main/java/syscamstranslator/SysCAMSTPortTDF.java
@@ -0,0 +1,112 @@
+/* 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 syscamstranslator;
+
+/**
+ * Creation: 07/05/2018
+ * @version 1.0 07/05/2018
+ * @author Irina Kit Yan LEE
+*/
+
+public class SysCAMSTPortTDF extends SysCAMSTComponent {
+
+	private String name;
+	private int period;
+	private int rate;
+	private int delay;
+	private String origin;
+	private String TDFType;
+	
+	public SysCAMSTPortTDF(String _name, int _period, int _rate, int _delay, String _origin, String _TDFType) {
+		name = _name;
+		period = _period;
+		rate = _rate;
+		delay = _delay;
+		origin = _origin;
+		TDFType = _TDFType;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String _name) {
+		name = _name;
+	}
+
+	public int getPeriod() {
+		return period;
+	}
+
+	public void setPeriod(int _period) {
+		period = _period;
+	}
+
+	public int getRate() {
+		return rate;
+	}
+
+	public void setRate(int _rate) {
+		rate = _rate;
+	}
+
+	public int getDelay() {
+		return delay;
+	}
+
+	public void setDelay(int _delay) {
+		delay = _delay;
+	}
+
+	public String getOrigin() {
+		return origin;
+	}
+
+	public void setOrigin(String _origin) {
+		origin = _origin;
+	}
+
+	public String getTDFType() {
+		return TDFType;
+	}
+
+	public void setTDFType(String _TDFType) {
+		TDFType = _TDFType;
+	}
+}
diff --git a/src/main/java/ui/ActionPerformer.java b/src/main/java/ui/ActionPerformer.java
index 0e6085e0ea..22750ac639 100755
--- a/src/main/java/ui/ActionPerformer.java
+++ b/src/main/java/ui/ActionPerformer.java
@@ -908,16 +908,26 @@ public class ActionPerformer {
         } else if (command.equals(mgui.actions[TGUIAction.TMLSD_ACTION_STATE].getActionCommand())) {
             mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLSD_ACTION_STATE);
 
-	    //SystemC AMS
-	} else if (command.equals(mgui.actions[TGUIAction.CAMS_EDIT].getActionCommand())) {
+	    	// SystemC-AMS
+        } else if (command.equals(mgui.actions[TGUIAction.CAMS_EDIT].getActionCommand())) {
             mgui.actionOnButton(TGComponentManager.EDIT, -1);
-	} else if (command.equals(mgui.actions[TGUIAction.CAMS_BLOCK].getActionCommand())) {
-            mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.CAMS_BLOCK);
+        } /*else if (command.equals(mgui.actions[TGUIAction.CAMS_BLOCK_TDF].getActionCommand())) {
+	         mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.CAMS_BLOCK_TDF);
+        } else if (command.equals(mgui.actions[TGUIAction.CAMS_BLOCK_DE].getActionCommand())) {
+        	mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.CAMS_BLOCK_DE);
         } else if (command.equals(mgui.actions[TGUIAction.CAMS_CONNECTOR].getActionCommand())) {
-	    mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.CAMS_CONNECTOR);
+        	mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.CAMS_CONNECTOR);
+        } else if (command.equals(mgui.actions[TGUIAction.CAMS_PORT_TDF].getActionCommand())) {
+        	mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.CAMS_PORT_TDF);
+        } else if (command.equals(mgui.actions[TGUIAction.CAMS_PORT_DE].getActionCommand())) {
+        	mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.CAMS_PORT_DE);
+        } else if (command.equals(mgui.actions[TGUIAction.CAMS_PORT_CONVERTER].getActionCommand())) {
+        	mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.CAMS_PORT_CONVERTER);
+        } else if (command.equals(mgui.actions[TGUIAction.CAMS_CLUSTER].getActionCommand())) {
+        	mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.CAMS_CLUSTER);
 
             // Attack Tree Diagrams
-        } else if (command.equals(mgui.actions[TGUIAction.ATD_BLOCK].getActionCommand())) {
+	    } */ else if (command.equals(mgui.actions[TGUIAction.ATD_BLOCK].getActionCommand())) {
             mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ATD_BLOCK);
         } else if (command.equals(mgui.actions[TGUIAction.ATD_ATTACK].getActionCommand())) {
             mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ATD_ATTACK);
diff --git a/src/main/java/ui/TGUIAction.java b/src/main/java/ui/TGUIAction.java
index b28909c4b3..5aadb346b1 100755
--- a/src/main/java/ui/TGUIAction.java
+++ b/src/main/java/ui/TGUIAction.java
@@ -276,8 +276,13 @@ public class TGUIAction extends AbstractAction {
     public static final int TMLSD_EDIT = 391;
 
     public static final int CAMS_EDIT = 458;
-    public static final int CAMS_BLOCK = 459;
+    public static final int CAMS_BLOCK_TDF = 459;
     public static final int CAMS_CONNECTOR = 460;
+    public static final int CAMS_BLOCK_DE = 475;
+    public static final int CAMS_PORT_TDF = 476;
+    public static final int CAMS_PORT_DE = 477;
+    public static final int CAMS_PORT_CONVERTER = 478;
+    public static final int CAMS_CLUSTER = 479;
 
     public static final int EBRDD_EDIT = 271;
     public static final int EBRDD_CONNECTOR = 272;
@@ -631,7 +636,7 @@ public class TGUIAction extends AbstractAction {
     public static final int MOVE_ENABLED = 463;
     public static final int FIRST_DIAGRAM = 464;
     
-    public static final int NB_ACTION = 476;
+    public static final int NB_ACTION = 480;
 
     private static final TAction [] actions = new TAction[NB_ACTION];
 
@@ -1090,8 +1095,13 @@ public class TGUIAction extends AbstractAction {
 
         //System C-AMS
         actions[CAMS_EDIT] = new TAction("add-action-C-AMS", "Action state", IconManager.imgic100, IconManager.imgic101, "Action state", "Add an action state to the currently opened SystemC-AMS diagram", 0);
-        actions[CAMS_BLOCK] = new TAction("C-AMS-block", "Add a block", IconManager.imgic5000, IconManager.imgic5000, "Block", "Add a Block to the currently opened SystemC-AMS Diagram", 0);
+        actions[CAMS_BLOCK_TDF] = new TAction("C-AMS-block-TDF", "Add a TDF block", IconManager.imgic5000, IconManager.imgic5000, "TDF block", "Add a TDF block to the currently opened SystemC-AMS Diagram", 0);
+        actions[CAMS_BLOCK_DE] = new TAction("C-AMS-block-DE", "Add a DE block", IconManager.imgic5000, IconManager.imgic5000, "DE block", "Add a DE block to the currently opened SystemC-AMS Diagram", 0);
         actions[CAMS_CONNECTOR] = new TAction("C-AMS-connector", "Add a connection", IconManager.imgic202, IconManager.imgic202, "Connector", "Connects two block of the currently opened SystemC-AMS Diagram", 0);
+        actions[CAMS_PORT_TDF] = new TAction("C-AMS-port-TDF", "Add a TDF port", IconManager.imgic8000, IconManager.imgic8000, "TDF port", "Add a TDF port to the currently opened SystemC-AMS Diagram", 0);
+        actions[CAMS_PORT_DE] = new TAction("C-AMS-port-DE", "Add a DE port", IconManager.imgic8001, IconManager.imgic8001, "DE port", "Add a DE port to the currently opened SystemC-AMS Diagram", 0);
+        actions[CAMS_PORT_CONVERTER] = new TAction("C-AMS-port-converter", "Add a converter port", IconManager.imgic8003, IconManager.imgic8003, "Converter port", "Add a converter port to the currently opened SystemC-AMS Diagram", 0);
+        actions[CAMS_CLUSTER] = new TAction("C-AMS-cluster", "Add a cluster", IconManager.imgic5000, IconManager.imgic5000, "Cluster", "Add a cluster to the currently opened SystemC-AMS Diagram", 0);
 
 
         //ProActive State Machine Diagram
diff --git a/src/main/java/ui/syscams/SysCAMSBlockDE.java b/src/main/java/ui/syscams/SysCAMSBlockDE.java
new file mode 100644
index 0000000000..27cb244370
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSBlockDE.java
@@ -0,0 +1,67 @@
+/* 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.syscams;
+
+import ui.TDiagramPanel;
+import ui.TGComponent;
+
+/**
+ * Class SysCAMSBlockDE
+ * Primitive Component. To be used in SystemC-AMS component task diagrams 
+ * Creation: 23/04/2018
+ * @version 1.0 23/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSBlockDE extends SysCAMSPrimitiveComponent {
+	private int period;
+
+	public SysCAMSBlockDE(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos,
+			TGComponent _father, TDiagramPanel _tdp) {
+		super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+	}
+
+	public int getPeriod() {
+		return period;
+	}
+
+	public void setPeriod(int period) {
+		this.period = period;
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSBlockTDF.java b/src/main/java/ui/syscams/SysCAMSBlockTDF.java
new file mode 100644
index 0000000000..a354f6566f
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSBlockTDF.java
@@ -0,0 +1,76 @@
+/* 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.syscams;
+
+import ui.TDiagramPanel;
+import ui.TGComponent;
+
+/**
+ * Class SysCAMSBlockTDF
+ * Primitive Component. To be used in SystemC-AMS component task diagrams 
+ * Creation: 23/04/2018
+ * @version 1.0 23/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSBlockTDF extends SysCAMSPrimitiveComponent {
+	private int period;
+	private String processCode;
+
+	public SysCAMSBlockTDF(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos,
+			TGComponent _father, TDiagramPanel _tdp) {
+		super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+	}
+
+	public String getProcessCode() {
+		return processCode;
+	}
+
+	public void setProcessCode(String processCode) {
+		this.processCode = processCode;
+	}
+
+	public int getPeriod() {
+		return period;
+	}
+
+	public void setPeriod(int period) {
+		this.period = period;
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSChannelFacility.java b/src/main/java/ui/syscams/SysCAMSChannelFacility.java
new file mode 100644
index 0000000000..3ac59014a0
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSChannelFacility.java
@@ -0,0 +1,180 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+import ui.*;
+
+import java.awt.*;
+
+/**
+ * Class SysCAMSChannelFacility
+ * Channel facility. To be used in SystemC-AMS component task diagrams
+ * Creation: 22/04/2018
+ * @version 1.0 22/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public abstract class SysCAMSChannelFacility extends TGCScalableWithInternalComponent {
+    protected Color myColor, portColor;
+
+    protected SysCAMSPrimitivePort inp, outp;
+    protected int inpIndex, outpIndex;
+    protected boolean conflict = false;
+    protected String conflictMessage;
+
+    public SysCAMSChannelFacility(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+
+        minWidth = 10;
+        minHeight = 10;
+
+        moveable = true;
+        editable = false;
+        removable = true;
+        userResizable = false;
+    }
+
+    public TGComponent isOnOnlyMe(int _x, int _y) {
+        if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) {
+            return this;
+        }
+        return null;
+    }
+
+    public void calculatePortColor() {
+        if (conflict) {
+            myColor = Color.red;
+        } else {
+            SysCAMSPrimitivePort port = inp;
+            if (port == null) {
+                port = outp;
+            }
+            if (port == null) {
+                portColor = null;
+                if (myColor == null) {
+                    myColor = new Color(251, 252, 155- (getMyDepth() * 10));
+                }
+            } else {
+                int typep = port.getPortType();
+                if (typep == 0) {
+                    myColor = ColorManager.TML_PORT_CHANNEL;
+                } else if (typep == 1) {
+                    myColor = ColorManager.TML_PORT_EVENT;
+                } else {
+                    myColor = ColorManager.TML_PORT_REQUEST;
+                }
+            }
+        }
+        portColor = myColor;
+    }
+
+    public void setInPort(SysCAMSPrimitivePort _inp) {
+        inp = _inp;
+        calculatePortColor();
+    }
+
+    public void setOutPort(SysCAMSPrimitivePort _outp) {
+        outp = _outp;
+        calculatePortColor();
+    }
+
+    public SysCAMSPrimitivePort getInPort() {
+        return inp;
+    }
+
+    public SysCAMSPrimitivePort getOutPort() {
+        return outp;
+    }
+
+    public int getInpIndex() {
+        return inpIndex;
+    }
+
+    public int getOutpIndex() {
+        return outpIndex;
+    }
+
+    public void setInpIndex(int _inpIndex) {
+        inpIndex = _inpIndex;
+    }
+
+    public void setOutpIndex(int _outpIndex) {
+        outpIndex = _outpIndex;
+    }
+
+    public boolean getConflict() {
+        return conflict;
+    }
+
+    public void setConflict(boolean _conflict, String _msg) {
+        conflict = _conflict;
+        myColor = null;
+        conflictMessage = _msg;
+        calculatePortColor();
+    }
+
+    public int getDefaultConnector() {
+        return TGComponentManager.CONNECTOR_PORT_TMLC;
+    }
+
+    public Color getPortColor() {
+        return portColor;
+    }
+
+    public String getAttributes() {
+        if (conflict) {
+            return conflictMessage;
+        }
+        String s = "";
+        if (inp != null) {
+            s = s + inp.getAttributes();
+            if (outp != null) {
+                s = s + "\n";
+            }
+        }
+        if (outp != null) {
+            s = s + outp.getAttributes();
+        }
+        if (conflict) {
+            s += "Error in path=" + conflict;
+        }
+        return s;
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSChannelOutPort.java b/src/main/java/ui/syscams/SysCAMSChannelOutPort.java
new file mode 100644
index 0000000000..ed1f34c0f9
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSChannelOutPort.java
@@ -0,0 +1,68 @@
+/* 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.syscams;
+
+import ui.TDiagramPanel;
+import ui.TGComponent;
+import ui.TGComponentManager;
+
+import java.awt.*;
+
+/**
+ * Class SysCAMSChannelOutPort
+ * Channel out port. To be used in SystemC-AMS component task diagrams
+ * Creation: 22/04/2018
+ * @version 1.0 22/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSChannelOutPort extends SysCAMSPrimitivePort {
+    public SysCAMSChannelOutPort(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+        
+		initConnectingPoint(true, true, 1);
+    }
+	
+	public void drawParticularity(Graphics g) {
+	}
+	
+    public int getType() {
+        return TGComponentManager.TMLCTD_COPORT;
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramPanel.java b/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramPanel.java
new file mode 100644
index 0000000000..1d834b9153
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramPanel.java
@@ -0,0 +1,1261 @@
+/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici
+ *
+ * ludovic.apvrille AT enst.fr
+ * andrea.enrici 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.syscams;
+
+import myutil.TraceManager;
+import org.w3c.dom.Element;
+import ui.*;
+
+import java.util.*;
+
+/**
+ * Class SysCAMSComponentTaskDiagramPanel
+ * Panel for drawing SystemC-AMS elements
+ * Creation: 27/04/2018
+ * @version 1.0 27/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+@SuppressWarnings("serial")
+
+public class SysCAMSComponentTaskDiagramPanel extends TDiagramPanel implements TDPWithAttributes {
+
+    public SysCAMSComponentTaskDiagramPanel(MainGUI mgui, TToolBar _ttb) {
+        super(mgui, _ttb);
+    }
+
+    public boolean actionOnDoubleClick(TGComponent tgc) {
+        return false;
+    }
+
+    public boolean actionOnAdd(TGComponent tgc) {
+        if (tgc instanceof SysCAMSPrimitiveComponent) {
+            return true;
+        } 
+        if (tgc instanceof SysCAMSCompositePort) {
+            if (tgc.getFather() instanceof SysCAMSCompositeComponent) {
+                getMGUI().updateReferenceToSysCAMSCompositeComponent((SysCAMSCompositeComponent)(tgc.getFather()));
+            }
+        }
+
+        return true;
+    }
+
+    public boolean actionOnRemove(TGComponent tgc) {
+        if (tgc instanceof SysCAMSPortConnector) {
+            updatePorts();
+        }
+        if (tgc instanceof SysCAMSPrimitivePort) {
+            updatePorts();
+        }
+
+        if (tgc instanceof SysCAMSChannelFacility) {
+            updatePorts();
+        }
+
+        if (tgc instanceof SysCAMSCompositePort) {
+            updatePorts();
+            if (fatherOfRemoved instanceof SysCAMSCompositeComponent) {
+                getMGUI().updateReferenceToSysCAMSCompositeComponent((SysCAMSCompositeComponent)(fatherOfRemoved));
+            }
+        }
+
+        return true;
+    }
+
+    public List<SysCAMSPrimitivePort> getPortsByName(String name){
+        List<SysCAMSPrimitivePort> ports = new ArrayList<SysCAMSPrimitivePort>();
+        for (TGComponent tgc : componentList){
+
+            if (tgc instanceof SysCAMSPrimitiveComponent){
+                SysCAMSPrimitiveComponent comp = (SysCAMSPrimitiveComponent) tgc;
+                List<SysCAMSPrimitivePort> cps = comp.getAllTDFOriginPorts();
+                for (SysCAMSPrimitivePort port : cps){
+                    if (port.commName.equals(name)){
+                        ports.add(port);
+                    }
+                }
+                cps = comp.getAllTDFDestinationPorts();
+                for (SysCAMSPrimitivePort port : cps){
+                    if (port.commName.equals(name)){
+                        ports.add(port);
+                    }
+                }
+            }
+            if (tgc instanceof SysCAMSPrimitiveComponent){
+            	SysCAMSPrimitiveComponent comp = (SysCAMSPrimitiveComponent) tgc;
+            	List<SysCAMSPrimitivePort> cps = comp.getAllDEOriginPorts();
+            	for (SysCAMSPrimitivePort port : cps){
+            		if (port.commName.equals(name)){
+            			ports.add(port);
+            		}
+            	}
+            	cps = comp.getAllDEDestinationPorts();
+            	for (SysCAMSPrimitivePort port : cps){
+            		if (port.commName.equals(name)){
+            			ports.add(port);
+            		}
+            	}
+            }
+        }
+        return ports;
+    }
+
+    public boolean actionOnValueChanged(TGComponent tgc) {
+        if (tgc instanceof SysCAMSPrimitiveComponent) {
+            SysCAMSPrimitiveComponent t = (SysCAMSPrimitiveComponent)tgc;
+            mgui.newSysCAMSTaskName(tp, t.oldValue, t.getValue());
+            return true;
+        }
+        if (tgc instanceof SysCAMSCompositeComponent) {
+            SysCAMSCompositeComponent syscamscc = (SysCAMSCompositeComponent)tgc;
+            getMGUI().updateReferenceToSysCAMSCompositeComponent(syscamscc);
+        }
+        return true;
+    }
+
+    public boolean renamePrimitiveComponent(String oldValue, String newValue) {
+        return mgui.newSysCAMSComponentTaskName(tp, oldValue, newValue);
+    }
+
+    public boolean namePrimitiveComponentInUse(String oldValue, String newValue) {
+        boolean ko = mgui.nameComponentInUse(tp, oldValue, newValue);
+        return ko ? ko : nameAllRecordComponentInUse(oldValue, newValue);
+    }
+
+    public boolean nameRecordComponentInUse(String oldValue, String newValue) {
+        boolean ko = mgui.nameComponentInUse(tp, oldValue, newValue);
+        return ko? ko : nameAllRecordComponentInUse(oldValue, newValue);
+    }
+
+    public boolean isCompositeNameUsed(String newvalue) {
+        for (TGComponent tgc: this.componentList) {
+            if (tgc.getValue().equals(newvalue))
+                return true;
+        }
+        return false;
+    }
+
+    public boolean nameAllRecordComponentInUse(String oldValue, String newValue) {
+        Iterator<SysCAMSRecordComponent> iterator = getRecordComponentList().listIterator();
+        SysCAMSRecordComponent record;
+
+        while(iterator.hasNext()) {
+            record = iterator.next();
+            if (record.getName().compareTo(newValue) == 0) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public LinkedList<SysCAMSRecordComponent> getRecordComponentList() {
+        LinkedList<SysCAMSRecordComponent> ll = new LinkedList<SysCAMSRecordComponent>();
+        TGComponent tgc;
+
+        Iterator<TGComponent> iterator = componentList.listIterator();
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+            if (tgc instanceof SysCAMSRecordComponent) {
+                ll.add((SysCAMSRecordComponent) tgc);
+            }
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                ll.addAll(((SysCAMSCompositeComponent)tgc).getAllRecordComponents());
+            }
+            if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+                ll.addAll(((SysCAMSRemoteCompositeComponent)tgc).getAllRecordComponents());
+            }
+        }
+        return ll;
+    }
+
+    public List<SysCAMSPrimitiveComponent> getPrimitiveComponentList() {
+        List<SysCAMSPrimitiveComponent> ll = new LinkedList<SysCAMSPrimitiveComponent>();
+        TGComponent tgc;
+
+        Iterator<TGComponent> iterator = componentList.listIterator();
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+
+            if (tgc instanceof SysCAMSPrimitiveComponent) {
+                ll.add( (SysCAMSPrimitiveComponent) tgc );
+            }
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                ll.addAll(((SysCAMSCompositeComponent)tgc).getAllPrimitiveComponents());
+            }
+            if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+                ll.addAll(((SysCAMSRemoteCompositeComponent)tgc).getAllPrimitiveComponents());
+            }
+        }
+        return ll;
+    }
+
+    public List<SysCAMSPrimitivePort> getPortsConnectedTo(SysCAMSPrimitivePort _port, List<? extends TGComponent> componentsToTakeIntoAccount) {
+        List<TGComponent> ll;
+        List<SysCAMSPrimitivePort> ret = new LinkedList<SysCAMSPrimitivePort>();
+        Object o;
+        SysCAMSPrimitivePort p;
+
+        ll = getAllPortsConnectedTo(_port);
+        Iterator<TGComponent> li = ll.listIterator();
+
+        while(li.hasNext()) {
+            o = li.next();
+
+            if (o instanceof SysCAMSPrimitivePort) {
+                p = (SysCAMSPrimitivePort)o;
+
+                if (p.getFather() instanceof SysCAMSPrimitiveComponent) {
+                    if (componentsToTakeIntoAccount.contains(p.getFather())) {
+                        ret.add( p );
+                    }
+                }
+            }
+        }
+        return ret;
+    }
+
+    public List<TGComponent> getAllPortsConnectedTo(SysCAMSPrimitivePort _port) {
+        List<TGComponent> ll = new LinkedList<TGComponent>();
+        getAllPortsConnectedTo( ll, _port );
+        return ll;
+    }
+
+//    public List<String> getAllSysCAMSCommunicationNames(String _topname) {
+//        List<String> al = new ArrayList<String>();
+//
+//        SysCAMSPrimitiveComponent syscamsc;
+//        List<SysCAMSPrimitiveComponent> components = getPrimitiveComponentList();
+//        Iterator<SysCAMSPrimitiveComponent> iterator = components.listIterator();
+//        Iterator<SysCAMSPrimitivePort> li;//, li2;
+//        List<SysCAMSPrimitivePort> ports, portstome;
+//        String name, name1, name2;
+//        SysCAMSPrimitivePort port1, port2;
+//
+//        int j;
+//
+//        while( iterator.hasNext() ) {
+//            syscamsc = iterator.next();
+//            ports = syscamsc.getAllChannelsOriginPorts();
+//            li = ports.listIterator();
+//            while( li.hasNext() ) {
+//                port1 = li.next();
+//                portstome = getPortsConnectedTo( port1, components );
+//                Iterator<SysCAMSPrimitivePort> ite = portstome.listIterator();
+//
+//                while( ite.hasNext()) {
+//                    port2 = ite.next();
+//                    if (!port2.isOrigin()) {
+//                        String []text1 = port1.getPortName().split( "," );
+//                        String []text2 = port2.getPortName().split( "," );
+//                        for ( j = 0; j < Math.min( text1.length, text2.length ); j++ ) {
+//                            name1 = text1[j].trim();
+//                            name2 = text2[j].trim();
+//                            if( name1.equals( name2 ) ) {
+//                                name = name1;
+//                            }
+//                            else {
+//                                name = name1 + "__" + name2;
+//                            }
+//                            al.add( _topname + "::" + name );
+//                        }
+//                    }
+//                }
+//            }
+//        }
+//        return al;
+//    }
+//
+//    public List<String> getAllSysCAMSInputPorts( String _topname ) {   //the destination ports
+//        //Use HashSet to avoid returning multiple identical ports due to the presence of join nodes
+//        Set<String> al = new HashSet<String>();
+//        SysCAMSPrimitiveComponent syscamsc;
+//        List<SysCAMSPrimitiveComponent> components = getPrimitiveComponentList();
+//        Iterator<SysCAMSPrimitiveComponent> iterator = components.listIterator();
+//        Iterator<SysCAMSPrimitivePort> li;//, li2;
+//        List<SysCAMSPrimitivePort> ports, portstome;
+//        String name2;
+//        SysCAMSPrimitivePort port1, port2;
+//        int j;
+//
+//        while( iterator.hasNext() ) {
+//            syscamsc = iterator.next();
+//            ports = syscamsc.getAllChannelsOriginPorts();
+//            li = ports.listIterator();
+//            while( li.hasNext() ) {
+//                port1 = li.next();
+//                portstome = getPortsConnectedTo( port1, components );   //this prints the ports via TraceManager
+//                Iterator<SysCAMSPrimitivePort> ite = portstome.listIterator();
+//                while( ite.hasNext()) {
+//                    port2 = ite.next();
+//                    if( !port2.isOrigin() ) {
+//                        String []text1 = port1.getPortName().split( "," );
+//                        String []text2 = port2.getPortName().split( "," );
+//                        for( j = 0; j < Math.min( text1.length, text2.length ); j++ ) {
+//                            name2 = text2[j].trim();
+//                            al.add( _topname + "::" + name2 );
+//                        }
+//                    }
+//                }
+//            }
+//        }
+//        return new ArrayList<String>(al);
+//    }
+//
+//    public List<String> getAllSysCAMSEventNames( String _topname ) {
+//
+//        List<String> al = new ArrayList<String>();
+//        SysCAMSPrimitiveComponent syscamsc;
+//        List<SysCAMSPrimitiveComponent> components = getPrimitiveComponentList();
+//        Iterator<SysCAMSPrimitiveComponent> iterator = components.listIterator();
+//        Iterator<SysCAMSPrimitivePort> li;//, li2;
+//        List<SysCAMSPrimitivePort> ports, portstome;
+//        String name, name1, name2;
+//        SysCAMSPrimitivePort port1, port2;
+//        int j;
+//
+//        while( iterator.hasNext() ) {
+//            syscamsc = iterator.next() ;
+//            ports = syscamsc.getAllEventsOriginPorts();
+//            li = ports.listIterator();
+//            while( li.hasNext() ) {
+//                port1 = li.next();
+//                portstome = getPortsConnectedTo( port1, components );
+//                if ( portstome.size() == 1 ) {
+//                    port2 = portstome.get(0);
+//                    String []text1 = port1.getPortName().split( "," );
+//                    String []text2 = port2.getPortName().split( "," );
+//                    for ( j = 0; j < Math.min( text1.length, text2.length ); j++ ) {
+//                        name1 = text1[j].trim();
+//                        name2 = text2[j].trim();
+//                        if( name1.equals( name2 ) ) {
+//                            name = name1;
+//                        }
+//                        else {
+//                            name = name1 + "__" + name2;
+//                        }
+//                        al.add( _topname + "::" + name );
+//                    }
+//                }
+//            }
+//        }
+//        return al;
+//    }
+
+    public void getAllPortsConnectedTo( List<TGComponent> ll, SysCAMSPrimitivePort _port) {
+        List<TGComponent> components = getMGUI().getAllSysCAMSComponents();
+        Iterator<TGComponent> iterator = components.listIterator();
+        TGComponent tgc, tgc1, tgc2;
+        SysCAMSPortConnector portco;
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+
+            if (tgc instanceof SysCAMSPortConnector) {
+                portco = (SysCAMSPortConnector)tgc;
+                tgc1 = getComponentToWhichBelongs(components, portco.getTGConnectingPointP1());
+                tgc2 = getComponentToWhichBelongs(components, portco.getTGConnectingPointP2());
+                if ((tgc1 != null) && (tgc2 != null)) {
+                    if (tgc1 instanceof SysCAMSRemoteCompositeComponent) {
+                        tgc1 = ((SysCAMSRemoteCompositeComponent)tgc1).getPortOf(portco.getTGConnectingPointP1());
+                    }
+
+                    if (tgc2 instanceof SysCAMSRemoteCompositeComponent) {
+                        tgc2 = ((SysCAMSRemoteCompositeComponent)tgc2).getPortOf(portco.getTGConnectingPointP2());
+                    }
+                    if ((!ll.contains(tgc2) && (tgc2 != _port) && ((tgc1 == _port) || (ll.contains(tgc1))))) {
+                        ll.add(tgc2);
+                        iterator = components.listIterator();
+                    } else {
+                        if ((!ll.contains(tgc1) && (tgc1 != _port) && ((tgc2 == _port) || (ll.contains(tgc2))))) {
+                            ll.add(tgc1);
+                            iterator = components.listIterator();
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public String getXMLHead() {
+        return "<SysCAMSComponentTaskDiagramPanel name=\"" + name + "\"" + sizeParam() + displayParam() + zoomParam() +" >";
+    }
+
+    public String getXMLTail() {
+        return "</SysCAMSComponentTaskDiagramPanel>";
+    }
+
+    public String getXMLSelectedHead() {
+        return "<SysCAMSComponentTaskDiagramPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >";
+    }
+
+    public String getXMLSelectedTail() {
+        return "</SysCAMSComponentTaskDiagramPanelCopy>";
+    }
+
+    public String getXMLCloneHead() {
+        return "<SysCAMSComponentTaskDiagramPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >";
+    }
+
+    public String getXMLCloneTail() {
+        return "</SysCAMSComponentTaskDiagramPanelCopy>";
+    }
+
+    public boolean areAttributesVisible() {
+        return attributesVisible;
+    }
+
+    public boolean areChannelVisible() {
+        return synchroVisible;
+    }
+
+    public void setAttributesVisible(boolean b) {
+        attributesVisible = b;
+    }
+
+
+    public void setChannelVisible(boolean b) {
+        channelVisible = b;
+    }
+
+    public String displayParam() {
+        String s = "";
+        if (channelsVisible) {
+            s += " TDF=\"true\"";
+        } else {
+            s += " TDF=\"false\"";
+        }
+        if (eventsVisible) {
+            s += " DE=\"true\"";
+        } else {
+            s += " DE=\"false\"";
+        }
+        return s;
+    }
+
+    public ArrayList<String> getAllCompositeComponent(String _name) {
+        ArrayList<String> list = new ArrayList<String>();
+        TGComponent tgc1;
+        String s;
+        SysCAMSCompositeComponent syscamscc;
+        Iterator<TGComponent> iterator = componentList.listIterator();
+
+        while(iterator.hasNext()) {
+            tgc1 = iterator.next();
+
+            if (tgc1 instanceof SysCAMSCompositeComponent) {
+                syscamscc = (SysCAMSCompositeComponent)tgc1;
+                s = _name + "::" + syscamscc.getValue();
+                list.add(s);
+                syscamscc.getAllCompositeComponents(list, _name);
+            }
+        }
+        return list;
+    }
+
+    public String[] getCompOutTDF(){
+        List<String> chls = new ArrayList<String>();
+        TGComponent tgc;
+        Iterator<TGComponent> iterator = componentList.listIterator();
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+            if (tgc instanceof SysCAMSPrimitiveComponent) {
+                SysCAMSPrimitiveComponent comp = (SysCAMSPrimitiveComponent) tgc;
+                List<SysCAMSPrimitivePort> ll = comp.getAllTDFOriginPorts();
+                Iterator<SysCAMSPrimitivePort> ite = ll.listIterator();
+                while(ite.hasNext()) {
+                    SysCAMSPrimitivePort port = ite.next();
+                    chls.add(port.getPortName());
+                }
+            }
+        }
+        String[] chlArray = new String[chls.size()];
+        chlArray = chls.toArray(chlArray);
+        return chlArray;
+    }
+
+    public String[] getCompInTDF(){
+        List<String> chls = new ArrayList<String>();
+        TGComponent tgc;
+        Iterator<TGComponent> iterator = componentList.listIterator();
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+            if (tgc instanceof SysCAMSPrimitiveComponent) {
+                SysCAMSPrimitiveComponent comp = (SysCAMSPrimitiveComponent) tgc;
+                List<SysCAMSPrimitivePort> ll = comp.getAllTDFDestinationPorts();
+                Iterator<SysCAMSPrimitivePort> ite = ll.listIterator();
+                while(ite.hasNext()) {
+                    SysCAMSPrimitivePort port = ite.next();
+                    chls.add(port.getPortName());
+                }
+            }
+        }
+        String[] chlArray = new String[chls.size()];
+        chlArray = chls.toArray(chlArray);
+        return chlArray;
+    }
+
+    public SysCAMSPrimitiveComponent getPrimitiveComponentByName(String _name) {
+        TGComponent tgc;
+        Iterator<TGComponent> iterator = componentList.listIterator();
+        SysCAMSPrimitiveComponent tmp;
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+            if (tgc instanceof SysCAMSPrimitiveComponent) {
+                if (tgc.getValue().equals(_name)) {
+                    return ((SysCAMSPrimitiveComponent)tgc);
+                }
+            }
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                tmp = ((SysCAMSCompositeComponent)tgc).getPrimitiveComponentByName(_name);
+                if (tmp != null) {
+                    return tmp;
+                }
+            }
+            if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+                tmp = ((SysCAMSRemoteCompositeComponent)tgc).getPrimitiveComponentByName(_name);
+                if (tmp != null) {
+                    return tmp;
+                }
+            }
+        }
+        return null;
+    }
+
+    public void updateReferenceToSysCAMSCompositeComponent(SysCAMSCompositeComponent syscamscc) {
+        Iterator<TGComponent> iterator = componentList.listIterator();
+        TGComponent tgc;
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                ((SysCAMSCompositeComponent)tgc).updateReferenceToSysCAMSCompositeComponent(syscamscc);
+            }
+
+            if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+                ((SysCAMSRemoteCompositeComponent)tgc).updateReference(syscamscc);
+            }
+        }
+    }
+
+    public SysCAMSCompositeComponent getCompositeComponentByName(String _name) {
+        TGComponent tgc;
+        Iterator<TGComponent> iterator = componentList.listIterator();
+        SysCAMSCompositeComponent tmp;
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                tmp = (SysCAMSCompositeComponent)tgc;
+                if (tmp.getValue().equals(_name)) {
+                    return tmp;
+                }
+
+                if ((tmp = tmp.getCompositeComponentByName(name)) != null) {
+                    return tmp;
+                }
+            }
+        }
+        return null;
+    }
+
+    public void hideConnectors() {
+        Iterator<TGComponent> iterator = componentList.listIterator();
+        SysCAMSPortConnector connector;
+        TGComponent tgc;
+        TGComponent tgc1;
+        TGComponent tgc2;
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+
+            if (tgc instanceof SysCAMSPortConnector) {
+                connector = (SysCAMSPortConnector) tgc;
+                tgc1 = getComponentToWhichBelongs(connector.getTGConnectingPointP1());
+                tgc2 = getComponentToWhichBelongs(connector.getTGConnectingPointP2());
+                if ((tgc1 != null) && (tgc2 != null)) {
+                    if (tgc1.hasAnHiddenAncestor()) {
+                        tgc.setHidden(true);
+                    } else {
+                        if (tgc2.hasAnHiddenAncestor()) {
+                            tgc.setHidden(true);
+                        } else {
+                            tgc.setHidden(false);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public void loadExtraParameters(Element elt) {
+    }
+
+    public void setConnectorsToFront() {
+        TGComponent tgc;
+        Iterator<TGComponent> iterator = componentList.listIterator();
+        List<TGComponent> list = new ArrayList<TGComponent>();
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+            if (!(tgc instanceof TGConnector)) {
+                list.add(tgc);
+            }
+        }
+        for(TGComponent tgc1: list) {
+            componentList.remove(tgc1);
+            componentList.add(tgc1);
+        }
+    }
+
+    public void delayedLoad() {
+        Iterator<TGComponent> iterator;
+        TGComponent tgc;
+
+        iterator = componentList.listIterator();
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                ((SysCAMSCompositeComponent)(tgc)).delayedLoad();
+            }
+
+            if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+                try {
+                    ((SysCAMSRemoteCompositeComponent)(tgc)).delayedLoad();
+                } catch (Exception e) {
+                }
+            }
+        }
+    }
+
+    // Returns the faulty paths
+    public ArrayList<SysCAMSPath> updatePorts() {
+        List<SysCAMSPath> paths = makePaths();
+        ArrayList<SysCAMSPath> faultyPaths = new ArrayList<SysCAMSPath>();
+
+        // Checking rules of paths, and setting colors accordingly
+        for(SysCAMSPath path: paths) {
+            path.checkRules();
+            if (path.hasError()) {
+                TraceManager.addDev("Path error:" + path.getErrorMessage());
+                faultyPaths.add(path);
+            }
+            path.setColor();
+        }
+        return faultyPaths;
+    }
+
+    public void updatePorts_oldVersion() {
+        Iterator<TGComponent> iterator;
+        TGComponent tgc;
+
+        // Get all SysCAMSPrimitivePort
+        List<SysCAMSCompositePort> ports = new ArrayList<SysCAMSCompositePort>();
+        List<SysCAMSCompositePort> referencedports = new ArrayList<SysCAMSCompositePort>();
+        List<SysCAMSPrimitivePort> pports = new ArrayList<SysCAMSPrimitivePort>();
+        List<SysCAMSChannelFacility> facilities = new ArrayList<SysCAMSChannelFacility>();
+
+        iterator = componentList.listIterator();
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                ports.addAll(((SysCAMSCompositeComponent)tgc).getAllInternalCompositePorts());
+                pports.addAll(((SysCAMSCompositeComponent)tgc).getAllInternalPrimitivePorts());
+                referencedports.addAll(((SysCAMSCompositeComponent)tgc).getAllReferencedCompositePorts());
+            }
+            if (tgc instanceof SysCAMSPrimitiveComponent) {
+                pports.addAll(((SysCAMSPrimitiveComponent)tgc).getAllInternalPrimitivePorts());
+            }
+            if (tgc instanceof SysCAMSCompositePort) {
+                ports.add((SysCAMSCompositePort)tgc);
+            }
+            if (tgc instanceof SysCAMSPrimitivePort) {
+                pports.add((SysCAMSPrimitivePort)tgc);
+            }
+            if (tgc instanceof SysCAMSChannelFacility) {
+                facilities.add((SysCAMSChannelFacility)tgc);
+            }
+        }
+
+        // Remove All Current Links To Ports
+        for(SysCAMSCompositePort port:ports) {
+            if (!referencedports.contains(port)) {
+                port.purge();
+            }
+        }
+
+        // We take each primitive ports individually and we go thru the graph
+        ArrayList<SysCAMSChannelFacility> mets = new ArrayList<SysCAMSChannelFacility>();
+        TGConnector connector;
+        TGConnectingPoint tp;
+        String conflictMessage;
+
+        for(SysCAMSPrimitivePort pport:pports) {
+            for(int i=0; i<pport.getNbConnectingPoint(); i++) {
+                tp = pport.getTGConnectingPointAtIndex(i);
+                connector = findTGConnectorUsing(tp);
+                if (connector != null) {
+                    mets.clear();
+                    conflictMessage = propagate(pport, tp, connector, mets);
+                    TraceManager.addDev("Conflict=" + conflictMessage);
+                    analysePorts(pport, mets, (conflictMessage != null), conflictMessage);
+                } 
+            }
+        }
+    }
+
+    public String propagate(SysCAMSPrimitivePort pport, TGConnectingPoint tp, TGConnector connector, ArrayList<SysCAMSChannelFacility> mets) {
+        TGConnectingPoint tp2;
+        SysCAMSChannelFacility cp = null;
+        String conflictMessage = null;
+        String conflictMessageTmp;
+        int outindex, inindex;
+
+        if (tp == connector.getTGConnectingPointP1()) {
+            tp2 = connector.getTGConnectingPointP2();
+        } else {
+            tp2 = connector.getTGConnectingPointP1();
+        }
+
+        TGComponent tgc = (TGComponent)(tp2.getFather());
+        int index = tgc.getIndexOfTGConnectingPoint(tp2);
+
+        if (tgc instanceof SysCAMSPrimitivePort) {
+            return conflictMessage;
+        }
+
+        // Cycle?
+        if (mets.contains(tgc)) {
+            return "Connection contains a cycle";
+        }
+        if(tgc instanceof SysCAMSCompositePort) {
+            cp = (SysCAMSChannelFacility)tgc;
+            mets.add(cp);
+
+            inindex = cp.getInpIndex();
+            outindex = cp.getOutpIndex();
+            // Already positionned port?
+            if (pport.isOrigin()) {
+                if (cp.getOutPort() != null) {
+                    if (pport.getPortType() != 2) {
+                        conflictMessage = "Conflicting ports types";
+                    } else {
+                        if (cp.getOutPort().getPortType() != 2) {
+                            conflictMessage = "More than two sending non-request ports ";
+                        } else {
+                            if ((outindex<5 && index>4) || (outindex>4 && index<5)) {
+                                conflictMessage = "Sending ports on both side of a composite port";
+                            }
+                        }
+                    }
+                } else {
+                    if (inindex > -1) {
+                        if ((inindex<5 && index<5) || (inindex>4 && index>4)) {
+                            conflictMessage = "Sending and receiving ports on the same side of a composite port";
+                        }
+                    }
+                    cp.setOutPort(pport);
+                    cp.setOutpIndex(index);
+                }
+                conflictMessageTmp = explore(pport, tp2, cp, mets);
+                if (conflictMessageTmp != null) {
+                    conflictMessage = conflictMessageTmp;
+                }
+            } else {
+                if (cp.getInPort() != null) {
+                    conflictMessage = "More than two receiving ports ";
+                } else {
+                    if (outindex > -1) {
+                        if ((index<5 && outindex<5) || (index>4 && outindex>4)) {
+                            conflictMessage = "Sending and receiving ports on the same side of a composite port";
+                        }
+                    }
+                    cp.setInPort(pport);
+                    cp.setInpIndex(index);
+                }
+                conflictMessageTmp = explore(pport, tp2, cp, mets);
+                if (conflictMessageTmp != null) {
+                    conflictMessage = conflictMessageTmp;
+                }
+            }
+        } else if(tgc instanceof SysCAMSFork) {
+            // Only one out, more than one in is ok
+            // No SysCAMSJoin
+            cp = (SysCAMSChannelFacility)tgc;
+            mets.add(cp);
+
+            // Checks that "mets" contains no SysCAMSJoin
+            for(SysCAMSChannelFacility met: mets) {
+                if (met instanceof SysCAMSJoin) {
+                    conflictMessage = "Join and Fork operators are mixed in the same channel";
+                    conflictMessageTmp = explore(pport, tp2, cp, mets);
+                    if (conflictMessageTmp != null) {
+                        conflictMessage = conflictMessageTmp;
+                    }
+                    return conflictMessage;
+                }
+            }
+
+            if (pport.isOrigin()) {
+                if ((cp.getInPort() != null) && (cp.getInPort() != pport)) {
+                    conflictMessage = "More than two sending ports  in a fork architecture";
+                }
+                cp.setInPort(pport);
+                conflictMessageTmp = explore(pport, tp2, cp, mets);
+                if (conflictMessageTmp != null) {
+                    conflictMessage = conflictMessageTmp;
+                }
+            } else {
+                conflictMessage = explore(pport, tp2, cp, mets);
+            }
+        } else if(tgc instanceof SysCAMSJoin) {
+            // Only one out, more than one in is ok
+            // No SysCAMSFork
+            cp = (SysCAMSChannelFacility)tgc;
+            mets.add(cp);
+
+            // Checks that "mets" contains no SysCAMSJoin
+            for(SysCAMSChannelFacility met: mets) {
+                if (met instanceof SysCAMSFork) {
+                    conflictMessage = "Fork and Join operators are mixed in the same channel";
+                    conflictMessageTmp = explore(pport, tp2, cp, mets);
+                    if (conflictMessageTmp != null) {
+                        conflictMessage = conflictMessageTmp;
+                    }
+                    return conflictMessage;
+                }
+            }
+
+            if (!pport.isOrigin()) {
+                if ((cp.getOutPort() != null) && (cp.getOutPort() != pport)) {
+                    conflictMessage = "More than two receiving ports in a join architecture";
+                }
+                cp.setOutPort(pport);
+                conflictMessageTmp = explore(pport, tp2, cp, mets);
+                if (conflictMessageTmp != null) {
+                    conflictMessage = conflictMessageTmp;
+                }
+            } else {
+                conflictMessage = explore(pport, tp2, cp, mets);
+            }
+        }
+        if (cp != null) {
+            if ((cp.getInPort() != null) && (cp.getOutPort() != null)){
+                if (cp.getInPort().getType() != cp.getOutPort().getType()) {
+                    conflictMessage = "Ports are not compatible";
+                } else {
+                    TraceManager.addDev("ports of " + cp + " are compatible out=" + cp.getOutPort().getType() + " in=" + cp.getInPort().getType());
+                }
+            }
+        }
+        return conflictMessage;
+    }
+
+    public String explore(SysCAMSPrimitivePort pport, TGConnectingPoint _tp, SysCAMSChannelFacility cp, ArrayList<SysCAMSChannelFacility> mets) {
+        String conflictMessage = null;
+        String conflictMessageTmp;
+        TGConnectingPoint tp;
+        TGConnector connector;
+
+        for(int i=0; i<cp.getNbConnectingPoint(); i++) {
+            tp = cp.getTGConnectingPointAtIndex(i);
+            if (tp != _tp) {
+                connector = findTGConnectorUsing(tp);
+                if (connector != null) {
+                    conflictMessageTmp = propagate(pport, tp, connector, mets);
+                    if (conflictMessageTmp != null) {
+                        conflictMessage = conflictMessageTmp;
+                    }
+                }
+            }
+        }
+        return conflictMessage;
+    }
+
+    public void analysePorts(SysCAMSPrimitivePort pport, ArrayList<SysCAMSChannelFacility> mets, boolean conflict, String message) {
+        if (mets.size() == 0) {
+            return;
+        }
+        for(SysCAMSChannelFacility port: mets) {
+            port.setConflict(conflict, message);
+        }
+    }
+
+    public List<String> getAllSysCAMSTaskNames(String _topname) {
+        TGComponent tgc;
+        Iterator<TGComponent> iterator = componentList.listIterator();
+        List<String> list = new ArrayList<String>();
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+
+            if (tgc instanceof SysCAMSPrimitiveComponent) {
+                list.add(_topname + "::" + tgc.getValue());
+            }
+        }
+        return list;
+    }
+
+    public Vector<String> getAllSysCAMSTasksAttributes() {
+        TGComponent tgc;
+        Iterator<TGComponent> iterator = componentList.listIterator();
+        Vector<String> list = new Vector<String>();
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+            if( tgc instanceof SysCAMSCompositeComponent ) {
+                for( SysCAMSPrimitiveComponent primComp: ((SysCAMSCompositeComponent)tgc).getAllPrimitiveComponents() ) {
+                    for( Object o: primComp.getAttributeList() )   {
+                        String s = o.toString();
+                        list.add( primComp.getValue() + "." + s.substring( 2, s.length()-1 ) );
+                    }
+                }
+            }
+        }
+        return list;
+    }
+
+    public Vector<String> getAllRecords(SysCAMSPrimitiveComponent tgc) {
+        Vector<String> list = new Vector<String>();
+        getAllRecords((SysCAMSCompositeComponent)(tgc.getFather()), list);
+        return list;
+    }
+
+    public void getAllRecords(SysCAMSCompositeComponent comp,  Vector<String> list) {
+        TGComponent tgc;
+        if (comp == null) {
+            Iterator<TGComponent> iterator = componentList.listIterator();
+            while(iterator.hasNext()) {
+                tgc = iterator.next();
+                if (tgc instanceof SysCAMSRecordComponent) {
+                    list.add(tgc.getValue());
+                }
+            }
+            return;
+        }
+
+        for(int i=0; i<comp.getNbInternalTGComponent(); i++) {
+            tgc = comp.getInternalTGComponent(i);
+            if (tgc instanceof SysCAMSRecordComponent) {
+                list.add(tgc.getValue());
+            }
+        }
+        getAllRecords((SysCAMSCompositeComponent)(comp.getFather()), list);
+    }
+
+    public SysCAMSRecordComponent getRecordNamed(SysCAMSPrimitiveComponent tgc, String _nameOfRecord) {
+        return getRecordNamed((SysCAMSCompositeComponent)(tgc.getFather()), _nameOfRecord);
+    }
+
+    public SysCAMSRecordComponent getRecordNamed(SysCAMSCompositeComponent comp,  String _nameOfRecord) {
+        TGComponent tgc;
+        if (comp == null) {
+            Iterator<TGComponent> iterator = componentList.listIterator();
+            while(iterator.hasNext()) {
+                tgc = iterator.next();
+                if (tgc instanceof SysCAMSRecordComponent) {
+                    if (tgc.getValue().compareTo(_nameOfRecord) == 0) {
+                        return (SysCAMSRecordComponent)tgc;
+                    }
+                }
+            }
+            return null;
+        }
+        for(int i=0; i<comp.getNbInternalTGComponent(); i++) {
+            tgc = comp.getInternalTGComponent(i);
+            if (tgc instanceof SysCAMSRecordComponent) {
+                if (tgc.getValue().compareTo(_nameOfRecord) == 0) {
+                    return (SysCAMSRecordComponent)tgc;
+                }
+            }
+        }
+        return getRecordNamed((SysCAMSCompositeComponent)(comp.getFather()), _nameOfRecord);
+    }
+
+    public void findAllReferencedPanels( List<SysCAMSComponentTaskDiagramPanel> panels) {
+        if (panels.contains(this)) {
+            return;
+        }
+        panels.add(this);
+
+        Iterator<TGComponent> iterator = componentList.listIterator();
+        TGComponent tgc;
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+            if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+                SysCAMSRemoteCompositeComponent remote = (SysCAMSRemoteCompositeComponent)tgc;
+                TDiagramPanel panel = remote.getReferencedDiagram();
+                if ((panel != null) && (panel instanceof SysCAMSComponentTaskDiagramPanel)){
+                    ((SysCAMSComponentTaskDiagramPanel)panel).findAllReferencedPanels(panels);
+                }
+            }
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                //We must find all panels referencing this component
+                panels.addAll(mgui.getAllPanelsReferencingSysCAMSCompositeComponent((SysCAMSCompositeComponent)tgc));
+            }
+        }
+    }
+
+    public List<SysCAMSPath> makePaths() {
+        List<SysCAMSComponentTaskDiagramPanel> panels = new ArrayList<SysCAMSComponentTaskDiagramPanel>();
+
+        // We first find all the implicated panels
+        findAllReferencedPanels(panels);
+
+        List<SysCAMSPath> paths = new ArrayList<SysCAMSPath>();
+        Iterator<TGComponent> iterator;
+        TGComponent tgc;
+
+        // Go through the component list of all panels, and make paths. Then, go thru connectors,
+        // and merge paths until nomore merging is possible
+        for (TDiagramPanel panel: panels) {
+            iterator = panel.getComponentList().listIterator();
+            List<SysCAMSCompositePort> listcp;
+            List<SysCAMSPrimitivePort> listpp;
+
+            while(iterator.hasNext()) {
+                tgc = iterator.next();
+
+                if (tgc instanceof SysCAMSCompositeComponent) {
+                    listcp = ((SysCAMSCompositeComponent)tgc).getAllInternalCompositePorts();
+                    for(SysCAMSCompositePort cp: listcp) {
+                        addToPaths(paths, cp);
+                    }
+                    listpp = ((SysCAMSCompositeComponent)tgc).getAllInternalPrimitivePorts();
+                    for(SysCAMSPrimitivePort pp: listpp) {
+                        addToPaths(paths, pp);
+                    }
+                }
+                if (tgc instanceof SysCAMSPrimitiveComponent) {
+                    listpp = ((SysCAMSPrimitiveComponent)tgc).getAllInternalPrimitivePorts();
+                    for(SysCAMSPrimitivePort pp: listpp) {
+                        addToPaths(paths, pp);
+                    }
+                }
+                if (tgc instanceof SysCAMSPrimitivePort) {
+                    addToPaths(paths, tgc);
+                }
+                if (tgc instanceof SysCAMSChannelFacility) {
+                    addToPaths(paths, tgc);
+                }
+            }
+        }
+
+        // Use connectors to merge paths with one another
+        for (TDiagramPanel panel: panels) {
+            iterator = panel.getComponentList().listIterator();
+            SysCAMSPortConnector connector;
+            TGComponent tgc1, tgc2;
+            SysCAMSPath path1, path2;
+
+            while(iterator.hasNext()) {
+                tgc = iterator.next();
+                if (tgc instanceof SysCAMSPortConnector) {
+                    connector = (SysCAMSPortConnector)tgc;
+                    if (connector.getTGConnectingPointP1().getFather() instanceof TGComponent) {
+                        tgc1 = (TGComponent)(connector.getTGConnectingPointP1().getFather());
+                    } else {
+                        tgc1 = null;
+                    }
+                    if (connector.getTGConnectingPointP2().getFather() instanceof TGComponent) {
+                        tgc2 = (TGComponent)(connector.getTGConnectingPointP2().getFather());
+                    } else {
+                        tgc2 = null;
+                    }
+                    if (tgc1 instanceof SysCAMSRemoteCompositeComponent) {
+                        tgc1 = ((SysCAMSRemoteCompositeComponent)tgc1).getPortOf(connector.getTGConnectingPointP1());
+                    }
+                    if (tgc2 instanceof SysCAMSRemoteCompositeComponent) {
+                        tgc2 = ((SysCAMSRemoteCompositeComponent)tgc2).getPortOf(connector.getTGConnectingPointP2());
+                    }
+                    if ((tgc1 != null) && (tgc2 != null) && (tgc1 != tgc2)) {
+                        path1 = getPathOf(paths, tgc1);
+                        path2 = getPathOf(paths, tgc2);
+                        if ((path1 != null) && (path2 != null)) {
+                            // Not in the same path -> we must do a merging
+                            // and then we remove path2 from path
+                            if (path1 != path2) {
+                                path1.mergeWith(path2);
+                                paths.remove(path2);
+                            }
+                        }
+                    } else {
+                        // If there is a null component in the path, then, we must set an error in the path
+                        if ((tgc1 == null) && (tgc2 != null)) {
+                            path2 = getPathOf(paths, tgc2);
+                            path2.setErrorOfConnection(true);
+
+                        }
+                        if ((tgc2 == null) && (tgc1 != null)) {
+                            path1 = getPathOf(paths, tgc1);
+                            path1.setErrorOfConnection(true);
+                        }
+                    }
+                }
+            }
+        }
+        return paths;
+    }
+
+    public SysCAMSPath getPathOf( List<SysCAMSPath> paths, TGComponent tgc) {
+        for(SysCAMSPath path: paths) {
+            if (path.contains(tgc)) {
+                return path;
+            }
+        }
+        return null;
+    }
+
+    public void addToPaths( List<SysCAMSPath> paths, TGComponent tgc) {
+        for(SysCAMSPath path: paths) {
+            if (path.contains(tgc)) {
+                return;
+            }
+        }
+        // Create a new path
+        SysCAMSPath ph = new SysCAMSPath();
+        ph.addComponent(tgc);
+        paths.add(ph);
+    }
+
+
+    public void getPanelsUsingAComponent(SysCAMSCompositeComponent syscamscc, ArrayList<SysCAMSComponentTaskDiagramPanel> panels) {
+        Iterator<TGComponent> iterator = componentList.listIterator();
+        TGComponent tgc;
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                if (((SysCAMSCompositeComponent)tgc).hasReferencesTo(syscamscc)) {
+                    panels.add(this);
+                    return;
+                }
+            }
+            if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+                if (((SysCAMSRemoteCompositeComponent)tgc).getReference() == syscamscc) {
+                    panels.add(this);
+                    return;
+                }
+            }
+        }
+    }
+
+    public String[] getAllOutDE(String nameOfComponent) {
+        SysCAMSPrimitiveComponent comp = getPrimitiveComponentByName(nameOfComponent);
+        if (comp == null) {
+            return null;
+        }
+        List<SysCAMSPrimitivePort> ll = comp.getAllDEOriginPorts();
+        String[]terms = new String[ll.size()];
+        Iterator<SysCAMSPrimitivePort> ite = ll.listIterator();
+        int i = 0;
+
+        while(ite.hasNext()) {
+            SysCAMSPrimitivePort port = ite.next();
+            terms[i] = port.getPortName();
+            i ++;
+        }
+        return terms;
+    }
+
+    public String[] getAllInDE(String nameOfComponent) {
+        SysCAMSPrimitiveComponent comp = getPrimitiveComponentByName(nameOfComponent);
+        if (comp == null) {
+            return null;
+        }
+        List<SysCAMSPrimitivePort> ll = comp.getAllDEDestinationPorts();
+        String[]terms = new String[ll.size()];
+        ListIterator<SysCAMSPrimitivePort> ite = ll.listIterator();
+        int i = 0;
+        while(ite.hasNext()) {
+            SysCAMSPrimitivePort port = ite.next();
+            terms[i] = port.getPortName();
+            i ++;
+        }
+        return terms;
+    }
+
+    public String[] getAllOutTDF(String nameOfComponent) {
+        SysCAMSPrimitiveComponent comp = getPrimitiveComponentByName(nameOfComponent);
+        if (comp == null) {
+            return null;
+        }
+        List<SysCAMSPrimitivePort> ll = comp.getAllTDFOriginPorts();
+        String[]terms = new String[ll.size()];
+        Iterator<SysCAMSPrimitivePort> ite = ll.listIterator();
+        int i = 0;
+        while(ite.hasNext()) {
+            SysCAMSPrimitivePort port = ite.next();
+            terms[i] = port.getPortName();
+            i++;
+        }
+        return terms;
+    }
+
+    public String[] getAllInTDF(String nameOfComponent) {
+        SysCAMSPrimitiveComponent comp = getPrimitiveComponentByName(nameOfComponent);
+        if (comp == null) {
+            return null;
+        }
+
+        List<SysCAMSPrimitivePort> ll = comp.getAllTDFDestinationPorts();
+        String[]terms = new String[ll.size()];
+        Iterator<SysCAMSPrimitivePort> ite = ll.listIterator();
+        int i = 0;
+
+        while(ite.hasNext()) {
+            SysCAMSPrimitivePort port = ite.next();
+            terms[i] = port.getPortName();
+            i++;
+        }
+        return terms;
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java b/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java
new file mode 100644
index 0000000000..7f20e799aa
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java
@@ -0,0 +1,124 @@
+/* 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.syscams;
+
+import ui.MainGUI;
+import ui.TGUIAction;
+import ui.TToolBar;
+
+import javax.swing.*;
+
+/**
+ * Class SysCAMSComponentTaskDiagramToolBar Implements the toolbar to be used in
+ * conjunction with the panel of a SystemC-AMS diagram Creation: 22/04/2018
+ * 
+ * @version 1.0 22/04/2018
+ * @author Irina Kit Yan LEE
+ * @see SysCAMSComponentTaskDiagramPanel
+ */
+
+@SuppressWarnings("serial")
+
+public class SysCAMSComponentTaskDiagramToolBar extends TToolBar {
+
+	public SysCAMSComponentTaskDiagramToolBar(MainGUI _mgui) {
+		super(_mgui);
+	}
+
+	protected void setActive(boolean b) {
+		mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(b);
+		mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(b);
+
+		mgui.actions[TGUIAction.CAMS_EDIT].setEnabled(b);
+		mgui.actions[TGUIAction.UML_NOTE].setEnabled(b);
+		mgui.actions[TGUIAction.CAMS_CONNECTOR].setEnabled(b);
+		mgui.actions[TGUIAction.CAMS_BLOCK_TDF].setEnabled(b);
+		mgui.actions[TGUIAction.CAMS_BLOCK_DE].setEnabled(b);
+		mgui.actions[TGUIAction.CAMS_PORT_TDF].setEnabled(b);
+		mgui.actions[TGUIAction.CAMS_PORT_DE].setEnabled(b);
+		mgui.actions[TGUIAction.CAMS_PORT_CONVERTER].setEnabled(b);
+		mgui.actions[TGUIAction.CAMS_CLUSTER].setEnabled(b);
+
+		mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b);
+		mgui.actions[TGUIAction.ACT_ONECLICK_LOTOS_RG].setEnabled(b);
+		mgui.actions[TGUIAction.ACT_SIMU_SYSTEMC].setEnabled(b);
+		
+		mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(b);
+		mgui.updateZoomInfo();
+	}
+
+	protected void setButtons() {
+		JButton button;
+
+		button = this.add(mgui.actions[TGUIAction.CAMS_EDIT]);
+		button.addMouseListener(mgui.mouseHandler);
+
+		button = this.add(mgui.actions[TGUIAction.UML_NOTE]);
+		button.addMouseListener(mgui.mouseHandler);
+
+		this.addSeparator();
+		
+		button = this.add(mgui.actions[TGUIAction.CAMS_CLUSTER]);
+		button.addMouseListener(mgui.mouseHandler);
+		
+		button = this.add(mgui.actions[TGUIAction.CAMS_PORT_CONVERTER]);
+		button.addMouseListener(mgui.mouseHandler);
+		
+		this.addSeparator();
+		
+		button = this.add(mgui.actions[TGUIAction.CAMS_BLOCK_TDF]);
+		button.addMouseListener(mgui.mouseHandler);
+		
+		button = this.add(mgui.actions[TGUIAction.CAMS_PORT_TDF]);
+		button.addMouseListener(mgui.mouseHandler);
+		
+		this.addSeparator();
+				
+		button = this.add(mgui.actions[TGUIAction.CAMS_BLOCK_DE]);
+		button.addMouseListener(mgui.mouseHandler);
+		
+		button = this.add(mgui.actions[TGUIAction.CAMS_PORT_DE]);
+		button.addMouseListener(mgui.mouseHandler);
+		
+		this.addSeparator();
+		
+		button = this.add(mgui.actions[TGUIAction.CAMS_CONNECTOR]);
+		button.addMouseListener(mgui.mouseHandler);
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSCompositeComponent.java b/src/main/java/ui/syscams/SysCAMSCompositeComponent.java
new file mode 100644
index 0000000000..fddb4ac31a
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSCompositeComponent.java
@@ -0,0 +1,633 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import ui.*;
+import ui.util.IconManager;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.ListIterator;
+
+/**
+ * Class SysCAMSCompositeComponent
+ * Composite Component. To be used in SystemC-AMS diagrams
+ * Creation: 27/04/2018
+ *
+ * @author Irina Kit Yan LEE
+ * @version 1.0 27/04/2018
+ */
+
+public class SysCAMSCompositeComponent extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent, HiddenInternalComponents {
+    private int maxFontSize = 20;
+    private int minFontSize = 4;
+    private int currentFontSize = -1;
+    private boolean displayText = true;
+    private Color myColor;
+    private int iconSize = 17;
+
+    private int textX = 15; // border for ports
+    private double dtextX = 0.0;
+
+    private boolean hiddeni;
+
+    private int compositePortNb = 0;
+
+    public SysCAMSCompositeComponent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+
+        initScaling(250, 200);
+
+        oldScaleFactor = tdp.getZoom();
+        dtextX = textX * oldScaleFactor;
+        textX = (int) dtextX;
+        dtextX = dtextX - textX;
+
+        minWidth = 1;
+        minHeight = 1;
+
+        nbConnectingPoint = 0;
+        addTGConnectingPointsComment();
+
+        nbInternalTGComponent = 0;
+
+        maxWidth = 2000;
+        maxHeight = 2000;
+
+        moveable = true;
+        editable = true;
+        removable = true;
+        userResizable = true;
+
+        value = "Cluster";
+        name = "Composite component";
+
+        myImageIcon = IconManager.imgic1200;
+    }
+
+    public void internalDrawing(Graphics g) {
+        int w;
+        int c;
+        Font f = g.getFont();
+        Font fold = f;
+
+        if (myColor == null) {
+            if (ColorManager.TML_COMPOSITE_COMPONENT == Color.white) {
+                myColor = Color.white;
+            } else {
+                myColor = Color.white;
+            }
+        }
+        if ((rescaled) && (!tdp.isScaled())) {
+            if (currentFontSize == -1) {
+                currentFontSize = f.getSize();
+            }
+            rescaled = false;
+            // Must set the font size ..
+            // Find the biggest font not greater than max_font size
+            // By Increment of 1
+            // Or decrement of 1
+            // If font is less than 4, no text is displayed
+
+            int maxCurrentFontSize = Math.max(0, Math.min(height - (2 * textX), maxFontSize));
+
+            while (maxCurrentFontSize > (minFontSize - 1)) {
+                f = f.deriveFont((float) maxCurrentFontSize);
+                g.setFont(f);
+                w = g.getFontMetrics().stringWidth(value);
+                c = width - iconSize - (2 * textX);
+                if (w < c) {
+                    break;
+                }
+                maxCurrentFontSize--;
+            }
+            currentFontSize = maxCurrentFontSize;
+            displayText = currentFontSize >= minFontSize;
+        }
+        // Zoom is assumed to be computed
+        Color col = g.getColor();
+        g.drawRect(x, y, width, height);
+        if ((width > 2) && (height > 2)) {
+            g.setColor(myColor);
+            g.fillRect(x + 1, y + 1, width - 1, height - 1);
+            g.setColor(col);
+        }
+        // Font size 
+        if (displayText) {
+            f = f.deriveFont((float) currentFontSize);
+            g.setFont(f);
+            w = g.getFontMetrics().stringWidth(value);
+            if (!(w < (width - 2 * (iconSize + textX)))) {
+                g.drawString(value, x + textX + 1, y + currentFontSize + textX);
+            } else {
+                g.drawString(value, x + (width - w) / 2, y + currentFontSize + textX);
+            }
+        }
+        g.setFont(fold);
+//		// Icon
+//		if ((width>30) && (height > (iconSize + 2*textX))) {
+//			g.drawImage(IconManager.imgic1200.getImage(), x + width - iconSize - textX, y + textX, null);
+//		}
+    }
+
+    public void rescale(double scaleFactor) {
+        dtextX = (textX + dtextX) / oldScaleFactor * scaleFactor;
+        textX = (int) (dtextX);
+        dtextX = dtextX - textX;
+        super.rescale(scaleFactor);
+    }
+
+    public TGComponent isOnOnlyMe(int _x, int _y) {
+        if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) {
+            return this;
+        }
+        return null;
+    }
+
+    public boolean editOndoubleClick(JFrame frame) {
+        String s = (String) JOptionPane.showInputDialog(frame, "Name:", "Setting component name",
+                JOptionPane.PLAIN_MESSAGE, IconManager.imgic100,
+                null,
+                getValue());
+        if ((s != null) && (s.length() > 0)) {
+            if (!TAttribute.isAValidId(s, false, false)) {
+                JOptionPane.showMessageDialog(frame,
+                        "Could not change the name of the component: the new name is not a valid name",
+                        "Error",
+                        JOptionPane.INFORMATION_MESSAGE);
+                return false;
+            }
+            if (((SysCAMSComponentTaskDiagramPanel) (tdp)).isCompositeNameUsed(s)) {
+                JOptionPane.showMessageDialog(frame,
+                        "Error: the name is already in use",
+                        "Name modification",
+                        JOptionPane.ERROR_MESSAGE);
+                return false;
+            }
+            setValueWithChange(s);
+            return true;
+        }
+        return false;
+    }
+
+    public int getType() {
+        return TGComponentManager.CAMS_CLUSTER;
+    }
+
+    public void wasSwallowed() {
+        myColor = null;
+    }
+
+    public void wasUnswallowed() {
+        myColor = null;
+        setFather(null);
+        TDiagramPanel tdp = getTDiagramPanel();
+        setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY());
+    }
+
+    public boolean acceptSwallowedTGComponent(TGComponent tgc) {
+        if (tgc instanceof SysCAMSCompositeComponent) {
+            return true;
+        }
+        if (tgc instanceof SysCAMSRecordComponent) {
+            return true;
+        }
+        if (tgc instanceof SysCAMSPrimitiveComponent) {
+            return true;
+        }
+        if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+            return true;
+        }
+        return tgc instanceof SysCAMSCompositePort;
+    }
+
+    public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) {
+        boolean swallowed = false;
+
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SwallowTGComponent) {
+                if (((SwallowTGComponent) tgcomponent[i]).acceptSwallowedTGComponent(tgc)) {
+                    if (tgcomponent[i].isOnMe(x, y) != null) {
+                        swallowed = true;
+                        ((SwallowTGComponent) tgcomponent[i]).addSwallowedTGComponent(tgc, x, y);
+                        break;
+                    }
+                }
+            }
+        }
+        if (swallowed) {
+            return true;
+        }
+        if (!acceptSwallowedTGComponent(tgc)) {
+            return false;
+        }
+        // Choose its position
+
+        // Make it an internal component
+        // It's one of my son
+        tgc.setFather(this);
+        tgc.setDrawingZone(true);
+
+        //Set its coordinates
+        if (tgc instanceof SysCAMSCompositeComponent) {
+            tgc.resizeWithFather();
+        }
+
+        if (tgc instanceof SysCAMSRecordComponent) {
+            tgc.resizeWithFather();
+        }
+
+        if (tgc instanceof SysCAMSPrimitiveComponent) {
+            tgc.resizeWithFather();
+        }
+
+        if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+            tgc.resizeWithFather();
+        }
+        if (tgc instanceof SysCAMSCompositePort) {
+            tgc.resizeWithFather();
+            compositePortNb++;
+        }
+        //add it
+        addInternalComponent(tgc, 0);
+        return true;
+    }
+
+    public void removeSwallowedTGComponent(TGComponent tgc) {
+        if (tgc instanceof SysCAMSCompositePort) {
+            portRemoved();
+        }
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] == tgc) {
+                nbInternalTGComponent = nbInternalTGComponent - 1;
+                if (nbInternalTGComponent == 0) {
+                    tgcomponent = null;
+                } else {
+                    TGComponent[] tgcomponentbis = new TGComponent[nbInternalTGComponent];
+                    for (int j = 0; j < nbInternalTGComponent; j++) {
+                        if (j < i) {
+                            tgcomponentbis[j] = tgcomponent[j];
+                        }
+                        if (j >= i) {
+                            tgcomponentbis[j] = tgcomponent[j + 1];
+                        }
+                    }
+                    tgcomponent = tgcomponentbis;
+                }
+                break;
+            }
+        }
+    }
+
+    public void hasBeenResized() {
+        rescaled = true;
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                tgcomponent[i].resizeWithFather();
+            }
+            if (tgcomponent[i] instanceof SysCAMSPrimitiveComponent) {
+                tgcomponent[i].resizeWithFather();
+            }
+            if (tgcomponent[i] instanceof SysCAMSRecordComponent) {
+                tgcomponent[i].resizeWithFather();
+            }
+            if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) {
+                tgcomponent[i].resizeWithFather();
+            }
+            if (tgcomponent[i] instanceof SysCAMSCompositePort) {
+                tgcomponent[i].resizeWithFather();
+            }
+        }
+        if (getFather() != null) {
+            resizeWithFather();
+        }
+    }
+
+    public void resizeWithFather() {
+        if ((father != null) && ((father instanceof SysCAMSCompositeComponent) || (father instanceof SysCAMSPrimitiveComponent))) {
+            // Too large to fit in the father? -> resize it!
+            resizeToFatherSize();
+
+            setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight());
+            setMoveCd(x, y);
+        }
+    }
+
+    public java.util.List<SysCAMSPrimitiveComponent> getAllPrimitiveComponents() {
+        ArrayList<SysCAMSPrimitiveComponent> ll = new ArrayList<SysCAMSPrimitiveComponent>();
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                ll.addAll(((SysCAMSCompositeComponent) tgcomponent[i]).getAllPrimitiveComponents());
+            }
+            if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) {
+                ll.addAll(((SysCAMSRemoteCompositeComponent) tgcomponent[i]).getAllPrimitiveComponents());
+            }
+            if (tgcomponent[i] instanceof SysCAMSPrimitiveComponent) {
+                ll.add(((SysCAMSPrimitiveComponent) (tgcomponent[i])));
+            }
+        }
+        return ll;
+    }
+
+    public ArrayList<SysCAMSRecordComponent> getAllRecordComponents() {
+        ArrayList<SysCAMSRecordComponent> ll = new ArrayList<SysCAMSRecordComponent>();
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                ll.addAll(((SysCAMSCompositeComponent) tgcomponent[i]).getAllRecordComponents());
+            }
+            if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) {
+                ll.addAll(((SysCAMSRemoteCompositeComponent) tgcomponent[i]).getAllRecordComponents());
+            }
+
+            if (tgcomponent[i] instanceof SysCAMSRecordComponent) {
+                ll.add(((SysCAMSRecordComponent) (tgcomponent[i])));
+            }
+        }
+        return ll;
+    }
+
+    public void getAllCompositeComponents(ArrayList<String> list, String _name) {
+        String s;
+        SysCAMSCompositeComponent syscamscc;
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                syscamscc = (SysCAMSCompositeComponent) tgcomponent[i];
+                s = _name + "::" + syscamscc.getValue();
+                list.add(s);
+                syscamscc.getAllCompositeComponents(list, _name);
+            }
+        }
+    }
+
+    public ArrayList<SysCAMSCompositePort> getAllInternalCompositePorts() {
+        ArrayList<SysCAMSCompositePort> list = new ArrayList<SysCAMSCompositePort>();
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                list.addAll(((SysCAMSCompositeComponent) tgcomponent[i]).getAllInternalCompositePorts());
+            }
+            if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) {
+                list.addAll(((SysCAMSRemoteCompositeComponent) tgcomponent[i]).getAllInternalCompositePorts());
+            }
+            if (tgcomponent[i] instanceof SysCAMSCompositePort) {
+                list.add((SysCAMSCompositePort) (tgcomponent[i]));
+            }
+        }
+        return list;
+    }
+
+    public ArrayList<SysCAMSCompositePort> getAllReferencedCompositePorts() {
+        ArrayList<SysCAMSCompositePort> list = new ArrayList<SysCAMSCompositePort>();
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                list.addAll(((SysCAMSCompositeComponent) tgcomponent[i]).getAllReferencedCompositePorts());
+            }
+            if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) {
+                list.addAll(((SysCAMSRemoteCompositeComponent) tgcomponent[i]).getAllInternalCompositePorts());
+            }
+        }
+        return list;
+    }
+
+    public ArrayList<SysCAMSCompositePort> getFirstLevelCompositePorts() {
+        ArrayList<SysCAMSCompositePort> list = new ArrayList<SysCAMSCompositePort>();
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositePort) {
+                list.add((SysCAMSCompositePort) (tgcomponent[i]));
+            }
+        }
+        return list;
+    }
+
+    public ArrayList<SysCAMSPrimitivePort> getAllInternalPrimitivePorts() {
+        ArrayList<SysCAMSPrimitivePort> list = new ArrayList<SysCAMSPrimitivePort>();
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                list.addAll(((SysCAMSCompositeComponent) tgcomponent[i]).getAllInternalPrimitivePorts());
+            }
+            if (tgcomponent[i] instanceof SysCAMSPrimitiveComponent) {
+                list.addAll(((SysCAMSPrimitiveComponent) tgcomponent[i]).getAllInternalPrimitivePorts());
+            }
+        }
+        return list;
+    }
+
+    public SysCAMSPrimitiveComponent getPrimitiveComponentByName(String _name) {
+        SysCAMSPrimitiveComponent tgc;
+        ListIterator<SysCAMSPrimitiveComponent> li = getAllPrimitiveComponents().listIterator();
+
+        while (li.hasNext()) {
+            tgc = li.next();
+            if (tgc.getValue().equals(_name)) {
+                return tgc;
+            }
+        }
+        return null;
+    }
+
+    public SysCAMSCompositeComponent getCompositeComponentByName(String _name) {
+        TGComponent tgc;
+        SysCAMSCompositeComponent tmp;
+
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            tgc = tgcomponent[i];
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                tmp = (SysCAMSCompositeComponent) tgc;
+                if (tmp.getValue().equals(_name)) {
+                    return tmp;
+                }
+
+                if ((tmp = tmp.getCompositeComponentByName(name)) != null) {
+                    return tmp;
+                }
+            }
+        }
+        return null;
+    }
+
+    public void setInternalsHidden(boolean hide) {
+        hiddeni = hide;
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (!(tgcomponent[i] instanceof SysCAMSCompositePort)) {
+                tgcomponent[i].setHidden(hide);
+            }
+        }
+
+        if (tdp instanceof SysCAMSComponentTaskDiagramPanel) {
+            ((SysCAMSComponentTaskDiagramPanel) tdp).hideConnectors();
+        }
+    }
+
+    public boolean areInternalsHidden() {
+        return hiddeni;
+    }
+
+    public void drawInternalComponentsWhenHidden(Graphics g) {
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositePort) {
+                tgcomponent[i].draw(g);
+            }
+        }
+    }
+
+    protected String translateExtraParam() {
+        StringBuffer sb = new StringBuffer("<extraparam>\n");
+        sb.append("<info hiddeni=\"" + hiddeni + "\" ");
+        sb.append("/>\n");
+        sb.append("</extraparam>\n");
+        return new String(sb);
+    }
+
+    public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException {
+        try {
+            NodeList nli;
+            Node n1, n2;
+            Element elt;
+
+            for (int i = 0; i < nl.getLength(); i++) {
+                n1 = nl.item(i);
+                if (n1.getNodeType() == Node.ELEMENT_NODE) {
+                    nli = n1.getChildNodes();
+                    for (int j = 0; j < nli.getLength(); j++) {
+                        n2 = nli.item(j);
+                        if (n2.getNodeType() == Node.ELEMENT_NODE) {
+                            elt = (Element) n2;
+                            if (elt.getTagName().equals("info")) {
+                                if (elt.getAttribute("hiddeni").equals("true")) {
+                                    setInternalsHidden(true);
+                                }
+                            }
+
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            throw new MalformedModelingException();
+        }
+    }
+
+    public void drawTGConnectingPoint(Graphics g, int type) {
+        for (int i = 0; i < nbConnectingPoint; i++) {
+            if (connectingPoint[i].isCompatibleWith(type)) {
+                connectingPoint[i].draw(g);
+            }
+        }
+
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (hiddeni) {
+                if (tgcomponent[i] instanceof SysCAMSCompositePort) {
+                    tgcomponent[i].drawTGConnectingPoint(g, type);
+                }
+            } else {
+                tgcomponent[i].drawTGConnectingPoint(g, type);
+            }
+        }
+    }
+
+    public String getExtendedValue() {
+        return getValuePanel() + "::" + getValue();
+    }
+
+    public void myActionWhenRemoved() {
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                tgcomponent[i].myActionWhenRemoved();
+            }
+        }
+        tdp = null;
+    }
+
+    public void updateReferenceToSysCAMSCompositeComponent(SysCAMSCompositeComponent syscamscc) {
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) {
+                ((SysCAMSRemoteCompositeComponent) tgcomponent[i]).updateReference(syscamscc);
+            }
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                ((SysCAMSCompositeComponent) tgcomponent[i]).updateReferenceToSysCAMSCompositeComponent(syscamscc);
+            }
+        }
+    }
+
+    public void delayedLoad() {
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) {
+                try {
+                    ((SysCAMSRemoteCompositeComponent) tgcomponent[i]).delayedLoad();
+                } catch (Exception e) {
+                }
+            }
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                ((SysCAMSCompositeComponent) tgcomponent[i]).delayedLoad();
+            }
+        }
+    }
+
+    public int getCompositePortNb() {
+        return compositePortNb;
+    }
+
+    public void portRemoved() {
+        compositePortNb--;
+    }
+
+    public boolean hasReferencesTo(SysCAMSCompositeComponent syscamscc) {
+        boolean b;
+
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) {
+                b = ((SysCAMSRemoteCompositeComponent) tgcomponent[i]).getReference() == syscamscc;
+                if (b) {
+                    return true;
+                }
+            }
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                b = ((SysCAMSCompositeComponent) tgcomponent[i]).hasReferencesTo(syscamscc);
+                if (b) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSCompositePort.java b/src/main/java/ui/syscams/SysCAMSCompositePort.java
new file mode 100644
index 0000000000..5a8ac86da5
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSCompositePort.java
@@ -0,0 +1,325 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+import ui.*;
+import ui.util.IconManager;
+import ui.window.JDialogSysCAMSPortConverter;
+
+import java.awt.*;
+import javax.swing.ImageIcon;
+import javax.swing.JFrame;
+
+/**
+ * Class SysCAMSCompositePort
+ * Composite port. To be used in SystemC-AMS diagrams
+ * Creation: 29/04/2018
+ * @version 1.0 29/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSCompositePort extends SysCAMSChannelFacility implements SwallowedTGComponent, WithAttributes {
+	private int oldx, oldy;
+	private int halfwidth = 13;
+	private int currentOrientation = GraphicLib.NORTH;
+	protected int decPoint = 3;
+	private ImageIcon portImageIconW, portImageIconE, portImageIconN, portImageIconS;
+	public String commName;
+    
+	// Attributes
+    public String portName;
+    public int period;
+    public int rate;
+    public int delay;
+    public String type;
+    public String origin;
+	
+    public SysCAMSCompositePort(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+        
+		initScaling(2*halfwidth, 2*halfwidth);
+		
+        minWidth = 10;
+        minHeight = 10;
+        
+        nbConnectingPoint = 10;
+        connectingPoint = new TGConnectingPoint[10];
+		int i;
+		for (i=0; i<5; i++) {
+			connectingPoint[i] = new SysCAMSPortConnectingPoint(this, 0, 0, true, true, 0.5, 0.0);
+		}
+		for(i=5; i<10; i++) {
+			connectingPoint[i] = new SysCAMSPortConnectingPoint(this, 0, 0, true, true, 0.5, 1.0);
+		}
+        
+        addTGConnectingPointsComment();
+        
+        nbInternalTGComponent = 0;
+        
+		value = "";
+		name = "Composite port";
+		commName = "port";
+		
+        myImageIcon = IconManager.imgic1204;
+        portImageIconW = IconManager.imgic8002; 
+        portImageIconE = IconManager.imgic8003; 
+        portImageIconN = IconManager.imgic8004; 
+        portImageIconS = IconManager.imgic8005; 
+        
+        // Initialization of port attributes
+    	((SysCAMSPortConverter) this).setPeriod(0);
+    	((SysCAMSPortConverter) this).setDelay(0);
+    	((SysCAMSPortConverter) this).setRate(0);
+    	((SysCAMSPortConverter) this).setConvType("");
+    	((SysCAMSPortConverter) this).setOrigin("");
+    }
+    
+    public void internalDrawing(Graphics g) {
+		if ((x != oldx) | (oldy != y)) {
+			// Component has moved!
+			manageMove();
+			oldx = x;
+			oldy = y;
+		}
+		if (rescaled) {
+			rescaled = false;	
+		}
+		
+		calculatePortColor();
+		
+		// Zoom is assumed to be computed
+		Color c = g.getColor();
+		g.setColor(c);
+		
+		TGComponent tgc = getFather();
+		
+        if ((tgc != null) && (tgc instanceof SysCAMSCompositeComponent)) {
+        	if (tgc instanceof SysCAMSCompositeComponent && this instanceof SysCAMSCompositePort) {
+        		switch(currentOrientation) {
+                case GraphicLib.NORTH:
+            		g.drawRect(x-1+width/2-portImageIconN.getIconWidth()/2, y-1+height/2-portImageIconN.getIconHeight()/2, portImageIconN.getIconWidth()+2, portImageIconN.getIconHeight()+2);
+             		g.drawImage(portImageIconN.getImage(), x+width/2-portImageIconN.getIconWidth()/2, y+height/2-portImageIconN.getIconHeight()/2, null);
+                	break;
+                case GraphicLib.SOUTH:
+            		g.drawRect(x+width/2-portImageIconS.getIconWidth()/2, y+height/2-portImageIconS.getIconHeight()/2, portImageIconS.getIconWidth(), portImageIconS.getIconHeight());
+             		g.drawImage(portImageIconS.getImage(), x+width/2-portImageIconS.getIconWidth()/2, y+height/2-portImageIconS.getIconHeight()/2, null);
+                	break;
+                case GraphicLib.WEST:
+            		g.drawRect(x+width/2-portImageIconW.getIconWidth()/2, y+height/2-portImageIconW.getIconHeight()/2, portImageIconW.getIconWidth(), portImageIconW.getIconHeight());
+             		g.drawImage(portImageIconW.getImage(), x+width/2-portImageIconW.getIconWidth()/2, y+height/2-portImageIconW.getIconHeight()/2, null);
+                	break;
+                case GraphicLib.EAST:
+                default:
+            		g.drawRect(x+width/2-portImageIconE.getIconWidth()/2, y+height/2-portImageIconE.getIconHeight()/2, portImageIconE.getIconWidth(), portImageIconE.getIconHeight());
+             		g.drawImage(portImageIconE.getImage(), x+width/2-portImageIconE.getIconWidth()/2, y+height/2-portImageIconE.getIconHeight()/2, null);
+                }
+        	}
+        }
+		
+        int ft = 10;
+        if ((tgc != null) && (tgc instanceof SysCAMSPrimitiveComponent)) {
+            ft = ((SysCAMSPrimitiveComponent)tgc).getCurrentFontSize();
+        }
+        int w;
+        Font f = g.getFont();
+        Font fold = f;
+
+        int si = Math.min(8, (int)((float)ft - 2));
+        f = f.deriveFont((float)si);
+        g.setFont(f);
+        w = g.getFontMetrics().stringWidth(commName);
+        if (w < ((int)(width * 1.5))) {
+            g.drawString(commName, x, y-1);
+        }
+        
+        g.setFont(fold);
+        
+		// Draw arrow showing the connection if necessary
+		if ((!conflict) && (outp != null || inp != null)) {
+			int wayTo = currentOrientation;
+			if (inp != null) {
+				if (inpIndex > 4) {
+					wayTo = (wayTo + 2 )% 4;
+				} 
+			} else {
+				if (outpIndex < 5) {
+					wayTo = (wayTo + 2 )% 4;
+				}
+			}
+			
+			int []px = new int[3];
+			int []py = new int[3];
+			switch(wayTo) {
+				case GraphicLib.NORTH:
+				case GraphicLib.SOUTH:
+					px[0] = x+width/2;
+					px[1] = x +width/2;
+					py[0] = y;
+					py[1] = y + height;
+					break;
+				case GraphicLib.EAST:
+				case GraphicLib.WEST:
+				default:
+					px[0] = x;
+					px[1] = x +width;
+					py[0] = y+height/2;
+					py[1] = y + height/2;
+					break;
+			}
+			g.drawPolygon(px, py, 2);
+		}
+    }
+	
+	public void manageMove() {
+		if (father != null) {
+			Point p = GraphicLib.putPointOnRectangle(x+(width/2), y+(height/2), father.getX(), father.getY(), father.getWidth(), father.getHeight());
+			
+			x = p.x - width/2;
+			y = p.y - height/2;
+			
+			setMoveCd(x, y);
+			
+			int orientation = GraphicLib.getCloserOrientation(x+(width/2), y+(height/2), father.getX(), father.getY(), father.getWidth(), father.getHeight());
+			if (orientation != currentOrientation) {
+				setOrientation(orientation);
+			}
+		}
+	}
+	
+	// TGConnecting points ..
+	public void setOrientation(int orientation) {
+		currentOrientation = orientation;
+		double w0, h0,w1, h1; 
+		
+		switch(orientation) {
+			case GraphicLib.NORTH:
+				w0 = 0.5;
+				h0 = 0.0;
+				w1 = 0.5;
+				h1 = 1.0;
+				break;
+			case GraphicLib.WEST:
+				w0 = 0.0;
+				h0 = 0.5;
+				w1 = 1.0;
+				h1 = 0.5;
+				break;
+			case GraphicLib.SOUTH:
+				w1 = 0.5;
+				h1 = 0.0;
+				w0 = 0.5;
+				h0 = 1.0;
+				break;
+			case GraphicLib.EAST:
+			default:
+				w1 = 0.0;
+				h1 = 0.5;
+				w0 = 1.0;
+				h0 = 0.5;
+		}
+		
+		for (int i=0; i<5; i++) {
+			((SysCAMSPortConnectingPoint)(connectingPoint[i])).setW(w0);
+			((SysCAMSPortConnectingPoint)(connectingPoint[i])).setH(h0);
+			((SysCAMSPortConnectingPoint)(connectingPoint[i+5])).setW(w1);
+			((SysCAMSPortConnectingPoint)(connectingPoint[i+5])).setH(h1);
+		}
+	}
+    
+    public int getType() {
+        return TGComponentManager.TMLCTD_CPORT;
+    }
+	
+	public void wasSwallowed() {
+		myColor = null;
+	}
+	
+	public void wasUnswallowed() {
+		myColor = null;
+		setFather(null);
+		TDiagramPanel tdp = getTDiagramPanel();
+		setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY());
+	}
+	
+	public void resizeWithFather() {
+        if ((father != null) && (father instanceof SysCAMSCompositeComponent)) {
+			// Too large to fit in the father? -> resize it!
+            setCdRectangle(0-getWidth()/2, father.getWidth() - (getWidth()/2), 0-getHeight()/2, father.getHeight() - (getHeight()/2));
+            setMoveCd(x, y);
+			oldx = -1;
+			oldy = -1;
+        }
+    }
+	
+	public boolean editOndoubleClick(JFrame frame) {
+		JDialogSysCAMSPortConverter jtdf = new JDialogSysCAMSPortConverter((SysCAMSPortConverter) this);
+		jtdf.setVisible(true);
+    	
+        ((SysCAMSComponentTaskDiagramPanel)tdp).updatePorts();
+        return true;
+    }
+	
+	public String getPortName() {
+        return commName;
+    }
+	
+	public void setPortName(String s) {
+		commName = s;
+	}
+	
+	public void purge() {
+		inp = null;
+		outp = null;
+		conflict = false;
+		inpIndex = -1;
+		outpIndex = -1;
+		myColor = null;
+		calculatePortColor();
+	}
+	
+	public void myActionWhenRemoved() {
+		tdp = null;
+		TGComponent tgc =  getFather();
+		if (tgc instanceof SysCAMSCompositeComponent) {
+			((SysCAMSCompositeComponent)(tgc)).portRemoved();
+		}
+		father = null;
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSFork.java b/src/main/java/ui/syscams/SysCAMSFork.java
new file mode 100644
index 0000000000..b3ec86bac7
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSFork.java
@@ -0,0 +1,111 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+import ui.*;
+import ui.util.IconManager;
+
+import java.awt.*;
+
+/**
+ * Class SysCAMSFork
+ * Fork operator. To be used in SystemC-AMS component task diagrams
+ * Creation: 22/04/2018
+ * @version 1.0 22/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSFork extends SysCAMSChannelFacility implements WithAttributes {
+    protected int radius = 11;
+    protected int decPoint = 3;
+
+    public SysCAMSFork(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+
+        initScaling(2*radius, 2*radius);
+
+        nbConnectingPoint = 7;
+        connectingPoint = new TGConnectingPoint[7];
+
+        connectingPoint[0] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.0, 0.5);
+        connectingPoint[1] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 1.0, 0.5);
+        connectingPoint[2] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 1.0, 0.5);
+        connectingPoint[3] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 0.75, 0.134);
+        connectingPoint[4] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 0.75, 0.134);
+        connectingPoint[5] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 0.75, 0.866);
+        connectingPoint[6] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 0.75, 0.866);
+
+        addTGConnectingPointsComment();
+
+        nbInternalTGComponent = 0;
+
+        value = "F";
+        name = "Composite port";
+
+        myImageIcon = IconManager.imgic1204;
+    }
+
+    public void internalDrawing(Graphics g) {
+    	radius = width / 2;
+
+        if (rescaled) {
+            rescaled = false;
+        }
+        calculatePortColor();
+
+        // Zoom is assumed to be computed
+        Color c = g.getColor();
+        if ((width > 2) && (height > 2)) {
+            g.setColor(myColor);
+            g.fillOval(x, y, radius*2, radius*2);
+            g.setColor(c);
+        }
+        g.drawOval(x, y, radius*2, radius*2);
+        g.drawLine(x, y+radius, x+radius, y+radius);
+
+        GraphicLib.arrowWithLine(g, 1, 1, 5, x+radius, y+radius, x+2*radius, y+radius, false);
+        GraphicLib.arrowWithLine(g, 1, 1, 5, x+radius, y+radius, x+3*radius/2, (int)(y+(0.134*radius)), false);
+        GraphicLib.arrowWithLine(g, 1, 1, 5, x+radius, y+radius, x+3*radius/2, (int)(y+2*radius-(0.134*radius)), false);
+    }
+
+    public int getType() {
+        return TGComponentManager.TMLCTD_FORK;
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSJoin.java b/src/main/java/ui/syscams/SysCAMSJoin.java
new file mode 100644
index 0000000000..7bd2da8532
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSJoin.java
@@ -0,0 +1,115 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+import ui.*;
+import ui.util.IconManager;
+
+import java.awt.*;
+
+/**
+ * Class SysCAMSJoin
+ * Join operator. To be used in SystemC-AMS component task diagrams
+ * Creation: 22/04/2018
+ * @version 1.0 22/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSJoin extends SysCAMSChannelFacility implements WithAttributes {
+    protected int radius = 11;
+    protected int decPoint = 3;
+
+    public SysCAMSJoin(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+
+        initScaling(2*radius, 2*radius);
+
+        nbConnectingPoint = 7;
+        connectingPoint = new TGConnectingPoint[7];
+
+        // output
+        connectingPoint[0] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 1.0, 0.5);
+        // input
+        connectingPoint[1] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.0, 0.5);
+        connectingPoint[2] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.0, 0.5);
+        connectingPoint[3] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.25, 0.134);
+        connectingPoint[4] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.25, 0.134);
+        connectingPoint[5] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.25, 0.866);
+        connectingPoint[6] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.25, 0.866);
+
+        addTGConnectingPointsComment();
+
+        nbInternalTGComponent = 0;
+
+        value = "J";
+        name = "Composite port";
+
+        myImageIcon = IconManager.imgic1204;
+    }
+
+    public void internalDrawing(Graphics g) {
+
+	radius = width / 2;
+
+        if (rescaled) {
+            rescaled = false;
+        }
+
+        calculatePortColor();
+
+        // Zoom is assumed to be computed
+        Color c = g.getColor();
+        if ((width > 2) && (height > 2)) {
+            g.setColor(myColor);
+            g.fillOval(x, y, radius*2, radius*2);
+            g.setColor(c);
+        }
+        g.drawOval(x, y, radius*2, radius*2);
+        g.drawLine(x, y+radius, x+radius, y+radius);
+        g.drawLine(x+radius/2, (int)(y+(0.134*radius)), x+radius, y+radius);
+        g.drawLine(x+radius/2, (int)(y+2*radius-(0.134*radius)), x+radius, y+radius);
+
+        GraphicLib.arrowWithLine(g, 1, 1, 5, x+radius, y+radius, x+2*radius, y+radius, false);
+    }
+
+    public int getType() {
+        return TGComponentManager.TMLCTD_JOIN;
+    }
+}
diff --git a/src/main/java/ui/syscams/SysCAMSPath.java b/src/main/java/ui/syscams/SysCAMSPath.java
new file mode 100644
index 0000000000..9b05b7de2d
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSPath.java
@@ -0,0 +1,360 @@
+/* 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.syscams;
+
+import ui.TGComponent;
+import java.util.ArrayList;
+
+/**
+ * Class SysCAMSPath
+ * Notion of Path. To be used to analyze the correctness of paths in the model
+ * Creation: 07/05/2018
+ * @version 1.0 07/05/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSPath  {
+
+    public ArrayList<SysCAMSPrimitivePort> producerPorts;
+    public ArrayList<SysCAMSPrimitivePort> consumerPorts;
+
+    // Facilities
+    public ArrayList<SysCAMSCompositePort> cports;
+    public ArrayList<SysCAMSFork> forks;
+    public ArrayList<SysCAMSJoin> joins;
+
+    private boolean errorOfConnection = false;
+
+    private int errorNumber;
+    private TGComponent faultyComponent;
+
+
+    private String[] errors = {"Fork and Join operators in the same path",
+                               "Must have at least one sender",
+                               "Must have at least one receiver",
+                               "More than one sender in a path with a fork",
+                               "Senders and receivers are not of the same kind",
+                               "One of more element of the path is badly connected",
+                               "Events are not compatible with fork/join",
+                               "Requests are not compatible with fork/join",
+                               "Events/requests must all have the same parameters",
+                               "Channels and events can have only one input and one output"
+    };
+
+    public SysCAMSPath() {
+        cports = new ArrayList<SysCAMSCompositePort>();
+        producerPorts = new ArrayList<SysCAMSPrimitivePort>();
+        consumerPorts = new ArrayList<SysCAMSPrimitivePort>();
+        forks = new ArrayList<SysCAMSFork>();
+        joins = new ArrayList<SysCAMSJoin>();
+    }
+
+    public void addComponent(TGComponent _tgc) {
+        if (_tgc instanceof SysCAMSCompositePort) {
+            cports.add((SysCAMSCompositePort)_tgc);
+        }
+        if (_tgc instanceof SysCAMSPrimitivePort) {
+            SysCAMSPrimitivePort p = (SysCAMSPrimitivePort)_tgc;
+            if (p.isOrigin()) {
+                producerPorts.add(p);
+            } else {
+                consumerPorts.add(p);
+            }
+        }
+        if (_tgc instanceof SysCAMSFork) {
+            forks.add((SysCAMSFork)_tgc);
+        }
+        if (_tgc instanceof SysCAMSJoin) {
+            joins.add((SysCAMSJoin)_tgc);
+        }
+    }
+
+    public void setErrorOfConnection(boolean _err) {
+        errorOfConnection = _err;
+    }
+
+    public boolean getErrorOfConnection() {
+        return errorOfConnection;
+    }
+
+    public boolean contains(TGComponent tgc) {
+        if (cports.contains(tgc)) {
+            return true;
+        }
+        if (producerPorts.contains(tgc)) {
+            return true;
+        }
+        if (consumerPorts.contains(tgc)) {
+            return true;
+        }
+        if (forks.contains(tgc)) {
+            return true;
+        }
+        return joins.contains(tgc);
+    }
+
+    public void mergeWith(SysCAMSPath _path) {
+        cports.addAll(_path.cports);
+        producerPorts.addAll(_path.producerPorts);
+        consumerPorts.addAll(_path.consumerPorts);
+        forks.addAll(_path.forks);
+        joins.addAll(_path.joins);
+        setErrorOfConnection(getErrorOfConnection() || _path.getErrorOfConnection());
+    }
+
+    public boolean hasError() {
+        return (errorNumber != -1);
+    }
+
+    public String getErrorMessage() {
+        if (hasError()) {
+            return errors[errorNumber];
+        }
+        return "";
+    }
+
+    public TGComponent getFaultyComponent() {
+        return faultyComponent;
+    }
+
+    public void checkRules() {
+        errorNumber = -1;
+
+        //rule0: fork or join, but not both
+        if ((forks.size() > 0) && (joins.size() >0)) {
+            faultyComponent = forks.get(0);
+            errorNumber = 0;
+        }
+
+        //rule1: Must have at least one producer
+        if (producerPorts.size() == 0) {
+            errorNumber = 1;
+            if ((consumerPorts != null) && (consumerPorts.size() > 0)) {
+                faultyComponent = consumerPorts.get(0);
+            }
+        }
+
+        //rule2: Must have at least one receiver
+        if (consumerPorts.size() == 0) {
+            errorNumber = 2;
+            if ((producerPorts != null) && (producerPorts.size() > 0)) {
+                faultyComponent = producerPorts.get(0);
+            }
+        }
+
+        //rule3: If fork: must have only one producer
+        if ((forks.size() > 0) && (producerPorts.size() >1)) {
+            errorNumber = 3;
+            faultyComponent = forks.get(0);
+        }
+
+        //rule4: producers and consumers must be of the same type
+        if ((consumerPorts.size()>0) && (producerPorts.size()>0)) {
+            int type = consumerPorts.get(0).getPortType();
+            for (SysCAMSPrimitivePort porto: producerPorts) {
+                if (porto.getPortType() != type) {
+                    errorNumber = 4;
+                    faultyComponent = porto;
+                    break;
+                }
+            }
+            for (SysCAMSPrimitivePort porti: consumerPorts) {
+                if (porti.getPortType() != type) {
+                    errorNumber = 4;
+                    faultyComponent = porti;
+                    break;
+                }
+            }
+        }
+
+        //rule5: Error of connection
+        if (errorOfConnection) {
+            errorNumber = 5;
+        }
+
+        //rule7: requests cannot be connected through fork or join
+        if ((forks.size() > 0) || (joins.size() >0)) {
+            // Look for event, either at origin, or at destination
+            for (SysCAMSPrimitivePort porto: producerPorts) {
+                if (porto.getPortType() == 2) {
+                    errorNumber = 7;
+                    faultyComponent = porto;
+                    break;
+                }
+            }
+            for (SysCAMSPrimitivePort porti: consumerPorts) {
+                if (porti.getPortType() == 2) {
+                    errorNumber = 7;
+                    faultyComponent = porti;
+                    break;
+                }
+            }
+        }
+
+        //rule8: all events/requests with the same parameters
+//        if ((forks.size() > 0) || (joins.size() >0)) {
+//            if (producerPorts != null && producerPorts.size() > 0) {
+//                SysCAMSPrimitivePort referencePort = producerPorts.get(0);
+//                if (referencePort != null) {
+//                    if ((referencePort.getPortType() == 1) ||(referencePort.getPortType() == 2)) {
+//                        // Event or request found
+//                        // We now check that they are all compatible with the reference
+//                        for (SysCAMSPrimitivePort porto: producerPorts) {
+//                            if (!(porto.hasSameParametersThan(referencePort))) {
+//                                errorNumber = 8;
+//                                faultyComponent = porto;
+//                                break;
+//                            }
+//                        }
+//
+//                        for (SysCAMSPrimitivePort porti: consumerPorts) {
+//                            if (!(porti.hasSameParametersThan(referencePort))) {
+//                                errorNumber = 8;
+//                                faultyComponent = porti;
+//                                break;
+//                            }
+//                        }
+//                    }
+//                }
+//            }
+//        }
+
+        // rule9: if no fork, no join, no request: one to one communication
+        boolean foundReq = true;
+        if ((forks.size() == 0) && (joins.size() == 0)) {
+            if (producerPorts != null && producerPorts.size() > 0) {
+                SysCAMSPrimitivePort referencePort = producerPorts.get(0);
+                if (referencePort != null) {
+                    if (referencePort.getPortType() != 2) {
+                        foundReq = false;
+                    }
+                }
+            }
+            if (!foundReq) {
+                if (producerPorts.size() > 1) {
+                    errorNumber = 9;
+                    faultyComponent = producerPorts.get(1);
+                } else if (consumerPorts.size() > 1) {
+                    errorNumber = 9;
+                    faultyComponent = consumerPorts.get(1);
+                }
+            }
+        }
+    }
+
+    public void setColor() {
+        // For each channel facility,
+        // set the inp and outp primitive ports if possible (otherwise, null)
+        // if no error: set conflict to false
+        // If error -> set the conflict to true
+
+        for (SysCAMSFork fork: forks) {
+            if (producerPorts.size() > 0) {
+                fork.setOutPort(producerPorts.get(0));
+            } else {
+                fork.setOutPort(null);
+            }
+
+            if (consumerPorts.size() > 0) {
+                fork.setInPort(consumerPorts.get(0));
+            } else {
+                fork.setInPort(null);
+            }
+
+            if (hasError()) {
+                fork.setConflict(hasError(), errors[errorNumber]);
+            } else {
+                fork.setConflict(false, "");
+            }
+        }
+
+        for (SysCAMSJoin join: joins) {
+            if (producerPorts.size() > 0) {
+                join.setOutPort(producerPorts.get(0));
+            } else {
+                join.setOutPort(null);
+            }
+
+            if (consumerPorts.size() > 0) {
+                join.setInPort(consumerPorts.get(0));
+            } else {
+                join.setInPort(null);
+            }
+            if (hasError()) {
+                join.setConflict(hasError(), errors[errorNumber]);
+            } else {
+                join.setConflict(false, "");
+            }
+        }
+
+        for (SysCAMSCompositePort port: cports) {
+            if (producerPorts.size() > 0) {
+                port.setOutPort(producerPorts.get(0));
+            } else {
+                port.setOutPort(null);
+            }
+
+            if (consumerPorts.size() > 0) {
+                port.setInPort(consumerPorts.get(0));
+            } else {
+                port.setInPort(null);
+            }
+            if (hasError()) {
+                port.setConflict(hasError(), errors[errorNumber]);
+            } else {
+                port.setConflict(false, "");
+            }
+        }
+
+        for (SysCAMSPrimitivePort pport: producerPorts) {
+            if (hasError()) {
+                pport.setConflict(hasError(), errors[errorNumber]);
+            } else {
+                pport.setConflict(false, "");
+            }
+        }
+        for (SysCAMSPrimitivePort cport: consumerPorts) {
+            if (hasError()) {
+                cport.setConflict(hasError(), errors[errorNumber]);
+            } else {
+                cport.setConflict(false, "");
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSPortConnectingPoint.java b/src/main/java/ui/syscams/SysCAMSPortConnectingPoint.java
new file mode 100644
index 0000000000..2482024935
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSPortConnectingPoint.java
@@ -0,0 +1,64 @@
+/* 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.syscams;
+
+import ui.CDElement;
+import ui.TGComponentManager;
+import ui.TGConnectingPointWidthHeight;
+
+/**
+ * Class SysCAMSPortConnectingPoint
+ * Definition of connecting points on which connectors of SystemC-AMS Component Task diagrams can be connected
+ * Creation: 22/04/2018
+ * @version 1.0 22/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSPortConnectingPoint extends TGConnectingPointWidthHeight{
+    public SysCAMSPrimitivePort port;
+	public boolean positionned;
+	
+    public SysCAMSPortConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) {
+        super(_container, _x, _y, _in, _out, _w, _h);
+    }
+    
+    public boolean isCompatibleWith(int type) {
+        return type == TGComponentManager.CONNECTOR_PORT_TMLC;
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSPortConnector.java b/src/main/java/ui/syscams/SysCAMSPortConnector.java
new file mode 100644
index 0000000000..6766b226e7
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSPortConnector.java
@@ -0,0 +1,139 @@
+/* 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.syscams;
+
+import ui.*;
+import ui.util.IconManager;
+
+import java.awt.*;
+import java.util.Vector;
+
+/**
+ * Class SysCAMSPortConnector
+ * Connector used in SystemC-AMS Component task diagrams
+ * Creation: 27/04/2018
+ * @version 1.0 27/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public  class SysCAMSPortConnector extends TGConnector implements ScalableTGComponent, SpecificActionAfterAdd,  SpecificActionAfterMove{
+    protected double oldScaleFactor;
+
+    public SysCAMSPortConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) {
+        super(_x, _y,  _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint);
+        myImageIcon = IconManager.imgic202;
+        value = "Connector between ports";
+        editable = false;
+        oldScaleFactor = tdp.getZoom();
+        p1 = _p1;	
+        p2 = _p2;
+    }
+
+    public TGConnectingPoint get_p1(){
+    	return p1;
+	}
+
+    public TGConnectingPoint get_p2(){
+    	return p2;
+	}
+
+    protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){
+        try {
+            SysCAMSPortConnectingPoint pt1 = (SysCAMSPortConnectingPoint)p1;
+            SysCAMSPortConnectingPoint pt2 = (SysCAMSPortConnectingPoint)p2;
+            if (!pt1.positionned) {
+                pt1.positionned = true;
+                if (pt1.getFather() instanceof SysCAMSPrimitivePort) {
+                    pt1.port = (SysCAMSPrimitivePort)(pt1.getFather());
+                }
+            }
+            if (!pt2.positionned) {
+                pt2.positionned = true;
+                if (pt2.getFather() instanceof SysCAMSPrimitivePort) {
+                    pt2.port = (SysCAMSPrimitivePort)(pt2.getFather());
+                }
+            }
+            if ((pt1.port != null) && (pt2.port != null)) {
+                String name1 = pt1.port.getPortName();
+                String name2 = pt2.port.getPortName();
+                if (name1.equals(name2)) {
+                    int w = g.getFontMetrics().stringWidth(name1);
+                    Font fold = g.getFont();
+                    Font f = fold.deriveFont(Font.ITALIC, (float)(tdp.getFontSize()));
+                    g.setFont(f);
+                    g.drawString(name1, (x1 + x2 - w)/2, (y1 + y2)/2);
+                    g.setFont(fold);
+                }
+            }
+            g.drawLine(x1, y1, x2, y2);
+            return;
+        } catch (Exception e) {
+        }
+        g.drawLine(x1, y1, x2, y2);
+    }
+
+    public void rescale(double scaleFactor){
+        int xx, yy;
+
+        for(int i=0; i<nbInternalTGComponent; i++) {
+            xx = tgcomponent[i].getX();
+            yy = tgcomponent[i].getY();
+            tgcomponent[i].dx = (tgcomponent[i].dx + xx) / oldScaleFactor * scaleFactor;
+            tgcomponent[i].dy = (tgcomponent[i].dy + yy) / oldScaleFactor * scaleFactor;
+            xx = (int)(tgcomponent[i].dx);
+            tgcomponent[i].dx = tgcomponent[i].dx - xx;
+            yy = (int)(tgcomponent[i].dy);
+            tgcomponent[i].dy = tgcomponent[i].dy - yy;
+            tgcomponent[i].setCd(xx, yy);
+        }
+        oldScaleFactor = scaleFactor;
+    }
+
+    public int getType() {
+        return TGComponentManager.CONNECTOR_PORT_TMLC;
+    }
+
+    public void specificActionAfterAdd() {
+        ((SysCAMSComponentTaskDiagramPanel)tdp).updatePorts();
+    }
+
+    public void specificActionAfterMove() {
+        ((SysCAMSComponentTaskDiagramPanel)tdp).updatePorts();
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSPortConverter.java b/src/main/java/ui/syscams/SysCAMSPortConverter.java
new file mode 100644
index 0000000000..ceaf066a16
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSPortConverter.java
@@ -0,0 +1,57 @@
+package ui.syscams;
+
+import ui.TDiagramPanel;
+import ui.TGComponent;
+
+public class SysCAMSPortConverter extends SysCAMSCompositePort {
+	private int period;
+	private int rate;
+	private int delay;
+	private String origin;
+	private String convType;
+	
+	public SysCAMSPortConverter(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos,
+			TGComponent _father, TDiagramPanel _tdp) {
+		super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+	}
+
+	public int getPeriod() {
+		return period;
+	}
+
+	public void setPeriod(int period) {
+		this.period = period;
+	}
+
+	public int getRate() {
+		return rate;
+	}
+
+	public void setRate(int rate) {
+		this.rate = rate;
+	}
+
+	public int getDelay() {
+		return delay;
+	}
+
+	public void setDelay(int delay) {
+		this.delay = delay;
+	}
+
+	public String getOrigin() {
+		return origin;
+	}
+
+	public void setOrigin(String origin) {
+		this.origin = origin;
+	}
+
+	public String getConvType() {
+		return convType;
+	}
+
+	public void setConvType(String convType) {
+		this.convType = convType;
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSPortDE.java b/src/main/java/ui/syscams/SysCAMSPortDE.java
new file mode 100644
index 0000000000..5f837c6d98
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSPortDE.java
@@ -0,0 +1,62 @@
+package ui.syscams;
+
+import java.awt.Graphics;
+
+import ui.TDiagramPanel;
+import ui.TGComponent;
+
+public class SysCAMSPortDE extends SysCAMSPrimitivePort {
+	private int period;
+	private int rate;
+	private int delay;
+	private String origin;
+	private String DEType;
+	
+	public SysCAMSPortDE(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father,
+			TDiagramPanel _tdp) {
+		super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+	}
+
+	public String getDEType() {
+		return DEType;
+	}
+
+	public void setDEType(String DEType) {
+		this.DEType = DEType;
+	}
+
+	public String getOrigin() {
+		return origin;
+	}
+
+	public void setOrigin(String origin) {
+		this.origin = origin;
+	}
+
+	public int getPeriod() {
+		return period;
+	}
+
+	public void setPeriod(int period) {
+		this.period = period;
+	}
+
+	public int getRate() {
+		return rate;
+	}
+
+	public void setRate(int rate) {
+		this.rate = rate;
+	}
+
+	public int getDelay() {
+		return delay;
+	}
+
+	public void setDelay(int delay) {
+		this.delay = delay;
+	}
+
+	public void drawParticularity(Graphics g) {
+	}	
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSPortTDF.java b/src/main/java/ui/syscams/SysCAMSPortTDF.java
new file mode 100644
index 0000000000..afc054a3a0
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSPortTDF.java
@@ -0,0 +1,62 @@
+package ui.syscams;
+
+import java.awt.Graphics;
+
+import ui.TDiagramPanel;
+import ui.TGComponent;
+
+public class SysCAMSPortTDF extends SysCAMSPrimitivePort {
+	private int period;
+	private int rate;
+	private int delay;
+	private String origin;
+	private String TDFType;
+	
+	public SysCAMSPortTDF(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father,
+			TDiagramPanel _tdp) {
+		super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+	}
+	
+	public String getTDFType() {
+		return TDFType;
+	}
+
+	public void setTDFType(String tDFType) {
+		TDFType = tDFType;
+	}
+
+	public String getOrigin() {
+		return origin;
+	}
+
+	public void setOrigin(String origin) {
+		this.origin = origin;
+	}
+
+	public int getPeriod() {
+		return period;
+	}
+
+	public void setPeriod(int period) {
+		this.period = period;
+	}
+
+	public int getRate() {
+		return rate;
+	}
+
+	public void setRate(int rate) {
+		this.rate = rate;
+	}
+
+	public int getDelay() {
+		return delay;
+	}
+
+	public void setDelay(int delay) {
+		this.delay = delay;
+	}
+
+	public void drawParticularity(Graphics g) {
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSPrimitiveComponent.java b/src/main/java/ui/syscams/SysCAMSPrimitiveComponent.java
new file mode 100644
index 0000000000..152f6ea18b
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSPrimitiveComponent.java
@@ -0,0 +1,620 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import ui.*;
+import ui.util.IconManager;
+//import ui.window.JDialogAttribute;
+import ui.window.JDialogSysCAMSBlockDE;
+import ui.window.JDialogSysCAMSBlockTDF;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.Vector;
+
+/**
+ * Class SysCAMSPrimitiveComponent
+ * Primitive Component. To be used in SystemC-AMSdiagrams
+ * Creation: 27/04/2018
+ * @version 1.0 27/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSPrimitiveComponent extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent, WithAttributes {
+    private int maxFontSize = 14;
+    private int minFontSize = 4;
+    private int currentFontSize = -1;
+    private boolean displayText = true;
+    private Color myColor;
+
+	private boolean isAttacker=false;
+    // Icon
+    private int iconSize = 15;
+//    private boolean iconIsDrawn = false;
+
+    // Attributes
+    public HashMap<String, Integer> attrMap = new HashMap<String, Integer>();
+    public String mappingName;
+    protected LinkedList<TAttribute> myAttributes;
+    private int textX = 15; // border for ports
+    private double dtextX = 0.0;
+
+    public String oldValue;
+
+    public SysCAMSPrimitiveComponent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+
+        initScaling(200, 150);
+
+        oldScaleFactor = tdp.getZoom();
+        dtextX = textX * oldScaleFactor;
+        textX = (int)dtextX;
+        dtextX = dtextX - textX;
+
+        minWidth = 1;
+        minHeight = 1;
+
+        nbConnectingPoint = 0;
+
+        addTGConnectingPointsComment();
+
+        nbInternalTGComponent = 0;
+
+        moveable = true;
+        multieditable = true;
+        editable = true;
+        removable = true;
+        userResizable = true;
+
+        if (this instanceof SysCAMSBlockTDF) {
+        	value = "TDF_Block";
+        } else if (this instanceof SysCAMSBlockDE) {
+        	value = "DE_Block";
+        }
+        
+//        oldValue = value;
+//        setName("Primitive component");
+        name = "Primitive component";
+        
+        myImageIcon = IconManager.imgic1202;
+
+        myAttributes = new LinkedList<TAttribute> ();
+
+        actionOnAdd();
+    }
+
+    public void internalDrawing(Graphics g) {
+        int w;
+        Font f = g.getFont();
+        Font fold = f;
+
+        if (myColor == null) {
+            if (ColorManager.TML_COMPOSITE_COMPONENT == Color.white) {
+                myColor = Color.white;
+            } else {
+            	if (this instanceof SysCAMSBlockTDF) {
+            		myColor = Color.lightGray;
+            	} else {
+            		myColor = Color.white;
+            	}
+            }
+        }
+        if ((rescaled) && (!tdp.isScaled())) {
+            if (currentFontSize == -1) {
+                currentFontSize = f.getSize();
+            }
+            rescaled = false;
+            // Must set the font size ..
+            // Find the biggest font not greater than max_font size
+            // By Increment of 1
+            // Or decrement of 1
+            // If font is less than 4, no text is displayed
+
+            int maxCurrentFontSize = Math.max(0, Math.min(height-(2*textX), maxFontSize));
+            f = f.deriveFont((float)maxCurrentFontSize);
+            g.setFont(f);
+            while(maxCurrentFontSize > (minFontSize-1)) {
+                if (g.getFontMetrics().stringWidth(value) < (width - iconSize - (2 * textX))) {
+                    break;
+                }
+                maxCurrentFontSize --;
+                f = f.deriveFont((float)maxCurrentFontSize);
+                g.setFont(f);
+            }
+            currentFontSize = maxCurrentFontSize;
+            if(currentFontSize <minFontSize) {
+                displayText = false;
+            } else {
+                displayText = true;
+                f = f.deriveFont((float)currentFontSize);
+                g.setFont(f);
+            }
+        }
+
+        // Zoom is assumed to be computed
+        Color c = g.getColor();
+        g.drawRect(x, y, width, height);
+        if ((width > 2) && (height > 2)) {
+            g.setColor(myColor);
+            g.fillRect(x+1, y+1, width-1, height-1);
+            g.setColor(c);
+        }
+
+        // Font size
+        if (displayText) {
+            f = f.deriveFont((float)currentFontSize);
+            g.setFont(f);
+            w = g.getFontMetrics().stringWidth(value);
+            if (w > (width - 2 * (iconSize + textX))) {
+                g.drawString(value, x + textX + 1, y + currentFontSize + textX);
+                
+                if (this instanceof SysCAMSBlockTDF) {
+                	String s = "Tm = " + ((SysCAMSBlockTDF) this).getPeriod();
+                	g.drawString(s, x + textX + 1, y + height - currentFontSize - textX);
+                } else if (this instanceof SysCAMSBlockDE) {
+                	String s = "Tm = " + ((SysCAMSBlockDE) this).getPeriod();
+                	g.drawString(s, x + textX + 1, y + height - currentFontSize - textX);
+                }
+            } else {
+                g.drawString(value, x + (width - w)/2, y + currentFontSize + textX);
+                if (this instanceof SysCAMSBlockTDF) {
+                	String s = "Tm = " + ((SysCAMSBlockTDF) this).getPeriod();
+                	w = g.getFontMetrics().stringWidth(s);
+                	g.drawString(s, x + (width - w)/2, y + height - currentFontSize - textX);
+                } else if (this instanceof SysCAMSBlockDE) {
+                	String s = "Tm = " + ((SysCAMSBlockDE) this).getPeriod();
+                	w = g.getFontMetrics().stringWidth(s);
+                	g.drawString(s, x + (width - w)/2, y + height - currentFontSize - textX);
+                }
+            }
+        }
+
+//        // Icon
+//        if ((width>30) && (height > (iconSize + 2*textX))) {
+//            iconIsDrawn = true;
+//            g.drawImage(IconManager.imgic1200.getImage(), x + width - iconSize - textX, y + textX, null);
+//        } else {
+//            iconIsDrawn = false;
+//        }
+//		if (isAttacker){
+//			g.drawImage(IconManager.imgic7008.getImage(), x + width - 2*iconSize - textX, y + 2*textX, null);
+//		}
+
+        // Attributes
+        if (tdp.areAttributesVisible()) {
+            int index = 0;
+            int cpt = currentFontSize + 2 * textX;
+            String attr;
+
+            TAttribute a;
+
+            int si = Math.min(12, (int)((float)currentFontSize - 2));
+
+            f = g.getFont();
+            f = f.deriveFont((float)si);
+            g.setFont(f);
+            int step = si + 2;
+
+            while(index < myAttributes.size()) {
+                cpt += step;
+                if (cpt >= (height - textX)) {
+                    break;
+                }
+                a = myAttributes.get (index);
+                attr = a.toString();
+                w = g.getFontMetrics().stringWidth(attr);
+                if ((w + (2 * textX) + 1) < width) {
+                    g.drawString(attr, x + textX, y + cpt);
+                    drawVerification(g, x + textX, y+ cpt, a.getConfidentialityVerification());
+                } else {
+                    attr = "...";
+                    w = g.getFontMetrics().stringWidth(attr);
+                    if ((w + textX + 2) < width) {
+                        g.drawString(attr, x + textX + 1, y + cpt);
+                    } else {
+                        // skip attribute
+                        cpt -= step;
+                    }
+                }
+                index ++;
+            }
+        }
+        g.setFont(fold);
+    }
+     public void drawVerification(Graphics g, int x, int y, int checkConfStatus){
+        Color c = g.getColor();
+        Color c1;
+        switch(checkConfStatus) {
+        case TAttribute.CONFIDENTIALITY_OK:
+            c1 = Color.green;
+            break;
+        case TAttribute.CONFIDENTIALITY_KO:
+            c1 = Color.red;
+            break;
+        default:
+            return;
+        }
+		g.drawOval(x-10, y-10, 6, 9);
+		g.setColor(c1);
+		g.fillRect(x-12, y-5, 9, 7);
+		g.setColor(c);
+		g.drawRect(x-12, y-5, 9, 7);
+    }
+
+    public void rescale(double scaleFactor){
+        dtextX = (textX + dtextX) / oldScaleFactor * scaleFactor;
+        textX = (int)(dtextX);
+        dtextX = dtextX - textX;
+        super.rescale(scaleFactor);
+    }
+
+    public TGComponent isOnOnlyMe(int _x, int _y) {
+        if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) {
+            return this;
+        }
+        return null;
+    }
+
+
+	public boolean isAttacker(){
+		return isAttacker;
+	}
+
+    public boolean editOndoubleClick(JFrame frame, int _x, int _y) {
+//        // On the icon?
+//        if (iconIsDrawn) {
+//            if (GraphicLib.isInRectangle(_x, _y, x + width - iconSize - textX, y + textX, iconSize, iconSize)) {
+//            	tdp.getMouseManager().setSelection(-1, -1);
+//                tdp.selectTab(getValue());
+//                return true;
+//            }
+//        }
+        // On the name ?
+//        if ((displayText) && (_y <= (y + currentFontSize + textX))) {
+////            oldValue = value;
+//            String s = (String)JOptionPane.showInputDialog(frame, "Name:", "Setting component name",
+//                                                           JOptionPane.PLAIN_MESSAGE, IconManager.imgic100,
+//                                                           null,
+//                                                           getValue());
+//            if ((s != null) && (s.length() > 0)) {
+//                // Check whether this name is already in use, or not
+//                if (!TAttribute.isAValidId(s, false, false)) {
+//                    JOptionPane.showMessageDialog(frame,
+//                                                  "Could not change the name of the component: the new name is not a valid name",
+//                                                  "Error",
+//                                                  JOptionPane.INFORMATION_MESSAGE);
+//                    return false;
+//                }
+//                if (oldValue.compareTo(s) != 0) {
+//                    if (((SysCAMSComponentTaskDiagramPanel)(tdp)).namePrimitiveComponentInUse(oldValue, s)) {
+//                        JOptionPane.showMessageDialog(frame,
+//                                                      "Error: the name is already in use",
+//                                                      "Name modification",
+//                                                      JOptionPane.ERROR_MESSAGE);
+//                        return false;
+//                    }
+//                }
+//                if (((SysCAMSComponentTaskDiagramPanel)(tdp)).isCompositeNameUsed(s)) {
+//                    JOptionPane.showMessageDialog(frame,
+//                                                  "Error: the name is already in use",
+//                                                  "Name modification",
+//                                                  JOptionPane.ERROR_MESSAGE);
+//                    return false;
+//                }
+//    			setComponentName(s);
+//                setValueWithChange(s);
+////				isAttacker = s.contains("Attacker");
+//                rescaled = true;
+//                return true;
+//
+//            }
+//            return false;
+//        }
+
+        // And so -> attributes!
+//        JDialogAttribute jda = new JDialogAttribute(myAttributes, null, frame, "Setting attributes of " + value, "Attribute");
+//        setJDialogOptions(jda);
+//        GraphicLib.centerOnParent(jda, 650, 375);
+        if (this instanceof SysCAMSBlockTDF) {
+        	JDialogSysCAMSBlockTDF jtdf = new JDialogSysCAMSBlockTDF((SysCAMSBlockTDF) this);
+        	jtdf.setVisible(true);
+        } else {
+        	JDialogSysCAMSBlockDE jde = new JDialogSysCAMSBlockDE((SysCAMSBlockDE) this);
+        	jde.setVisible(true);
+    	}	
+//        jda.setVisible(true); // blocked until dialog has been closed
+        rescaled = true;
+        return true;
+
+    }
+
+//    protected void setJDialogOptions(JDialogAttribute jda) {
+//        jda.addAccess(TAttribute.getStringAccess(TAttribute.PUBLIC));
+//        jda.addAccess(TAttribute.getStringAccess(TAttribute.PRIVATE));
+//        jda.addType(TAttribute.getStringType(TAttribute.NATURAL), true);
+//        jda.addType(TAttribute.getStringType(TAttribute.BOOLEAN), true);
+//
+//        Vector<String> records = ((SysCAMSComponentTaskDiagramPanel)(tdp)).getAllRecords(this);
+//        for(String s: records) {
+//            jda.addType(s, false);
+//        }
+//        jda.enableInitialValue(true);
+//        jda.enableRTLOTOSKeyword(true);
+//        jda.enableJavaKeyword(false);
+//        jda.enableTMLKeyword(false);
+//    }
+
+    public Vector<String> getAllRecords() {
+        return ((SysCAMSComponentTaskDiagramPanel)(tdp)).getAllRecords(this);
+    }
+
+    public SysCAMSRecordComponent getRecordNamed(String _nameOfRecord) {
+        return ((SysCAMSComponentTaskDiagramPanel)(tdp)).getRecordNamed(this, _nameOfRecord);
+    }
+
+    public int getType() {
+        return TGComponentManager.TMLCTD_PCOMPONENT;
+    }
+
+    public void wasSwallowed() {
+        myColor = null;
+    }
+
+    public void wasUnswallowed() {
+        myColor = null;
+        setFather(null);
+        TDiagramPanel tdp = getTDiagramPanel();
+        setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY());
+    }
+
+    public boolean acceptSwallowedTGComponent(TGComponent tgc) {
+        return tgc instanceof SysCAMSPrimitivePort;
+    }
+
+    public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) {
+        //TraceManager.addDev("Add swallow component");
+        // Choose its position
+        // Make it an internal component
+        // It's one of my son
+        //Set its coordinates
+        if (tgc instanceof SysCAMSPrimitivePort) {
+            tgc.setFather(this);
+            tgc.setDrawingZone(true);
+            tgc.resizeWithFather();
+            addInternalComponent(tgc, 0);
+            return true;
+        }
+        return false;
+    }
+
+    public void removeSwallowedTGComponent(TGComponent tgc) {
+        removeInternalComponent(tgc);
+    }
+
+    public void hasBeenResized() {
+        rescaled = true;
+        for(int i=0; i<nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSPrimitivePort) {
+                tgcomponent[i].resizeWithFather();
+            }
+        }
+        if (getFather() != null) {
+            resizeWithFather();
+        }
+    }
+
+    public void resizeWithFather() {
+        if ((father != null) && (father instanceof SysCAMSCompositeComponent)) {
+            // Too large to fit in the father? -> resize it!
+            resizeToFatherSize();
+
+            setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight());
+            setMoveCd(x, y);
+        }
+    }
+
+    public int getChildCount() {
+        return myAttributes.size() + nbInternalTGComponent + 1;
+    }
+
+    public Object getChild(int index) {
+        if (index == 0) {
+            return value;
+        } else {
+            if (index <= myAttributes.size()) {
+                return myAttributes.get (index-1);
+            } else {
+                return tgcomponent[index-1-myAttributes.size()];
+            }
+        }
+    }
+
+    public int getIndexOfChild(Object child) {
+        if (child instanceof String) {
+            return 0;
+        } else {
+            if (myAttributes.indexOf(child) > -1) {
+                return myAttributes.indexOf(child) + 1;
+            } else {
+                for(int i=0; i<nbInternalTGComponent; i++) {
+                    if (tgcomponent[i] == child) {
+                        return myAttributes.size() + 1 + i;
+                    }
+                }
+            }
+        }
+        return -1;
+    }
+
+    protected String translateExtraParam() {
+        TAttribute a;
+        StringBuffer sb = new StringBuffer("<extraparam>\n");
+			sb.append("<Data isAttacker=\"");
+            sb.append(isAttacker() ? "Yes": "No");
+	        sb.append("\" />\n");
+        for(int i=0; i<myAttributes.size(); i++) {
+            a = myAttributes.get (i);
+            sb.append("<Attribute access=\"");
+            sb.append(a.getAccess());
+            sb.append("\" id=\"");
+            sb.append(a.getId());
+            sb.append("\" value=\"");
+            sb.append(a.getInitialValue());
+            sb.append("\" type=\"");
+            sb.append(a.getType());
+            sb.append("\" typeOther=\"");
+            sb.append(a.getTypeOther());
+            sb.append("\" />\n");
+        }
+        sb.append("</extraparam>\n");
+        return new String(sb);
+    }
+
+    public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{
+        try {
+            NodeList nli;
+            Node n1, n2;
+            Element elt;
+            int access, type;
+            String typeOther;
+            String id, valueAtt;
+
+            for(int i=0; i<nl.getLength(); i++) {
+                n1 = nl.item(i);
+                if (n1.getNodeType() == Node.ELEMENT_NODE) {
+                    nli = n1.getChildNodes();
+                    for(int j=0; j<nli.getLength(); j++) {
+                        n2 = nli.item(j);
+                        if (n2.getNodeType() == Node.ELEMENT_NODE) {
+                            elt = (Element) n2;
+							if (elt.getTagName().equals("Data")) {
+                                isAttacker = elt.getAttribute("isAttacker").equals("Yes");
+							}
+                            if (elt.getTagName().equals("Attribute")) {
+                                access = Integer.decode(elt.getAttribute("access")).intValue();
+                                type = Integer.decode(elt.getAttribute("type")).intValue();
+                                try {
+                                    typeOther = elt.getAttribute("typeOther");
+                                } catch (Exception e) {
+                                    typeOther = "";
+                                }
+                                id = elt.getAttribute("id");
+                                valueAtt = elt.getAttribute("value");
+
+                                if (valueAtt.equals("null")) {
+                                    valueAtt = "";
+                                }
+                                if ((TAttribute.isAValidId(id, false, false)) && (TAttribute.isAValidInitialValue(type, valueAtt))) {
+                                    TAttribute ta = new TAttribute(access, id, valueAtt, type, typeOther);
+                                    myAttributes.add (ta);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            throw new MalformedModelingException();
+        }
+    }
+
+    public int getCurrentFontSize() {
+        return currentFontSize;
+    }
+
+    public java.util.List<TAttribute> getAttributeList() {
+        return myAttributes;
+    }
+
+    public java.util.List<SysCAMSPrimitivePort> getAllTDFOriginPorts() {
+        return getAllPorts(0, true);
+    }
+
+    public java.util.List<SysCAMSPrimitivePort> getAllTDFDestinationPorts() {
+        return getAllPorts(0, false);
+    }
+
+    public java.util.List<SysCAMSPrimitivePort> getAllDEOriginPorts() {
+        return getAllPorts(1, true);
+    }
+
+    public java.util.List<SysCAMSPrimitivePort> getAllDEDestinationPorts() {
+        return getAllPorts(1, false);
+    }
+
+    public java.util.List<SysCAMSPrimitivePort> getAllPorts(int _type, boolean _isOrigin) {
+    	java.util.List<SysCAMSPrimitivePort> ret = new LinkedList<SysCAMSPrimitivePort>();
+        SysCAMSPrimitivePort port;
+
+        for(int i=0; i<nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSPrimitivePort) {
+                port = (SysCAMSPrimitivePort)tgcomponent[i];
+                if ((port.getPortType() == _type) && (port.isOrigin() == _isOrigin)) {
+                    ret.add(port);
+                }
+            }
+        }
+        return ret;
+    }
+
+    public java.util.List<SysCAMSPrimitivePort> getAllInternalPrimitivePorts() {
+    	java.util.List<SysCAMSPrimitivePort> list = new ArrayList<SysCAMSPrimitivePort>();
+        for(int i=0; i<nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSPrimitivePort) {
+                list.add((SysCAMSPrimitivePort)(tgcomponent[i]));
+            }
+        }
+        return list;
+    }
+
+    public String getAttributes() {
+        String attr = "";
+        for (TAttribute a: myAttributes) {
+            attr +=  a.toAvatarString() + "\n";
+        }
+        return attr;
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSPrimitivePort.java b/src/main/java/ui/syscams/SysCAMSPrimitivePort.java
new file mode 100644
index 0000000000..2e79885b2f
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSPrimitivePort.java
@@ -0,0 +1,878 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import ui.*;
+import ui.tmlad.TMLADNotifiedEvent;
+import ui.tmlad.TMLADReadChannel;
+import ui.tmlad.TMLADSendEvent;
+import ui.tmlad.TMLADSendRequest;
+import ui.tmlad.TMLADWaitEvent;
+import ui.tmlad.TMLADWriteChannel;
+import ui.tmldd.TMLArchiCPNode;
+import ui.tmldd.TMLArchiPortArtifact;
+import ui.util.IconManager;
+import ui.window.JDialogSysCAMSPortDE;
+import ui.window.JDialogSysCAMSPortTDF;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * Class SysCAMSPrimitivePort
+ * Primitive port. To be used in SystemC-AMS diagrams
+ * Creation: 27/04/2018
+ * @version 1.0 27/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public abstract class SysCAMSPrimitivePort extends TGCScalableWithInternalComponent implements SwallowedTGComponent, LinkedReference, WithAttributes {
+    protected Color myColor;
+    protected int orientation;
+    protected int oldx, oldy;
+    protected int halfwidth = 13;
+    protected int currentOrientation = GraphicLib.NORTH;
+
+    protected int nbMaxAttribute = 5;
+    protected TType list[];
+    protected int maxSamples = 8;
+    protected int widthSamples = 4;
+    protected boolean isFinite = false;
+    protected boolean isBlocking = false;
+    public boolean isOrigin = true;
+    public int typep = 0;
+    protected int oldTypep = typep;
+    public String commName;
+
+    protected boolean isLossy;
+    protected boolean isPostex = false;
+    protected boolean isPrex = false;
+    protected int lossPercentage;
+    protected int maxNbOfLoss; //-1 means no max
+
+    //Security Verification
+    public int checkConfStatus;
+
+    public int checkSecConfStatus;
+    public String secName="";
+
+    public int checkWeakAuthStatus;
+    public int checkStrongAuthStatus;
+    public boolean checkConf;
+    public boolean checkAuth;
+    public static int NOCHECK= 0;
+    public static int TOCHECK = 1;
+    public static int CHECKED_CONF = 2;
+    public static int CHECKED_UNCONF = 3;
+
+    public String mappingName="???";
+    protected int decPoint = 3;
+
+    protected boolean conflict = false;
+    protected String conflictMessage;
+    protected String dataFlowType = "VOID";
+    protected String associatedEvent = "VOID";
+
+    public int verification;
+    
+    private ImageIcon portImageIconTDF, portImageIconDE;
+    
+    public SysCAMSPrimitivePort(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+
+        initScaling(2*halfwidth, 2*halfwidth);
+
+        minWidth = 1;
+        minHeight = 1;
+
+        nbConnectingPoint = 1;
+        connectingPoint = new TGConnectingPoint[1];
+		for (int i=0; i<1; i++) {
+			connectingPoint[i] = new SysCAMSPortConnectingPoint(this, 0, 0, true, true, 0.5, 0.0);
+		}
+        
+        addTGConnectingPointsComment();
+
+        nbInternalTGComponent = 0;
+
+        moveable = true;
+        editable = true;
+        removable = true;
+        userResizable = false;
+        checkConf=false;
+        commName = "comm";
+        makeValue();
+        setName("Primitive port");
+        checkConfStatus= NOCHECK;
+        list = new TType[nbMaxAttribute];
+        for(int i=0; i<nbMaxAttribute; i++) {
+            list[i] = new TType();
+        }
+        myImageIcon = IconManager.imgic1206;
+        portImageIconTDF = IconManager.imgic8000;
+        portImageIconDE = IconManager.imgic8001;
+        
+        // Initialization of port attributes
+        if (this instanceof SysCAMSPortTDF) {
+        	((SysCAMSPortTDF) this).setTDFType("");
+        } else if (this instanceof SysCAMSPortDE) {
+        	((SysCAMSPortDE) this).setDEType("");
+        }
+    }
+
+    public void initConnectingPoint(boolean in, boolean out, int nb) {
+        nbConnectingPoint = nb;
+        connectingPoint = new TGConnectingPoint[nb];
+        int i;
+        for (i=0; i<nbConnectingPoint; i++) {
+            connectingPoint[i] = new SysCAMSPortConnectingPoint(this, 0, 0, in, out, 0.5, 0.0);
+        }
+    }
+
+    public Color getMyColor() {
+        return myColor;
+    }
+
+    public void internalDrawing(Graphics g) {
+        if ((x != oldx) | (oldy != y)) {
+            // Component has moved!
+            manageMove();
+            oldx = x;
+            oldy = y;
+        }
+        calculatePortColor();
+
+        if (rescaled) {
+            rescaled = false;
+        }
+
+        // Zoom is assumed to be computed
+        Color c = g.getColor();
+        g.setColor(c);
+         
+        TGComponent tgc = getFather();
+        if ((tgc != null) && (tgc instanceof SysCAMSPrimitiveComponent)) {
+        	if (tgc instanceof SysCAMSBlockTDF && this instanceof SysCAMSPortTDF) {
+        		g.drawRect(x+width/2-portImageIconTDF.getIconWidth()/2, y+height/2-portImageIconTDF.getIconHeight()/2, portImageIconTDF.getIconWidth(), portImageIconTDF.getIconHeight());
+        		g.drawImage(portImageIconTDF.getImage(), x+width/2-portImageIconTDF.getIconWidth()/2, y+height/2-portImageIconTDF.getIconHeight()/2, null);
+        	} else if (tgc instanceof SysCAMSBlockDE && this instanceof SysCAMSPortDE) {
+        		g.drawRect(x+width/2-portImageIconDE.getIconWidth()/2, y+height/2-portImageIconDE.getIconHeight()/2, portImageIconDE.getIconWidth(), portImageIconDE.getIconHeight());
+        		g.drawImage(portImageIconDE.getImage(), x+width/2-portImageIconDE.getIconWidth()/2, y+height/2-portImageIconDE.getIconHeight()/2, null);
+        	}
+        }
+        
+        int ft = 10;
+        if ((tgc != null) && (tgc instanceof SysCAMSPrimitiveComponent)) {
+            ft = ((SysCAMSPrimitiveComponent)tgc).getCurrentFontSize();
+        }
+        int w;
+        Font f = g.getFont();
+        Font fold = f;
+
+        int si = Math.min(8, (int)((float)ft - 2));
+        f = f.deriveFont((float)si);
+        g.setFont(f);
+        w = g.getFontMetrics().stringWidth(commName);
+        if (w < ((int)(width * 1.5))) {
+            g.drawString(commName, x, y-1);
+        }
+
+        if (checkConf && isOrigin){
+            drawConfVerification(g);
+        }
+        if (checkAuth && !isOrigin){
+            drawAuthVerification(g);
+        }
+        g.setFont(fold);
+
+        drawParticularity(g);
+    }
+
+    public abstract void drawParticularity(Graphics g);
+
+    public void drawAuthVerification(Graphics g){
+        int lockwidth=(int) (16*tdp.getZoom());
+        int lockheight=(int) (16*tdp.getZoom());
+
+        int xc=(int) (18*tdp.getZoom());
+        int yc= (int) (12*tdp.getZoom());
+
+        int xoffset= (int) (20*tdp.getZoom());
+        int yoffset= (int) (18*tdp.getZoom());
+
+        int ovalwidth=(int) (10*tdp.getZoom());
+        int ovalheight=(int) (15*tdp.getZoom());
+        g.drawString(secName, x-xc*2/3, y+yc*2/3);
+        Color c = g.getColor();
+        Color c1;
+        Color c2;
+        switch(checkStrongAuthStatus) {
+        case 2:
+            c1 = Color.green;
+            break;
+        case 3:
+            c1 = Color.red;
+            break;
+        default:
+            c1 = Color.gray;
+        }
+        switch(checkWeakAuthStatus) {
+        case 2:
+            c2 = Color.green;
+            break;
+        case 3:
+            c2 = Color.red;
+            break;
+        default:
+            c2= c1;
+        }
+        g.drawOval(x-xc, y+yc, ovalwidth, ovalheight);
+        g.setColor(c1);
+        int[] xps = new int[]{x-xoffset, x-xoffset, x-xoffset+lockwidth};
+        int[] yps = new int[]{y+yoffset, y+yoffset+lockheight, y+yoffset+lockheight};
+        int[] xpw = new int[]{x-xoffset+lockwidth, x-xoffset+lockwidth, x-xoffset};
+        int[] ypw = new int[]{y+yoffset+lockheight, y+yoffset, y+yoffset};
+        g.fillPolygon(xps, yps,3);
+
+        g.setColor(c2);
+        g.fillPolygon(xpw, ypw, 3);
+        g.setColor(c);
+        g.drawPolygon(xps, yps,3);
+        g.drawPolygon(xpw, ypw, 3);
+        g.drawString("S", x-xoffset+1, y+yc+yoffset);
+        g.drawString("W", x-xoffset+lockwidth/2, y+yc+ovalheight);
+        if (checkStrongAuthStatus ==3){
+            g.drawLine(x-xoffset, y+yoffset*3/2, x-xoffset/2, y+yoffset+yc);
+            g.drawLine(x-xoffset, y+yoffset+yc, x-xoffset/2, y+yoffset*3/2);
+        }
+        if (checkWeakAuthStatus==3 || checkStrongAuthStatus==3 && checkWeakAuthStatus <2){
+            g.drawLine(x-xc*2/3, y+yoffset, x-xc/3, y+yc+lockheight);
+            g.drawLine(x-xc*2/3, y+yc+lockheight, x-xc/3, y+yoffset);
+        }
+    }
+
+    public void drawConfVerification(Graphics g){
+        int lockwidth=(int) (9*tdp.getZoom());
+        int lockheight=(int) (7*tdp.getZoom());
+        int yoffset = 3*lockheight;
+
+        int ovalwidth=(int) (6*tdp.getZoom());
+        int ovalheight=(int) (9*tdp.getZoom());
+
+        Color c = g.getColor();
+        Color c1;
+        switch(checkConfStatus) {
+        case 1:
+            c1 = Color.gray;
+            break;
+        case 2:
+            c1 = Color.green;
+            break;
+        case 3:
+            c1 = Color.red;
+            break;
+        default:
+            return;
+        }
+        g.drawString(mappingName, x-lockwidth*2, y-lockheight);
+        g.drawOval(x-ovalwidth*2, y, ovalwidth, ovalheight);
+        g.setColor(c1);
+        g.fillRect(x-lockwidth*3/2, y+lockheight/2, lockwidth, lockheight);
+        g.setColor(c);
+        g.drawRect(x-lockwidth*3/2, y+lockheight/2, lockwidth, lockheight);
+        if (checkConfStatus==3){
+            g.drawLine(x-lockwidth*2, y, x, y+lockheight*2);
+            g.drawLine(x-lockwidth*2, y+lockheight*2, x, y);
+        }
+        if (!secName.equals("")){
+            switch(checkSecConfStatus) {
+            case 1:
+                c1 = Color.gray;
+                break;
+            case 2:
+                c1 = Color.green;
+                break;
+            case 3:
+                c1 = Color.red;
+                break;
+            default:
+                return;
+            }
+            g.drawString(secName, x-lockwidth*2, y+lockheight*3);
+            g.drawOval(x-ovalwidth*2, y+yoffset, ovalwidth, ovalheight);
+            g.setColor(c1);
+            g.fillRect(x-lockwidth*3/2, y+lockheight/2+yoffset, lockwidth, lockheight);
+            g.setColor(c);
+            g.drawRect(x-lockwidth*3/2, y+lockheight/2+yoffset, lockwidth, lockheight);
+        }
+    }
+
+    public void manageMove() {
+        if (father != null) {
+            Point p = GraphicLib.putPointOnRectangle(x+(width/2), y+(height/2), father.getX(), father.getY(), father.getWidth(), father.getHeight());
+
+            x = p.x - width/2;
+            y = p.y - height/2;
+
+            setMoveCd(x, y);
+
+            int orientation = GraphicLib.getCloserOrientation(x+(width/2), y+(height/2), father.getX(), father.getY(), father.getWidth(), father.getHeight());
+            if (orientation != currentOrientation) {
+                setOrientation(orientation);
+            }
+        }
+    }
+
+    // TGConnecting points ..
+    public void setOrientation(int orientation) {
+        currentOrientation = orientation;
+        double w0, h0;
+
+        switch(orientation) {
+        case GraphicLib.NORTH:
+            w0 = 0.5;
+            h0 = 0.0;
+            break;
+        case GraphicLib.WEST:
+            w0 = 0.0;
+            h0 = 0.5;
+            break;
+        case GraphicLib.SOUTH:
+            w0 = 0.5;
+            h0 = 1.0;
+            break;
+        case GraphicLib.EAST:
+        default:
+            w0 = 1.0;
+            h0 = 0.5;
+        }
+
+        for (int i=0; i<nbConnectingPoint; i++) {
+            ((SysCAMSPortConnectingPoint) connectingPoint[i]).setW(w0);
+            ((SysCAMSPortConnectingPoint) connectingPoint[i]).setH(h0);
+        }
+    }
+
+    public TGComponent isOnOnlyMe(int _x, int _y) {
+        if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) {
+            return this;
+        }
+        return null;
+    }
+
+    public void wasSwallowed() {
+        myColor = null;
+    }
+
+    public void wasUnswallowed() {
+        myColor = null;
+        setFather(null);
+        TDiagramPanel tdp = getTDiagramPanel();
+        setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY());
+    }
+
+    public void resizeWithFather() {
+        if ((father != null) && (father instanceof SysCAMSPrimitiveComponent)) {
+            // Too large to fit in the father? -> resize it!
+            //resizeToFatherSize();
+            setCdRectangle(0-getWidth()/2, father.getWidth() - (getWidth()/2), 0-getHeight()/2, father.getHeight() - (getHeight()/2));
+            setMoveCd(x, y);
+            oldx = -1;
+            oldy = -1;
+        }
+    }
+
+    public boolean editOndoubleClick(JFrame frame) {
+//        int oldSample = maxSamples;
+//
+//        Vector<String> otherTypes;
+//
+//        if (getFather() == null) {
+//            otherTypes = new Vector<String>();
+//        } else {
+//            SysCAMSPrimitiveComponent tgc = (SysCAMSPrimitiveComponent)(getFather());
+//            otherTypes = tgc.getAllRecords();
+//        }
+//        Vector<TGComponent> refs = new Vector<TGComponent>();
+//        for (TGComponent req: tdp.getMGUI().getAllRequirements()){
+//            if (req instanceof AvatarRDRequirement){
+//                refs.add(req);
+//            }
+//        }
+
+//        JDialogTMLCompositePort jda = new JDialogTMLCompositePort(commName, typep, list[0], list[1], list[2], list[3], list[4], isOrigin, isFinite, isBlocking, ""+maxSamples, ""+widthSamples, isLossy, lossPercentage, maxNbOfLoss, frame, "Port properties", otherTypes, dataFlowType, associatedEvent, isPrex, isPostex, checkConf, checkAuth, reference, refs);
+//        GraphicLib.centerOnParent(jda, 350, 700 );
+//        jda.setVisible( true );
+//        dataFlowType = jda.getDataFlowType();
+//        associatedEvent = jda.getAssociatedEvent();
+//        isPrex = jda.isChannelPrex();
+//        isPostex = jda.isChannelPostex();
+
+//        TraceManager.addDev( "The Data flow type is: " + dataFlowType );
+//        TraceManager.addDev( "The Associated event is: " + associatedEvent );
+
+//        if (jda.hasNewData()) {
+//            try {
+//                maxSamples = Integer.decode(jda.getMaxSamples()).intValue();
+//                widthSamples = Integer.decode(jda.getWidthSamples()).intValue();
+//                if (maxSamples < 1) {
+//                    maxSamples = oldSample;
+//                    JOptionPane.showMessageDialog(frame, "Non valid value: " + maxSamples + ": Should be at least 1", "Error", JOptionPane.INFORMATION_MESSAGE);
+//                    return false;
+//                }
+//                isOrigin = jda.isOrigin();
+//                isFinite = jda.isFinite();
+//                isBlocking = jda.isBlocking();
+//                setPortName(jda.getParamName());
+//                commName = jda.getParamName();
+//                isLossy = jda.isLossy();
+//                lossPercentage = jda.getLossPercentage();
+//                maxNbOfLoss = jda.getMaxNbOfLoss();
+//                oldTypep = typep;
+//                typep = jda.getPortType();
+//                checkConf = jda.checkConf;
+//                reference = jda.getReference();
+//                if (checkConf){
+//                    if (checkConfStatus == NOCHECK){
+//                        checkConfStatus = TOCHECK;
+//                    }
+//                }
+//                else {
+//                    if (checkConfStatus != NOCHECK){
+//                        checkConfStatus = NOCHECK;
+//                    }
+//                }
+//                checkAuth = jda.checkAuth;
+//                if (checkStrongAuthStatus < 2){
+//                	checkStrongAuthStatus = 1;
+//                	checkWeakAuthStatus = 1;
+//                }
+//                for(int i=0; i<nbMaxAttribute; i++) {
+//                    list[i].setType(jda.getStringType(i));
+//                }
+//            } catch (Exception e) {
+//                JOptionPane.showMessageDialog(frame, "Non valid value: " + e.getMessage(), "Error", JOptionPane.INFORMATION_MESSAGE);
+//                return false;
+//            }
+//        }
+    	
+    	if (this instanceof SysCAMSPortTDF) {
+    		JDialogSysCAMSPortTDF jtdf = new JDialogSysCAMSPortTDF((SysCAMSPortTDF) this);
+    		jtdf.setVisible(true);
+    	} else {
+    		JDialogSysCAMSPortDE jde = new JDialogSysCAMSPortDE((SysCAMSPortDE) this);
+    		jde.setVisible(true);
+    	}
+    	
+        ((SysCAMSComponentTaskDiagramPanel)tdp).updatePorts();
+        return true;
+    }
+
+    protected String translateExtraParam() {
+        TType a;
+        StringBuffer sb = new StringBuffer("<extraparam>\n");
+        sb.append("<Prop commName=\"");
+        sb.append(commName);
+        sb.append("\" commType=\"" + typep);
+        sb.append("\" origin=\"");
+        if (isOrigin) {
+            sb.append("true");
+        } else {
+            sb.append("false");
+        }
+        sb.append("\" finite=\"");
+        if (isFinite) {
+            sb.append("true");
+        } else {
+            sb.append("false");
+        }
+        sb.append("\" blocking=\"");
+        if (isBlocking) {
+            sb.append("true");
+        } else {
+            sb.append("false");
+        }
+        sb.append("\" maxSamples=\"" + maxSamples);
+        sb.append("\" widthSamples=\"" + widthSamples);
+        sb.append("\" isLossy=\"" + isLossy);
+        sb.append("\" isPrex=\"" + isPrex);
+        sb.append("\" isPostex=\"" + isPostex);
+        sb.append("\" lossPercentage=\"" + lossPercentage);
+        sb.append("\" maxNbOfLoss=\"" + maxNbOfLoss);
+        sb.append("\" dataFlowType=\"" + dataFlowType);
+        sb.append("\" associatedEvent=\"" + associatedEvent);
+        sb.append("\" checkConf=\"" + checkConf);
+        sb.append("\" checkConfStatus=\"" + checkConfStatus);
+        sb.append("\" checkAuth=\"" + checkAuth);
+        sb.append("\" checkWeakAuthStatus=\"" + checkWeakAuthStatus);
+        sb.append("\" checkStrongAuthStatus=\"" + checkStrongAuthStatus);
+        sb.append("\" />\n");
+        for(int i=0; i<nbMaxAttribute; i++) {
+            a = list[i];
+            sb.append("<Type");
+            sb.append(" type=\"");
+            sb.append(a.getType());
+            sb.append("\" typeOther=\"");
+            sb.append(a.getTypeOther());
+            sb.append("\" />\n");
+        }
+        sb.append("</extraparam>\n");
+        return new String(sb);
+    }
+
+    public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{
+        try {
+            NodeList nli;
+            Node n1, n2;
+            Element elt;
+            int typeAtt;
+            String typeOther;
+            int nbAttribute = 0;
+
+            for(int i=0; i<nl.getLength(); i++) {
+                n1 = nl.item(i);
+                if (n1.getNodeType() == Node.ELEMENT_NODE) {
+                    nli = n1.getChildNodes();
+                    for(int j=0; j<nli.getLength(); j++) {
+                        n2 = nli.item(j);
+                        if (n2.getNodeType() == Node.ELEMENT_NODE) {
+                            elt = (Element) n2;
+                            if ((elt.getTagName().equals("Type")) && (nbAttribute < nbMaxAttribute)) {
+                                typeAtt = Integer.decode(elt.getAttribute("type")).intValue();
+                                try {
+                                    typeOther = elt.getAttribute("typeOther");
+                                } catch (Exception e) {
+                                    typeOther = "";
+                                }
+                                TType ta = new TType(typeAtt, typeOther);
+                                list[nbAttribute] = ta;
+                                nbAttribute ++;
+                            }
+                            if (elt.getTagName().equals("Prop")) {
+                                commName = elt.getAttribute("commName");
+                                try {
+                                    typep = Integer.decode(elt.getAttribute("commType")).intValue();
+                                    maxSamples = Integer.decode(elt.getAttribute("maxSamples")).intValue();
+                                    widthSamples = Integer.decode(elt.getAttribute("widthSamples")).intValue();
+                                } catch (Exception e) {
+                                }
+                                try {
+                                    lossPercentage = Integer.decode(elt.getAttribute("lossPercentage")).intValue();
+                                    maxNbOfLoss = Integer.decode(elt.getAttribute("maxNbOfLoss")).intValue();
+                                    dataFlowType = elt.getAttribute("dataFlowType");
+                                    associatedEvent = elt.getAttribute("associatedEvent");
+                                    checkConf = (elt.getAttribute("checkConf").compareTo("true")==0);
+                                    if (checkConf){
+                                        checkConfStatus=TOCHECK;
+                                    }
+                                    checkAuth = (elt.getAttribute("checkAuth").compareTo("true")==0);
+                                    isLossy = (elt.getAttribute("isLossy").compareTo("true") ==0);
+                                    isPrex = (elt.getAttribute("isPrex").compareTo("true") ==0);
+                                    isPostex = (elt.getAttribute("isPostex").compareTo("true") ==0);
+                                } catch (Exception e) {
+                                    lossPercentage = 0;
+                                    maxNbOfLoss = -1;
+                                    isLossy = false;
+                                }
+                                try {
+                                    isBlocking = (elt.getAttribute("blocking").compareTo("true") ==0);
+                                    isOrigin = (elt.getAttribute("origin").compareTo("true") ==0);
+                                    isFinite = (elt.getAttribute("finite").compareTo("true") ==0);
+
+                                } catch (Exception e) {}
+                            }
+                            makeValue();
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            throw new MalformedModelingException();
+        }
+    }
+
+    public void makeValue() {
+        value = getPortTypeName() + " " + getPortName();
+    }
+
+    public String getPortName() {
+        return commName;
+    }
+
+    public int getPortType() {
+        return typep;
+    }
+
+    public String getPortTypeName() {
+        switch(typep) {
+        case 0:
+            return "Channel";
+        case 1:
+            return "Event";
+        case 2:
+        default:
+            return "Request";
+        }
+    }
+
+    public boolean isBlocking() {
+        return isBlocking;
+    }
+
+    public boolean isFinite() {
+        return isFinite;
+    }
+
+    public int getMax() {
+        return maxSamples;
+    }
+
+    public int getSize() {
+        return widthSamples;
+    }
+
+    public boolean isOrigin() {
+        return isOrigin;
+    }
+
+    public int getNbMaxAttribute() {
+        return nbMaxAttribute;
+    }
+
+    public TType getParamAt(int index) {
+        return list[index];
+    }
+    public void setParam(int index, TType t){
+        list[index] = t;
+    }
+
+    public int getDefaultConnector() {
+        return TGComponentManager.CONNECTOR_PORT_TMLC;
+    }
+
+    public String getAttributes() {
+        String attr = "";
+        if (isOrigin()) {
+            attr += "out ";
+        } else {
+            attr += "in ";
+        }
+        attr += getPortTypeName() + ": ";
+        attr += getPortName() + "\n";
+        // Channel
+        if (typep == 0) {
+            if (!isBlocking()) {
+                attr += "N";
+            }
+            attr += "B";
+            if (isOrigin()) {
+                attr += "W\n";
+                attr += "Width (in B): " + getSize() + "\n";
+                if (isFinite()) {
+                    attr += "Max samples: " + getNbMaxAttribute() + "\n";
+                } else {
+                    attr += "Infinite\n";
+                }
+            } else {
+                attr += "R\n";
+            }
+            // Event and Request
+        } else {
+            attr += "(";
+            for(int i=0; i<nbMaxAttribute; i++) {
+                if (i!=0) {
+                    attr += ",";
+                }
+                attr += TType.getStringType(list[i].getType());
+            }
+            attr += ")\n";
+            if (typep == 1) {
+                if (isOrigin()) {
+                    if (!isFinite()) {
+                        attr += "Infinite FIFO\n";
+                    } else {
+                        if (isBlocking()) {
+                            attr += "Blocking ";
+                        } else {
+                            attr += "Non-blocking ";
+                        }
+                        attr += "finite FIFO: " + getMax() + "\n";
+                    }
+                }
+            }
+        }
+        if (conflict) {
+            attr += "Error in path=" + conflictMessage;
+        }
+        return attr;
+    }
+
+    public boolean isLossy() {
+        return isLossy && isOrigin;
+    }
+
+    public int getLossPercentage() {
+        return lossPercentage;
+    }
+
+    public int getMaxNbOfLoss() {
+        return maxNbOfLoss;
+    }
+
+    public boolean getConflict() {
+        return conflict;
+    }
+
+    public void setConflict(boolean _conflict, String _msg) {
+        conflict = _conflict;
+        myColor = null;
+        conflictMessage = _msg;
+        calculatePortColor();
+    }
+
+    public void calculatePortColor() {
+        if (conflict) {
+            myColor = Color.red;
+        } else {
+//            if (typep == 0) {
+//                myColor = ColorManager.TML_PORT_CHANNEL;
+//            } else if (typep == 1) {
+//                myColor = ColorManager.TML_PORT_EVENT;
+//            } else {
+//                myColor = ColorManager.TML_PORT_REQUEST;
+//            }
+        	if (this instanceof SysCAMSPortTDF) {
+        		myColor = Color.lightGray;
+        	} else {
+        		myColor = Color.white;
+        	}
+        }
+    }
+
+    public String getDataFlowType() {
+        return dataFlowType;
+    }
+
+    public boolean isPrex() {
+        return isPrex;
+    }
+
+    public boolean isPostex() {
+        return isPostex;
+    }
+
+    public String getAssociatedEvent() {
+        return associatedEvent;
+    }
+
+    public boolean hasSameParametersThan(SysCAMSPrimitivePort _p) {
+        for(int i=0; i<5; i++) {
+            if (!(getParamAt(i).equals(_p.getParamAt(i)))) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    public void setPortName(String s) {
+        for (TURTLEPanel tp : tdp.getMainGUI().tabs) {
+            for (TDiagramPanel t : tp.getPanels()) {
+                for (TGComponent t2 : t.getComponentList()) {
+                    if (t2 instanceof TMLArchiCPNode) {
+                        TMLArchiCPNode tacn = (TMLArchiCPNode) t2;
+                        for (TGComponent tgc : tacn.getRecursiveAllInternalComponent()) {
+                            if (tgc instanceof TMLArchiPortArtifact) {
+                                TMLArchiPortArtifact tapi = (TMLArchiPortArtifact) tgc;
+                                String tmp = tapi.getValue().replaceAll("(?i)" + commName + "$", s);
+                                tapi.setValue(tmp);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        if ( (father != null) && (father instanceof SysCAMSPrimitiveComponent)) {
+            String name = father.getValue();
+            TURTLEPanel tp = tdp.getMainGUI().getCurrentTURTLEPanel();
+            for (TDiagramPanel t : tp.getPanels()) {
+                if (t.getName().compareTo(name) == 0) {
+                    for (TGComponent t2 : t.getComponentList()) {
+                        if (t2 instanceof TMLADWriteChannel) {
+                            TMLADWriteChannel twc = (TMLADWriteChannel) t2;
+                            if (twc.getChannelName().equals(commName))
+                                twc.setChannelName(s);
+                        }
+                        if (t2 instanceof TMLADReadChannel) {
+                            TMLADReadChannel trc = (TMLADReadChannel) t2;
+                            if (trc.getChannelName().equals(commName))
+                                trc.setChannelName(s);
+                        }
+                        if (t2 instanceof TMLADSendEvent) {
+                            TMLADSendEvent tse = (TMLADSendEvent) t2;
+                            if (tse.getEventName().equals(commName))
+                                tse.setEventName(s);
+                        }
+                        if (t2 instanceof TMLADSendRequest) {
+                            TMLADSendRequest tsr = (TMLADSendRequest) t2;
+                            if (tsr.getRequestName().equals(commName))
+                                tsr.setRequestName(s);
+                        }
+                        if (t2 instanceof TMLADWaitEvent) {
+                            TMLADWaitEvent twe = (TMLADWaitEvent) t2;
+                            if (twe.getEventName().equals(commName))
+                                twe.setEventName(s);
+                        }
+                        if (t2 instanceof TMLADNotifiedEvent) {
+                            TMLADNotifiedEvent tne = (TMLADNotifiedEvent) t2;
+                            if (tne.getEventName().equals(commName))
+                                tne.setEventName(s);
+                        }
+                    }
+                    t.repaint();
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSRecordComponent.java b/src/main/java/ui/syscams/SysCAMSRecordComponent.java
new file mode 100644
index 0000000000..b74e5adab7
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSRecordComponent.java
@@ -0,0 +1,420 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import ui.*;
+import ui.util.IconManager;
+import ui.window.JDialogAttribute;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.LinkedList;
+
+/**
+ * Class SysCAMSRecordComponent
+ * Record Component. To be used in SystemC-AMS component task diagrams
+ * Creation: 22/04/2018
+ * @version 1.0 22/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSRecordComponent extends TGCScalableWithInternalComponent implements SwallowedTGComponent {
+	private int maxFontSize = 14;
+	private int minFontSize = 4;
+	private int currentFontSize = -1;
+	private boolean displayText = true;
+	private Color myColor;
+	
+	// Icon
+	private int iconSize = 15;
+	
+	// Attributes
+	protected LinkedList<TAttribute> myAttributes;
+	private int textX = 15; // border for ports
+	private double dtextX = 0.0;
+	
+	public String oldValue;
+    
+    public SysCAMSRecordComponent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+        
+		initScaling(200, 150);
+		
+		oldScaleFactor = tdp.getZoom();
+		dtextX = textX * oldScaleFactor;
+		textX = (int)dtextX;
+		dtextX = dtextX - textX;
+		
+        minWidth = 1;
+        minHeight = 1;
+        
+        nbConnectingPoint = 0;
+       
+        addTGConnectingPointsComment();
+        
+        nbInternalTGComponent = 0;
+        
+        moveable = true;
+        multieditable = true;
+		editable = true;
+        removable = true;
+        userResizable = true;
+        
+		value = tdp.findTMLRecordComponentName("Record_");
+		oldValue = value;
+		setName("Record component");
+		
+        myImageIcon = IconManager.imgic1202;
+		
+		myAttributes = new LinkedList<TAttribute> ();
+		
+		actionOnAdd();
+    }
+    
+    public void internalDrawing(Graphics g) {
+		int w;
+		Font f = g.getFont();
+		Font fold = f;
+		
+		if (myColor == null) {
+			myColor = new Color(193, 218, 241- (getMyDepth() * 10), 200);
+		}
+		
+		if ((rescaled) && (!tdp.isScaled())) {
+			
+			if (currentFontSize == -1) {
+				currentFontSize = f.getSize();
+			}
+			rescaled = false;
+			// Must set the font size ..
+			// Find the biggest font not greater than max_font size
+			// By Increment of 1
+			// Or decrement of 1
+			// If font is less than 4, no text is displayed
+			
+			int maxCurrentFontSize = Math.max(0, Math.min(height-(2*textX), maxFontSize));
+			
+			f = f.deriveFont((float)maxCurrentFontSize);
+			g.setFont(f);
+			while(maxCurrentFontSize > (minFontSize-1)) {
+				if (g.getFontMetrics().stringWidth(value) < (width - iconSize - (2 * textX))) {
+					break;
+				}
+				maxCurrentFontSize --;
+				f = f.deriveFont((float)maxCurrentFontSize);
+				g.setFont(f);
+			}
+			
+			currentFontSize = maxCurrentFontSize;
+			
+			if(currentFontSize <minFontSize) {
+				displayText = false;
+			} else {
+				displayText = true;
+				f = f.deriveFont((float)currentFontSize);
+				g.setFont(f);
+			}
+		}
+		
+		// Zoom is assumed to be computed
+		Color c = g.getColor();
+		g.drawRect(x, y, width, height);
+		if ((width > 2) && (height > 2)) {
+			g.setColor(myColor);
+			g.fillRect(x+1, y+1, width-1, height-1);
+			g.setColor(c);
+		}
+		
+        // Font size 
+		if (displayText) {
+			f = f.deriveFont((float)currentFontSize);
+			g.setFont(f);
+			w = g.getFontMetrics().stringWidth(value);
+			if (w > (width - 2 * (iconSize + textX))) {
+				g.drawString(value, x + textX + 1, y + currentFontSize + textX);
+			} else {
+				g.drawString(value, x + (width - w)/2, y + currentFontSize + textX);
+			}
+		}
+		
+		// Icon
+		if ((width>30) && (height > (iconSize + 2*textX))) {
+			g.drawImage(IconManager.imgic1200.getImage(), x + width - iconSize - textX, y + textX, null);
+		} 
+
+		// Attributes
+		if (tdp.areAttributesVisible()) {
+			int index = 0;
+			int cpt = currentFontSize + 2 * textX;
+			String attr;
+			
+			TAttribute a;
+           
+			int si = Math.min(12, (int)((float)currentFontSize - 2));
+			
+			f = g.getFont();
+			f = f.deriveFont((float)si);
+			g.setFont(f);
+			int step = si + 2;
+			
+			while(index < myAttributes.size()) {
+				cpt += step;
+				if (cpt >= (height - textX)) {
+					break;
+				}
+				a = myAttributes.get (index);
+				attr = a.toString();
+				w = g.getFontMetrics().stringWidth(attr);
+				if ((w + (2 * textX) + 1) < width) {
+					g.drawString(attr, x + textX, y + cpt);
+				} else {
+					attr = "...";
+					w = g.getFontMetrics().stringWidth(attr);
+					if ((w + textX + 2) < width) {
+						g.drawString(attr, x + textX + 1, y + cpt);
+					} else {
+						// skip attribute
+						cpt -= step;
+					}
+				}
+				index ++;
+			}
+		}
+		g.setFont(fold);
+    }
+	
+	public void rescale(double scaleFactor){
+		dtextX = (textX + dtextX) / oldScaleFactor * scaleFactor;
+		textX = (int)(dtextX);
+		dtextX = dtextX - textX; 
+		
+		super.rescale(scaleFactor);
+	}
+    
+    public TGComponent isOnOnlyMe(int _x, int _y) {
+		if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) {
+            return this;
+        }
+        return null;
+    }
+    
+    public boolean editOndoubleClick(JFrame frame, int _x, int _y) {
+		// On the name ?
+		if ((displayText) && (_y <= (y + currentFontSize + textX))) {
+			oldValue = value;
+			String s = (String)JOptionPane.showInputDialog(frame, "Name:", "Setting component name",
+			JOptionPane.PLAIN_MESSAGE, IconManager.imgic100,
+			null,
+			getValue());
+			if ((s != null) && (s.length() > 0)) {
+				// Check whether this name is already in use, or not 
+				
+				if (!TAttribute.isAValidId(s, false, false)) {
+					JOptionPane.showMessageDialog(frame,
+						"Could not change the name of the component: the new name is not a valid name",
+						"Error",
+						JOptionPane.INFORMATION_MESSAGE);
+					return false;
+				}
+				
+				if (((SysCAMSComponentTaskDiagramPanel)(tdp)).nameRecordComponentInUse(oldValue, s)) {
+					JOptionPane.showMessageDialog(frame,
+						"Error: the name is already in use",
+						"Name modification",
+						JOptionPane.ERROR_MESSAGE);
+					return false;
+				} else {
+					setValueWithChange(s);
+					rescaled = true;
+					return true;
+				}
+			}
+			return false;
+		}
+		
+		// And so -> attributes!
+		JDialogAttribute jda = new JDialogAttribute(myAttributes, null, frame, "Setting fields of " + value, "Field");
+        setJDialogOptions(jda);
+        GraphicLib.centerOnParent(jda, 650, 375);
+        jda.setVisible(true); // blocked until dialog has been closed
+		rescaled = true;
+		return true;
+    }
+	
+	protected void setJDialogOptions(JDialogAttribute jda) {
+        jda.addAccess(TAttribute.getStringAccess(TAttribute.PUBLIC));
+        jda.addAccess(TAttribute.getStringAccess(TAttribute.PRIVATE));
+        jda.addType(TAttribute.getStringType(TAttribute.NATURAL), true);
+        jda.addType(TAttribute.getStringType(TAttribute.BOOLEAN), true);
+		jda.enableInitialValue(true);
+        jda.enableRTLOTOSKeyword(true);
+        jda.enableJavaKeyword(false);
+    }
+    
+    public int getType() {
+        return TGComponentManager.TMLCTD_RCOMPONENT;
+    }
+	
+	public void wasSwallowed() {
+		myColor = null;
+	}
+	
+	public void wasUnswallowed() {
+		myColor = null;
+		setFather(null);
+		TDiagramPanel tdp = getTDiagramPanel();
+		setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY());
+	}
+    
+    public void hasBeenResized() {
+		rescaled = true;
+		
+		if (getFather() != null) {
+			resizeWithFather();
+		}
+    }
+	
+	public void resizeWithFather() {
+        if ((father != null) && (father instanceof SysCAMSCompositeComponent)) {
+			// Too large to fit in the father? -> resize it!
+			resizeToFatherSize();
+			
+            setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight());
+            setMoveCd(x, y);
+        }
+    }
+	
+	public int getChildCount() {
+        return myAttributes.size();
+    }
+    
+    public Object getChild(int index) {
+		if (index == 0) {
+			return value;
+		} else {
+			return myAttributes.get (index-1);
+		}
+    }
+    
+    public int getIndexOfChild(Object child) {
+		if (child instanceof String) {
+			return 0;
+		} else {
+			return myAttributes.indexOf(child) + 1;
+		}
+    }
+    
+    protected String translateExtraParam() {
+        TAttribute a;
+        StringBuffer sb = new StringBuffer("<extraparam>\n");
+        for(int i=0; i<myAttributes.size(); i++) {
+            a = myAttributes.get (i);
+            sb.append("<Attribute access=\"");
+            sb.append(a.getAccess());
+            sb.append("\" id=\"");
+            sb.append(a.getId());
+            sb.append("\" value=\"");
+            sb.append(a.getInitialValue());
+            sb.append("\" type=\"");
+            sb.append(a.getType());
+            sb.append("\" typeOther=\"");
+            sb.append(a.getTypeOther());
+            sb.append("\" />\n");
+        }
+        sb.append("</extraparam>\n");
+        return new String(sb);
+    }
+    
+    public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{
+        try {
+            NodeList nli;
+            Node n1, n2;
+            Element elt;
+            int access, type;
+            String typeOther;
+            String id, valueAtt;
+            
+            for(int i=0; i<nl.getLength(); i++) {
+                n1 = nl.item(i);
+                if (n1.getNodeType() == Node.ELEMENT_NODE) {
+                    nli = n1.getChildNodes();
+                    for(int j=0; j<nli.getLength(); j++) {
+                        n2 = nli.item(j);
+                        if (n2.getNodeType() == Node.ELEMENT_NODE) {
+                            elt = (Element) n2;
+                            if (elt.getTagName().equals("Attribute")) {
+                                access = Integer.decode(elt.getAttribute("access")).intValue();
+                                type = Integer.decode(elt.getAttribute("type")).intValue();
+                                try {
+                                    typeOther = elt.getAttribute("typeOther");
+                                } catch (Exception e) {
+                                    typeOther = "";
+                                }
+                                id = elt.getAttribute("id");
+                                valueAtt = elt.getAttribute("value");
+                                
+                                if (valueAtt.equals("null")) {
+                                    valueAtt = "";
+                                }
+                                if ((TAttribute.isAValidId(id, false, false)) && (TAttribute.isAValidInitialValue(type, valueAtt))) {
+                                    TAttribute ta = new TAttribute(access, id, valueAtt, type, typeOther);
+                                    myAttributes.add (ta);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            throw new MalformedModelingException();
+        }
+    }
+	
+	public int getCurrentFontSize() {
+		return currentFontSize;
+	}
+	
+	public LinkedList<TAttribute> getAttributes() {
+		return myAttributes;
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSReferencePortConnectingPoint.java b/src/main/java/ui/syscams/SysCAMSReferencePortConnectingPoint.java
new file mode 100644
index 0000000000..88945a228f
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSReferencePortConnectingPoint.java
@@ -0,0 +1,122 @@
+/* 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.syscams;
+
+import ui.CDElement;
+import ui.TGComponent;
+
+/**
+ * Class SysCAMSReferencePortConnectingPoint
+ * Definition of referenced connecting points on which connectors of SystemC-AMS Component Task diagrams can be connected
+ * Creation: 27/04/2018
+ * @version 1.0 27/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSReferencePortConnectingPoint extends SysCAMSPortConnectingPoint{
+    
+	private SysCAMSCompositePort port;
+	
+    public SysCAMSReferencePortConnectingPoint(SysCAMSCompositePort _port, CDElement _container, double _w, double _h) {
+        super(_container, 0, 0, true, true, _w, _h);
+		port = _port;
+    }
+	
+	public void setPort(SysCAMSCompositePort _port) {
+		port = _port;
+	}
+	
+	public SysCAMSCompositePort getPort() {
+		return port;
+	}
+	
+	public static double getDecX(SysCAMSCompositePort _port) {
+		if (_port != null) {
+			TGComponent tgc = _port.getFather();
+			if (tgc != null) {
+				int x1 = _port.getX() + _port.getWidth()/2;
+				int x2 = tgc.getX();
+				int w1 = tgc.getWidth();
+				return ((double)x1 - x2) / w1;
+			}
+		}
+		return 0;
+	}
+	
+	public double getDecX() {
+		if (port != null) {
+			return getDecX(port);
+		}
+		return 0;
+	}
+	
+	public static double getDecY(SysCAMSCompositePort _port) {
+		if (_port != null) {
+			TGComponent tgc = _port.getFather();
+			if (tgc != null) {
+				int y1 = _port.getY() + _port.getHeight()/2;
+				int y2 = tgc.getY();
+				int h1 = tgc.getHeight();
+				return ((double)y1 - y2) / h1;
+			}
+		}
+		return 0;
+	}
+	
+	public double getDecY() {
+		if (port != null) {
+			return getDecY(port);
+		}
+		return 0;
+	}
+	
+	public int getX() {
+		if (container != null) {
+			return x + container.getX() + (int)(container.getWidth() * getDecX());
+		}
+		return x;
+    }
+    
+    public int getY() {
+		if (container != null) {
+			return y + container.getY() + (int)(container.getHeight() * getDecY());
+		}
+		return y;
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSRemoteCompositeComponent.java b/src/main/java/ui/syscams/SysCAMSRemoteCompositeComponent.java
new file mode 100644
index 0000000000..b85c1ea3c7
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSRemoteCompositeComponent.java
@@ -0,0 +1,596 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+import myutil.TraceManager;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import ui.*;
+import ui.util.IconManager;
+//import ui.window.JDialogTMLRemoteCompositeComponent;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.ArrayList;
+
+/**
+* Class SysCAMSRemoteCompositeComponent
+* Composite Component. To be used in SystemC-AMS diagrams
+ * Creation: 27/04/2018
+ * @version 1.0 27/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSRemoteCompositeComponent extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent {
+	private int maxFontSize = 20;
+	private int minFontSize = 4;
+	private int currentFontSize = -1;
+	private boolean displayText = true;
+	private Color myColor;
+	private int iconSize = 17;
+	private boolean iconIsDrawn = false;
+	
+	private int textX = 15; // border for ports
+	private double dtextX = 0.0;	
+	
+	private int defaultDiag = 10;
+	private double ddefaultDiag = 0.0;
+	
+	private SysCAMSCompositeComponent syscamscc;
+	private ArrayList<SysCAMSCompositePort> ports;
+	
+	private NodeList nl;
+    
+    public SysCAMSRemoteCompositeComponent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+        
+		initScaling(250, 200);
+		
+		oldScaleFactor = tdp.getZoom();
+		dtextX = textX * oldScaleFactor;
+		textX = (int)dtextX;
+		dtextX = dtextX - textX;
+		
+        minWidth = 1;
+        minHeight = 1;
+        
+        nbConnectingPoint = 0;
+        nbInternalTGComponent = 0;
+        
+        moveable = true;
+        editable = true;
+        removable = true;
+        userResizable = true;
+		multieditable = true;
+        
+		value = "No reference";
+		name = "Remote composite component";
+		
+		ports = new ArrayList<SysCAMSCompositePort>();
+		
+        myImageIcon = IconManager.imgic1200;
+    }
+	
+	public void updateReference(SysCAMSCompositeComponent syscamsccc) {
+		if (syscamscc == syscamsccc) {
+			updateReference();
+		}
+	}
+	
+	public void updateReference() {
+		if (syscamscc != null) {
+			if (syscamscc.getTDiagramPanel() == null) {
+				syscamscc = null;
+				value =  "No reference";
+			} else {
+				// Update
+				value = syscamscc.getExtendedValue();
+				updatePorts();
+			}
+		}
+	}
+    
+    public void internalDrawing(Graphics g) {
+		int w;
+		int c;
+		Font f = g.getFont();
+		Font fold = f;
+		
+		if (syscamscc == null) {
+			// Use value to find the component
+			syscamscc = tdp.getMGUI().getSysCAMSCompositeComponent(value);
+			if (syscamscc == null) {
+				value =  "No reference";
+			}
+		} else {
+			if (syscamscc.getTDiagramPanel() == null) {
+				syscamscc = null;
+				value =  "No reference";
+			} else {
+				if (ports.size() != syscamscc.getCompositePortNb()) {
+					updateReference();
+				}
+			}
+		}
+		if (myColor == null) {
+			myColor = new Color(251, 252, 200- (getMyDepth() * 10), 200);
+		}
+		
+		if ((rescaled) && (!tdp.isScaled())) {
+			if (currentFontSize == -1) {
+				currentFontSize = f.getSize();
+			}
+			rescaled = false;
+			// Must set the font size ..
+			// Find the biggest font not greater than max_font size
+			// By Increment of 1
+			// Or decrement of 1
+			// If font is less than 4, no text is displayed
+			int maxCurrentFontSize = Math.max(0, Math.min(height-(2*textX), maxFontSize));
+			while(maxCurrentFontSize > (minFontSize-1)) {
+				f = f.deriveFont((float)maxCurrentFontSize);
+				g.setFont(f);
+				w = g.getFontMetrics().stringWidth(value);
+				c = width - iconSize - (2 * textX);
+				if (w < c) {
+					break;
+				}
+				maxCurrentFontSize --;
+			}
+			currentFontSize = maxCurrentFontSize;
+            displayText = currentFontSize >= minFontSize;
+		}
+		
+		// Zoom is assumed to be computed
+		Color col = g.getColor();
+		g.drawRect(x, y, width, height);
+		if ((width > 2) && (height > 2)) {
+			g.setColor(myColor);
+			g.fillRect(x+1, y+1, width-1, height-1);
+			g.setColor(col);
+		}
+		
+        // Font size 
+		if (displayText) {
+			f = f.deriveFont((float)currentFontSize);
+			g.setFont(f);
+			w = g.getFontMetrics().stringWidth(value);
+			if (!(w < (width - 2 * (iconSize + textX)))) {
+				g.drawString(value, x + textX + 1, y + currentFontSize + textX);
+			} else {
+				g.drawString(value, x + (width - w)/2, y + currentFontSize + textX);
+			}
+		}
+		g.setFont(fold);
+		
+		// Icon
+		if ((width>30) && (height > (iconSize + 2*textX))) {
+			g.drawImage(IconManager.imgic1200.getImage(), x + width - iconSize - textX, y + textX, null);
+			iconIsDrawn = true;
+		} else {
+			iconIsDrawn = false;
+		}
+    }
+	
+	public void rescale(double scaleFactor){
+		dtextX = (textX + dtextX) / oldScaleFactor * scaleFactor;
+		textX = (int)(dtextX);
+		dtextX = dtextX - textX; 
+		
+		ddefaultDiag = (defaultDiag + ddefaultDiag) / oldScaleFactor * scaleFactor;
+		defaultDiag = (int)(ddefaultDiag);
+		ddefaultDiag = ddefaultDiag - defaultDiag; 
+		
+		super.rescale(scaleFactor);
+	}
+    
+    public TGComponent isOnOnlyMe(int _x, int _y) {
+		if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) {
+            return this;
+        }
+        return null;
+    }
+    
+    public boolean editOndoubleClick(JFrame frame, int _x, int _y) {
+		// On the icon?
+		if (iconIsDrawn && (syscamscc != null)) {
+			if (GraphicLib.isInRectangle(_x, _y, x + width - iconSize - textX, y + textX, iconSize, iconSize)) {
+				boolean b = tdp.getMGUI().selectHighLevelTab(syscamscc.getValuePanel());
+				if (b) {
+					return false;
+				}
+			}
+		}
+		
+//		JDialogTMLRemoteCompositeComponent dialog = new JDialogTMLRemoteCompositeComponent(frame, "Setting referenced component", this);
+//        GraphicLib.centerOnParent(dialog, 400, 350);
+//        dialog.setVisible( true ); // blocked until dialog has been closed
+//        
+//		if (!dialog.isRegularClose()) {
+//			return false;
+//		}
+//		
+//		if (dialog.getReferenceComponentName() == null) {
+//			return false;
+//		}
+//		
+//		if (dialog.getReferenceComponentName().length() != 0) {
+//			tmlcc = getTDiagramPanel().getMGUI().getCompositeComponent(dialog.getReferenceComponentName());
+//			if (tmlcc != null ){
+//				updateReference();
+//				rescaled = true;
+//			}
+//			tdp.repaint();
+//		}
+		return false;
+    }
+	
+	protected String translateExtraParam() {
+        StringBuffer sb = new StringBuffer("<extraparam>\n");
+		sb.append("<info ref=\"" + value + "\" "); 
+        sb.append("/>\n");
+		
+		for (SysCAMSCompositePort port: ports) {
+			sb.append("<port id=\"" + port.getId() + "\" />\n");
+		}
+        sb.append("</extraparam>\n");
+        return new String(sb);
+    }
+	
+	public void loadExtraParam(NodeList _nl, int decX, int decY, int decId) throws MalformedModelingException{
+		nl = _nl;
+	}
+	
+	public void delayedLoad() throws MalformedModelingException {
+        try {
+            NodeList nli;
+            Node n1, n2;
+            Element elt;
+			int j, k;
+			int index;
+			int cptk = 0;
+			SysCAMSRemotePortCompositeComponent pcc;
+			TGConnectingPoint[] old = null;
+			ArrayList<SysCAMSCompositePort> tmp = null;
+			
+            for(int i=0; i<nl.getLength(); i++) {
+                n1 = nl.item(i);
+                if (n1.getNodeType() == Node.ELEMENT_NODE) {
+                    nli = n1.getChildNodes();
+                    for(j=0; j<nli.getLength(); j++) {
+                        n2 = nli.item(j);
+                        if (n2.getNodeType() == Node.ELEMENT_NODE) {
+                            elt = (Element) n2;
+                            if (elt.getTagName().equals("info")) {
+								value = elt.getAttribute("ref");
+								syscamscc = getTDiagramPanel().getMGUI().getSysCAMSCompositeComponent(value);
+								if (syscamscc != null ){
+									updateReference();
+									rescaled = true;
+									tmp = ports;
+									ports = new ArrayList<SysCAMSCompositePort>();
+									for (SysCAMSCompositePort port: tmp) {
+										ports.add(port);
+									}
+								}
+							}
+							
+							if (elt.getTagName().equals("port")) {
+								if (old == null) {
+									old =  connectingPoint;
+									connectingPoint = new TGConnectingPoint[nbConnectingPoint];
+								}
+								try {
+									int portid = Integer.decode(elt.getAttribute("id")).intValue();
+									
+									for (SysCAMSCompositePort port: tmp) {
+										if (port.getId() == portid) {
+											index = tmp.indexOf(port);
+											for (k=index*5; k<(index+1)*5; k++) {
+												// Must update position of connecting point
+												connectingPoint[k] = old[cptk];
+												
+												if ((k % 5) == 0) {
+													if (nbInternalTGComponent > (k/5)) {
+														pcc = (SysCAMSRemotePortCompositeComponent)(tgcomponent[k/5]);
+														if (pcc != null) {
+															pcc.setElements(port, (SysCAMSReferencePortConnectingPoint)(connectingPoint[k]));
+														}
+													}
+												}
+												((SysCAMSReferencePortConnectingPoint)(connectingPoint[k])).setPort(port);
+												if (connectingPoint[k] == null) {
+													TraceManager.addDev("null cp");
+												}
+												cptk ++;
+											}
+											break;
+										}
+									}
+								} catch (Exception e) {
+								}
+							}
+							
+                        }
+                    }
+                }
+            }
+			// Make paths
+			((SysCAMSComponentTaskDiagramPanel)getTDiagramPanel()).makePaths();
+        } catch (Exception e) {
+            throw new MalformedModelingException();
+        }
+    }
+    
+    public int getType() {
+        return TGComponentManager.TMLCTD_CREMOTECOMPONENT;
+    }
+	
+	public void wasSwallowed() {
+		myColor = null;
+	}
+	
+	public void wasUnswallowed() {
+		myColor = null;
+		setFather(null);
+		TDiagramPanel tdp = getTDiagramPanel();
+		setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY());
+	}
+
+	public void hasBeenResized() {
+		rescaled = true;
+		if (getFather() != null) {
+			resizeWithFather();
+		}
+    }
+	
+	public void resizeWithFather() {
+        if ((father != null) && ((father instanceof SysCAMSCompositeComponent) ||(father instanceof SysCAMSPrimitiveComponent))) {
+			// Too large to fit in the father? -> resize it!
+			resizeToFatherSize();
+            setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight());
+            setMoveCd(x, y);
+        }
+    }
+	
+	public java.util.List<SysCAMSPrimitiveComponent> getAllPrimitiveComponents() {
+		if (syscamscc == null) {
+			return new ArrayList<SysCAMSPrimitiveComponent>();
+		}
+		return syscamscc.getAllPrimitiveComponents();
+	}
+	
+	public java.util.List<SysCAMSRecordComponent> getAllRecordComponents() {
+		if (syscamscc == null) {
+			return new ArrayList<SysCAMSRecordComponent>();
+		}
+		return syscamscc.getAllRecordComponents();
+	}
+	
+	public java.util.List<SysCAMSCompositePort> getAllInternalCompositePorts() {
+		java.util.List<SysCAMSCompositePort> list = new ArrayList<SysCAMSCompositePort>();
+		if (syscamscc == null) {
+			return list;
+		}
+		return syscamscc.getAllInternalCompositePorts();
+	}
+	
+	public ArrayList<SysCAMSPrimitivePort> getAllInternalPrimitivePorts() {
+		ArrayList<SysCAMSPrimitivePort> list = new ArrayList<SysCAMSPrimitivePort>();
+		if (syscamscc == null) {
+			return list;
+		}
+		return syscamscc.getAllInternalPrimitivePorts();
+	}
+	
+	public SysCAMSPrimitiveComponent getPrimitiveComponentByName(String _name) {
+		if (syscamscc == null) {
+			return null;
+		}
+		return syscamscc.getPrimitiveComponentByName(_name);
+	}
+	
+	public void drawTGConnectingPoint(Graphics g, int type) {
+        for (int i=0; i<nbConnectingPoint; i++) {
+            if (connectingPoint[i].isCompatibleWith(type)) {
+                connectingPoint[i].draw(g);
+            }
+        }
+    }
+	
+	// 5 tgconnecting per port: we show only them toward the exterior of the component
+	// Add to ports the new port and remove to ports the removed ports
+	// Update tgconnecting points accordingly. Those points should point to their original ones so as to be sure to be drawn at the right place
+	// to a list of those points, keep that list, and then, generate a array of those points.
+	public void updatePorts() {
+		ArrayList<SysCAMSCompositePort> list = syscamscc.getFirstLevelCompositePorts();
+		int cpt=0;
+		
+		int i, j;
+		SysCAMSCompositePort tmp;
+		SysCAMSReferencePortConnectingPoint point;
+		
+		// Close attention to the list
+		boolean change = true;
+		if (list.size() != ports.size()) {
+			change = true;
+		} else {
+			for (SysCAMSCompositePort port: ports) {
+				if (!list.contains(port)) {
+					change = true;
+					break;
+				}
+			}
+		}
+		
+		if (change) {
+			TraceManager.addDev("change on  ports!");
+			// Delete unused ports and 
+			ArrayList<SysCAMSReferencePortConnectingPoint> points = new ArrayList<SysCAMSReferencePortConnectingPoint>();
+			cpt=0;
+			
+			for(i=0; i<ports.size(); i++) {
+				tmp = ports.get(i);
+				if (list.contains(tmp)) {
+					for (j=cpt; j<cpt+5; j++) {
+						points.add((SysCAMSReferencePortConnectingPoint)(connectingPoint[cpt]));
+					}
+				} else {
+					ports.remove(tmp);
+					for (j=cpt; j<cpt+5; j++) {
+						tdp.removeOneConnector(connectingPoint[cpt]);
+						// Shall we remove the connecting points?
+					}
+					i --;
+				}
+				cpt = cpt + 5;
+			}
+			// Add new ports
+			for (SysCAMSCompositePort port1: list) {
+				if (!ports.contains(port1)) {
+					ports.add(port1);
+					for(j=0; j<5; j++) {
+						point = new SysCAMSReferencePortConnectingPoint(port1, this, 0.5, 0.5);
+						points.add(point);
+					}
+				}
+			}
+			
+			if (nbConnectingPoint == points.size()) {
+			} else {
+				nbConnectingPoint = points.size();
+				SysCAMSRemotePortCompositeComponent tgp;
+				connectingPoint = new TGConnectingPoint[nbConnectingPoint];
+				nbInternalTGComponent = nbConnectingPoint/5;
+				tgcomponent = new TGComponent[nbInternalTGComponent];
+				cpt = 0;
+				int cpttg = 0;
+				
+				for(SysCAMSPortConnectingPoint pt: points) {
+					connectingPoint[cpt] = pt;
+					if ((cpt % 5) == 0) {
+						tgp = new SysCAMSRemotePortCompositeComponent(getX(), getY(), 0, 0, 10, 10, false, this, tdp);
+						tgp.setElements(ports.get(cpttg), (SysCAMSReferencePortConnectingPoint)pt);
+						tgcomponent[cpttg] = tgp;
+						cpttg ++;
+					}
+					cpt ++;
+				}
+			}
+		}
+	}
+	
+	public TGComponent getPortOf(TGConnectingPoint tp) {
+		if (ports == null) {
+			return null;
+		}
+		for (int i=0; i<nbConnectingPoint; i++) {
+			if (connectingPoint[i] == tp) {
+				if (i/5 < ports.size()) {
+					return ports.get(i/5);
+				}
+			}
+		}
+		return null;
+	}
+	
+	public boolean setIdTGConnectingPoint(int num, int id) {
+		int i;
+		try {
+			if (connectingPoint == null) {
+				nbConnectingPoint = num + 1;
+				connectingPoint = new TGConnectingPoint[nbConnectingPoint];
+				for(i=0; i<nbConnectingPoint; i++) {
+					connectingPoint[i] = new SysCAMSReferencePortConnectingPoint(null, this, 0.5, 0.5);
+				}
+			} else {
+				if (num >= nbConnectingPoint) {
+					nbConnectingPoint = num + 1;
+					TGConnectingPoint[] old = connectingPoint;
+					connectingPoint = new TGConnectingPoint[nbConnectingPoint];
+					for(i=0; i<old.length; i++) {
+						connectingPoint[i] = old[i];
+					}
+					for(i=old.length; i<nbConnectingPoint; i++) {
+						connectingPoint[i] = new SysCAMSReferencePortConnectingPoint(null, this, 0.5, 0.5);
+					}
+				}
+			}
+			connectingPoint[num].forceId(id);
+			return true;
+		} catch (Exception e) {
+			TraceManager.addDev("Exception remote 1:" + e.getMessage());
+			return false;
+		}
+    }
+
+	public boolean acceptSwallowedTGComponent(TGComponent tgc) {
+        return tgc instanceof SysCAMSRemotePortCompositeComponent;
+	}
+	
+    public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) {
+		if (!acceptSwallowedTGComponent(tgc)) {
+			return false;
+		}
+		tgc.setFather(this);
+        tgc.setDrawingZone(true);
+		addInternalComponent(tgc, 0);
+		return true;
+	}
+	
+    public void removeSwallowedTGComponent(TGComponent tgc) {
+	}
+	
+	public String getAttributes() {
+		return "";
+	}
+	
+	public TDiagramPanel getReferencedDiagram() {
+		if (syscamscc == null) {
+			return null;
+		}
+		return syscamscc.getTDiagramPanel();
+	}
+	
+	public SysCAMSCompositeComponent getReference() {
+		return syscamscc;
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/ui/syscams/SysCAMSRemotePortCompositeComponent.java b/src/main/java/ui/syscams/SysCAMSRemotePortCompositeComponent.java
new file mode 100644
index 0000000000..6d43d81325
--- /dev/null
+++ b/src/main/java/ui/syscams/SysCAMSRemotePortCompositeComponent.java
@@ -0,0 +1,138 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+import ui.*;
+import ui.util.IconManager;
+
+import java.awt.*;
+
+/**
+ * Class SysCAMSRemotePortCompositeComponent
+ * Port referencing the port of a composite component
+ * Creation: 22/04/2018
+ * @version 1.0 22/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSRemotePortCompositeComponent extends TGCWithInternalComponent implements SwallowedTGComponent, WithAttributes {
+    private SysCAMSCompositePort port;
+	SysCAMSReferencePortConnectingPoint point;
+	private int defaultDiag = 10;
+	private Color myColor = new Color(251, 252, 200);
+	
+    public SysCAMSRemotePortCompositeComponent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+        
+		nbConnectingPoint = 0;
+        nbInternalTGComponent = 0;
+		
+		moveable = false;
+        editable = false;
+        removable = false;
+		userResizable = false;
+		multieditable = false;
+		
+		value = "Reference Port";
+		name = "Reference Port";
+		
+		myImageIcon = IconManager.imgic1200;
+    }
+	
+	public void internalDrawing(Graphics g) {
+		int xp, yp;
+		Color pc = myColor;
+		Color col = g.getColor();
+		
+		if (port != null) {
+			pc = port.getPortColor();
+			if (pc == null) {
+				pc = myColor;
+			}
+		}
+		
+		if (point != null) {
+			xp = point.getX() - (defaultDiag / 2);
+			yp = point.getY() - (defaultDiag / 2);
+			x = point.getX();
+			y = point.getY() ;
+			forceSize(0, 0);
+			g.setColor(pc);
+			g.fillOval(xp, yp, defaultDiag+1, defaultDiag+1);
+			g.setColor(col);
+			g.drawOval(xp, yp, defaultDiag, defaultDiag);
+		}
+	}
+	
+	public void setElements(SysCAMSCompositePort _port, SysCAMSReferencePortConnectingPoint _point) {
+		port = _port;
+		point = _point;
+	}
+	
+	public SysCAMSCompositePort getPort() {
+		return port;
+	}
+	
+	public String getAttributes() {
+		if (port != null) {
+			return port.getAttributes();
+		}
+		return "";
+	}
+	
+	public TGComponent isOnOnlyMe(int x1, int y1) {
+        if (point == null) {
+			return null;
+		}
+		
+		int xp, yp;
+		xp = point.getX() - (defaultDiag / 2);
+		yp = point.getY() - (defaultDiag / 2);
+		
+        if (GraphicLib.isInRectangle(x1, y1, xp, yp, defaultDiag, defaultDiag)) {
+            return this;
+        }
+        return null;
+    }
+	
+	 public int getType() {
+        return TGComponentManager.TMLCTD_CREMOTEPORTCOMPONENT;
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/ui/util/IconManager.java b/src/main/java/ui/util/IconManager.java
index 626cd74f09..4688b7dd48 100755
--- a/src/main/java/ui/util/IconManager.java
+++ b/src/main/java/ui/util/IconManager.java
@@ -182,6 +182,8 @@ public class IconManager {
     // Image of the help button for the ports (Solange)
     public static ImageIcon imgic2111; //New icon created by Solange
 
+		// SystemC-AMS
+    public static ImageIcon imgic8000, imgic8001, imgic8002, imgic8003, imgic8004, imgic8005;
 
     //private static String icon7 = "turtle_large.gif";
     private static String icon8 = "turtle_16.gif";
@@ -654,7 +656,13 @@ public class IconManager {
     private static String icon7008 = "attacker.gif";
     private static String icon7009 = "uppaal.gif";
 
-    //
+    // SystemC-AMS
+    private static String icon8000 = "camstdfport.gif";
+    private static String icon8001 = "camsdeport.gif";
+    private static String icon8002 = "camsconverterportW.gif";
+    private static String icon8003 = "camsconverterportE.gif";
+    private static String icon8004 = "camsconverterportN.gif";
+    private static String icon8005 = "camsconverterportS.gif";
 
 
     public IconManager() {
@@ -1134,6 +1142,13 @@ public class IconManager {
         imgic7007 = getIcon(icon7007);
         imgic7008 = getIcon(icon7008);
         imgic7009 = getIcon(icon7009);
+        
+        imgic8000 = getIcon(icon8000);
+        imgic8001 = getIcon(icon8001);
+        imgic8002 = getIcon(icon8002);
+        imgic8003 = getIcon(icon8003);
+        imgic8004 = getIcon(icon8004);
+        imgic8005 = getIcon(icon8005);
     }
 
 } // Class
diff --git a/src/main/java/ui/window/JDialogSysCAMSBlockDE.java b/src/main/java/ui/window/JDialogSysCAMSBlockDE.java
new file mode 100644
index 0000000000..70765f3685
--- /dev/null
+++ b/src/main/java/ui/window/JDialogSysCAMSBlockDE.java
@@ -0,0 +1,196 @@
+/* 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.window;
+
+import ui.syscams.*;
+import ui.util.IconManager;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.AbstractAction;
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.KeyStroke;
+
+/**
+ * Class JDialogSystemCAMSBlockDE
+ * Dialog for managing of SystemC-AMS DE Block
+ * Creation: 26/04/2018
+ * @version 1.0 26/04/2018
+ * @author Irina Kit Yan LEE
+*/
+
+@SuppressWarnings("serial")
+
+public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener {
+
+	/** Access to ActionPerformed **/
+	private JTextField nameTextField;
+	private JTextField periodTextField;
+
+	/** Parameters **/
+	private SysCAMSBlockDE block;
+
+	/** Constructor **/
+	public JDialogSysCAMSBlockDE(SysCAMSBlockDE block) {
+		/** Set JDialog **/
+		this.setTitle("Setting TDF Block Attributes");
+		this.setSize(500, 168);
+		this.setLocationRelativeTo(null);
+		this.setVisible(true);
+		this.setAlwaysOnTop(true);
+		this.setResizable(false);
+
+		/** Parameters **/
+		this.block = block;
+		
+		getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
+        getRootPane().getActionMap().put("close", new AbstractAction() {
+        	public void actionPerformed(ActionEvent e) {
+                dispose();
+        	}
+        });
+		
+		dialog();
+	}
+
+	public void dialog() {
+		/** JPanel **/
+		JPanel mainPanel = new JPanel(new BorderLayout());
+		this.add(mainPanel);
+
+		/** JTabbedPane **/
+		JPanel attributesMainPanel = new JPanel();
+		mainPanel.add(attributesMainPanel, BorderLayout.NORTH); // add tab to main panel
+
+		// --- Attributes GridLayout ---//
+		attributesMainPanel.setLayout(new BorderLayout());
+
+		// Box for Attributes
+		Box attributesBox = Box.createVerticalBox();
+		attributesBox.setBorder(BorderFactory.createTitledBorder("Setting DE block attributes"));
+
+		// BorderLayout for Adding Attributes
+		JPanel attributesBoxPanel = new JPanel(new GridLayout(2, 2, 0, 10));
+		
+		// GridLayout for name
+		JLabel nameLabel = new JLabel("Name : ");
+		attributesBoxPanel.add(nameLabel);
+		if (block.getValue().toString().equals("")) { // name empty
+			nameTextField = new JTextField(10);
+		} else {
+			nameTextField = new JTextField(block.getValue().toString(), 10); // name not empty
+		}
+		attributesBoxPanel.add(nameTextField);
+		
+		// GridLayout for period
+		JLabel periodLabel = new JLabel("Period Tm (ms) : ");
+		attributesBoxPanel.add(periodLabel);
+		if (block.getPeriod() == -1) {
+			periodTextField = new JTextField(10);
+		} else {
+			periodTextField = new JTextField(Integer.toString(block.getPeriod()), 10);
+		}
+		attributesBoxPanel.add(periodTextField);
+		attributesBox.add(attributesBoxPanel); // add border to box
+		
+		attributesMainPanel.add(attributesBox, BorderLayout.NORTH); // add box to grid
+
+		// Down Side
+		JPanel downPanel = new JPanel(new GridLayout(1, 2));
+
+		JButton saveCloseButton = new JButton("Save and close");
+		saveCloseButton.setIcon(IconManager.imgic25);
+		saveCloseButton.setActionCommand("Save_Close");
+		saveCloseButton.addActionListener(this);
+		downPanel.add(saveCloseButton);
+
+		JButton cancelButton = new JButton("Cancel");
+		cancelButton.setIcon(IconManager.imgic27);
+		cancelButton.setActionCommand("Cancel");
+		cancelButton.addActionListener(this);
+		downPanel.add(cancelButton);
+			
+		mainPanel.add(downPanel, BorderLayout.CENTER);
+		
+		this.getRootPane().setDefaultButton(saveCloseButton);
+	}
+
+	public void actionPerformed(ActionEvent e) {
+		if ("Save_Close".equals(e.getActionCommand())) {
+			/** Save the name of the block into listNameTDF **/
+			block.setValue(new String(nameTextField.getText()));
+
+			/** Save the period of the block into listPeriodTmTDF **/
+			if (!(periodTextField.getText().isEmpty())) {
+				Boolean periodValueInteger = false;
+				try {
+					Integer.parseInt(periodTextField.getText());
+				} catch (NumberFormatException e1) {
+					JDialog msg = new JDialog(this);
+					msg.setLocationRelativeTo(null);
+					JOptionPane.showMessageDialog(msg, "Period Tm is not a Integer", "Warning !",
+							JOptionPane.WARNING_MESSAGE);
+					periodValueInteger = true;
+				}
+				if (periodValueInteger == false) {
+					block.setPeriod(Integer.parseInt(periodTextField.getText()));
+				}
+			} else {
+				block.setPeriod(-1);
+			}
+			
+			this.dispose();
+		}
+
+		if ("Cancel".equals(e.getActionCommand())) {
+			this.dispose();
+		}
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/ui/window/JDialogSysCAMSBlockTDF.java b/src/main/java/ui/window/JDialogSysCAMSBlockTDF.java
new file mode 100644
index 0000000000..b2303903c1
--- /dev/null
+++ b/src/main/java/ui/window/JDialogSysCAMSBlockTDF.java
@@ -0,0 +1,238 @@
+/* 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.window;
+
+import ui.syscams.*;
+import ui.util.IconManager;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.AbstractAction;
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.KeyStroke;
+
+/**
+ * Class JDialogSystemCAMSBlockTDF
+ * Dialog for managing of SystemC-AMS TDF Block
+ * Creation: 26/04/2018
+ * @version 1.0 26/04/2018
+ * @author Irina Kit Yan LEE
+*/
+
+@SuppressWarnings("serial")
+
+public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener {
+
+	/** Access to ActionPerformed **/
+	private JTextField nameTextField;
+	private JTextField periodTextField;
+	private JTextArea processCodeTextArea;
+
+	/** Parameters **/
+	private SysCAMSBlockTDF block;
+
+	/** Constructor **/
+	public JDialogSysCAMSBlockTDF(SysCAMSBlockTDF block) {
+		/** Set JDialog **/
+		this.setTitle("Setting TDF Block Attributes");
+		this.setSize(500, 310);
+		this.setLocationRelativeTo(null);
+		this.setVisible(true);
+		this.setAlwaysOnTop(true);
+		this.setResizable(false);
+
+		/** Parameters **/
+		this.block = block;
+		
+		getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
+        getRootPane().getActionMap().put("close", new AbstractAction() {
+        	public void actionPerformed(ActionEvent e) {
+                dispose();
+        	}
+        });
+		
+		dialog();
+	}
+
+	public void dialog() {
+		/** JPanel **/
+		JPanel mainPanel = new JPanel(new BorderLayout());
+		this.add(mainPanel);
+
+		/** JTabbedPane **/
+		JTabbedPane tabbedPane = new JTabbedPane();
+		JPanel attributesMainPanel = new JPanel();
+		JPanel processMainPanel = new JPanel();
+		tabbedPane.add("Attributes", attributesMainPanel);
+		tabbedPane.add("Process Code", processMainPanel);
+
+		mainPanel.add(tabbedPane, BorderLayout.NORTH); // add tab to main panel
+
+		// --- Attributes GridLayout ---//
+		attributesMainPanel.setLayout(new BorderLayout());
+
+		// Box for Attributes
+		Box attributesBox = Box.createVerticalBox();
+		attributesBox.setBorder(BorderFactory.createTitledBorder("Setting TDF block attributes"));
+
+		// BorderLayout for Adding Attributes
+		JPanel attributesBoxPanel = new JPanel(new GridLayout(2, 2, 0, 10));
+		
+		// GridLayout for name
+		JLabel nameLabel = new JLabel("Name : ");
+		attributesBoxPanel.add(nameLabel);
+		if (block.getValue().toString().equals("")) { // name empty
+			nameTextField = new JTextField(10);
+		} else {
+			nameTextField = new JTextField(block.getValue().toString(), 10); // name not empty
+		}
+		attributesBoxPanel.add(nameTextField);
+		
+		// GridLayout for period
+		JLabel periodLabel = new JLabel("Period Tm (ms) : ");
+		attributesBoxPanel.add(periodLabel);
+		if (block.getPeriod() == -1) {
+			periodTextField = new JTextField(10);
+		} else {
+			periodTextField = new JTextField(Integer.toString(block.getPeriod()), 10);
+		}
+		attributesBoxPanel.add(periodTextField);
+		attributesBox.add(attributesBoxPanel); // add border to box
+		
+		attributesMainPanel.add(attributesBox, BorderLayout.NORTH); // add box to grid
+
+		// Down Side
+		JPanel downPanel = new JPanel(new GridLayout(1, 2));
+
+		JButton saveCloseButton = new JButton("Save and close");
+		saveCloseButton.setIcon(IconManager.imgic25);
+		saveCloseButton.setActionCommand("Save_Close");
+		saveCloseButton.addActionListener(this);
+		downPanel.add(saveCloseButton);
+
+		JButton cancelButton = new JButton("Cancel");
+		cancelButton.setIcon(IconManager.imgic27);
+		cancelButton.setActionCommand("Cancel");
+		cancelButton.addActionListener(this);
+		downPanel.add(cancelButton);
+			
+		mainPanel.add(downPanel, BorderLayout.CENTER);
+		
+		this.getRootPane().setDefaultButton(saveCloseButton);
+
+		// --- ProcessCode BorderLayout ---//
+		processMainPanel.setLayout(new BorderLayout());
+
+		Box codeBox = Box.createVerticalBox();
+		codeBox.setBorder(BorderFactory.createTitledBorder("Generating code"));
+
+		JPanel codeBoxPanel = new JPanel(new BorderLayout());
+		
+		codeBoxPanel.add(new JLabel("Behavior function of TDF block : "), BorderLayout.NORTH);
+		
+		processCodeTextArea = new JTextArea(block.getProcessCode());
+		processCodeTextArea.setSize(100, 100);
+		processCodeTextArea.setTabSize(2);
+
+		processCodeTextArea.setFont(new Font("Arial", Font.PLAIN, 16));
+		processCodeTextArea.setLineWrap(true);
+		processCodeTextArea.setWrapStyleWord(true);
+
+		JScrollPane processScrollPane = new JScrollPane(processCodeTextArea);
+		processScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+		processScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
+		processScrollPane.setPreferredSize(new Dimension(200, 150));
+
+		codeBoxPanel.add(processScrollPane, BorderLayout.SOUTH);
+		
+		codeBox.add(codeBoxPanel);
+		processMainPanel.add(codeBox, BorderLayout.PAGE_START);
+	}
+
+	public void actionPerformed(ActionEvent e) {
+		if ("Save_Close".equals(e.getActionCommand())) {
+			/** Save the name of the block into listNameTDF **/
+			block.setValue(new String(nameTextField.getText()));
+
+			/** Save the period of the block into listPeriodTmTDF **/
+			if (!(periodTextField.getText().isEmpty())) {
+				Boolean periodValueInteger = false;
+				try {
+					Integer.parseInt(periodTextField.getText());
+				} catch (NumberFormatException e1) {
+					JDialog msg = new JDialog(this);
+					msg.setLocationRelativeTo(null);
+					JOptionPane.showMessageDialog(msg, "Period Tm is not a Integer", "Warning !",
+							JOptionPane.WARNING_MESSAGE);
+					periodValueInteger = true;
+				}
+				if (periodValueInteger == false) {
+					block.setPeriod(Integer.parseInt(periodTextField.getText()));
+				}
+			} else {
+				block.setPeriod(-1);
+			}
+			
+			/** Save the process code into listProcessCodeTDF **/
+			block.setProcessCode(processCodeTextArea.getText());
+
+			this.dispose();
+		}
+
+		if ("Cancel".equals(e.getActionCommand())) {
+			this.dispose();
+		}
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/ui/window/JDialogSysCAMSPortConverter.java b/src/main/java/ui/window/JDialogSysCAMSPortConverter.java
new file mode 100644
index 0000000000..4dc79f42d7
--- /dev/null
+++ b/src/main/java/ui/window/JDialogSysCAMSPortConverter.java
@@ -0,0 +1,301 @@
+/* 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.window;
+
+import ui.syscams.*;
+import ui.util.IconManager;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.AbstractAction;
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.KeyStroke;
+
+/**
+ * Class JDialogSystemCAMSPortConverterIn
+ * Dialog for managing of SystemC-AMS Converter Input Port
+ * Creation: 07/05/2018
+ * @version 1.0 07/05/2018
+ * @author Irina Kit Yan LEE
+*/
+
+@SuppressWarnings("serial")
+
+public class JDialogSysCAMSPortConverter extends JDialog implements ActionListener {
+
+	/** Access to ActionPerformed **/
+	private JTextField nameTextField;
+	private JTextField periodTextField;
+	private JTextField rateTextField;
+	private JTextField delayTextField;
+	private String listTypeString[];
+	private JComboBox<String> typeComboBoxString;
+	private String listOriginString[];
+	private JComboBox<String> originComboBoxString;
+
+	/** Parameters **/
+	private SysCAMSPortConverter port;
+
+	/** Constructor **/
+	public JDialogSysCAMSPortConverter(SysCAMSPortConverter port) {
+		/** Set JDialog **/
+		this.setTitle("Setting Converter Ports");
+		this.setSize(500, 318);
+		this.setLocationRelativeTo(null);
+		this.setVisible(true);
+		this.setAlwaysOnTop(true);
+		this.setResizable(false);
+
+		/** Parameters **/
+		this.port = port;
+		
+		getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
+        getRootPane().getActionMap().put("close", new AbstractAction() {
+        	public void actionPerformed(ActionEvent e) {
+                dispose();
+        	}
+        });
+        
+		dialog();
+	}
+
+	public void dialog() {
+		/** JPanel **/
+		JPanel mainPanel = new JPanel(new BorderLayout());
+		this.add(mainPanel);
+		
+		JPanel attributesMainPanel = new JPanel(new GridLayout());
+		mainPanel.add(attributesMainPanel, BorderLayout.NORTH);
+		
+		// Left Side
+		Box box = Box.createVerticalBox();
+		box.setBorder(BorderFactory.createTitledBorder("Setting converter input port attributes"));
+
+		JPanel boxPanel = new JPanel(new GridLayout(6, 2, 0, 10));
+
+		JLabel labelName = new JLabel("Name : ");
+		boxPanel.add(labelName);
+
+		if (port.getPortName().toString().equals("")) { // name empty
+			nameTextField = new JTextField(10);
+		} else {
+			nameTextField = new JTextField(port.getPortName().toString(), 10); // name not empty
+		}
+
+		boxPanel.add(nameTextField);
+
+		// Period
+		JLabel periodLabel = new JLabel("Period Tp (us) : ");
+		boxPanel.add(periodLabel); // add label to box
+		if (port.getPeriod() == -1) { // name empty 		// port.getName().toString().equals("") ||
+			periodTextField = new JTextField(10);
+		} else {
+			periodTextField = new JTextField("" + port.getPeriod(), 10); // name not empty
+		}
+		boxPanel.add(periodTextField); // add text to box
+
+		// Rate
+		JLabel rateLabel = new JLabel("Rate : ");
+		boxPanel.add(rateLabel); // add label to box
+
+		if (port.getRate() == -1) { // name empty		// port.getName().toString().equals("") ||
+			rateTextField = new JTextField(10);
+		} else {
+			rateTextField = new JTextField("" + port.getRate(), 10); // name not empty
+		}
+		boxPanel.add(rateTextField); // add text to box
+
+		// Delay
+		JLabel delayLabel = new JLabel("Delay : ");
+		boxPanel.add(delayLabel); // add label to box
+		if (port.getDelay() == -1) { // name empty			// port.getName().toString().equals("") || 
+			delayTextField = new JTextField(10);
+		} else {
+			delayTextField = new JTextField("" + port.getDelay(), 10); // name not empty
+		}
+		boxPanel.add(delayTextField); // add text to box
+
+		// Type
+		JLabel typeLabel = new JLabel("Type : ");
+		boxPanel.add(typeLabel); // add label to box
+		listTypeString = new String[4];
+		listTypeString[0] = "int";
+		listTypeString[1] = "bool";
+		listTypeString[2] = "double";
+		listTypeString[3] = "sc_dt::sc_logic";
+		typeComboBoxString = new JComboBox<String>(listTypeString);
+		if (port.getConvType().equals("") || port.getConvType().equals("int")) {
+			typeComboBoxString.setSelectedIndex(0);
+		}
+		if (port.getConvType().equals("bool")) {
+			typeComboBoxString.setSelectedIndex(1);
+		}
+		if (port.getConvType().equals("double")) {
+			typeComboBoxString.setSelectedIndex(2);
+		}
+		if (port.getConvType().equals("sc_dt::sc_logic")) {
+			typeComboBoxString.setSelectedIndex(3);
+		}
+		typeComboBoxString.setActionCommand("type");
+		typeComboBoxString.addActionListener(this);
+		boxPanel.add(typeComboBoxString); // add combo to box
+
+		// Origin
+		JLabel orginLabel = new JLabel("Origin : ");
+		boxPanel.add(orginLabel); // add label to box
+		listOriginString = new String[2];
+		listOriginString[0] = "Input";
+		listOriginString[1] = "Output";
+		originComboBoxString = new JComboBox<String>(listOriginString);
+		if (port.getOrigin() == 0 || port.getOrigin() == -1) {
+			originComboBoxString.setSelectedIndex(0);
+		} else {
+			originComboBoxString.setSelectedIndex(1);
+		}
+		originComboBoxString.setActionCommand("origin");
+		originComboBoxString.addActionListener(this);
+		boxPanel.add(originComboBoxString); // add combo to box
+		
+		box.add(boxPanel); // add border to box
+		attributesMainPanel.add(box); // add grid to grid
+
+		// Down Side
+		JPanel downPanel = new JPanel(new GridLayout(1, 2));
+
+		JButton saveCloseButton = new JButton("Save and close");
+		saveCloseButton.setIcon(IconManager.imgic25);
+		saveCloseButton.setActionCommand("Save_Close");
+		saveCloseButton.addActionListener(this);
+		downPanel.add(saveCloseButton);
+
+		JButton cancelButton = new JButton("Cancel");
+		cancelButton.setIcon(IconManager.imgic27);
+		cancelButton.setActionCommand("Cancel");
+		cancelButton.addActionListener(this);
+		downPanel.add(cancelButton);
+
+		mainPanel.add(downPanel, BorderLayout.CENTER);
+	
+		this.getRootPane().setDefaultButton(saveCloseButton);
+	}
+
+	public void actionPerformed(ActionEvent e) {
+		if ("Save_Close".equals(e.getActionCommand())) {
+			port.setPortName(new String(nameTextField.getText()));
+
+			if (!(periodTextField.getText().isEmpty())) {
+				Boolean periodValueInteger = false;
+				try {
+					Integer.parseInt(periodTextField.getText());
+				} catch (NumberFormatException e1) {
+					JDialog msg = new JDialog(this);
+					msg.setLocationRelativeTo(null);
+					JOptionPane.showMessageDialog(msg, "Period is not a Integer", "Warning !",
+							JOptionPane.WARNING_MESSAGE);
+					periodValueInteger = true;
+				}
+				if (periodValueInteger == false) {
+					port.setPeriod(Integer.parseInt(periodTextField.getText()));
+				}
+			} else {
+				port.setPeriod(-1);
+			}
+			if (!(rateTextField.getText().isEmpty())) {
+				Boolean rateValueInteger = false;
+				try {
+					Integer.parseInt(rateTextField.getText());
+				} catch (NumberFormatException e1) {
+					JDialog msg = new JDialog(this);
+					msg.setLocationRelativeTo(null);
+					JOptionPane.showMessageDialog(msg, "Rate is not a Integer", "Warning !",
+							JOptionPane.WARNING_MESSAGE);
+					rateValueInteger = true;
+				}
+				if (rateValueInteger == false) {
+					port.setRate(Integer.parseInt(rateTextField.getText()));
+				}
+			} else {
+				port.setRate(-1);
+			}
+
+			if (!(delayTextField.getText().isEmpty())) {
+				Boolean delayValueInteger = false;
+				try {
+					Integer.parseInt(delayTextField.getText());
+				} catch (NumberFormatException e1) {
+					JDialog msg = new JDialog(this);
+					msg.setLocationRelativeTo(null);
+					JOptionPane.showMessageDialog(msg, "Delay is not a Integer", "Warning !",
+							JOptionPane.WARNING_MESSAGE);
+					delayValueInteger = true;
+				}
+				if (delayValueInteger == false) {
+					port.setDelay(Integer.parseInt(delayTextField.getText()));
+				}
+			} else {
+				port.setDelay(-1);
+			}
+			port.setConvType((String) typeComboBoxString.getSelectedItem());
+			
+			if ((String) originComboBoxString.getSelectedItem() == "Output") {
+				port.setOrigin(1);
+			} else {
+				port.setOrigin(0);
+			}
+			
+			this.dispose();
+		}
+
+		if ("Cancel".equals(e.getActionCommand())) {
+			this.dispose();
+		}
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/ui/window/JDialogSysCAMSPortDE.java b/src/main/java/ui/window/JDialogSysCAMSPortDE.java
new file mode 100644
index 0000000000..8befc5994a
--- /dev/null
+++ b/src/main/java/ui/window/JDialogSysCAMSPortDE.java
@@ -0,0 +1,297 @@
+/* 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.window;
+
+import ui.syscams.*;
+import ui.util.IconManager;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.AbstractAction;
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.KeyStroke;
+
+/**
+ * Class JDialogSystemCAMSPortDE
+ * Dialog for managing of SystemC-AMS DE Port
+ * Creation: 07/05/2018
+ * @version 1.0 07/05/2018
+ * @author Irina Kit Yan LEE
+*/
+
+@SuppressWarnings("serial")
+
+public class JDialogSysCAMSPortDE extends JDialog implements ActionListener {
+
+	/** Access to ActionPerformed **/
+	private JTextField nameTextField;
+	private JTextField periodTextField;
+	private JTextField rateTextField;
+	private JTextField delayTextField;
+	private String listTypeString[];
+	private JComboBox<String> typeComboBoxString;
+	private String listOriginString[];
+	private JComboBox<String> originComboBoxString;
+
+	/** Parameters **/
+	private SysCAMSPortDE port;
+
+	/** Constructor **/
+	public JDialogSysCAMSPortDE(SysCAMSPortDE port) {
+		/** Set JDialog **/
+		this.setTitle("Setting DE Ports");
+		this.setSize(500, 318);
+		this.setLocationRelativeTo(null);
+		this.setVisible(true);
+		this.setAlwaysOnTop(true);
+		this.setResizable(false);
+
+		/** Parameters **/
+		this.port = port;
+		
+		getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
+        getRootPane().getActionMap().put("close", new AbstractAction() {
+        	public void actionPerformed(ActionEvent e) {
+                dispose();
+        	}
+        });
+		
+		dialog();
+	}
+
+	public void dialog() {
+		/** JPanel **/
+		JPanel mainPanel = new JPanel(new BorderLayout());
+		this.add(mainPanel);
+		
+		JPanel attributesMainPanel = new JPanel(new GridLayout());
+		mainPanel.add(attributesMainPanel, BorderLayout.NORTH);
+		
+		// Left Side
+		Box box = Box.createVerticalBox();
+		box.setBorder(BorderFactory.createTitledBorder("Setting DE port attributes"));
+
+		JPanel boxPanel = new JPanel(new GridLayout(6, 2, 0, 10));
+
+		JLabel labelName = new JLabel("Name : ");
+		boxPanel.add(labelName);
+
+		if (port.getPortName().toString().equals("")) { // name empty
+			nameTextField = new JTextField(10);
+		} else {
+			nameTextField = new JTextField(port.getPortName().toString(), 10); // name not empty
+		}
+
+		boxPanel.add(nameTextField);
+
+		// Period
+		JLabel periodLabel = new JLabel("Period Tp (us) : ");
+		boxPanel.add(periodLabel); // add label to box
+		if (port.getPeriod() == -1) { // name empty 		// port.getName().toString().equals("") ||
+			periodTextField = new JTextField(10);
+		} else {
+			periodTextField = new JTextField("" + port.getPeriod(), 10); // name not empty
+		}
+		boxPanel.add(periodTextField); // add text to box
+
+		// Rate
+		JLabel rateLabel = new JLabel("Rate : ");
+		boxPanel.add(rateLabel); // add label to box
+
+		if (port.getRate() == -1) { // name empty		// port.getName().toString().equals("") ||
+			rateTextField = new JTextField(10);
+		} else {
+			rateTextField = new JTextField("" + port.getRate(), 10); // name not empty
+		}
+		boxPanel.add(rateTextField); // add text to box
+
+		// Delay
+		JLabel delayLabel = new JLabel("Delay : ");
+		boxPanel.add(delayLabel); // add label to box
+		if (port.getDelay() == -1) { // name empty			// port.getName().toString().equals("") || 
+			delayTextField = new JTextField(10);
+		} else {
+			delayTextField = new JTextField("" + port.getDelay(), 10); // name not empty
+		}
+		boxPanel.add(delayTextField); // add text to box
+
+		// Type
+		JLabel typeLabel = new JLabel("Type : ");
+		boxPanel.add(typeLabel); // add label to box
+		listTypeString = new String[3];
+		listTypeString[0] = "int";
+		listTypeString[1] = "bool";
+		listTypeString[2] = "double";
+		typeComboBoxString = new JComboBox<String>(listTypeString);
+		if (port.getDEType().equals("") || port.getDEType().equals("int")) {
+			typeComboBoxString.setSelectedIndex(0);
+		}
+		if (port.getDEType().equals("bool")) {
+			typeComboBoxString.setSelectedIndex(1);
+		}
+		if (port.getDEType().equals("double")) {
+			typeComboBoxString.setSelectedIndex(2);
+		}
+		typeComboBoxString.setActionCommand("type");
+		typeComboBoxString.addActionListener(this);
+		boxPanel.add(typeComboBoxString); // add combo to box
+		
+		// Origin
+		JLabel orginLabel = new JLabel("Origin : ");
+		boxPanel.add(orginLabel); // add label to box
+		listOriginString = new String[2];
+		listOriginString[0] = "Input";
+		listOriginString[1] = "Output";
+		originComboBoxString = new JComboBox<String>(listOriginString);
+		if (port.getOrigin() == 0 || port.getOrigin() == -1) {
+			originComboBoxString.setSelectedIndex(0);
+		} else {
+			originComboBoxString.setSelectedIndex(1);
+		}
+		originComboBoxString.setActionCommand("origin");
+		originComboBoxString.addActionListener(this);
+		boxPanel.add(originComboBoxString); // add combo to box
+
+		box.add(boxPanel); // add border to box
+		attributesMainPanel.add(box); // add grid to grid
+
+		// Down Side
+		JPanel downPanel = new JPanel(new GridLayout(1, 2));
+
+		JButton saveCloseButton = new JButton("Save and close");
+		saveCloseButton.setIcon(IconManager.imgic25);
+		saveCloseButton.setActionCommand("Save_Close");
+		saveCloseButton.addActionListener(this);
+		downPanel.add(saveCloseButton);
+
+		JButton cancelButton = new JButton("Cancel");
+		cancelButton.setIcon(IconManager.imgic27);
+		cancelButton.setActionCommand("Cancel");
+		cancelButton.addActionListener(this);
+		downPanel.add(cancelButton);
+
+		mainPanel.add(downPanel, BorderLayout.CENTER);
+		
+		this.getRootPane().setDefaultButton(saveCloseButton);
+	}
+
+	public void actionPerformed(ActionEvent e) {
+		if ("Save_Close".equals(e.getActionCommand())) {
+			port.setPortName(new String(nameTextField.getText()));
+
+			if (!(periodTextField.getText().isEmpty())) {
+				Boolean periodValueInteger = false;
+				try {
+					Integer.parseInt(periodTextField.getText());
+				} catch (NumberFormatException e1) {
+					JDialog msg = new JDialog(this);
+					msg.setLocationRelativeTo(null);
+					JOptionPane.showMessageDialog(msg, "Period is not a Integer", "Warning !",
+							JOptionPane.WARNING_MESSAGE);
+					periodValueInteger = true;
+				}
+				if (periodValueInteger == false) {
+					port.setPeriod(Integer.parseInt(periodTextField.getText()));
+				}
+			} else {
+				port.setPeriod(-1);
+			}
+			if (!(rateTextField.getText().isEmpty())) {
+				Boolean rateValueInteger = false;
+				try {
+					Integer.parseInt(rateTextField.getText());
+				} catch (NumberFormatException e1) {
+					JDialog msg = new JDialog(this);
+					msg.setLocationRelativeTo(null);
+					JOptionPane.showMessageDialog(msg, "Rate is not a Integer", "Warning !",
+							JOptionPane.WARNING_MESSAGE);
+					rateValueInteger = true;
+				}
+				if (rateValueInteger == false) {
+					port.setRate(Integer.parseInt(rateTextField.getText()));
+				}
+			} else {
+				port.setRate(-1);
+			}
+
+			if (!(delayTextField.getText().isEmpty())) {
+				Boolean delayValueInteger = false;
+				try {
+					Integer.parseInt(delayTextField.getText());
+				} catch (NumberFormatException e1) {
+					JDialog msg = new JDialog(this);
+					msg.setLocationRelativeTo(null);
+					JOptionPane.showMessageDialog(msg, "Delay is not a Integer", "Warning !",
+							JOptionPane.WARNING_MESSAGE);
+					delayValueInteger = true;
+				}
+				if (delayValueInteger == false) {
+					port.setDelay(Integer.parseInt(delayTextField.getText()));
+				}
+			} else {
+				port.setDelay(-1);
+			}
+			port.setDEType((String) typeComboBoxString.getSelectedItem());
+
+			if ((String) originComboBoxString.getSelectedItem() == "Output") {
+				port.setOrigin(1);
+			} else {
+				port.setOrigin(0);
+			}
+			
+			this.dispose();
+		}
+
+		if ("Cancel".equals(e.getActionCommand())) {
+			this.dispose();
+		}
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/ui/window/JDialogSysCAMSPortTDF.java b/src/main/java/ui/window/JDialogSysCAMSPortTDF.java
new file mode 100644
index 0000000000..59f0a08f8c
--- /dev/null
+++ b/src/main/java/ui/window/JDialogSysCAMSPortTDF.java
@@ -0,0 +1,297 @@
+/* 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.window;
+
+import ui.syscams.*;
+import ui.util.IconManager;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.AbstractAction;
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.KeyStroke;
+
+/**
+ * Class JDialogSystemCAMSPortTDF
+ * Dialog for managing of SystemC-AMS TDF Port
+ * Creation: 26/04/2018
+ * @version 1.0 26/04/2018
+ * @author Irina Kit Yan LEE
+*/
+
+@SuppressWarnings("serial")
+
+public class JDialogSysCAMSPortTDF extends JDialog implements ActionListener {
+
+	/** Access to ActionPerformed **/
+	private JTextField nameTextField;
+	private JTextField periodTextField;
+	private JTextField rateTextField;
+	private JTextField delayTextField;
+	private String listTypeString[];
+	private JComboBox<String> typeComboBoxString;
+	private String listOriginString[];
+	private JComboBox<String> originComboBoxString;
+
+	/** Parameters **/
+	private SysCAMSPortTDF port;
+
+	/** Constructor **/
+	public JDialogSysCAMSPortTDF(SysCAMSPortTDF port) {
+		/** Set JDialog **/
+		this.setTitle("Setting TDF Ports");
+		this.setSize(500, 318);
+		this.setLocationRelativeTo(null);
+		this.setVisible(true);
+		this.setAlwaysOnTop(true);
+		this.setResizable(false);
+
+		/** Parameters **/
+		this.port = port;
+		
+		getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
+        getRootPane().getActionMap().put("close", new AbstractAction() {
+        	public void actionPerformed(ActionEvent e) {
+                dispose();
+        	}
+        });
+		
+		dialog();
+	}
+
+	public void dialog() {
+		/** JPanel **/
+		JPanel mainPanel = new JPanel(new BorderLayout());
+		this.add(mainPanel);
+		
+		JPanel attributesMainPanel = new JPanel(new GridLayout());
+		mainPanel.add(attributesMainPanel, BorderLayout.NORTH);
+		
+		// Left Side
+		Box box = Box.createVerticalBox();
+		box.setBorder(BorderFactory.createTitledBorder("Setting TDF port attributes"));
+
+		JPanel boxPanel = new JPanel(new GridLayout(6, 2, 0, 10));
+
+		JLabel labelName = new JLabel("Name : ");
+		boxPanel.add(labelName);
+
+		if (port.getPortName().toString().equals("")) { // name empty
+			nameTextField = new JTextField(10);
+		} else {
+			nameTextField = new JTextField(port.getPortName().toString(), 10); // name not empty
+		}
+
+		boxPanel.add(nameTextField);
+
+		// Period
+		JLabel periodLabel = new JLabel("Period Tp (us) : ");
+		boxPanel.add(periodLabel); // add label to box
+		if (port.getPeriod() == -1) { // name empty 		// port.getName().toString().equals("") ||
+			periodTextField = new JTextField(10);
+		} else {
+			periodTextField = new JTextField("" + port.getPeriod(), 10); // name not empty
+		}
+		boxPanel.add(periodTextField); // add text to box
+
+		// Rate
+		JLabel rateLabel = new JLabel("Rate : ");
+		boxPanel.add(rateLabel); // add label to box
+
+		if (port.getRate() == -1) { // name empty		// port.getName().toString().equals("") ||
+			rateTextField = new JTextField(10);
+		} else {
+			rateTextField = new JTextField("" + port.getRate(), 10); // name not empty
+		}
+		boxPanel.add(rateTextField); // add text to box
+
+		// Delay
+		JLabel delayLabel = new JLabel("Delay : ");
+		boxPanel.add(delayLabel); // add label to box
+		if (port.getDelay() == -1) { // name empty			// port.getName().toString().equals("") || 
+			delayTextField = new JTextField(10);
+		} else {
+			delayTextField = new JTextField("" + port.getDelay(), 10); // name not empty
+		}
+		boxPanel.add(delayTextField); // add text to box
+
+		// Type
+		JLabel typeLabel = new JLabel("Type : ");
+		boxPanel.add(typeLabel); // add label to box
+		listTypeString = new String[3];
+		listTypeString[0] = "int";
+		listTypeString[1] = "bool";
+		listTypeString[2] = "double";
+		typeComboBoxString = new JComboBox<String>(listTypeString);
+		if (port.getTDFType().equals("") || port.getTDFType().equals("int")) {
+			typeComboBoxString.setSelectedIndex(0);
+		}
+		if (port.getTDFType().equals("bool")) {
+			typeComboBoxString.setSelectedIndex(1);
+		}
+		if (port.getTDFType().equals("double")) {
+			typeComboBoxString.setSelectedIndex(2);
+		}
+		typeComboBoxString.setActionCommand("type");
+		typeComboBoxString.addActionListener(this);
+		boxPanel.add(typeComboBoxString); // add combo to box
+
+		// Origin
+		JLabel orginLabel = new JLabel("Origin : ");
+		boxPanel.add(orginLabel); // add label to box
+		listOriginString = new String[2];
+		listOriginString[0] = "Input";
+		listOriginString[1] = "Output";
+		originComboBoxString = new JComboBox<String>(listOriginString);
+		if (port.getOrigin() == 0 || port.getOrigin() == -1) {
+			originComboBoxString.setSelectedIndex(0);
+		} else {
+			originComboBoxString.setSelectedIndex(1);
+		}
+		originComboBoxString.setActionCommand("origin");
+		originComboBoxString.addActionListener(this);
+		boxPanel.add(originComboBoxString); // add combo to box
+		
+		box.add(boxPanel); // add border to box
+		attributesMainPanel.add(box); // add grid to grid
+
+		// Down Side
+		JPanel downPanel = new JPanel(new GridLayout(1, 2));
+
+		JButton saveCloseButton = new JButton("Save and close");
+		saveCloseButton.setIcon(IconManager.imgic25);
+		saveCloseButton.setActionCommand("Save_Close");
+		saveCloseButton.addActionListener(this);
+		downPanel.add(saveCloseButton);
+
+		JButton cancelButton = new JButton("Cancel");
+		cancelButton.setIcon(IconManager.imgic27);
+		cancelButton.setActionCommand("Cancel");
+		cancelButton.addActionListener(this);
+		downPanel.add(cancelButton);
+
+		mainPanel.add(downPanel, BorderLayout.CENTER);
+		
+		this.getRootPane().setDefaultButton(saveCloseButton);
+	}
+
+	public void actionPerformed(ActionEvent e) {
+		if ("Save_Close".equals(e.getActionCommand())) {
+			port.setPortName(new String(nameTextField.getText()));
+
+			if (!(periodTextField.getText().isEmpty())) {
+				Boolean periodValueInteger = false;
+				try {
+					Integer.parseInt(periodTextField.getText());
+				} catch (NumberFormatException e1) {
+					JDialog msg = new JDialog(this);
+					msg.setLocationRelativeTo(null);
+					JOptionPane.showMessageDialog(msg, "Period is not a Integer", "Warning !",
+							JOptionPane.WARNING_MESSAGE);
+					periodValueInteger = true;
+				}
+				if (periodValueInteger == false) {
+					port.setPeriod(Integer.parseInt(periodTextField.getText()));
+				}
+			} else {
+				port.setPeriod(-1);
+			}
+			if (!(rateTextField.getText().isEmpty())) {
+				Boolean rateValueInteger = false;
+				try {
+					Integer.parseInt(rateTextField.getText());
+				} catch (NumberFormatException e1) {
+					JDialog msg = new JDialog(this);
+					msg.setLocationRelativeTo(null);
+					JOptionPane.showMessageDialog(msg, "Rate is not a Integer", "Warning !",
+							JOptionPane.WARNING_MESSAGE);
+					rateValueInteger = true;
+				}
+				if (rateValueInteger == false) {
+					port.setRate(Integer.parseInt(rateTextField.getText()));
+				}
+			} else {
+				port.setRate(-1);
+			}
+
+			if (!(delayTextField.getText().isEmpty())) {
+				Boolean delayValueInteger = false;
+				try {
+					Integer.parseInt(delayTextField.getText());
+				} catch (NumberFormatException e1) {
+					JDialog msg = new JDialog(this);
+					msg.setLocationRelativeTo(null);
+					JOptionPane.showMessageDialog(msg, "Delay is not a Integer", "Warning !",
+							JOptionPane.WARNING_MESSAGE);
+					delayValueInteger = true;
+				}
+				if (delayValueInteger == false) {
+					port.setDelay(Integer.parseInt(delayTextField.getText()));
+				}
+			} else {
+				port.setDelay(-1);
+			}
+			port.setTDFType((String) typeComboBoxString.getSelectedItem());
+			
+			if ((String) originComboBoxString.getSelectedItem() == "Output") {
+				port.setOrigin(1);
+			} else {
+				port.setOrigin(0);
+			}
+			
+			this.dispose();
+		}
+
+		if ("Cancel".equals(e.getActionCommand())) {
+			this.dispose();
+		}
+	}
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/GTURTLEModeling.java b/src/main/resources/ui/GTURTLEModeling.java
new file mode 100755
index 0000000000..d79e897533
--- /dev/null
+++ b/src/main/resources/ui/GTURTLEModeling.java
@@ -0,0 +1,10035 @@
+/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
+ *
+ * ludovic.apvrille AT telecom-paristech.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 avatartranslator.*;
+import avatartranslator.toproverif.AVATAR2ProVerif;
+import avatartranslator.totpn.AVATAR2TPN;
+import avatartranslator.toturtle.AVATAR2TURTLE;
+import avatartranslator.touppaal.AVATAR2UPPAAL;
+import common.ConfigurationTTool;
+import common.SpecConfigTTool;
+import ddtranslator.DDSyntaxException;
+import ddtranslator.DDTranslator;
+import launcher.LauncherException;
+import launcher.RemoteExecutionThread;
+import launcher.RshClient;
+import myutil.*;
+import nc.NCStructure;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+import proverifspec.ProVerifOutputAnalyzer;
+import proverifspec.ProVerifQueryAuthResult;
+import proverifspec.ProVerifQueryResult;
+import proverifspec.ProVerifSpec;
+import req.ebrdd.EBRDD;
+import sddescription.HMSC;
+import sddescription.MSC;
+import sddescription.SDExchange;
+import sdtranslator.SDTranslationException;
+import sdtranslator.SDTranslator;
+import tmatrix.RequirementModeling;
+import tmltranslator.*;
+import tmltranslator.modelcompiler.TMLModelCompiler;
+import tmltranslator.toautomata.TML2AUT;
+import tmltranslator.toautomata.TML2AUTviaLOTOS;
+import tmltranslator.toavatar.TML2Avatar;
+import tmltranslator.tosystemc.TML2SystemC;
+import tmltranslator.toturtle.Mapping2TIF;
+import tmltranslator.toturtle.TML2TURTLE;
+import tmltranslator.touppaal.RelationTMLUPPAAL;
+import tmltranslator.touppaal.TML2UPPAAL;
+import tpndescription.TPN;
+import translator.*;
+import translator.totpn.TURTLE2TPN;
+import translator.touppaal.RelationTIFUPPAAL;
+import translator.touppaal.TURTLE2UPPAAL;
+import ui.ad.TActivityDiagramPanel;
+import ui.atd.AttackTreeDiagramPanel;
+import ui.avatarad.AvatarADPanel;
+import ui.avatarbd.*;
+import ui.avatarcd.AvatarCDPanel;
+import ui.avatardd.ADDDiagramPanel;
+import ui.avatarmad.AvatarMADPanel;
+import ui.avatarmethodology.AvatarMethodologyDiagramPanel;
+import ui.avatarpd.AvatarPDPanel;
+import ui.avatarrd.AvatarRDPanel;
+import ui.avatarsmd.*;
+import ui.cd.TCDTClass;
+import ui.cd.TCDTObject;
+import ui.cd.TClassDiagramPanel;
+import ui.dd.TDDArtifact;
+import ui.dd.TDDNode;
+import ui.dd.TDeploymentDiagramPanel;
+import ui.diplodocusmethodology.DiplodocusMethodologyDiagramPanel;
+import ui.ebrdd.EBRDDPanel;
+import ui.ftd.FaultTreeDiagramPanel;
+import graph.RG;
+//import ui.het.CAMSBlockDiagramPanel;
+import ui.iod.InteractionOverviewDiagramPanel;
+import ui.ncdd.NCDiagramPanel;
+import ui.osad.TURTLEOSActivityDiagramPanel;
+import ui.oscd.TOSClass;
+import ui.oscd.TURTLEOSClassDiagramPanel;
+import ui.procsd.ProCSDComponent;
+import ui.procsd.ProactiveCSDPanel;
+import ui.prosmd.ProactiveSMDPanel;
+import ui.req.Requirement;
+import ui.req.RequirementDiagramPanel;
+import ui.sysmlsecmethodology.SysmlsecMethodologyDiagramPanel;
+import ui.tmlad.*;
+import ui.tmlcd.TMLTaskDiagramPanel;
+import ui.tmlcd.TMLTaskOperator;
+import ui.tmlcompd.*;
+import ui.tmlcp.TMLCPPanel;
+import ui.tmldd.*;
+import ui.tmlsd.TMLSDPanel;
+import ui.tree.*;
+import ui.ucd.UseCaseDiagramPanel;
+import ui.util.DefaultText;
+import ui.util.IconManager;
+import ui.window.JFrameSimulationTrace;
+import uppaaldesc.UPPAALSpec;
+
+import javax.swing.*;
+import javax.swing.tree.TreePath;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.awt.*;
+import java.io.*;
+import java.util.*;
+import java.util.List;
+
+// AVATAR
+// AVATAR
+
+//Communication Pattern javaCC parser
+//import compiler.tmlCPparser.*;
+
+/**
+ * Class GTURTLEModeling
+ * Creation: 09/12/2003
+ * Version: 1.1 02/06/2014
+ *
+ * @author Ludovic APVRILLE
+ */
+public class GTURTLEModeling {
+
+    //Added by Solange
+
+    public GProactiveDesign gpdtemp;
+
+
+    //
+    private Vector<TURTLEPanel> panels; /* analysis, design, deployment, tml design */
+    private TURTLEModeling tm;
+    private AvatarSpecification avatarspec;
+    //  private AttackTree attackTree;
+    private AVATAR2UPPAAL avatar2uppaal;
+    private AVATAR2ProVerif avatar2proverif;
+    private boolean optimizeAvatar;
+    private int tmState; // 0:generated, 1: to be generated from mapping, 2: to be generated from TML modeling
+
+    private TMLModeling<TGComponent> tmlm;
+    private TMLMapping<TGComponent> artificialtmap;
+    private TMLMapping<TGComponent> tmap;
+    private TMLCP tmlcp;
+    private TML2Avatar t2a;
+    private RequirementModeling rm;
+    private NCStructure ncs;
+    private final MainGUI mgui;
+    private CorrespondanceTGElement listE;
+    private String rtlotos;
+
+    private EBRDD ebrdd;
+
+    private UPPAALSpec uppaal;
+    private RelationTIFUPPAAL uppaalTIFTable;
+    private RelationTMLUPPAAL uppaalTMLTable;
+
+    private ProVerifSpec proverif;
+
+    private AVATAR2TPN avatar2tpn;
+    private TPN tpnFromAvatar;
+
+    private String tpn;
+    private String sim;
+    private String dta;
+    private String dtadot;
+    private String rg;
+    private String rgdot;
+    private String rgaut;
+    private String rgautdot;
+    private String rgautproj;
+    private String rgautprojdot;
+    private String tlsa;
+    private String tlsadot;
+
+    private List<RG> graphs;
+    private GraphTree gt;
+
+    private int nbRTLOTOS;
+    private int nbSuggestedDesign;
+    //  private int nbSuggestedAnalysis;
+    //  private int nbTPN;
+
+    //private ValidationDataTree vdt;
+    private SearchTree st;
+    private SyntaxAnalysisTree mcvdt;
+    private InvariantDataTree idt;
+
+    private List<CheckingError> checkingErrors;
+    private List<CheckingError> warnings;
+
+    private List<Invariant> invariants;
+
+    List<TGConnectorInfo> pendingConnectors;
+
+    private Vector<String> savedOperations;
+    private Vector<Point> savedPanels;
+    private int nbMaxSavedOperations = 10;
+    private int pointerOperation;
+
+    private DocumentBuilderFactory dbf;
+    private DocumentBuilder db;
+    private Document docCopy;
+
+    private int decX, decY, decId;
+
+    private static int graphId = 0;
+
+    private int languageID;
+    public final static int RT_LOTOS = 0;
+    public final static int LOTOS = 1;
+    public final static int AUT = 2;
+    public final static int TPN = 3;
+    public final static int MATRIX = 4;
+    public final static int UPPAAL = 5;
+    public final static int PROVERIF = 6;
+
+    private boolean undoRunning = false;
+
+
+    boolean hasCrypto = false;
+    //private Charset chset1, chset2;
+
+    public GTURTLEModeling(MainGUI _mgui, Vector<TURTLEPanel> _panels) {
+        mgui = _mgui;
+        panels = _panels;
+        try {
+            dbf = DocumentBuilderFactory.newInstance();
+            db = dbf.newDocumentBuilder();
+        } catch (ParserConfigurationException e) {
+            dbf = null;
+            db = null;
+        }
+        savedOperations = new Vector<String>();
+        savedPanels = new Vector<Point>();
+        pointerOperation = -1;
+
+        graphs = new ArrayList<RG>();
+        invariants = new LinkedList<Invariant>();
+
+        //vdt = new ValidationDataTree(mgui);
+        mcvdt = new SyntaxAnalysisTree(mgui);
+        idt = new InvariantDataTree(mgui);
+        st = new SearchTree(mgui);
+        gt = new GraphTree(mgui);
+
+        /*if (!Charset.isSupported("UTF-8")) {
+          ErrorGUI.exit(ErrorGUI.ERROR_CHARSET);
+          }
+
+          chset1 = Charset.forName("UTF-8");*/
+    }
+
+    public int getLanguageID() {
+        return languageID;
+    }
+
+    public boolean isRegularTM() {
+        if (tm == null) {
+            return false;
+        }
+        return tm.isARegularTIFSpec();
+    }
+
+    public List<RG> getRGs() {
+        return graphs;
+    }
+
+    public void addRG(RG newGraph) {
+        //TraceManager.addDev("Adding new graph " + newGraph);
+        graphs.add(newGraph);
+    }
+
+    public void removeRG(RG oldGraph) {
+        //TraceManager.addDev("Adding new graph " + newGraph);
+        graphs.remove(oldGraph);
+    }
+
+
+    public List<Invariant> getInvariants() {
+        return invariants;
+    }
+
+
+    public void addInvariant(Invariant _inv) {
+        invariants.add(_inv);
+        TraceManager.addDev("Adding invariant: " + _inv.toString());
+    }
+
+    public void clearInvariants() {
+        invariants.clear();
+    }
+
+
+    public String saveTIF() {
+        if (tm == null) {
+            TraceManager.addDev("NO TIF to save");
+            return null;
+        }
+
+        TIFExchange tif = new TIFExchange();
+        tif.setTURTLEModeling(tm);
+        String ret = tif.saveInXMLTIF();
+        TraceManager.addDev("TIF=\n" + ret);
+        return ret;
+    }
+
+    public boolean openTIF(String s) {
+        TIFExchange tif = new TIFExchange();
+        boolean ret = false;
+
+        try {
+            ret = tif.loadFromXMLTIF(s);
+            if (ret) {
+                tm = tif.getTURTLEModeling();
+                tmState = 0;
+                TraceManager.addDev("Got TIF");
+                generateDesign();
+            }
+        } catch (Exception e) {
+            TraceManager.addDev("Exception on TIF: " + e.getMessage());
+        }
+        return ret;
+    }
+
+    public boolean openSD(String s) {
+        SDExchange sde = new SDExchange();
+        boolean ret = false;
+
+        try {
+            ret = sde.loadFromXMLSD(s);
+            if (ret) {
+                //tm = tif.getTURTLEModeling();
+                //tmState = 0;
+                TraceManager.addDev("Got SD");
+                generateIOD(sde.getHMSC(), sde.getMSC());
+            }
+        } catch (Exception e) {
+            TraceManager.addDev("Exception on SD: " + e.getMessage());
+        }
+        return ret;
+    }
+
+    /*public void mergeChoices(boolean nonDeterministic) {
+      if (tm != null) {
+      tm.mergeChoices(nonDeterministic);
+      }
+      }*/
+
+    public NCStructure getNCS() {
+        return ncs;
+    }
+
+    public void generateRTLOTOS(File f) {
+        TURTLETranslator tt = new TURTLETranslator(tm);
+        rtlotos = tt.generateRTLOTOS();
+        warnings = tt.getWarnings();
+        nbRTLOTOS++;
+        if (f != null) {
+            saveInFile(f, rtlotos);
+        }
+        languageID = RT_LOTOS;
+        mgui.setMode(MainGUI.RTLOTOS_OK);
+    }
+
+    public void generateFullLOTOS(File f) {
+        reinitSIM();
+        reinitDTA();
+        reinitRG();
+        reinitRGAUT();
+        reinitRGAUTPROJDOT();
+        //TraceManager.addDev("generate LOTOS");
+        generateLOTOS(f);
+    }
+
+    public void generateLOTOS(File f) {
+        //tm.print();
+        TraceManager.addDev("Generating Lotos");
+        TURTLETranslator tt = new TURTLETranslator(tm);
+        rtlotos = tt.generateLOTOS(true);
+        warnings = tt.getWarnings();
+        TraceManager.addDev("Lotos generated");
+
+
+        nbRTLOTOS++;
+        if (f != null) {
+            saveInFile(f, rtlotos);
+        }
+        TraceManager.addDev("LOTOS to file done");
+        languageID = LOTOS;
+        mgui.setMode(MainGUI.RTLOTOS_OK);
+    }
+
+    public void generateTPN(File f) {
+        //tm.print();
+        TURTLE2TPN t2tpn = new TURTLE2TPN(tm);
+        tpn = t2tpn.generateTPN().toString();
+        warnings = t2tpn.getWarnings();
+
+        //  nbTPN ++;
+        if (f != null) {
+            TraceManager.addDev("Saving in file: " + f);
+            saveInFile(f, tpn);
+        }
+        languageID = TPN;
+
+        // For debug purpose
+        //TraceManager.addDev(tpn);
+
+        mgui.setMode(MainGUI.RTLOTOS_OK);
+    }
+
+    public List<String> generateAUT(String path) {
+        TML2AUT tml2aut = new TML2AUT(tmlm);
+        tml2aut.generateAutomatas(true);
+        try {
+            return tml2aut.saveInFiles(path);
+        } catch (FileException fe) {
+            return null;
+        }
+    }
+
+    public boolean generateCCode(String directory, String compilationOptions) {
+
+        //CheckingError ce;
+        //int type;
+        // TGComponent tgc;
+        String applicationName;
+        TMLModelCompiler CCode;
+
+        if (tmap == null) {
+            JOptionPane.showMessageDialog(mgui.frame, "C code is only generated from an architecture diagram with mapping information", "Control code generation failed", JOptionPane.INFORMATION_MESSAGE);
+            return true;
+        }
+        // Get the file from DiplodocusPECPragma
+        //List<TGComponent> components = mgui.getCurrentArchiPanel().tmlap.getComponentList();
+        // Parse the PEC file and the library of code snippets for each DIPLODOCUS unit
+        applicationName = tmap.getMappedTasks().get(0).getName().split("__")[0];        // Remember that it works only for one application
+        CCode = new TMLModelCompiler(directory, applicationName, mgui.frame, mgui.getAllTMLCP(), tmap);
+
+        // Issue #98: Use the passed directory
+        File dir = new File(directory /*ConfigurationTTool.CCodeDirectory*/ + File.separator);
+
+        if (!dir.exists()) {
+            dir.mkdirs();
+        }
+
+        CCode.toTextFormat();
+
+        try {
+            if (directory.equals("")) {
+
+                JOptionPane.showMessageDialog(mgui.frame,
+                        "No directory for C code generation found in config.xml. The C code cannot be generated.",
+                        "Control code generation failed", JOptionPane.INFORMATION_MESSAGE);
+                return true;
+            } else {
+                SpecConfigTTool.checkAndCreateCCodeDir(directory);
+                CCode.saveFile(directory + File.separator, applicationName);
+            }
+        } catch (Exception e) {
+            JOptionPane.showMessageDialog(mgui.frame, "The application C files could not be saved: " + e.getMessage(), "Control code generation failed", JOptionPane.INFORMATION_MESSAGE);
+            return true;
+        }
+        return false;
+    }
+
+    public boolean generateTMLTxt(String _title) {
+
+        //This branch is activated if doing the syntax check from the architecture panel.
+        //It generates the text TML for the architecture and the application + mapping information
+        if (tmap != null) {
+            TMLMappingTextSpecification<TGComponent> spec = new TMLMappingTextSpecification<>(_title);
+            spec.toTextFormat(tmap);    //TMLMapping
+            try {
+                //TraceManager.addDev( "*** " + ConfigurationTTool.TMLCodeDirectory + File.separator );
+                spec.saveFile(SpecConfigTTool.TMLCodeDirectory, "spec");
+            } catch (Exception e) {
+                TraceManager.addError("Files could not be saved: " + e.getMessage());
+                return false;
+            }
+        }
+
+        if (tmlcp != null) {         //Use the data structure filled by translateToTML... and pass it to the appropriate toTextFormat()
+            TraceManager.addError("About to generate the TMLText for CPs");
+            TMLCPTextSpecification specCP = new TMLCPTextSpecification(_title);
+
+            //get the architecture panel and the nodes
+            TMLArchiDiagramPanel tmlap = mgui.getTMLArchiDiagramPanels().get(0).tmlap;
+            List<TGComponent> components = tmlap.getComponentList();
+            Iterator<TGComponent> iterator = components.listIterator();
+            TGComponent tgc;
+
+            while (iterator.hasNext()) {
+                tgc = iterator.next();
+
+                if (tgc instanceof TMLArchiCPNode) {
+                    TMLArchiCPNode node = (TMLArchiCPNode) tgc;
+                    TraceManager.addDev("Found CP node: " + node.getName());
+                    TraceManager.addDev("with mapping info: " + node.getMappedUnits());
+                }
+            }
+
+            List<TMLCommunicationPatternPanel> tmlcpPanelsList = new ArrayList<TMLCommunicationPatternPanel>();
+            //get the TMLCommunicationPatternPanels :)
+            for (int i = 0; i < mgui.tabs.size(); i++) {
+                TURTLEPanel panel = mgui.tabs.get(i);
+
+                if (panel instanceof TMLCommunicationPatternPanel) {
+                    tmlcpPanelsList.add((TMLCommunicationPatternPanel) panel);
+                    TraceManager.addDev("Found TMLCommunicationPatternPanel: " + panel.toString());
+                }
+            }
+
+            specCP.toTextFormat(tmlcp);          // the data structure tmlcp is filled with the info concerning the CP panel
+            // from which the button is pressed. If there are multiple CP panels this operation must be repeated for each panel. It
+            // should be no difficult to implement.
+            try {
+                specCP.saveFile(SpecConfigTTool.TMLCodeDirectory, "spec.tmlcp");
+            } catch (Exception e) {
+                TraceManager.addError("Writing TMLText for CPs, file could not be saved: " + e.getMessage());
+                return false;
+            }
+
+        } else if (tmap == null) {
+            //This branch is activated if doing the syntax check from the application panel.
+            //It only generates the application TML text
+            if (tmap == null) {
+                TMLTextSpecification<TGComponent> spec = new TMLTextSpecification<>(_title);
+                spec.toTextFormat(tmlm);        //TMLModeling
+                try {
+                    spec.saveFile(SpecConfigTTool.TMLCodeDirectory, "spec.tml");
+                } catch (Exception e) {
+                    TraceManager.addError("File could not be saved: " + e.getMessage());
+                    return false;
+                }
+            }
+
+
+        }
+        return true;    //temporary, just to check functionality
+    }
+
+    public boolean generateUPPAALFromTIF(String path, boolean debug, int nb, boolean choices, boolean variables) {
+        TURTLE2UPPAAL turtle2uppaal = new TURTLE2UPPAAL(tm);
+        turtle2uppaal.setChoiceDeterministic(choices);
+        turtle2uppaal.setVariablesAsActions(variables);
+        uppaal = turtle2uppaal.generateUPPAAL(debug, nb);
+        TraceManager.addDev("Building relation table");
+        uppaalTIFTable = turtle2uppaal.getRelationTIFUPPAAL();
+        TraceManager.addDev("Building relation table done");
+        uppaalTMLTable = null;
+
+        languageID = UPPAAL;
+        mgui.setMode(MainGUI.UPPAAL_OK);
+
+        try {
+            TraceManager.addDev("Saving specification in " + path + "\n");
+
+            // DB: Moved from TURTLE2UPPAAL (introduced for project management)
+            SpecConfigTTool.checkAndCreateUPPAALDir(path);
+
+            turtle2uppaal.saveInFile(path);
+            TraceManager.addDev("UPPAAL specification has been generated in " + path + "\n");
+            return true;
+        } catch (FileException fe) {
+            TraceManager.addError("Exception: " + fe.getMessage());
+            return false;
+        }
+    }
+
+    public boolean generateUPPAALFromTML(String _path, boolean _debug, int _size, boolean choices) {
+        TraceManager.addDev("Generate UPPAAL from TML");
+        TML2UPPAAL tml2uppaal = new TML2UPPAAL(tmlm);
+        //tml2uppaal.setChoiceDeterministic(choices);
+        tml2uppaal.setSizeInfiniteFIFO(_size);
+        uppaal = tml2uppaal.generateUPPAAL(_debug);
+        uppaalTMLTable = tml2uppaal.getRelationTMLUPPAAL();
+        uppaalTIFTable = null;
+        languageID = UPPAAL;
+        mgui.setMode(MainGUI.UPPAAL_OK);
+        //uppaalTable = tml2uppaal.getRelationTIFUPPAAL(_debug);
+        try {
+            tml2uppaal.saveInFile(_path);
+            return true;
+        } catch (FileException fe) {
+            TraceManager.addError("Exception: " + fe.getMessage());
+            return false;
+        }
+    }
+
+    public boolean generateUPPAALFromAVATAR(String _path) {
+        if (avatarspec == null) {
+            TraceManager.addDev("Null avatar spec");
+            return false;
+        }
+        avatar2uppaal = new AVATAR2UPPAAL(avatarspec);
+        //tml2uppaal.setChoiceDeterministic(choices);
+        //tml2uppaal.setSizeInfiniteFIFO(_size);
+        uppaal = avatar2uppaal.generateUPPAAL(true, optimizeAvatar);
+        warnings = avatar2uppaal.getWarnings();
+        uppaalTMLTable = null;
+        uppaalTIFTable = null;
+        languageID = UPPAAL;
+        mgui.setMode(MainGUI.UPPAAL_OK);
+        //uppaalTable = tml2uppaal.getRelationTIFUPPAAL(_debug);
+        try {
+            avatar2uppaal.saveInFile(_path);
+            return true;
+        } catch (FileException fe) {
+            TraceManager.addError("Exception: " + fe.getMessage());
+            return false;
+        }
+    }
+
+    public AvatarSpecification getAvatarSpecification() {
+        return avatarspec;
+    }
+
+    public AVATAR2UPPAAL getAvatar2Uppaal() {
+        return avatar2uppaal;
+    }
+
+    public ProVerifOutputAnalyzer getProVerifOutputAnalyzer() {
+        return this.avatar2proverif.getOutputAnalyzer();
+    }
+
+    public boolean generateProVerifFromAVATAR(String _path, int _stateReachability, boolean _typed, boolean allowPrivateChannelDuplication) {
+        return generateProVerifFromAVATAR(_path, _stateReachability, _typed, allowPrivateChannelDuplication, "1");
+    }
+
+    public int calcSec() {
+        int overhead = 0;
+        //count # of insecure channels?
+        return overhead;
+    }
+
+    public boolean channelAllowed(TMLMapping<TGComponent> map, TMLChannel chan) {
+        TMLTask orig = chan.getOriginTask();
+        TMLTask dest = chan.getDestinationTask();
+        List<HwNode> path = getPath(map, orig, dest);
+        for (HwNode node : path) {
+            if (node instanceof HwBridge) {
+                for (String rule : ((HwBridge) node).firewallRules) {
+                    String t1 = rule.split("->")[0];
+                    String t2 = rule.split("->")[1];
+                    if (t1.equals(orig.getName().replaceAll("__", "::")) || t1.equals("*")) {
+                        if (t2.equals(dest.getName().replaceAll("__", "::")) || t2.equals("*")) {
+                            return false;
+                        }
+                    }
+                }
+            }
+        }
+        return true;
+    }
+
+    public List<HwNode> getPath(TMLMapping<TGComponent> map, TMLTask t1, TMLTask t2) {
+        HwNode node1 = map.getHwNodeOf(t1);
+        HwNode node2 = map.getHwNodeOf(t2);
+        List<HwNode> path = new ArrayList<HwNode>();
+        if (node1 == node2) {
+            return path;
+        }
+        if (node1 != node2) {
+            //Navigate architecture for node
+            List<HwLink> links = map.getTMLArchitecture().getHwLinks();
+            //  HwNode last = node1;
+            List<HwNode> found = new ArrayList<HwNode>();
+            List<HwNode> done = new ArrayList<HwNode>();
+            Map<HwNode, List<HwNode>> pathMap = new HashMap<HwNode, List<HwNode>>();
+            for (HwLink link : links) {
+                if (link.hwnode == node1) {
+                    found.add(link.bus);
+                    List<HwNode> tmp = new ArrayList<HwNode>();
+                    tmp.add(link.bus);
+                    pathMap.put(link.bus, tmp);
+                }
+            }
+            outerloop:
+            while (found.size() > 0) {
+                HwNode curr = found.remove(0);
+                for (HwLink link : links) {
+                    if (curr == link.bus) {
+                        if (link.hwnode == node2) {
+                            path = pathMap.get(curr);
+                            break outerloop;
+                        }
+                        if (!done.contains(link.hwnode) && !found.contains(link.hwnode) && link.hwnode instanceof HwBridge) {
+                            found.add(link.hwnode);
+                            List<HwNode> tmp = new ArrayList<HwNode>(pathMap.get(curr));
+                            tmp.add(link.hwnode);
+                            pathMap.put(link.hwnode, tmp);
+                        }
+                    } else if (curr == link.hwnode) {
+                        if (!done.contains(link.bus) && !found.contains(link.bus)) {
+                            found.add(link.bus);
+                            List<HwNode> tmp = new ArrayList<HwNode>(pathMap.get(curr));
+                            tmp.add(link.bus);
+                            pathMap.put(link.bus, tmp);
+                        }
+                    }
+                }
+                done.add(curr);
+            }
+        }
+        return path;
+    }
+
+    public TMLMapping<TGComponent> drawFirewall(TMLMapping<TGComponent> map) {
+        //  System.out.println("DRAWING FIREWALL");
+        TGComponent comp = map.getTMLModeling().getTGComponent();
+        TMLComponentDesignPanel tmlcdp = (TMLComponentDesignPanel) comp.getTDiagramPanel().tp;
+        // TMLComponentDesignPanel tmlcdp = map.getTMLCDesignPanel();
+        TMLModeling<TGComponent> tmlm = map.getTMLModeling();
+        TMLArchitecture archi = map.getArch();
+        TURTLEPanel tmlap = map.getCorrespondanceList().getTG(archi.getFirstCPU()).getTDiagramPanel().tp;
+        TMLActivityDiagramPanel firewallADP = null;
+        TMLComponentDesignPanel tcp = tmlcdp;
+        TMLComponentTaskDiagramPanel tcdp = tmlcdp.tmlctdp;
+        if (TraceManager.devPolicy == TraceManager.TO_CONSOLE) {
+            MainGUI gui = tmlcdp.getMainGUI();
+
+            int arch = mgui.tabs.indexOf(tmlap);
+            gui.cloneRenameTab(arch, "firewallArch");
+            TMLArchiPanel newarch = (TMLArchiPanel) gui.tabs.get(gui.tabs.size() - 1);
+            int ind = gui.tabs.indexOf(tmlcdp);
+            String tabName = gui.getTitleAt(tmlcdp);
+            gui.cloneRenameTab(ind, "firewallDesign");
+            tcp = (TMLComponentDesignPanel) gui.tabs.get(gui.tabs.size()-1);
+            newarch.renameMapping(tabName, tabName + "_firewallDesign");
+
+        }
+        for (HwBridge firewallNode : map.getTMLArchitecture().getFirewalls()) {
+            TraceManager.addDev("Found firewall " + firewallNode.getName());
+            TMLCPrimitiveComponent firewallComp = null;
+            TMLADStartState adStart = null;
+            TMLADForEverLoop adLoop = null;
+            TMLADChoice adChoice = null;
+            TMLADChoice adChoice2 = null;
+            TMLADReadChannel adRC = null;
+            TMLADExecI exec = null;
+            TMLADWriteChannel adWC = null;
+            TMLADStopState adStop = null;
+            TMLADStopState adStop2= null;
+
+            int links = map.getArch().getLinkByHwNode(firewallNode).size();
+            TraceManager.addDev("Links " + links);
+
+            HwCPU cpu = new HwCPU(firewallNode.getName());
+            map.getTMLArchitecture().replaceFirewall(firewallNode, cpu);
+          //  for (int link = 0; link < links / 2; link++) {
+                HashMap<TMLChannel, TMLChannel> inChans = new HashMap<TMLChannel, TMLChannel>();
+                HashMap<TMLChannel, TMLChannel> outChans = new HashMap<TMLChannel, TMLChannel>();
+                if (TraceManager.devPolicy == TraceManager.TO_CONSOLE) {
+                    firewallComp = new TMLCPrimitiveComponent(tmlcdp.tmlctdp.getMaxX()-100, tmlcdp.tmlctdp.getMaxY()-100, tmlcdp.tmlctdp.getMinX(), tmlcdp.tmlctdp.getMaxX(), tmlcdp.tmlctdp.getMinY(), tmlcdp.tmlctdp.getMaxY(), false, null, tcp.tmlctdp);
+                    tcp.tmlctdp.addComponent(firewallComp, 0, 0, false, true);
+                    firewallComp.setValueWithChange(firewallNode.getName());
+                    firewallADP = tcp.getTMLActivityDiagramPanel(firewallNode.getName());
+                }
+
+                List<TMLChannel> channelsCopy = tmlm.getChannels();
+                List<TMLChannel> toAdd = new ArrayList<TMLChannel>();
+
+                TMLTask firewall = new TMLTask("TASK__" + firewallNode.getName(), firewallComp, firewallADP);
+
+
+                tmlm.addTask(firewall);
+                map.addTaskToHwExecutionNode(firewall, cpu);
+                TMLActivity act = firewall.getActivityDiagram();
+
+                TraceManager.addDev("FirewallADP " + firewallADP);
+                for (TMLChannel chan : channelsCopy) {
+                    TMLTask orig = chan.getOriginTask();
+                    TMLTask dest = chan.getDestinationTask();
+                    TMLPort origPort = chan.getOriginPort();
+                    TMLPort destPort = chan.getDestinationPort();
+                    TMLChannel wr = new TMLChannel(chan.getName() + "_firewallIn", chan.getReferenceObject());
+                    //Specify new channel attributes
+                    wr.setSize(chan.getSize());
+                    wr.setMax(chan.getMax());
+                    wr.setPorts(origPort, destPort);
+                    wr.setType(TMLChannel.BRBW);
+                    wr.setPriority(chan.getPriority());
+                    wr.setTasks(orig, firewall);
+                    TMLChannel rd = new TMLChannel(chan.getName() + "_firewallOut", chan.getReferenceObject());
+                    rd.setTasks(firewall, dest);
+                    rd.setSize(chan.getSize());
+                    rd.setMax(chan.getMax());
+                    rd.setPorts(origPort, destPort);
+                    rd.setType(TMLChannel.BRBW);
+                    rd.setPriority(chan.getPriority());
+                    inChans.put(chan, wr);
+                    outChans.put(chan, rd);
+                    toAdd.add(rd);
+                    toAdd.add(wr);
+                    map.getCorrespondanceList().addCor(rd, (TGComponent) rd.getReferenceObject());
+                    map.getCorrespondanceList().addCor(wr, (TGComponent) wr.getReferenceObject());
+                }
+                tmlm.removeAllChannels();
+                for (TMLChannel c : toAdd) {
+                    tmlm.addChannel(c);
+                }
+
+
+                if (TraceManager.devPolicy == TraceManager.TO_CONSOLE) {
+                    //Build activity diagram
+                    //Get start state
+                    adStart = (TMLADStartState) firewallADP.getComponentList().get(0);
+                    //add loop
+                    adLoop = new TMLADForEverLoop(400, 150, firewallADP.getMinX(), firewallADP.getMaxX(), firewallADP.getMinY(), firewallADP.getMaxY(), false, null, firewallADP);
+                    firewallADP.addComponent(adLoop, 400, 150, false, true);
+                    TGConnector tmp = new TGConnectorTMLAD(adLoop.getX(), adLoop.getY(), firewallADP.getMinX(), firewallADP.getMaxX(), firewallADP.getMinY(), firewallADP.getMaxY(), false, null, firewallADP, adStart.getTGConnectingPointAtIndex(0), adLoop.getTGConnectingPointAtIndex(0), new Vector<Point>());
+                    firewallADP.addComponent(tmp, adLoop.getX(), adLoop.getY(), false, true);
+                    //add choice
+                    adChoice = new TMLADChoice(400, 300, firewallADP.getMinX(), firewallADP.getMaxX(), firewallADP.getMinY(), firewallADP.getMaxY(), false, null, firewallADP);
+                    firewallADP.addComponent(adChoice, 400, 300, false, true);
+
+                    tmp = new TGConnectorTMLAD(adChoice.getX(), adChoice.getY(), firewallADP.getMinX(), firewallADP.getMaxX(), firewallADP.getMinY(), firewallADP.getMaxY(), false, null, firewallADP, adLoop.getTGConnectingPointAtIndex(1), adChoice.getTGConnectingPointAtIndex(0), new Vector<Point>());
+                    firewallADP.addComponent(tmp, adChoice.getX(), adChoice.getY(), false, true);
+                    for (TMLChannel chan : inChans.keySet()) {
+
+                        TMLChannel newChan = inChans.get(chan);
+                        TMLCChannelOutPort originPort = new TMLCChannelOutPort(0, 0, tcp.tmlctdp.getMinX(), tcp.tmlctdp.getMaxX(), tcp.tmlctdp.getMinY(), tcp.tmlctdp.getMaxX(), true, null, tcp.tmlctdp);
+                        TMLCChannelOutPort destPort = new TMLCChannelOutPort(0, 0, tcp.tmlctdp.getMinX(), tcp.tmlctdp.getMaxX(), tcp.tmlctdp.getMinY(), tcp.tmlctdp.getMaxX(), true, null, tcp.tmlctdp);
+                        for (TGComponent tg : tcp.tmlctdp.getComponentList()) {
+                            if (tg instanceof TMLCPrimitiveComponent) {
+                                if (tg.getValue().equals(newChan.getOriginTask().getName().split("__")[1])) {
+                                	System.out.println(newChan.getName() + " " + tg.getValue());
+                                    originPort = new TMLCChannelOutPort(tg.getX(), tg.getY(), tcp.tmlctdp.getMinX(), tcp.tmlctdp.getMaxX(), tcp.tmlctdp.getMinY(), tcp.tmlctdp.getMaxX(), true, tg, tcp.tmlctdp);
+                                    originPort.commName = newChan.getName();
+                                    tcp.tmlctdp.addComponent(originPort, tg.getX(), tg.getY(), true, true);
+                                } else if (tg.getValue().equals(firewallNode.getName())) {
+                                	System.out.println(newChan.getName() + tg.getValue());
+                                    destPort = new TMLCChannelOutPort(tg.getX(), tg.getY(), tcp.tmlctdp.getMinX(), tcp.tmlctdp.getMaxX(), tcp.tmlctdp.getMinY(), tcp.tmlctdp.getMaxX(), true, tg, tcp.tmlctdp);
+                                    destPort.isOrigin = false;
+                                    destPort.commName = newChan.getName();
+                                    tcp.tmlctdp.addComponent(destPort, tg.getX(), tg.getY(), true, true);
+                                }
+                            }
+                        }
+                        System.out.println("Ports " + originPort + " " + destPort);
+                        TMLCPortConnector conn = new TMLCPortConnector(0, 0, tcp.tmlctdp.getMinX(), tcp.tmlctdp.getMaxX(), tcp.tmlctdp.getMinY(), tcp.tmlctdp.getMaxX(), true, null, tcp.tmlctdp, originPort.getTGConnectingPointAtIndex(0), destPort.getTGConnectingPointAtIndex(0), new Vector<Point>());
+                        tcp.tmlctdp.addComponent(conn, 0, 0, false, true);
+                        
+                        
+                        originPort = new TMLCChannelOutPort(0, 0, tcp.tmlctdp.getMinX(), tcp.tmlctdp.getMaxX(), tcp.tmlctdp.getMinY(), tcp.tmlctdp.getMaxX(), true, null, tcp.tmlctdp);
+						destPort = new TMLCChannelOutPort(0, 0, tcp.tmlctdp.getMinX(), tcp.tmlctdp.getMaxX(), tcp.tmlctdp.getMinY(), tcp.tmlctdp.getMaxX(), true, null, tcp.tmlctdp);
+						
+                        TMLChannel wrChan = outChans.get(chan);
+                        for (TGComponent tg : tcp.tmlctdp.getComponentList()) {
+                            if (tg instanceof TMLCPrimitiveComponent) {
+                                if (tg.getValue().equals(firewallNode.getName())) {
+                                    System.out.println(newChan.getName() + tg.getValue());
+                                    originPort = new TMLCChannelOutPort(tg.getX(), tg.getY(), tcp.tmlctdp.getMinX(), tcp.tmlctdp.getMaxX(), tcp.tmlctdp.getMinY(), tcp.tmlctdp.getMaxX(), true, tg, tcp.tmlctdp);
+                                    originPort.commName = wrChan.getName();
+                                    tcp.tmlctdp.addComponent(originPort, tg.getX(), tg.getY(), true, true);
+                                } else if (tg.getValue().equals(wrChan.getDestinationTask().getName().split("__")[1])) {
+                                    System.out.println(wrChan.getName() + " "+ tg.getValue());
+                                    destPort = new TMLCChannelOutPort(tg.getX(), tg.getY(), tcp.tmlctdp.getMinX(), tcp.tmlctdp.getMaxX(), tcp.tmlctdp.getMinY(), tcp.tmlctdp.getMaxX(), true, tg, tcp.tmlctdp);
+                                    destPort.isOrigin = false;
+                                    destPort.commName = wrChan.getName();
+                                    tcp.tmlctdp.addComponent(destPort, tg.getX(), tg.getY(), true, true);
+                                }
+                            }
+                        }
+                        
+                        System.out.println("Ports " + originPort + " " + destPort);
+                        conn = new TMLCPortConnector(0, 0, tcp.tmlctdp.getMinX(), tcp.tmlctdp.getMaxX(), tcp.tmlctdp.getMinY(), tcp.tmlctdp.getMaxX(), true, null, tcp.tmlctdp, originPort.getTGConnectingPointAtIndex(0), destPort.getTGConnectingPointAtIndex(0), new Vector<Point>());
+                        tcp.tmlctdp.addComponent(conn, 0, 0, false, true);
+                        
+                    }
+                    int xpos = 200;
+                    int i = 1;
+                    for (TMLChannel chan : inChans.keySet()) {
+                    	if (i>3){
+                    		break;
+                    	}
+                        TMLChannel newChan = inChans.get(chan);
+                        adRC = new TMLADReadChannel(xpos, 350, firewallADP.getMinX(), firewallADP.getMaxX(), firewallADP.getMinY(), firewallADP.getMaxY(), false, null, firewallADP);
+                        adRC.setChannelName(newChan.getName());
+                        adRC.setSamples("1");
+
+                        tmp = new TGConnectorTMLAD(adRC.getX(), adRC.getY(), firewallADP.getMinX(), firewallADP.getMaxX(), firewallADP.getMinY(), firewallADP.getMaxY(), false, null, firewallADP, adChoice.getTGConnectingPointAtIndex(i), adRC.getTGConnectingPointAtIndex(0), new Vector<Point>());
+                        firewallADP.addComponent(tmp, adRC.getX(), adRC.getY(), false, true);
+
+                        firewallADP.addComponent(adRC, xpos, 350, false, true);
+
+                        //Execute for latency value
+                        exec = new TMLADExecI(xpos, 400, firewallADP.getMinX(), firewallADP.getMaxX(), firewallADP.getMinY(), firewallADP.getMaxY(), false, null, firewallADP);
+
+                        exec.setDelayValue(Integer.toString(firewallNode.latency));
+                        firewallADP.addComponent(exec, xpos, 400, false, true);
+
+                        tmp = new TGConnectorTMLAD(exec.getX(), exec.getY(), firewallADP.getMinX(), firewallADP.getMaxX(), firewallADP.getMinY(), firewallADP.getMaxY(), false, null, firewallADP, adRC.getTGConnectingPointAtIndex(1), exec.getTGConnectingPointAtIndex(0), new Vector<Point>());
+                        firewallADP.addComponent(tmp, exec.getX(), exec.getY(), false, true);
+                        
+                        
+                        
+
+						adChoice2 = new TMLADChoice(xpos, 500, firewallADP.getMinX(), firewallADP.getMaxX(), firewallADP.getMinY(), firewallADP.getMaxY(), false, null, firewallADP);
+		                firewallADP.addComponent(adChoice2, 500, 300, false, true);
+
+						tmp = new TGConnectorTMLAD(exec.getX(), exec.getY(), firewallADP.getMinX(), firewallADP.getMaxX(), firewallADP.getMinY(), firewallADP.getMaxY(), false, null, firewallADP, exec.getTGConnectingPointAtIndex(1), adChoice2.getTGConnectingPointAtIndex(0), new Vector<Point>());
+                        firewallADP.addComponent(tmp, exec.getX(), exec.getY(), false, true);
+
+
+  //                      if (channelAllowed(map, chan)) {
+                            TMLChannel wrChan = outChans.get(chan);
+
+                            adWC = new TMLADWriteChannel(xpos, 600, firewallADP.getMinX(), firewallADP.getMaxX(), firewallADP.getMinY(), firewallADP.getMaxY(), false, null, firewallADP);
+                            adWC.setChannelName(wrChan.getName());
+                            adWC.setSamples("1");                                              
+                            firewallADP.addComponent(adWC, xpos, 600, false, true);
+
+
+                            tmp = new TGConnectorTMLAD(exec.getX(), exec.getY(), firewallADP.getMinX(), firewallADP.getMaxX(), firewallADP.getMinY(), firewallADP.getMaxY(), false, null, firewallADP, adChoice2.getTGConnectingPointAtIndex(1), adWC.getTGConnectingPointAtIndex(0), new Vector<Point>());
+                            firewallADP.addComponent(tmp, exec.getX(), exec.getY(), false, true);
+
+                            adStop = new TMLADStopState(xpos, 650, firewallADP.getMinX(), firewallADP.getMaxX(), firewallADP.getMinY(), firewallADP.getMaxY(), false, null, firewallADP);
+                            firewallADP.addComponent(adStop, xpos, 650, false, true);
+                            tmp = new TGConnectorTMLAD(adStop.getX(), adStop.getY(), firewallADP.getMinX(), firewallADP.getMaxX(), firewallADP.getMinY(), firewallADP.getMaxY(), false, null, firewallADP, adWC.getTGConnectingPointAtIndex(1), adStop.getTGConnectingPointAtIndex(0), new Vector<Point>());
+                            firewallADP.addComponent(tmp, adStop.getX(), adStop.getY(), false, true);
+                    //    } else {
+                            adStop2 = new TMLADStopState(xpos, 650, firewallADP.getMinX(), firewallADP.getMaxX(), firewallADP.getMinY(), firewallADP.getMaxY(), false, null, firewallADP);
+                            firewallADP.addComponent(adStop2, xpos, 650, false, true);
+
+                            tmp = new TGConnectorTMLAD(adStop.getX(), adStop.getY(), firewallADP.getMinX(), firewallADP.getMaxX(), firewallADP.getMinY(), firewallADP.getMaxY(), false, null, firewallADP, adChoice2.getTGConnectingPointAtIndex(2), adStop2.getTGConnectingPointAtIndex(0), new Vector<Point>());
+                            firewallADP.addComponent(tmp, adStop.getX(), adStop.getY(), false, true);
+                     //   }
+                        xpos += 100;
+                        i++;
+                    }
+               // }
+
+                TMLStartState start = new TMLStartState("start", adStart);
+                act.setFirst(start);
+                map.getCorrespondanceList().addCor(start, adStart);
+
+                //Add infinite loop
+
+                TMLForLoop loop = new TMLForLoop("infiniteloop", adLoop);
+                loop.setInit("");
+                loop.setCondition("");
+                loop.setIncrement("");
+                loop.setInfinite(true);
+                start.addNext(loop);
+                act.addElement(loop);
+                //Add choice
+
+                TMLChoice choice = new TMLChoice("chooseChannel", adChoice);
+                act.addElement(choice);
+                loop.addNext(choice);
+                map.getCorrespondanceList().addCor(choice, adChoice);
+
+
+                for (TMLChannel chan : inChans.keySet()) {
+                    TMLChannel newChan = inChans.get(chan);
+                    TMLChannel wrChan = outChans.get(chan);
+                    //Add channels into firewall activity diagram
+                    TMLReadChannel rd = new TMLReadChannel(newChan.getName(), adRC);
+                    rd.setNbOfSamples("1");
+                    rd.addChannel(newChan);
+                    choice.addNext(rd);
+                    choice.addGuard("");
+
+                    act.addElement(rd);
+
+                    //Execute for latency value
+
+                    TMLExecI ex = new TMLExecI("execi", exec);
+                    ex.setAction(Integer.toString(firewallNode.latency));
+                    act.addElement(ex);
+                    rd.addNext(ex);
+
+                    if (channelAllowed(map, chan)) {
+
+                        TMLWriteChannel wr = new TMLWriteChannel(wrChan.getName(), adWC);
+                        wr.setNbOfSamples("1");
+                        wr.addChannel(wrChan);
+                        ex.addNext(wr);
+                        act.addElement(wr);
+
+                        TMLStopState stop = new TMLStopState("stop", adStop);
+                        wr.addNext(stop);
+                        act.addElement(stop);
+
+                    } else {
+                        TMLStopState stop = new TMLStopState("stop", adStop);
+                        ex.addNext(stop);
+                        act.addElement(stop);
+                    }
+                    for (TMLTask t : tmlm.getTasks()) {
+                        TMLActivity actd = t.getActivityDiagram();
+                        actd.replaceWriteChannelWith(chan, newChan);
+                        actd.replaceReadChannelWith(chan, outChans.get(chan));
+                    }
+                }
+
+            }
+
+        }
+        //Redo all reference objects
+
+        map.getCorrespondanceList().useDIPLOIDs();
+        return map;
+    }
+
+    class ChannelData {
+        public String name;
+        public boolean isOrigin;
+        public boolean isChan;
+
+        public ChannelData(String n, boolean orig, boolean isCh) {
+            name = n;
+            isOrigin = orig;
+            isChan = isCh;
+        }
+
+    }
+
+    class HSMChannel {
+        public String name;
+        public static final int SENC = 0;
+        public static final int NONCE_ENC = 1;
+        public static final int MAC = 2;
+        public static final int DEC = 3;
+        public static final int AENC = 4;
+        public static final int NONCE = 5;
+        public String task;
+        public String securityContext = "";
+        public int secType;
+        public String nonceName = "";
+
+        public HSMChannel(String n, String t, int type) {
+            name = n;
+            task = t;
+            secType = type;
+        }
+    }
+
+    public HashMap<String, HashSet<String>> getCPUTaskMap() {
+        HashMap<String, HashSet<String>> cpuTaskMap = new HashMap<String, HashSet<String>>();
+        if (tmap == null) {
+            return cpuTaskMap;
+        }
+
+        for (HwNode node : tmap.getArch().getCPUs()) {
+            if (tmap.getMappedTasks(node).size() > 0) {
+                cpuTaskMap.put(node.getName(), tmap.getMappedTasks(node));
+            }
+        }
+
+        return cpuTaskMap;
+    }
+
+    public void addHSM(MainGUI gui, Map<String, List<String>> selectedCpuTasks) {
+        System.out.println("Adding HSM");
+        String encComp = "100";
+        String decComp = "100";
+        String overhead = "0";
+        String name = "hsm";
+        if (tmap == null) {
+            return;
+        }
+        //Clone diagrams
+        TURTLEPanel tmlap = tmap.getCorrespondanceList().getTG(tmap.getArch().getFirstCPU()).getTDiagramPanel().tp;
+        int arch = gui.tabs.indexOf(tmlap);
+        gui.cloneRenameTab(arch, "hsm");
+        TMLArchiPanel newarch = (TMLArchiPanel) gui.tabs.get(gui.tabs.size() - 1);
+
+        TGComponent tgcomp = tmap.getTMLModeling().getTGComponent();
+        TMLComponentDesignPanel tmlcdp = (TMLComponentDesignPanel) tgcomp.getTDiagramPanel().tp;
+
+//        TMLComponentDesignPanel tmlcdp = tmap.getTMLCDesignPanel();
+        int ind = gui.tabs.indexOf(tmlcdp);
+        String tabName = gui.getTitleAt(tmlcdp);
+        gui.cloneRenameTab(ind, name);
+        TMLComponentDesignPanel t = (TMLComponentDesignPanel) gui.tabs.get(gui.tabs.size() - 1);
+        TMLComponentTaskDiagramPanel tcdp = t.tmlctdp;
+        //Create clone of architecture panel and map tasks to it
+        newarch.renameMapping(tabName, tabName + "_" + name);
+
+
+        //ProVerif analysis
+        List<String> nonAuthChans = new ArrayList<String>();
+        List<String> nonSecChans = new ArrayList<String>();
+
+        proverifAnalysis(tmap, nonAuthChans, nonSecChans);
+
+        TGConnector fromStart;
+        Map<String, HSMChannel> secChannels = new HashMap<String, HSMChannel>();
+        //Add a HSM for each selected CPU on the component diagram
+        for (String cpuName : selectedCpuTasks.keySet()) {
+            Map<String, HSMChannel> hsmChannels = new HashMap<String, HSMChannel>();
+            TMLCPrimitiveComponent hsm = new TMLCPrimitiveComponent(0, 500, tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxY(), false, null, tcdp);
+            //TAttribute isEnc = new TAttribute(2, "isEnc", "true", 4);
+            //hsm.getAttributeList().add(isEnc);
+            tcdp.addComponent(hsm, 0, 500, false, true);
+            hsm.setValueWithChange("HSM_" + cpuName);
+            //Find all associated components
+            List<TMLCPrimitiveComponent> comps = new ArrayList<TMLCPrimitiveComponent>();
+            //Find the component to add a HSM to
+
+            for (TGComponent tg : tcdp.getComponentList()) {
+                if (tg instanceof TMLCPrimitiveComponent) {
+                    for (String compName : selectedCpuTasks.get(cpuName)) {
+                        if (tg.getValue().equals(compName)) {
+                            comps.add((TMLCPrimitiveComponent) tg);
+                            break;
+                        }
+                    }
+                } else if (tg instanceof TMLCCompositeComponent) {
+                    TMLCCompositeComponent cc = (TMLCCompositeComponent) tg;
+                    List<TMLCPrimitiveComponent> pcomps = cc.getAllPrimitiveComponents();
+                    for (TMLCPrimitiveComponent pc : pcomps) {
+                        for (String compName : selectedCpuTasks.get(cpuName)) {
+                            if (pc.getValue().equals(compName)) {
+                                comps.add(pc);
+                                break;
+                            }
+                        }
+                    }
+                }
+            }
+            if (comps.size() == 0) {
+                //System.out.println("No Components found");
+                continue;
+            }
+            //  System.out.println("nonAuthChans " + nonAuthChans);
+            //System.out.println("nonSecChans "+ nonSecChans);
+            for (TMLCPrimitiveComponent comp : comps) {
+
+                Map<String, HSMChannel> compChannels = new HashMap<String, HSMChannel>();
+                String compName = comp.getValue();
+                TMLActivityDiagramPanel tad = t.getTMLActivityDiagramPanel(compName);
+                Set<TGComponent> channelInstances = new HashSet<TGComponent>();
+                Set<TGComponent> secOperators = new HashSet<TGComponent>();
+              //  isEnc = new TAttribute(2, "isEnc", "true", 4);
+                //comp.getAttributeList().add(isEnc);
+                //Find all unsecured channels
+                //For previously secured channels, relocate encryption to the hsm
+
+                for (TGComponent tg : tad.getComponentList()) {
+                    if (tg instanceof TMLADWriteChannel) {
+                        TMLADWriteChannel writeChannel = (TMLADWriteChannel) tg;
+                        if (writeChannel.getSecurityContext().equals("")) {
+                            String nonceName = "";
+                            int type = -1;
+                            if (nonSecChans.contains(compName + "__" + writeChannel.getChannelName() + "_chData")) {
+                                type = HSMChannel.SENC;
+                                if (nonAuthChans.contains(compName + "__" + writeChannel.getChannelName())) {
+                                    nonceName = "nonce_" + writeChannel.getChannelName();
+                                }
+                            } else if (nonAuthChans.contains(compName + "__" + writeChannel.getChannelName())) {
+                                type = HSMChannel.MAC;
+                            }
+                            HSMChannel ch = new HSMChannel(writeChannel.getChannelName(), compName, type);
+                            ch.securityContext = "hsmSec_" + writeChannel.getChannelName();
+                            ch.nonceName = nonceName;
+                            fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0));
+                            if (fromStart != null) {
+                                if (type != -1) {
+                                    compChannels.put(writeChannel.getChannelName(), ch);
+                                    channelInstances.add(tg);
+                                }
+                            }
+                        } else {
+                            //System.out.println("security context:"+writeChannel.securityContext);
+                            fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0));
+                            if (fromStart != null) {
+                                channelInstances.add(tg);
+                                SecurityPattern sp = tmap.getSecurityPatternByName(writeChannel.getSecurityContext());
+                                int type = -1;
+                                if (sp.type.equals("Symmetric Encryption")) {
+                                    type = HSMChannel.SENC;
+                                } else if (sp.type.equals("Asymmetric Encryption")) {
+                                    type = HSMChannel.AENC;
+                                } else if (sp.type.equals("MAC")) {
+                                    type = HSMChannel.MAC;
+                                } else if (sp.type.equals("Nonce")) {
+                                    type = HSMChannel.NONCE;
+                                }
+                                HSMChannel ch = new HSMChannel(writeChannel.getChannelName(), compName, type);
+                                ch.securityContext = writeChannel.getSecurityContext();
+                                compChannels.put(writeChannel.getChannelName(), ch);
+                                //chanNames.add(writeChannel.getChannelName()+compName);
+                            }
+                        }
+                    }
+                    if (tg instanceof TMLADReadChannel) {
+                        TMLADReadChannel readChannel = (TMLADReadChannel) tg;
+                        if (readChannel.getSecurityContext().equals("")) {
+                            fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0));
+                            if (fromStart != null) {
+                                if (nonSecChans.contains(compName + "__" + readChannel.getChannelName() + "_chData") || nonAuthChans.contains(compName + "__" + readChannel.getChannelName())) {
+                                    channelInstances.add(tg);
+                                    HSMChannel ch = new HSMChannel(readChannel.getChannelName(), compName, HSMChannel.DEC);
+                                    ch.securityContext = "hsmSec_" + readChannel.getChannelName();
+                                    compChannels.put(readChannel.getChannelName(), ch);
+                                    if (nonSecChans.contains(compName + "__" + readChannel.getChannelName() + "_chData") && nonAuthChans.contains(compName + "__" + readChannel.getChannelName())) {
+                                        ch.nonceName = "nonce_" + readChannel.getChannelName();
+                                    }
+                                }
+                            }
+                        } else {
+                            fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0));
+                            if (fromStart != null) {
+                                channelInstances.add(tg);
+                                HSMChannel ch = new HSMChannel(readChannel.getChannelName(), compName, HSMChannel.DEC);
+                                ch.securityContext = readChannel.getSecurityContext();
+                                compChannels.put(readChannel.getChannelName(), ch);
+                            }
+                        }
+                    }
+                    if (tg instanceof TMLADEncrypt) {
+                        //      TMLADEncrypt enc = (TMLADEncrypt) tg;
+                        secOperators.add(tg);
+                        //}
+                    }
+                    if (tg instanceof TMLADDecrypt) {
+                        //      TMLADDecrypt dec = (TMLADDecrypt) tg;
+                        secOperators.add(tg);
+                        //}
+                    }
+                }
+                //System.out.println("compchannels " +compChannels);
+                List<ChannelData> hsmChans = new ArrayList<ChannelData>();
+                ChannelData chd = new ChannelData("startHSM_" + cpuName, false, false);
+                hsmChans.add(chd);
+                for (String s : compChannels.keySet()) {
+                    hsmChannels.put(s, compChannels.get(s));
+                    chd = new ChannelData("data_" + s + "_" + compChannels.get(s).task, false, true);
+                    hsmChans.add(chd);
+                    chd = new ChannelData("retData_" + s + "_" + compChannels.get(s).task, true, true);
+                    hsmChans.add(chd);
+                }
+                for (ChannelData hsmChan : hsmChans) {
+                    TMLCChannelOutPort originPort = new TMLCChannelOutPort(comp.getX(), comp.getY(), tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, hsm, tcdp);
+                    TMLCChannelOutPort destPort = new TMLCChannelOutPort(comp.getX(), comp.getY(), tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, comp, tcdp);
+                    originPort.commName = hsmChan.name;
+                    originPort.isOrigin = hsmChan.isOrigin;
+                    tcdp.addComponent(originPort, hsm.getX(), hsm.getY(), true, true);
+                    destPort.commName = hsmChan.name;
+                    if (!hsmChan.isChan) {
+                        originPort.typep = 2;
+                        destPort.typep = 2;
+                    //    originPort.setParam(0, new TType(2));
+                    }
+                    destPort.isOrigin = !hsmChan.isOrigin;
+
+                    tcdp.addComponent(destPort, comp.getX(), comp.getY(), true, true);
+
+                    TMLCPortConnector conn = new TMLCPortConnector(0, 0, tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, null, tcdp, originPort.getTGConnectingPointAtIndex(0), destPort.getTGConnectingPointAtIndex(0), new Vector<Point>());
+                    tcdp.addComponent(conn, 0, 0, false, true);
+                }
+                int xpos = 0;
+                int ypos = 0;
+
+                //Remove existing security elements
+                for (TGComponent op : secOperators) {
+                    TGConnector prev = tad.findTGConnectorEndingAt(op.getTGConnectingPointAtIndex(0));
+                    //TGConnectingPoint point = prev.getTGConnectingPointP1();
+                    TGConnector end = tad.findTGConnectorStartingAt(op.getTGConnectingPointAtIndex(1));
+                    TGConnectingPoint point2 = end.getTGConnectingPointP2();
+                    tad.removeComponent(op);
+                    tad.removeComponent(end);
+                    tad.addComponent(prev, 0, 0, false, true);
+                    prev.setP2(point2);
+                }
+
+                //Modify component activity diagram to add read/write to HSM
+
+                //Add actions before Write Channel
+                for (TGComponent chan : channelInstances) {
+                    String chanName = "";
+                    if (!(chan instanceof TMLADWriteChannel)) {
+                        continue;
+                    }
+                    TMLADWriteChannel writeChannel = (TMLADWriteChannel) chan;
+                    chanName = writeChannel.getChannelName();
+                    HSMChannel ch = hsmChannels.get(chanName);
+                    writeChannel.setSecurityContext(ch.securityContext);
+                    xpos = chan.getX();
+                    ypos = chan.getY();
+                    fromStart = tad.findTGConnectorEndingAt(chan.getTGConnectingPointAtIndex(0));
+                    TGConnectingPoint point = fromStart.getTGConnectingPointP2();
+
+                    int yShift = 50;
+
+                    TMLADSendRequest req = new TMLADSendRequest(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                    req.setRequestName("startHSM_" + cpuName);
+                   // req.setParam(0, "isEnc");
+                    tad.addComponent(req, xpos, ypos + yShift, false, true);
+
+                    fromStart.setP2(req.getTGConnectingPointAtIndex(0));
+                    tad.addComponent(fromStart, xpos, ypos, false, true);
+
+                    //Add connection
+                    fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                    fromStart.setP1(req.getTGConnectingPointAtIndex(1));
+                    TMLADWriteChannel wr = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+
+                    yShift += 50;
+                    //Add write channel operator
+                    wr = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                    wr.setChannelName("data_" + chanName + "_" + compName);
+                    wr.setSecurityContext(ch.securityContext);
+                    tad.addComponent(wr, xpos, ypos + yShift, false, true);
+
+
+                    fromStart.setP2(wr.getTGConnectingPointAtIndex(0));
+                    tad.addComponent(fromStart, xpos, ypos, false, true);
+
+                    fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                    tad.addComponent(fromStart, xpos, ypos, false, true);
+                    fromStart.setP1(wr.getTGConnectingPointAtIndex(1));
+
+
+                    //Add read channel operator
+
+                    yShift += 60;
+                    TMLADReadChannel rd = new TMLADReadChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                    rd.setChannelName("retData_" + chanName + "_" + compName);
+                    rd.setSecurityContext(ch.securityContext);
+                    tad.addComponent(rd, xpos, ypos + yShift, false, true);
+
+                    fromStart.setP2(rd.getTGConnectingPointAtIndex(0));
+                    yShift += 50;
+
+                    //Add connector
+                    fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                    tad.addComponent(fromStart, xpos, ypos, false, true);
+                    fromStart.setP1(rd.getTGConnectingPointAtIndex(1));
+                    yShift += 50;
+
+                    //Direct the last TGConnector back to the start of the write channel operator
+
+
+                    fromStart.setP2(point);
+                    //Shift components down to make room for the added ones, and add security contexts to write channels
+                    for (TGComponent tg : tad.getComponentList()) {
+                        if (tg.getY() >= ypos && tg != wr && tg != req && tg != rd) {
+                            tg.setCd(tg.getX(), tg.getY() + yShift);
+                        }
+                    }
+                    tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift);
+                    tad.repaint();
+
+                }
+                //Add actions after Read Channel
+                for (TGComponent chan : channelInstances) {
+                    String chanName = "";
+                    if (!(chan instanceof TMLADReadChannel)) {
+                        continue;
+                    }
+                    TMLADReadChannel readChannel = (TMLADReadChannel) chan;
+                    chanName = readChannel.getChannelName();
+                    HSMChannel ch = hsmChannels.get(chanName);
+                    readChannel.setSecurityContext(ch.securityContext);
+                    xpos = chan.getX() + 10;
+                    ypos = chan.getY();
+                    fromStart = tad.findTGConnectorStartingAt(chan.getTGConnectingPointAtIndex(1));
+                    if (fromStart == null) {
+                        fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                        fromStart.setP1(chan.getTGConnectingPointAtIndex(1));
+                        tad.addComponent(fromStart, xpos, ypos, false, true);
+                    }
+                    TGConnectingPoint point = fromStart.getTGConnectingPointP2();
+
+                    //Set isEnc to false
+                    int yShift = 50;
+              //      TMLADActionState act = new TMLADActionState(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                //    act.setValue("isEnc=false");
+                  //  tad.addComponent(act, xpos, ypos + yShift, false, true);
+                    //fromStart.setP2(act.getTGConnectingPointAtIndex(0));
+
+
+                    //Add send request operator
+
+                    yShift += 50;
+                    TMLADSendRequest req = new TMLADSendRequest(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                    req.setRequestName("startHSM_" + cpuName);
+                  //  req.setParam(0, "isEnc");
+                    req.makeValue();
+                    tad.addComponent(req, xpos, ypos + yShift, false, true);
+
+
+                    //Add connection
+                   // fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                  //  fromStart.setP1(act.getTGConnectingPointAtIndex(1));
+                    fromStart.setP2(req.getTGConnectingPointAtIndex(0));
+                  //  tad.addComponent(fromStart, xpos, ypos, false, true);
+
+
+                    yShift += 50;
+                    //Add write channel operator
+                    TMLADWriteChannel wr = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                    wr.setChannelName("data_" + chanName + "_" + compName);
+                    wr.setSecurityContext(ch.securityContext);
+                    tad.addComponent(wr, xpos, ypos + yShift, false, true);
+
+
+                    //Add connection
+                    fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                    fromStart.setP1(req.getTGConnectingPointAtIndex(1));
+                    fromStart.setP2(wr.getTGConnectingPointAtIndex(0));
+                    tad.addComponent(fromStart, xpos, ypos, false, true);
+
+                    //Add read channel operator
+
+                    yShift += 60;
+                    TMLADReadChannel rd = new TMLADReadChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                    rd.setChannelName("retData_" + chanName + "_" + compName);
+                    rd.setSecurityContext(ch.securityContext);
+                    tad.addComponent(rd, xpos, ypos + yShift, false, true);
+
+                    fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                    tad.addComponent(fromStart, xpos, ypos, false, true);
+                    fromStart.setP1(wr.getTGConnectingPointAtIndex(1));
+                    fromStart.setP2(rd.getTGConnectingPointAtIndex(0));
+                    yShift += 50;
+
+                    if (point != null) {
+                        fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                        tad.addComponent(fromStart, xpos, ypos, false, true);
+                        fromStart.setP1(rd.getTGConnectingPointAtIndex(1));
+                        //Direct the last TGConnector back to the start of the write channel operator
+
+                        fromStart.setP2(point);
+                    }
+                    yShift += 50;
+
+                    //Shift components down to make room for the added ones, and add security contexts to write channels
+                    for (TGComponent tg : tad.getComponentList()) {
+                        if (tg.getY() >= ypos && tg != wr && tg != req && tg != rd && tg != chan) {
+                            tg.setCd(tg.getX(), tg.getY() + yShift);
+                        }
+                    }
+                    tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift);
+                    tad.repaint();
+                }
+                //for (String chan: chanNames){
+                //                        hsmChannels.put(chan, compName);
+                //}
+            }
+
+            int xpos = 0;
+            int ypos = 0;
+
+
+            //Build HSM Activity diagram
+
+            TMLActivityDiagramPanel tad = t.getTMLActivityDiagramPanel("HSM_" + cpuName);
+
+            TMLADStartState start = (TMLADStartState) tad.getComponentList().get(0);
+            fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+
+
+/*            TMLADReadRequestArg req = new TMLADReadRequestArg(300, 100, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+            tad.addComponent(req, 300, 100, false, true);
+            req.setParam(0, "isEnc");
+            req.makeValue();
+
+            //Connect start and readrequest
+            fromStart.setP1(start.getTGConnectingPointAtIndex(0));
+            fromStart.setP2(req.getTGConnectingPointAtIndex(0));
+            tad.addComponent(fromStart, 300, 200, false, true);
+
+*/
+            TMLADChoice choice = new TMLADChoice(300, 200, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+            tad.addComponent(choice, 300, 200, false, true);
+
+
+            //Connect readrequest and choice
+            fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+            fromStart.setP1(start.getTGConnectingPointAtIndex(0));
+            fromStart.setP2(choice.getTGConnectingPointAtIndex(0));
+            tad.addComponent(fromStart, 300, 200, false, true);
+
+
+            int xc = 150;
+            //Allows 9 channels max to simplify the diagram
+
+            //If more than 3 channels, build 2 levels of choices
+            TMLADChoice choice2 = new TMLADChoice(xc, 400, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+            if (hsmChannels.keySet().size() > 3) {
+                int i = 0;
+                for (String chan : hsmChannels.keySet()) {
+                    HSMChannel ch = hsmChannels.get(chan);
+                    if (i % 3 == 0) {
+                        //Add a new choice every third channel
+                        choice2 = new TMLADChoice(xc, 250, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                        tad.addComponent(choice2, xc, 400, false, true);
+                        //Connect new choice operator to top choice
+                        fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                        fromStart.setP1(choice.getTGConnectingPointAtIndex(i / 3 + 1));
+                        fromStart.setP2(choice2.getTGConnectingPointAtIndex(0));
+                        tad.addComponent(fromStart, 300, 200, false, true);
+                    }
+                    TMLADReadChannel rd = new TMLADReadChannel(xc, 300, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                    rd.setChannelName("data_" + chan + "_" + hsmChannels.get(chan).task);
+                    rd.setSecurityContext(ch.securityContext);
+                    tad.addComponent(rd, xc, 300, false, true);
+                    //Connect choice and readchannel
+                    fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                    fromStart.setP1(choice2.getTGConnectingPointAtIndex(i % 3 + 1));
+                    fromStart.setP2(rd.getTGConnectingPointAtIndex(0));
+
+                    tad.addComponent(fromStart, 300, 200, false, true);
+                    TMLADWriteChannel wr = new TMLADWriteChannel(xc, 600, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                    wr.setChannelName("retData_" + chan + "_" + hsmChannels.get(chan).task);
+                    tad.addComponent(wr, xc, 600, false, true);
+                    wr.setSecurityContext(ch.securityContext);
+
+
+                    if (hsmChannels.get(chan).secType == HSMChannel.DEC) {
+                        TMLADDecrypt dec = new TMLADDecrypt(xc, 500, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                        dec.securityContext = ch.securityContext;
+                        tad.addComponent(dec, xc, 500, false, true);
+                        fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                        fromStart.setP1(rd.getTGConnectingPointAtIndex(1));
+                        fromStart.setP2(dec.getTGConnectingPointAtIndex(0));
+                        tad.addComponent(fromStart, 300, 200, false, true);
+
+                        fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                        fromStart.setP1(rd.getTGConnectingPointAtIndex(1));
+                        fromStart.setP2(dec.getTGConnectingPointAtIndex(0));
+                        tad.addComponent(fromStart, 300, 200, false, true);
+
+                        //Connect encrypt and writechannel
+                        fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                        fromStart.setP1(dec.getTGConnectingPointAtIndex(1));
+                        fromStart.setP2(wr.getTGConnectingPointAtIndex(0));
+                        tad.addComponent(fromStart, 300, 200, false, true);
+                    } else {
+                        TMLADEncrypt enc = new TMLADEncrypt(xc, 500, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                        enc.securityContext = ch.securityContext;
+                        if (hsmChannels.get(chan).secType == HSMChannel.SENC) {
+                            enc.type = "Symmetric Encryption";
+                        } else if (hsmChannels.get(chan).secType == HSMChannel.AENC) {
+                            enc.type = "Asymmetric Encryption";
+                        } else if (hsmChannels.get(chan).secType == HSMChannel.MAC) {
+                            enc.type = "MAC";
+                        } else if (hsmChannels.get(chan).secType == HSMChannel.NONCE) {
+                            enc.type = "Nonce";
+                        }
+
+                        enc.message_overhead = overhead;
+                        enc.encTime = encComp;
+                        enc.decTime = decComp;
+                        enc.nonce = hsmChannels.get(chan).nonceName;
+                        tad.addComponent(enc, xc, 500, false, true);
+
+                        //Connect encrypt and readchannel
+                        fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                        fromStart.setP1(rd.getTGConnectingPointAtIndex(1));
+                        fromStart.setP2(enc.getTGConnectingPointAtIndex(0));
+                        tad.addComponent(fromStart, 300, 200, false, true);
+
+                        //Connect encrypt and writechannel
+                        fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                        fromStart.setP1(enc.getTGConnectingPointAtIndex(1));
+                        fromStart.setP2(wr.getTGConnectingPointAtIndex(0));
+                        tad.addComponent(fromStart, 300, 200, false, true);
+                        
+                        //Add Stop
+                        TMLADStopState stop = new TMLADStopState(xc, 600, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                        tad.addComponent(stop, xc, 700, false, true);
+
+
+						//Connext stop and write channel
+                        fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                        fromStart.setP1(wr.getTGConnectingPointAtIndex(1));
+                        fromStart.setP2(stop.getTGConnectingPointAtIndex(0));
+                        tad.addComponent(fromStart, 300, 200, false, true);
+
+                    }
+                    xc += 300;
+                    i++;
+                }
+            } else {
+
+                int i = 1;
+
+                for (String chan : hsmChannels.keySet()) {
+                    HSMChannel ch = hsmChannels.get(chan);
+                    TMLADReadChannel rd = new TMLADReadChannel(xc, 300, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                    rd.setChannelName("data_" + chan + "_" + hsmChannels.get(chan).task);
+                    rd.setSecurityContext(ch.securityContext);
+                    tad.addComponent(rd, xc, 300, false, true);
+                    //Connect choice and readchannel
+
+                    fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                    fromStart.setP1(choice.getTGConnectingPointAtIndex(i));
+                    fromStart.setP2(rd.getTGConnectingPointAtIndex(0));
+
+                    tad.addComponent(fromStart, 300, 200, false, true);
+
+                    TMLADWriteChannel wr = new TMLADWriteChannel(xc, 600, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                    wr.setChannelName("retData_" + chan + "_" + hsmChannels.get(chan).task);
+                    tad.addComponent(wr, xc, 600, false, true);
+                    wr.setSecurityContext(ch.securityContext);
+
+
+                    if (hsmChannels.get(chan).secType == HSMChannel.DEC) {
+                        TMLADDecrypt dec = new TMLADDecrypt(xc, 500, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                        dec.securityContext = ch.securityContext;
+                        tad.addComponent(dec, xc, 500, false, true);
+
+                        fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                        fromStart.setP1(rd.getTGConnectingPointAtIndex(1));
+                        fromStart.setP2(dec.getTGConnectingPointAtIndex(0));
+                        tad.addComponent(fromStart, 300, 200, false, true);
+
+                        //Connect encrypt and writechannel
+                        fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                        fromStart.setP1(dec.getTGConnectingPointAtIndex(1));
+                        fromStart.setP2(wr.getTGConnectingPointAtIndex(0));
+                        tad.addComponent(fromStart, 300, 200, false, true);
+                    } else {
+                        TMLADEncrypt enc = new TMLADEncrypt(xc, 500, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                        enc.securityContext = ch.securityContext;
+                        if (hsmChannels.get(chan).secType == HSMChannel.SENC) {
+                            enc.type = "Symmetric Encryption";
+                        } else if (hsmChannels.get(chan).secType == HSMChannel.AENC) {
+                            enc.type = "Asymmetric Encryption";
+                        } else if (hsmChannels.get(chan).secType == HSMChannel.MAC) {
+                            enc.type = "MAC";
+                        } else if (hsmChannels.get(chan).secType == HSMChannel.NONCE) {
+                            enc.type = "Nonce";
+                        }
+
+                        enc.message_overhead = overhead;
+                        enc.encTime = encComp;
+                        enc.decTime = decComp;
+                        tad.addComponent(enc, xc, 500, false, true);
+
+                        //Connect encrypt and readchannel
+                        fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                        fromStart.setP1(rd.getTGConnectingPointAtIndex(1));
+                        fromStart.setP2(enc.getTGConnectingPointAtIndex(0));
+                        tad.addComponent(fromStart, 300, 200, false, true);
+
+                        //Connect encrypt and writechannel
+                        fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                        fromStart.setP1(enc.getTGConnectingPointAtIndex(1));
+                        fromStart.setP2(wr.getTGConnectingPointAtIndex(0));
+                        tad.addComponent(fromStart, 300, 200, false, true);
+                        
+                        //Add Stop
+                        TMLADStopState stop = new TMLADStopState(xc, 600, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                        tad.addComponent(stop, xc, 700, false, true);
+
+
+						//Connext stop and write channel
+                        fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                        fromStart.setP1(wr.getTGConnectingPointAtIndex(1));
+                        fromStart.setP2(stop.getTGConnectingPointAtIndex(0));
+                        tad.addComponent(fromStart, 300, 200, false, true);
+
+
+                    }
+
+
+                    /*MLADChoice choice2 = new TMLADChoice(xc, 400, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                      tad.addComponent(choice2, xc, 400,false,true);
+                      choice2.setGuard("[isEnc]", 0);
+                      choice2.setGuard("[else]",1);
+
+                      //connect readchannel and choice 2
+                      fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+                      fromStart.setP1(rd.getTGConnectingPointAtIndex(1));
+                      fromStart.setP2(choice2.getTGConnectingPointAtIndex(0));
+                      tad.addComponent(fromStart, 300,200,false,true);
+
+                      TMLADEncrypt enc = new TMLADEncrypt(xc-75, 500, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                      enc.securityContext = "hsmSec_"+chan;
+                      enc.type = "Symmetric Encryption";
+                      enc.message_overhead = overhead;
+                      enc.encTime= encComp;
+                      enc.decTime=decComp;
+                      tad.addComponent(enc, xc-75, 500,false,true);
+
+                      //Connect choice 2 and encrypt
+                      fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+                      fromStart.setP1(choice2.getTGConnectingPointAtIndex(1));
+                      fromStart.setP2(enc.getTGConnectingPointAtIndex(0));
+                      tad.addComponent(fromStart, 300,200,false,true);
+
+                      TMLADWriteChannel wr = new TMLADWriteChannel(xc-75, 600, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                      wr.setChannelName("retData_"+chan+hsmChannels.get(chan));
+                      tad.addComponent(wr, xc-75, 600,false,true);
+                      wr.securityContext = "hsmSec_"+chan;
+
+                      //Connect encrypt and writeChannel
+                      fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+                      fromStart.setP1(enc.getTGConnectingPointAtIndex(1));
+                      fromStart.setP2(wr.getTGConnectingPointAtIndex(0));
+                      tad.addComponent(fromStart, 300,200,false,true);
+
+
+                      TMLADDecrypt dec = new TMLADDecrypt(xc+75, 500, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                      dec.securityContext = "hsmSec_"+chan;
+                      tad.addComponent(dec, xc+75, 500,false,true);
+
+                      //Connect choice2 and decrypt
+
+                      fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+                      fromStart.setP1(choice2.getTGConnectingPointAtIndex(2));
+                      fromStart.setP2(dec.getTGConnectingPointAtIndex(0));
+                      tad.addComponent(fromStart, 300,200,false,true);
+
+                      TMLADWriteChannel wr2 = new TMLADWriteChannel(xc+75, 600, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                      wr2.setChannelName("retData_"+chan+hsmChannels.get(chan));
+                      wr2.securityContext = "hsmSec_"+chan;
+
+                      //Connect decrypt and writeChannel
+                      fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector());
+                      fromStart.setP1(dec.getTGConnectingPointAtIndex(1));
+                      fromStart.setP2(wr2.getTGConnectingPointAtIndex(0));
+                      tad.addComponent(fromStart, 300,200,false,true);
+                      tad.addComponent(wr2, xc+75, 600,false,true);
+
+                    */
+                    xc += 300;
+                    i++;
+                }
+
+            }
+
+            secChannels.putAll(hsmChannels);
+        }
+        //For all the tasks that receive encrypted data, decrypt it, assuming it has no associated HSM
+        for (TMLTask task : tmap.getTMLModeling().getTasks()) {
+            int xpos, ypos;
+            //System.out.println("loop 2");
+            TMLActivityDiagramPanel tad = t.getTMLActivityDiagramPanel(task.getName());
+            HashSet<TGComponent> channelInstances = new HashSet<TGComponent>();
+            for (String chan : secChannels.keySet()) {
+                HSMChannel ch = secChannels.get(chan);
+                channelInstances.clear();
+                for (TGComponent tg : tad.getComponentList()) {
+                    if (tg instanceof TMLADReadChannel) {
+                        TMLADReadChannel readChannel = (TMLADReadChannel) tg;
+                        if (readChannel.getChannelName().equals(chan) && readChannel.getSecurityContext().equals("")) {
+                            fromStart = tad.findTGConnectorStartingAt(tg.getTGConnectingPointAtIndex(1));
+                            if (fromStart != null) {
+                                channelInstances.add(tg);
+                            }
+                        }
+                    }
+                }
+                for (TGComponent chI : channelInstances) {
+                    TMLADReadChannel readChannel = (TMLADReadChannel) chI;
+                    readChannel.setSecurityContext(ch.securityContext);
+                    xpos = chI.getX();
+                    ypos = chI.getY() + 10;
+                    fromStart = tad.findTGConnectorStartingAt(chI.getTGConnectingPointAtIndex(1));
+                    if (fromStart == null) {
+                        fromStart = new TGConnectorTMLAD(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                        fromStart.setP1(chI.getTGConnectingPointAtIndex(1));
+                        tad.addComponent(fromStart, xpos, ypos, false, true);
+                    }
+                    TGConnectingPoint point = fromStart.getTGConnectingPointP2();
+                    //Add decryption operator
+                    int yShift = 100;
+                    TMLADDecrypt dec = new TMLADDecrypt(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                    dec.securityContext = ch.securityContext;
+                    tad.addComponent(dec, xpos, ypos + yShift, false, true);
+
+
+                    fromStart.setP2(dec.getTGConnectingPointAtIndex(0));
+                    if (point != null) {
+                        fromStart = new TGConnectorTMLAD(dec.getX(), dec.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                        tad.addComponent(fromStart, xpos, ypos, false, true);
+                        fromStart.setP1(dec.getTGConnectingPointAtIndex(1));
+
+                        //Direct the last TGConnector back to the next action
+
+                        fromStart.setP2(point);
+                    }
+                    //Shift components down to make room for the added ones, and add security contexts to write channels
+                    for (TGComponent tg : tad.getComponentList()) {
+                        if (tg.getY() >= ypos && tg != dec) {
+                            tg.setCd(tg.getX(), tg.getY() + yShift);
+                        }
+                    }
+                    tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift);
+                    tad.repaint();
+
+                }
+            }
+            //Next find channels that send encrypted data, and add the encryption operator
+            for (String chan : secChannels.keySet()) {
+                channelInstances.clear();
+                HSMChannel ch = secChannels.get(chan);
+                for (TGComponent tg : tad.getComponentList()) {
+                    if (tg instanceof TMLADWriteChannel) {
+                        TMLADWriteChannel writeChannel = (TMLADWriteChannel) tg;
+                        if (writeChannel.getChannelName().equals(chan) && writeChannel.getSecurityContext().equals("")) {
+                            fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0));
+                            if (fromStart != null) {
+                                channelInstances.add(tg);
+                            }
+                        }
+                    }
+                }
+                for (TGComponent chI : channelInstances) {
+                    TMLADWriteChannel writeChannel = (TMLADWriteChannel) chI;
+                    writeChannel.setSecurityContext(ch.securityContext);
+                    xpos = chI.getX();
+                    ypos = chI.getY() - 10;
+                    fromStart = tad.findTGConnectorEndingAt(chI.getTGConnectingPointAtIndex(0));
+                    TGConnectingPoint point = fromStart.getTGConnectingPointP2();
+                    //Add encryption operator
+                    int yShift = 100;
+
+                    TMLADEncrypt enc = new TMLADEncrypt(xpos, ypos, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                    tad.addComponent(enc, xpos, ypos, false, true);
+                    enc.securityContext = ch.securityContext;
+                    enc.type = "Symmetric Encryption";
+                    enc.message_overhead = overhead;
+                    enc.encTime = encComp;
+                    enc.decTime = decComp;
+                    enc.size = overhead;
+
+
+                    fromStart.setP2(enc.getTGConnectingPointAtIndex(0));
+                    fromStart = new TGConnectorTMLAD(enc.getX(), enc.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                    tad.addComponent(fromStart, xpos, ypos, false, true);
+                    fromStart.setP1(enc.getTGConnectingPointAtIndex(1));
+
+                    //Direct the last TGConnector back to the start of the write channel operator
+
+                    fromStart.setP2(point);
+                    //Shift components down to make room for the added ones, and add security contexts to write channels
+                    for (TGComponent tg : tad.getComponentList()) {
+                        if (tg.getY() >= ypos && tg != enc) {
+                            tg.setCd(tg.getX(), tg.getY() + yShift);
+                        }
+                    }
+                    tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift);
+                    tad.repaint();
+
+                }
+            }
+
+        }
+        for (String cpuName : selectedCpuTasks.keySet()) {
+            //Add a private bus to Hardware Accelerator with the task for hsm
+
+            //Find the CPU the task is mapped to
+            TMLArchiDiagramPanel archPanel = newarch.tmlap;
+            TMLArchiCPUNode cpu = null;
+            String refTask = "";
+            for (TGComponent tg : archPanel.getComponentList()) {
+                if (tg instanceof TMLArchiCPUNode) {
+                    if (tg.getName().equals(cpuName)) {
+                        cpu = (TMLArchiCPUNode) tg;
+                        TMLArchiArtifact art = cpu.getArtifactList().get(0);
+                        refTask = art.getReferenceTaskName();
+                        break;
+
+                    }
+                }
+            }
+
+            if (cpu == null) {
+                return;
+            }
+
+            //Add new memory
+            TMLArchiMemoryNode mem = new TMLArchiMemoryNode(cpu.getX() + 100, cpu.getY() + 100, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel);
+            archPanel.addComponent(mem, cpu.getX() + 100, cpu.getY() + 100, false, true);
+            mem.setName("HSMMemory_" + cpuName);
+            //Add Hardware Accelerator
+
+            TMLArchiHWANode hwa = new TMLArchiHWANode(cpu.getX() + 100, cpu.getY() + 100, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel);
+            archPanel.addComponent(hwa, cpu.getX() + 100, cpu.getY() + 100, false, true);
+            hwa.setName("HSM_" + cpuName);
+            //Add hsm task to hwa
+
+
+            TMLArchiArtifact hsmArt = new TMLArchiArtifact(cpu.getX() + 100, cpu.getY() + 100, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, hwa, archPanel);
+            archPanel.addComponent(hsmArt, cpu.getX() + 100, cpu.getY() + 100, true, true);
+            hsmArt.setFullName("HSM_" + cpuName, refTask);
+            //Add bus connecting the cpu and HWA
+
+            TMLArchiBUSNode bus = new TMLArchiBUSNode(cpu.getX() + 100, cpu.getY() + 100, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel);
+            bus.setPrivacy(1);
+            bus.setName("HSMBus_" + cpuName);
+            archPanel.addComponent(bus, cpu.getX() + 200, cpu.getY() + 200, false, true);
+
+            //Connect Bus and CPU
+            TMLArchiConnectorNode connect = new TMLArchiConnectorNode(cpu.getX() + 100, cpu.getY() + 100, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel, null, null, new Vector<Point>());
+            TGConnectingPoint p1 = bus.findFirstFreeTGConnectingPoint(true, true);
+            p1.setFree(false);
+            connect.setP2(p1);
+
+
+            TGConnectingPoint p2 = cpu.findFirstFreeTGConnectingPoint(true, true);
+            p1.setFree(false);
+            connect.setP1(p2);
+            archPanel.addComponent(connect, cpu.getX() + 100, cpu.getY() + 100, false, true);
+            //Connect Bus and HWA
+
+            connect = new TMLArchiConnectorNode(cpu.getX() + 100, cpu.getY() + 100, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel, null, null, new Vector<Point>());
+            p1 = bus.findFirstFreeTGConnectingPoint(true, true);
+            p1.setFree(false);
+            connect.setP2(p1);
+
+            p2 = hwa.findFirstFreeTGConnectingPoint(true, true);
+            p1.setFree(false);
+            connect.setP1(p2);
+
+            archPanel.addComponent(connect, cpu.getX() + 100, cpu.getY() + 100, false, true);
+            //Connect Bus and Memory
+
+            connect = new TMLArchiConnectorNode(cpu.getX() + 100, cpu.getY() + 100, archPanel.getMinX(), archPanel.getMaxX(), archPanel.getMinY(), archPanel.getMaxY(), true, null, archPanel, null, null, new Vector<Point>());
+            p1 = bus.findFirstFreeTGConnectingPoint(true, true);
+            p1.setFree(false);
+            connect.setP2(p1);
+
+            p2 = mem.findFirstFreeTGConnectingPoint(true, true);
+            p1.setFree(false);
+            connect.setP1(p2);
+            archPanel.addComponent(connect, cpu.getX() + 100, cpu.getY() + 100, false, true);
+        }
+
+    }
+
+
+    public TMLMapping<TGComponent> autoSecure(MainGUI gui, boolean autoConf, boolean autoWeakAuth, boolean autoStrongAuth) {
+        //TODO add more options
+        //
+        if (tmap == null) {
+            return null;
+        }
+        TURTLEPanel tmlap = tmap.getCorrespondanceList().getTG(tmap.getArch().getFirstCPU()).getTDiagramPanel().tp;
+        int arch = gui.tabs.indexOf(tmlap);
+        gui.cloneRenameTab(arch, "enc");
+        TMLArchiPanel newarch = (TMLArchiPanel) gui.tabs.get(gui.tabs.size() - 1);
+
+        return autoSecure(gui, "enc", tmap, newarch, autoConf, autoWeakAuth, autoStrongAuth);
+    }
+
+    public TMLMapping<TGComponent> autoSecure(MainGUI gui, String name, TMLMapping<TGComponent> map, TMLArchiPanel newarch) {
+        return autoSecure(gui, name, map, newarch, "100", "0", "100", true, false, false);
+    }
+
+    public TMLMapping<TGComponent> autoSecure(MainGUI gui, String name, TMLMapping<TGComponent> map, TMLArchiPanel newarch, boolean autoConf,
+                                              boolean autoWeakAuth, boolean autoStrongAuth) {
+        return autoSecure(gui, name, map, newarch, "100", "0", "100", autoConf, autoWeakAuth, autoStrongAuth);
+    }
+
+    public TMLMapping<TGComponent> autoSecure(MainGUI gui, String encComp, String overhead, String decComp) {
+        if (tmap == null) {
+            return null;
+        }
+        TURTLEPanel tmlap = tmap.getCorrespondanceList().getTG(tmap.getArch().getFirstCPU()).getTDiagramPanel().tp;
+        int arch = gui.tabs.indexOf(tmlap);
+        gui.cloneRenameTab(arch, "enc");
+        TMLArchiPanel newarch = (TMLArchiPanel) gui.tabs.get(gui.tabs.size() - 1);
+        return autoSecure(gui, "enc", tmap, newarch, encComp, overhead, decComp, true, false, false);
+    }
+
+    public TMLMapping<TGComponent> autoSecure(MainGUI gui, String encComp, String overhead, String decComp, boolean autoConf, boolean autoWeakAuth,
+                                              boolean autoStrongAuth) {
+        if (tmap == null) {
+            return null;
+        }
+        TURTLEPanel tmlap = tmap.getCorrespondanceList().getTG(tmap.getArch().getFirstCPU()).getTDiagramPanel().tp;
+        int arch = gui.tabs.indexOf(tmlap);
+        gui.cloneRenameTab(arch, "enc");
+        TMLArchiPanel newarch = (TMLArchiPanel) gui.tabs.get(gui.tabs.size() - 1);
+        return autoSecure(gui, "enc", tmap, newarch, encComp, overhead, decComp, autoConf, autoWeakAuth, autoStrongAuth);
+    }
+
+    public TMLMapping<TGComponent> autoSecure(MainGUI gui, String name, TMLMapping<TGComponent> map, TMLArchiPanel newarch, String encComp, String
+            overhead, String decComp) {
+        return autoSecure(gui, name, tmap, newarch, encComp, overhead, decComp, true, false, false);
+    }
+
+    public void proverifAnalysis(TMLMapping<TGComponent> map, List<String> nonAuthChans, List<String> nonSecChans) {
+        if (map == null) {
+            TraceManager.addDev("No mapping");
+            return;
+        }
+        //Perform ProVerif Analysis
+        TML2Avatar t2a = new TML2Avatar(map, false, true);
+        AvatarSpecification avatarspec = t2a.generateAvatarSpec("1");
+        if (avatarspec == null) {
+            TraceManager.addDev("No avatar spec");
+            return;
+        }
+
+        avatar2proverif = new AVATAR2ProVerif(avatarspec);
+        try {
+            proverif = avatar2proverif.generateProVerif(true, true, 1, true, false);
+            warnings = avatar2proverif.getWarnings();
+
+            if (!avatar2proverif.saveInFile("pvspec")) {
+                return;
+            }
+
+            RshClient rshc = new RshClient(ConfigurationTTool.ProVerifVerifierHost);
+
+            rshc.setCmd(ConfigurationTTool.ProVerifVerifierPath + " -in pitype pvspec");
+            rshc.sendExecuteCommandRequest();
+            Reader data = rshc.getDataReaderFromProcess();
+
+            ProVerifOutputAnalyzer pvoa = getProVerifOutputAnalyzer();
+            pvoa.analyzeOutput(data, true);
+            HashMap<AvatarPragmaSecret, ProVerifQueryResult> confResults = pvoa.getConfidentialityResults();
+            for (AvatarPragmaSecret pragma : confResults.keySet()) {
+                if (confResults.get(pragma).isProved() && !confResults.get(pragma).isSatisfied()) {
+                    nonSecChans.add(pragma.getArg().getBlock().getName() + "__" + pragma.getArg().getName());
+                    TraceManager.addDev(pragma.getArg().getBlock().getName() + "." + pragma.getArg().getName() + " is not secret");
+                    TMLChannel chan = map.getTMLModeling().getChannelByShortName(pragma.getArg().getName().replaceAll("_chData", ""));
+                    for (String block : chan.getTaskNames()) {
+                        nonSecChans.add(block + "__" + pragma.getArg().getName());
+                    }
+                }
+            }
+            HashMap<AvatarPragmaAuthenticity, ProVerifQueryAuthResult> authResults = pvoa.getAuthenticityResults();
+            for (AvatarPragmaAuthenticity pragma : authResults.keySet()) {
+                if (authResults.get(pragma).isProved() && !authResults.get(pragma).isSatisfied()) {
+                    nonAuthChans.add(pragma.getAttrA().getAttribute().getBlock().getName() + "__" + pragma.getAttrA().getAttribute().getName().replaceAll("_chData", ""));
+                    nonAuthChans.add(pragma.getAttrB().getAttribute().getBlock().getName() + "__" + pragma.getAttrB().getAttribute().getName().replaceAll("_chData", ""));
+                }
+            }
+            TraceManager.addDev("nonsecchans " + nonSecChans);
+            TraceManager.addDev("nonauthchans " + nonAuthChans);
+            TraceManager.addDev("all results displayed");
+
+        } catch (Exception e) {
+            System.out.println("ProVerif Analysis Failed " + e);
+        }
+    }
+
+    public TMLMapping<TGComponent> autoSecure(MainGUI gui, String name, TMLMapping<TGComponent> map, TMLArchiPanel newarch, String encComp, String overhead, String decComp, boolean autoConf, boolean autoWeakAuth, boolean autoStrongAuth) {
+        Map<TMLTask, List<TMLTask>> toSecure = new HashMap<TMLTask, List<TMLTask>>();
+        Map<TMLTask, List<TMLTask>> toSecureRev = new HashMap<TMLTask, List<TMLTask>>();
+        Map<TMLTask, List<String>> secOutChannels = new HashMap<TMLTask, List<String>>();
+        Map<TMLTask, List<String>> secInChannels = new HashMap<TMLTask, List<String>>();
+        Map<TMLTask, List<String>> nonceOutChannels = new HashMap<TMLTask, List<String>>();
+        Map<TMLTask, List<String>> nonceInChannels = new HashMap<TMLTask, List<String>>();
+        Map<TMLTask, List<String>> macOutChannels = new HashMap<TMLTask, List<String>>();
+        Map<TMLTask, List<String>> macInChannels = new HashMap<TMLTask, List<String>>();
+        Map<TMLTask, List<String>> macNonceOutChannels = new HashMap<TMLTask, List<String>>();
+        Map<TMLTask, List<String>> macNonceInChannels = new HashMap<TMLTask, List<String>>();
+        TraceManager.addDev("mapping " + map.getSummaryTaskMapping());
+        List<String> nonAuthChans = new ArrayList<String>();
+        List<String> nonSecChans = new ArrayList<String>();
+
+        proverifAnalysis(map, nonAuthChans, nonSecChans);
+
+        TMLModeling<TGComponent> tmlmodel = map.getTMLModeling();
+        List<TMLChannel> channels = tmlmodel.getChannels();
+        for (TMLChannel channel : channels) {
+            for (TMLCPrimitivePort p : channel.ports) {
+                channel.checkConf = channel.checkConf || p.checkConf;
+                channel.checkAuth = channel.checkAuth || p.checkAuth;
+            }
+        }
+
+        //Create clone of Component Diagram + Activity diagrams to secure
+        TGComponent tgcomp = map.getTMLModeling().getTGComponent();
+        TMLComponentDesignPanel tmlcdp = (TMLComponentDesignPanel) tgcomp.getTDiagramPanel().tp;
+//        TMLComponentDesignPanel tmlcdp = map.getTMLCDesignPanel();
+        int ind = gui.tabs.indexOf(tmlcdp);
+        if (ind == -1) {
+            TraceManager.addDev("No Component Design Panel");
+            return null;
+        }
+        String tabName = gui.getTitleAt(tmlcdp);
+        gui.cloneRenameTab(ind, name);
+        TMLComponentDesignPanel t = (TMLComponentDesignPanel) gui.tabs.get(gui.tabs.size() - 1);
+
+        TMLComponentTaskDiagramPanel tcdp = t.tmlctdp;
+        //Create clone of architecture panel and map tasks to it
+        newarch.renameMapping(tabName, tabName + "_" + name);
+
+        for (TMLTask task : map.getTMLModeling().getTasks()) {
+            List<String> tmp = new ArrayList<String>();
+            List<String> tmp2 = new ArrayList<String>();
+            List<TMLTask> tmp3 = new ArrayList<TMLTask>();
+            List<TMLTask> tmp4 = new ArrayList<TMLTask>();
+            List<String> tmp5 = new ArrayList<String>();
+            List<String> tmp6 = new ArrayList<String>();
+            List<String> tmp7 = new ArrayList<String>();
+            List<String> tmp8 = new ArrayList<String>();
+            List<String> tmp9 = new ArrayList<String>();
+            List<String> tmp10 = new ArrayList<String>();
+            secInChannels.put(task, tmp);
+            secOutChannels.put(task, tmp2);
+            toSecure.put(task, tmp3);
+            toSecureRev.put(task, tmp4);
+            nonceInChannels.put(task, tmp5);
+            nonceOutChannels.put(task, tmp6);
+            macInChannels.put(task, tmp7);
+            macOutChannels.put(task, tmp8);
+            macNonceOutChannels.put(task, tmp9);
+            macNonceInChannels.put(task, tmp10);
+        }
+        //With the proverif results, check which channels need to be secured
+        for (TMLTask task : map.getTMLModeling().getTasks()) {
+            //Check if all channel operators are secured
+            TMLActivityDiagramPanel tad = t.getTMLActivityDiagramPanel(task.getName());
+            for (TGComponent tg : tad.getComponentList()) {
+                if (tg instanceof TMLADWriteChannel) {
+                    TMLADWriteChannel writeChannel = (TMLADWriteChannel) tg;
+                    if (writeChannel.getSecurityContext().equals("")) {
+
+                        TMLChannel chan = tmlmodel.getChannelByName(tabName + "__" + writeChannel.getChannelName());
+                        //System.out.println("channel " + chan);
+                        if (chan != null) {
+                            if (chan.checkConf && autoConf) {
+                                //        System.out.println(chan.getOriginTask().getName().split("__")[1]);
+                                if (nonSecChans.contains(chan.getOriginTask().getName().split("__")[1] + "__" + writeChannel.getChannelName() + "_chData") && !secInChannels.get(chan.getDestinationTask()).contains(writeChannel.getChannelName())) {
+                                    //                                                                                            if (!securePath(map, chan.getOriginTask(), chan.getDestinationTask())){
+                                    secOutChannels.get(chan.getOriginTask()).add(writeChannel.getChannelName());
+                                    secInChannels.get(chan.getDestinationTask()).add(writeChannel.getChannelName());
+                                    toSecure.get(chan.getOriginTask()).add(chan.getDestinationTask());
+                                    if (chan.checkAuth && autoStrongAuth) {
+                                        toSecureRev.get(chan.getDestinationTask()).add(chan.getOriginTask());
+                                        nonceOutChannels.get(chan.getOriginTask()).add(writeChannel.getChannelName());
+                                        nonceInChannels.get(chan.getDestinationTask()).add(writeChannel.getChannelName());
+                                    }
+                                }
+                            } else if (chan.checkAuth && autoWeakAuth) {
+                                if (nonAuthChans.contains(chan.getDestinationTask().getName().split("__")[1] + "__" + writeChannel.getChannelName())) {
+                                    toSecure.get(chan.getOriginTask()).add(chan.getDestinationTask());
+                                    macOutChannels.get(chan.getOriginTask()).add(writeChannel.getChannelName());
+                                    macInChannels.get(chan.getDestinationTask()).add(writeChannel.getChannelName());
+                                    if (autoStrongAuth) {
+                                        toSecureRev.get(chan.getDestinationTask()).add(chan.getOriginTask());
+                                        macNonceInChannels.get(chan.getDestinationTask()).add(writeChannel.getChannelName());
+                                        macNonceOutChannels.get(chan.getOriginTask()).add(writeChannel.getChannelName());
+                                    }
+                                }
+
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        TraceManager.addDev("macoutchans " + macOutChannels);
+        TraceManager.addDev("macinchans " + macInChannels);
+        TraceManager.addDev("nonsecin " + secInChannels);
+        TraceManager.addDev("nonsecout " + secOutChannels);
+        TraceManager.addDev("noncein " + nonceInChannels);
+        TraceManager.addDev("nonceout " + nonceOutChannels);
+
+        //        System.out.println(secOutChanannels.toString());
+        //        int num=0;
+        //int nonceNum=0;
+        //Create reverse channels on component diagram to send nonces if they don't already exist
+
+        for (TMLTask task : toSecureRev.keySet()) {
+            TraceManager.addDev("Adding nonces to " + task.getName());
+            List<TMLChannel> chans = tmlmodel.getChannelsFromMe(task);
+
+            for (TMLTask task2 : toSecureRev.get(task)) {
+                boolean addChan = true;
+                for (TMLChannel chan : chans) {
+                    if (chan.getDestinationTask() == task2) {
+                        addChan = false;
+                    }
+                }
+
+                if (addChan) {
+                    TMLCChannelOutPort originPort = new TMLCChannelOutPort(0, 0, tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, null, tcdp);
+                    TMLCChannelOutPort destPort = new TMLCChannelOutPort(0, 0, tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, null, tcdp);
+                    for (TGComponent tg : tcdp.getComponentList()) {
+                        if (tg instanceof TMLCPrimitiveComponent) {
+                            if (tg.getValue().equals(task.getName().split("__")[1])) {
+                                originPort = new TMLCChannelOutPort(tg.getX(), tg.getY(), tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, tg, tcdp);
+                                originPort.commName = "nonceCh" + task.getName().split("__")[1] + "_" + task2.getName().split("__")[1];
+                                tcdp.addComponent(originPort, tg.getX(), tg.getY(), true, true);
+                            } else if (tg.getValue().equals(task2.getName().split("__")[1])) {
+                                destPort = new TMLCChannelOutPort(tg.getX(), tg.getY(), tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, tg, tcdp);
+                                destPort.isOrigin = false;
+                                destPort.commName = "nonceCh" + task.getName().split("__")[1] + "_" + task2.getName().split("__")[1];
+                                tcdp.addComponent(destPort, tg.getX(), tg.getY(), true, true);
+                            }
+                        }
+                    }
+                    tmlmodel.addChannel(new TMLChannel("nonceCh" + task.getName().split("__")[1] + "_" + task2.getName().split("__")[1], originPort));
+                    //Add connection
+                    TMLCPortConnector conn = new TMLCPortConnector(0, 0, tcdp.getMinX(), tcdp.getMaxX(), tcdp.getMinY(), tcdp.getMaxX(), true, null, tcdp, originPort.getTGConnectingPointAtIndex(0), destPort.getTGConnectingPointAtIndex(0), new Vector<Point>());
+                    tcdp.addComponent(conn, 0, 0, false, true);
+                }
+            }
+        }
+        //  }
+        //Add encryption/nonces to activity diagram
+        for (TMLTask task : toSecure.keySet()) {
+            String title = task.getName().split("__")[0];
+            TraceManager.addDev("Securing task " + task.getName());
+            TMLActivityDiagramPanel tad = t.getTMLActivityDiagramPanel(task.getName());
+            //Get start state position, shift everything down
+            int xpos = 0;
+            int ypos = 0;
+            TGConnector fromStart = new TGConnectorTMLAD(0, 0, 0, 0, 0, 0, false, null, tad, null, null, new Vector<Point>());
+            TGConnectingPoint point = new TGConnectingPoint(null, 0, 0, false, false);
+            //Find states immediately before the write channel operator
+
+            //For each occurence of a write channel operator, add encryption/nonces before it
+
+            for (String channel : secOutChannels.get(task)) {
+                Set<TGComponent> channelInstances = new HashSet<TGComponent>();
+                int yShift = 50;
+                TMLChannel tmlc = tmlmodel.getChannelByName(title + "__" + channel);
+                //First, find the connector that points to it. We will add the encryption, nonce operators directly before the write channel operator
+                for (TGComponent tg : tad.getComponentList()) {
+                    if (tg instanceof TMLADWriteChannel) {
+                        TMLADWriteChannel writeChannel = (TMLADWriteChannel) tg;
+                        if (writeChannel.getChannelName().equals(channel) && writeChannel.getSecurityContext().equals("")) {
+
+                            if (fromStart != null) {
+                                channelInstances.add(tg);
+                            }
+                        }
+                    }
+                }
+                for (TGComponent comp : channelInstances) {
+                    //TMLADWriteChannel writeChannel = (TMLADWriteChannel) comp;
+                    xpos = comp.getX();
+                    ypos = comp.getY();
+                    fromStart = tad.findTGConnectorEndingAt(comp.getTGConnectingPointAtIndex(0));
+                    point = fromStart.getTGConnectingPointP2();
+                    //Add encryption operator
+                    TMLADEncrypt enc = new TMLADEncrypt(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                    TMLADReadChannel rd = new TMLADReadChannel(0, 0, 0, 0, 0, 0, false, null, tad);
+                    if (nonceOutChannels.get(task).contains(channel)) {
+                        //Receive any nonces if ensuring authenticity
+                        rd = new TMLADReadChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                        List<TMLChannel> matches = tmlmodel.getChannels(tmlc.getDestinationTask(), tmlc.getOriginTask());
+
+                        if (matches.size() > 0) {
+                            rd.setChannelName(matches.get(0).getName().replaceAll(title + "__", ""));
+                        } else {
+                            rd.setChannelName("nonceCh" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]);
+                        }
+                        rd.setSecurityContext("nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]);
+                        tad.addComponent(rd, xpos, ypos + yShift, false, true);
+                        fromStart.setP2(rd.getTGConnectingPointAtIndex(0));
+                        fromStart = new TGConnectorTMLAD(enc.getX(), enc.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                        tad.addComponent(fromStart, xpos, ypos, false, true);
+                        fromStart.setP1(rd.getTGConnectingPointAtIndex(1));
+                        yShift += 60;
+                        //Move encryption operator after receive nonce component
+                        enc.setCd(xpos, ypos + yShift);
+                        if (tmlc != null) {
+                            enc.nonce = "nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1];
+                        }
+                    }
+
+                    enc.securityContext = "autoEncrypt_" + channel;
+                    enc.type = "Symmetric Encryption";
+                    enc.message_overhead = overhead;
+                    enc.encTime = encComp;
+                    enc.decTime = decComp;
+                    tad.addComponent(enc, xpos, ypos + yShift, false, true);
+                    yShift += 60;
+                    fromStart.setP2(enc.getTGConnectingPointAtIndex(0));
+                    fromStart = new TGConnectorTMLAD(enc.getX(), enc.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                    tad.addComponent(fromStart, xpos, ypos, false, true);
+                    fromStart.setP1(enc.getTGConnectingPointAtIndex(1));
+
+                    //Direct the last TGConnector back to the start of the write channel operator
+
+                    fromStart.setP2(point);
+                    //Shift components down to make room for the added ones, and add security contexts to write channels
+                    for (TGComponent tg : tad.getComponentList()) {
+                        if (tg instanceof TMLADWriteChannel) {
+                            TMLADWriteChannel wChannel = (TMLADWriteChannel) tg;
+                            TraceManager.addDev("Inspecting write channel " + wChannel.getChannelName());
+                            if (channel.equals(wChannel.getChannelName()) && wChannel.getSecurityContext().equals("")) {
+                                TraceManager.addDev("Securing write channel " + wChannel.getChannelName());
+                                wChannel.setSecurityContext("autoEncrypt_" + wChannel.getChannelName());
+
+                            }
+                        }
+                        if (tg.getY() >= ypos && tg != enc && tg != rd) {
+                            tg.setCd(tg.getX(), tg.getY() + yShift);
+                        }
+                    }
+                    tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift);
+                    tad.repaint();
+                }
+            }
+
+            for (String channel : macOutChannels.get(task)) {
+                //Add MAC before writechannel
+                int yShift = 50;
+                TMLChannel tmlc = tmlmodel.getChannelByName(title + "__" + channel);
+                //First, find the connector that points to it. We will add the encryption, nonce operators directly before the write channel operator
+                Set<TGComponent> channelInstances = new HashSet<TGComponent>();
+                for (TGComponent tg : tad.getComponentList()) {
+                    if (tg instanceof TMLADWriteChannel) {
+                        TMLADWriteChannel writeChannel = (TMLADWriteChannel) tg;
+                        if (writeChannel.getChannelName().equals(channel) && writeChannel.getSecurityContext().equals("")) {
+                            xpos = tg.getX();
+                            ypos = tg.getY();
+                            fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0));
+                            if (fromStart != null) {
+                                channelInstances.add(tg);
+                            }
+                        }
+                    }
+                }
+                for (TGComponent comp : channelInstances) {
+                    //TMLADWriteChannel writeChannel = (TMLADWriteChannel) comp;
+                    xpos = comp.getX();
+                    ypos = comp.getY();
+                    fromStart = tad.findTGConnectorEndingAt(comp.getTGConnectingPointAtIndex(0));
+                    point = fromStart.getTGConnectingPointP2();
+
+                    TMLADEncrypt enc = new TMLADEncrypt(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+
+                    //If we need to receive a nonce
+                    TMLADReadChannel rd = new TMLADReadChannel(0, 0, 0, 0, 0, 0, false, null, tad);
+                    if (macNonceOutChannels.get(task).contains(channel)) {
+                        //Receive any nonces if ensuring authenticity
+                        rd = new TMLADReadChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                        List<TMLChannel> matches = tmlmodel.getChannels(tmlc.getDestinationTask(), tmlc.getOriginTask());
+
+                        if (matches.size() > 0) {
+                            rd.setChannelName(matches.get(0).getName().replaceAll(title + "__", ""));
+                        } else {
+                            rd.setChannelName("nonceCh" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]);
+                        }
+                        rd.setSecurityContext("nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]);
+                        tad.addComponent(rd, xpos, ypos + yShift, false, true);
+                        fromStart.setP2(rd.getTGConnectingPointAtIndex(0));
+                        fromStart = new TGConnectorTMLAD(enc.getX(), enc.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                        tad.addComponent(fromStart, xpos, ypos, false, true);
+                        fromStart.setP1(rd.getTGConnectingPointAtIndex(1));
+                        yShift += 60;
+                        //Move encryption operator after receive nonce component
+                        enc.setCd(xpos, ypos + yShift);
+                        if (tmlc != null) {
+                            enc.nonce = "nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1];
+                        }
+                    }
+
+                    //Add encryption operator
+
+                    enc.securityContext = "autoEncrypt_" + channel;
+                    enc.type = "MAC";
+                    enc.message_overhead = overhead;
+                    enc.encTime = encComp;
+                    enc.decTime = decComp;
+                    enc.size = overhead;
+                    tad.addComponent(enc, xpos, ypos + yShift, false, true);
+                    yShift += 60;
+                    fromStart.setP2(enc.getTGConnectingPointAtIndex(0));
+                    fromStart = new TGConnectorTMLAD(enc.getX(), enc.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, null, null, new Vector<Point>());
+                    tad.addComponent(fromStart, xpos, ypos, false, true);
+                    fromStart.setP1(enc.getTGConnectingPointAtIndex(1));
+
+                    //Direct the last TGConnector back to the start of the write channel operator
+
+                    fromStart.setP2(point);
+                    //Shift components down to make room for the added ones, and add security contexts to write channels
+                    for (TGComponent tg : tad.getComponentList()) {
+                        if (tg instanceof TMLADWriteChannel) {
+                            TMLADWriteChannel wChannel = (TMLADWriteChannel) tg;
+                            TraceManager.addDev("Inspecting write channel " + wChannel.getChannelName());
+                            if (channel.equals(wChannel.getChannelName()) && wChannel.getSecurityContext().equals("")) {
+                                TraceManager.addDev("Securing write channel " + wChannel.getChannelName());
+                                wChannel.setSecurityContext("autoEncrypt_" + wChannel.getChannelName());
+                                tad.repaint();
+                            }
+                        }
+                        if (tg.getY() >= ypos && tg != enc && tg != rd) {
+                            tg.setCd(tg.getX(), tg.getY() + yShift);
+                        }
+                    }
+                    tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift);
+                }
+            }
+            for (String channel : macInChannels.get(task)) {
+                //Add decryptmac after readchannel
+                int yShift = 50;
+                Set<TGComponent> channelInstances = new HashSet<TGComponent>();
+                TGConnector conn = new TGConnectorTMLAD(0, 0, 0, 0, 0, 0, false, null, tad, null, null, new Vector<Point>());
+                TGConnectingPoint next = new TGConnectingPoint(null, 0, 0, false, false);
+                //Find read channel operator
+
+                for (TGComponent tg : tad.getComponentList()) {
+                    if (tg instanceof TMLADReadChannel) {
+                        TMLADReadChannel readChannel = (TMLADReadChannel) tg;
+                        if (readChannel.getChannelName().equals(channel) && readChannel.getSecurityContext().equals("")) {
+                            fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0));
+                            if (fromStart != null) {
+                                channelInstances.add(tg);
+                            }
+                        }
+                    }
+                }
+
+
+                for (TGComponent comp : channelInstances) {
+
+                    fromStart = tad.findTGConnectorEndingAt(comp.getTGConnectingPointAtIndex(0));
+                    point = fromStart.getTGConnectingPointP2();
+                    conn = tad.findTGConnectorStartingAt(comp.getTGConnectingPointAtIndex(1));
+                    next = conn.getTGConnectingPointP2();
+                    xpos = fromStart.getX();
+                    ypos = fromStart.getY();
+
+
+                    TMLADReadChannel readChannel = (TMLADReadChannel) comp;
+                    TraceManager.addDev("Securing read channel " + readChannel.getChannelName());
+                    readChannel.setSecurityContext("autoEncrypt_" + readChannel.getChannelName());
+                    tad.repaint();
+
+                    TMLADWriteChannel wr = new TMLADWriteChannel(0, 0, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                    //Create nonce and send it
+                    TMLChannel tmlc = tmlmodel.getChannelByName(title + "__" + channel);
+                    if (macNonceInChannels.get(task).contains(channel)) {
+                        //Create a nonce operator and a write channel operator
+                        TMLADEncrypt nonce = new TMLADEncrypt(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                        nonce.securityContext = "nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1];
+                        nonce.type = "Nonce";
+                        nonce.message_overhead = overhead;
+                        nonce.encTime = encComp;
+                        nonce.decTime = decComp;
+                        tad.addComponent(nonce, xpos, ypos + yShift, false, true);
+                        fromStart.setP2(nonce.getTGConnectingPointAtIndex(0));
+                        yShift += 50;
+                        wr = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                        //Send nonce along channel, the newly created nonce channel or an existing channel with the matching sender and receiver
+                        //Find matching channels
+                        List<TMLChannel> matches = tmlmodel.getChannels(tmlc.getDestinationTask(), tmlc.getOriginTask());
+
+                        if (matches.size() > 0) {
+                            wr.setChannelName(matches.get(0).getName().replaceAll(title + "__", ""));
+                        } else {
+                            wr.setChannelName("nonceCh" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]);
+                        }
+                        //send the nonce along the channel
+                        wr.setSecurityContext("nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]);
+                        tad.addComponent(wr, xpos, ypos + yShift, false, true);
+                        wr.makeValue();
+                        TGConnector tmp = new TGConnectorTMLAD(wr.getX(), wr.getY() + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, nonce.getTGConnectingPointAtIndex(1), wr.getTGConnectingPointAtIndex(0), new Vector<Point>());
+                        tad.addComponent(tmp, xpos, ypos, false, true);
+                        fromStart = new TGConnectorTMLAD(wr.getX(), wr.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, wr.getTGConnectingPointAtIndex(1), null, new Vector<Point>());
+                        tad.addComponent(fromStart, xpos, ypos, false, true);
+                        //Connect created write channel operator to start of read channel operator
+                        fromStart.setP1(wr.getTGConnectingPointAtIndex(1));
+                        fromStart.setP2(point);
+                        //Shift everything from the read channel on down
+                        for (TGComponent tg : tad.getComponentList()) {
+                            if (tg.getY() >= ypos && tg != nonce && tg != wr) {
+                                tg.setCd(tg.getX(), tg.getY() + yShift);
+                            }
+                        }
+                    }
+
+                    //Add decryption operator if it does not already exist
+                    xpos = conn.getX();
+                    ypos = conn.getY();
+
+                    TMLADDecrypt dec = new TMLADDecrypt(xpos + 10, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                    dec.securityContext = "autoEncrypt_" + readChannel.getChannelName();
+                    tad.addComponent(dec, dec.getX(), dec.getY(), false, true);
+                    conn.setP2(dec.getTGConnectingPointAtIndex(0));
+                    yShift += 60;
+                    conn = new TGConnectorTMLAD(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, dec.getTGConnectingPointAtIndex(1), next, new Vector<Point>());
+                    conn.setP1(dec.getTGConnectingPointAtIndex(1));
+                    conn.setP2(next);
+                    tad.addComponent(conn, conn.getX(), conn.getY(), false, true);
+                    //Shift everything down
+                    for (TGComponent tg : tad.getComponentList()) {
+                        if (tg instanceof TMLADReadChannel) {
+                            readChannel = (TMLADReadChannel) tg;
+                            TraceManager.addDev("Inspecting read channel " + readChannel.getChannelName());
+                            if (channel.equals(readChannel.getChannelName()) && readChannel.getSecurityContext().equals("")) {
+                                TraceManager.addDev("Securing read channel " + readChannel.getChannelName());
+                                readChannel.setSecurityContext("autoEncrypt_" + readChannel.getChannelName());
+
+                            }
+                        }
+                        if (tg.getY() > ypos && tg != dec && tg != comp) {
+
+                            tg.setCd(tg.getX(), tg.getY() + yShift);
+                        }
+                    }
+
+
+                    tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift);
+                    tad.repaint();
+                }
+            }
+            for (String channel : secInChannels.get(task)) {
+                TraceManager.addDev("securing channel " + channel);
+                int yShift = 20;
+                //        String title = task.getName().split("__")[0];
+                TMLChannel tmlc = tmlmodel.getChannelByName(title + "__" + channel);
+                TGConnector conn = new TGConnectorTMLAD(0, 0, 0, 0, 0, 0, false, null, tad, null, null, new Vector<Point>());
+                TGConnectingPoint next = new TGConnectingPoint(null, 0, 0, false, false);
+                //Find read channel operator
+                TMLADReadChannel readChannel = new TMLADReadChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                HashSet<TGComponent> channelInstances = new HashSet<TGComponent>();
+                for (TGComponent tg : tad.getComponentList()) {
+                    if (tg instanceof TMLADReadChannel) {
+                        readChannel = (TMLADReadChannel) tg;
+                        if (readChannel.getChannelName().equals(channel) && readChannel.getSecurityContext().equals("")) {
+                            fromStart = tad.findTGConnectorEndingAt(tg.getTGConnectingPointAtIndex(0));
+                            if (fromStart != null) {
+                                channelInstances.add(tg);
+                            }
+                        }
+                    }
+                }
+
+                for (TGComponent comp : channelInstances) {
+
+                    fromStart = tad.findTGConnectorEndingAt(comp.getTGConnectingPointAtIndex(0));
+                    point = fromStart.getTGConnectingPointP2();
+                    conn = tad.findTGConnectorStartingAt(comp.getTGConnectingPointAtIndex(1));
+                    next = conn.getTGConnectingPointP2();
+                    xpos = fromStart.getX();
+                    ypos = fromStart.getY();
+                    TMLADWriteChannel wr = new TMLADWriteChannel(0, 0, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                    if (nonceInChannels.get(task).contains(channel)) {
+                        //Create a nonce operator and a write channel operator
+                        TMLADEncrypt nonce = new TMLADEncrypt(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                        nonce.securityContext = "nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1];
+                        nonce.type = "Nonce";
+                        nonce.message_overhead = overhead;
+                        nonce.encTime = encComp;
+                        nonce.decTime = decComp;
+                        tad.addComponent(nonce, xpos, ypos + yShift, false, true);
+                        fromStart.setP2(nonce.getTGConnectingPointAtIndex(0));
+                        yShift += 50;
+                        wr = new TMLADWriteChannel(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                        //Send nonce along channel, the newly created nonce channel or an existing channel with the matching sender and receiver
+                        //Find matching channels
+                        List<TMLChannel> matches = tmlmodel.getChannels(tmlc.getDestinationTask(), tmlc.getOriginTask());
+
+                        if (matches.size() > 0) {
+                            wr.setChannelName(matches.get(0).getName().replaceAll(title + "__", ""));
+                        } else {
+                            wr.setChannelName("nonceCh" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]);
+                        }
+                        //send the nonce along the channel
+                        wr.setSecurityContext("nonce_" + tmlc.getDestinationTask().getName().split("__")[1] + "_" + tmlc.getOriginTask().getName().split("__")[1]);
+                        tad.addComponent(wr, xpos, ypos + yShift, false, true);
+                        wr.makeValue();
+                        TGConnector tmp = new TGConnectorTMLAD(wr.getX(), wr.getY() + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, nonce.getTGConnectingPointAtIndex(1), wr.getTGConnectingPointAtIndex(0), new Vector<Point>());
+                        tad.addComponent(tmp, xpos, ypos, false, true);
+                        fromStart = new TGConnectorTMLAD(wr.getX(), wr.getY(), tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, wr.getTGConnectingPointAtIndex(1), null, new Vector<Point>());
+                        tad.addComponent(fromStart, xpos, ypos, false, true);
+                        //Connect created write channel operator to start of read channel operator
+                        fromStart.setP1(wr.getTGConnectingPointAtIndex(1));
+                        fromStart.setP2(point);
+                        //Shift everything from the read channel on down
+                        for (TGComponent tg : tad.getComponentList()) {
+                            if (tg.getY() >= ypos && tg != nonce && tg != wr) {
+                                tg.setCd(tg.getX(), tg.getY() + yShift);
+                            }
+                        }
+                    }
+                    //tad.repaint();
+
+                    //Now add the decrypt operator
+                    yShift = 40;
+                    TraceManager.addDev("Securing read channel " + readChannel.getChannelName());
+                    readChannel.setSecurityContext("autoEncrypt_" + readChannel.getChannelName());
+                    tad.repaint();
+                    //Add decryption operator if it does not already exist
+                    xpos = readChannel.getX();
+                    ypos = readChannel.getY();
+                    TMLADDecrypt dec = new TMLADDecrypt(xpos + 10, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad);
+                    dec.securityContext = "autoEncrypt_" + readChannel.getChannelName();
+                    tad.addComponent(dec, dec.getX(), dec.getY(), false, true);
+                    conn.setP2(dec.getTGConnectingPointAtIndex(0));
+                    yShift += 100;
+                    conn = new TGConnectorTMLAD(xpos, ypos + yShift, tad.getMinX(), tad.getMaxX(), tad.getMinY(), tad.getMaxY(), false, null, tad, dec.getTGConnectingPointAtIndex(1), next, new Vector<Point>());
+                    conn.setP1(dec.getTGConnectingPointAtIndex(1));
+
+                    conn.setP2(next);
+                    tad.addComponent(conn, conn.getX(), conn.getY(), false, true);
+                    //Shift everything down
+                    for (TGComponent tg : tad.getComponentList()) {
+                        if (tg instanceof TMLADReadChannel) {
+                            readChannel = (TMLADReadChannel) tg;
+                            TraceManager.addDev("Inspecting read channel " + readChannel.getChannelName());
+                            if (channel.equals(readChannel.getChannelName()) && readChannel.getSecurityContext().equals("")) {
+                                TraceManager.addDev("Securing read channel " + readChannel.getChannelName());
+                                readChannel.setSecurityContext("autoEncrypt_" + readChannel.getChannelName());
+
+                            }
+                        }
+                        if (tg.getY() > ypos && tg != dec) {
+
+                            tg.setCd(tg.getX(), tg.getY() + yShift);
+                        }
+                    }
+
+                    tad.setMaxPanelSize(tad.getMaxX(), tad.getMaxY() + yShift);
+
+                    tad.repaint();
+                }
+            }
+        }
+        GTMLModeling gtm = new GTMLModeling(t, false);
+        TMLModeling<TGComponent> newmodel = gtm.translateToTMLModeling(false, false);
+        for (TMLTask task : newmodel.getTasks()) {
+            task.setName(tabName + "_" + name + "__" + task.getName());
+        }
+        for (TMLTask task : tmlmodel.getTasks()) {
+            HwExecutionNode node = (HwExecutionNode) map.getHwNodeOf(task);
+            if (newmodel.getTMLTaskByName(task.getName().replace(tabName, tabName + "_" + name)) != null) {
+                map.addTaskToHwExecutionNode(newmodel.getTMLTaskByName(task.getName().replace(tabName, tabName + "_" + name)), node);
+                map.removeTask(task);
+            } else {
+                System.out.println("Can't find " + task.getName());
+            }
+        }
+        //map.setTMLModeling(newmodel);
+        //System.out.println(map);
+        //TMLMapping newMap = gtm.translateToTMLMapping();
+        map.setTMLModeling(newmodel);
+        return map;
+    }
+
+
+    public boolean securePath(TMLMapping<TGComponent> map, TMLTask t1, TMLTask t2) {
+        //Check if a path between two tasks is secure
+        boolean secure = true;
+        List<HwLink> links = map.getTMLArchitecture().getHwLinks();
+        HwExecutionNode node1 = (HwExecutionNode) map.getHwNodeOf(t1);
+        HwExecutionNode node2 = (HwExecutionNode) map.getHwNodeOf(t2);
+        List<HwNode> found = new ArrayList<HwNode>();
+        List<HwNode> done = new ArrayList<HwNode>();
+        List<HwNode> path = new ArrayList<HwNode>();
+        Map<HwNode, List<HwNode>> pathMap = new HashMap<HwNode, List<HwNode>>();
+        TraceManager.addDev("Links " + links);
+        if (node1 == node2) {
+            return true;
+        }
+        for (HwLink link : links) {
+            if (link.hwnode == node1) {
+                found.add(link.bus);
+                List<HwNode> tmp = new ArrayList<HwNode>();
+                tmp.add(link.bus);
+                pathMap.put(link.bus, tmp);
+            }
+        }
+        outerloop:
+        while (found.size() > 0) {
+            HwNode curr = found.remove(0);
+            for (HwLink link : links) {
+                if (curr == link.bus) {
+                    if (link.hwnode == node2) {
+                        path = pathMap.get(curr);
+                        break outerloop;
+                    }
+                    if (!done.contains(link.hwnode) && !found.contains(link.hwnode) && link.hwnode instanceof HwBridge) {
+                        found.add(link.hwnode);
+                        List<HwNode> tmp = new ArrayList<HwNode>(pathMap.get(curr));
+                        tmp.add(link.hwnode);
+                        pathMap.put(link.hwnode, tmp);
+                    }
+                } else if (curr == link.hwnode) {
+                    if (!done.contains(link.bus) && !found.contains(link.bus)) {
+                        found.add(link.bus);
+                        List<HwNode> tmp = new ArrayList<HwNode>(pathMap.get(curr));
+                        tmp.add(link.bus);
+                        pathMap.put(link.bus, tmp);
+                    }
+                }
+            }
+            done.add(curr);
+        }
+        if (path.size() == 0) {
+            System.out.println("no path");
+            return true;
+        } else {
+            HwBus bus;
+            //Check if all buses and bridges are private
+            for (HwNode n : path) {
+                if (n instanceof HwBus) {
+                    bus = (HwBus) n;
+                    if (bus.privacy == 0) {
+                        return false;
+                    }
+                }
+            }
+        }
+        return secure;
+    }
+
+    public void autoMapKeys() {
+        TraceManager.addDev("auto map keys");
+        if (tmap == null) {
+            return;
+        }
+        List<HwLink> links = tmap.getArch().getHwLinks();
+        //Find all Security Patterns, if they don't have an associated memory at encrypt and decrypt, map them
+        TMLModeling<TGComponent> tmlm = tmap.getTMLModeling();
+        if (tmlm.securityTaskMap == null) {
+            return;
+        }
+        //      System.out.println(tmlm.securityTaskMap);
+        for (SecurityPattern sp : tmlm.securityTaskMap.keySet()) {
+            if (sp.type.contains("Symmetric Encryption") || sp.type.equals("MAC")) {
+                TraceManager.addDev("Adding keys for " + sp.name);
+                for (TMLTask t : tmlm.securityTaskMap.get(sp)) {
+                    ArrayList<HwMemory> mems = new ArrayList<HwMemory>();
+                    boolean keyFound = false;
+                    HwExecutionNode node1 = (HwExecutionNode) tmap.getHwNodeOf(t);
+                    //Try to find memory using only private buses
+                    List<HwNode> toVisit = new ArrayList<HwNode>();
+                    //  List<HwNode> toMemory = new ArrayList<HwNode>();
+                    List<HwNode> complete = new ArrayList<HwNode>();
+                    for (HwLink link : links) {
+                        if (link.hwnode == node1) {
+                            if (link.bus.privacy == 1) {
+                                toVisit.add(link.bus);
+                            }
+                        }
+                    }
+                    memloop:
+                    while (toVisit.size() > 0) {
+                        HwNode curr = toVisit.remove(0);
+                        for (HwLink link : links) {
+                            if (curr == link.bus) {
+                                if (link.hwnode instanceof HwMemory) {
+                                    mems.add((HwMemory) link.hwnode);
+                                    TMLArchiMemoryNode memNode = (TMLArchiMemoryNode) listE.getTG(link.hwnode);
+                                    ArrayList<TMLArchiKey> keys = memNode.getKeyList();
+                                    String patternString = "";
+                                    for (TMLArchiKey key : keys) {
+                                        if (key.getValue().equals(sp.name)) {
+
+                                            keyFound = true;
+                                            break memloop;
+                                        }
+                                        patternString += key.getValue();
+                                        patternString += " ";
+                                    }
+                                    TraceManager.addDev("Memory " + link.hwnode.getName() + " has currently mapped: " + patternString);
+                                }
+                                if (!complete.contains(link.hwnode) && !toVisit.contains(link.hwnode) && link.hwnode instanceof HwBridge) {
+                                    toVisit.add(link.hwnode);
+                                }
+                            } else if (curr == link.hwnode) {
+                                if (!complete.contains(link.bus) && !toVisit.contains(link.bus)) {
+                                    toVisit.add(link.bus);
+                                }
+                            }
+                        }
+                        complete.add(curr);
+                    }
+                    if (!keyFound) {
+                        if (mems.size() > 0) {
+                            TMLArchiMemoryNode memNode = (TMLArchiMemoryNode) listE.getTG(mems.get(0));
+                            TMLArchiKey key = new TMLArchiKey(memNode.x, memNode.y, memNode.tdp.getMinX(), memNode.tdp.getMaxX(), memNode.tdp.getMinY(), memNode.tdp.getMaxY(), false, memNode, memNode.tdp);
+                            key.setReferenceKey(sp.name);
+                            key.makeFullValue();
+                            TraceManager.addDev("Adding " + sp.name + " key to " + memNode.getName());
+                            TraceManager.addDev("Adding " + sp + " key to " + memNode.getName());
+                            memNode.tdp.addComponent(key, memNode.x, memNode.y, true, true);
+                            memNode.tdp.repaint();
+                        } else {
+                            System.out.println("Can't map key to memory for " + sp.name + " on task " + t.getName());
+                            UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Cannot map key in memory for " + sp.name + " on task " + t.getName());
+                            ce.setTDiagramPanel(tmap.getCorrespondanceList().getTG(tmap.getArch().getFirstCPU()).getTDiagramPanel());
+                            ce.setTGComponent(null);
+                            checkingErrors.add(ce);
+                        }
+                    }
+                }
+            } else if (sp.type.contains("Asymmetric Encryption")) {
+                for (TMLTask t : tmlm.securityTaskMap.get(sp)) {
+                    ArrayList<HwMemory> mems = new ArrayList<HwMemory>();
+                    boolean keyFound = false;
+                    HwExecutionNode node1 = (HwExecutionNode) tmap.getHwNodeOf(t);
+                    //Try to find memory using only private buses
+                    List<HwNode> toVisit = new ArrayList<HwNode>();
+                    //  List<HwNode> toMemory = new ArrayList<HwNode>();
+                    List<HwNode> complete = new ArrayList<HwNode>();
+                    for (HwLink link : links) {
+                        if (link.hwnode == node1) {
+                            if (link.bus.privacy == 1) {
+                                toVisit.add(link.bus);
+                            }
+                        }
+                    }
+                    memloop:
+                    while (toVisit.size() > 0) {
+                        HwNode curr = toVisit.remove(0);
+                        for (HwLink link : links) {
+                            if (curr == link.bus) {
+                                if (link.hwnode instanceof HwMemory) {
+                                    mems.add((HwMemory) link.hwnode);
+                                    TMLArchiMemoryNode memNode = (TMLArchiMemoryNode) listE.getTG(link.hwnode);
+                                    ArrayList<TMLArchiKey> keys = memNode.getKeyList();
+                                    String patternString = "";
+                                    for (TMLArchiKey key : keys) {
+                                        if (key.getValue().equals(sp.name)) {
+
+                                            keyFound = true;
+                                            break memloop;
+                                        }
+                                        patternString += key.getValue();
+                                        patternString += " ";
+                                    }
+                                    TraceManager.addDev("Memory " + link.hwnode.getName() + " has currently mapped: " + patternString);
+                                }
+                                if (!complete.contains(link.hwnode) && !toVisit.contains(link.hwnode) && link.hwnode instanceof HwBridge) {
+                                    toVisit.add(link.hwnode);
+                                }
+                            } else if (curr == link.hwnode) {
+                                if (!complete.contains(link.bus) && !toVisit.contains(link.bus)) {
+                                    toVisit.add(link.bus);
+                                }
+                            }
+                        }
+                        complete.add(curr);
+                    }
+                    if (!keyFound) {
+                        if (mems.size() > 0) {
+                            TMLArchiMemoryNode memNode = (TMLArchiMemoryNode) listE.getTG(mems.get(0));
+                            TMLArchiKey key = new TMLArchiKey(memNode.x, memNode.y, memNode.tdp.getMinX(), memNode.tdp.getMaxX(), memNode.tdp.getMinY(), memNode.tdp.getMaxY(), false, memNode, memNode.tdp);
+                            key.setReferenceKey(sp.name);
+                            key.makeFullValue();
+                            TraceManager.addDev("Adding " + sp.name + " key to " + memNode.getName());
+                            TraceManager.addDev("Adding " + sp + " key to " + memNode.getName());
+                            memNode.tdp.addComponent(key, memNode.x, memNode.y, true, true);
+                            memNode.tdp.repaint();
+                        } else {
+                            System.out.println("Can't map key to memory for " + sp.name + " on task " + t.getName());
+                            UICheckingError ce = new UICheckingError(CheckingError.STRUCTURE_ERROR, "Cannot map key in memory for " + sp.name + " on task " + t.getName());
+                            ce.setTDiagramPanel(tmap.getCorrespondanceList().getTG(tmap.getArch().getFirstCPU()).getTDiagramPanel());
+                            ce.setTGComponent(null);
+                            checkingErrors.add(ce);
+                        }
+                    }
+                }
+            }
+        }
+        TraceManager.addDev("Mapping finished");
+    }
+
+    public void generateAvatarFromTML(boolean mc, boolean security) {
+        TraceManager.addDev("Generating Avatar from TML");
+        if (tmlm != null && tmap == null) {
+            tmap = tmlm.getDefaultMapping();
+        }
+        if (avatarspec != null) {
+            return;
+        } else if (tmap != null) {
+            t2a = new TML2Avatar(tmap, mc, security);
+            TraceManager.addDev("Avatar spec generation");
+            avatarspec = t2a.generateAvatarSpec("1");
+            TraceManager.addDev("Avatar spec generation: done");
+        }
+    }
+
+    public boolean generateProVerifFromAVATAR(String _path, int _stateReachability, boolean _typed, boolean allowPrivateChannelDuplication, String loopLimit) {
+        //      System.out.println(avatarspec);
+        if (avatarspec != null) {
+            //use avspec
+        } else if (tmap != null) {
+            t2a = new TML2Avatar(tmap, false, true);
+            avatarspec = t2a.generateAvatarSpec(loopLimit);
+            drawPanel(avatarspec, mgui.getFirstAvatarDesignPanelFound());
+
+        } else if (tmlm != null) {
+            //Generate default mapping
+            tmap = tmlm.getDefaultMapping();
+
+            t2a = new TML2Avatar(tmap, false, true);
+            avatarspec = t2a.generateAvatarSpec(loopLimit);
+        } else if (avatarspec == null) {
+            return false;
+        }
+
+        avatar2proverif = new AVATAR2ProVerif(avatarspec);
+        //tml2uppaal.setChoiceDeterministic(choices);
+        //tml2uppaal.setSizeInfiniteFIFO(_size);
+        proverif = avatar2proverif.generateProVerif(true, true, _stateReachability, _typed, allowPrivateChannelDuplication);
+        warnings = avatar2proverif.getWarnings();
+        languageID = PROVERIF;
+        mgui.setMode(MainGUI.EDIT_PROVERIF_OK);
+        //uppaalTable = tml2uppaal.getRelationTIFUPPAAL(_debug);
+        try {
+            if (avatar2proverif.saveInFile(_path)) {
+                TraceManager.addDev("Specification generated in " + _path);
+                return true;
+            }
+            return false;
+        } catch (FileException fe) {
+            TraceManager.addError("Exception: " + fe.getMessage());
+            return false;
+        }
+    }
+
+    public TPN generateTPNFromAvatar() {
+        avatar2tpn = new AVATAR2TPN(avatarspec);
+        //tml2uppaal.setChoiceDeterministic(choices);
+        //tml2uppaal.setSizeInfiniteFIFO(_size);
+        tpnFromAvatar = avatar2tpn.generateTPN(true, true);
+        languageID = TPN;
+        return tpnFromAvatar;
+    }
+
+    /*IntMatrix im = tpnFromAvatar.getIncidenceMatrix();
+      TraceManager.addDev("Farkas computing on " + im.toString());
+      im.Farkas();
+      TraceManager.addDev("Farkas done:" + im.toString());
+
+
+
+      languageID = TPN;
+      //uppaalTable = tml2uppaal.getRelationTIFUPPAAL(_debug);
+      return true;
+      /*try {
+      avatar2tpn.saveInFile(_path);
+      TraceManager.addDev("Specification generated in " + _path);
+      return true;
+      } catch (FileException fe) {
+      TraceManager.addError("Exception: " + fe.getMessage());
+      return false;
+      }*/
+
+
+    public ArrayList<TGComponentAndUPPAALQuery> getUPPAALQueries() {
+        return getUPPAALQueries(mgui.getCurrentTURTLEPanel());
+    }
+
+    public ArrayList<TGComponentAndUPPAALQuery> getUPPAALQueries(TURTLEPanel tp) {
+        return getUPPAALQueries(tp, false);
+    }
+
+    public ArrayList<TGComponentAndUPPAALQuery> getUPPAALQueries(TURTLEPanel tp, boolean considerAll) {
+        TraceManager.addDev("Searching for queries on " + mgui.getTabName(tp));
+        ArrayList<TGComponent> list = new ArrayList<TGComponent>();
+        ArrayList<TClass> tclasses;
+        if (considerAll) {
+            tp.getAllCheckableTGComponent(list);
+        } else {
+            tp.getAllCheckedTGComponent(list);
+        }
+        TGComponentAndUPPAALQuery tmpQ;
+
+        ArrayList<TGComponentAndUPPAALQuery> listQ = new ArrayList<TGComponentAndUPPAALQuery>();
+
+        if (tp instanceof DesignPanel) {
+            ArrayList<ADComponent> listAD = listE.getADComponentCorrespondance(list);
+
+            //TraceManager.addDev("List size:" + listAD.size());
+
+            if (listAD == null) {
+                return null;
+            }
+
+            TClass t;
+            String s;
+            for (ADComponent adc : listAD) {
+                if (adc != null) {
+                    t = tm.findTClass(adc);
+                    //TraceManager.addDev("Found class:" + t.getName());
+                    if (t != null) {
+                        tclasses = new ArrayList<TClass>();
+                        tclasses.add(t);
+                        // For handling tobjects
+                        tm.addAllTClassesEndingWith(tclasses, "_" + t.getName());
+                        for (TClass tc : tclasses) {
+                            //TraceManager.addDev("Analyzing class:" + tc.getName());
+                            s = uppaalTIFTable.getRQuery(tc, adc);
+                            if (s != null) {
+                                //TraceManager.addDev("Adding query:" + s);
+                                tmpQ = new TGComponentAndUPPAALQuery(null, s + "$" + adc);
+                                listQ.add(tmpQ);
+                            }
+                        }
+                    }
+                }
+            }
+        } else if ((tp instanceof TMLComponentDesignPanel) || (tp instanceof TMLDesignPanel)) {
+            //TraceManager.addDev("uppaalTMLTable");
+            ArrayList<TMLActivityElement> listAE = listE.getTMLActivityElementCorrespondance(list);
+
+            if (listAE == null) {
+                return null;
+            }
+
+            TMLTask task;
+            String s;
+            for (TMLActivityElement elt : listAE) {
+                if (elt != null) {
+                    task = tmlm.findTMLTask(elt);
+                    if (task != null) {
+                        s = uppaalTMLTable.getRQuery(task, elt);
+                        if (s != null) {
+                            //TraceManager.addDev("Adding query:" + s);
+                            // Object ref;
+                            if (elt.getReferenceObject() instanceof TGComponent) {
+                                tmpQ = new TGComponentAndUPPAALQuery((TGComponent) (elt.getReferenceObject()), s + "$" + elt);
+                            } else {
+                                tmpQ = new TGComponentAndUPPAALQuery(null, s + "$" + elt);
+                            }
+                            listQ.add(tmpQ);
+                        }
+                    }
+                }
+            }
+
+        } else if ((avatar2uppaal != null) && (tp instanceof AvatarDesignPanel)) {
+            TraceManager.addDev("Making UPPAAL queries");
+            for (TGComponent tgc : list) {
+                TraceManager.addDev("Making UPPAAL query for " + tgc);
+                String s = avatar2uppaal.getUPPAALIdentification(tgc);
+                TraceManager.addDev("Query: " + s);
+                if ((s != null) && (s.length() > 0)) {
+                    AvatarBlock block = avatar2uppaal.getBlockFromReferenceObject(tgc);
+                    listQ.add(new TGComponentAndUPPAALQuery(tgc, s + "$" + block.getName() + "." + tgc));
+                } else {
+                    TraceManager.addDev("Could not make query for " + tgc);
+                }
+            }
+        } else if ((avatar2uppaal != null) && (tp instanceof AttackTreePanel)) {
+            TraceManager.addDev("Making UPPAAL queries");
+            for (TGComponent tgc : list) {
+                TraceManager.addDev("Making UPPAAL query for " + tgc);
+                String s = avatar2uppaal.getUPPAALIdentification(tgc);
+                TraceManager.addDev("Query: " + s);
+                if ((s != null) && (s.length() > 0)) {
+                    AvatarBlock block = avatar2uppaal.getBlockFromReferenceObject(tgc);
+                    listQ.add(new TGComponentAndUPPAALQuery(tgc, s + "$" + block.getName() + "." + tgc));
+                } else {
+                    TraceManager.addDev("Could not make query for " + tgc);
+                }
+            }
+        } else if ((avatar2uppaal != null) && (tp instanceof FaultTreePanel)) {
+            TraceManager.addDev("Making UPPAAL queries");
+            for (TGComponent tgc : list) {
+                TraceManager.addDev("Making UPPAAL query for " + tgc);
+                String s = avatar2uppaal.getUPPAALIdentification(tgc);
+                TraceManager.addDev("Query: " + s);
+                if ((s != null) && (s.length() > 0)) {
+                    AvatarBlock block = avatar2uppaal.getBlockFromReferenceObject(tgc);
+                    listQ.add(new TGComponentAndUPPAALQuery(tgc, s + "$" + block.getName() + "." + tgc));
+                } else {
+                    TraceManager.addDev("Could not make query for " + tgc);
+                }
+            }
+        }
+
+
+        return listQ;
+    }
+
+    public List<String> generateLOTOSAUT(String path) {
+        TML2AUTviaLOTOS tml2aut = new TML2AUTviaLOTOS(tmlm, tm);
+        tml2aut.generateLOTOS(true);
+        return tml2aut.getSpecs();
+        /*try {
+          return tml2aut.saveInFiles(path);
+          } catch (FileException fe) {
+          return null;
+          }*/
+    }
+
+    public void generateSystemC() {
+        String path = ConfigurationTTool.SystemCCodeDirectory;
+        String list = FileUtils.deleteFiles(path, ".cpp");
+        if (list.length() == 0) {
+            TraceManager.addDev("No cpp files were deleted\n");
+        } else {
+            TraceManager.addDev("Files deleted:\n" + list + "\n");
+        }
+
+        list = FileUtils.deleteFiles(path, ".x");
+
+        if (list.length() == 0) {
+            TraceManager.addDev("No x files were deleted\n");
+        } else {
+            TraceManager.addDev("Files deleted:\n" + list + "\n");
+        }
+
+        TML2SystemC tml2systc = new TML2SystemC(tmlm);
+        tml2systc.generateSystemC(true);
+        //tml2systc.print();
+        try {
+            tml2systc.saveFile(path, "appmodel");
+        } catch (FileException fe) {
+            TraceManager.addError("File could not be saved (SystemC)");
+        }
+
+    }
+
+
+    public void saveSIM(File f) {
+        if ((sim != null) && (f != null)) {
+            saveInFile(f, sim);
+        }
+    }
+
+    public void saveDTA(File f) {
+        if ((dta != null) && (f != null)) {
+            saveInFile(f, dta);
+        }
+    }
+
+    public void saveDTADOT(File f) {
+        if ((dtadot != null) && (f != null)) {
+            saveInFile(f, dtadot);
+        }
+    }
+
+    public void saveRG(File f) {
+        if ((rg != null) && (f != null)) {
+            saveInFile(f, rg);
+        }
+    }
+
+    public void saveTLSA(File f) {
+        if ((rg != null) && (f != null)) {
+            saveInFile(f, tlsa);
+        }
+    }
+
+    public void saveRGAut(File f) {
+        if ((rgaut != null) && (f != null)) {
+            saveInFile(f, rgaut);
+        }
+    }
+
+    public void saveRGDOT(File f) {
+        if ((rgdot != null) && (f != null)) {
+            saveInFile(f, rgdot);
+        }
+    }
+
+    public void saveTLSADOT(File f) {
+        if ((rgdot != null) && (f != null)) {
+            saveInFile(f, tlsadot);
+        }
+    }
+
+    public void saveRGAutDOT(File f) {
+        if ((rgautdot != null) && (f != null)) {
+            saveInFile(f, rgautdot);
+        }
+    }
+
+    public void saveRGAutProj(File f) {
+        if ((rgautproj != null) && (f != null)) {
+            saveInFile(f, rgautproj);
+        }
+    }
+
+    public void saveRGAutProjDOT(File f) {
+        if ((rgautprojdot != null) && (f != null)) {
+            saveInFile(f, rgautprojdot);
+        }
+    }
+
+    public void modifyMinimizedGraph() {
+        /*AUTMappingGraph graph = new AUTMappingGraph();
+          TraceManager.addDev("Building graph");
+          graph.buildGraph(rgautproj);
+          TraceManager.addDev("Renaming transitions");
+          graph.renameTransitions();
+          TraceManager.addDev("Merging transitions 23/4=" + (23/4) + "23%4="  + (23%4));
+          graph.mergeWriteTransitions();
+          graph.mergeReadTransitions();
+          graph.removeInternalTransitions();
+          TraceManager.addDev("Printing graph:\n" + graph.toAUTStringFormat());
+          TraceManager.addDev("Splitting transitions");
+          graph.splitTransitions();
+          modifiedaut = graph.toAUTStringFormat();
+          TraceManager.addDev("Printing graph:\n" + modifiedaut);
+          TraceManager.addDev("Translation in DOT format");
+
+          // AUT  2 dot
+          String fileName = "graph";
+          try {
+          RshClient rshc = new RshClient(getHostAldebaran());
+          int id = rshc.getId();
+          fileName = FileUtils.addBeforeFileExtension(fileName, "_" + id);
+          String data = rgautproj;
+          rshc.sendFileData(fileName + ".aut", data);
+          String cmd1 = getPathBcgio() + " -aldebaran " + fileName + ".aut" + " -graphviz " + fileName + ".dot";
+          data = processCmd(rshc, cmd1);
+          data = rshc.getFileData(fileName + ".dot");
+          modifiedautdot = data;
+          TraceManager.addDev("All done");
+          } catch (LauncherException le) {
+          TraceManager.addDev("Error: conversion failed");
+          }*/
+    }
+
+    protected String processCmd(RshClient rshc, String cmd) throws LauncherException {
+        rshc.setCmd(cmd);
+        String s = null;
+        rshc.sendExecuteCommandRequest();
+        s = rshc.getDataFromProcess();
+        return s;
+    }
+
+    public void showSIM(int type) {
+        if (sim != null) {
+            JFrameSimulationTrace jfst = new JFrameSimulationTrace("Last simulation trace", sim, type);
+            jfst.setIconImage(IconManager.img8);
+            //  jfst.setSize(900, 600);
+            GraphicLib.centerOnParent(jfst, 900, 600);
+            jfst.setVisible(true);
+        }
+    }
+
+    public String showDTA() {
+        if (dta != null) {
+            return runDOTTY(dtadot);
+        }
+        return null;
+    }
+
+    public String showRG() {
+        if (rg != null) {
+            return runDOTTY(rgdot);
+        }
+        return null;
+    }
+
+    public String showTLSA() {
+        if (rg != null) {
+            return runDOTTY(tlsadot);
+        }
+        return null;
+    }
+
+    public String showRGAut() {
+        if (rgaut != null) {
+            return runDOTTY(rgautdot);
+        }
+        return null;
+    }
+
+    public String showRGDiplodocus() {
+        //TraceManager.addDev("Show diplodocus graph located in " + ConfigurationTTool.GGraphPath + "/tree.dot");
+        RemoteExecutionThread ret = new RemoteExecutionThread(ConfigurationTTool.DOTTYHost, null, null, ConfigurationTTool.DOTTYPath + " " + SpecConfigTTool.GGraphPath + "/tree.dot");
+        ret.start();
+        return null;
+    }
+
+    public String showRGAutProj() {
+        if (rgaut != null) {
+            return runDOTTY(rgautprojdot);
+        }
+        return null;
+    }
+
+    public static String showGGraph(String ggraph) {
+        if (ggraph != null) {
+            return runDOTTY(ggraph);
+        }
+        return null;
+    }
+
+    public static String runDOTTY(String data) {
+        String fileName = "graph" + graphId + ".dot";
+        graphId++;
+
+        RemoteExecutionThread ret = new RemoteExecutionThread(ConfigurationTTool.DOTTYHost, fileName, data, ConfigurationTTool.DOTTYPath + " " + fileName);
+        ret.start();
+
+        return null;
+    }
+
+    public boolean useDynamicStructure(String data) {
+        int index1 = data.indexOf("behaviour");
+        if (index1 == -1) {
+            return false;
+        }
+
+        data = data.substring(index1, data.length());
+
+        return (data.indexOf("Queue_nat") != -1);
+
+    }
+
+    public void saveInFile(File file, String s) {
+        TraceManager.addDev("Saving in file " + file.getAbsolutePath() + " size of file=" + s.length());
+        //TraceManager.addDev("Length of s=" + s.length());
+
+        int index1 = 0, index2;
+        int step = 1048576;
+        int length = s.length();
+        //String sub;
+
+        try {
+            FileOutputStream fos = new FileOutputStream(file);
+            while (index1 < length) {
+                index2 = Math.min(index1 + step, length);
+                fos.write(s.substring(index1, index2).getBytes());
+                index1 += step;
+            }
+            fos.close();
+        } catch (Exception e) {
+            JOptionPane.showMessageDialog(mgui.frame, "Specification could not be saved " + e.getMessage(), "Lotos File Error", JOptionPane.INFORMATION_MESSAGE);
+            TraceManager.addError("Specification could not be saved " + e.getMessage());
+        }
+
+        /*try {
+          FileOutputStream fos = new FileOutputStream(file);
+          fos.write(s.getBytes());
+          fos.close();
+          } catch(Exception e) {
+          JOptionPane.showMessageDialog(mgui.frame, "Specification could not be saved " + e.getMessage(), "Lotos File Error", JOptionPane.INFORMATION_MESSAGE);
+          TraceManager.addDev("Specification could not be saved " + e.getMessage());
+          }*/
+    }
+
+    public String getLastRTLOTOSSpecification() {
+        return rtlotos;
+    }
+
+    public String getLastTextualDTA() {
+        return dta;
+    }
+
+    public String getLastGraphicalDTA() {
+        return dtadot;
+    }
+
+    public String getLastTextualRG() {
+        return rg;
+    }
+
+    public String getLastGraphicalRG() {
+        return rgdot;
+    }
+
+    public String getLastTextualTLSA() {
+        return tlsa;
+    }
+
+    public String getLastGraphicalTLSA() {
+        return tlsadot;
+    }
+
+    public String getLastTextualRGAUT() {
+        return rgaut;
+    }
+
+    public String getLastGraphicalRGAUT() {
+        return rgautdot;
+    }
+
+    public String getLastTextualRGAUTProj() {
+        return rgautproj;
+    }
+
+    public String getLastGraphicalRGAUTProj() {
+        return rgautprojdot;
+    }
+
+    public String getLastProVerifSpecification() {
+        if (proverif == null) {
+            return "";
+        }
+
+        return proverif.getStringSpec();
+    }
+
+    public int getNbRTLOTOS() {
+        return nbRTLOTOS;
+    }
+
+    public String getLastTextualDesign() {
+        if (tm == null) {
+            return "";
+        } else {
+            return tm.printToStringBuffer().toString();
+        }
+    }
+
+    public int getNbSuggestedDesign() {
+        return nbSuggestedDesign;
+    }
+
+    // formal validation
+    public void reinitSIM() {
+        sim = null;
+        mgui.setMode(MainGUI.SIM_KO);
+    }
+
+    public void reinitDTA() {
+        dta = null;
+        dtadot = null;
+        mgui.setMode(MainGUI.DTADOT_KO);
+    }
+
+    public void reinitRG() {
+        rg = null;
+        rgdot = null;
+        mgui.setMode(MainGUI.RGDOT_KO);
+    }
+
+    public void reinitRGAUT() {
+        rgaut = null;
+        rgautdot = null;
+        mgui.setMode(MainGUI.RGAUTDOT_KO);
+        mgui.setMode(MainGUI.RGAUT_KO);
+    }
+
+    public void reinitRGAUTPROJDOT() {
+        rgautprojdot = null;
+        mgui.setMode(MainGUI.RGAUTPROJDOT_KO);
+    }
+
+    public void setSIM(String data) {
+        sim = data;
+        mgui.setMode(MainGUI.SIM_OK);
+    }
+
+    public void setDTA(String data) {
+        dta = data;
+    }
+
+    public void setDTADOT(String data) {
+        dtadot = data;
+        mgui.setMode(MainGUI.DTADOT_OK);
+    }
+
+    public void setRG(String data) {
+        rg = data;
+        mgui.setMode(MainGUI.RGDOT_OK);
+    }
+
+    public void setTLSA(String data) {
+        tlsa = data;
+        //mgui.setMode(MainGUI.TLSADOT_OK);
+    }
+
+    public void setTLSADOT(String data) {
+        tlsadot = data;
+        mgui.setMode(MainGUI.TLSADOT_OK);
+    }
+
+    public void setRGAut(String data) {
+        rgaut = data;
+        mgui.setMode(MainGUI.RGAUT_OK);
+    }
+
+    public String getLastRGAUT() {
+        return rgaut;
+    }
+
+    public void setRGDOT(String data) {
+        rgdot = data;
+        mgui.setMode(MainGUI.RGDOT_OK);
+    }
+
+    public void setRGAutDOT(String data) {
+        rgautdot = data;
+        mgui.setMode(MainGUI.RGAUTDOT_OK);
+    }
+
+    public void setRGAUTPROJ(String data) {
+        rgautproj = data;
+    }
+
+    public void setRGAUTPROJDOT(String data) {
+        rgautprojdot = data;
+        mgui.setMode(MainGUI.RGAUTPROJDOT_OK);
+    }
+
+    // Configuration
+
+    public String getPathRTL() {
+        return ConfigurationTTool.RTLPath;
+    }
+
+    public String getPathCaesar() {
+        return ConfigurationTTool.CaesarPath;
+    }
+
+    public String getPathCaesarOpen() {
+        return ConfigurationTTool.CaesarOpenPath;
+    }
+
+    public String getPathDTA2DOT() {
+        return ConfigurationTTool.DTA2DOTPath;
+    }
+
+    public String getPathRGSTRAP() {
+        return ConfigurationTTool.RGSTRAPPath;
+    }
+
+    public String getPathRG2TLSA() {
+        return ConfigurationTTool.RG2TLSAPath;
+    }
+
+    public String getHost() {
+        return ConfigurationTTool.RTLHost;
+    }
+
+    public static String getCaesarHost() {
+        return ConfigurationTTool.AldebaranHost;
+    }
+
+    public static String getHostAldebaran() {
+        return ConfigurationTTool.AldebaranHost;
+    }
+
+    public static String getPathAldebaran() {
+        return ConfigurationTTool.AldebaranPath;
+    }
+
+    public static String getPathBcgio() {
+        return ConfigurationTTool.BcgioPath;
+    }
+
+    public static String getPathBisimulator() {
+        return ConfigurationTTool.BisimulatorPath;
+    }
+
+    public String getPathBcgmerge() {
+        return ConfigurationTTool.BcgmergePath;
+    }
+
+    public String getPathBcgmin() {
+        return ConfigurationTTool.BcgminPath;
+    }
+
+    public String getPathVerifyta() {
+        return ConfigurationTTool.UPPAALVerifierPath;
+    }
+
+    public String getPathUPPAALVerifier() {
+        return ConfigurationTTool.UPPAALVerifierPath;
+    }
+
+    public String getPathUPPAALFile() {
+        return SpecConfigTTool.UPPAALCodeDirectory;
+    }
+
+    public String getUPPAALVerifierHost() {
+        return ConfigurationTTool.UPPAALVerifierHost;
+    }
+
+
+    public TURTLEModeling getTURTLEModeling() {
+        return tm;
+    }
+
+    public int getTURTLEModelingState() {
+        return tmState;
+    }
+
+    public TMLModeling<TGComponent> getTMLModeling() {
+        return tmlm;
+    }
+
+    public TML2Avatar getTML2Avatar() {
+        return t2a;
+    }
+
+    public TMLMapping<TGComponent> getArtificialTMLMapping() {
+        return artificialtmap;
+    }
+
+    public TMLMapping<TGComponent> getTMLMapping() {
+        return tmap;
+    }
+
+    public UPPAALSpec getLastUPPAALSpecification() {
+        return uppaal;
+    }
+
+    // TREE MANAGEMENT
+    public void expandToErrors() {
+        if ((mcvdt != null) && (checkingErrors != null) && (checkingErrors.size() > 0)) {
+            SyntaxAnalysisErrorTree saet = mcvdt.getSyntaxAnalysisErrorTree();
+            if (saet != null) {
+                Object[] obj = new Object[3];
+                obj[0] = mgui.dtree.getModel().getRoot();
+                obj[1] = mcvdt;
+                obj[2] = saet;
+                TraceManager.addDev("Expanding Path because of errors");
+                mgui.dtree.expandMyPath(new TreePath(obj));
+                mgui.dtree.forceUpdate();
+            }
+        }
+    }
+
+    public void expandToWarnings() {
+        if ((mcvdt != null) && (warnings != null) && (warnings.size() > 0)) {
+            SyntaxAnalysisWarningTree sawt = mcvdt.getSyntaxAnalysisWarningTree();
+            if (sawt != null) {
+                Object[] obj = new Object[3];
+                obj[0] = mgui.dtree.getModel().getRoot();
+                obj[1] = mcvdt;
+                obj[2] = sawt;
+                TraceManager.addDev("Expanding Path because of warnings");
+                mgui.dtree.expandMyPath(new TreePath(obj));
+                mgui.dtree.forceUpdate();
+            }
+        }
+    }
+
+    public void expandToGraphs() {
+        if ((gt != null) && (graphs != null) && (graphs.size() > 0)) {
+            Object[] obj = new Object[2];
+            obj[0] = mgui.dtree.getModel().getRoot();
+            obj[1] = gt;
+            TraceManager.addDev("Expanding Path because of graphs");
+            mgui.dtree.expandMyPath(new TreePath(obj));
+            mgui.dtree.forceUpdate();
+
+        }
+    }
+
+    public String toString() {
+        return mgui.getTitle();
+    }
+
+    public int getChildCount() {
+        return panels.size() + 4;
+    }
+
+    public Object getChild(int index) {
+        if (index < panels.size()) {
+            return panels.elementAt(index);
+        } else if (index == panels.size()) {
+            return mcvdt;
+        } else if (index == (panels.size() + 1)) {
+            return gt;
+        } else if (index == (panels.size() + 2)) {
+            return idt;
+        } else {
+            return st;
+        }
+    }
+
+    public int getIndexOfChild(Object child) {
+        int index = panels.indexOf(child);
+
+        if (index > -1) {
+            return index;
+        }
+
+        if (child == mcvdt) {
+            return panels.size();
+        }
+
+        if (child == gt) {
+            return panels.size() + 1;
+        }
+
+        if (child == idt) {
+            return panels.size() + 2;
+        }
+
+        return panels.size() + 3;
+    }
+
+    // Projection management
+
+    public MasterGateManager getNewMasterGateManager() {
+        return new MasterGateManager(tm);
+    }
+
+    // Assume the inputData is in AUT format: generated by RTL or CADP
+    public String performProjection(String inputData, LinkedList<TClassAndGateDS> gates) {
+        StringBuffer result = new StringBuffer("");
+        StringReader sr = new StringReader(inputData);
+        BufferedReader br = new BufferedReader(sr);
+        String s;
+        String actionName, actionName1;
+        int index, index1, index2;
+        MasterGateManager mgm = new MasterGateManager(tm, 1);
+        //   Gate g;
+        GroupOfGates gog;
+        Hashtable<String, GroupOfGates> hashtable = new Hashtable<String, GroupOfGates>();
+
+        //   int cpt = 0;
+
+        //TraceManager.addDev("input data=" + inputData);
+
+        // Fill Hashtable
+        // int j;
+        for (TClassAndGateDS tag : gates) {
+            //TraceManager.addDev("TClass:" + tag.getTClassName() + " Gate:" + tag.getGateName());
+            //actionName = tag.getGateName();
+            //g = mgm.getGate(tag.getTClassName(), actionName);
+            //TraceManager.addDev("actionName = " + actionName + " gateName = " + g.getName());
+            //if (g != null) {
+            //gog = mgm.getGroupOfGatesByGate(g);
+            gog = mgm.groupOf(tag.getTClassName(), tag.getGateName());
+            if (gog != null) {
+                //TraceManager.addDev("Found a gog: >" + gog.getMasterGateName() + "<");
+                hashtable.put(gog.getMasterGateName().getName(), gog);
+                /*for(j=0;j<gog.size();j++) {
+                  g = gog.getGateAt(j);
+                  TraceManager.addDev("Putting: " + g.getName());
+                  hashtable.put(g.getName(), g);
+                  }*/
+            }
+            //}
+        }
+
+        try {
+            while ((s = br.readLine()) != null) {
+                /*if (cpt % 10000 == 0) {
+                  TraceManager.addDev("cpt=" + cpt);
+                  }*/
+                //   cpt ++;
+
+                if (s.startsWith("des")) {
+                    result.append(s + "\n");
+                } else if (s.startsWith("(")) {
+                    index = s.indexOf("\"t\"");
+                    if (index > 0) {
+                        // temporal action
+                        // replace t with i
+                        s = s.replaceAll("\"t\"", "i");
+                        result.append(s + "\n");
+                    } else {
+                        //exit action?
+                        index = s.indexOf("\"exit\"");
+                        if (index > 0) {
+                            // exit action
+                            // replace t with i
+                            s = s.replaceAll("\"exit\"", "i");
+                            result.append(s + "\n");
+                        } else {
+                            // regular action
+                            // find the name of this action
+                            index1 = s.indexOf("i(");
+                            index2 = s.indexOf(")");
+                            actionName = s.substring(index1 + 2, index2);
+                            index = actionName.indexOf("<");
+                            if (index < 0) {
+                                actionName1 = actionName;
+                            } else {
+                                actionName1 = actionName.substring(0, index);
+                            }
+                            TraceManager.addDev("Action = >" + actionName1 + "<");
+
+                            gog = hashtable.get(actionName1);
+                            if (gog == null) {
+                                TraceManager.addDev("Not in hash");
+                                result.append(makeIAction(s) + "\n");
+                            } else {
+                                TraceManager.addDev("In hash");
+                                result.append(makeAction(s, actionName) + "\n");
+                            }
+
+                            // action to ignored or to project ?
+                            /*g = mgm.getGate(actionName1);
+                              if (g == null) {
+                              //TraceManager.addDev("null1");
+                              result.append(makeIAction(s) + "\n");
+                              } else {
+                              gog = mgm.getGroupOfGatesByGate(g);
+                              if (gog == null) {
+                              //TraceManager.addDev("null2");
+                              result.append(makeIAction(s) + "\n");
+                              } else {
+                              if (!belongTo(gog, gates)) {
+                              // Check if directly a master Gate!
+                              // A completer ...
+                              //TraceManager.addDev("null3");
+                              result.append(makeIAction(s) + "\n");
+                              } else {
+                              //TraceManager.addDev("action added: " + actionName);
+                              result.append(makeAction(s, actionName) + "\n");
+                              }
+                              }
+                              }*/
+                        }
+
+                    }
+                }
+            }
+        } catch (Exception e) {
+            TraceManager.addError("Exception during projection" + e.getMessage());
+            return null;
+        }
+        return new String(result);
+    }
+
+    // Assume the inputData is in AUT format and has been generated by CADP
+    // Note: might not work because of case sensitive problem...
+    public String convertCADP_AUT_to_RTL_AUT(String inputData, int max) {
+        StringBuffer result = new StringBuffer("");
+        StringReader sr = new StringReader(inputData);
+        BufferedReader br = new BufferedReader(sr);
+        String s, s1;
+        String actionName;
+        int index1, index2, index3, index4;
+        Gate g;
+        String g0, g1, g2;
+        int cpt, transi = 0;
+        MasterGateManager mgm = new MasterGateManager(tm, 1);
+        Map<String, Gate> ht = mgm.getGatesUpperCaseHashTable();
+        warnings = new LinkedList<CheckingError>();
+
+        //TraceManager.addDev("input data=" + inputData);
+
+        //   int cpt1 = 0;
+
+        try {
+            while ((s = br.readLine()) != null) {
+                //   cpt1 ++;
+                //if (cpt1 % 100000 == 0) {
+                //TraceManager.addDev("=" + cpt1 + " / " + transi);
+                //}
+                if (s.charAt(0) == '(') {
+                    index1 = s.indexOf(",");
+                    if ((index1 > -1) && ((index1 + 1) < s.length())) {
+                        g1 = s.substring(0, index1 + 1);
+                        s = s.substring(index1 + 1, s.length());
+
+                        //TraceManager.addDev("g1=" + g1 + " s=" + s);
+
+                        index2 = s.indexOf(",");
+                        if ((index2 > -1) && ((index2 + 1) < s.length())) {
+                            g2 = s.substring(index2, s.length());
+                            s = s.substring(0, index2);
+                            s = s.trim();
+
+                            //TraceManager.addDev("g2=" + g2 + " s=" + s);
+
+                            // Get action id
+                            // Most common case: no data
+                            index3 = s.indexOf('"');
+                            if (index3 == -1) { // no data
+                                actionName = s;
+                                g0 = "";
+                            } else {
+                                // Extract action name
+                                actionName = s.substring(index3 + 1, s.indexOf('!')).trim();
+
+                                // Format data
+                                g0 = "<";
+                                cpt = 0;
+                                while ((index4 = s.indexOf('!')) > -1) {
+                                    s = s.substring(index4 + 1, s.length());
+                                    if (cpt > 0) {
+                                        g0 += ",";
+                                    }
+                                    cpt++;
+                                    index4 = s.indexOf('!');
+                                    if (index4 > -1) {
+                                        g0 += s.substring(0, index4);
+                                    } else {
+                                        g0 += s.substring(0, s.indexOf('"')).trim();
+                                    }
+                                }
+                                g0 += ">";
+                            }
+
+                            // Working on action name!
+                            //g = mgm.getGateLowerCase(actionName);
+                            g = ht.get(actionName);
+
+                            if (g != null) {
+                                //actionName1 = actionName;
+                                actionName = g.getName();
+                                //TraceManager.addDev("actionName = " + g.getName());
+                                /*if (mgm.nbOfPossibleGatesLowerCase(actionName1) > 1) {
+                                  CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Action " + actionName1 + " has several possible candidates ; " + actionName + " has been chosen");
+                                  warnings.add(ce);
+                                  }*/
+                            } else {
+                                TraceManager.addDev("actionName is not in hashtable: ->" + actionName + "<- length=" + actionName.length());
+                            }
+
+                            // Store result
+                            result.append(g1 + "\"i(" + actionName + g0 + ")\"" + g2 + "\n");
+                        }
+                    }
+                } else if (s.startsWith("des")) {
+                    index1 = s.indexOf(",");
+                    s1 = s.substring(index1 + 1, s.length());
+                    index1 = s1.indexOf(",");
+                    s1 = s1.substring(0, index1).trim();
+                    //TraceManager.addDev("nb of transitions=" + s);
+                    transi = Integer.decode(s1).intValue();
+                    if (transi > max) {
+                        return null;
+                    }
+                    result.append(s + "\n");
+                }
+            }
+        } catch (Exception e) {
+            TraceManager.addError("Exception convert0" + e.getMessage());
+            return null;
+        }
+        return new String(result);
+    }
+
+
+    public boolean belongTo(GroupOfGates gog, Vector<TClassAndGateDS> gates) {
+        int i, j;
+        TClassAndGateDS tcg;
+        String nameTClass, nameGate;
+        for (i = 0; i < gog.size(); i++) {
+            nameTClass = gog.getTClassAt(i).getName();
+            nameGate = gog.getGateAt(i).getName();
+            for (j = 0; j < gates.size(); j++) {
+                tcg = gates.elementAt(j);
+
+                if ((tcg.getTClassName().compareTo(nameTClass) == 0) && (tcg.getGateName().compareTo(nameGate) == 0)) {
+                    //TraceManager.addDev("Projected gate");
+                    return true;
+                }
+            }
+
+        }
+        return false;
+
+    }
+
+    public String makeIAction(String s) {
+        int index1, index2;
+        index1 = s.indexOf("i(");
+        index2 = s.indexOf(")");
+        return s.substring(0, index1 - 1) + "i" + s.substring(index2 + 2, s.length());
+    }
+
+    public String makeAction(String s, String actionName) {
+        int index1, index2;
+        index1 = s.indexOf("i(");
+        index2 = s.indexOf(")");
+        return s.substring(0, index1) + actionName + s.substring(index2 + 1, s.length());
+    }
+
+    public void enableUndo(boolean b) {
+        undoRunning = !b;
+    }
+
+    public boolean isUndoEnable() {
+        return !undoRunning;
+    }
+
+    // UNDO MANAGEMENT
+
+    // This function is not be performed when executing an undo
+    // if variable undoRunnin has been set to true
+    public void saveOperation(Point p) {
+        if (undoRunning) {
+            return;
+        }
+
+        //TraceManager.addDev("Save operation");
+
+        String s = makeXMLFromTurtleModeling(-1);
+
+        if ((pointerOperation > -1) && (pointerOperation < savedOperations.size() - 1)) {
+            // some save operations must be erased
+            for (int i = pointerOperation + 1; i < savedOperations.size(); i++) {
+                savedOperations.removeElementAt(i);
+                savedPanels.removeElementAt(i);
+                i--;
+            }
+        }
+
+        // save actions on tab
+        int size = savedPanels.size();
+        if (size > 0) {
+            Point p1 = savedPanels.elementAt(size - 1); // panels are saved under the form of a point -> x = analysis/design, y = panel
+            if (p == null)
+                p = p1;
+            /*if ((p1.x != p.x) || (p1.y != p.y)){
+              savedOperations.add(savedOperations.elementAt(size - 1));
+              savedPanels.add(p);
+              if (savedOperations.size() > nbMaxSavedOperations) {
+              savedOperations.removeElementAt(0);
+              savedPanels.removeElementAt(0);
+              }
+              }*/
+        }
+
+        savedOperations.add(s);
+        savedPanels.add(p);
+        if (savedOperations.size() > nbMaxSavedOperations) {
+            savedOperations.removeElementAt(0);
+            savedPanels.removeElementAt(0);
+        }
+        pointerOperation = savedOperations.size() - 1;
+        //TraceManager.addDev("Setting pointer to " + pointerOperation);
+
+        selectBackwardMode();
+    }
+
+    public void backward() {
+        undoRunning = true;
+        TraceManager.addDev("Nb Of saved operations:" + savedOperations.size() + " pointer=" + pointerOperation);
+        if ((pointerOperation < 1) || (savedOperations.size() < 2)) {
+            TraceManager.addDev("Undo not possible");
+            undoRunning = false;
+            return;
+        }
+
+        removeAllComponents();
+        mgui.reinitMainTabbedPane();
+
+        // Issue #42: the selected tabs should be memorized before decrementing the pointer
+        final Point prevSelectedTabs = savedPanels.elementAt(pointerOperation);
+
+        try {
+            pointerOperation--;
+            TraceManager.addDev("Decrementing pointer =" + pointerOperation);
+            loadModelingFromXML(savedOperations.elementAt(pointerOperation));
+
+        } catch (Exception e) {
+            TraceManager.addError("Exception in backward: " + e.getMessage());
+        }
+
+        TraceManager.addDev("Selecting tab");
+
+        // Issue #42:
+        //Point p = savedPanels.elementAt(pointerOperation);
+
+        if (prevSelectedTabs != null) {
+            TraceManager.addDev("Selecting tab panel=" + prevSelectedTabs.getX() + " diagram=" + prevSelectedTabs.getY());
+            TDiagramPanel tdp = mgui.selectTab(prevSelectedTabs);
+            tdp.mode = TDiagramPanel.NORMAL;
+            tdp.setDraw(true);
+            tdp.repaint();
+        }
+
+        TraceManager.addDev("Selecting backward mode");
+        selectBackwardMode();
+        undoRunning = false;
+    }
+
+    public void selectBackwardMode() {
+        if (pointerOperation < 0) {
+            mgui.setMode(MainGUI.NO_BACKWARD);
+            mgui.setMode(MainGUI.NO_FORWARD);
+        } else {
+
+            // forward
+            if (pointerOperation < savedOperations.size() - 1) {
+                mgui.setMode(MainGUI.FORWARD);
+            } else {
+                mgui.setMode(MainGUI.NO_FORWARD);
+            }
+
+            // backward
+            if (pointerOperation > 0) {
+                mgui.setMode(MainGUI.BACKWARD);
+            } else {
+                mgui.setMode(MainGUI.NO_BACKWARD);
+            }
+        }
+    }
+
+
+    public void forward() {
+        if ((pointerOperation < 0) || (pointerOperation > savedOperations.size() - 2)) {
+            return;
+        }
+
+        undoRunning = true;
+        removeAllComponents();
+        mgui.reinitMainTabbedPane();
+
+        // Issue #42: the selected tabs should be memorized before incrementing the pointer
+        final Point prevSelectedTabs = savedPanels.elementAt(pointerOperation);
+
+        try {
+            pointerOperation++;
+            loadModelingFromXML(savedOperations.elementAt(pointerOperation));
+        } catch (Exception e) {
+            TraceManager.addError("Exception in forward: " + e.getMessage());
+        }
+
+        //Point prevSelectedTabs = savedPanels.elementAt(pointerOperation);
+        if (prevSelectedTabs != null) {
+            TDiagramPanel tdp = mgui.selectTab(prevSelectedTabs);
+            tdp.mode = TDiagramPanel.NORMAL;
+            tdp.setDraw(true);
+            tdp.repaint();
+        }
+
+        selectBackwardMode();
+        undoRunning = false;
+    }
+
+
+    // BUILDING A TURTLE MODELING AND CHECKING IT
+    public boolean checkTURTLEModeling(LinkedList<TClassInterface> tclasses, DesignPanel dp, boolean overideSyntaxChecking) {
+        // Builds a TURTLE modeling from diagrams
+        //warnings = new Vector();
+        //checkingErrors = null;
+        mgui.setMode(MainGUI.VIEW_SUGG_DESIGN_KO);
+        //tm = new TURTLEModeling();
+        //listE = new CorrespondanceTGElement();
+        mgui.reinitCountOfPanels();
+
+        DesignPanelTranslator dpt = new DesignPanelTranslator(dp);
+        tm = dpt.generateTURTLEModeling(tclasses, "");
+        tmState = 0;
+
+        listE = dpt.getCorrespondanceTGElement();
+        checkingErrors = dpt.getErrors();
+        warnings = dpt.getWarnings();
+        if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+            return false;
+        }
+
+        // modeling is built
+        // Now check it !
+        if (!overideSyntaxChecking) {
+            TURTLEModelChecker tmc = new TURTLEModelChecker(tm, listE);
+
+            checkingErrors = tmc.syntaxAnalysisChecking();
+            warnings.addAll(tmc.getWarnings());
+
+            if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+                analyzeErrors();
+                return false;
+            } else {
+                return true;
+            }
+        }
+
+        return true;
+    }
+
+    // BUILDING An AVATAR Design AND CHECKING IT
+    public boolean checkAvatarDesign(LinkedList<AvatarBDStateMachineOwner> blocks, AvatarDesignPanel adp, boolean _optimize) {
+        // Builds a TURTLE modeling from diagrams
+        //warnings = new Vector();
+        //checkingErrors = null;
+        mgui.setMode(MainGUI.VIEW_SUGG_DESIGN_KO);
+        //tm = new TURTLEModeling();
+        //listE = new CorrespondanceTGElement();
+        mgui.reinitCountOfPanels();
+
+        //avatarspec = new AvatarSpecification("avatarspecification", adp);
+
+        AvatarDesignPanelTranslator adpt = new AvatarDesignPanelTranslator(adp);
+        avatarspec = adpt.generateAvatarSpecification(blocks);
+        avatarspec.setInformationSource(adp);
+        optimizeAvatar = _optimize;
+        //TraceManager.addDev("AvatarSpec:" + avatarspec.toString() + "\n\n");
+        tmState = 3;
+
+        listE = adpt.getCorrespondanceTGElement();
+        checkingErrors = adpt.getErrors();
+        warnings = adpt.getWarnings();
+        return !((checkingErrors != null) && (checkingErrors.size() > 0));
+
+        // Modeling is built
+        // Now check it !
+        /*if (!overideSyntaxChecking) {
+          TURTLEModelChecker tmc = new TURTLEModelChecker(tm, listE);
+
+          checkingErrors = tmc.syntaxAnalysisChecking();
+          warnings.addAll(tmc.getWarnings());
+
+          if ((checkingErrors != null) && (checkingErrors.size() > 0)){
+          analyzeErrors();
+          return false;
+          } else {
+          return true;
+          }
+          }
+
+          return true;*/
+    }
+
+    // Return values
+    // -1: error
+    // -2: no mutex
+    // -3: invariant for mutex not found
+    // else: invariant found! -> invariant index
+    public int computeMutex() {
+        if (avatarspec == null) {
+            return -1;
+        }
+
+        AvatarDesignPanel adp = null;
+
+        try {
+            adp = (AvatarDesignPanel) (avatarspec.getInformationSource());
+        } catch (Exception e) {
+            TraceManager.addDev("Exception gtm: " + e.getMessage());
+            return -1;
+        }
+
+        // Building the list of all states in the mutex
+        LinkedList<TGComponent> compInMutex = adp.getListOfComponentsInMutex();
+        TraceManager.addDev("Nb of elements in mutex:" + compInMutex.size());
+
+        if (compInMutex.size() == 0) {
+            return -2;
+        }
+
+        LinkedList<TGComponent> comps;
+        boolean found;
+        int nbOfFound;
+        int cpt = 0;
+        // Go thru invariants, and see whether one contains
+        for (Invariant inv : invariants) {
+            comps = inv.getComponents();
+            nbOfFound = 0;
+            for (TGComponent tgc_mutex : compInMutex) {
+                found = false;
+                for (TGComponent tgc_inv : comps) {
+                    if (tgc_mutex == tgc_inv) {
+                        found = true;
+                        break;
+                    }
+                }
+                if (!found) {
+                    break;
+                }
+                nbOfFound++;
+            }
+            if (nbOfFound == compInMutex.size()) {
+                TraceManager.addDev("Mutex found in inv:" + cpt);
+                for (TGComponent tgc : compInMutex) {
+                    tgc.setMutexResult(TGComponent.MUTEX_OK);
+                }
+                return cpt;
+            }
+            cpt++;
+        }
+
+
+        for (TGComponent tgc : compInMutex) {
+            tgc.setMutexResult(TGComponent.MUTEX_UNKNOWN);
+        }
+
+        return -3;
+
+
+    }
+
+    public void clearGraphicalInfoOnInvariants() {
+        if (avatarspec == null) {
+            return;
+        }
+
+        AvatarDesignPanel adp = null;
+
+        try {
+            adp = (AvatarDesignPanel) (avatarspec.getInformationSource());
+        } catch (Exception e) {
+            TraceManager.addDev("Exception gtm: " + e.getMessage());
+            return;
+        }
+
+        if (adp == null) {
+            return;
+        }
+
+        adp.removeAllMutualExclusionWithMasterMutex();
+
+
+    }
+
+
+    // Returns the number of states found
+    // Returns -1 in case of error
+    public int computeMutexStatesWith(AvatarSMDState state) {
+        Vector<TGComponent> list = new Vector<TGComponent>();
+
+        if (state == null) {
+            // DB Issue 17 this will cause null pointer exception
+            //                  state.setMutexWith(TGComponent.MUTEX_UNKNOWN);
+            return -1;
+        }
+
+        for (Invariant inv : invariants) {
+            if (inv.containsComponent(state)) {
+                // All other states are in mutual exclusion
+                for (TGComponent tgc : inv.getComponents()) {
+                    if ((tgc instanceof AvatarSMDState) && (tgc != state)) {
+                        if (tgc.getTDiagramPanel() != state.getTDiagramPanel()) {
+                            if (!(list.contains(tgc))) {
+                                tgc.setMutualExclusionWithMasterMutex(state.getTDiagramPanel().getName() + "/" + state.getStateName());
+                                list.add(tgc);
+
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        if (list.size() > 0) {
+            state.setMutexWith(TGComponent.MUTEX_OK);
+        } else {
+            state.setMutexWith(TGComponent.MUTEX_UNKNOWN);
+        }
+
+        return list.size();
+
+    }
+
+
+    public void computeAllMutualExclusions() {
+        TURTLEPanel tp = mgui.getCurrentTURTLEPanel();
+
+        if (tp == null) {
+            return;
+        }
+
+        if (!(tp instanceof AvatarDesignPanel)) {
+            return;
+        }
+
+        AvatarDesignPanel adp = (AvatarDesignPanel) (tp);
+        adp.reinitMutualExclusionStates();
+
+        // First step: build a list of all states being in invariants
+        Vector<AvatarSMDState> v = new Vector<AvatarSMDState>();
+        for (Invariant inv : invariants) {
+            for (TGComponent tgc : inv.getComponents()) {
+                if (tgc instanceof AvatarSMDState) {
+                    if (!(v.contains(tgc))) {
+                        v.add((AvatarSMDState) tgc);
+                    }
+                }
+            }
+        }
+
+        // Then, add to all states its list of mutually exclusive states
+
+        for (AvatarSMDState s : v) {
+            Vector<AvatarSMDState> v0 = new Vector<AvatarSMDState>();
+            for (Invariant inv : invariants) {
+                if (inv.containsComponent(s)) {
+                    for (TGComponent tgc : inv.getComponents()) {
+                        if ((tgc instanceof AvatarSMDState) && (tgc != s)) {
+                            if (tgc.getTDiagramPanel() != s.getTDiagramPanel()) {
+                                if (!(v0.contains(tgc))) {
+                                    v0.add((AvatarSMDState) tgc);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            TraceManager.addDev("State " + s.getStateName() + " has " + v0.size() + " mutually eclusive states");
+
+            for (AvatarSMDState s0 : v0) {
+                s.addMutexState(s0);
+            }
+        }
+
+
+    }
+
+    // From AVATAR to TURTLEModeling
+    public boolean translateAvatarSpecificationToTIF() {
+        AVATAR2TURTLE att = new AVATAR2TURTLE(avatarspec);
+        tm = att.generateTURTLEModeling();
+
+        TURTLEModelChecker tmc = new TURTLEModelChecker(tm, listE);
+
+        checkingErrors = tmc.syntaxAnalysisChecking();
+        warnings.addAll(tmc.getWarnings());
+
+        if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+            analyzeErrors();
+            return false;
+        } else {
+            return true;
+        }
+
+    }
+
+    public List<CheckingError> getCheckingErrors() {
+        return checkingErrors;
+    }
+
+    public List<CheckingError> getCheckingWarnings() {
+        return warnings;
+    }
+
+
+    // SAVING AND LOADING IN XML
+    public static String transformString(String s) {
+        if (s != null) {
+            s = Conversion.replaceAllChar(s, '&', "&amp;");
+            s = Conversion.replaceAllChar(s, '<', "&lt;");
+            s = Conversion.replaceAllChar(s, '>', "&gt;");
+            s = Conversion.replaceAllChar(s, '"', "&quot;");
+            s = Conversion.replaceAllChar(s, '\'', "&apos;");
+        }
+        return s;
+    }
+
+    public static String encodeString(String s) {
+        return s;
+    }
+
+    public static String decodeString(String s) throws MalformedModelingException {
+        if (s == null)
+            return s;
+        byte b[] = null;
+        try {
+            b = s.getBytes("ISO-8859-1");
+            return new String(b);
+        } catch (Exception e) {
+            throw new MalformedModelingException();
+        }
+    }
+
+    public String mergeTURTLEGModeling(String modeling1, String modeling2) {
+        int index1 = modeling1.indexOf("</TURTLEGMODELING");
+        int index2 = modeling2.indexOf("<TURTLEGMODELING");
+        if ((index1 == -1) || (index2 == -1)) {
+            return null;
+        }
+
+        String modeling = modeling1.substring(0, index1);
+        String tmp = modeling2.substring(index2, modeling2.length());
+        index2 = modeling2.indexOf('<');
+        if (index2 == -1) {
+            return null;
+        }
+
+        tmp = tmp.substring(index2 + 1, tmp.length());
+
+        return modeling + tmp;
+    }
+
+    public String makeXMLFromComponentOfADiagram(TDiagramPanel tdp, TGComponent tgc, int copyMaxId, int _decX, int _decY) {
+        StringBuffer sb = new StringBuffer();
+
+        //sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<TURTLEGMODELING>\n\n");
+        sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n<TURTLEGSELECTEDCOMPONENTS ");
+        sb.append("version=\"" + DefaultText.getVersion());
+        sb.append("\" copyMaxId=\"" + copyMaxId);
+        sb.append("\" decX=\"" + _decX);
+        sb.append("\" decY=\"" + _decY);
+        sb.append("\" >\n\n");
+
+        StringBuffer s;
+        String str;
+
+        s = tdp.saveComponentInXML(tgc);
+
+        if (tgc instanceof AvatarBDBlock) {
+            AvatarSMDPanel asmdp = mgui.getAvatarSMDPanel(mgui.getCurrentSelectedIndex(), tgc.getValue());
+            s.append(asmdp.saveInXML());
+            LinkedList<AvatarBDBlock> list = ((AvatarBDBlock) tgc).getFullBlockList();
+            for (AvatarBDBlock b : list) {
+                asmdp = mgui.getAvatarSMDPanel(mgui.getCurrentSelectedIndex(), b.getValue());
+                s.append(asmdp.saveInXML());
+            }
+        }
+
+        if (tgc instanceof AvatarBDLibraryFunction) {
+            AvatarSMDPanel asmdp = mgui.getAvatarSMDPanel(mgui.getCurrentSelectedIndex(), ((AvatarBDLibraryFunction) tgc).getFunctionName());
+            s.append(asmdp.saveInXML());
+        }
+
+        if (tgc instanceof TCDTClass) {
+            TActivityDiagramPanel tadp = mgui.getActivityDiagramPanel(mgui.getCurrentSelectedIndex(), tgc.getValue());
+            s.append(tadp.saveInXML());
+        }
+
+        if (tgc instanceof TOSClass) {
+            TURTLEOSActivityDiagramPanel tosadp = mgui.getTURTLEOSActivityDiagramPanel(mgui.getCurrentSelectedIndex(), tgc.getValue());
+            s.append(tosadp.saveInXML());
+        }
+
+        if (tgc instanceof TMLTaskOperator) {
+            TMLActivityDiagramPanel tmladp1 = mgui.getTMLActivityDiagramPanel(mgui.getCurrentSelectedIndex(), tgc.getValue());
+            s.append(tmladp1.saveInXML());
+        }
+
+        if (tgc instanceof TMLCPrimitiveComponent) {
+            TMLActivityDiagramPanel tmladp2 = mgui.getTMLActivityDiagramPanel(mgui.getCurrentSelectedIndex(), tgc.getValue());
+            s.append(tmladp2.saveInXML());
+        }
+
+        if (tgc instanceof TMLCCompositeComponent) {
+            TMLActivityDiagramPanel tmladp3;
+            List<TMLCPrimitiveComponent> list = ((TMLCCompositeComponent) tgc).getAllPrimitiveComponents();
+
+            for (TMLCPrimitiveComponent comp : list) {
+                tmladp3 = mgui.getTMLActivityDiagramPanel(mgui.getCurrentSelectedIndex(), comp.getValue());
+                s.append(tmladp3.saveInXML());
+            }
+        }
+
+        if (s == null) {
+            return null;
+        }
+        sb.append(s);
+        sb.append("\n\n");
+        sb.append("</TURTLEGSELECTEDCOMPONENTS>");
+
+        str = new String(sb);
+        str = encodeString(str);
+
+        return str;
+    }
+
+
+    public String makeXMLFromSelectedComponentOfADiagram(TDiagramPanel tdp, int copyMaxId, int _decX, int _decY) {
+        StringBuffer sb = new StringBuffer();
+        //TraceManager.addDev("Making copy");
+
+        //sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<TURTLEGMODELING>\n\n");
+        sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n<TURTLEGSELECTEDCOMPONENTS ");
+        sb.append("version=\"" + DefaultText.getVersion());
+        sb.append("\" copyMaxId=\"" + copyMaxId);
+        sb.append("\" decX=\"" + _decX);
+        sb.append("\" decY=\"" + _decY);
+        sb.append("\" >\n\n");
+
+        StringBuffer s;
+        String str;
+
+        s = tdp.saveSelectedInXML();
+
+        final Vector<TCDTClass> classes = tdp.selectedTclasses();
+
+        if ((classes != null) && (classes.size() > 0)) {
+            TCDTClass t;
+            TActivityDiagramPanel tadp;
+            for (int i = 0; i < classes.size(); i++) {
+                t = classes.elementAt(i);
+                tadp = mgui.getActivityDiagramPanel(mgui.getCurrentSelectedIndex(), t.getValue());
+                s.append(tadp.saveInXML());
+            }
+        }
+
+        //Added by Solange
+        //bug removed by Emil
+        if (tdp instanceof ProactiveCSDPanel) {
+            final Vector<ProCSDComponent> comp = ((ProactiveCSDPanel) tdp).selectedProCSDComponent(null);
+
+            if ((comp != null) && (comp.size() > 0)) {
+                ProCSDComponent t;
+                ProactiveSMDPanel psmd;
+                for (int i = 0; i < comp.size(); i++) {
+                    t = comp.elementAt(i);
+                    psmd = mgui.getSMDPanel(mgui.getCurrentSelectedIndex(), t.getValue());
+                    if (psmd != null)
+                        s.append(psmd.saveInXML());
+                }
+            }
+        }
+        //until here
+
+
+        final Vector<TOSClass> toClasses = tdp.selectedTURTLEOSClasses();
+
+        if ((toClasses != null) && (toClasses.size() > 0)) {
+            //TraceManager.addDev("Saving TURTLEOS activity diagram Panel...");
+            TOSClass t;
+            TURTLEOSActivityDiagramPanel tosadp;
+            for (int i = 0; i < toClasses.size(); i++) {
+                t = toClasses.elementAt(i);
+                tosadp = mgui.getTURTLEOSActivityDiagramPanel(mgui.getCurrentSelectedIndex(), t.getValue());
+                s.append(tosadp.saveInXML());
+            }
+        }
+
+        final Vector<TMLTaskOperator> operators = tdp.selectedTMLTasks();
+        if ((operators != null) && (operators.size() > 0)) {
+            //TraceManager.addDev("Saving TML activity diagram Panel...");
+            TMLTaskOperator t;
+            TMLActivityDiagramPanel tmladp;
+            for (int i = 0; i < operators.size(); i++) {
+                t = operators.elementAt(i);
+                tmladp = mgui.getTMLActivityDiagramPanel(mgui.getCurrentSelectedIndex(), t.getValue());
+                s.append(tmladp.saveInXML());
+            }
+        }
+
+        final Vector<AvatarBDBlock> blocks = tdp.selectedAvatarBDBlocks();
+        if ((blocks != null) && (blocks.size() > 0)) {
+            //TraceManager.addDev("Saving TML activity diagram Panel...");
+            AvatarBDBlock abdb;
+            AvatarSMDPanel asmdp;
+            for (int i = 0; i < blocks.size(); i++) {
+                abdb = blocks.elementAt(i);
+                asmdp = mgui.getAvatarSMDPanel(mgui.getCurrentSelectedIndex(), abdb.getBlockName());
+                s.append(asmdp.saveInXML());
+
+            }
+        }
+
+        final Vector<TMLCPrimitiveComponent> primComps = tdp.selectedCPrimitiveComponent();
+
+        if ((primComps != null) && (primComps.size() > 0)) {
+            //TraceManager.addDev("Saving TML activity diagram Panel...");
+            TMLCPrimitiveComponent ct;
+            TMLActivityDiagramPanel tmladp;
+            for (int i = 0; i < primComps.size(); i++) {
+                ct = primComps.elementAt(i);
+                tmladp = mgui.getTMLActivityDiagramPanel(mgui.getCurrentSelectedIndex(), ct.getValue());
+                s.append(tmladp.saveInXML());
+            }
+        }
+
+        if (s == null) {
+            return null;
+        }
+        sb.append(s);
+        sb.append("\n\n");
+        sb.append("</TURTLEGSELECTEDCOMPONENTS>");
+
+        str = new String(sb);
+        str = encodeString(str);
+
+        TraceManager.addDev("Copy done");
+        //TraceManager.addDev(str);
+
+        return str;
+    }
+
+    public String makeOneDiagramXMLFromGraphicalModel(TURTLEPanel tp, int indexOfDiagram) {
+        StringBuffer sb = new StringBuffer();
+        //sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<TURTLEGMODELING>\n\n");
+        sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n<TURTLEGMODELING version=\"" + DefaultText.getVersion() + "\">\n\n");
+
+        StringBuffer s;
+        String str;
+
+
+        s = tp.saveInXML(indexOfDiagram);
+
+        sb.append(s);
+        sb.append("\n\n");
+
+
+        sb.append("</TURTLEGMODELING>");
+
+        str = new String(sb);
+        str = encodeString(str);
+
+        return str;
+    }
+
+    public String makeXMLFromTurtleModeling(int index) {
+        return makeXMLFromTurtleModeling(index, null);
+    }
+
+    public String makeXMLFromTurtleModeling(int index, String extensionToName) {
+        StringBuffer sb = new StringBuffer();
+        //sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<TURTLEGMODELING>\n\n");
+        sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n<TURTLEGMODELING version=\"" + DefaultText.getVersion() + "\">\n\n");
+
+        StringBuffer s;
+        String str;
+
+        TURTLEPanel tp;
+        int i;
+        // search for diagram panels (Design)
+        for (i = 0; i < panels.size(); i++) {
+            if ((index == -1) || (i == index)) {
+                tp = panels.elementAt(i);
+                s = tp.saveInXML(extensionToName);
+                if (s == null) {
+                    return null;
+                }
+                sb.append(s);
+                sb.append("\n\n");
+            }
+        }
+
+        sb.append("</TURTLEGMODELING>");
+
+        str = new String(sb);
+        str = encodeString(str);
+
+        return str;
+    }
+
+    public void removeAllComponents() {
+        TDiagramPanel tdp;
+        int i, j;
+        Vector<TDiagramPanel> panelss;
+        // search for diagram panels
+        for (i = 0; i < panels.size(); i++) {
+            panelss = (panels.elementAt(i).panels);
+            for (j = 0; j < panelss.size(); j++) {
+                tdp = panelss.elementAt(j);
+                tdp.removeAll();
+            }
+        }
+    }
+
+
+    private void prepareErrors() {
+        checkingErrors = new ArrayList<CheckingError>();
+        warnings = new ArrayList<CheckingError>();
+    }
+
+    public void copyModelingFromXML(TDiagramPanel tdp, String s, int X, int Y) throws MalformedModelingException {
+        //TraceManager.addDev("copyModelingFromXML: " + s);
+        //TraceManager.addDev("tdp: " + tdp);
+
+        //TraceManager.addDev(s);
+        //TraceManager.addDev("copyModelingFromXML:");
+        //LinkedList ComponentsList=tdp.getComponentList();
+
+        prepareErrors();
+
+
+        int beginIndex = tdp.getComponentList().size();
+
+        //Added by Solange
+        int cuenta = 1;
+
+        s = decodeString(s);
+
+        //TraceManager.addDev("copy=" + s);
+
+        ByteArrayInputStream bais = new ByteArrayInputStream(s.getBytes());
+        if ((dbf == null) || (db == null)) {
+            throw new MalformedModelingException();
+        }
+
+        int i;
+        //int copyMaxId;
+        int _decX = 0, _decY = 0;
+
+        try {
+            // building nodes from xml String
+            Document doc = db.parse(bais);
+            NodeList nl;
+
+            decId = tdp.getMaxId() + 1;
+            TGComponent.setGeneralId(TGComponent.getGeneralId() + decId + 2);
+            nl = doc.getElementsByTagName("TURTLEGSELECTEDCOMPONENTS");
+
+            if (nl == null) {
+                return;
+            }
+
+            Node adn;
+            Element elt;
+
+            for (i = 0; i < nl.getLength(); i++) {
+                adn = nl.item(i);
+                if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                    elt = (Element) adn;
+                    _decX = X - Integer.decode(elt.getAttribute("decX")).intValue();
+                    _decY = Y - Integer.decode(elt.getAttribute("decY")).intValue();
+                    //copyMaxId = Integer.decode(elt.getAttribute("copyMaxId")).intValue();
+                }
+            }
+
+            // Managing diagrams
+            if (tdp instanceof TClassDiagramPanel) {
+                TraceManager.addDev("TClassDiagramPanel copy");
+
+                nl = doc.getElementsByTagName("TClassDiagramPanelCopy");
+                docCopy = doc;
+
+                if (nl == null) {
+                    return;
+                }
+
+
+                TClassDiagramPanel tcdp = (TClassDiagramPanel) tdp;
+
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (tcdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        tcdp.loadExtraParameters(elt);
+
+                        //TraceManager.addDev("Class diagram : " + tcdp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), tcdp);
+                        makePostProcessing(tcdp);
+                        //TraceManager.addDev("Class diagram : " + tcdp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), tcdp);
+                        //TraceManager.addDev("Class diagram : " + tcdp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), tcdp);
+                        //TraceManager.addDev("Class diagram : " + tcdp.getName() + " real points");
+                        connectConnectorsToRealPoints(tcdp);
+                        tcdp.structureChanged();
+                        //TraceManager.addDev("Class diagram : " + tcdp.getName() + " post loading " + beginIndex);
+                        makePostLoading(tcdp, beginIndex);
+                        //TraceManager.addDev("Class diagram : " + tcdp.getName() + " post loading done");
+                    }
+                }
+                docCopy = null;
+
+            } else if (tdp instanceof TActivityDiagramPanel) {
+                TraceManager.addDev("TActivityDiagramPanel copy");
+                nl = doc.getElementsByTagName("TActivityDiagramPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                TActivityDiagramPanel tadp = (TActivityDiagramPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (tadp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        tadp.loadExtraParameters(elt);
+
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), tadp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), tadp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), tadp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " real points");
+                        connectConnectorsToRealPoints(tadp);
+                        tadp.structureChanged();
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " post loading");
+                        makePostLoading(tadp, beginIndex);
+                    }
+                }
+            } else if (tdp instanceof InteractionOverviewDiagramPanel) {
+
+                nl = doc.getElementsByTagName("InteractionOverviewDiagramPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                InteractionOverviewDiagramPanel iodp = (InteractionOverviewDiagramPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (iodp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        //TraceManager.addDev("Activity diagram : " + iodp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), iodp);
+                        //TraceManager.addDev("Activity diagram : " + iodp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), iodp);
+                        //TraceManager.addDev("Activity diagram : " + iodp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), iodp);
+                        //TraceManager.addDev("Activity diagram : " + iodp.getName() + " real points");
+                        connectConnectorsToRealPoints(iodp);
+                        iodp.structureChanged();
+                        //TraceManager.addDev("Activity diagram : " + iodp.getName() + " post loading");
+                        makePostLoading(iodp, beginIndex);
+                    }
+                }
+            } else if (tdp instanceof ui.sd.SequenceDiagramPanel) {
+                //TraceManager.addDev("Sequence diagram!");
+                nl = doc.getElementsByTagName("SequenceDiagramPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                ui.sd.SequenceDiagramPanel sdp = (ui.sd.SequenceDiagramPanel) tdp;
+
+                //TraceManager.addDev("Sequence diagram!");
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (sdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        //TraceManager.addDev("Sequence diagram: " + sdp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), sdp);
+                        //TraceManager.addDev("Sequence diagram: " + sdp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), sdp);
+                        //TraceManager.addDev("Sequence diagram: " + sdp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), sdp);
+                        //TraceManager.addDev("Sequence diagram: " + sdp.getName() + " real points");
+                        connectConnectorsToRealPoints(sdp);
+                        sdp.structureChanged();
+                        //TraceManager.addDev("Sequence diagram: " + sdp.getName() + " post loading");
+                        makePostLoading(sdp, beginIndex);
+                    }
+                }
+            } else if (tdp instanceof ui.sd2.SequenceDiagramPanel) {
+                //TraceManager.addDev("Sequence diagram!");
+                nl = doc.getElementsByTagName("SequenceDiagramPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                ui.sd2.SequenceDiagramPanel sdp = (ui.sd2.SequenceDiagramPanel) tdp;
+
+                //TraceManager.addDev("Sequence diagram!");
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (sdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        //TraceManager.addDev("Sequence diagram: " + sdp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), sdp);
+                        //TraceManager.addDev("Sequence diagram: " + sdp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), sdp);
+                        //TraceManager.addDev("Sequence diagram: " + sdp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), sdp);
+                        //TraceManager.addDev("Sequence diagram: " + sdp.getName() + " real points");
+                        connectConnectorsToRealPoints(sdp);
+                        sdp.structureChanged();
+                        //TraceManager.addDev("Sequence diagram: " + sdp.getName() + " post loading");
+                        makePostLoading(sdp, beginIndex);
+                    }
+                }
+
+            } else if (tdp instanceof UseCaseDiagramPanel) {
+                nl = doc.getElementsByTagName("UseCaseDiagramPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                UseCaseDiagramPanel ucdp = (UseCaseDiagramPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (ucdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        //TraceManager.addDev("Activity diagram : " + sdp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), ucdp);
+                        //TraceManager.addDev("Activity diagram : " + sdp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), ucdp);
+                        //TraceManager.addDev("Activity diagram : " + sdp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), ucdp);
+                        //TraceManager.addDev("Activity diagram : " + sdp.getName() + " real points");
+                        connectConnectorsToRealPoints(ucdp);
+                        ucdp.structureChanged();
+                        //TraceManager.addDev("Activity diagram : " + iodp.getName() + " post loading");
+                        makePostLoading(ucdp, beginIndex);
+                    }
+                }
+            } else if (tdp instanceof TDeploymentDiagramPanel) {
+                nl = doc.getElementsByTagName("TDeploymentDiagramPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                TDeploymentDiagramPanel tddp = (TDeploymentDiagramPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (tddp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        //TraceManager.addDev("Activity diagram : " + sdp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), tddp);
+                        //TraceManager.addDev("Activity diagram : " + sdp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), tddp);
+                        //TraceManager.addDev("Activity diagram : " + sdp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), tddp);
+                        //TraceManager.addDev("Activity diagram : " + sdp.getName() + " real points");
+                        connectConnectorsToRealPoints(tddp);
+                        tddp.structureChanged();
+                        //TraceManager.addDev("Activity diagram : " + iodp.getName() + " post loading");
+                        makePostLoading(tddp, beginIndex);
+                    }
+                }
+            } else if (tdp instanceof NCDiagramPanel) {
+                nl = doc.getElementsByTagName("NCDiagramPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                NCDiagramPanel ncdp = (NCDiagramPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (ncdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        //TraceManager.addDev("Activity diagram : " + sdp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), ncdp);
+                        //TraceManager.addDev("Activity diagram : " + sdp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), ncdp);
+                        //TraceManager.addDev("Activity diagram : " + sdp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), ncdp);
+                        //TraceManager.addDev("Activity diagram : " + sdp.getName() + " real points");
+                        connectConnectorsToRealPoints(ncdp);
+                        ncdp.structureChanged();
+                        //TraceManager.addDev("Activity diagram : " + iodp.getName() + " post loading");
+                        makePostLoading(ncdp, beginIndex);
+                    }
+                }
+            } else if (tdp instanceof RequirementDiagramPanel) {
+                nl = doc.getElementsByTagName("TRequirementDiagramPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                RequirementDiagramPanel rdp = (RequirementDiagramPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (rdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), rdp);
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), rdp);
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), rdp);
+                        connectConnectorsToRealPoints(rdp);
+                        rdp.structureChanged();
+                        makePostLoading(rdp, beginIndex);
+                    }
+                }
+            } else if (tdp instanceof EBRDDPanel) {
+                nl = doc.getElementsByTagName("EBRDDPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                EBRDDPanel ebrddp = (EBRDDPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (ebrddp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), ebrddp);
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), ebrddp);
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), ebrddp);
+                        connectConnectorsToRealPoints(ebrddp);
+                        ebrddp.structureChanged();
+                        makePostLoading(ebrddp, beginIndex);
+                    }
+                }
+            } else if (tdp instanceof AttackTreeDiagramPanel) {
+                nl = doc.getElementsByTagName("AttackTreeDiagramPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                AttackTreeDiagramPanel atdp = (AttackTreeDiagramPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (atdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), atdp);
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), atdp);
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), atdp);
+                        connectConnectorsToRealPoints(atdp);
+                        atdp.structureChanged();
+                        makePostLoading(atdp, beginIndex);
+                    }
+                }
+
+            } else if (tdp instanceof FaultTreeDiagramPanel) {
+                nl = doc.getElementsByTagName("FaultTreeDiagramPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                FaultTreeDiagramPanel ftdp = (FaultTreeDiagramPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (ftdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), ftdp);
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), ftdp);
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), ftdp);
+                        connectConnectorsToRealPoints(ftdp);
+                        ftdp.structureChanged();
+                        makePostLoading(ftdp, beginIndex);
+                    }
+                }
+            } else if (tdp instanceof TMLTaskDiagramPanel) {
+                nl = doc.getElementsByTagName("TMLTaskDiagramPanelCopy");
+                docCopy = doc;
+
+                if (nl == null) {
+                    return;
+                }
+
+                //TraceManager.addDev("Toto 1");
+
+
+                TMLTaskDiagramPanel tmltdp = (TMLTaskDiagramPanel) tdp;
+
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (tmltdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        tmltdp.loadExtraParameters(elt);
+
+                        //TraceManager.addDev("Toto 2");
+
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), tmltdp);
+                        //TraceManager.addDev("Toto 3");
+                        makePostProcessing(tmltdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), tmltdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), tmltdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " real points");
+                        connectConnectorsToRealPoints(tmltdp);
+                        tmltdp.structureChanged();
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading " + beginIndex);
+                        makePostLoading(tmltdp, beginIndex);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading done");
+                    }
+                }
+            } else if (tdp instanceof DiplodocusMethodologyDiagramPanel) {
+                nl = doc.getElementsByTagName("DiplodocusMethodologyDiagramPanelCopy");
+                docCopy = doc;
+
+                if (nl == null) {
+                    return;
+                }
+
+                //TraceManager.addDev("Toto 1");
+
+
+                DiplodocusMethodologyDiagramPanel tmltdp = (DiplodocusMethodologyDiagramPanel) tdp;
+
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (tmltdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        tmltdp.loadExtraParameters(elt);
+
+                        //TraceManager.addDev("Toto 2");
+
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), tmltdp);
+                        //TraceManager.addDev("Toto 3");
+                        makePostProcessing(tmltdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), tmltdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), tmltdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " real points");
+                        connectConnectorsToRealPoints(tmltdp);
+                        tmltdp.structureChanged();
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading " + beginIndex);
+                        makePostLoading(tmltdp, beginIndex);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading done");
+                    }
+                }
+
+
+            } else if (tdp instanceof AvatarMethodologyDiagramPanel) {
+                nl = doc.getElementsByTagName("AvatarMethodologyDiagramPanelCopy");
+                docCopy = doc;
+
+                if (nl == null) {
+                    return;
+                }
+
+                //TraceManager.addDev("Toto 1");
+
+
+                AvatarMethodologyDiagramPanel amdp = (AvatarMethodologyDiagramPanel) tdp;
+
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (amdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        amdp.loadExtraParameters(elt);
+
+                        //TraceManager.addDev("Toto 2");
+
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), amdp);
+                        //TraceManager.addDev("Toto 3");
+                        makePostProcessing(amdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), amdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), amdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " real points");
+                        connectConnectorsToRealPoints(amdp);
+                        amdp.structureChanged();
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading " + beginIndex);
+                        makePostLoading(amdp, beginIndex);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading done");
+                    }
+                }
+            } else if (tdp instanceof SysmlsecMethodologyDiagramPanel) {
+                nl = doc.getElementsByTagName("SysmlsecMethodologyDiagramPanelCopy");
+                docCopy = doc;
+
+                if (nl == null) {
+                    return;
+                }
+
+                //TraceManager.addDev("Toto 1");
+
+
+                SysmlsecMethodologyDiagramPanel amdp = (SysmlsecMethodologyDiagramPanel) tdp;
+
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (amdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        amdp.loadExtraParameters(elt);
+
+                        //TraceManager.addDev("Toto 2");
+
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), amdp);
+                        //TraceManager.addDev("Toto 3");
+                        makePostProcessing(amdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), amdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), amdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " real points");
+                        connectConnectorsToRealPoints(amdp);
+                        amdp.structureChanged();
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading " + beginIndex);
+                        makePostLoading(amdp, beginIndex);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading done");
+                    }
+                }
+            } else if (tdp instanceof TMLComponentTaskDiagramPanel) {
+                nl = doc.getElementsByTagName("TMLComponentTaskDiagramPanelCopy");
+                docCopy = doc;
+
+                if (nl == null) {
+                    return;
+                }
+
+                //TraceManager.addDev("Toto 1");
+
+
+                TMLComponentTaskDiagramPanel tmlctdp = (TMLComponentTaskDiagramPanel) tdp;
+                //tmlctdp.updateReferences();
+
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (tmlctdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        tmlctdp.loadExtraParameters(elt);
+
+                        //TraceManager.addDev("Toto 2");
+
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), tmlctdp);
+                        //TraceManager.addDev("Toto 3");
+                        makePostProcessing(tmlctdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), tmlctdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), tmlctdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " real points");
+                        connectConnectorsToRealPoints(tmlctdp);
+                        tmlctdp.structureChanged();
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading " + beginIndex);
+                        makePostLoading(tmlctdp, beginIndex);
+                        tmlctdp.hideConnectors();
+                        tmlctdp.updatePorts();
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading done");
+                    }
+                }
+                tmlctdp.updatePorts();
+            } else if (tdp instanceof TMLActivityDiagramPanel) {
+                nl = doc.getElementsByTagName("TMLActivityDiagramPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                TMLActivityDiagramPanel tmladp = (TMLActivityDiagramPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (tmladp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        //tmladp.loadExtraParameters(elt);
+
+                        //TraceManager.addDev("Activity diagram : " + tmladp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), tmladp);
+                        //TraceManager.addDev("Activity diagram : " + tmladp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), tmladp);
+                        //TraceManager.addDev("Activity diagram : " + tmladp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), tmladp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " real points");
+                        connectConnectorsToRealPoints(tmladp);
+                        tmladp.structureChanged();
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " post loading");
+                        makePostLoading(tmladp, beginIndex);
+                    }
+                }
+            } else if (tdp instanceof TMLCPPanel) {
+                nl = doc.getElementsByTagName("CommunicationPatternDiagramPanelCopy");
+                docCopy = doc;
+
+                if (nl == null) {
+                    return;
+                }
+
+                //TraceManager.addDev("Toto 1");
+
+                TMLCPPanel tmlcpp = (TMLCPPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (tmlcpp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        //tmlcpp.loadExtraParameters(elt);
+
+                        //TraceManager.addDev("Toto 2");
+
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), tmlcpp);
+                        //TraceManager.addDev("Toto 3");
+                        makePostProcessing(tmlcpp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), tmlcpp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), tmlcpp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " real points");
+                        connectConnectorsToRealPoints(tmlcpp);
+                        tmlcpp.structureChanged();
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading " + beginIndex);
+                        makePostLoading(tmlcpp, beginIndex);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading done");
+                    }
+                }
+            } else if (tdp instanceof TMLSDPanel) {
+                nl = doc.getElementsByTagName("TMLSDPanelCopy");
+                docCopy = doc;
+
+                if (nl == null) {
+                    return;
+                }
+
+                //TraceManager.addDev("Toto 1");
+
+                TMLSDPanel tmlsdp = (TMLSDPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (tmlsdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        //tmlcpp.loadExtraParameters(elt);
+
+                        //TraceManager.addDev("Toto 2");
+
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), tmlsdp);
+                        //TraceManager.addDev("Toto 3");
+                        makePostProcessing(tmlsdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), tmlsdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), tmlsdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " real points");
+                        connectConnectorsToRealPoints(tmlsdp);
+                        tmlsdp.structureChanged();
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading " + beginIndex);
+                        makePostLoading(tmlsdp, beginIndex);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading done");
+                    }
+                }
+            } else if (tdp instanceof TMLArchiDiagramPanel) {
+                nl = doc.getElementsByTagName("TMLArchiDiagramPanelCopy");
+                docCopy = doc;
+
+                if (nl == null) {
+                    return;
+                }
+
+                //TraceManager.addDev("Toto 1");
+
+                TMLArchiDiagramPanel tmadp = (TMLArchiDiagramPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (tmadp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        tmadp.loadExtraParameters(elt);
+
+                        //TraceManager.addDev("Toto 2");
+
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), tmadp);
+                        //TraceManager.addDev("Toto 3");
+                        makePostProcessing(tmadp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), tmadp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), tmadp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " real points");
+                        connectConnectorsToRealPoints(tmadp);
+                        tmadp.structureChanged();
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading " + beginIndex);
+                        makePostLoading(tmadp, beginIndex);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading done");
+                    }
+                }
+            } else if (tdp instanceof TURTLEOSClassDiagramPanel) {
+                nl = doc.getElementsByTagName("TURTLEOSClassDiagramPanelCopy");
+                docCopy = doc;
+
+                if (nl == null) {
+                    return;
+                }
+
+                TURTLEOSClassDiagramPanel toscdp = (TURTLEOSClassDiagramPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (toscdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        //toscdp.loadExtraParameters(elt);
+                        //TraceManager.addDev("Toto 2");
+                        //TraceManager.addDev("TURTLEOS task diagram : " + toscdp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), toscdp);
+                        //TraceManager.addDev("Toto 3");
+                        makePostProcessing(toscdp);
+                        //TraceManager.addDev("TURTLEOS task diagram : " + toscdp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), toscdp);
+                        //TraceManager.addDev("TURTLEOS task diagram : " + toscdp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), toscdp);
+                        //TraceManager.addDev("TURTLEOS task diagram : " + toscdp.getName() + " real points");
+                        connectConnectorsToRealPoints(toscdp);
+                        toscdp.structureChanged();
+                        //TraceManager.addDev("TURTLEOS task diagram : " + toscdp.getName() + " post loading " + beginIndex);
+                        makePostLoading(toscdp, beginIndex);
+                        //TraceManager.addDev("TURTLEOS task diagram : " + toscdp.getName() + " post loading done");
+                    }
+                }
+            } else if (tdp instanceof TURTLEOSActivityDiagramPanel) {
+                nl = doc.getElementsByTagName("TURTLEOSActivityDiagramPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                TURTLEOSActivityDiagramPanel tosadp = (TURTLEOSActivityDiagramPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (tosadp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        //tmladp.loadExtraParameters(elt);
+
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), tosadp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), tosadp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), tosadp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " real points");
+                        connectConnectorsToRealPoints(tosadp);
+                        tosadp.structureChanged();
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " post loading");
+                        makePostLoading(tosadp, beginIndex);
+                    }
+                }
+            } else if (tdp instanceof ProactiveCSDPanel) {
+                //cuenta=beginIndex+1;
+                cuenta = mgui.tabs.size() - 1;
+                nl = doc.getElementsByTagName("ProactiveCSDPanelCopy");
+                if (nl.getLength() == 0) {
+                    nl = doc.getElementsByTagName("ProactiveCSDPanel");
+                }
+                docCopy = doc;
+                if (nl == null) {
+                    return;
+                }
+                ProactiveCSDPanel pcsdp = (ProactiveCSDPanel) tdp;
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+                        if (pcsdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+
+                        //                                                                                        int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        //pcsdp.loadExtraParameters(elt);
+                        //TraceManager.addDev("Toto 2");
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), pcsdp);
+                        //TraceManager.addDev("Toto 3");
+                        makePostProcessing(pcsdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), pcsdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), pcsdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " real points");
+                        connectConnectorsToRealPoints(pcsdp);
+                        pcsdp.structureChanged();
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading " + beginIndex);
+                        makePostLoading(pcsdp, beginIndex);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading done");
+                    }
+                }
+                // Added by Solange
+                nl = doc.getElementsByTagName("ProactiveSMDPanel");
+                if (nl == null) {
+                    return;
+                }
+                String name = "";
+                ProactiveSMDPanel psmdp;
+                for (i = 0; i < nl.getLength(); i++) //Erased cuenta++ by Solange at the end condition of the for
+                {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+                        name = elt.getAttribute("name");
+                        //Added by Solange name at the beginning and cuenta
+                        name = mgui.createProActiveSMD(cuenta, name);
+                        psmdp = mgui.getSMDPanel(cuenta, name);
+                        if (psmdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //                                                                                        int xSel = Integer.decode(elt.getAttribute("minX")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("maxX")).intValue(); // - mgui.getCurrentTDiagramPanel().currentX;
+                        //                                                                                        int widthSel = Integer.decode(elt.getAttribute("minY")).intValue(); // - mgui.getCurrentTDiagramPanel().currentY;;
+                        //                                                                                        int heightSel = Integer.decode(elt.getAttribute("maxY")).intValue(); // - mgui.getCurrentTDiagramPanel().currentY;;
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        //tmladp.loadExtraParameters(elt);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), psmdp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), psmdp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), psmdp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " real points");
+                        connectConnectorsToRealPoints(psmdp);
+                        psmdp.structureChanged();
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " post loading");
+                        makePostLoading(psmdp, beginIndex);
+                        //until here
+                    }
+                }
+            } else if (tdp instanceof ProactiveSMDPanel) {
+                //Changed by Solange, before it was like the first line
+                //nl = doc.getElementsByTagName("ProactiveSMDPanelCopy");
+                nl = doc.getElementsByTagName("ProactiveSMDPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                ProactiveSMDPanel psmdp = (ProactiveSMDPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (psmdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        //tmladp.loadExtraParameters(elt);
+
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), psmdp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), psmdp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), psmdp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " real points");
+                        connectConnectorsToRealPoints(psmdp);
+                        psmdp.structureChanged();
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " post loading");
+                        makePostLoading(psmdp, beginIndex);
+                    }
+                }
+
+                // AVATAR
+            } else if (tdp instanceof AvatarBDPanel) {
+                nl = doc.getElementsByTagName("AVATARBlockDiagramPanelCopy");
+                docCopy = doc;
+
+                if (nl == null) {
+                    return;
+                }
+
+                //TraceManager.addDev("Toto 1");
+
+
+                AvatarBDPanel abdp = (AvatarBDPanel) tdp;
+
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (abdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        abdp.loadExtraParameters(elt);
+
+                        //TraceManager.addDev("Toto 2");
+
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), abdp);
+                        //TraceManager.addDev("Toto 3");
+                        makePostProcessing(abdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), abdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), abdp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " real points");
+                        connectConnectorsToRealPoints(abdp);
+                        abdp.structureChanged();
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading " + beginIndex);
+                        makePostLoading(abdp, beginIndex);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading done");
+                    }
+                }
+
+
+            } else if (tdp instanceof ADDDiagramPanel) {
+                nl = doc.getElementsByTagName("ADDDiagramPanelCopy");
+                docCopy = doc;
+
+                if (nl == null) {
+                    return;
+                }
+
+                //TraceManager.addDev("Toto 1");
+
+
+                ADDDiagramPanel addp = (ADDDiagramPanel) tdp;
+
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (addp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        addp.loadExtraParameters(elt);
+
+                        //TraceManager.addDev("Toto 2");
+
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), addp);
+                        //TraceManager.addDev("Toto 3");
+                        makePostProcessing(addp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), addp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), addp);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " real points");
+                        connectConnectorsToRealPoints(addp);
+                        addp.structureChanged();
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading " + beginIndex);
+                        makePostLoading(addp, beginIndex);
+                        //TraceManager.addDev("TML task diagram : " + tmltdp.getName() + " post loading done");
+                    }
+                }
+
+            } else if (tdp instanceof AvatarSMDPanel) {
+                nl = doc.getElementsByTagName("AVATARStateMachineDiagramPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                AvatarSMDPanel asmdp = (AvatarSMDPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (asmdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        //tmladp.loadExtraParameters(elt);
+
+                        //TraceManager.addDev("Activity diagram : " + tmladp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), asmdp);
+                        //TraceManager.addDev("Activity diagram : " + tmladp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), asmdp);
+                        //TraceManager.addDev("Activity diagram : " + tmladp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), asmdp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " real points");
+                        connectConnectorsToRealPoints(asmdp);
+                        asmdp.structureChanged();
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " post loading");
+                        makePostLoading(asmdp, beginIndex);
+                    }
+                }
+            } else if (tdp instanceof AvatarRDPanel) {
+                nl = doc.getElementsByTagName("AvatarRDPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                AvatarRDPanel ardp = (AvatarRDPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (ardp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), ardp);
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), ardp);
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), ardp);
+                        connectConnectorsToRealPoints(ardp);
+                        ardp.structureChanged();
+                        makePostLoading(ardp, beginIndex);
+                    }
+                }
+
+            } else if (tdp instanceof AvatarMADPanel) {
+                nl = doc.getElementsByTagName("AvatarMADPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                AvatarMADPanel amadp = (AvatarMADPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (amadp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), amadp);
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), amadp);
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), amadp);
+                        connectConnectorsToRealPoints(amadp);
+                        amadp.structureChanged();
+                        makePostLoading(amadp, beginIndex);
+                    }
+                }
+
+            } else if (tdp instanceof AvatarPDPanel) {
+                nl = doc.getElementsByTagName("AvatarPDPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                AvatarPDPanel apdp = (AvatarPDPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (apdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), apdp);
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), apdp);
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), apdp);
+                        connectConnectorsToRealPoints(apdp);
+                        apdp.structureChanged();
+                        makePostLoading(apdp, beginIndex);
+                    }
+                }
+
+            } else if (tdp instanceof AvatarCDPanel) {
+                nl = doc.getElementsByTagName("AvatarCDPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                AvatarCDPanel acdp = (AvatarCDPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (acdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue();
+                        //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue();
+                        //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue();
+                        //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue();
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), acdp);
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), acdp);
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), acdp);
+                        connectConnectorsToRealPoints(acdp);
+                        acdp.structureChanged();
+                        makePostLoading(acdp, beginIndex);
+                    }
+                }
+
+            } /*else if (tdp instanceof CAMSBlockDiagramPanel) {  //ajout CD 24.07----mark
+                nl = doc.getElementsByTagName("CAMSBlockDiagramPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                CAMSBlockDiagramPanel camsp = (CAMSBlockDiagramPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (camsp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), camsp);
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), camsp);
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), camsp);
+                        connectConnectorsToRealPoints(camsp);
+                        camsp.structureChanged();
+                        makePostLoading(camsp, beginIndex);
+                    }
+                }
+
+            } */ else if (tdp instanceof AvatarADPanel) {
+                nl = doc.getElementsByTagName("AvatarADPanelCopy");
+
+                if (nl == null) {
+                    return;
+                }
+
+                AvatarADPanel aadp = (AvatarADPanel) tdp;
+
+                for (i = 0; i < nl.getLength(); i++) {
+                    adn = nl.item(i);
+                    if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                        elt = (Element) adn;
+
+                        if (aadp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        decX = _decX;
+                        decY = _decY;
+
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), aadp);
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), aadp);
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), aadp);
+                        connectConnectorsToRealPoints(aadp);
+                        aadp.structureChanged();
+                        makePostLoading(aadp, beginIndex);
+                    }
+                }
+            }
+
+        } catch (IOException e) {
+            TraceManager.addError("Loading 500: " + e.getMessage());
+            throw new MalformedModelingException();
+        } catch (SAXException saxe) {
+            TraceManager.addError("Loading 501 " + saxe.getMessage());
+            throw new MalformedModelingException();
+        }
+
+    }
+
+    // Returns null if s is not a saved TURTLE modeling of an older format
+    public String upgradeSaved(String s) {
+        int index1, index2, index3;
+        StringBuffer sb = new StringBuffer("");
+        //String tmp;
+
+        index1 = s.indexOf("<TClassDiagramPanel");
+        index2 = s.indexOf("<InteractionOverviewDiagramPanel ");
+        index3 = s.indexOf("</TURTLEGMODELING>");
+
+        if ((index1 < 0) || (index3 < 0)) {
+            return null;
+        }
+
+        sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n<TURTLEGMODELING version=\"" + DefaultText.getVersion() + "\">\n\n");
+
+        if (index2 > -1) {
+            sb.append("<Modeling type=\"Analysis\" nameTab=\"Analysis\" >\n");
+            sb.append(s.substring(index2, index3));
+            sb.append("</Modeling>\n\n");
+        }
+
+        if (index2 < 0) {
+            index2 = index3;
+        }
+        sb.append("<Modeling type=\"Design\" nameTab=\"Design\" >\n");
+        sb.append(s.substring(index1, index2));
+        sb.append("</Modeling>\n\n");
+
+        sb.append(s.substring(index3, s.length()));
+
+        //TraceManager.addDev("Got:" + sb);
+
+        return sb.toString();
+    }
+
+    public void loadModelingFromXML(String s) throws MalformedModelingException {
+
+        if (s == null) {
+            return;
+        }
+
+        s = decodeString(s);
+
+        decX = 0;
+        decY = 0;
+        decId = 0;
+        TGComponent.setGeneralId(100000);
+
+        ByteArrayInputStream bais = new ByteArrayInputStream(s.getBytes());
+
+        if ((dbf == null) || (db == null)) {
+            throw new MalformedModelingException();
+        }
+
+        prepareErrors();
+
+        try {
+            // building nodes from xml String
+            Document doc = db.parse(bais);
+            NodeList panelNl;
+            //NodeList designPanelNl;
+            //NodeList analysisNl;
+
+            int i;
+            //Element elt;
+            Node node;
+
+            // Managing design panels
+            panelNl = doc.getElementsByTagName("Modeling");
+
+            if (panelNl.getLength() == 0) {
+                // Modeling saved in old format?
+                s = upgradeSaved(s);
+                if (s != null) {
+                    JOptionPane.showMessageDialog(mgui.frame, "The modeling has been converted to this new version of TTool", "Loading information", JOptionPane.INFORMATION_MESSAGE);
+                }
+                loadModelingFromXML(s);
+                return;
+
+            }
+            //designPanelNl = doc.getElementsByTagName("Design");
+            //analysisNl = doc.getElementsByTagName("Analysis");
+
+            pendingConnectors = new ArrayList<TGConnectorInfo>();
+
+            //TraceManager.addDev("nb de design=" + designPanelNl.getLength() + " nb d'analyse=" + analysisNl.getLength());
+            boolean error = false;
+            for (i = 0; i < panelNl.getLength(); i++) {
+                node = panelNl.item(i);
+                //TraceManager.addDev("Node = " + dnd);
+
+                if (node.getNodeType() == Node.ELEMENT_NODE) {
+                    // create design, and get an index for it
+                    try {
+                        loadModeling(node);
+                    } catch (MalformedModelingException mme) {
+                        Element elt = (Element) node;
+                        String type = elt.getAttribute("type");
+                        TraceManager.addError("Error when loading diagram: " + elt + " " + type, mme);
+                        error = true;
+                    }
+                }
+            }
+            if (error == true) {
+                throw new MalformedModelingException();
+            }
+
+        } catch (NumberFormatException nfe) {
+            TraceManager.addError("Loading 400 " + nfe.getMessage());
+            throw new MalformedModelingException();
+        } catch (IOException e) {
+            TraceManager.addError("Loading 600 " + e.getMessage());
+            throw new MalformedModelingException();
+        } catch (SAXException saxe) {
+            TraceManager.addError("Loading 601 " + saxe.getMessage());
+            throw new MalformedModelingException();
+        }
+        //TraceManager.addDev("making IDs");
+        makeLastLoad();
+        makeLovelyIds();
+        //TraceManager.addDev("IDs done");
+    }
+
+    public void loadModeling(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String type = elt.getAttribute("type");
+        // AVATAR
+        if (type.compareTo("ADD") == 0) {
+            loadAvatarDeployment(node);
+        } else if (type.compareTo("AVATAR Design") == 0) {
+            loadAvatarDesign(node);
+        } else if (type.compareTo("Avatar Requirement") == 0) {
+            loadAvatarRequirement(node);
+        } else if (type.compareTo("Avatar MAD") == 0) {
+            loadAvatarMADs(node);
+        } else if (type.compareTo("Avatar Analysis") == 0) {
+            loadAvatarAnalysis(node);
+
+
+            // TURTLE
+        } else if (type.compareTo("Design") == 0) {
+            loadDesign(node);
+        } else if (type.compareTo("Analysis") == 0) {
+            loadAnalysis(node);
+        } else if (type.compareTo("Deployment") == 0) {
+            loadDeployment(node);
+        } else if (type.compareTo("NC diagram") == 0) {
+            loadNC(node);
+        } else if (type.compareTo("Requirement") == 0) {
+            loadRequirement(node);
+        } else if (type.compareTo("AttackTree") == 0) {
+            loadAttackTree(node);
+        } else if (type.compareTo("FaultTree") == 0) {
+            loadFaultTree(node);
+        } else if (type.compareTo("Diplodocus Methodology") == 0) {
+            loadDiplodocusMethodology(node);
+        } else if (type.compareTo("Avatar Methodology") == 0) {
+            loadAvatarMethodology(node);
+        } else if (type.compareTo("Sysmlsec Methodology") == 0) {
+            loadSysmlsecMethodology(node);
+        } /*else if (type.compareTo("SystemC-AMS") == 0) {
+            loadSystemCAMS(node);
+        }*/ else if (type.compareTo("TML Design") == 0) {
+            loadTMLDesign(node);
+        } else if (type.compareTo("TML Component Design") == 0) {
+            loadTMLComponentDesign(node);
+        } else if (type.compareTo("TML CP") == 0) {
+            loadTMLCP(node);
+        } else if (type.compareTo("TML Architecture") == 0) {
+            loadTMLArchitecture(node);
+        } else if (type.compareTo("TURTLE-OS Design") == 0) {
+            loadTURTLEOSDesign(node);
+        } else if (type.compareTo("ProActive Design") == 0) {
+            loadProActiveDesign(node);
+        } else {
+            throw new MalformedModelingException();
+        }
+    }
+
+    public void loadAvatarDesign(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexDesign;
+
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexDesign = mgui.createAvatarDesign(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        /* First load all Block diagrams, then all state machines
+         * This is done this way so that state machines can rely on
+         * informations provided by blocks. For instance we can check
+         * that an attribute used in a state machine really exists.
+         */
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("AVATARBlockDiagramPanel") == 0)
+                    // Class diagram
+                    loadAvatarBD(elt, indexDesign);
+            }
+        }
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("AVATARStateMachineDiagramPanel") == 0)
+                    // Managing activity diagrams
+                    loadAvatarSMD(elt, indexDesign);
+            }
+        }
+    }
+
+    public void loadAvatarDeployment(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexReq;
+        int cpt_req = 0;
+
+        TraceManager.addDev("Loading ADD 0");
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexReq = mgui.createADD(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("Deployment nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("ADDDiagramPanel") == 0) {
+                    TraceManager.addDev("Loading ADD 1");
+                    loadADDDiagram(elt, indexReq, cpt_req);
+                    cpt_req++;
+                }
+            }
+        }
+    }
+
+    public void loadAvatarRequirement(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexReq;
+        int cpt_req = 0;
+
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexReq = mgui.createAvatarRequirement(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("Deployment nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("AvatarRDPanel") == 0) {
+                    loadAvatarRD(elt, indexReq, cpt_req);
+                    cpt_req++;
+                } else if (elt.getTagName().compareTo("AvatarPDPanel") == 0) {
+                    loadAvatarPD(elt, indexReq, cpt_req);
+                    cpt_req++;
+                }
+            }
+        }
+    }
+
+    public void loadAttackTree(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexTree;
+        int cpttdp = 0;
+
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexTree = mgui.createAttackTree(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("Deployment nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("AttackTreeDiagramPanel") == 0) {
+                    loadAttackTreeDiagram(elt, indexTree, cpttdp);
+                    cpttdp++;
+                }
+            }
+        }
+    }
+
+    public void loadFaultTree(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexTree;
+        int cpttdp = 0;
+
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexTree = mgui.createFaultTree(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("Deployment nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("FaultTreeDiagramPanel") == 0) {
+                    loadFaultTreeDiagram(elt, indexTree, cpttdp);
+                    cpttdp++;
+                }
+            }
+        }
+    }
+
+    public void loadAvatarMADs(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexReq;
+        int cpt_req = 0;
+
+
+        nameTab = elt.getAttribute("nameTab");
+
+        TraceManager.addDev("Creating MAD panel ");
+
+        indexReq = mgui.createAvatarMADs(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            TraceManager.addDev("MADs nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("AvatarMADPanel") == 0) {
+                    loadAvatarMAD(elt, indexReq, cpt_req);
+                    cpt_req++;
+                }
+            }
+        }
+    }
+
+    public void loadDesign(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexDesign;
+
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexDesign = mgui.createDesign(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("Design nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("TClassDiagramPanel") == 0) {
+                    // Class diagram
+                    loadTClassDiagram(elt, indexDesign);
+                } else { // Managing activity diagrams
+                    if (elt.getTagName().compareTo("TActivityDiagramPanel") == 0) {
+                        // Managing activity diagrams
+                        loadTActivityDiagram(elt, indexDesign);
+                    }
+                }
+            }
+        }
+    }
+
+    public void loadAnalysis(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexAnalysis;
+        int cpt = 0;
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexAnalysis = mgui.createAnalysis(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("Design nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("InteractionOverviewDiagramPanel") == 0) {
+                    // IOD
+                    loadIODiagram(elt, indexAnalysis);
+                    cpt++;
+                } else { // Managing sequence diagrams
+                    if (elt.getTagName().compareTo("SequenceDiagramPanel") == 0) {
+                        loadSequenceDiagram(elt, indexAnalysis);
+                        cpt++;
+                    } else if (elt.getTagName().compareTo("SequenceDiagramPanelZV") == 0) {
+                        loadSequenceDiagramZV(elt, indexAnalysis);
+                        cpt++;
+                    } else if (elt.getTagName().compareTo("UseCaseDiagramPanel") == 0) {
+                        // Managing use case diagrams
+                        loadUseCaseDiagram(elt, indexAnalysis, cpt);
+                        cpt++;
+                    } /*else if (elt.getTagName().compareTo("AvatarCDPanel") == 0) {
+                      // Managing use case diagrams
+                      loadAvatarCD(elt, indexAnalysis, cpt);
+                      cpt ++;
+                      } else if (elt.getTagName().compareTo("AvatarADPanel") == 0) {
+                      // Managing use case diagrams
+                      loadAvatarAD(elt, indexAnalysis, cpt);
+                      cpt ++;
+                      }*/
+                }
+            }
+        }
+    }
+
+    public void loadTMLCP(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexTMLCP;
+        //  int cpt = 0;
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexTMLCP = mgui.createTMLCP(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("Nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("CommunicationPatternDiagramPanel") == 0) {
+                    // CP
+                    loadTMLCPDiagram(elt, indexTMLCP);
+                    // cpt ++;
+                } else { // Managing sequence diagrams
+                    if (elt.getTagName().compareTo("TMLSDPanel") == 0) {
+                        loadTMLSDDiagram(elt, indexTMLCP);
+                        //       cpt ++;
+                    }
+                }
+            }
+        }
+    }
+
+    public void loadAvatarAnalysis(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexAnalysis;
+        int cpt = 0;
+
+        //TraceManager.addDev("Loading Avatar analysis");
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexAnalysis = mgui.createAvatarAnalysis(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("Design nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+
+                if (elt.getTagName().compareTo("SequenceDiagramPanel") == 0) {
+                    //TraceManager.addDev("Loading seq diag");
+                    loadSequenceDiagram(elt, indexAnalysis);
+                    //TraceManager.addDev("Loading seq diag done");
+                    cpt++;
+                } else if (elt.getTagName().compareTo("SequenceDiagramPanelZV") == 0) {
+                    //TraceManager.addDev("Loading seq diag");
+                    loadSequenceDiagramZV(elt, indexAnalysis);
+                    //TraceManager.addDev("Loading seq diag done");
+                    cpt++;
+                } else if (elt.getTagName().compareTo("UseCaseDiagramPanel") == 0) {
+                    // Managing use case diagrams
+                    //TraceManager.addDev("Loading ucd diag");
+                    loadUseCaseDiagram(elt, indexAnalysis, cpt);
+                    //TraceManager.addDev("Loading ucd diag done");
+
+                    cpt++;
+                } else if (elt.getTagName().compareTo("AvatarCDPanel") == 0) {
+                    // Managing use case diagrams
+                    //TraceManager.addDev("Loading cd diag");
+                    loadAvatarCD(elt, indexAnalysis, cpt);
+                    //TraceManager.addDev("Loading cd diag done");
+                    cpt++;
+                } else if (elt.getTagName().compareTo("AvatarADPanel") == 0) {
+                    // Managing use case diagrams
+                    //TraceManager.addDev("Loading ad diag");
+                    loadAvatarAD(elt, indexAnalysis, cpt);
+                    //TraceManager.addDev("Loading ad diag done");
+                    cpt++;
+                }
+
+            }
+        }
+    }
+
+    public void loadDeployment(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexAnalysis;
+
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexAnalysis = mgui.createDeployment(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("Deployment nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("TDeploymentDiagramPanel") == 0) {
+                    // IOD
+                    loadTDeploymentDiagram(elt, indexAnalysis);
+                }
+            }
+        }
+    }
+
+    public void loadNC(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexAnalysis;
+
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexAnalysis = mgui.createNC(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("Deployment nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("NCDiagramPanel") == 0) {
+                    // IOD
+                    loadNCDiagram(elt, indexAnalysis);
+                }
+            }
+        }
+    }
+
+    public void loadRequirement(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexReq;
+        int cpt_req = 0;
+
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexReq = mgui.createRequirement(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("Deployment nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("TRequirementDiagramPanel") == 0) {
+                    loadRequirementDiagram(elt, indexReq, cpt_req);
+                    cpt_req++;
+                } else if (elt.getTagName().compareTo("EBRDDPanel") == 0) {
+                    loadEBRDD(elt, indexReq, cpt_req);
+                    cpt_req++;
+                }
+            }
+        }
+    }
+
+
+    public void loadDiplodocusMethodology(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexDesign;
+
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexDesign = mgui.createDiplodocusMethodology(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("Design nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("DiplodocusMethodologyDiagramPanel") == 0) {
+                    // Class diagram
+                    //TraceManager.addDev("Loading TML CD");
+                    loadDiplodocusMethodologyDiagram(elt, indexDesign);
+                    //TraceManager.addDev("End loading TML CD");
+                }
+            }
+        }
+    }
+
+    public void loadAvatarMethodology(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexDesign;
+
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexDesign = mgui.createAvatarMethodology(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("Design nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("AvatarMethodologyDiagramPanel") == 0) {
+                    // Class diagram
+                    TraceManager.addDev("Loading Avatar methodo");
+                    loadAvatarMethodologyDiagram(elt, indexDesign);
+                    TraceManager.addDev("End Loading avatar methodo");
+                }
+            }
+        }
+    }
+
+    public void loadSysmlsecMethodology(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexDesign;
+
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexDesign = mgui.createSysmlsecMethodology(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("Design nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("SysmlsecMethodologyDiagramPanel") == 0) {
+                    // Class diagram
+                    TraceManager.addDev("Loading SysMLSec methodo");
+                    loadSysmlsecMethodologyDiagram(elt, indexDesign);
+                    TraceManager.addDev("End loading SysMLSec methodo");
+                }
+            }
+        }
+    }
+
+/*  public void loadSystemCAMS(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexDesign;
+
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexDesign = mgui.createSystemCAMS(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("Design nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("SystemCAMSDiagramPanel") == 0) {
+                    // Class diagram
+                    TraceManager.addDev("Loading SystemC-AMS");
+                    loadSystemCAMSDiagram(elt, indexDesign);
+                    TraceManager.addDev("End loading SystemC-AMS");
+                }
+            }
+        }
+	}*/
+
+    public void loadTMLDesign(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexDesign;
+
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexDesign = mgui.createTMLDesign(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("Design nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("TMLTaskDiagramPanel") == 0) {
+                    // Class diagram
+                    //TraceManager.addDev("Loading TML CD");
+                    loadTMLTaskDiagram(elt, indexDesign);
+                    //TraceManager.addDev("End loading TML CD");
+                } else { // Managing activity diagrams
+                    if (elt.getTagName().compareTo("TMLActivityDiagramPanel") == 0) {
+                        // Managing activity diagrams
+                        //TraceManager.addDev("Loading TML AD");
+                        loadTMLActivityDiagram(elt, indexDesign);
+                    }
+                }
+            }
+        }
+    }
+
+    public void loadTMLComponentDesign(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexDesign;
+
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexDesign = mgui.createTMLComponentDesign(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("Design nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("TMLComponentTaskDiagramPanel") == 0) {
+                    // Component diagram
+                    //TraceManager.addDev("Loading TML Component diagram");
+                    loadTMLComponentTaskDiagram(elt, indexDesign);
+                    //TraceManager.addDev("End loading TML CD");
+                } else { // Managing activity diagrams
+                    if (elt.getTagName().compareTo("TMLActivityDiagramPanel") == 0) {
+                        // Managing activity diagrams
+                        //TraceManager.addDev("Loading TML AD");
+                        loadTMLActivityDiagram(elt, indexDesign);
+                    }
+                }
+            }
+        }
+    }
+
+    public void loadTMLArchitecture(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexDesign;
+
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexDesign = mgui.createTMLArchitecture(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("TML Architecture nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("TMLArchiDiagramPanel") == 0) {
+                    //TraceManager.addDev("Loading TML DD" + elt.getTagName() );
+                    loadTMLArchitectureDiagram(elt, indexDesign);
+                    //TraceManager.addDev("End loading TML DD");
+                }
+            }
+        }
+    }
+
+    public void loadTURTLEOSDesign(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexDesign;
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexDesign = mgui.createTURTLEOSDesign(nameTab);
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("Design nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("TURTLEOSClassDiagramPanel") == 0) {
+                    // Class diagram
+                    //TraceManager.addDev("Loading TURTLEOS CD");
+                    loadTURTLEOSClassDiagram(elt, indexDesign);
+                    //TraceManager.addDev("End loading TML CD");
+                } else { // Managing activity diagrams
+                    if (elt.getTagName().compareTo("TURTLEOSActivityDiagramPanel") == 0) {
+                        // Managing activity diagrams
+                        //TraceManager.addDev("Loading TURTLEOS AD");
+                        loadTURTLEOSActivityDiagram(elt, indexDesign);
+                    }
+                }
+            }
+        }
+    }
+
+    public void loadProActiveDesign(Node node) throws MalformedModelingException, SAXException {
+        Element elt = (Element) node;
+        String nameTab;
+        NodeList diagramNl;
+        int indexDesign;
+
+
+        nameTab = elt.getAttribute("nameTab");
+
+        indexDesign = mgui.createProActiveDesign(nameTab);
+
+
+        diagramNl = node.getChildNodes();
+
+        for (int j = 0; j < diagramNl.getLength(); j++) {
+            //TraceManager.addDev("Design nodes: " + j);
+            node = diagramNl.item(j);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                elt = (Element) node;
+                if (elt.getTagName().compareTo("ProactiveCSDPanel") == 0) {
+                    // Class diagram
+                    //TraceManager.addDev("Loading TML CD");
+                    loadProactiveCSD(elt, indexDesign);
+                    //TraceManager.addDev("End loading TML CD");
+                } else { // Managing activity diagrams
+                    if (elt.getTagName().compareTo("ProactiveSMDPanel") == 0) {
+                        // Managing activity diagrams
+                        //TraceManager.addDev("Loading TML AD");
+                        loadProactiveSMD(elt, indexDesign);
+                    }
+                }
+            }
+        }
+    }
+
+    public void loadDiagram(Element elt, TDiagramPanel tdp) throws MalformedModelingException, SAXException {
+        int x, y;
+        double zoom = 0;
+        try {
+            x = Integer.decode(elt.getAttribute("minX")).intValue();
+            tdp.setMinX(x);
+            x = Integer.decode(elt.getAttribute("maxX")).intValue();
+            tdp.setMaxX(x);
+            y = Integer.decode(elt.getAttribute("minY")).intValue();
+            tdp.setMinY(y);
+            y = Integer.decode(elt.getAttribute("maxY")).intValue();
+            tdp.setMaxY(y);
+            tdp.updateSize();
+            zoom = Double.parseDouble(elt.getAttribute("zoom"));
+            if (zoom != 0) {
+                tdp.forceZoom(zoom);
+                mgui.updateZoomInfo();
+            }
+        } catch (Exception e) {
+            // Model was saved in an older version of TTool
+        }
+
+        // for TClassdiagram Panel
+        if (tdp instanceof TClassDiagramPanel) {
+            ((TClassDiagramPanel) tdp).loadExtraParameters(elt);
+        }
+
+        if (tdp instanceof TActivityDiagramPanel) {
+            ((TActivityDiagramPanel) tdp).loadExtraParameters(elt);
+        }
+
+        if (tdp instanceof TMLTaskDiagramPanel) {
+            ((TMLTaskDiagramPanel) tdp).loadExtraParameters(elt);
+        }
+
+        if (tdp instanceof TMLComponentTaskDiagramPanel) {
+            ((TMLComponentTaskDiagramPanel) tdp).loadExtraParameters(elt);
+        }
+
+        if (tdp instanceof TMLArchiDiagramPanel) {
+            ((TMLArchiDiagramPanel) tdp).loadExtraParameters(elt);
+        }
+
+
+        if (tdp instanceof AvatarBDPanel) {
+            ((AvatarBDPanel) tdp).loadExtraParameters(elt);
+        }
+
+        //TraceManager.addDev("Element" + elt.toString());
+        // Loads components of the class diagram
+        //TraceManager.addDev("Components");
+        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), tdp);
+        //TraceManager.addDev("Post processing");
+        makePostProcessing(tdp);
+        //TraceManager.addDev("Connectors");
+        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), tdp);
+        //TraceManager.addDev("Subcomponents");
+        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), tdp);
+        //TraceManager.addDev("RealPoints");
+        connectConnectorsToRealPoints(tdp);
+        //TraceManager.addDev("Structure changed");
+        tdp.structureChanged();
+        //TraceManager.addDev("Post loading");
+        makePostLoading(tdp, 0);
+
+        //TraceManager.addDev("Test connectors");
+        if (tdp instanceof TMLComponentTaskDiagramPanel) {
+            //TraceManager.addDev("Connectors...");
+            ((TMLComponentTaskDiagramPanel) tdp).setConnectorsToFront();
+        }
+
+        if (tdp instanceof EBRDDPanel) {
+            //TraceManager.addDev("Connectors...");
+            ((EBRDDPanel) tdp).setConnectorsToFront();
+        }
+
+        if (tdp instanceof AttackTreeDiagramPanel) {
+            //TraceManager.addDev("Connectors...");
+            ((AttackTreeDiagramPanel) tdp).setConnectorsToFront();
+        }
+
+        if (tdp instanceof FaultTreeDiagramPanel) {
+            //TraceManager.addDev("Connectors...");
+            ((FaultTreeDiagramPanel) tdp).setConnectorsToFront();
+        }
+
+        if (tdp instanceof AvatarBDPanel) {
+            //TraceManager.addDev("Connectors...");
+            ((AvatarBDPanel) tdp).setConnectorsToFront();
+        }
+
+        if (tdp instanceof AvatarSMDPanel) {
+            //TraceManager.addDev("Connectors...");
+            ((AvatarSMDPanel) tdp).setConnectorsToFront();
+        }
+
+        if (tdp instanceof AvatarPDPanel) {
+            //TraceManager.addDev("Connectors...");
+            ((AvatarPDPanel) tdp).setConnectorsToFront();
+        }
+
+        if (tdp instanceof AvatarCDPanel) {
+            //TraceManager.addDev("Connectors...");
+            ((AvatarCDPanel) tdp).setConnectorsToFront();
+        }
+
+        if (tdp instanceof AvatarADPanel) {
+            //TraceManager.addDev("Connectors...");
+            ((AvatarADPanel) tdp).setConnectorsToFront();
+        }
+
+	/* if (tdp instanceof CAMSBlockDiagramPanel) {
+            //TraceManager.addDev("Connectors...");
+            ((CAMSBlockDiagramPanel) tdp).setConnectorsToFront();
+	    }*/
+    }
+
+    // AVATAR
+    public void loadAvatarBD(Element elt, int indexDesign) throws MalformedModelingException, SAXException {
+
+        String name;
+        TDiagramPanel tdp;
+
+        // class diagram name
+        name = elt.getAttribute("name");
+        mgui.setAvatarBDName(indexDesign, name);
+        tdp = mgui.getMainTDiagramPanel(indexDesign);
+
+        loadDiagram(elt, tdp);
+    }
+
+    public void loadAvatarSMD(Element elt, int indexDesign) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+        //TraceManager.addDev("Loading SMD of:" + name);
+        AvatarSMDPanel asmdp = mgui.getAvatarSMDPanel(indexDesign, name);
+
+        if (asmdp == null) {
+            throw new MalformedModelingException();
+        }
+
+        asmdp.removeAll();
+
+        mgui.selectDummyTab(indexDesign);
+        loadDiagram(elt, asmdp);
+        mgui.forgetDummyTab();
+    }
+
+    public void loadAvatarRD(Element elt, int indexAnalysis, int indexTab) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+        mgui.createAvatarRD(indexAnalysis, name);
+
+
+        TDiagramPanel tdp = mgui.getAvatarRDPanel(indexAnalysis, indexTab, name);
+
+        if (tdp == null) {
+            throw new MalformedModelingException();
+        }
+        tdp.removeAll();
+
+        loadDiagram(elt, tdp);
+    }
+
+    public void loadAvatarMAD(Element elt, int indexAnalysis, int indexTab) throws MalformedModelingException, SAXException {
+        String name;
+        name = elt.getAttribute("name");
+        mgui.createAvatarMAD(indexAnalysis, name);
+        TDiagramPanel tdp = mgui.getAvatarMADPanel(indexAnalysis, indexTab, name);
+        if (tdp == null) {
+            throw new MalformedModelingException();
+        }
+        tdp.removeAll();
+        loadDiagram(elt, tdp);
+    }
+
+
+    public void loadADDDiagram(Element elt, int indexAnalysis, int indexTab) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+
+        TraceManager.addDev("ADD 2");
+        mgui.createAvatarPD(indexAnalysis, name);
+
+        TraceManager.addDev("ADD 3");
+        TDiagramPanel tdp = mgui.getAvatarADDPanel(indexAnalysis, indexTab, name);
+
+        TraceManager.addDev("ADD 3.1");
+
+        if (tdp == null) {
+            // 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");
+
+        loadDiagram(elt, tdp);
+        TraceManager.addDev("ADD 5");
+    }
+
+    public void loadAvatarPD(Element elt, int indexAnalysis, int indexTab) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+        mgui.createAvatarPD(indexAnalysis, name);
+
+        TDiagramPanel tdp = mgui.getAvatarPDPanel(indexAnalysis, indexTab, name);
+
+        if (tdp == null) {
+            throw new MalformedModelingException();
+        }
+        tdp.removeAll();
+
+        loadDiagram(elt, tdp);
+    }
+
+    public void loadAvatarCD(Element elt, int indexAnalysis, int indexTab) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+        mgui.createAvatarCD(indexAnalysis, name);
+
+        TDiagramPanel tdp = mgui.getAvatarCDPanel(indexAnalysis, indexTab, name);
+
+        if (tdp == null) {
+            throw new MalformedModelingException();
+        }
+        tdp.removeAll();
+
+        loadDiagram(elt, tdp);
+    }
+
+    public void loadAvatarAD(Element elt, int indexAnalysis, int indexTab) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+        mgui.createAvatarAD(indexAnalysis, name);
+
+        TDiagramPanel tdp = mgui.getAvatarADPanel(indexAnalysis, indexTab, name);
+
+        if (tdp == null) {
+            throw new MalformedModelingException();
+        }
+        tdp.removeAll();
+
+        loadDiagram(elt, tdp);
+    }
+
+    // TURTLE Design
+    public void loadTClassDiagram(Element elt, int indexDesign) throws MalformedModelingException, SAXException {
+
+        String name;
+        TDiagramPanel tdp;
+
+        // class diagram name
+        name = elt.getAttribute("name");
+        mgui.setClassDiagramName(indexDesign, name);
+        tdp = mgui.getMainTDiagramPanel(indexDesign);
+
+        loadDiagram(elt, tdp);
+    }
+
+    public void loadTActivityDiagram(Element elt, int indexDesign) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+        TActivityDiagramPanel tadp = mgui.getActivityDiagramPanel(indexDesign, name);
+
+        if (tadp == null) {
+            throw new MalformedModelingException();
+        }
+
+        tadp.removeAll();
+
+        loadDiagram(elt, tadp);
+    }
+
+    public void loadDiplodocusMethodologyDiagram(Element elt, int indexDesign) throws MalformedModelingException, SAXException {
+
+        String name;
+        TDiagramPanel tdp;
+
+        // Diagram name
+        name = elt.getAttribute("name");
+        mgui.setDiplodocusMethodologyDiagramName(indexDesign, name);
+        tdp = mgui.getMainTDiagramPanel(indexDesign);
+        tdp.setName(name);
+
+        //TraceManager.addDev("tdp=" + tdp.getName());
+
+        loadDiagram(elt, tdp);
+    }
+
+    public void loadAvatarMethodologyDiagram(Element elt, int indexDesign) throws MalformedModelingException, SAXException {
+
+        String name;
+        TDiagramPanel tdp;
+
+        // class diagram name
+        name = elt.getAttribute("name");
+        mgui.setAvatarMethodologyDiagramName(indexDesign, name);
+        tdp = mgui.getMainTDiagramPanel(indexDesign);
+        tdp.setName(name);
+
+        //TraceManager.addDev("tdp=" + tdp.getName());
+
+        loadDiagram(elt, tdp);
+    }
+
+    public void loadSysmlsecMethodologyDiagram(Element elt, int indexDesign) throws MalformedModelingException, SAXException {
+
+        String name;
+        TDiagramPanel tdp;
+
+        // class diagram name
+        name = elt.getAttribute("name");
+        mgui.setSysmlsecMethodologyDiagramName(indexDesign, name);
+        tdp = mgui.getMainTDiagramPanel(indexDesign);
+        tdp.setName(name);
+
+        //TraceManager.addDev("tdp=" + tdp.getName());
+
+        loadDiagram(elt, tdp);
+    }
+
+/*public void loadSystemCAMSDiagram(Element elt, int indexDesign) throws MalformedModelingException, SAXException {
+        //ajout CD
+        String name;
+        TDiagramPanel tdp;
+
+        // class diagram name
+        name = elt.getAttribute("name");
+        mgui.setSystemCAMSDiagramName(indexDesign, name);
+        tdp = mgui.getMainTDiagramPanel(indexDesign);
+        tdp.setName(name);
+
+        //TraceManager.addDev("tdp=" + tdp.getName());
+
+        loadDiagram(elt, tdp);
+	}*/
+
+    public void loadTMLTaskDiagram(Element elt, int indexDesign) throws MalformedModelingException, SAXException {
+
+        String name;
+        TDiagramPanel tdp;
+
+        // class diagram name
+        name = elt.getAttribute("name");
+        mgui.setTMLTaskDiagramName(indexDesign, name);
+        tdp = mgui.getMainTDiagramPanel(indexDesign);
+
+        //TraceManager.addDev("tdp=" + tdp.getName());
+
+        loadDiagram(elt, tdp);
+    }
+
+    public void loadTMLComponentTaskDiagram(Element elt, int indexDesign) throws MalformedModelingException, SAXException {
+
+        String name;
+        TDiagramPanel tdp;
+
+        // Diagram name
+        name = elt.getAttribute("name");
+        mgui.setTMLComponentTaskDiagramName(indexDesign, name);
+        tdp = mgui.getMainTDiagramPanel(indexDesign);
+
+        //TraceManager.addDev("tdp=" + tdp.getName());
+
+        loadDiagram(elt, tdp);
+
+        ((TMLComponentTaskDiagramPanel) tdp).hideConnectors();
+        ((TMLComponentTaskDiagramPanel) tdp).updatePorts();
+    }
+
+    public void loadTMLArchitectureDiagram(Element elt, int indexDesign) throws MalformedModelingException, SAXException {
+
+        String name;
+        TDiagramPanel tdp;
+
+        // Diagram name
+        name = elt.getAttribute("name");
+        mgui.setTMLArchitectureDiagramName(indexDesign, name);
+        tdp = mgui.getMainTDiagramPanel(indexDesign);
+
+        //TraceManager.addDev("tdp=" + tdp.getName());
+
+        loadDiagram(elt, tdp);
+    }
+
+    public void loadTMLActivityDiagram(Element elt, int indexDesign) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+
+        //TraceManager.addDev("getting tmladp: " + name);
+        TMLActivityDiagramPanel tmladp = mgui.getTMLActivityDiagramPanel(indexDesign, name);
+        //TraceManager.addDev("Got tmladp");
+
+
+        if (tmladp == null) {
+            //TraceManager.addDev("null tmladp");
+            throw new MalformedModelingException();
+        }
+
+        tmladp.removeAll();
+
+        loadDiagram(elt, tmladp);
+    }
+
+    public void loadTURTLEOSClassDiagram(Element elt, int indexDesign) throws MalformedModelingException, SAXException {
+
+        String name;
+        TDiagramPanel tdp;
+
+        // class diagram name
+        name = elt.getAttribute("name");
+        mgui.setTMLTaskDiagramName(indexDesign, name);
+        tdp = mgui.getMainTDiagramPanel(indexDesign);
+        loadDiagram(elt, tdp);
+    }
+
+    public void loadTURTLEOSActivityDiagram(Element elt, int indexDesign) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+        TURTLEOSActivityDiagramPanel tosadp = mgui.getTURTLEOSActivityDiagramPanel(indexDesign, name);
+
+        if (tosadp == null) {
+            throw new MalformedModelingException();
+        }
+
+        tosadp.removeAll();
+
+        loadDiagram(elt, tosadp);
+    }
+
+    public void loadProactiveCSD(Element elt, int indexDesign) throws MalformedModelingException, SAXException {
+
+        String name;
+        TDiagramPanel tdp;
+
+        // class diagram name
+        name = elt.getAttribute("name");
+        //  mgui.setProacticeCSDName(indexDesign, name);
+        tdp = mgui.getMainTDiagramPanel(indexDesign);
+        //ProactiveDesignPanel pdp=(ProactiveDesignPanel) mgui.getCurrentTURTLEPanel();
+        ProactiveDesignPanel pdp = (ProactiveDesignPanel) tdp.tp;
+        if (!tdp.getName().equals(name)) {
+
+            //tdp=pdp.addCompositeStructureDiagram(name);
+            tdp = pdp.addProActiveCompSpecificationPanel(name);
+        }
+
+        //TraceManager.addDev("tdp=" + tdp.getName());
+
+        loadDiagram(elt, tdp);
+
+    }
+
+    public void loadProactiveSMD(Element elt, int indexAnalysis) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+        if (!(mgui.isProActiveSMDCreated(indexAnalysis, name))) {
+            mgui.createProActiveSMD(indexAnalysis, name);
+        }
+        ProactiveSMDPanel smd = mgui.getSMDPanel(indexAnalysis, name);
+
+        if (smd == null) {
+            throw new MalformedModelingException();
+        }
+
+        smd.removeAll();
+
+        loadDiagram(elt, smd);
+    }
+
+    public void loadIODiagram(Element elt, int indexAnalysis) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+        //mgui.setIODName(indexAnalysis, name);
+        if (!(mgui.isIODCreated(indexAnalysis, name))) {
+            mgui.createIODiagram(indexAnalysis, name);
+        }
+
+        TDiagramPanel tdp = mgui.getIODiagramPanel(indexAnalysis, name);
+
+        if (tdp == null) {
+            throw new MalformedModelingException();
+        }
+        tdp.removeAll();
+
+        loadDiagram(elt, tdp);
+    }
+
+    public void loadTMLCPDiagram(Element elt, int indexAnalysis) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+        if (!(mgui.isTMLCPCreated(indexAnalysis, name))) {
+            mgui.createTMLCPDiagram(indexAnalysis, name);
+        }
+
+        TDiagramPanel tdp = mgui.getTMLCPDiagramPanel(indexAnalysis, name);
+
+        if (tdp == null) {
+            throw new MalformedModelingException();
+        }
+        tdp.removeAll();
+
+        loadDiagram(elt, tdp);
+    }
+
+    public void loadTMLSDDiagram(Element elt, int indexAnalysis) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+        if (!(mgui.isTMLCPSDCreated(indexAnalysis, name))) {
+            mgui.createTMLCPSequenceDiagram(indexAnalysis, name);
+        }
+
+        TDiagramPanel tdp = mgui.getTMLCPSDDiagramPanel(indexAnalysis, name);
+
+        if (tdp == null) {
+            throw new MalformedModelingException();
+        }
+        tdp.removeAll();
+
+        loadDiagram(elt, tdp);
+    }
+
+    public void loadRequirementDiagram(Element elt, int indexAnalysis, int indexTab) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+        mgui.createRequirementDiagram(indexAnalysis, name);
+
+
+        TDiagramPanel tdp = mgui.getRequirementDiagramPanel(indexAnalysis, indexTab, name);
+
+        if (tdp == null) {
+            throw new MalformedModelingException();
+        }
+        tdp.removeAll();
+
+        loadDiagram(elt, tdp);
+    }
+
+    public void loadEBRDD(Element elt, int indexAnalysis, int indexTab) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+        mgui.createEBRDD(indexAnalysis, name);
+
+
+        TDiagramPanel tdp = mgui.getEBRDDPanel(indexAnalysis, indexTab, name);
+
+        if (tdp == null) {
+            throw new MalformedModelingException();
+        }
+        tdp.removeAll();
+
+        loadDiagram(elt, tdp);
+    }
+
+    public void loadAttackTreeDiagram(Element elt, int indexDiag, int indexTab) throws MalformedModelingException, SAXException {
+        String name;
+
+        //TraceManager.addDev("indexDiag=" + indexDiag);
+
+        name = elt.getAttribute("name");
+        mgui.createAttackTreeDiagram(indexDiag, name);
+
+        TDiagramPanel tdp = mgui.getAttackTreeDiagramPanel(indexDiag, indexTab, name);
+
+        if (tdp == null) {
+            throw new MalformedModelingException();
+        }
+        tdp.removeAll();
+
+        loadDiagram(elt, tdp);
+    }
+
+    public void loadFaultTreeDiagram(Element elt, int indexDiag, int indexTab) throws MalformedModelingException, SAXException {
+        String name;
+
+        //TraceManager.addDev("indexDiag=" + indexDiag);
+
+        name = elt.getAttribute("name");
+        mgui.createFaultTreeDiagram(indexDiag, name);
+
+        TDiagramPanel tdp = mgui.getFaultTreeDiagramPanel(indexDiag, indexTab, name);
+
+        if (tdp == null) {
+            throw new MalformedModelingException();
+        }
+        tdp.removeAll();
+
+        loadDiagram(elt, tdp);
+    }
+
+    public void loadSequenceDiagram(Element elt, int indexAnalysis) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+        if (!(mgui.isSDCreated(indexAnalysis, name))) {
+            mgui.createSequenceDiagram(indexAnalysis, name);
+        }
+        //TraceManager.addDev("Loading seq diag1");
+        ui.sd.SequenceDiagramPanel sdp = mgui.getSequenceDiagramPanel(indexAnalysis, name);
+        //TraceManager.addDev("Loading seq diag2");
+        ui.sd2.SequenceDiagramPanel sdp2 = mgui.getSequenceDiagramPanelZV(indexAnalysis, name);
+
+        if (sdp != null) {
+            sdp.removeAll();
+            //TraceManager.addDev("Loading seq diag4");
+
+            loadDiagram(elt, sdp);
+            //TraceManager.addDev("Loading seq diag5");
+        } else if (sdp2 != null) {
+            sdp2.removeAll();
+
+            loadDiagram(elt, sdp2);
+        } else
+            throw new MalformedModelingException();
+        //TraceManager.addDev("Loading seq diag3");
+
+
+    }
+
+    public void loadSequenceDiagramZV(Element elt, int indexAnalysis) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+        if (!(mgui.isSDZVCreated(indexAnalysis, name))) {
+            mgui.createSequenceDiagramZV(indexAnalysis, name);
+        }
+        //TraceManager.addDev("Loading seq diag1");
+        ui.sd2.SequenceDiagramPanel sdp = mgui.getSequenceDiagramPanelZV(indexAnalysis, name);
+        //TraceManager.addDev("Loading seq diag2");
+
+        if (sdp == null) {
+            throw new MalformedModelingException();
+        }
+        //TraceManager.addDev("Loading seq diag3");
+
+        sdp.removeAll();
+        //TraceManager.addDev("Loading seq diag4");
+
+        loadDiagram(elt, sdp);
+        //TraceManager.addDev("Loading seq diag5");
+    }
+
+    public void loadUseCaseDiagram(Element elt, int indexAnalysis, int indexTab) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+        /*if (!(mgui.isUCDCreated(indexAnalysis, name))) {*/
+        mgui.createUseCaseDiagram(indexAnalysis, name);
+        //}
+        UseCaseDiagramPanel ucdp = mgui.getUseCaseDiagramPanel(indexAnalysis, indexTab, name);
+
+        if (ucdp == null) {
+            throw new MalformedModelingException();
+        }
+
+        ucdp.removeAll();
+
+        loadDiagram(elt, ucdp);
+    }
+
+    public void loadTDeploymentDiagram(Element elt, int indexDeployment) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+        mgui.setDeploymentName(indexDeployment, name);
+        TDiagramPanel tdp = mgui.getMainTDiagramPanel(indexDeployment);
+
+        loadDiagram(elt, tdp);
+    }
+
+    public void loadNCDiagram(Element elt, int indexNC) throws MalformedModelingException, SAXException {
+        String name;
+
+        name = elt.getAttribute("name");
+        mgui.setNCName(indexNC, name);
+        TDiagramPanel tdp = mgui.getMainTDiagramPanel(indexNC);
+
+        loadDiagram(elt, tdp);
+    }
+
+    // reinit the id of all components
+    public void makeLovelyIds() {
+        TDiagramPanel tdp;
+        int id = 1;
+        int i, j;
+        TURTLEPanel tp;
+        // search for diagram panels
+        for (i = 0; i < panels.size(); i++) {
+            tp = panels.elementAt(i);
+            for (j = 0; j < tp.panels.size(); j++) {
+                tdp = tp.panels.elementAt(j);
+                id = tdp.makeLovelyIds(id);
+                //TraceManager.addDev("Lovely id =" + id);
+            }
+        }
+
+        TGComponent.setGeneralId(id + 1);
+    }
+
+    public void loadDiagramInformation(Element elt, TDiagramPanel tdp) throws MalformedModelingException {
+        int x, y;
+        double zoom = 0;
+        try {
+            x = Integer.decode(elt.getAttribute("minX")).intValue();
+            tdp.setMinX(x);
+            x = Integer.decode(elt.getAttribute("maxX")).intValue();
+            tdp.setMaxX(x);
+            y = Integer.decode(elt.getAttribute("minY")).intValue();
+            tdp.setMinY(y);
+            y = Integer.decode(elt.getAttribute("maxY")).intValue();
+            tdp.setMaxY(y);
+            tdp.updateSize();
+            zoom = Double.parseDouble(elt.getAttribute("zoom"));
+            if (zoom != 0) {
+                tdp.forceZoom(zoom);
+                mgui.updateZoomInfo();
+            }
+        } catch (Exception e) {
+            // Model was saved in an older version of TTool
+        }
+
+        if (tdp instanceof TActivityDiagramPanel) {
+            ((TActivityDiagramPanel) tdp).loadExtraParameters(elt);
+        }
+    }
+
+    public void loadActivityDiagram(TDiagramPanel tdp, String oldValue, String newValue) throws MalformedModelingException {
+        //TraceManager.addDev("---> Load activity diagram");
+        try {
+            NodeList activityDiagramNl = docCopy.getElementsByTagName("TActivityDiagramPanel");
+
+            TraceManager.addDev("Loading activity diagram of " + newValue + "Before : " + oldValue);
+            TraceManager.addDev("" + docCopy);
+
+            if (activityDiagramNl == null) {
+                throw new MalformedModelingException();
+            }
+
+            Node adn;
+            Element elt;
+            TActivityDiagramPanel tadp;
+            String name;
+            int decXTmp = decX;
+            int decYTmp = decY;
+            int decIdTmp = decId;
+
+            for (int i = 0; i < activityDiagramNl.getLength(); i++) {
+                adn = activityDiagramNl.item(i);
+                if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                    elt = (Element) adn;
+                    // class diagram name
+                    name = elt.getAttribute("name");
+                    //TraceManager.addDev("Name of activity diagram=" + name);
+
+                    if (name.equals(oldValue)) {
+                        int indexDesign = mgui.getMajorIndexOf(tdp);
+
+                        if (indexDesign < 0) {
+                            throw new MalformedModelingException();
+                        }
+
+                        tadp = mgui.getActivityDiagramPanel(indexDesign, newValue);
+
+                        //TraceManager.addDev("Searching panel");
+
+                        if (tadp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //TraceManager.addDev("Panel ok");
+
+                        decX = 0;
+                        decY = 0;
+                        decId = 0;
+
+
+                        tadp.removeAll();
+
+                        loadDiagramInformation(elt, tadp);
+
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), tadp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), tadp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), tadp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " real points");
+                        connectConnectorsToRealPoints(tadp);
+                        tadp.structureChanged();
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " post loading");
+                        makePostLoading(tadp, 0);
+                    }
+                }
+            }
+            decX = decXTmp;
+            decY = decYTmp;
+            decId = decIdTmp;
+        } catch (SAXException saxe) {
+            TraceManager.addError("Loading 701 " + saxe.getMessage());
+            throw new MalformedModelingException();
+        }
+    }
+
+    public void loadAvatarSMD(TDiagramPanel tdp, String oldValue, String newValue) throws MalformedModelingException {
+        TraceManager.addDev("---> Load activity diagram of old=" + oldValue + " new=" + newValue);
+        try {
+            NodeList smdNl = docCopy.getElementsByTagName("AVATARStateMachineDiagramPanel");
+
+            //TraceManager.addDev("Loading state machine diagram of " + newValue + " Before : " + oldValue);
+            //TraceManager.addDev("smdNL: " + smdNl);
+
+            if (smdNl == null) {
+                TraceManager.addDev("AVATAR: null doc");
+                throw new MalformedModelingException();
+            }
+
+            Node adn;
+            Element elt;
+            AvatarSMDPanel asmdp;
+            String name;
+            int decXTmp = decX;
+            int decYTmp = decY;
+            int decIdTmp = decId;
+
+            for (int i = 0; i < smdNl.getLength(); i++) {
+                adn = smdNl.item(i);
+                if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                    elt = (Element) adn;
+                    // class diagram name
+                    name = elt.getAttribute("name");
+                    TraceManager.addDev("Name of activity diagram=" + name);
+
+                    if (name.equals(oldValue)) {
+                        int indexDesign = mgui.getMajorIndexOf(tdp);
+
+                        if (indexDesign < 0) {
+                            throw new MalformedModelingException();
+                        }
+
+                        asmdp = mgui.getAvatarSMDPanel(indexDesign, newValue);
+
+                        TraceManager.addDev("Searching panel: " + newValue);
+
+                        if (asmdp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        TraceManager.addDev("Panel ok");
+
+                        decX = 0;
+                        decY = 0;
+                        decId = 0;
+
+
+                        asmdp.removeAll();
+
+                        loadDiagramInformation(elt, asmdp);
+
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), asmdp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), asmdp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), asmdp);
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " real points");
+                        connectConnectorsToRealPoints(asmdp);
+                        asmdp.structureChanged();
+                        //TraceManager.addDev("Activity diagram : " + tadp.getName() + " post loading");
+                        makePostLoading(asmdp, 0);
+                    }
+                }
+            }
+            decX = decXTmp;
+            decY = decYTmp;
+            decId = decIdTmp;
+        } catch (SAXException saxe) {
+            TraceManager.addError("Loading 801 " + saxe.getMessage());
+            throw new MalformedModelingException();
+        }
+    }
+
+    public void loadTMLActivityDiagram(TDiagramPanel tdp, String oldValue, String newValue) throws MalformedModelingException {
+        //TraceManager.addDev("---> Load TML activity diagram");
+        try {
+            if (docCopy == null) {
+                TraceManager.addDev("Null doc copy");
+            }
+            NodeList activityDiagramNl = docCopy.getElementsByTagName("TMLActivityDiagramPanel");
+
+            //TraceManager.addDev("Loading activity diagram of " + newValue + "Before : " + oldValue);
+
+            if (activityDiagramNl == null) {
+                //TraceManager.addDev("Null");
+                throw new MalformedModelingException();
+            }
+
+            Node adn;
+            Element elt;
+            TMLActivityDiagramPanel tmladp;
+            String name;
+            int decXTmp = decX;
+            int decYTmp = decY;
+            int decIdTmp = decId;
+
+            for (int i = 0; i < activityDiagramNl.getLength(); i++) {
+                adn = activityDiagramNl.item(i);
+                if (adn.getNodeType() == Node.ELEMENT_NODE) {
+                    elt = (Element) adn;
+                    // class diagram name
+                    name = elt.getAttribute("name");
+                    //TraceManager.addDev("Name of activity diagram=" + name);
+
+                    if (name.equals(oldValue)) {
+                        int indexDesign = mgui.getMajorIndexOf(tdp);
+
+                        if (indexDesign < 0) {
+                            throw new MalformedModelingException();
+                        }
+
+                        tmladp = mgui.getTMLActivityDiagramPanel(indexDesign, newValue);
+
+                        //TraceManager.addDev("Searching panel");
+
+                        if (tmladp == null) {
+                            throw new MalformedModelingException();
+                        }
+
+                        //TraceManager.addDev("Panel ok");
+
+                        decX = 0;
+                        decY = 0;
+                        decId = 0;
+
+                        tmladp.removeAll();
+
+                        loadDiagramInformation(elt, tmladp);
+
+                        //TraceManager.addDev("Activity diagram : " + tmladp.getName() + " components");
+                        makeXMLComponents(elt.getElementsByTagName("COMPONENT"), tmladp);
+                        //TraceManager.addDev("Activity diagram : " + tmladp.getName() + " connectors");
+                        makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), tmladp);
+                        //TraceManager.addDev("Activity diagram : " + tmladp.getName() + " subcomponents");
+                        makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), tmladp);
+                        //TraceManager.addDev("Activity diagram : " + tmladp.getName() + " real points");
+                        connectConnectorsToRealPoints(tmladp);
+                        tmladp.structureChanged();
+                        //TraceManager.addDev("Activity diagram : " + tmladp.getName() + " post loading");
+                        makePostLoading(tmladp, 0);
+                    }
+                }
+            }
+            decX = decXTmp;
+            decY = decYTmp;
+            decId = decIdTmp;
+        } catch (SAXException saxe) {
+            TraceManager.addError("Loading 901 " + saxe.getMessage());
+            throw new MalformedModelingException();
+        }
+    }
+
+    public void makePostLoading(TDiagramPanel tdp, int beginIndex) throws MalformedModelingException {
+        TGComponent tgc;
+
+        //TraceManager.addDev("Post loading of diagram " + tdp.toString());
+
+        List<TGComponent> list = tdp.getComponentList();
+
+        for (int i = 0; i < list.size() - beginIndex; i++) {
+            tgc = list.get(i);
+            //TraceManager.addDev(tgc.getName());
+            //TraceManager.addDev(tgc.getValue());
+            tgc.makePostLoading(decId);
+        }
+        /*SwingUtilities.invokeAndWait(new Runnable() {
+          public void run() {
+          mgui.repaintAll();
+          }
+          });*/
+
+
+        //TraceManager.addDev("Post loading of diagram " + tdp.toString() + " achieved");
+    }
+
+    public void makeXMLComponents(NodeList nl, TDiagramPanel tdp) throws SAXException, MalformedModelingException {
+        Node n;
+        //Element elt;
+        TGComponent tgc;
+
+        if (tdp == null) {
+            throw new MalformedModelingException();
+        }
+        //boolean error = false;
+
+        tdp.drawable = false;
+
+        try {
+
+            for (int i = 0; i < nl.getLength(); i++) {
+                n = nl.item(i);
+                if (n.getNodeType() == Node.ELEMENT_NODE) {
+                    try {
+                        tgc = makeXMLComponent(n, tdp);
+                        //TraceManager.addDev("About to add component= " + tgc);
+                        if ((tgc != null) && (tgc.getFather() == null)) {
+                            //TraceManager.addDev("Component added to diagram tgc=" + tgc);
+                            tdp.addBuiltComponent(tgc);
+                        } else if (tgc == null) {
+                            TraceManager.addDev("Component not added to diagram:" + tgc);
+                        }
+                    } catch (MalformedModelingException mme) {
+                        int type = getTypeOfComponentNode(n);
+                        String t = "unknown";
+                        if (type > 0) {
+                            t = "" + type;
+                        }
+                        TraceManager.addDev("A badly formed component could not be created in the diagram");
+
+                        UICheckingError ce = new UICheckingError(CheckingError.BEHAVIOR_ERROR, "A component could not be correctly loaded - type=" + t);
+                        ce.setTDiagramPanel(tdp);
+                        checkingErrors.add(ce);
+                        //error = true;
+                    }
+                }
+            }
+
+        } catch (SAXException se) {
+            tdp.drawable = true;
+            throw se;
+        } catch (Exception e) {
+            tdp.drawable = true;
+            throw e;
+        }
+
+        tdp.drawable = true;
+
+        /*if (error) {
+          throw new MalformedModelingException();
+          }*/
+    }
+
+    public int getTypeOfComponentNode(Node n) {
+        try {
+            //NodeList nl = n.getChildNodes();
+            Element elt = (Element) n;
+            return Integer.decode(elt.getAttribute("type")).intValue();
+        } catch (Exception e) {
+        }
+        return -1;
+    }
+
+
+    public TGComponent makeXMLComponent(Node n, TDiagramPanel tdp) throws SAXException, MalformedModelingException {
+        Element elt;
+        Element elt1;
+        TGComponent tgc = null;
+        TGComponent father;
+        //  TGComponent reference;
+
+        //
+        try {
+
+            NodeList nl = n.getChildNodes();
+            elt = (Element) n;
+            elt1 = elt;
+            //TraceManager.addDev("elt=" + elt);
+
+            int myType = Integer.decode(elt.getAttribute("type")).intValue();
+            int myId = Integer.decode(elt.getAttribute("id")).intValue() + decId;
+
+            int myX = -1, myY = -1, myWidth = -1, myHeight = -1;
+            int myMinWidth = -1, myMinHeight = -1, myMinDesiredWidth = -1, myMinDesiredHeight = -1;
+            int myMinX = -1, myMaxX = -1, myMinY = -1, myMaxY = -1;
+            String myName = null, myValue = null;
+            Vector<Point> tgcpList = new Vector<Point>();
+            Point p;
+            int i, x, y;
+            int fatherId = -1, fatherNum = -1;
+            int referenceId = -1;
+            String pre = "", post = "";
+            String internalComment = "";
+            boolean accessibility = false;
+            boolean latencyCheck = false;
+            boolean invariant = false;
+            boolean breakpoint = false;
+            boolean hidden = false;
+            boolean masterMutex = false;
+            boolean enable = true;
+
+            for (i = 0; i < nl.getLength(); i++) {
+                n = nl.item(i);
+                if (n.getNodeType() == Node.ELEMENT_NODE) {
+                    elt = (Element) n;
+                    if (elt.getTagName().equals("cdparam")) {
+                        myX = Integer.decode(elt.getAttribute("x")).intValue() + decX;
+                        myY = Integer.decode(elt.getAttribute("y")).intValue() + decY;
+                    } else if (elt.getTagName().equals("sizeparam")) {
+                        myWidth = Integer.decode(elt.getAttribute("width")).intValue();
+                        myHeight = Integer.decode(elt.getAttribute("height")).intValue();
+                        myMinWidth = Integer.decode(elt.getAttribute("minWidth")).intValue();
+                        myMinHeight = Integer.decode(elt.getAttribute("minHeight")).intValue();
+                        myMinDesiredWidth = Integer.decode(elt.getAttribute("minDesiredWidth")).intValue();
+                        myMinDesiredHeight = Integer.decode(elt.getAttribute("minDesiredHeight")).intValue();
+                    } else if (elt.getTagName().equals("cdrectangleparam")) {
+                        myMinX = Integer.decode(elt.getAttribute("minX")).intValue();
+                        myMaxX = Integer.decode(elt.getAttribute("maxX")).intValue();
+                        myMinY = Integer.decode(elt.getAttribute("minY")).intValue();
+                        myMaxY = Integer.decode(elt.getAttribute("maxY")).intValue();
+                    } else if (elt.getTagName().equals("infoparam")) {
+                        myName = elt.getAttribute("name");
+                        myValue = elt.getAttribute("value");
+                    } else if (elt.getTagName().equals("hidden")) {
+                        hidden = elt.getAttribute("value").equals("true");
+                    } else if (elt.getTagName().equals("enabled")) {
+                        enable = elt.getAttribute("value").equals("true");
+                    } else if (elt.getTagName().equals("TGConnectingPoint")) {
+                        x = Integer.decode(elt.getAttribute("num")).intValue();
+                        y = Integer.decode(elt.getAttribute("id")).intValue() + decId;
+                        tgcpList.add(new Point(x, y));
+                    } else if (elt.getTagName().equals("father")) {
+                        fatherId = Integer.decode(elt.getAttribute("id")).intValue();
+                        fatherNum = Integer.decode(elt.getAttribute("num")).intValue();
+                    } else if (elt.getTagName().equals("reference")) {
+                        referenceId = Integer.decode(elt.getAttribute("id")).intValue();
+                    } else if (elt.getTagName().equals("prejavacode")) {
+                        pre += elt.getAttribute("value") + "\n";
+                    } else if (elt.getTagName().equals("postjavacode")) {
+                        post += elt.getAttribute("value") + "\n";
+                    } else if (elt.getTagName().equals("InternalComment")) {
+                        internalComment += elt.getAttribute("value") + "\n";
+                    } else if (elt.getTagName().equals("accessibility")) {
+                        accessibility = true;
+                    } else if (elt.getTagName().equals("latencyCheck")) {
+                        latencyCheck = true;
+                    } else if (elt.getTagName().equals("invariant")) {
+                        invariant = true;
+                    } else if (elt.getTagName().equals("mastermutex")) {
+                        masterMutex = true;
+                    } else if (elt.getTagName().equals("breakpoint")) {
+                        breakpoint = true;
+                    }
+                }
+            }
+
+            if ((myId == -1) || (myX == -1) || (myY == -1) || (myWidth == -1) || (myHeight == -1)) {
+                throw new MalformedModelingException();
+            }
+
+            //TraceManager.addDev("Making TGComponent of type " + myType + " and of name " + myName);
+            //TGComponent is ready to be built
+
+
+            if (fatherId != -1) {
+                fatherId += decId;
+                // internal component
+                //TraceManager.addDev("I am " + myName);
+                //TraceManager.addDev("Searching for component with id " + fatherId);
+                father = tdp.findComponentWithId(fatherId);
+                if (father == null) {
+                    throw new MalformedModelingException();
+                }
+
+                //TraceManager.addDev("Done");
+                //TraceManager.addDev("Father My value is " + father.getValue());
+                //TraceManager.addDev("My class is " + father.getClass());
+
+                //TraceManager.addDev("Searching for component " + fatherNum + " at " + tgc.getName());
+                tgc = father.getInternalTGComponent(fatherNum);
+
+                if (tgc == null) {
+                    // To be added to its father -> swallow component
+                    if (father instanceof SwallowTGComponent) {
+                        //TraceManager.addDev("1 Must add the component to its father:");
+                        tgc = TGComponentManager.addComponent(myX, myY, myType, tdp);
+                        //TraceManager.addDev("2 Must add the component to its father:" + tgc);
+                        if (tgc instanceof SwallowedTGComponent) {
+                            //TraceManager.addDev("3 Must add the component to its father:");
+                            ((SwallowTGComponent) father).addSwallowedTGComponent(tgc, myX, myY);
+                            //TraceManager.addDev("Swallowed to father = " + father.getValue() + ". My name=" + myName + " decId=" + decId);
+                        } else {
+                            throw new MalformedModelingException();
+                        }
+                    } else {
+                        throw new MalformedModelingException();
+                    }
+                }
+
+                if (tgc != null) {
+                    tgc.setCdRectangle(myMinX, myMaxX, myMinY, myMaxY);
+                    tgc.setCd(myX, myY);
+                    //TraceManager.addDev("set cd of " + tgc.getName());
+                }
+            } else {
+                tgc = TGComponentManager.addComponent(myX, myY, myType, tdp);
+            }
+            // TraceManager.addDev("TGComponent (" + tgc + ") built " + myType);
+
+            if (tgc == null) {
+                throw new MalformedModelingException();
+            }
+
+            if (myName != null) {
+                tgc.setName(myName);
+            }
+
+
+            if (referenceId != -1) {
+                referenceId += decId;
+                for (TURTLEPanel turtlepanel : panels) {
+                    for (TDiagramPanel tdpanel : turtlepanel.panels) {
+                        if (tdpanel.findComponentWithId(referenceId) != null) {
+                            tgc.reference = tdpanel.findComponentWithId(referenceId);
+                            break;
+                        }
+                    }
+                }
+            }
+
+            tgc.setEnabled(enable);
+
+            /*if (tgc instanceof TCDTObject) {
+              TraceManager.addDev("Loading " + myValue);
+              }*/
+
+            String oldClassName = myValue;
+            //TraceManager.addDev("Old class name=" + oldClassName);
+            //Added by Solange
+            if ((myValue != null) && (!myValue.equals(null))) {
+                if (tgc instanceof ProCSDComponent) {
+                    //Added by Solange
+                    //And removed by emil
+                    //myValue=generateNameIfInUse(myValue);
+                    //  tgc.setValueWithChange(myValue);
+                    //TraceManager.addDev("myValue=" + myValue);
+                }
+                //until here
+                if ((tgc instanceof TCDTClass) && (decId > 0)) {
+                    if (tdp.isAlreadyATClassName(myValue)) {
+                        myValue = tdp.findTClassName(myValue + "_");
+                    }
+                }
+                if ((tgc instanceof TMLTaskOperator) && (decId > 0)) {
+                    if (tdp.isAlreadyATMLTaskName(myValue)) {
+                        myValue = tdp.findTMLTaskName(myValue + "_");
+                    }
+                }
+
+                if ((tgc instanceof AvatarBDBlock) && (decId > 0)) {
+                    if (tdp.isAlreadyAnAvatarBDBlockName(myValue)) {
+                        myValue = tdp.findAvatarBDBlockName(myValue + "_");
+                    }
+                }
+
+                if ((tgc instanceof TMLCPrimitiveComponent) && (decId > 0)) {
+                    if (tdp.isAlreadyATMLPrimitiveComponentName(myValue)) {
+                        myValue = tdp.findTMLPrimitiveComponentName(myValue + "_");
+                    }
+                    //TraceManager.addDev("MyValue=" + myValue);
+                }
+                if ((tgc instanceof TOSClass) && (decId > 0)) {
+                    if (tdp.isAlreadyATOSClassName(myValue)) {
+                        myValue = tdp.findTOSClassName(myValue + "_");
+                    }
+                }
+                //TraceManager.addDev("myValue=" + myValue);
+                tgc.setValueWithChange(myValue);
+                //TraceManager.addDev("value done");
+                if ((tgc instanceof TCDTClass) && (decId > 0)) {
+                    loadActivityDiagram(tdp, oldClassName, myValue);
+                }
+
+                if ((tgc instanceof AvatarBDBlock) && (decId > 0)) {
+                    //TraceManager.addDev("Going to load ad of task " + oldClassName + " myValue=" + myValue);
+                    loadAvatarSMD(tdp, oldClassName, myValue);
+                }
+
+                if ((tgc instanceof TMLTaskOperator) && (decId > 0)) {
+                    //TraceManager.addDev("Going to load ad of task " + oldClassName + " myValue=" + myValue);
+                    loadTMLActivityDiagram(tdp, oldClassName, myValue);
+                }
+
+                if ((tgc instanceof TMLCPrimitiveComponent) && (decId > 0)) {
+                    //TraceManager.addDev("Going to load ad of component " + oldClassName + " myValue=" + myValue);
+                    loadTMLActivityDiagram(tdp, oldClassName, myValue);
+                }
+            }
+
+            tgc.forceId(myId);
+            tgc.setLoaded(true);
+            tgc.setInternalLoaded(false);
+            tgc.setMinSize(myMinWidth, myMinHeight);
+            tgc.setMinDesiredSize(myMinDesiredWidth, myMinDesiredHeight);
+            tgc.resize(myWidth, myHeight);
+            tgc.hasBeenResized();
+
+            //TraceManager.addDev("Options set");
+
+            if (pre.compareTo("") != 0) {
+                tgc.setPreJavaCode(pre);
+            }
+            if (post.compareTo("") != 0) {
+                tgc.setPostJavaCode(post);
+            }
+
+            if (internalComment.compareTo("") != 0) {
+                tgc.setInternalComment(internalComment);
+            }
+
+            if (accessibility) {
+                tgc.setCheckableAccessibility(accessibility);
+
+            }
+
+            if (latencyCheck) {
+                tgc.setCheckLatency(latencyCheck);
+
+            }
+            if (invariant) {
+                tgc.setCheckableInvariant(invariant);
+            }
+
+            if (masterMutex) {
+                tgc.setMasterMutex(true);
+            }
+
+            if (breakpoint) {
+                tgc.setBreakpoint(breakpoint);
+            }
+
+            //extra param
+            // TraceManager.addDev("Extra params" + tgc.getClass());
+            // TraceManager.addDev("My value = " + tgc.getValue());
+            tgc.loadExtraParam(elt1.getElementsByTagName("extraparam"), decX, decY, decId);
+            // TraceManager.addDev("Extra param ok");
+
+            if ((tgc instanceof TCDTObject) && (decId > 0)) {
+                TCDTObject to = (TCDTObject) tgc;
+                //TraceManager.addDev("Setting TObject name to: " + to.getObjectName());
+                //TraceManager.addDev("Setting TObject name to: " + tdp.findTObjectName(to.getObjectName()));
+                to.setObjectName(tdp.findTObjectName(to.getObjectName()));
+            }
+
+            //TraceManager.addDev(tgc.toString());
+
+            //TraceManager.addDev("Making connecting points " + tgcpList.size());
+            for (i = 0; i < tgcpList.size(); i++) {
+                p = tgcpList.elementAt(i);
+                if (!tgc.setIdTGConnectingPoint(p.x, p.y)) {
+                    //TraceManager.addDev("Warning: a connecting point has been removed");
+                    //throw new MalformedModelingException();
+                }
+            }
+
+            //TraceManager.addDev("Not yet except!");
+            if (decId > 0) {
+                tdp.bringToFront(tgc);
+            }
+            //TraceManager.addDev("Connecting points done " + myType);
+
+            /*if (tgc instanceof TCDTObject) {
+              TraceManager.addDev("getValue " + tgc.getValue());
+              }*/
+
+        } catch (Exception e) {
+            // TraceManager.addError("Exception XML Component "/* + e.getMessage() + "trace=" + e.getStackTrace()*/);
+            throw new MalformedModelingException();
+        }
+        return tgc;
+    }
+
+    //method added by Solange
+
+    public String generateNameIfInUse(String myName) {
+        if (!(mgui.getCurrentTURTLEPanel().nameInUse(myName))) {
+            return myName;
+        }
+
+        String other;
+        for (int w = 0; w < 100000; w++) {
+            other = myName + "_" + w;
+            if (!(mgui.getCurrentTURTLEPanel().nameInUse(other))) {
+                return other;
+            }
+        }
+        return null;
+    }
+    //until here
+
+    public void makePostProcessing(TDiagramPanel tdp) throws MalformedModelingException {
+        //TraceManager.addDev("Make post processing!");
+        if (tdp instanceof TClassDiagramPanel) {
+            ((TClassDiagramPanel) tdp).makePostLoadingProcessing();
+        }
+        //TraceManager.addDev("Post processing is over");
+    }
+
+    public void makeXMLConnectors(NodeList nl, TDiagramPanel tdp) throws SAXException, MalformedModelingException {
+        Node n;
+        //Element elt;
+        TGConnector tgco = null;
+        int i;
+
+        if (tdp == null) {
+            throw new MalformedModelingException();
+        }
+
+        for (i = 0; i < nl.getLength(); i++) {
+            n = nl.item(i);
+            if (n.getNodeType() == Node.ELEMENT_NODE) {
+                tgco = makeXMLConnector(n, tdp);
+                if (tgco != null) {
+                    tdp.addBuiltConnector(tgco);
+                } else {
+                    TraceManager.addDev("Connector error");
+                    throw new MalformedModelingException();
+                }
+            }
+        }
+    }
+
+    public void connectConnectorsToRealPoints(TDiagramPanel tdp) throws MalformedModelingException {
+        List<TGComponent> list = tdp.getComponentList();
+        TGConnectingPoint p1, p2, p3, p4;
+        //TGConnectingPointTmp p;
+        int i;
+        TGComponent tgc;
+        //TGComponent tgctmp;
+        TGConnector tgco = null;
+        //boolean error = false;
+        TGConnectorInfo tgcoinfo;
+
+
+        //connect connectors to their real connecting point
+        //TraceManager.addDev("Valid connectors ?");
+        for (i = 0; i < list.size(); i++) {
+            tgc = list.get(i);
+            if (tgc instanceof TGConnector) {
+                tgco = (TGConnector) tgc;
+                p1 = tgco.getTGConnectingPointP1();
+                p2 = tgco.getTGConnectingPointP2();
+                if ((p1 instanceof TGConnectingPointTmp) && (p2 instanceof TGConnectingPointTmp)) {
+                    //TraceManager.addDev("Searching for id " + p1.getId());
+                    p3 = tdp.findConnectingPoint(p1.getId());
+                    //TraceManager.addDev("Searching for id " + p2.getId());
+                    p4 = tdp.findConnectingPoint(p2.getId());
+                    if (((p3 == null) || (p4 == null)) && (decId != 0)) {
+                        if (list.remove(tgc)) {
+                            i--;
+                        } else {
+                            throw new MalformedModelingException();
+                        }
+                    } else {
+                        if ((p3 == null) || (p4 == null)) {
+                            //warning = true;
+                            if (p3 == null) {
+                                //TraceManager.addDev("Error on first id");
+                            }
+                            if (p4 == null) {
+                                //TraceManager.addDev("Error on second id");
+                            }
+                            tgcoinfo = new TGConnectorInfo();
+                            tgcoinfo.connector = tgco;
+                            pendingConnectors.add(tgcoinfo);
+                            TraceManager.addDev("One connector added to pending list");
+                        } else {
+                            tgco.setP1(p3);
+                            p3.setFree(false);
+                            tgco.setP2(p4);
+                            p4.setFree(false);
+                        }
+                    }
+                }
+            }
+        }
+
+        /*for(TGConnector con: connectorsToRemove) {
+          list.remove(con);
+          }*/
+
+        /*if (error) {
+          TraceManager.addDev("Connecting error: " + connectorsToRemove.size()  + " connectors have been removed");
+          throw new MalformedModelingException();
+          }*/
+    }
+
+    public void makeLastLoad() {
+        // Update references on all diagrams
+        //TraceManager.addDev("Updating ports");
+        //mgui.updateAllPorts();
+
+        // Update ports on all diagrams
+        //TraceManager.addDev("Updating references / ports");
+        mgui.updateAllReferences();
+
+        mgui.updateAllPorts();
+
+        //TraceManager.addDev("Pending connectors");
+        // Make use of pending connectors
+        TGConnectingPoint p1, p2, p3, p4;
+        TDiagramPanel tdp;
+        TGConnector tgco;
+        for (TGConnectorInfo info : pendingConnectors) {
+            tgco = info.connector;
+            if (tgco != null) {
+                tdp = tgco.getTDiagramPanel();
+                if (tdp != null) {
+                    p1 = tgco.getTGConnectingPointP1();
+                    p2 = tgco.getTGConnectingPointP2();
+                    if ((p1 instanceof TGConnectingPointTmp) && (p2 instanceof TGConnectingPointTmp)) {
+                        TraceManager.addDev("Searching for id " + p1.getId());
+                        p3 = tdp.findConnectingPoint(p1.getId());
+                        TraceManager.addDev("Searching for id " + p2.getId());
+                        p4 = tdp.findConnectingPoint(p2.getId());
+                        if ((p3 == null) || (p4 == null)) {
+                            //warning = true;
+                            if (p3 == null) {
+                                TraceManager.addDev("Error on first id");
+                            }
+                            if (p4 == null) {
+                                TraceManager.addDev("Error on second id");
+                            }
+                            TraceManager.addDev("One connector ignored");
+                        } else {
+                            tgco.setP1(p3);
+                            p3.setFree(false);
+                            tgco.setP2(p4);
+                            p4.setFree(false);
+                        }
+                    }
+                }
+            }
+        }
+        pendingConnectors.clear();
+        //TraceManager.addDev("Last load done");
+    }
+
+    public TGConnector makeXMLConnector(Node n, TDiagramPanel tdp) throws SAXException, MalformedModelingException {
+        Element elt, elt1;
+        TGConnector tgco = null;
+        //TGComponent tgc = null;
+
+        //TraceManager.addDev(n.toString());
+
+        try {
+
+            NodeList nl = n.getChildNodes();
+            elt = (Element) n;
+            elt1 = elt;
+
+            int myType = Integer.decode(elt.getAttribute("type")).intValue();
+            int myId = Integer.decode(elt.getAttribute("id")).intValue() + decId;
+
+            int myX = -1, myY = -1, myWidth = -1, myHeight = -1;
+            int myMinWidth = -1, myMinHeight = -1, myMinDesiredWidth = -1, myMinDesiredHeight = -1;
+            int myMaxWidth = -1, myMaxHeight = -1;
+            String myName = null, myValue = null;
+            int tmpx, tmpy, tmpid;
+            TGConnectingPoint p1 = null, p2 = null;
+            Vector<Point> pointList = new Vector<Point>();
+
+            Vector<Point> tgcpList = new Vector<Point>();
+            Point p;
+            int i, x, y;
+            //int fatherId = -1, fatherNum = -1;
+            boolean automaticDrawing = true;
+
+            for (i = 0; i < nl.getLength(); i++) {
+                n = nl.item(i);
+                if (n.getNodeType() == Node.ELEMENT_NODE) {
+                    elt = (Element) n;
+                    if (elt.getTagName().equals("cdparam")) {
+                        myX = Integer.decode(elt.getAttribute("x")).intValue() + decX;
+                        myY = Integer.decode(elt.getAttribute("y")).intValue() + decY;
+                    } else if (elt.getTagName().equals("sizeparam")) {
+                        myWidth = Integer.decode(elt.getAttribute("width")).intValue();
+                        myHeight = Integer.decode(elt.getAttribute("height")).intValue();
+                        myMinWidth = Integer.decode(elt.getAttribute("minWidth")).intValue();
+                        myMinHeight = Integer.decode(elt.getAttribute("minHeight")).intValue();
+                        if ((elt.getAttribute("maxWidth") != null) && (elt.getAttribute("maxWidth").length() > 0)) { // Test is made for compatibility with old versions
+                            //TraceManager.addDev("maxWidth = " +  elt.getAttribute("maxWidth"));
+                            myMaxWidth = Integer.decode(elt.getAttribute("maxWidth")).intValue();
+                            myMaxHeight = Integer.decode(elt.getAttribute("maxHeight")).intValue();
+                        }
+                        myMinDesiredWidth = Integer.decode(elt.getAttribute("minDesiredWidth")).intValue();
+                        myMinDesiredHeight = Integer.decode(elt.getAttribute("minDesiredHeight")).intValue();
+                    } else if (elt.getTagName().equals("infoparam")) {
+                        myName = elt.getAttribute("name");
+                        myValue = elt.getAttribute("value");
+                    } else if (elt.getTagName().equals("P1")) {
+                        tmpx = Integer.decode(elt.getAttribute("x")).intValue() + decX;
+                        tmpy = Integer.decode(elt.getAttribute("y")).intValue() + decY;
+                        tmpid = Integer.decode(elt.getAttribute("id")).intValue() + decId;
+                        TGComponent tgc1 = TGComponentManager.addComponent(tmpx, tmpy, TGComponentManager.TAD_START_STATE, tdp);
+                        p1 = new TGConnectingPointTmp(tgc1, tmpx, tmpy, tmpid);
+                        //TraceManager.addDev("P1id = " + tmpid);
+                    } else if (elt.getTagName().equals("P2")) {
+                        tmpx = Integer.decode(elt.getAttribute("x")).intValue() + decX;
+                        tmpy = Integer.decode(elt.getAttribute("y")).intValue() + decY;
+                        tmpid = Integer.decode(elt.getAttribute("id")).intValue() + decId;
+                        TGComponent tgc2 = TGComponentManager.addComponent(tmpx, tmpy, TGComponentManager.TAD_START_STATE, tdp);
+                        p2 = new TGConnectingPointTmp(tgc2, tmpx, tmpy, tmpid);
+                        //TraceManager.addDev("P2id = " + tmpid);
+                    } else if (elt.getTagName().equals("Point")) {
+                        tmpx = Integer.decode(elt.getAttribute("x")).intValue() + decX;
+                        tmpy = Integer.decode(elt.getAttribute("y")).intValue() + decY;
+                        pointList.add(new Point(tmpx, tmpy));
+                    } else if (elt.getTagName().equals("TGConnectingPoint")) {
+                        x = Integer.decode(elt.getAttribute("num")).intValue();
+                        y = Integer.decode(elt.getAttribute("id")).intValue() + decId;
+                        tgcpList.add(new Point(x, y));
+                        //TraceManager.addDev(" adding Connecting point !");
+                    } else if (elt.getTagName().equals("AutomaticDrawing")) {
+                        //TraceManager.addDev("AutomaticDrawing=" + elt.getAttribute("data"));
+                        //TraceManager.addDev("set to true");
+                        automaticDrawing = elt.getAttribute("data").compareTo("true") == 0;
+                        //automaticDrawing = Boolean.getBoolean(elt.getAttribute("data"));
+                    }
+                }
+            }
+
+            if ((myType == -1) || (myId == -1) || (myX == -1) || (myY == -1) || (myWidth == -1) || (myHeight == -1) || (p1 == null) || (p2 == null)) {
+                throw new MalformedModelingException();
+            }
+
+            //TGConnector is ready to be built
+            //TraceManager.addDev("Making TGConnector of type " + myType);
+            tgco = TGComponentManager.addConnector(myX, myY, myType, tdp, p1, p2, pointList);
+            //TraceManager.addDev("TGConnector built " + myType);
+
+            if (tgco == null) {
+                TraceManager.addDev("TGCO is null myType: " + myType);
+                throw new MalformedModelingException();
+            }
+
+            tgco.setAutomaticDrawing(automaticDrawing);
+
+            if (myName != null) {
+                tgco.setName(myName);
+            }
+            if ((myValue != null) && (!myValue.equals(null))) {
+                tgco.setValueWithChange(myValue);
+            }
+
+            tgco.forceId(myId);
+            tgco.setLoaded(true);
+            tgco.setInternalLoaded(false);
+            tgco.setMinSize(myMinWidth, myMinHeight);
+            tgco.setMaxSize(myMaxWidth, myMaxHeight);
+            tgco.setMinDesiredSize(myMinDesiredWidth, myMinDesiredHeight);
+            tgco.resize(myWidth, myHeight);
+
+            tgco.loadExtraParam(elt1.getElementsByTagName("extraparam"), decX, decY, decId);
+
+            //TraceManager.addDev("Making connecting points " + myType);
+            for (i = 0; i < tgcpList.size(); i++) {
+                p = tgcpList.elementAt(i);
+                if (!tgco.setIdTGConnectingPoint(p.x, p.y)) {
+                    throw new MalformedModelingException();
+                }
+            }
+
+            if (decId > 0) {
+                tdp.bringToFront(tgco);
+            }
+
+            //TraceManager.addDev("Connecting points done " + myType);
+
+        } catch (Exception e) {
+            TraceManager.addError("Exception on connectors: HERE I AM");
+            throw new MalformedModelingException();
+        }
+        return tgco;
+    }
+
+
+    public boolean buildTURTLEModelingFromAnalysis(AnalysisPanel ap) throws AnalysisSyntaxException {
+
+        HMSC h;
+        //listE = new CorrespondanceTGElement();
+        checkingErrors = new LinkedList<CheckingError>();
+
+        AnalysisPanelTranslator apt = new AnalysisPanelTranslator(ap, mgui);
+
+        try {
+            h = apt.translateHMSC();
+            listE = apt.getCorrespondanceTGElement();
+            checkingErrors = apt.getErrors();
+            apt.translateMSCs(h);
+            listE = apt.getCorrespondanceTGElement();
+            checkingErrors = apt.getErrors();
+        } catch (AnalysisSyntaxException ase) {
+            CheckingError ce = new CheckingError(CheckingError.STRUCTURE_ERROR, ase.getMessage());
+            checkingErrors.add(ce);
+            throw ase;
+        }
+
+        SDTranslator sd = new SDTranslator(h);
+        checkingErrors = null;
+        warnings = new LinkedList<CheckingError>();
+        //TraceManager.addDev("Step 02");
+
+        mgui.setMode(MainGUI.VIEW_SUGG_DESIGN_KO);
+
+        //TraceManager.addDev("Step 1");
+        try {
+            tm = sd.toTURTLEModeling();
+            tmState = 0;
+        } catch (SDTranslationException e) {
+            checkingErrors = new LinkedList<CheckingError>();
+            CheckingError error = new CheckingError(CheckingError.STRUCTURE_ERROR, e.getMessage());
+            checkingErrors.add(error);
+
+            throw new AnalysisSyntaxException("Problem during translation to a design TURTLE modeling");
+        }
+
+        //TraceManager.addDev("Step 2");
+
+        if (checkingErrors != null) {
+            return false;
+        }
+
+        // modeling is built
+        // Now check it !
+        //TraceManager.addDev("Step 3");
+        TURTLEModelChecker tmc = new TURTLEModelChecker(tm);
+        checkingErrors = tmc.syntaxAnalysisChecking();
+        //TraceManager.addDev("Step 4");
+
+        if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+            mgui.setMode(MainGUI.VIEW_SUGG_DESIGN_KO);
+            return false;
+        } else {
+            mgui.setMode(MainGUI.VIEW_SUGG_DESIGN_OK);
+            return true;
+        }
+    }
+
+    public void generateDesign() {
+        generateDesign(tm);
+    }
+
+    public void generateDesign(TURTLEModeling tm) {
+        //TURTLEPanel tp = mgui.getCurrentTURTLEPanel();
+        nbSuggestedDesign++;
+        TURTLEModelingDrawer tmd = new TURTLEModelingDrawer(mgui);
+        tmd.setTURTLEModeling(tm);
+        tmd.draw(nbSuggestedDesign);
+        mgui.changeMade(null, -1);
+    }
+
+    public void generateIOD(HMSC _hmsc, MSC _msc) {
+        MSCDrawer mscd = new MSCDrawer(mgui);
+        mscd.setHMSC(_hmsc);
+        mscd.setMSC(_msc);
+        mscd.drawFromMSC(nbSuggestedDesign);
+        nbSuggestedDesign++;
+        mgui.changeMade(null, -1);
+    }
+
+    public boolean translateDeployment(DeploymentPanel dp) {
+        // Builds a TURTLE modeling from a deployment diagram
+        TraceManager.addDev("deployement");
+        checkingErrors = new LinkedList<CheckingError>();
+        warnings = new LinkedList<CheckingError>();
+        mgui.setMode(MainGUI.VIEW_SUGG_DESIGN_KO);
+        tm = new TURTLEModeling();
+        tmState = 0;
+        listE = new CorrespondanceTGElement();
+        mgui.reinitCountOfPanels();
+
+        List<TDDNode> ll;
+        Iterator<TDDNode> iterator;//, iterator2;
+
+        // First step: adding all necessary classes + their ad
+        ll = dp.tddp.getListOfNodes();
+        iterator = ll.listIterator();
+        TDDNode node;
+        Vector<TDDArtifact> artifacts;
+        TDDArtifact art;
+        int i;
+        DesignPanel dp2;
+        TGComponent tgc;
+        //TCDTClass tc;
+        String name;
+        TClass t;
+        DesignPanelTranslator dpt;
+
+        // Loop on nodes
+        while (iterator.hasNext()) {
+            node = iterator.next();
+
+            // Loop on artifact
+            artifacts = node.getArtifactList();
+            for (i = 0; i < artifacts.size(); i++) {
+                art = artifacts.elementAt(i);
+                dp2 = art.getDesignPanel();
+
+                final Iterator<TGComponent> iterator2 = dp2.tcdp.getComponentList().listIterator();
+                LinkedList<TClassInterface> tclasses = new LinkedList<TClassInterface>();
+                while (iterator2.hasNext()) {
+                    tgc = iterator2.next();
+                    if (tgc instanceof TClassInterface) {
+                        TraceManager.addDev("Found tclass: " + tgc.getValue());
+                        tclasses.add((TClassInterface) tgc);
+                    }
+                }
+                if (tclasses.size() > 0) {
+                    name = node.getNodeName() + "__" + art.getValue() + "__";
+                    dpt = new DesignPanelTranslator(dp2);
+                    dpt.addTClasses(dp2, tclasses, name, tm);
+                    dpt.addRelations(dp2, name, tm);
+
+                    listE.merge(dpt.getCorrespondanceTGElement());
+                    checkingErrors.addAll(dpt.getErrors());
+
+                    // Set package name of tclasses
+                    for (int j = 0; j < tclasses.size(); j++) {
+                        tgc = (TGComponent) tclasses.get(j);
+                        t = listE.getTClass(tgc);
+                        if (t != null) {
+                            TraceManager.addDev("Setting package name of " + t.getName() + " to " + node.getNodeName());
+                            t.setPackageName(node.getNodeName() + "_" + art.getValue());
+                        }
+                    }
+                }
+            }
+        }
+
+        // Second step : dealing with links!
+
+        DDTranslator ddt = new DDTranslator(dp, tm, listE);
+
+        try {
+            TraceManager.addDev("Dealing with links!");
+            ddt.translateLinks();
+        } catch (DDSyntaxException e) {
+            //throw new AnalysisSyntaxException("Problem during translation to a design TURTLE modeling");
+            TraceManager.addDev("Error during translation: " + e.getMessage());
+            return false;
+        }
+
+        mgui.setMode(MainGUI.GEN_DESIGN_OK);
+
+        if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+            return false;
+        }
+
+        // modeling is built
+        // Now check it !
+        TURTLEModelChecker tmc = new TURTLEModelChecker(tm);
+        checkingErrors = tmc.syntaxAnalysisChecking();
+
+        if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+            return false;
+        } else {
+            mgui.setMode(MainGUI.GEN_DESIGN_OK);
+            return true;
+        }
+    }
+
+    public boolean translateAttackTreePanel(AttackTreePanel atp) {
+        AttackTreePanelTranslator att = new AttackTreePanelTranslator(atp);
+        /*attackTree =*/
+        att.translateToAttackTreeDataStructure();
+        checkingErrors = att.getCheckingErrors();
+        warnings = att.getWarnings();
+        if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+            return false;
+        }
+        avatarspec = att.generateAvatarSpec();
+        //TraceManager.addDev("Avatar spec:" + avatarspec);
+        return true;
+    }
+
+    public boolean translateFaultTreePanel(FaultTreePanel atp) {
+        FaultTreePanelTranslator att = new FaultTreePanelTranslator(atp);
+        /*attackTree =*/
+        att.translateToFaultTreeDataStructure();
+        checkingErrors = att.getCheckingErrors();
+        warnings = att.getWarnings();
+        if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+            return false;
+        }
+        avatarspec = att.generateAvatarSpec();
+        //TraceManager.addDev("Avatar spec:" + avatarspec);
+        return true;
+    }
+
+    public boolean translateNC(NCPanel ncp) {
+        TraceManager.addDev("Translating NC");
+        checkingErrors = new LinkedList<CheckingError>();
+        warnings = new LinkedList<CheckingError>();
+        mgui.setMode(MainGUI.VIEW_SUGG_DESIGN_KO);
+
+        GNCModeling gncm = new GNCModeling(ncp);
+        ncs = gncm.translateToNCStructure();
+        listE = gncm.getCorrespondanceTable();
+
+        checkingErrors = gncm.getCheckingErrors();
+        warnings = gncm.getCheckingWarnings();
+
+        TraceManager.addDev("errors:" + checkingErrors.size() + " warnings:" + warnings.size());
+        if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+            return false;
+        } else {
+            // Generate XML file
+            try {
+                if (SpecConfigTTool.NCDirectory != null) {
+                    File dir = new File(SpecConfigTTool.NCDirectory);
+                    if (!dir.exists())
+                        dir.mkdirs();
+                }
+                String fileName = "network.xml";
+                if (SpecConfigTTool.NCDirectory != null) {
+                    fileName = SpecConfigTTool.NCDirectory + fileName;
+                }
+                TraceManager.addDev("Saving in network structure in file: " + fileName);
+                FileUtils.saveFile(fileName, ncs.toISAENetworkXML());
+                fileName = "traffics.xml";
+                if (SpecConfigTTool.NCDirectory != null) {
+                    fileName = SpecConfigTTool.NCDirectory + fileName;
+                }
+                TraceManager.addDev("Saving in traffics in file: " + fileName);
+                FileUtils.saveFile(fileName, ncs.toISAETrafficsXML());
+                TraceManager.addDev("Save done");
+            } catch (FileException fe) {
+                TraceManager.addError("Could not save NC in file:" + fe.getMessage());
+            }
+            mgui.setMode(MainGUI.NC_OK);
+            return true;
+        }
+
+    }
+
+    private void nullifyTMLModeling() {
+        tmlm = null;
+        artificialtmap = null;
+        tmap = null;
+        tmlcp = null;
+    }
+
+
+    public boolean translateTMLDesign(Vector<? extends TGComponent> tasksToTakeIntoAccount, TMLDesignPanel tmldp, boolean optimize) {
+        nullifyTMLModeling();
+        //  List<TMLError> warningsOptimize = new ArrayList<TMLError>();
+        warnings = new LinkedList<CheckingError>();
+        mgui.setMode(MainGUI.VIEW_SUGG_DESIGN_KO);
+
+        GTMLModeling gtmlm = new GTMLModeling(tmldp, true);
+        gtmlm.setTasks(tasksToTakeIntoAccount);
+        tmlm = gtmlm.translateToTMLModeling(true);
+        //tmlm.removeAllRandomSequences();
+        //TraceManager.addDev("New TML Modeling:" + tmlm.toString());
+        //mgui.generateTMLTxt();
+        artificialtmap = tmlm.getDefaultMapping();
+        tmap = null;
+        listE = gtmlm.getCorrespondanceTable();
+        //TraceManager.addDev("TML Modeling translated");
+        //TraceManager.addDev("----- TML Modeling -----");
+        //TraceManager.addDev(tmlm.toString());
+        //TraceManager.addDev("------------------------");
+        checkingErrors = gtmlm.getCheckingErrors();
+        warnings = gtmlm.getCheckingWarnings();
+
+        if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+            analyzeErrors();
+
+            return false;
+        } else {
+            //                  if (optimize) {
+            //                          warningsOptimize = tmlm.optimize();
+            //                  }
+
+            tmState = 2;
+            mgui.resetAllDIPLOIDs();
+            listE.useDIPLOIDs();
+            return true;
+            //TraceManager.addDev("tm generated:");
+            //tm.print();
+        }
+    }
+
+    public Vector<CheckingError> convertToCheckingErrorTMLErrors(List<TMLError> warningsOptimize, TDiagramPanel _tdp) {
+        Vector<CheckingError> v = new Vector<CheckingError>();
+        UICheckingError warning;
+
+        for (TMLError error : warningsOptimize) {
+            warning = new UICheckingError(CheckingError.BEHAVIOR_ERROR, error.message);
+            warning.setTDiagramPanel(_tdp);
+            v.add(warning);
+        }
+
+        return v;
+    }
+
+    public boolean translateTMLComponentDesign(Vector<? extends TGComponent> componentsToTakeIntoAccount, TMLComponentDesignPanel tmlcdp, boolean optimize) {
+        nullifyTMLModeling();
+        //      ArrayList<TMLError> warningsOptimize = new ArrayList<TMLError>();
+        warnings = new LinkedList<CheckingError>();
+        mgui.setMode(MainGUI.VIEW_SUGG_DESIGN_KO);
+
+        GTMLModeling gctmlm = new GTMLModeling(tmlcdp, true);
+        gctmlm.putPrefixName(true);
+        gctmlm.setComponents(componentsToTakeIntoAccount);
+        tmlm = gctmlm.translateToTMLModeling(true);
+        //mgui.generateTMLTxt();
+        artificialtmap = tmlm.getDefaultMapping();
+        tmap = null;
+        listE = gctmlm.getCorrespondanceTable();
+
+        //TraceManager.addDev("TML Modeling translated");
+        //TraceManager.addDev("----- TML Modeling -----");
+        //TraceManager.addDev(tmlm.toString());
+        //TraceManager.addDev("------------------------");
+        //mgui.generateTMLTxt();
+        checkingErrors = gctmlm.getCheckingErrors();
+        warnings = gctmlm.getCheckingWarnings();
+
+        if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+            analyzeErrors();
+            return false;
+        } else {
+            //                  if (optimize) {
+            //                          //TraceManager.addDev("OPTIMIZE");
+            //                          warningsOptimize = tmlm.optimize();
+            //                  }
+
+            tmState = 2;
+            //TraceManager.addDev("tm generated:");
+            mgui.resetAllDIPLOIDs();
+            listE.useDIPLOIDs();
+            return true;
+            //tm.print();
+        }
+    }
+
+    public boolean translateTMLModeling() {
+        TML2TURTLE tt = new TML2TURTLE(tmlm);
+        tm = tt.generateTURTLEModeling();
+        if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+            TraceManager.addDev("Error in TURTLE generation");
+            analyzeErrors();
+            return false;
+        } else {
+            // Optimize
+            TraceManager.addDev("Optimize");
+            tm.optimize();
+            TraceManager.addDev("Optimize done");
+            TURTLEModelChecker tmc = new TURTLEModelChecker(tm);
+            checkingErrors = tmc.syntaxAnalysisChecking();
+            if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+                analyzeErrors();
+                return false;
+            } else {
+                mgui.setMode(MainGUI.GEN_DESIGN_OK);
+                return true;
+            }
+        }
+    }
+
+/*    public boolean checkSyntaxSystemCAMS(Vector<TGComponent> blocksToTakeIntoAccount, SystemCAMSPanel scp, boolean optimize) { //ajout CD 04/07 FIXME
+        //     List<TMLError> warningsOptimize = new ArrayList<TMLError>();
+        //     warnings = new LinkedList<CheckingError> ();
+        //     mgui.setMode(MainGUI.VIEW_SUGG_DESIGN_KO);
+        //     GTMLModeling gtmlm = new GTMLModeling(scp, true);
+
+        // 	// gtmlm.setBlocks(blocksToTakeIntoAccount); //simply transforms the parameter from a Vector to LinkedList
+        //     nullifyTMLModeling();
+        //     tmlm = null;
+        //     tm = null;
+        //     tmState = 1;
+        // 	// scp = gtmlm.translateToSystemCAMS();
+
+        //     listE = gtmlm.getCorrespondanceTable();
+
+        //     checkingErrors = gtmlm.getCheckingErrors();
+        //     avatarspec = gtmlm.avspec;
+        //     if ((checkingErrors != null) && (checkingErrors.size() > 0)){
+        //         analyzeErrors();
+        //         warnings = gtmlm.getCheckingWarnings();
+        //         return false;
+        //     } else {
+        //         if (optimize) {
+        //             warningsOptimize = tmap.optimize();
+        //         }
+        // 	    //  warnings.addAll(convertToCheckingErrorTMLErrors(warningsOptimize, scp.scp));
+        //         mgui.resetAllDIPLOIDs();
+        //         listE.useDIPLOIDs();
+        //         mgui.setMode(MainGUI.GEN_DESIGN_OK);
+        return true;
+        //     }
+	}*/
+
+    public boolean checkSyntaxTMLMapping(Vector<TGComponent> nodesToTakeIntoAccount, TMLArchiPanel tmlap, boolean optimize) {
+        List<TMLError> warningsOptimize = new ArrayList<TMLError>();
+        warnings = new LinkedList<CheckingError>();
+        mgui.setMode(MainGUI.VIEW_SUGG_DESIGN_KO);
+        //TraceManager.addDev("New TML Mapping");
+        GTMLModeling gtmlm = new GTMLModeling(tmlap, true);
+
+
+        gtmlm.setNodes(nodesToTakeIntoAccount); //simply transforms the parameter from a Vector to LinkedList
+        nullifyTMLModeling();
+        tmlm = null;
+        tm = null;
+        tmState = 1;
+        tmap = gtmlm.translateToTMLMapping();
+
+        listE = gtmlm.getCorrespondanceTable();
+
+        checkingErrors = gtmlm.getCheckingErrors();
+        warnings = gtmlm.getCheckingWarnings();
+
+        avatarspec = gtmlm.avspec;
+        if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+            analyzeErrors();
+            return false;
+        } else {
+            //tmap.removeAllRandomSequences();
+            if (optimize) {
+                warningsOptimize = tmap.optimize();
+            }
+            warnings.addAll(convertToCheckingErrorTMLErrors(warningsOptimize, tmlap.tmlap));
+            mgui.resetAllDIPLOIDs();
+            listE.useDIPLOIDs();
+            mgui.setMode(MainGUI.GEN_DESIGN_OK);
+            return true;
+        }
+    }
+
+    //Newly introduced to perform Syntax check of CP diagrams. Actually the mapping of CPs onto the architecture is done via SDs,
+    //onto the application is done onto blocks in the architecture. It would be better to have all the mapping information in one
+    //diagram. Up to now, not taking the mapping information into account
+    public boolean checkSyntaxTMLCP(Vector<TGComponent> nodesToTakeIntoAccount, TMLCommunicationPatternPanel tmlcpp, boolean optimize) {
+
+        //nodesToTakeIntoAccount is the list of SDs and ADs corresponding that compose the CP selected for syntax checking
+        //      List<TMLError> warningsOptimize = new ArrayList<TMLError>();
+        warnings = new LinkedList<CheckingError>();
+        mgui.setMode(MainGUI.VIEW_SUGG_DESIGN_KO);
+        GTMLModeling gtmlm = new GTMLModeling(tmlcpp, true);
+
+        TraceManager.addDev("NodesToTakeIntoAccount :" + nodesToTakeIntoAccount.toString());
+
+        //Useless because nodesToTakeIntoAccount does not include the mainCP!
+        //gtmlm.setDiagramPanels( nodesToTakeIntoAccount );      //passes the list of nodes (SDs and ADs) to gtml as a LinkedList
+        tmlm = null;
+        tm = null;
+        tmState = 1;
+        nullifyTMLModeling();
+        //tmlcp is the data structure for a CP corresponding to the graphical description with diagrams
+        tmlcp = gtmlm.translateToTMLCPDataStructure(tmlcpp.getName());
+        //tmlcp.toString();
+        /*TraceManager.addDev( "I AM ABOUT TO GENERATE THE TMLtxt CODE!" );
+          mgui.generateTMLTxt();                //Now generating the TMLtxt code
+          TraceManager.addDev( "TMLtxt CODE GENERATION DONE" );*/
+        listE = gtmlm.getCorrespondanceTable();
+        //for( CorrespondanceTGElement element : listE.getNames() )      {
+        TraceManager.addDev("Printing listE.getNames: " + listE.getNames().toString());
+        TraceManager.addDev("Printing listE.getTG: " + listE.getTG().toString());
+        TraceManager.addDev("Printing listE.getPanelNames: " + listE.getPanelNames().toString());
+        TraceManager.addDev("Printing listE.getData: " + listE.getData().toString());
+        //}
+        checkingErrors = gtmlm.getCheckingErrors();
+
+        if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+            //analyzeErrors();
+
+            return false;
+        }
+        /*else {
+        //tmcp.removeAllRandomSequences();
+        if( optimize )  {
+        warningsOptimize = tmap.optimize();
+        //warningsOptimize = tmcp.optimize();
+        }
+        warnings.addAll( convertToCheckingErrorTMLErrors(warningsOptimize, tmlcpp.tmlcpp ) );
+        mgui.resetAllDIPLOIDs();
+        listE.useDIPLOIDs();
+        mgui.setMode( MainGUI.GEN_DESIGN_OK );
+        return true;
+        }*/
+        return true;    //It means that there are no errors
+    }
+
+    public boolean translateTMLMapping(boolean _sample, boolean _channel, boolean _event, boolean _request, boolean _exec, boolean _busTransfers, boolean _scheduling, boolean _taskState, boolean _channelState, boolean _branching, boolean _terminateCPU, boolean _terminateCPUs, boolean _clocked, String _tickValue, boolean _endClocked, boolean _countTick, boolean _maxCountTick, String _maxCountTickValue, boolean _randomTask) {
+        //TraceManager.addDev("TML=" + tmap.toString());
+        Mapping2TIF m2tif = new Mapping2TIF(tmap);
+        m2tif.setShowSampleChannels(_sample);
+        m2tif.setShowChannels(_channel);
+        m2tif.setShowEvents(_event);
+        m2tif.setShowRequests(_request);
+        m2tif.setShowExecs(_exec);
+        m2tif.setShowBusTransfers(_busTransfers);
+        m2tif.setShowScheduling(_scheduling);
+        m2tif.setIsClocked(_clocked);
+        m2tif.setTickValue(_tickValue);
+        m2tif.setIsEndClocked(_endClocked);
+        m2tif.setIsCountTick(_countTick);
+        m2tif.hasMaxCountTick(_maxCountTick);
+        if (_maxCountTick) {
+            m2tif.setMaxCountTickValue(_maxCountTickValue);
+        }
+        m2tif.setShowTaskState(_taskState);
+        m2tif.setShowChannelState(_channelState);
+        m2tif.setShowBlockedCPU(_terminateCPU);
+        m2tif.setShowTerminateCPUs(_terminateCPUs);
+        m2tif.setShowBranching(_branching);
+        m2tif.setRandomTasks(_randomTask);
+        tm = m2tif.generateTURTLEModeling();
+        //StringBuffer sb = tm.printToStringBuffer();
+        //TraceManager.addDev("tm=" + sb);
+
+        TraceManager.addDev("tm generated from TMAP");
+        checkingErrors = m2tif.getCheckingErrors();
+        if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+            return false;
+        }
+        mgui.setMode(MainGUI.GEN_DESIGN_OK);
+        return true;
+    }
+
+    //Added by Solange
+    public void generateLists(ProactiveDesignPanel pdp) {
+        gpdtemp = new GProactiveDesign(pdp);
+    }
+    //
+
+    public boolean translateTURTLEOSDesign(TURTLEOSDesignPanel tosdp) {
+        warnings = new LinkedList<CheckingError>();
+        mgui.setMode(MainGUI.VIEW_SUGG_DESIGN_KO);
+        //TraceManager.addDev("New TML Modeling");
+        GTURTLEOSModeling gosm = new GTURTLEOSModeling(tosdp);
+        //gtmlm.setTasks(tasksToTakeIntoAccount);
+        //tmlm = gosm.translateToTMLModeling();
+        //TraceManager.addDev("TML Modeling translated");
+        //TraceManager.addDev("----- TML Modeling -----");
+        //TraceManager.addDev(tmlm.toString());
+        //TraceManager.addDev("------------------------");
+        tm = gosm.generateTURTLEModeling();
+        tmState = 0;
+        checkingErrors = gosm.getCheckingErrors();
+
+        if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+            return false;
+        } else {
+
+            //TraceManager.addDev("Optimize");
+            tm.optimize();
+            //TraceManager.addDev("Optimize done");
+            TURTLEModelChecker tmc = new TURTLEModelChecker(tm);
+            checkingErrors = tmc.syntaxAnalysisChecking();
+            if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+                return false;
+            } else {
+                warnings = gosm.getCheckingWarnings();
+                warnings.addAll(tmc.getWarnings());
+                mgui.setMode(MainGUI.GEN_DESIGN_OK);
+                return true;
+            }
+        }
+    }
+
+
+    public boolean translateProactiveDesign(ProactiveDesignPanel pdp) {
+        mgui.setMode(MainGUI.VIEW_SUGG_DESIGN_KO);
+        GProactiveDesign gpd = new GProactiveDesign(pdp);
+
+        tm = gpd.generateTURTLEModeling();
+        tmState = 0;
+
+        if (gpd.checkSyntax() == false) {
+            TraceManager.addDev("Errors found");
+            warnings = gpd.getCheckingWarnings();
+            checkingErrors = gpd.getCheckingErrors();
+            return false;
+        }
+        TURTLEModelChecker tmc = new TURTLEModelChecker(tm);
+        checkingErrors = tmc.syntaxAnalysisChecking();
+        warnings = tmc.getWarnings();
+        if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+            return false;
+        } else {
+            //A faire:
+            //  tm.optimize();
+            //  warnings = gpd.getCheckingWarnings();
+            //  warnings.addAll(tmc.getWarnings());
+            mgui.setMode(MainGUI.GEN_DESIGN_OK);
+            return true;
+        }
+
+    }
+
+
+    public void addStates(AvatarStateMachineElement asme, int x, int y, AvatarSMDPanel smp, AvatarBDBlock bl, Map<AvatarStateMachineElement, TGComponent> SMDMap, Map<AvatarStateMachineElement, TGComponent> locMap, Map<AvatarTransition, AvatarStateMachineElement> tranDestMap, Map<AvatarTransition, TGComponent> tranSourceMap) {
+        // TGConnectingPoint tp = new TGConnectingPoint(null, x, y, false, false);
+        //Create dummy tgcomponent
+        TGComponent tgcomp = new AvatarSMDStartState(x, y, smp.getMinX(), smp.getMaxX(), smp.getMinY(), smp.getMaxY(), false, null, smp);
+        if (asme == null) {
+            return;
+        }
+        if (asme instanceof AvatarStartState) {
+            AvatarSMDStartState smdss = new AvatarSMDStartState(x, y, smp.getMinX(), smp.getMaxX(), smp.getMinY(), smp.getMaxY(), false, null, smp);
+            tgcomp = smdss;
+            smp.addComponent(smdss, x, y, false, true);
+            SMDMap.put(asme, smdss);
+            //   tp = smdss.tgconnectingPointAtIndex(0);
+            locMap.put(asme, smdss);
+        }
+        if (asme instanceof AvatarTransition) {
+            //
+        }
+        if (asme instanceof AvatarRandom) {
+            AvatarSMDRandom smdr = new AvatarSMDRandom(x, y, smp.getMinX(), smp.getMaxX(), smp.getMinY(), smp.getMaxY(), false, null, smp);
+            smdr.setVariable(((AvatarRandom) asme).getVariable());
+            smp.addComponent(smdr, x, y, false, true);
+            tgcomp = smdr;
+            SMDMap.put(asme, smdr);
+            locMap.put(asme, smdr);
+        }
+        if (asme instanceof AvatarActionOnSignal) {
+            avatartranslator.AvatarSignal sig = ((AvatarActionOnSignal) asme).getSignal();
+            if (sig.isIn()) {
+                AvatarSMDReceiveSignal smdrs = new AvatarSMDReceiveSignal(x, y, smp.getMinX(), smp.getMaxX(), smp.getMinY(), smp.getMaxY(), false, null, smp);
+                tgcomp = smdrs;
+                smp.addComponent(smdrs, x, y, false, true);
+                //                              String name=sig.minString();
+                //System.out.println("signal values" +((AvatarActionOnSignal)asme).getValues());
+                String parameters = "";
+                if (((AvatarActionOnSignal) asme).getValues().size() > 0) {
+                    parameters += ((AvatarActionOnSignal) asme).getValues().get(0);
+                    for (int i = 1; i < ((AvatarActionOnSignal) asme).getValues().size(); i++) {
+                        parameters = parameters + "," + ((AvatarActionOnSignal) asme).getValues().get(i);
+                    }
+                }
+                String name = sig.getName() + "(" + parameters + ")";
+                smdrs.setValue(name);
+                // sig.setName(name);
+                smdrs.recalculateSize();
+                SMDMap.put(asme, smdrs);
+                //   tp = smdrs.getFreeTGConnectingPoint(x+smdrs.getWidth()/2,y+smdrs.getHeight());
+                //  TGConnectingPoint tp2 = smdrs.getFreeTGConnectingPoint(x+smdrs.getWidth()/2,y);
+                locMap.put(asme, smdrs);
+                if (bl.getAvatarSignalFromName(name) == null) {
+                    //bl.addSignal(new ui.AvatarSignal(0, name, new String[0], new String[0]));
+                }
+
+            } else {
+                AvatarSMDSendSignal smdss = new AvatarSMDSendSignal(x, y, smp.getMinX(), smp.getMaxX(), smp.getMinY(), smp.getMaxY(), false, null, smp);
+                tgcomp = smdss;
+                smp.addComponent(smdss, x, y, false, true);
+                String parameters = "";
+                if (((AvatarActionOnSignal) asme).getValues().size() > 0) {
+                    parameters += ((AvatarActionOnSignal) asme).getValues().get(0);
+                    for (int i = 1; i < ((AvatarActionOnSignal) asme).getValues().size(); i++) {
+                        parameters = parameters + "," + ((AvatarActionOnSignal) asme).getValues().get(i);
+                    }
+                }
+                String name = sig.getName() + "(" + parameters + ")";
+                //String name=sig.minString();
+                smdss.setValue(name);
+                smdss.recalculateSize();
+                SMDMap.put(asme, smdss);
+                //  tp = smdss.getFreeTGConnectingPoint(x+smdss.getWidth()/2,y+smdss.getHeight());
+                //      TGConnectingPoint tp2 = smdss.getFreeTGConnectingPoint(x+smdss.getWidth()/2,y);
+                locMap.put(asme, smdss);
+                if (bl.getAvatarSignalFromName(name) == null) {
+                    // bl.addSignal(new ui.AvatarSignal(1, name, new String[0], new String[0]));
+                }
+            }
+
+        }
+        if (asme instanceof AvatarStopState) {
+            AvatarSMDStopState smdstop = new AvatarSMDStopState(x, y, smp.getMinX(), smp.getMaxX(), smp.getMinY(), smp.getMaxY(), false, null, smp);
+            tgcomp = smdstop;
+            SMDMap.put(asme, smdstop);
+            smp.addComponent(smdstop, x, y, false, true);
+            //  tp = smdstop.tgconnectingPointAtIndex(0);
+            locMap.put(asme, smdstop);
+        }
+        if (asme instanceof AvatarState) {
+            //check if empty checker state
+            /* if (asme.getName().contains("signalstate_")){
+            //don't add the state, ignore next transition,
+            if (asme.getNexts().size()==1){
+            AvatarStateMachineElement next = asme.getNext(0).getNext(0);
+            //Reroute transition
+            for (AvatarTransition at: tranDestMap.keySet()){
+            if (tranDestMap.get(at) == asme){
+            tranDestMap.put(at, next);
+            }
+            }
+            addStates(next, x, y, smp,bl, SMDMap, locMap, tranDestMap, tranSourceMap);
+            return;
+            }
+            }*/
+            AvatarSMDState smdstate = new AvatarSMDState(x, y, smp.getMinX(), smp.getMaxX(), smp.getMinY(), smp.getMaxY(), false, null, smp);
+            tgcomp = smdstate;
+            smp.addComponent(smdstate, x, y, false, true);
+            smdstate.setValue(asme.getName());
+            smdstate.recalculateSize();
+            SMDMap.put(asme, smdstate);
+            //   tp = smdstate.getFreeTGConnectingPoint(x+smdstate.getWidth()/2,y+smdstate.getHeight());
+            //  TGConnectingPoint tp2 = smdstate.getFreeTGConnectingPoint(x+smdstate.getWidth()/2,y);
+            locMap.put(asme, smdstate);
+        }
+        int i = 0;
+        int diff = 300;
+        int ydiff = 50;
+        //int num = asme.nbOfNexts();
+        if (!(asme instanceof AvatarTransition)) {
+            for (AvatarStateMachineElement el : asme.getNexts()) {
+                if (!(el instanceof AvatarTransition)) {
+                    System.out.println("ERROR: non-Transition " + asme + " connected to non-Transition " + el);
+                }
+            }
+        }
+        for (AvatarStateMachineElement el : asme.getNexts()) {
+            if (el instanceof AvatarTransition) {
+                tranSourceMap.put((AvatarTransition) el, tgcomp);
+            } else {
+                if (asme instanceof AvatarTransition) {
+                    AvatarTransition t = (AvatarTransition) asme;
+                    tranDestMap.put(t, el);
+                }
+            }
+            if (!SMDMap.containsKey(el)) {
+                addStates(el, x + diff * i, y + ydiff, smp, bl, SMDMap, locMap, tranDestMap, tranSourceMap);
+            }
+            i++;
+        }
+        return;
+    }
+
+    public void drawBlockProperties(AvatarBlock ab, AvatarBDBlock bl) {
+        for (avatartranslator.AvatarSignal sig : ab.getSignals()) {
+            String name = sig.getName().split("__")[sig.getName().split("__").length - 1];
+            //           sig.setName(name);
+            String[] types = new String[sig.getListOfAttributes().size()];
+            String[] typeIds = new String[sig.getListOfAttributes().size()];
+            int i = 0;
+            for (AvatarAttribute attr : sig.getListOfAttributes()) {
+                types[i] = attr.getType().getStringType();
+                typeIds[i] = attr.getName();
+                i++;
+            }
+            TraceManager.addDev("Adding signal " + sig);
+            bl.addSignal(new ui.AvatarSignal(sig.getInOut(), name, types, typeIds));
+        }
+
+        bl.setValueWithChange(ab.getName().split("__")[ab.getName().split("__").length - 1]);
+
+        for (AvatarAttribute attr : ab.getAttributes()) {
+            int type = 5;
+            if (attr.getType() == AvatarType.BOOLEAN) {
+                type = 4;
+            }
+            if (attr.getType() == AvatarType.INTEGER) {
+                type = 0;
+            }
+            if (attr.hasInitialValue()) {
+                bl.addAttribute(new TAttribute(0, attr.getName(), attr.getInitialValue(), type));
+            } else {
+                bl.addAttribute(new TAttribute(0, attr.getName(), attr.getType().getDefaultInitialValue(), type));
+            }
+            if (attr.getName().contains("key_") || attr.getName().contains("privKey_")) {
+                hasCrypto = true;
+                bl.addCryptoElements();
+            }
+        }
+        for (avatartranslator.AvatarMethod method : ab.getMethods()) {
+            bl.addMethodIfApplicable(method.toString().replaceAll(" = 0", ""));
+        }
+    }
+
+    public void drawPanel(AvatarSpecification avspec, AvatarDesignPanel adp) {
+        //System.out.println(avspec.toString());
+        hasCrypto = false;
+        Map<String, Set<String>> originDestMap = new HashMap<String, Set<String>>();
+        Map<String, AvatarBDBlock> blockMap = new HashMap<String, AvatarBDBlock>();
+        if (adp == null) {
+            return;
+        }
+        if (avspec == null) {
+            return;
+        }
+        AvatarBDPanel abd = adp.abdp;
+
+        //Find all blocks, create nested blocks starting from top left
+        int xpos = 10;
+        int ypos = 40;
+
+        //Create blocks recursively, starting from top level ones with no father
+        //Lowest level blocks should be 100x100, next should be 100x(number of children*100+50)...etc,
+        //Find level #, 0 refers to no father, etc
+        Map<AvatarBlock, Integer> blockLevelMap = new HashMap<AvatarBlock, Integer>();
+        Map<AvatarBlock, Integer> blockSizeMap = new HashMap<AvatarBlock, Integer>();
+        Map<AvatarBlock, Integer> blockIncMap = new HashMap<AvatarBlock, Integer>();
+        int maxLevel = 0;
+        for (AvatarBlock ab : avspec.getListOfBlocks()) {
+            int level = 0;
+            AvatarBlock block = ab;
+            while (block.getFather() != null) {
+                if (blockSizeMap.containsKey(block.getFather())) {
+                    blockSizeMap.put(block.getFather(), blockSizeMap.get(block.getFather()) + 1);
+                } else {
+                    blockSizeMap.put(block.getFather(), 1);
+                    blockIncMap.put(block.getFather(), 10);
+                }
+                level++;
+                block = block.getFather();
+            }
+            if (level > maxLevel) {
+                maxLevel = level;
+            }
+            if (!blockSizeMap.containsKey(block)) {
+                blockSizeMap.put(block, 0);
+                blockIncMap.put(block, 10);
+            }
+            blockLevelMap.put(ab, level);
+        }
+
+
+        for (int level = 0; level < maxLevel + 1; level++) {
+            for (AvatarBlock ab : avspec.getListOfBlocks()) {
+                if (blockLevelMap.get(ab) == level) {
+                    if (level == 0) {
+                        AvatarBDBlock bl = new AvatarBDBlock(xpos, ypos, abd.getMinX(), abd.getMaxX(), abd.getMinY(), abd.getMaxY(), false, null, abd);
+                        abd.addComponent(bl, xpos, ypos, false, true);
+                        bl.resize(100 * blockSizeMap.get(ab) + 100, 100 + (maxLevel - level) * 50);
+                        drawBlockProperties(ab, bl);
+                        AvatarSMDPanel smp = adp.getAvatarSMDPanel(bl.getValue());
+                        buildStateMachine(ab, bl, smp);
+                        blockMap.put(bl.getValue().split("__")[bl.getValue().split("__").length - 1], bl);
+                        xpos += 100 * blockSizeMap.get(ab) + 200;
+                    } else {
+
+                        AvatarBDBlock father = blockMap.get(ab.getFather().getName().split("__")[ab.getFather().getName().split("__").length - 1]);
+                        //System.out.println("blockmap " + blockMap);
+                        if (father == null) {
+                            //System.out.println("Missing father block " + ab.getFather().getName());
+                            continue;
+                        }
+                        AvatarBDBlock bl = new AvatarBDBlock(father.getX() + blockIncMap.get(ab.getFather()), father.getY() + 10, abd.getMinX(), abd.getMaxX(), abd.getMinY(), abd.getMaxY(), false, father, abd);
+                        abd.addComponent(bl, father.getX() + blockIncMap.get(ab.getFather()), father.getY() + 10, false, true);
+                        int size = 100;
+                        if (blockSizeMap.containsKey(ab)) {
+                            size = 100 * blockSizeMap.get(ab) + 50;
+                        }
+                        bl.resize(size, 100 + (maxLevel - level) * 50);
+                        drawBlockProperties(ab, bl);
+                        abd.attach(bl);
+                        AvatarSMDPanel smp = adp.getAvatarSMDPanel(bl.getValue());
+                        buildStateMachine(ab, bl, smp);
+                        blockMap.put(bl.getValue().split("__")[bl.getValue().split("__").length - 1], bl);
+                        blockIncMap.put(ab.getFather(), blockIncMap.get(ab.getFather()) + size + 10);
+                    }
+                }
+            }
+        }
+
+
+        for (AvatarRelation ar : avspec.getRelations()) {
+            String bl1 = ar.block1.getName();
+            String bl2 = ar.block2.getName();
+            if (originDestMap.containsKey(bl1.split("__")[bl1.split("__").length - 1])) {
+                originDestMap.get(bl1.split("__")[bl1.split("__").length - 1]).add(bl2.split("__")[bl2.split("__").length - 1]);
+            } else if (originDestMap.containsKey(bl2.split("__")[bl2.split("__").length - 1])) {
+                originDestMap.get(bl2.split("__")[bl2.split("__").length - 1]).add(bl1.split("__")[bl1.split("__").length - 1]);
+            } else {
+                Set<String> hs = new HashSet<String>();
+                hs.add(bl2.split("__")[bl2.split("__").length - 1]);
+                originDestMap.put(bl1.split("__")[bl1.split("__").length - 1], hs);
+            }
+        }
+        //Add Relations
+
+        for (String bl1 : originDestMap.keySet()) {
+            for (String bl2 : originDestMap.get(bl1)) {
+                Vector<Point> points = new Vector<Point>();
+                //      System.out.println("Finding " + bl1 + " and bl2 "+ bl2);
+                if (blockMap.get(bl1) == null || blockMap.get(bl2) == null) {
+                    continue;
+                }
+                TGConnectingPoint p1 = blockMap.get(bl1).findFirstFreeTGConnectingPoint(true, true);
+                p1.setFree(false);
+
+                TGConnectingPoint p2 = blockMap.get(bl2).findFirstFreeTGConnectingPoint(true, true);
+                p2.setFree(false);
+
+                if (bl2.equals(bl1)) {
+                    //Add 2 point so the connection looks square
+                    Point p = new Point(p1.getX(), p1.getY() - 10);
+                    points.add(p);
+                    p = new Point(p2.getX(), p2.getY() - 10);
+                    points.add(p);
+                }
+                AvatarBDPortConnector conn = new AvatarBDPortConnector(0, 0, 0, 0, 0, 0, true, null, abd, p1, p2, points);
+                abd.addComponent(conn, 0, 0, false, true);
+
+                //Add Relations to connector
+                for (AvatarRelation ar : avspec.getRelations()) {
+                    if (ar.block1.getName().contains(bl1) && ar.block2.getName().contains(bl2) || ar.block1.getName().contains(bl2) && ar.block2.getName().contains(bl1)) {
+
+                        //TGConnectingPoint p1= blockMap.get(bl1).getFreeTGConnectingPoint(blockMap.get(bl1).getX(), blockMap.get(bl1).getY());
+
+                        conn.setAsynchronous(ar.isAsynchronous());
+                        conn.setBlocking(ar.isBlocking());
+                        conn.setPrivate(ar.isPrivate());
+                        conn.setSizeOfFIFO(ar.getSizeOfFIFO());
+                        //System.out.println(bl1 +" "+ ar.block1.getName() + " "+ ar.block2.getName());
+                        for (int i = 0; i < ar.nbOfSignals(); i++) {
+                            //System.out.println("Adding relation " + ar.getSignal1(i).toString() + " " + ar.getSignal2(i).toBasicString());
+                            conn.addSignal(ar.getSignal1(i).toString(), ar.getSignal1(i).getInOut() == 0, ar.block1.getName().contains(bl1));
+                            conn.addSignal(ar.getSignal2(i).toString(), ar.getSignal2(i).getInOut() == 0, !ar.block1.getName().contains(bl1));
+                            //  System.out.println("adding signal " +ar.getSignal1(i).toBasicString());
+                        }
+                        //System.out.println("Added Signals");
+                        conn.updateAllSignals();
+
+
+                    }
+                    conn.updateAllSignals();
+                }
+
+                /*for (ui.AvatarSignal sig:blockMap.get(bl1).getSignalList()){
+                  for (ui.AvatarSignal sig2: blockMap.get(bl2).getSignalList()){
+                  if (sig.getId().equals(sig2.getId())){
+                  conn.addSignal("in "+sig.getId(), true, true);
+                  conn.addSignal("out "+sig.getId(), false, false);
+                  }
+                  }
+                  }*/
+            }
+        }
+        ypos += 100;
+        //Add Pragmas
+        AvatarBDPragma pragma = new AvatarBDPragma(xpos, ypos, xpos, xpos * 2, ypos, ypos * 2, false, null, abd);
+        //  String[] arr = new String[avspec.getPragmas().size()];
+        String s = "";
+        // int i=0;
+        for (AvatarPragma p : avspec.getPragmas()) {
+
+            //    arr[i] = p.getName();
+            String t = "";
+            String[] split = p.getName().split(" ");
+            if (p.getName().contains("#Confidentiality")) {
+                for (String str : split) {
+                    if (str.contains(".")) {
+                        String tmp = str.split("\\.")[0];
+                        String tmp2 = str.split("\\.")[1];
+                        t = t.concat(tmp.split("__")[tmp.split("__").length - 1] + "." + tmp2.split("__")[tmp2.split("__").length - 1] + " ");
+                    } else {
+                        t = t.concat(str + " ");
+                    }
+                }
+            } else if (p.getName().contains("Authenticity")) {
+                t = p.getName();
+            } else if (p.getName().contains("Initial")) {
+                t = p.getName();
+            } else {
+                t = p.getName();
+            }
+            s = s.concat(t + "\n");
+            //  i++;
+        }
+        pragma.setValue(s);
+        pragma.makeValue();
+        abd.addComponent(pragma, xpos, ypos, false, true);
+        //Add message and key datatype if there is a cryptoblock
+
+        xpos = 50;
+        ypos += 200;
+        if (hasCrypto) {
+            AvatarBDDataType message = new AvatarBDDataType(xpos, ypos, xpos, xpos * 2, ypos, ypos * 2, false, null, abd);
+            message.setValue("Message");
+
+            abd.addComponent(message, xpos, ypos, false, true);
+            message.resize(200, 100);
+            xpos += 400;
+
+            AvatarBDDataType key = new AvatarBDDataType(xpos, ypos, xpos, xpos * 2, ypos, ypos * 2, false, null, abd);
+            key.setValue("Key");
+            TAttribute attr = new TAttribute(2, "data", "0", 8);
+            message.addAttribute(attr);
+            key.addAttribute(attr);
+            key.resize(200, 100);
+            abd.addComponent(key, xpos, ypos, false, true);
+        }
+    }
+
+    public void buildStateMachine(AvatarBlock ab, AvatarBDBlock bl, AvatarSMDPanel smp) {
+        Map<AvatarTransition, TGComponent> tranSourceMap = new HashMap<AvatarTransition, TGComponent>();
+        Map<AvatarTransition, AvatarStateMachineElement> tranDestMap = new HashMap<AvatarTransition, AvatarStateMachineElement>();
+        Map<AvatarStateMachineElement, TGComponent> locMap = new HashMap<AvatarStateMachineElement, TGComponent>();
+        Map<AvatarStateMachineElement, TGComponent> SMDMap = new HashMap<AvatarStateMachineElement, TGComponent>();
+
+        //Build the state machine
+        int smx = 400;
+        int smy = 40;
+
+        if (smp == null) {
+            System.out.println("can't find");
+            return;
+        }
+        smp.removeAll();
+        AvatarStateMachine asm = ab.getStateMachine();
+        //Remove the empty check states
+
+        AvatarStartState start = asm.getStartState();
+        addStates(start, smx, smy, smp, bl, SMDMap, locMap, tranDestMap, tranSourceMap);
+        //Add transitions
+        for (AvatarTransition t : tranSourceMap.keySet()) {
+            if (tranSourceMap.get(t) == null || tranDestMap.get(t) == null) {
+                continue;
+            }
+            int x = tranSourceMap.get(t).getX() + tranSourceMap.get(t).getWidth() / 2;
+            int y = tranSourceMap.get(t).getY() + tranSourceMap.get(t).getHeight();
+
+            //    TGConnectingPoint p1 = tranSourceMap.get(t).findFirstFreeTGConnectingPoint(true,false);
+            TGConnectingPoint p1 = tranSourceMap.get(t).closerFreeTGConnectingPoint(x, y, true, false);
+            if (p1 == null) {
+                p1 = tranSourceMap.get(t).findFirstFreeTGConnectingPoint(true, true);
+                //p1=tranSourceMap.get(t).closerFreeTGConnectingPoint(x,y,true, true);
+            }
+            x = locMap.get(tranDestMap.get(t)).getX() + locMap.get(tranDestMap.get(t)).getWidth() / 2;
+            y = locMap.get(tranDestMap.get(t)).getY();
+            if (tranSourceMap.get(t).getY() > locMap.get(tranDestMap.get(t)).getY()) {
+                y = locMap.get(tranDestMap.get(t)).getY() + locMap.get(tranDestMap.get(t)).getHeight() / 2;
+                if (tranSourceMap.get(t).getX() < locMap.get(tranDestMap.get(t)).getX()) {
+                    x = locMap.get(tranDestMap.get(t)).getX();
+                } else {
+                    x = locMap.get(tranDestMap.get(t)).getX() + locMap.get(tranDestMap.get(t)).getWidth();
+                }
+            }
+            TGConnectingPoint p2 = locMap.get(tranDestMap.get(t)).closerFreeTGConnectingPoint(x, y, false, true);
+            if (p2 == null) {
+                p2 = locMap.get(tranDestMap.get(t)).closerFreeTGConnectingPoint(x, y, true, true);
+            }
+            Vector<Point> points = new Vector<Point>();
+            if (p1 == null || p2 == null) {
+                System.out.println(tranSourceMap.get(t) + " " + locMap.get(tranDestMap.get(t)));
+
+                System.out.println("Missing point " + p1 + " " + p2);
+                return;
+            }
+            AvatarSMDConnector SMDcon = new AvatarSMDConnector(p1.getX(), p1.getY(), p1.getX(), p1.getY(), p1.getX(), p1.getY(), true, null, smp, p1, p2, points);
+            //System.out.println(tranSourceMap.get(t)+" "+locMap.get(tranDestMap.get(t)));
+            ///System.out.println("FREE " +p1.isFree() + " "+ p2.isFree());
+            p1.setFree(false);
+            p2.setFree(false);
+            String action = "";
+            if (t.getActions().size() == 0) {
+                action = "";
+            } else {
+                action = t.getActions().get(0).toString().replaceAll(" ", "");
+            }
+            SMDcon.setTransitionInfo(t.getGuard().toString(), action);
+            for (int i = 1; i < t.getActions().size(); i++) {
+                SMDcon.setTransitionInfo("", t.getActions().get(i).toString().replaceAll(" ", ""));
+            }
+            smp.addComponent(SMDcon, p1.getX(), p1.getY(), false, true);
+        }
+    }
+
+    // Generates for all observers, a TURTLE modeling for checking it
+    public boolean generateTMsForRequirementAnalysis(Vector<Requirement> reqs, RequirementDiagramPanel rdp) {
+        rm = new RequirementModeling(reqs, rdp, mgui);
+        checkingErrors = rm.getCheckingErrors();
+        warnings = rm.getWarnings();
+        if ((checkingErrors != null) && (checkingErrors.size() > 0)) {
+            return false;
+        } else {
+            //mgui.setMode(mgui.GEN_DESIGN_OK);
+            languageID = MATRIX;
+            return true;
+        }
+    }
+
+    public RequirementModeling getRequirementModeling() {
+        return rm;
+    }
+
+    public void removeBreakpoint(Point p) {
+        if (listE == null) {
+            return;
+        }
+
+        listE.removeBreakpoint(p);
+    }
+
+    public void addBreakpoint(Point p) {
+        if (listE == null) {
+            return;
+        }
+
+        listE.addBreakpoint(p);
+    }
+
+    private void analyzeErrors() {
+        CheckingError ce;
+        TGComponent tgc;
+
+        for (int i = 0; i < checkingErrors.size(); i++) {
+            ce = checkingErrors.get(i);
+            if (ce != null && ce instanceof UICheckingError) {
+                tgc = ((UICheckingError) ce).getTGComponent();
+                if (tgc != null) {
+                    analyzeErrorOnComponent(tgc);
+                }
+            }
+        }
+    }
+
+    private void analyzeErrorOnComponent(TGComponent _tgc) {
+        if (_tgc instanceof BasicErrorHighlight) {
+            ((BasicErrorHighlight) _tgc).setStateAction(ErrorHighlight.UNKNOWN);
+        } else if (_tgc instanceof ActionStateErrorHighlight) {
+            ((ActionStateErrorHighlight) _tgc).setStateAction(ErrorHighlight.UNKNOWN_AS);
+        }
+    }
+
+    public boolean makeEBRDD(EBRDDPanel tdp) {
+        EBRDDTranslator ebrddt = new EBRDDTranslator();
+        ebrdd = ebrddt.generateEBRDD(tdp, tdp.getName());
+        warnings = ebrddt.getWarnings();
+        checkingErrors = ebrddt.getErrors();
+        if (checkingErrors.size() > 0) {
+            return false;
+        }
+        TraceManager.addDev("the EBRDD:\n" + ebrdd.toString());
+        return true;
+    }
+
+    public void setElementsOfSearchTree(Vector<Object> elements) {
+        st.setElements(elements);
+    }
+
+}
diff --git a/src/main/resources/ui/MainGUI.java b/src/main/resources/ui/MainGUI.java
new file mode 100644
index 0000000000..d079fb5641
--- /dev/null
+++ b/src/main/resources/ui/MainGUI.java
@@ -0,0 +1,9127 @@
+/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici
+ *
+ * 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 avatartranslator.AvatarSpecification;
+import common.ConfigurationTTool;
+import common.SpecConfigTTool;
+import ddtranslatorSoclib.AvatarddSpecification;
+import ddtranslatorSoclib.toSoclib.TasksAndMainGenerator;
+import graph.AUTGraph;
+import graph.RG;
+import launcher.RemoteExecutionThread;
+import launcher.RshClient;
+import myutil.*;
+import proverifspec.ProVerifOutputAnalyzer;
+import translator.CheckingError;
+import translator.MasterGateManager;
+import ui.ad.TActivityDiagramPanel;
+import ui.atd.AttackTreeDiagramPanel;
+import ui.avatarad.AvatarADPanel;
+import ui.avatarbd.AvatarBDLibraryFunction;
+import ui.avatarbd.AvatarBDPortConnector;
+import ui.avatarbd.AvatarBDStateMachineOwner;
+import ui.avatarcd.AvatarCDPanel;
+import ui.avatardd.ADDDiagramPanel;
+import ui.avatarinteractivesimulation.JFrameAvatarInteractiveSimulation;
+import ui.avatarmad.AvatarMADPanel;
+import ui.avatarpd.AvatarPDPanel;
+import ui.avatarrd.AvatarRDPanel;
+import ui.avatarsmd.AvatarSMDPanel;
+import ui.cd.TClassDiagramPanel;
+import ui.diplodocusmethodology.DiplodocusMethodologyDiagramPanel;
+import ui.ebrdd.EBRDDPanel;
+import ui.file.*;
+import ui.ftd.FaultTreeDiagramPanel;
+
+import ui.interactivesimulation.JFrameInteractiveSimulation;
+import ui.interactivesimulation.SimulationTransaction;
+import ui.iod.InteractionOverviewDiagramPanel;
+import ui.networkmodelloader.JDialogLoadingNetworkModel;
+import ui.osad.TURTLEOSActivityDiagramPanel;
+import ui.prosmd.ProactiveSMDPanel;
+import ui.req.Requirement;
+import ui.req.RequirementDiagramPanel;
+import ui.tmlad.TMLActivityDiagramPanel;
+import ui.tmlcd.TMLTaskDiagramPanel;
+import ui.tmlcompd.TMLCCompositeComponent;
+import ui.tmlcompd.TMLComponentTaskDiagramPanel;
+import ui.tmlcp.TMLCPPanel;
+//import ui.tmldd.TMLArchiCAMSNode;
+import ui.tmldd.TMLArchiDiagramPanel;
+import ui.tmlsd.TMLSDPanel;
+import ui.tree.DiagramTreeModel;
+import ui.tree.DiagramTreeRenderer;
+import ui.tree.JDiagramTree;
+import ui.ucd.UseCaseDiagramPanel;
+import ui.util.DefaultText;
+import ui.util.IconManager;
+import ui.window.*;
+
+import javax.imageio.ImageIO;
+import javax.swing.*;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.filechooser.FileNameExtensionFilter;
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.util.*;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+
+// AVATAR
+
+/**
+ * Class MainGUI
+ * Main window / Actions management / Mode management
+ * Creation: 15/12/2003
+ * Version: 1.1 21/12/2003
+ * Version: 1.2 29/09/2004
+ * 26/11/2015 D. Genius added DDD
+ *
+ * @author Ludovic APVRILLE
+ */
+public class MainGUI implements ActionListener, WindowListener, KeyListener, PeriodicBehavior {
+
+    public static boolean systemcOn;
+    public static boolean lotosOn;
+    public static boolean proactiveOn;
+    public static boolean tpnOn;
+    public static boolean osOn;
+    public static boolean uppaalOn;
+    public static boolean ncOn;
+    public static boolean avatarOn;
+    public static boolean proverifOn;
+    public static boolean experimentalOn;
+    public static boolean avatarOnly;
+    public static boolean turtleOn;
+
+    public boolean isxml = false;
+
+    public final static int LOTOS = 0;
+    public final static int RT_LOTOS = 1;
+    public final static int UPPAAL = 2;
+    public final static int JAVA = 3;
+    public final static int DESIGN = 4;
+
+    public JFrame frame; //Main Frame
+    public Container framePanel; //Main pane
+    public Container panelForTab, panelForTree; //panelForAnalysisTab; //panelForDesignTab;
+    public JSplitPane split;
+
+    // Multi analysis / design / deployment
+    public Vector<TURTLEPanel> tabs;
+    /* This dummySelectedTab is used when loading a model from XML.
+     * It enables to use standard getCurrentTURTLEPanel even though
+     * the mainTabbedPane has not yet been created.
+     */
+    private TURTLEPanel dummySelectedTab;
+
+    // JTree
+    public JDiagramTree dtree;
+    public DiagramTreeModel dtm;
+
+    // Actions
+    public TGUIAction[] actions;
+    public MouseHandler mouseHandler;
+    public KeyListener keyHandler;
+
+    // Validation
+    public LinkedList<TClassInterface> tclassesToValidate = new LinkedList<TClassInterface>();
+
+    // Status bar
+    private JLabel status;
+
+    //Menubar
+    private JMenuBarTurtle jmenubarturtle;
+
+    // Communication key
+    private String sk;
+
+
+    // Annex windows
+    JFrameCode javaframe;
+    JFrameBird birdframe;
+    private boolean hasChanged = false;
+
+    //@author: Huy TRUONG
+    public JDialogSearchBox searchBox;
+
+
+    public final static byte NOT_OPENED = 0;
+    public final static byte OPENED = 1;
+    public final static byte MODEL_OK = 2;
+    public final static byte MODEL_CHANGED = 3;
+    public final static byte MODEL_SAVED = 4;
+    public final static byte RTLOTOS_OK = 5;
+    public final static byte BACKWARD = 6;
+    public final static byte NO_BACKWARD = 7;
+    public final static byte FORWARD = 8;
+    public final static byte NO_FORWARD = 9;
+    public final static byte FORWARD_DIAG = 10;
+    public final static byte BACKWARD_DIAG = 11;
+    public final static byte NO_FORWARD_DIAG = 12;
+    public final static byte NO_BACKWARD_DIAG = 13;
+    public final static byte DTADOT_OK = 14;
+    public final static byte DTADOT_KO = 15;
+    public final static byte RGDOT_OK = 16;
+    public final static byte RGDOT_KO = 17;
+    public final static byte TLSADOT_OK = 31;
+    public final static byte TLSADOT_KO = 32;
+    public final static byte SIM_OK = 18;
+    public final static byte SIM_KO = 19;
+    public final static byte CUTCOPY_OK = 20;
+    public final static byte CUTCOPY_KO = 21;
+    public final static byte PASTE_OK = 22;
+    public final static byte RGAUTDOT_OK = 23;
+    public final static byte RGAUTDOT_KO = 24;
+    public final static byte RGAUT_OK = 25;
+    public final static byte RGAUT_KO = 26;
+    public final static byte RGAUTPROJDOT_OK = 27;
+    public final static byte RGAUTPROJDOT_KO = 28;
+    public final static byte EXPORT_LIB_OK = 29;
+    public final static byte EXPORT_LIB_KO = 30;
+    public final static byte METHO_CHANGED = 33;
+    public final static byte VIEW_SUGG_DESIGN_OK = 34;
+    public final static byte VIEW_SUGG_DESIGN_KO = 35;
+    public final static byte GEN_DESIGN_OK = 36;
+    public final static byte GEN_DESIGN_KO = 37;
+    public final static byte GEN_SYSTEMC_OK = 38;
+    public final static byte GEN_SYSTEMC_KO = 39;
+    public final static byte VIEW_WAVE_OK = 40;
+    public final static byte REQ_OK = 41;
+    public final static byte UPPAAL_OK = 42;
+    public final static byte NC_OK = 43;
+    public final static byte MODEL_UPPAAL_OK = 44;
+    public final static byte EDIT_PROVERIF_OK = 46;
+    public final static byte AVATAR_SYNTAXCHECKING_OK = 47;
+    public final static byte PANEL_CHANGED = 48;
+    public final static byte ATTACKTREE_SYNTAXCHECKING_OK = 49;
+    public final static byte FAULTTREE_SYNTAXCHECKING_OK = 51;
+    public final static byte COMPONENT_SELECTED = 50;
+    public final static byte CREATE_NEW_PANEL = 52;
+
+    public final static int INCREMENT = 10;
+
+    public static Object BACK_COLOR;
+    //public static Object BACK_COLOR;
+
+    public final static String REMOTE_RTL_LOTOS_FILE = "spec.lot";
+    public final static String REMOTE_UPPAAL_FILE = "spec.xml";
+    public final static String REMOTE_ALDEBARAN_AUT_FILE = "spec.aut";
+    public final static String REMOTE_ALDEBARAN_BISIMU_FILE1 = "file1.aut";
+    public final static String REMOTE_ALDEBARAN_BISIMU_FILE2 = "file2.aut";
+    public final static String REMOTE_BISIMULATOR_FILE1 = "lts1bis";
+    public final static String REMOTE_BISIMULATOR_FILE2 = "lts2bis";
+
+    public final static byte METHO_ANALYSIS = 0;
+    public final static byte METHO_DESIGN = 1;
+    public final static byte METHO_DEPLOY = 2;
+
+    public byte mode;
+    public byte methoMode;
+
+    // TURTLE Modeling
+    public GTURTLEModeling gtm;
+
+
+    //TURTLE modeling graphic components
+    private JTabbedPane mainTabbedPane;
+    private JToolBarMainTurtle mainBar;
+    //private JPopupMenu menuTabbedPane;
+
+    private TDiagramPanel activetdp;
+
+    // Modified graphs
+    private String modifiedaut;
+    private String modifiedautdot;
+
+    private RG lastDiploRG;
+
+
+    // JBirdPanel
+    private JBirdPanel jbp;
+
+    private int typeButtonSelected;
+    private int idButtonSelected;
+    private Plugin pluginSelected;
+
+    private File file;
+    private File dir;
+    private File config;
+    private File lotosfile;
+    private File simfile;
+    private File dtafile;
+    private File dtadotfile;
+    private File rgfile;
+    private File rgdotfile;
+    private File tlsafile;
+    private File tlsadotfile;
+    private File rgautfile;
+    private File fc2file;
+    private File bcgfile;
+    private File rgautdotfile;
+    private File rgautprojfile;
+    private File rgautprojdotfile;
+    private JFileChooser jfc;
+    private JFileChooser jfclib;
+    private JFileChooser jfcimg;
+    private JFileChooser jfcimgsvg;
+    private JFileChooser jfcggraph;
+    private JFileChooser jfctgraph;
+    private JFileChooser jfclot;
+    private JFileChooser jfctif;
+    private JFileChooser jfcmsc;
+
+    //private int selectedAction = -1;
+
+    // Interaction with simulators
+    private ArrayList<RunningInfo> runningIDs;
+    private ArrayList<LoadInfo> loadIDs;
+    private ConcurrentHashMap<Integer, ArrayList<SimulationTransaction>> transactionMap = new ConcurrentHashMap<Integer, ArrayList<SimulationTransaction>>();
+    private ConcurrentHashMap<Integer, ConcurrentHashMap<String, String>> latencyMap = new ConcurrentHashMap<Integer, ConcurrentHashMap<String, String>>();
+    private ConcurrentHashMap<String, String> statusMap = new ConcurrentHashMap<String, String>();
+    private JFrameInteractiveSimulation jfis;
+    private JFrameAvatarInteractiveSimulation jfais;
+
+    // Invariants
+    Invariant currentInvariant;
+
+    // Thread for autosave
+    PeriodicBehaviorThread pbt;
+
+    private TMLArchiPanel tmlap;    // USed to retrieve the currently opened architecture panel
+
+    // Plugin management
+    //public static PluginManager pluginManager;
+
+
+    public MainGUI(boolean _turtleOn, boolean _systemcOn, boolean _lotosOn, boolean _proactiveOn, boolean _tpnOn, boolean _osOn, boolean _uppaalOn, boolean _ncOn, boolean _avatarOn, boolean _proverifOn, boolean
+            _avatarOnly, boolean _experimental) {
+        turtleOn = _turtleOn;
+        systemcOn = _systemcOn;
+        lotosOn = _lotosOn;
+        proactiveOn = _proactiveOn;
+        tpnOn = _tpnOn;
+        osOn = _osOn;
+        uppaalOn = _uppaalOn;
+        ncOn = _ncOn;
+        avatarOn = _avatarOn;
+        proverifOn = _proverifOn;
+        avatarOnly = _avatarOnly;
+        experimentalOn = _experimental;
+
+        currentInvariant = null;
+
+        pbt = new PeriodicBehaviorThread(this, 120000); // save every two minutes
+
+        //PluginManager.pluginManager = new PluginManager();
+
+    }
+
+    public void setKey(String _sk) {
+        sk = _sk;
+        RshClient.sk = sk;
+    }
+
+    public String getKey() {
+        return sk;
+    }
+
+    public File getDir() {
+        return dir;
+    }
+
+    public boolean isAvatarOn() {
+        return avatarOn;
+    }
+
+
+    public void build() {
+        // Swing look and feel
+
+        //try {
+        try {
+            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
+        } catch (ClassNotFoundException | InstantiationException | UnsupportedLookAndFeelException e) {
+            ErrorGUI.exit(ErrorGUI.GUI);
+            e.printStackTrace();
+        } catch (IllegalAccessException e) {
+            ErrorGUI.exit(ErrorGUI.GUI);
+            e.printStackTrace();
+        }
+        //} catch (Exception e) { ErrorGUI.exit(ErrorGUI.GUI);}
+
+        // Creating main container
+        frame = new JFrame("TTool");
+
+        frame.addWindowListener(this);
+        frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+        frame.setIconImage(IconManager.img8);
+
+        framePanel = frame.getContentPane();
+        framePanel.setLayout(new BorderLayout());
+
+        // file chooser
+        if (ConfigurationTTool.FILEPath.length() > 0) {
+            jfc = new JFileChooser(ConfigurationTTool.FILEPath);
+        } else {
+            jfc = new JFileChooser();
+        }
+
+        if (ConfigurationTTool.FILEPath.length() > 0) {
+            jfctif = new JFileChooser(ConfigurationTTool.FILEPath);
+        } else {
+            jfctif = new JFileChooser();
+        }
+
+        if (ConfigurationTTool.FILEPath.length() > 0) {
+            jfcmsc = new JFileChooser(ConfigurationTTool.FILEPath);
+        } else {
+            jfcmsc = new JFileChooser();
+        }
+
+        if (ConfigurationTTool.LIBPath.length() > 0) {
+            jfclib = new JFileChooser(ConfigurationTTool.LIBPath);
+        } else {
+            jfclib = new JFileChooser();
+        }
+
+        if (SpecConfigTTool.IMGPath.length() > 0) {
+            jfcimg = new JFileChooser(SpecConfigTTool.IMGPath);
+        } else {
+            jfcimg = new JFileChooser();
+        }
+
+        if (SpecConfigTTool.IMGPath.length() > 0) {
+            jfcimgsvg = new JFileChooser(SpecConfigTTool.IMGPath);
+        } else {
+            jfcimgsvg = new JFileChooser();
+        }
+
+        if (ConfigurationTTool.LOTOSPath.length() > 0) {
+            jfclot = new JFileChooser(ConfigurationTTool.LOTOSPath);
+        } else {
+            jfclot = new JFileChooser();
+        }
+
+        if (SpecConfigTTool.GGraphPath.length() > 0) {
+            jfcggraph = new JFileChooser(SpecConfigTTool.GGraphPath);
+        } else {
+            jfcggraph = new JFileChooser();
+        }
+
+        if (SpecConfigTTool.TGraphPath.length() > 0) {
+            jfctgraph = new JFileChooser(SpecConfigTTool.TGraphPath);
+        } else {
+            jfctgraph = new JFileChooser();
+        }
+
+        TFileFilter filter = new TFileFilter();
+        jfc.setFileFilter(filter);
+        jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
+
+        TTIFFilter filtertif = new TTIFFilter();
+        jfctif.setFileFilter(filtertif);
+
+        MSCFilter filtermsc = new MSCFilter();
+        jfcmsc.setFileFilter(filtermsc);
+
+        TLibFilter filterLib = new TLibFilter();
+        jfclib.setFileFilter(filterLib);
+
+        TImgFilter filterImg = new TImgFilter();
+        jfcimg.setFileFilter(filterImg);
+
+        TSVGFilter filterSVG = new TSVGFilter();
+        jfcimgsvg.setFileFilter(filterSVG);
+
+        RTLFileFilter filterRTL = new RTLFileFilter();
+        jfclot.setFileFilter(filterRTL);
+
+        TDotFilter filterDot = new TDotFilter();
+        jfcggraph.setFileFilter(filterDot);
+
+        // Actions
+        initActions();
+
+        // mode
+        setMode(NOT_OPENED);
+
+        // statusBar
+        status = createStatusBar();
+
+        // Mouse handler
+        mouseHandler = new MouseHandler(status);
+
+        framePanel.add(status, BorderLayout.SOUTH);
+
+        // toolbar
+        mainBar = new JToolBarMainTurtle(this);
+        framePanel.add(mainBar, BorderLayout.NORTH);
+
+        // Panels
+        panelForTab = new JPanel();
+        panelForTab.setLayout(new BorderLayout());
+        //panelForTree = new JPanel(); panelForTree.setLayout(new BorderLayout());
+        // Tree
+        dtree = new JDiagramTree(this);
+        dtree.setCellRenderer(new DiagramTreeRenderer());
+        ToolTipManager.sharedInstance().registerComponent(dtree);
+        JScrollPane scrollPane = new JScrollPane(dtree);
+        scrollPane.setPreferredSize(new Dimension(200, 600));
+        scrollPane.setMinimumSize(new Dimension(25, 200));
+        jbp = new JBirdPanel(this);
+        jbp.setPreferredSize(new Dimension(200, 200));
+        JSplitPane split1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, scrollPane, jbp);
+
+        //split1.setLastDividerLocation(500);
+        //panelForTree.add(scrollPane, BorderLayout.CENTER);
+
+        split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, split1, panelForTab);
+        framePanel.add(split, BorderLayout.CENTER);
+        //split1.resetToPreferredSizes();
+
+        // Creating menus
+        jmenubarturtle = new JMenuBarTurtle(this);
+        frame.setJMenuBar(jmenubarturtle);
+
+        //split1.setLastDividerLocation(split1.getHeight() * 4 / 5);
+        //split1.setLastDividerLocation(900);
+
+        // ToolBar
+        //toolbarDesign = new Vector();
+        //toolbarAnalysis       = new Vector();
+
+        // Panels
+        //analysisPanels = new Vector();
+        //designPanels = new Vector();
+
+    }
+
+    public void initActions() {
+        actions = new TGUIAction[TGUIAction.NB_ACTION];
+        for (int i = 0; i < TGUIAction.NB_ACTION; i++) {
+            actions[i] = new TGUIAction(i);
+            actions[i].addActionListener(this);
+            //actions[i].addKeyListener(this);
+        }
+    }
+
+    public String getTitle() {
+        return frame.getTitle();
+    }
+
+    public boolean hasChanged() {
+        return hasChanged;
+    }
+
+    public void resetChange() {
+        hasChanged = false;
+    }
+
+    public void changeMade(TDiagramPanel tdp, int type) {
+        hasChanged = true;
+        if (tdp != null) {
+            switch (type) {
+                case -1:
+                    // Structural change
+                    break;
+                case TDiagramPanel.NEW_COMPONENT:
+                    //TraceManager.addDev("New Component");
+                    tdp.structureChanged();
+                    break;
+                case TDiagramPanel.NEW_CONNECTOR:
+                    //TraceManager.addDev("New Connector");
+                    tdp.structureChanged();
+                    break;
+                case TDiagramPanel.REMOVE_COMPONENT:
+                    //TraceManager.addDev("Remove Component");
+                    tdp.structureChanged();
+                    break;
+                case TDiagramPanel.MOVE_CONNECTOR:
+                    //TraceManager.addDev("Move Connector");
+                    tdp.structureChanged();
+                    break;
+                case TDiagramPanel.CHANGE_VALUE_COMPONENT:
+                    //TraceManager.addDev("Value of component changed");
+                    tdp.valueChanged();
+                    break;
+                case TDiagramPanel.MOVE_COMPONENT:
+                    //TraceManager.addDev("Component moved");
+                    break;
+                default:
+
+            }
+        }
+        setMode(MODEL_CHANGED);
+        Point p;
+        if (tdp == null) {
+            p = getCurrentSelectedPoint();
+        } else {
+            p = getPoint(tdp);
+        }
+        //TraceManager.addDev("Change made!");
+        gtm.saveOperation(p);
+        dtree.toBeUpdated();
+    }
+
+    public void setMethodologicalMode(byte m) {
+        methoMode = m;
+        switch (methoMode) {
+            case METHO_ANALYSIS:
+                break;
+            case METHO_DESIGN:
+                break;
+            default:
+        }
+    }
+
+    public void setMode(byte m) {
+        mode = m;
+        ModeManager.setMode(mode, actions, mainBar, this);
+    }
+
+
+    //@author: Huy TRUONG
+    public JToolBarMainTurtle getMainBar() {
+        return this.mainBar;
+    }
+    //--
+
+    public void activeActions(boolean b) {
+        //TraceManager.addDev("Action actions:" + b);
+        for (int i = 0; i < TGUIAction.NB_ACTION; i++) {
+            actions[i].setEnabled(b);
+        }
+    }
+
+    public String getModelFileFullPath() {
+        if (file == null) {
+            return "./";
+        }
+        return file.getAbsolutePath();
+    }
+
+    public boolean isExperimentalOn() {
+        return experimentalOn;
+    }
+
+    public void periodicAction() {
+        //TraceManager.addDev("Autosaving ");
+        if (file == null) {
+            return;
+        }
+
+        File fileSave = new File(file.getAbsolutePath() + "~");
+        TraceManager.addDev("Autosaving in " + fileSave.getAbsolutePath());
+        status.setText("Autosaving in " + fileSave.getAbsolutePath());
+
+        if (checkFileForSave(fileSave)) {
+            try {
+                String s = gtm.makeXMLFromTurtleModeling(-1);
+                FileOutputStream fos = new FileOutputStream(fileSave);
+                fos.write(s.getBytes());
+                fos.close();
+            } catch (Exception e) {
+                TraceManager.addDev("Error during autosave: " + e.getMessage());
+                status.setText("Error during autosave: " + e.getMessage());
+                return;
+            }
+        }
+
+        status.setText("Autosave done in " + fileSave.getAbsolutePath());
+    }
+
+    public void search(String text) {
+
+        Vector<Object> elements = new Vector<Object>();
+
+        TURTLEPanel panel;
+        for (int i = 0; i < tabs.size(); i++) {
+            panel = tabs.get(i);
+            panel.searchForText(text.toLowerCase(), elements);
+        }
+
+        gtm.setElementsOfSearchTree(elements);
+        //TraceManager.addDev("Found " + elements.size() + " elements");
+        dtree.forceUpdate();
+    }
+
+
+    public List<Invariant> getInvariants() {
+        return gtm.getInvariants();
+    }
+
+    public List<RG> getRGs() {
+        return gtm.getRGs();
+    }
+
+    public void addRG(RG _newGraph) {
+        gtm.addRG(_newGraph);
+        expandToGraphs();
+        dtree.toBeUpdated();
+    }
+
+    public void removeRG(RG _toBeRemoved) {
+        gtm.removeRG(_toBeRemoved);
+        if (_toBeRemoved.fileName != null) {
+            TraceManager.addDev("Filename=" + _toBeRemoved.fileName);
+            File toBeDeleted = new File(_toBeRemoved.fileName);
+            try {
+                toBeDeleted.delete();
+                TraceManager.addDev("File of RG was deleted on disk");
+            } catch (Exception e) {
+
+            }
+        }
+        dtree.toBeUpdated();
+    }
+
+    public void minimizeRG(RG toBeMinimized) {
+        JFrameMinimize jfm = new JFrameMinimize(frame, this, "Graph minimization", toBeMinimized, SpecConfigTTool.TGraphPath);
+        //jfm.setSize(900, 700);
+        GraphicLib.centerOnParent(jfm, 900, 700);
+        jfm.setVisible(true);
+    }
+
+    public void makeRefusalGraph(RG inputGraph) {
+        JFrameRefusalGraph jfm = new JFrameRefusalGraph(frame, this, "Test Sequences Construction", inputGraph, SpecConfigTTool.TGraphPath);
+        //jfm.setSize(900, 700);
+        GraphicLib.centerOnParent(jfm, 900, 700);
+        jfm.setVisible(true);
+    }
+
+    public void showInFinder(RG inputGraph) {
+        TraceManager.addDev("in show in finder");
+        if (inputGraph.fileName == null) {
+            return;
+        }
+        if (!Desktop.isDesktopSupported()) {
+            return;
+        }
+        File file = new File(SpecConfigTTool.TGraphPath);
+        TraceManager.addDev("Getting desktop");
+        Desktop desktop = Desktop.getDesktop();
+        try {
+            TraceManager.addDev("opening in desktop");
+            desktop.open(file);
+        } catch (Exception e) {
+            TraceManager.addDev("Exception in opening explorer: " + e.getMessage());
+        }
+    }
+
+
+    public void setCurrentInvariant(Invariant inv) {
+        currentInvariant = inv;
+    }
+
+    public Invariant getCurrentInvariant() {
+        return currentInvariant;
+    }
+
+    public TGComponent hasCheckableMasterMutex() {
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+
+        if (tp instanceof AvatarDesignPanel) {
+            return ((AvatarDesignPanel) tp).hasCheckableMasterMutex();
+        }
+
+        return null;
+    }
+
+    public void removeAllMutualExclusionWithMasterMutex() {
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+
+        if (tp instanceof AvatarDesignPanel) {
+            ((AvatarDesignPanel) tp).removeAllMutualExclusionWithMasterMutex();
+        }
+
+    }
+
+
+    private int addAnalysisPanel(String name, int index) {
+        if (index == -1) {
+            index = tabs.size();
+        }
+        AnalysisPanel ap = new AnalysisPanel(this);
+        tabs.add(index, ap); // should look for the first
+        //mainTabbedPane.addTab(name, IconManager.imgic17, ap.tabbedPane, "Opens analysis diagrams");
+        mainTabbedPane.add(ap.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open analysis diagrams");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic17);
+        ap.init();
+        //TraceManager.addDev("Main analysis added");
+        return index;
+    }
+
+    private int addTMLCPPanel(String name, int index) {
+        if (index == -1) {
+            index = tabs.size();
+        }
+        TMLCommunicationPatternPanel tmlcpp = new TMLCommunicationPatternPanel(this);
+        tabs.add(index, tmlcpp); // should look for the first
+        //mainTabbedPane.addTab(name, IconManager.imgic17, ap.tabbedPane, "Opens analysis diagrams");
+        mainTabbedPane.add(tmlcpp.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open CP diagrams");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic17);
+        tmlcpp.init();
+        //TraceManager.addDev("Main analysis added");
+        return index;
+    }
+
+    private int addAvatarAnalysisPanel(String name, int index) {
+        if (index == -1) {
+            index = tabs.size();
+        }
+        AvatarAnalysisPanel aap = new AvatarAnalysisPanel(this);
+        tabs.add(index, aap); // should look for the first
+        //mainTabbedPane.addTab(name, IconManager.imgic17, ap.tabbedPane, "Opens analysis diagrams");
+        mainTabbedPane.add(aap.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open analysis diagrams");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic17);
+        aap.init();
+        //TraceManager.addDev("Main analysis added");
+        return index;
+    }
+
+    private int addAttackTreePanel(String name, int index) {
+        if (index == -1) {
+            index = tabs.size();
+        }
+        AttackTreePanel atp = new AttackTreePanel(this);
+        tabs.add(index, atp); // should look for the first
+        mainTabbedPane.add(atp.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open attack tree diagrams");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic1074);
+        atp.init();
+        return index;
+    }
+
+    private int addFaultTreePanel(String name, int index) {
+        if (index == -1) {
+            index = tabs.size();
+        }
+        FaultTreePanel ftp = new FaultTreePanel(this);
+        tabs.add(index, ftp); // should look for the first
+        mainTabbedPane.add(ftp.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open fault tree diagrams");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic1074);
+        ftp.init();
+        return index;
+    }
+
+    private int addRequirementPanel(String name, int index) {
+        if (index == -1) {
+            index = tabs.size();
+        }
+        RequirementPanel rp = new RequirementPanel(this);
+        tabs.add(index, rp); // should look for the first
+        mainTabbedPane.add(rp.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open requirement diagrams");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic1000);
+        rp.init();
+        return index;
+    }
+
+    private int addAvatarDesignPanel(String name, int index) {
+        if (index == -1) {
+            index = tabs.size();
+        }
+        AvatarDesignPanel adp = new AvatarDesignPanel(this);
+        tabs.add(index, adp);
+        mainTabbedPane.add(adp.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open AVATAR design diagrams");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic80);
+        //mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams");
+        adp.init();
+        //ystem.out.println("Design added");
+        return index;
+    }
+
+    private int addAvatarRequirementPanel(String name, int index) {
+        if (index == -1) {
+            index = tabs.size();
+        }
+        AvatarRequirementPanel arp = new AvatarRequirementPanel(this);
+        tabs.add(index, arp);
+        mainTabbedPane.add(arp.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open AVATAR requirement diagrams");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic82);
+        //mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams");
+        arp.init();
+        //ystem.out.println("Design added");
+        return index;
+    }
+
+    private int addAvatarMADPanel(String name, int index) {
+        if (index == -1) {
+            index = tabs.size();
+        }
+        AvatarMADsPanel amadsp = new AvatarMADsPanel(this);
+        tabs.add(index, amadsp);
+        mainTabbedPane.add(amadsp.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open AVATAR Modeling Assumptions diagrams");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic82);
+        //mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams");
+        amadsp.init();
+        //ystem.out.println("Design added");
+        return index;
+    }
+
+    private int addDesignPanel(String name, int index) {
+        if (index == -1) {
+            index = tabs.size();
+        }
+        DesignPanel dp = new DesignPanel(this);
+        tabs.add(index, dp);
+        mainTabbedPane.add(dp.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open design diagrams");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic14);
+        //mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams");
+        dp.init();
+        //ystem.out.println("Design added");
+        return index;
+    }
+
+    private int addTMLDesignPanel(String name, int index) {
+        if (index == -1) {
+            index = tabs.size();
+        }
+        TMLDesignPanel dp = new TMLDesignPanel(this);
+        tabs.add(index, dp);
+        mainTabbedPane.add(dp.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open DIPLODOCUS design diagrams");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic62);
+        //mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams");
+        dp.init();
+        //ystem.out.println("Design added");
+        return index;
+    }
+
+    private int addDiplodocusMethodologyPanel(String name, int index, boolean addDefaultElements) {
+        if (index == -1) {
+            index = tabs.size();
+        }
+        DiplodocusMethodologyPanel dp = new DiplodocusMethodologyPanel(this);
+        tabs.add(index, dp);
+        mainTabbedPane.add(dp.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open DIPLODOCUS methodology");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic98);
+        //mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams");
+        dp.init(name);
+        if (addDefaultElements) {
+            dp.initElements();
+        }
+        //ystem.out.println("Design added");
+        return index;
+    }
+
+    private int addAvatarMethodologyPanel(String name, int index, boolean addDefaultElements) {
+        if (index == -1) {
+            index = tabs.size();
+        }
+
+        TraceManager.addDev("New avatar methodo panel");
+        AvatarMethodologyPanel dp = new AvatarMethodologyPanel(this);
+        tabs.add(index, dp);
+        mainTabbedPane.add(dp.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open AVATAR methodology");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic99);
+        //mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams");
+        dp.init(name);
+        if (addDefaultElements) {
+            dp.initElements();
+        }
+        //ystem.out.println("Design added");
+        return index;
+    }
+
+    private int addSysmlsecMethodologyPanel(String name, int index, boolean addDefaultElements) {
+        if (index == -1) {
+            index = tabs.size();
+        }
+        TraceManager.addDev("New SysMLSec Methodopanel");
+        SysmlsecMethodologyPanel dp = new SysmlsecMethodologyPanel(this);
+        tabs.add(index, dp);
+        mainTabbedPane.add(dp.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open SysML-Sec methodology");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic99);
+        //mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams");
+        dp.init(name);
+        if (addDefaultElements) {
+            dp.initElements();
+        }
+        //ystem.out.println("Design added");
+        return index;
+    }
+
+
+    private int addTMLComponentDesignPanel(String name, int index) {
+        if (index == -1) {
+            index = tabs.size();
+        }
+        TMLComponentDesignPanel dp = new TMLComponentDesignPanel(this);
+        tabs.add(index, dp);
+        mainTabbedPane.add(dp.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open DIPLODOCUS component design diagrams");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic1208);
+        //mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams");
+        dp.init();
+        //ystem.out.println("Design added");
+        return index;
+    }
+
+    private int addADDPanel(String name, int index) {
+        if (index == -1) {
+            index = tabs.size();
+        }
+        ADDPanel dp = new ADDPanel(this);
+        tabs.add(index, dp);
+        mainTabbedPane.add(dp.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open deployment diagram");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic60);
+        //mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams");
+        dp.init();
+        //ystem.out.println("Design added");
+        return index;
+    }
+
+    private int addTMLArchiPanel(String name, int index) {
+        if (index == -1) {
+            index = tabs.size();
+        }
+        TMLArchiPanel dp = new TMLArchiPanel(this);
+        tabs.add(index, dp);
+        mainTabbedPane.add(dp.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open DIPLODOCUS architecture diagrams");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic60);
+        //mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams");
+        dp.init();
+        //ystem.out.println("Design added");
+        return index;
+    }
+
+    //Return the list of all the TMLArchiDiagramPanels
+    public Vector<TMLArchiPanel> getTMLArchiDiagramPanels() {
+
+        Vector<TMLArchiPanel> panelsList = new Vector<TMLArchiPanel>();
+        TURTLEPanel tp;
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof TMLArchiPanel) {
+                panelsList.add((TMLArchiPanel) (tp));
+            }
+        }
+        return panelsList;
+    }
+
+    public Vector<String> getAllTMLTaskNames() {
+        TURTLEPanel tp;
+        Vector<String> list = new Vector<String>();
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof TMLDesignPanel) {
+                list.addAll(((TMLDesignPanel) tp).getAllTMLTaskNames(mainTabbedPane.getTitleAt(i)));
+            }
+        }
+        return list;
+    }
+
+    public void expandToErrors() {
+        if (gtm != null) {
+            gtm.expandToErrors();
+        }
+    }
+
+    public void expandToWarnings() {
+        if (gtm != null) {
+            gtm.expandToWarnings();
+        }
+    }
+
+    public void expandToGraphs() {
+        if (gtm != null) {
+            gtm.expandToGraphs();
+        }
+    }
+
+    public Vector<String> getTMLTasks() {
+        TURTLEPanel tp;
+        Vector<String> list = new Vector<String>();
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof TMLDesignPanel) {
+                list.addAll(((TMLDesignPanel) tp).getAllTMLTaskNames(mainTabbedPane.getTitleAt(i)));
+            }
+            if (tp instanceof TMLComponentDesignPanel) {
+                list.addAll(((TMLComponentDesignPanel) tp).getAllTMLTaskNames(mainTabbedPane.getTitleAt(i)));
+            }
+        }
+
+        return list;
+    }
+
+    public Vector<String> getAllApplicationTMLTasksAttributes() {
+        TURTLEPanel tp;
+        Vector<String> list = new Vector<String>();
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof TMLComponentDesignPanel) {
+                list.addAll(((TMLComponentDesignPanel) tp).getAllTMLTasksAttributes());
+            }
+        }
+
+        return list;
+    }
+
+    public ArrayList<TMLCommunicationPatternPanel> getAllTMLCP() {
+        TURTLEPanel tp;
+        ArrayList<TMLCommunicationPatternPanel> list = new ArrayList<TMLCommunicationPatternPanel>();
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof TMLCommunicationPatternPanel) {
+                list.add((TMLCommunicationPatternPanel) tp);
+            }
+        }
+        return list;
+    }
+
+    public void updateAllReferences() {
+        TURTLEPanel tp;
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof TMLComponentDesignPanel) {
+                ((TMLComponentDesignPanel) tp).tmlctdp.delayedLoad();
+                //((TMLComponentDesignPanel)tp).tmlctdp.updatePorts();
+            }
+        }
+    }
+
+    public void updateAllPorts() {
+        TURTLEPanel tp;
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof TMLComponentDesignPanel) {
+                //((TMLComponentDesignPanel)tp).tmlctdp.delayedLoad();
+                ((TMLComponentDesignPanel) tp).tmlctdp.updatePorts();
+            }
+        }
+    }
+
+    public Vector<String> getAllTMLCommunicationNames() {
+        TURTLEPanel tp;
+        Vector<String> list = new Vector<String>();
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof TMLDesignPanel) {
+                list.addAll(((TMLDesignPanel) tp).getAllTMLCommunicationNames(mainTabbedPane.getTitleAt(i)));
+            } else if (tp instanceof TMLComponentDesignPanel) {
+                list.addAll(((TMLComponentDesignPanel) tp).getAllTMLCommunicationNames(mainTabbedPane.getTitleAt(i)));
+            }
+        }
+        return list;
+    }
+
+    public Vector<String> getAllTMLInputPorts() {
+        TURTLEPanel tp;
+        Vector<String> list = new Vector<String>();
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            /*if (tp instanceof TMLDesignPanel) {
+              list.addAll(((TMLDesignPanel)tp).getAllTMLChannelNames( mainTabbedPane.getTitleAt(i)) );
+              } else*/
+            if (tp instanceof TMLComponentDesignPanel) {
+                list.addAll(((TMLComponentDesignPanel) tp).getAllTMLInputPorts(mainTabbedPane.getTitleAt(i)));
+            }
+        }
+        return list;
+    }
+
+    public Vector<String> getAllTMLEventNames() {
+        TURTLEPanel tp;
+        Vector<String> list = new Vector<String>();
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof TMLDesignPanel) {
+                list.addAll(((TMLDesignPanel) tp).getAllTMLEventNames(mainTabbedPane.getTitleAt(i)));
+            } else if (tp instanceof TMLComponentDesignPanel) {
+                list.addAll(((TMLComponentDesignPanel) tp).getAllTMLEventNames(mainTabbedPane.getTitleAt(i)));
+            }
+        }
+        return list;
+    }
+
+    public Vector<String> getAllNonMappedTMLTaskNames(TMLArchiDiagramPanel tadp, String ref, String name) {
+        TURTLEPanel tp;
+        Vector<String> list = new Vector<String>();
+        boolean b;
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof TMLDesignPanel) {
+                b = (mainTabbedPane.getTitleAt(i).compareTo(ref) == 0);
+                list.addAll(((TMLDesignPanel) tp).getAllNonMappedTMLTaskNames(mainTabbedPane.getTitleAt(i), tadp, b, name));
+            }
+            if (tp instanceof TMLComponentDesignPanel) {
+                b = (mainTabbedPane.getTitleAt(i).compareTo(ref) == 0);
+                list.addAll(((TMLComponentDesignPanel) tp).getAllNonMappedTMLPrimitiveComponentNames(mainTabbedPane.getTitleAt(i), tadp, b, name));
+            }
+        }
+
+        return list;
+    }
+
+    public Vector<String> getAllNonMappedAvatarBlockNames(ADDDiagramPanel tadp, String ref, String name) {
+        TURTLEPanel tp;
+        Vector<String> list = new Vector<String>();
+        boolean b;
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof AvatarDesignPanel) {
+                b = (mainTabbedPane.getTitleAt(i).compareTo(ref) == 0);
+                list.addAll(((AvatarDesignPanel) tp).getAllNonMappedAvatarBlockNames(mainTabbedPane.getTitleAt(i), tadp, b, name));
+            }
+        }
+
+        return list;
+    }
+
+    public Vector<String> getAllNonMappedAvatarChannelNames(ADDDiagramPanel tadp, String ref, String name) {
+        TURTLEPanel tp;
+        Vector<String> list = new Vector<String>();
+        boolean b;
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof AvatarDesignPanel) {
+                b = (mainTabbedPane.getTitleAt(i).compareTo(ref) == 0);
+                list.addAll(((AvatarDesignPanel) tp).getAllNonMappedAvatarChannelNames(mainTabbedPane.getTitleAt(i), tadp, b, name));
+            }
+        }
+
+        return list;
+    }
+
+    public Vector<String> getAllCompositeComponent(TMLComponentTaskDiagramPanel tcdp) {
+        TURTLEPanel tp;
+        Vector<String> list = new Vector<String>();
+        // boolean b;
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof TMLComponentDesignPanel) {
+                if (((TMLComponentDesignPanel) tp).tmlctdp != tcdp) {
+                    list.addAll(((TMLComponentDesignPanel) tp).getAllCompositeComponent(mainTabbedPane.getTitleAt(i)));
+                }
+            }
+        }
+
+        return list;
+    }
+
+    private int addTURTLEOSDesignPanel(String name, int index) {
+
+        if (index == -1) {
+            index = tabs.size();
+        }
+        TURTLEOSDesignPanel dp = new TURTLEOSDesignPanel(this);
+        tabs.add(index, dp);
+        mainTabbedPane.add(dp.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open TURTLE-OS design diagrams");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic14);
+        //mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams");
+        dp.init();
+        TraceManager.addDev("TURTLE OS Design added index=" + index);
+        return index;
+    }
+
+    private int addNCDesignPanel(String name, int index) {
+
+        if (index == -1) {
+            index = tabs.size();
+        }
+        NCPanel ncp = new NCPanel(this);
+        tabs.add(index, ncp);
+        mainTabbedPane.add(ncp.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open network calculus diagrams");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic60);
+        //mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams");
+        ncp.init();
+        //TraceManager.addDev("TURTLE OS Design added index=" + index);
+        return index;
+    }
+
+    /*private int addAvatarDesignPanel(String name, int index) {
+
+      if (index == -1) {
+      index = tabs.size();
+      }
+      AvatarDesignPanel avdp = new AvatarDesignPanel(this);
+      tabs.add(index, avdp);
+      mainTabbedPane.add(avdp.tabbedPane, index);
+      mainTabbedPane.setToolTipTextAt(index, "Open AVATAR Design");
+      mainTabbedPane.setTitleAt(index, name);
+      mainTabbedPane.setIconAt(index, IconManager.imgic60);
+      //mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams");
+      avdp.init();
+      //TraceManager.addDev("TURTLE OS Design added index=" + index);
+      return index;
+      }*/
+
+    /*private int addAvatarRequirementPanel(String name, int index) {
+
+      if (index == -1) {
+      index = tabs.size();
+      }
+      AvatarRequirementPanel arp = new AvatarRequirementPanel(this);
+      tabs.add(index, arp);
+      mainTabbedPane.add(arp.tabbedPane, index);
+      mainTabbedPane.setToolTipTextAt(index, "Open AVATAR Requirement");
+      mainTabbedPane.setTitleAt(index, name);
+      mainTabbedPane.setIconAt(index, IconManager.imgic60);
+      //mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams");
+      arp.init();
+      //TraceManager.addDev("TURTLE OS Design added index=" + index);
+      return index;
+      }*/
+
+    private int addProActiveDesignPanel(String name, int index) {
+        if (index == -1) {
+            index = tabs.size();
+        }
+        ProactiveDesignPanel dp = new ProactiveDesignPanel(this);
+        tabs.add(index, dp);
+        mainTabbedPane.add(dp.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open ProActive design diagrams");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic14);
+        //mainTabbedPane.addTab(name, IconManager.imgic14, dp.tabbedPane, "Opens design diagrams");
+        dp.init();
+        //ystem.out.println("Design added");
+        return index;
+    }
+
+    private int addDeploymentPanel(String name, int index) {
+        if (index == -1) {
+            index = tabs.size();
+        }
+        DeploymentPanel dp = new DeploymentPanel(this);
+        tabs.add(index, dp);
+        mainTabbedPane.add(dp.tabbedPane, index);
+        mainTabbedPane.setToolTipTextAt(index, "Open deployment diagram");
+        mainTabbedPane.setTitleAt(index, name);
+        mainTabbedPane.setIconAt(index, IconManager.imgic60);
+        dp.init();
+        //ystem.out.println("Design added");
+        return index;
+    }
+
+    public int createAvatarDesign(String name) {
+        int index = addAvatarDesignPanel(name, -1);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public int createAvatarRequirement(String name) {
+        int index = addAvatarRequirementPanel(name, -1);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public int createAvatarMADs(String name) {
+        int index = addAvatarMADPanel(name, -1);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public int createDesign(String name) {
+        int index = addDesignPanel(name, -1);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public int createDiplodocusMethodology(String name) {
+        int index = addDiplodocusMethodologyPanel(name, -1, false);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public int createAvatarMethodology(String name) {
+        int index = addAvatarMethodologyPanel(name, -1, false);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public int createSysmlsecMethodology(String name) {
+        int index = addSysmlsecMethodologyPanel(name, -1, false);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public int createTMLDesign(String name) {
+        int index = addTMLDesignPanel(name, -1);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public int createTMLComponentDesign(String name) {
+        int index = addTMLComponentDesignPanel(name, -1);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public int createTMLCP(String name) {
+        int index = addTMLCPPanel(name, -1);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public int createTMLArchitecture(String name) {
+        int index = addTMLArchiPanel(name, -1);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    /* public int createSystemCAMS(String name) { //ajout CD
+        int index = addSystemCAMSPanel(name, -1);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+	}*/
+
+    public int createADD(String name) {
+        int index = addADDPanel(name, -1);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public int createTURTLEOSDesign(String name) {
+        int index = addTURTLEOSDesignPanel(name, -1);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public int createProActiveDesign(String name) {
+        int index = addProActiveDesignPanel(name, -1);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public int createAnalysis(String name) {
+        int index = addAnalysisPanel(name, -1);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public int createAvatarAnalysis(String name) {
+        int index = addAvatarAnalysisPanel(name, -1);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public int createDeployment(String name) {
+        int index = addDeploymentPanel(name, -1);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public int createNC(String name) {
+        int index = addNCDesignPanel(name, -1);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public int createRequirement(String name) {
+        int index = addRequirementPanel(name, -1);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public int createAttackTree(String name) {
+        int index = addAttackTreePanel(name, -1);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public int createFaultTree(String name) {
+        int index = addFaultTreePanel(name, -1);
+        mainTabbedPane.setSelectedIndex(index);
+        return index;
+    }
+
+    public void setIODName(int analysisIndex, String name) {
+        AnalysisPanel ap = (AnalysisPanel) (tabs.elementAt(analysisIndex));
+        ap.tabbedPane.setTitleAt(0, name);
+    }
+
+    public void setDeploymentName(int deploymentIndex, String name) {
+        DeploymentPanel dp = (DeploymentPanel) (tabs.elementAt(deploymentIndex));
+        dp.tabbedPane.setTitleAt(0, name);
+    }
+
+    public void setNCName(int ncIndex, String name) {
+        NCPanel ncp = (NCPanel) (tabs.elementAt(ncIndex));
+        ncp.tabbedPane.setTitleAt(0, name);
+    }
+
+
+    // add main panel for editing TURTLE diagrams
+    private void addTURTLEPanel() {
+
+        //TraceManager.addDev("New TURTLE Panels");
+        // Issue #41 Ordering of tabbed panes
+        mainTabbedPane = GraphicLib.createTabbedPane();//new JTabbedPane();
+        mainTabbedPane.setBackground(ColorManager.MainTabbedPane);
+        mainTabbedPane.setForeground(Color.black);
+
+        BACK_COLOR = UIManager.get("TabbedPane.selected");
+        //UIManager.put("TabbedPane.tabAreaBackground", ColorManager.MainTabbedPaneBack);
+        UIManager.put("TabbedPane.selected", ColorManager.MainTabbedPaneSelect);
+        //UIManager.put("TabbedPane.darkShadow", Color.black);
+        UIManager.put("TabbedPane.focus", Color.blue);
+        /*UIManager.put("TabbedPane.highlight", Color.blue);
+          UIManager.put("TabbedPane.lightHighlight", Color.red);
+          UIManager.put("TabbedPane.shadow", Color.black);
+          UIManager.put("TabbedPane.darkShadow", Color.magenta);
+          UIManager.put("TabbedPane.focus", Color.green);*/
+        SwingUtilities.updateComponentTreeUI(mainTabbedPane);
+        mainTabbedPane.setOpaque(true);
+
+        ChangeListener cl = new ChangeListener() {
+            @Override
+            public void stateChanged(ChangeEvent e) {
+                paneAction(e);
+            }
+        };
+
+        mainTabbedPane.addChangeListener(cl);
+        panelForTab.add(mainTabbedPane, BorderLayout.CENTER);
+        mainTabbedPane.addMouseListener(new PopupListener(this));
+
+        tabs = new Vector<TURTLEPanel>();
+
+        frame.setVisible(true);
+    }
+
+    public Vector<TURTLEPanel> getTabs() {
+        return tabs;
+    }
+
+    public void firstDiag() {
+
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        if (tp == null) {
+            return;
+        }
+        tp.tabbedPane.setSelectedIndex(0);
+    }
+
+    public String getTitleOf(TDiagramPanel _tdp) {
+        TURTLEPanel panel;
+        for (int i = 0; i < tabs.size(); i++) {
+            panel = tabs.get(i);
+            if (panel.hasTDiagramPanel(_tdp)) {
+                return getTitleAt(panel);
+            }
+        }
+
+        return "Unknown";
+
+
+    }
+
+    public String getTitleAt(TURTLEPanel tp) {
+        int index = tabs.indexOf(tp);
+        if (index == -1) {
+            return "Unknown";
+        }
+        return mainTabbedPane.getTitleAt(index);
+
+    }
+
+    public TURTLEPanel getTURTLEPanel(String s) {
+        for (int i = 0; i < mainTabbedPane.getTabCount(); i++) {
+            if (mainTabbedPane.getTitleAt(i).compareTo(s) == 0) {
+                return tabs.elementAt(i);
+            }
+        }
+        return null;
+    }
+
+    public void drawAvatarSpecification(AvatarSpecification av) {
+        int index = createAvatarDesign("GeneratedDesign");
+        AvatarDesignPanel adp = (AvatarDesignPanel) (tabs.elementAt(index));
+        gtm.drawPanel(av, adp);
+    }
+
+
+    // Creates the status bar.
+    private JLabel createStatusBar() {
+        status = new JLabel("Ready...");
+        status.setBorder(BorderFactory.createEtchedBorder());
+        return status;
+    }
+
+    public void activate(JMenu jm, boolean b) {
+        JMenuItem im;
+        for (int i = 0; i < jm.getItemCount(); i++) {
+            im = jm.getItem(i);
+            if (im != null)
+                im.setEnabled(b);
+        }
+    }
+
+    public void start() {
+        // Main window is ready to be drawn on screen
+        if (frame == null) {
+            ErrorGUI.exit(ErrorGUI.GUI);
+        }
+
+        boolean positioned = false;
+
+        if (ConfigurationTTool.configSizeAvailable()) {
+            try {
+                int x = Integer.decode(ConfigurationTTool.LastWindowAttributesX).intValue();
+                int y = Integer.decode(ConfigurationTTool.LastWindowAttributesY).intValue();
+                int width = Integer.decode(ConfigurationTTool.LastWindowAttributesWidth).intValue();
+                int height = Integer.decode(ConfigurationTTool.LastWindowAttributesHeight).intValue();
+                String max = ConfigurationTTool.LastWindowAttributesMax;
+                if (max.compareTo("true") != 0) {
+                    frame.setBounds(x, y, width, height);
+                    positioned = true;
+                }
+                //TraceManager.addDev("Setting window attributes");
+            } catch (Exception e) {
+                //TraceManager.addDev("Window positioning has failed: " + e.getMessage());
+            }
+        }
+
+        if (!positioned) {
+            frame.setBounds(100, 100, 800, 600);
+            // jdk 1.4 or more
+            frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);
+            //TraceManager.addDev("No default window attributes");
+        }
+
+        frame.setVisible(true);
+    }
+
+    public void newTurtleModeling() {
+        setMode(OPENED);
+        addTURTLEPanel();
+        gtm = new GTURTLEModeling(this, tabs);
+        dtm = new DiagramTreeModel(this);
+        dtree.setModel(dtm);
+    }
+
+    public void closeTurtleModeling() {
+        if (mode != NOT_OPENED) {
+            setMode(NOT_OPENED);
+
+            // tabbed pane
+            for (int i = 0; i < tabs.size(); i++) {
+                tabs.elementAt(i).tabbedPane.removeAll();
+            }
+
+            tabs = null;
+            mainTabbedPane = null;
+            panelForTab.removeAll();
+            activetdp = null;
+
+            gtm = null;
+            tclassesToValidate = new LinkedList<TClassInterface>();
+            MasterGateManager.reinitNameRestriction();
+
+            typeButtonSelected = -1;
+            idButtonSelected = -1;
+            pluginSelected = null;
+
+            //activeDiagramToolBar = null;
+
+            dtree.reinit();
+            dtree.forceUpdate();
+            frame.setTitle("TTool");
+            frame.repaint();
+        }
+    }
+
+    public void setStatusBarText(String s) {
+        // captitalizeFirstLetter
+        if (s == null) {
+            return;
+        }
+
+        if (s.length() == 0) {
+            return;
+        }
+
+        if (s.length() > 1) {
+            status.setText(s.substring(0, 1).toUpperCase() + s.substring(1, s.length()));
+        } else {
+            status.setText(s);
+        }
+    }
+
+    public void reinitMainTabbedPane() {
+        mainTabbedPane.removeAll();
+        tabs.removeAllElements();
+    }
+
+    public void newDesign() {
+        //TraceManager.addDev("NEW DESIGN");
+        addDesignPanel("Design", -1);
+        tabs.elementAt(tabs.size() - 1).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(tabs.size() - 1);
+        //paneAction(null);
+        //frame.repaint();
+    }
+
+    public void newDeployment() {
+        //TraceManager.addDev("NEW DESIGN");
+        addDeploymentPanel("Deployment", -1);
+        tabs.elementAt(tabs.size() - 1).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(tabs.size() - 1);
+        //paneAction(null);
+        //frame.repaint();
+    }
+
+    public void newAnalysis() {
+        //TraceManager.addDev("NEW ANALYSIS");
+        addAnalysisPanel("Analysis", 0);
+        tabs.elementAt(0).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(0);
+        //paneAction(null);
+        //frame.repaint();
+    }
+
+    public void newAvatarAnalysis() {
+        //TraceManager.addDev("NEW ANALYSIS");
+        addAvatarAnalysisPanel("Analysis", 0);
+        //((TURTLEPanel)tabs.elementAt(0)).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(0);
+        //paneAction(null);
+        //frame.repaint();
+    }
+
+
+    public void newCommunicationPattern() {
+        //TraceManager.addDev("NEW ANALYSIS");
+        //addCommunicationPatternPanel("CP", 0);
+        tabs.elementAt(0).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(0);
+        //paneAction(null);
+        //frame.repaint();
+    }
+
+    public void newTMLDesign() {
+        //TraceManager.addDev("NEW DESIGN");
+        addTMLDesignPanel("DIPLODOCUS_Design", -1);
+        tabs.elementAt(tabs.size() - 1).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(tabs.size() - 1);
+        //paneAction(null);
+        //frame.repaint();
+    }
+
+    public void newDiplodocusMethodology() {
+        //TraceManager.addDev("NEW DESIGN");
+        addDiplodocusMethodologyPanel("DIPLODOCUS_Methodology", -1, true);
+        tabs.elementAt(tabs.size() - 1).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(tabs.size() - 1);
+        //paneAction(null);
+        //frame.repaint();
+    }
+
+    public void newAvatarMethodology() {
+        //TraceManager.addDev("NEW DESIGN");
+        addAvatarMethodologyPanel("AVATAR_Methodology", -1, true);
+        tabs.elementAt(tabs.size() - 1).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(tabs.size() - 1);
+        //paneAction(null);
+        //frame.repaint();
+    }
+
+    public void newSysmlsecMethodology() {
+        //TraceManager.addDev("NEW DESIGN");
+        addSysmlsecMethodologyPanel("SysMLSec_Methodology", -1, true);
+        tabs.elementAt(tabs.size() - 1).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(tabs.size() - 1);
+        //paneAction(null);
+        //frame.repaint();
+    }
+
+    public void newTMLComponentDesign() {
+        //TraceManager.addDev("NEW DESIGN");
+        addTMLComponentDesignPanel("DIPLODOCUS_C_Design", -1);
+        tabs.elementAt(tabs.size() - 1).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(tabs.size() - 1);
+        //paneAction(null);
+        //frame.repaint();
+    }
+
+    public void newTMLCP() {
+        //TraceManager.addDev("NEW ANALYSIS");
+        addTMLCPPanel("CP", 0);
+        tabs.elementAt(0).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(0);
+        //paneAction(null);
+        //frame.repaint();
+    }
+
+    public void newTMLArchi() {
+        //TraceManager.addDev("NEW DIPLO Architecture");
+        addTMLArchiPanel("Architecture", -1);
+        tabs.elementAt(tabs.size() - 1).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(tabs.size() - 1);
+        //paneAction(null);
+        //frame.repaint();
+    }
+
+    /*   public void newSystemCAMS() {//ajout CD
+        //TraceManager.addDev("NEW DIPLO Architecture");
+        addSystemCAMSPanel("SystemC-AMS", -1);
+        tabs.elementAt(tabs.size() - 1).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(tabs.size() - 1);
+        //paneAction(null);
+        //frame.repaint();
+	}*/
+
+    public void newADD() {
+        //TraceManager.addDev("NEW Avatar deployment");
+        addADDPanel("Deployment", -1);
+        tabs.elementAt(tabs.size() - 1).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(tabs.size() - 1);
+        //paneAction(null);
+        //frame.repaint();
+    }
+
+    public void newTURTLEOSDesign() {
+        //TraceManager.addDev("NEW DESIGN");
+        addTURTLEOSDesignPanel("TURTLE-OS Design", -1);
+        tabs.elementAt(tabs.size() - 1).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(tabs.size() - 1);
+    }
+
+    public void newNCDesign() {
+        //TraceManager.addDev("NEW NC DESIGN");
+        addNCDesignPanel("NC Design", -1);
+        tabs.elementAt(tabs.size() - 1).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(tabs.size() - 1);
+    }
+
+    public void newAvatarBD() {
+        //TraceManager.addDev("NEW AVATAR BD");
+        addAvatarDesignPanel("Design", -1);
+        tabs.elementAt(tabs.size() - 1).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(tabs.size() - 1);
+    }
+
+    public void newAvatarRequirement() {
+        //TraceManager.addDev("NEW AVATAR Requirement");
+        addAvatarRequirementPanel("Requirements", 0);
+        //((TURTLEPanel)tabs.elementAt(tabs.size()-1)).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(0);
+    }
+
+    public void newAvatarMADs() {
+        //TraceManager.addDev("NEW AVATAR MAD");
+        addAvatarMADPanel("Assumptions", 0);
+        //((TURTLEPanel)tabs.elementAt(tabs.size()-1)).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(0);
+    }
+
+    public void newProactiveDesign() {
+        //TraceManager.addDev("NEW DESIGN");
+        /*int index = */
+        addProActiveDesignPanel("ProActive Design", -1);
+        tabs.elementAt(tabs.size() - 1).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(tabs.size() - 1);
+        //paneAction(null);
+        //frame.repaint();*/
+    }
+
+    public void newAttackTree() {
+        //TraceManager.addDev("NEW ANALYSIS");
+        addAttackTreePanel("Attack Trees", 0);
+        //((TURTLEPanel)tabs.elementAt(0)).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(0);
+        //paneAction(null);
+        //frame.repaint();
+    }
+
+    public void newFaultTree() {
+        //TraceManager.addDev("NEW ANALYSIS");
+        addFaultTreePanel("Fault Trees", 0);
+        //((TURTLEPanel)tabs.elementAt(0)).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(0);
+        //paneAction(null);
+        //frame.repaint();
+    }
+
+    public void newRequirement() {
+        //TraceManager.addDev("NEW ANALYSIS");
+        addRequirementPanel("Requirements", 0);
+        //((TURTLEPanel)tabs.elementAt(0)).tabbedPane.setSelectedIndex(0);
+        mainTabbedPane.setSelectedIndex(0);
+        //paneAction(null);
+        //frame.repaint();
+    }
+
+    // Action listeners
+    public void newProject() {
+        if (mode == NOT_OPENED) {
+            //mode = ProjectManager.TM_OPENED;
+            newTurtleModeling();
+            //gtm.saveOperation(tcdp);
+            file = null;
+            dir = null;
+            config = null;
+            frame.setTitle("TTool: unsaved project");
+        } else {
+            //  check if previous modeling is saved
+            boolean b = actions[TGUIAction.ACT_SAVE].isEnabled();
+            if (b) {
+                if (!saveBeforeAction("Save and Start New Modeling", "Start New modeling")) {
+                    return;
+                }
+                /*int back = JOptionPane.showConfirmDialog(frame, "Modeling has not been saved\nDo you really want to open a new one ?", "Attention: current modeling not saved ?", JOptionPane.OK_CANCEL_OPTION);
+                  if (back == JOptionPane.CANCEL_OPTION) {
+                  return;       */
+                /*}*/
+            }
+            // close current modeling
+            closeTurtleModeling();
+
+            // opens a new one
+            newTurtleModeling();
+
+            //gtm.saveOperation(tcdp);
+
+            file = null;
+            lotosfile = null;
+            simfile = null;
+            dtafile = null;
+            dtadotfile = null;
+            rgfile = null;
+            tlsafile = null;
+            rgdotfile = null;
+            tlsadotfile = null;
+            rgautfile = null;
+            fc2file = null;
+            bcgfile = null;
+            rgautdotfile = null;
+            rgautprojfile = null;
+            rgautprojdotfile = null;
+
+            frame.setTitle("TTool: unsaved project");
+        }
+    }
+
+    public void newProjectDir() {
+        if (mode == NOT_OPENED) {
+            int val = createFileDialog();
+            if (val == JFileChooser.APPROVE_OPTION)
+                createFile();
+        } else {
+            //  check if previous modeling is saved
+            boolean b = actions[TGUIAction.ACT_SAVE].isEnabled();
+            if (b) {
+                if (!saveBeforeAction("Save and Start New Modeling", "Start New modeling")) {
+                    return;
+                }
+                /*int back = JOptionPane.showConfirmDialog(frame, "Modeling has not been saved\nDo you really want to open a new one ?", "Attention: current modeling not saved ?", JOptionPane.OK_CANCEL_OPTION);
+                  if (back == JOptionPane.CANCEL_OPTION) {
+                  return;       */
+                /*}*/
+            }
+            int val = createFileDialog();
+            if (val == JFileChooser.APPROVE_OPTION) {
+                // close current modeling
+                closeTurtleModeling();
+                createFile();
+            }
+        }
+    }
+
+    public void saveConfig() {
+        int i = 0;
+        for (; i < tabs.size(); i++) {
+            if (tabs.get(i) == activetdp.tp)
+                break;
+        }
+        int j = tabs.get(i).getIndexOfChild(activetdp);
+        SpecConfigTTool.lastTab = i;
+        SpecConfigTTool.lastPanel = j;
+        try {
+            SpecConfigTTool.saveConfiguration(config);
+            SpecConfigTTool.lastPanel = -1;
+            SpecConfigTTool.lastTab = -1;
+        } catch (MalformedConfigurationException e) {
+            System.err.println(e.getMessage() + " : Can't save config file.");
+        }
+    }
+
+    public String loadFile(File f) {
+        String s = null;
+
+        if (checkFileForOpen(f)) {
+            try {
+                FileInputStream fis = new FileInputStream(f);
+                int nb = fis.available();
+
+                byte[] ba = new byte[nb];
+                fis.read(ba);
+                fis.close();
+                s = new String(ba);
+            } catch (Exception e) {
+                JOptionPane.showMessageDialog(frame, "File could not be opened because " + e.getMessage(), "File Error", JOptionPane.INFORMATION_MESSAGE);
+            } catch (OutOfMemoryError er) {
+                JOptionPane.showMessageDialog(frame, "File could not be opened because " + er.getMessage(), "File Error", JOptionPane.INFORMATION_MESSAGE);
+            }
+        }
+        return s;
+    }
+
+    public void saveFile(File f, String data, String msg) {
+        if (checkFileForSave(f)) {
+            try {
+                if (data == null) {
+                    return;
+                }
+                FileOutputStream fos = new FileOutputStream(f);
+                fos.write(data.getBytes());
+                fos.close();
+                JOptionPane.showMessageDialog(frame, msg + " " + f.getAbsolutePath(), "Saving", JOptionPane.INFORMATION_MESSAGE);
+                return;
+            } catch (Exception e) {
+                JOptionPane.showMessageDialog(frame, "File could not be saved because " + e.getMessage(), "File Error", JOptionPane.INFORMATION_MESSAGE);
+                return;
+            }
+        }
+    }
+
+    public String loadLibrary() {
+        File libfile;
+
+        int returnVal = jfclib.showDialog(frame, "Import library");
+        if (returnVal != JFileChooser.APPROVE_OPTION) {
+            return null;
+        }
+
+        libfile = jfclib.getSelectedFile();
+        libfile = FileUtils.addFileExtensionIfMissing(libfile, TLibFilter.getExtension());
+
+        return loadFile(libfile);
+    }
+
+    public String[] loadLotosSpec() {
+        File lotfile;
+
+        int returnVal = jfclot.showDialog(frame, "Load RT-LOTOS specification");
+        if (returnVal != JFileChooser.APPROVE_OPTION) {
+            return null;
+        }
+
+        lotfile = jfclot.getSelectedFile();
+        lotfile = FileUtils.addFileExtensionIfMissing(lotfile, RTLFileFilter.getExtension());
+
+        String spec = loadFile(lotfile);
+        if (spec == null) {
+            return null;
+        }
+
+        String[] ret = new String[2];
+        ret[0] = lotfile.getName();
+        ret[1] = spec;
+        return ret;
+    }
+
+    public void saveLotosSpec(String data) {
+        File lotfile;
+
+        int returnVal = jfclot.showDialog(frame, "Save RT-LOTOS specification");
+        if (returnVal != JFileChooser.APPROVE_OPTION) {
+            return;
+        }
+
+        lotfile = jfclot.getSelectedFile();
+        lotfile = FileUtils.addFileExtensionIfMissing(lotfile, RTLFileFilter.getExtension());
+
+        saveFile(lotfile, data, "LOTOS specification saved under");
+    }
+
+    public void saveDTA(String tdata, String gdata) {
+        File dtafile;
+
+        /* textual form */
+        DTAFileFilter filter = new DTAFileFilter();
+        jfctgraph.setFileFilter(filter);
+        jfctgraph.setCurrentDirectory(new File(SpecConfigTTool.TGraphPath));
+
+        int returnVal = jfctgraph.showDialog(frame, "Save last DTA (textual form)");
+        if (returnVal != JFileChooser.APPROVE_OPTION) {
+            return;
+        }
+
+        dtafile = jfctgraph.getSelectedFile();
+        dtafile = FileUtils.addFileExtensionIfMissing(dtafile, DTAFileFilter.getExtension());
+
+        saveFile(dtafile, tdata, "Textual DTA saved under");
+
+        /* graphical form */
+        returnVal = jfcggraph.showDialog(frame, "Save last DTA (graphical form)");
+        if (returnVal != JFileChooser.APPROVE_OPTION) {
+            return;
+        }
+
+        dtafile = jfcggraph.getSelectedFile();
+        dtafile = FileUtils.addFileExtensionIfMissing(dtafile, TDotFilter.getExtension());
+
+        saveFile(dtafile, gdata, "Graphical DTA saved under");
+    }
+
+    public String saveTPNNDRFormat(String tpn) {
+        String s = file.getAbsolutePath();
+        int l = s.length();
+        String myFile = s.substring(0, l - 4) + ".ndr";
+        try {
+            FileUtils.saveFile(myFile, tpn);
+        } catch (Exception e) {
+            return "TPN could not be saved in myFile: " + e.getMessage();
+        }
+        return "TPN saved in " + myFile;
+    }
+
+    public void saveRG(String tdata, String gdata) {
+        File rgfile;
+
+        /* textual form */
+        RGFileFilter filter = new RGFileFilter();
+        jfctgraph.setFileFilter(filter);
+        jfctgraph.setCurrentDirectory(new File(SpecConfigTTool.TGraphPath));
+
+        int returnVal = jfctgraph.showDialog(frame, "Save last RG (textual form)");
+        if (returnVal != JFileChooser.APPROVE_OPTION) {
+            return;
+        }
+
+        rgfile = jfctgraph.getSelectedFile();
+        rgfile = FileUtils.addFileExtensionIfMissing(rgfile, RGFileFilter.getExtension());
+
+        saveFile(rgfile, tdata, "Textual RG saved under");
+
+        /* graphical form */
+        returnVal = jfcggraph.showDialog(frame, "Save last RG (graphical form)");
+        if (returnVal != JFileChooser.APPROVE_OPTION) {
+            return;
+        }
+
+        rgfile = jfcggraph.getSelectedFile();
+        rgfile = FileUtils.addFileExtensionIfMissing(rgfile, TDotFilter.getExtension());
+
+        saveFile(rgfile, gdata, "Graphical RG saved under");
+    }
+
+    public void saveTLSA(String tdata, String gdata) {
+        File tlsafile;
+
+        /* textual form */
+        TLSAFileFilter filter = new TLSAFileFilter();
+        jfctgraph.setFileFilter(filter);
+
+        int returnVal = jfctgraph.showDialog(frame, "Save last TLSA (textual form)");
+        if (returnVal != JFileChooser.APPROVE_OPTION) {
+            return;
+        }
+
+        tlsafile = jfctgraph.getSelectedFile();
+        tlsafile = FileUtils.addFileExtensionIfMissing(tlsafile, TLSAFileFilter.getExtension());
+
+        saveFile(tlsafile, tdata, "Textual TLSA saved under");
+
+        /* graphical form */
+        returnVal = jfcggraph.showDialog(frame, "Save last TLSA (graphical form)");
+        if (returnVal != JFileChooser.APPROVE_OPTION) {
+            return;
+        }
+
+        tlsafile = jfcggraph.getSelectedFile();
+        tlsafile = FileUtils.addFileExtensionIfMissing(tlsafile, TDotFilter.getExtension());
+
+        saveFile(tlsafile, gdata, "Graphical TLSA saved under");
+    }
+
+    public void saveRGAUT(String tdata, String gdata) {
+        File rgfile;
+
+        /* textual form */
+        AUTFileFilter filter = new AUTFileFilter();
+        jfctgraph.setFileFilter(filter);
+
+        int returnVal = jfctgraph.showDialog(frame, "Save last RG/AUT (textual form)");
+        if (returnVal != JFileChooser.APPROVE_OPTION) {
+            return;
+        }
+
+        rgfile = jfctgraph.getSelectedFile();
+        rgfile = FileUtils.addFileExtensionIfMissing(rgfile, AUTFileFilter.getExtension());
+
+        saveFile(rgfile, tdata, "Textual RG/AUTsaved under");
+
+        /* graphical form */
+        returnVal = jfcggraph.showDialog(frame, "Save last RG/AUT (graphical form)");
+        if (returnVal != JFileChooser.APPROVE_OPTION) {
+            return;
+        }
+
+        rgfile = jfcggraph.getSelectedFile();
+        rgfile = FileUtils.addFileExtensionIfMissing(rgfile, TDotFilter.getExtension());
+
+        saveFile(rgfile, gdata, "Graphical RG/AUT saved under");
+    }
+
+
+    public String[] loadGGraph() {
+        File gfile;
+
+        int returnVal = jfcggraph.showDialog(frame, "Load Graph (DOT format)");
+        if (returnVal != JFileChooser.APPROVE_OPTION) {
+            return null;
+        }
+
+        gfile = jfcggraph.getSelectedFile();
+        gfile = FileUtils.addFileExtensionIfMissing(gfile, TDotFilter.getExtension());
+
+        String spec = loadFile(gfile);
+        if (spec == null) {
+            return null;
+        }
+
+        String[] ret = new String[2];
+        ret[0] = gfile.getName();
+        ret[1] = spec;
+        return ret;
+    }
+
+    public String[] loadGGraph(String name) {
+        try {
+            String spec = FileUtils.loadFile(name);
+            if (spec == null) {
+                return null;
+            }
+
+            String[] ret = new String[2];
+            ret[0] = name;
+            ret[1] = spec;
+            return ret;
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    public String[] loadAUTGraph() {
+        File autfile;
+
+        /* textual form */
+        AUTFileFilter filter = new AUTFileFilter();
+        jfctgraph.setFileFilter(filter);
+        jfctgraph.setCurrentDirectory(new File(SpecConfigTTool.TGraphPath));
+
+        int returnVal = jfctgraph.showDialog(frame, "Load AUT graph");
+        if (returnVal != JFileChooser.APPROVE_OPTION) {
+            return null;
+        }
+
+        autfile = jfctgraph.getSelectedFile();
+        autfile = FileUtils.addFileExtensionIfMissing(autfile, AUTFileFilter.getExtension());
+
+        String spec = loadFile(autfile);
+        if (spec == null) {
+            return null;
+        }
+
+        String[] ret = new String[2];
+        ret[0] = autfile.getName();
+        ret[1] = spec;
+        return ret;
+    }
+
+    public void loadAUTGraphsDir() {
+        File dir = new File(SpecConfigTTool.TGraphPath);
+        if (!dir.exists()) {
+            System.err.println("Graphs directory doesn't exists !");
+            return;
+        }
+
+        for (File autfile : dir.listFiles()) {
+            if (!FileUtils.getExtension(autfile).equals("aut"))
+                continue;
+
+            String spec = loadFile(autfile);
+            if (spec == null) {
+                continue;
+            }
+
+            RG rg = new RG(autfile.getName());
+            rg.fileName = autfile.getAbsolutePath();
+            rg.data = spec;
+            addRG(rg);
+        }
+
+    }
+
+    public void updateLastOpenFile(File file) {
+        if (ConfigurationTTool.LastOpenFileDefined) {
+            ConfigurationTTool.LastOpenFile = file.getPath();
+            if (ConfigurationTTool.LastOpenFile.contains(".ttool" + File.separator)) {
+                int last = 0;
+                for (int i = 0; i < ConfigurationTTool.LastOpenFile.length(); i++) {
+                    if (ConfigurationTTool.LastOpenFile.charAt(i) == '/')
+                        last = i;
+                }
+                ConfigurationTTool.LastOpenFile = ConfigurationTTool.LastOpenFile.substring(0, last);
+            }
+            // Change name of action
+            actions[TGUIAction.ACT_OPEN_LAST].setName(TGUIAction.ACT_OPEN_LAST, ConfigurationTTool.LastOpenFile);
+        }
+    }
+
+    // Only if a project is already opened
+    public void mergeProject() {
+        //TraceManager.addDev("Merge");
+        File filetmp = file;
+        int returnVal = jfc.showOpenDialog(frame);
+
+        if (returnVal == JFileChooser.APPROVE_OPTION) {
+            filetmp = jfc.getSelectedFile();
+        }
+
+        String s = null;
+        String oldmodeling = gtm.makeXMLFromTurtleModeling(-1);
+        if (checkFileForOpen(filetmp)) {
+            try {
+                FileInputStream fis = new FileInputStream(filetmp);
+                int nb = fis.available();
+
+                byte[] ba = new byte[nb];
+                fis.read(ba);
+                fis.close();
+                s = new String(ba);
+            } catch (Exception e) {
+                JOptionPane.showMessageDialog(frame, "File could not be opened because " + e.getMessage(), "File Error", JOptionPane.INFORMATION_MESSAGE);
+                return;
+            }
+            // close current modeling
+            closeTurtleModeling();
+
+            // open the new TURTLE modeling
+            newTurtleModeling();
+
+            //TraceManager.addDev("Loading");
+            // load the new TURTLE modeling
+            // Issue #41: Moved to common method
+            loadModels(gtm.mergeTURTLEGModeling(oldmodeling, s), "merged");
+            //            try {
+            //                //TraceManager.addDev("Merging");
+            //                gtm.enableUndo(false);
+            //                gtm.loadModelingFromXML(gtm.mergeTURTLEGModeling(oldmodeling, s));
+            //                gtm.enableUndo(true);
+            //                gtm.saveOperation(getCurrentSelectedPoint());
+            //                //gtm.saveOperation(tcdp);
+            //                frame.setTitle("TTool: " + file.getAbsolutePath());
+            //                makeLotosFile();
+            //
+            //                if (gtm.getCheckingErrors().size() > 0) {
+            //                    JOptionPane.showMessageDialog(frame, "Modeling could not be correctly merged", "Error when loading modeling", JOptionPane.INFORMATION_MESSAGE);
+            //                }
+            //
+            //            } catch (MalformedModelingException mme) {
+            //                JOptionPane.showMessageDialog(frame, "Modeling could not be correctly merged", "Error when loading modeling", JOptionPane.INFORMATION_MESSAGE);
+            //            }
+            //            dtree.forceUpdate();
+        }
+    }
+
+    public void openNetworkProject() {
+        boolean b = actions[TGUIAction.ACT_SAVE].isEnabled();
+        if (b) {
+            if (!saveBeforeAction("Save and Open", "Open")) {
+                return;
+            }
+            /*  int back = JOptionPane.showConfirmDialog(frame, "Current modeling has not been saved\nDo you really want to open a new one ?", "To quit, or not to quit ?", JOptionPane.OK_CANCEL_OPTION);
+                if (back == JOptionPane.CANCEL_OPTION) {
+                return;
+                }*/
+        }
+
+        JDialogLoadingNetworkModel jdlnm = new JDialogLoadingNetworkModel(frame, this, "Opening a network model", ConfigurationTTool.URL_MODEL);
+        GraphicLib.centerOnParent(jdlnm, 700, 800);
+        jdlnm.setVisible(true); // blocked until dialog has been closed
+    }
+
+
+    public void openProject(boolean isProject) {
+        if (config != null && activetdp != null)
+            saveConfig();
+        // check if a current modeling is opened
+        boolean b = actions[TGUIAction.ACT_SAVE].isEnabled();
+
+        if (b) {
+            if (!saveBeforeAction("Save and Open", "Open")) {
+                return;
+            }
+            /*  int back = JOptionPane.showConfirmDialog(frame, "Current modeling has not been saved\nDo you really want to open a new one ?", "To quit, or not to quit ?", JOptionPane.OK_CANCEL_OPTION);
+                if (back == JOptionPane.CANCEL_OPTION) {
+                return;
+                }*/
+        }
+
+        //jfc.setApproveButtonText("Open");
+        if (isProject) {
+            jfc.resetChoosableFileFilters();
+            jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+            jfc.setAcceptAllFileFilterUsed(false);
+            FileNameExtensionFilter filter = new FileNameExtensionFilter("TTool project", "ttool");
+            jfc.setFileFilter(filter);
+            /*jfc.addMouseListener(new MouseListener() {
+
+        	    @Override
+        	    public void mouseClicked(MouseEvent arg0) {
+
+        	        if(arg0.getClickCount() == 2) {
+        	            File file = jfc.getSelectedFile();
+        	            if(!FileUtils.getExtension(file).equals("ttool")) {
+        	                jfc.setCurrentDirectory(file);
+        	                jfc.rescanCurrentDirectory();
+        	            }
+        	            else {
+        	                jfc.approveSelection();
+        	            }
+        	        }
+        	    }
+
+				@Override
+				public void mouseEntered(MouseEvent e) {
+					// TODO Auto-generated method stub
+					return;
+				}
+
+				@Override
+				public void mouseExited(MouseEvent e) {
+					// TODO Auto-generated method stub
+					return;
+				}
+
+				@Override
+				public void mousePressed(MouseEvent e) {
+					// TODO Auto-generated method stub
+					return;
+				}
+
+				@Override
+				public void mouseReleased(MouseEvent e) {
+					// TODO Auto-generated method stub
+					return;
+				}		
+        	});*/
+        } else {
+            jfc.resetChoosableFileFilters();
+            jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
+            jfc.setAcceptAllFileFilterUsed(false);
+            FileNameExtensionFilter filter = new FileNameExtensionFilter("XML files", "xml");
+            jfc.setFileFilter(filter);
+            /*jfc.addMouseListener(new MouseListener() {
+
+        	    @Override
+        	    public void mouseClicked(MouseEvent arg0) {
+
+        	        if(arg0.getClickCount() == 2) {
+        	            File file = jfc.getSelectedFile();
+        	            if(!FileUtils.getExtension(file).equals("ttool")) {
+        	                jfc.setCurrentDirectory(file);
+        	                jfc.rescanCurrentDirectory();
+        	            }
+        	        }
+        	    }
+
+				@Override
+				public void mouseEntered(MouseEvent e) {
+					// TODO Auto-generated method stub
+					return;
+				}
+
+				@Override
+				public void mouseExited(MouseEvent e) {
+					// TODO Auto-generated method stub
+					return;
+				}
+
+				@Override
+				public void mousePressed(MouseEvent e) {
+					// TODO Auto-generated method stub
+					return;
+				}
+
+				@Override
+				public void mouseReleased(MouseEvent e) {
+					// TODO Auto-generated method stub
+					return;
+				}		
+        	});*/
+        }
+        int returnVal = jfc.showOpenDialog(frame);
+
+        if (returnVal == JFileChooser.CANCEL_OPTION) {
+            return;
+        }
+
+        if (returnVal == JFileChooser.APPROVE_OPTION) {
+            file = jfc.getSelectedFile();
+            openProjectFromFile(file);
+        }
+
+    }
+
+    public void openProjectFromFile(File _f) {
+        if (FileUtils.getExtension(_f).equals("ttool")) {
+            dir = _f;
+            SpecConfigTTool.setDirConfig(dir);
+            String filename = dir.getAbsolutePath() + "/" + dir.getName().replaceAll(".ttool", ".xml");
+            file = new File(filename);
+            config = new File(dir.getAbsolutePath() + "/project_config.xml");
+            try {
+                SpecConfigTTool.loadConfigFile(config);
+            } catch (MalformedConfigurationException e) {
+                System.err.println(e.getMessage() + " : Can't load config file.");
+            }
+        } else {
+            dir = null;
+            config = null;
+            SpecConfigTTool.setBasicConfig(systemcOn);
+            file = _f;
+        }
+
+        if (checkFileForOpen(file)) {
+            String s = null;
+
+            try {
+                FileInputStream fis = new FileInputStream(file);
+                int nb = fis.available();
+
+                byte[] ba = new byte[nb];
+                fis.read(ba);
+                fis.close();
+                s = new String(ba);
+            } catch (Exception e) {
+                JOptionPane.showMessageDialog(frame, "File could not be opened because " + e.getMessage(), "File Error", JOptionPane.INFORMATION_MESSAGE);
+                return;
+            }
+
+            // close current modeling
+            closeTurtleModeling();
+
+            // open the new TURTLE modeling
+            newTurtleModeling();
+
+            //            gtm.enableUndo(false);
+
+            // Update configuration
+            updateLastOpenFile(file);
+
+            // Issue #41: Moved to common method
+            loadModels(s, "loaded");
+            //            // load the new TURTLE modeling
+            //            try {
+            //                gtm.loadModelingFromXML(s);
+            //                //gtm.saveOperation(tcdp);
+            //                frame.setTitle("TTool: " + file.getAbsolutePath());
+            //                makeLotosFile();
+            //
+            //                if (gtm.getCheckingErrors().size() > 0) {
+            //                    JOptionPane.showMessageDialog(frame, "Modeling could not be correctly loaded", "Error when loading modeling", JOptionPane.INFORMATION_MESSAGE);
+            //
+            //                }
+            //            } catch (MalformedModelingException mme) {
+            //                JOptionPane.showMessageDialog(frame, "Modeling could not be correctly loaded", "Error when loading modeling", JOptionPane.INFORMATION_MESSAGE);
+            //                frame.setTitle("TToolt: unamed project");
+            //            }
+            //
+            //            gtm.enableUndo(true);
+            //            gtm.saveOperation(getCurrentSelectedPoint());
+            //            dtree.forceUpdate();
+            if (getCurrentTDiagramPanel() != null)
+                getCurrentTDiagramPanel().repaint();
+        }
+    }
+
+    public void openLastProject() {
+        // Check if a current modeling is opened
+        boolean b = actions[TGUIAction.ACT_SAVE].isEnabled();
+        if (b) {
+            if (!saveBeforeAction("Save and Open", "Open")) {
+                return;
+            }
+        }
+
+        file = new File(ConfigurationTTool.LastOpenFile);
+
+        if (checkFileForOpen(file)) {
+            String s = null;
+
+            if (FileUtils.getExtension(file).equals("ttool")) {
+                int last = 0;
+                for (int i = 0; i < ConfigurationTTool.LastOpenFile.length(); i++) {
+                    if (ConfigurationTTool.LastOpenFile.charAt(i) == '/')
+                        last = i;
+                }
+                dir = file;
+                String xml = ConfigurationTTool.LastOpenFile.substring(last, ConfigurationTTool.LastOpenFile.length()).replaceAll(".ttool", ".xml");
+                file = new File(dir.getAbsolutePath() + File.separator + xml);
+                SpecConfigTTool.setDirConfig(dir);
+                config = new File(dir.getAbsolutePath() + "/project_config.xml");
+                try {
+                    SpecConfigTTool.loadConfigFile(config);
+                } catch (MalformedConfigurationException e) {
+                    System.err.println(e.getMessage() + " : Can't load config file.");
+                }
+            } else {
+                dir = null;
+                config = null;
+                SpecConfigTTool.setBasicConfig(systemcOn);
+            }
+
+            try {
+                FileInputStream fis = new FileInputStream(file);
+                int nb = fis.available();
+
+                byte[] ba = new byte[nb];
+                fis.read(ba);
+                fis.close();
+                s = new String(ba);
+            } catch (Exception e) {
+                JOptionPane.showMessageDialog(frame, "File could not be opened because " + e.getMessage(), "File Error", JOptionPane.INFORMATION_MESSAGE);
+                return;
+            }
+
+            // close current modeling
+            closeTurtleModeling();
+
+            // open the new TURTLE modeling
+            newTurtleModeling();
+
+            gtm.enableUndo(false);
+
+            // Issue #41: Moved to common method
+            loadModels(s, "loaded");
+            //TraceManager.addDev("Loading");
+            // load the new TURTLE modeling
+            //            try {
+            //                gtm.loadModelingFromXML(s);
+            //                //gtm.saveOperation(tcdp);
+            //                frame.setTitle("TTool: " + file.getAbsolutePath());
+            //                makeLotosFile();
+            //
+            //                if (gtm.getCheckingErrors().size() > 0) {
+            //                    JOptionPane.showMessageDialog(frame, "Modeling could not be correctly loaded", "Error when loading modeling", JOptionPane.INFORMATION_MESSAGE);
+            //                }
+            //            }
+            //            catch (MalformedModelingException mme) {
+            //                JOptionPane.showMessageDialog(frame, "Modeling could not be correctly loaded ", "Error when loading modeling", JOptionPane.INFORMATION_MESSAGE);
+            //                frame.setTitle("TTool: unamed project");
+            //            }
+            //
+            //            dtree.forceUpdate();
+            //            gtm.enableUndo(true);
+            //            gtm.saveOperation(getCurrentSelectedPoint());
+        }
+
+        //Added by Solange
+        //TURTLEPanel tp = getCurrentTURTLEPanel();
+        //gtm.generateLists((ProactiveDesignPanel)tp);
+        //
+    }
+
+    private void loadModels(final String xmlModel,
+                            final String actionMessage) {
+        gtm.enableUndo(false);
+
+        // load the new TURTLE modeling
+        try {
+            gtm.loadModelingFromXML(xmlModel);
+            frame.setTitle("TTool: " + file.getAbsolutePath());
+            makeLotosFile();
+
+            // Issue #41: Reselect the last tab
+            mainTabbedPane.setSelectedIndex(mainTabbedPane.getTabCount() - 1);
+
+            if (gtm.getCheckingErrors().size() > 0) {
+                JOptionPane.showMessageDialog(frame, "Modeling could not be correctly " + actionMessage, "Error when loading modeling", JOptionPane.INFORMATION_MESSAGE);
+
+            }
+        } catch (MalformedModelingException mme) {
+            JOptionPane.showMessageDialog(frame, "Modeling could not be correctly " + actionMessage, "Error when loading modeling", JOptionPane.INFORMATION_MESSAGE);
+            frame.setTitle("TToolt: unnamed project");
+        }
+
+        gtm.enableUndo(true);
+        gtm.saveOperation(getCurrentSelectedPoint());
+        dtree.forceUpdate();
+        if (SpecConfigTTool.lastTab > -1 && SpecConfigTTool.lastPanel > -1 && mainTabbedPane.getTabCount() > 0) {
+            mainTabbedPane.setSelectedIndex(SpecConfigTTool.lastTab);
+            activetdp = tabs.get(SpecConfigTTool.lastTab).getPanels().elementAt(SpecConfigTTool.lastPanel);
+            activetdp.selectTab(activetdp.name);
+            basicActivateDrawing();
+        }
+
+        if (dir != null)
+            loadAUTGraphsDir();
+    }
+
+    public void saveAsLibrary(String data) {
+        File libfile;
+
+        int returnVal = jfclib.showDialog(frame, "Export library");
+        if (returnVal != JFileChooser.APPROVE_OPTION) {
+            return;
+        }
+
+        libfile = jfclib.getSelectedFile();
+        libfile = FileUtils.addFileExtensionIfMissing(libfile, TLibFilter.getExtension());
+
+        if (checkFileForSave(libfile)) {
+            try {
+                if (data == null) {
+                    throw new Exception("Selected data corrupted");
+                }
+                FileOutputStream fos = new FileOutputStream(libfile);
+                fos.write(data.getBytes());
+                fos.close();
+                JOptionPane.showMessageDialog(frame, "Modeling was correctly saved under a TURTLE library named " + libfile.getName(), "Saving", JOptionPane.INFORMATION_MESSAGE);
+                return;
+            } catch (Exception e) {
+                JOptionPane.showMessageDialog(frame, "File could not be saved because " + e.getMessage(), "File Error", JOptionPane.INFORMATION_MESSAGE);
+                return;
+            }
+        }
+    }
+
+    public void saveAsProject() {
+        File old = file;
+        if (file == null) {
+            // project never saved
+            saveProject();
+        } else {
+            file = null;
+            if (!saveProject()) {
+                file = old;
+            }
+        }
+        if (file != old) {
+            //frame.setTitle("TURTLE Toolkit: " + file.getAbsolutePath());
+            makeLotosFile();
+        }
+    }
+
+    public boolean saveTIF() {
+        int returnVal = jfctif.showSaveDialog(frame);
+        if (returnVal == JFileChooser.APPROVE_OPTION) {
+            file = jfctif.getSelectedFile();
+            file = FileUtils.addFileExtensionIfMissing(file, TTIFFilter.getExtension());
+        }
+
+        if (checkFileForSave(file)) {
+            String s = gtm.saveTIF();
+            try {
+
+                if (s == null) {
+                    throw new Exception("TIF specification is void");
+
+                }
+                FileOutputStream fos = new FileOutputStream(file);
+                fos.write(s.getBytes());
+                fos.close();
+
+                return true;
+            } catch (Exception e) {
+                JOptionPane.showMessageDialog(frame, "File could not be saved because " + e.getMessage(), "File Error", JOptionPane.INFORMATION_MESSAGE);
+                return false;
+            }
+        }
+        return false;
+    }
+
+    public boolean openTIF() {
+        //jfc.setApproveButtonText("Open");
+        int returnVal = jfctif.showOpenDialog(frame);
+
+        if (returnVal == JFileChooser.APPROVE_OPTION) {
+            file = jfctif.getSelectedFile();
+        }
+
+        String s = null;
+        if (checkFileForOpen(file)) {
+            try {
+                FileInputStream fis = new FileInputStream(file);
+                int nb = fis.available();
+
+                byte[] ba = new byte[nb];
+                fis.read(ba);
+                fis.close();
+                s = new String(ba);
+            } catch (Exception e) {
+                JOptionPane.showMessageDialog(frame, "File could not be opened because " + e.getMessage(), "File Error", JOptionPane.INFORMATION_MESSAGE);
+                return false;
+            }
+        }
+        if (s == null) {
+            return false;
+        }
+        TraceManager.addDev("Open TIF =" + s);
+        if (gtm == null) {
+            newTurtleModeling();
+        }
+        return gtm.openTIF(s);
+
+    }
+
+    public boolean openSD() {
+        //jfc.setApproveButtonText("Open");
+        int returnVal = jfcmsc.showOpenDialog(frame);
+
+        if (returnVal == JFileChooser.APPROVE_OPTION) {
+            file = jfcmsc.getSelectedFile();
+        }
+
+        String s = null;
+        if (checkFileForOpen(file)) {
+            try {
+                FileInputStream fis = new FileInputStream(file);
+                int nb = fis.available();
+
+                byte[] ba = new byte[nb];
+                fis.read(ba);
+                fis.close();
+                s = new String(ba);
+            } catch (Exception e) {
+                JOptionPane.showMessageDialog(frame, "File could not be opened because " + e.getMessage(), "File Error", JOptionPane.INFORMATION_MESSAGE);
+                return false;
+            }
+        }
+        if (s == null) {
+            return false;
+        }
+        TraceManager.addDev("Open SD =" + s);
+        if (gtm == null) {
+            newTurtleModeling();
+        }
+        return gtm.openSD(s);
+
+    }
+
+    private int createFileDialog() {
+        int returnVal = jfc.showSaveDialog(frame);
+        if (returnVal == JFileChooser.APPROVE_OPTION) {
+            dir = jfc.getSelectedFile();
+            dir = FileUtils.addFileExtensionIfMissing(dir, "ttool");
+            dir.mkdir();
+            SpecConfigTTool.setDirConfig(dir);
+            config = SpecConfigTTool.createProjectConfig(dir);
+            try {
+                SpecConfigTTool.loadConfigFile(config);
+            } catch (MalformedConfigurationException e) {
+                System.err.println(e.getMessage() + " : Can't load config file.");
+            }
+            String newname = FileUtils.removeFileExtension(dir.getName());
+            file = new File(dir, newname);
+            file = FileUtils.addFileExtensionIfMissing(file, TFileFilter.getExtension());
+        }
+
+        return returnVal;
+    }
+
+    private void createFile() {
+        newTurtleModeling();
+        frame.setTitle(file.getName());
+        try {
+            if (gtm == null) {
+                throw new Exception("Internal model Error 1");
+            }
+            String s = gtm.makeXMLFromTurtleModeling(-1);
+            if (s == null) {
+                throw new Exception("Internal model Error 2");
+            }
+            FileOutputStream fos = new FileOutputStream(file);
+            fos.write(s.getBytes());
+            fos.close();
+            updateLastOpenFile(file);
+            setMode(MODEL_SAVED);
+            String title = "TTool: " + file.getAbsolutePath();
+            if (!frame.getTitle().equals(title)) {
+                frame.setTitle(title);
+            }
+            if (lotosfile == null) {
+                makeLotosFile();
+            }
+        } catch (Exception e) {
+            JOptionPane.showMessageDialog(frame, "File could not be saved because " + e.getMessage(), "File Error", JOptionPane.INFORMATION_MESSAGE);
+        }
+    }
+
+
+    protected boolean saveAsNewProject() {
+        jfc.resetChoosableFileFilters();
+        jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+        jfc.setAcceptAllFileFilterUsed(false);
+        FileNameExtensionFilter filter = new FileNameExtensionFilter("TTool project", "ttool");
+        jfc.setFileFilter(filter);
+
+        createFileDialog();
+
+        return mainSave();
+
+    }
+
+    protected boolean saveAsNewModel() {
+        jfc.resetChoosableFileFilters();
+        jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
+        jfc.setAcceptAllFileFilterUsed(false);
+        FileNameExtensionFilter filter = new FileNameExtensionFilter("XML files", "xml");
+        jfc.setFileFilter(filter);
+        int returnVal = jfc.showSaveDialog(frame);
+        if (returnVal == JFileChooser.APPROVE_OPTION) {
+            file = jfc.getSelectedFile();
+            file = FileUtils.addFileExtensionIfMissing(file, TFileFilter.getExtension());
+        }
+
+        boolean b = mainSave();
+        if (b) {
+            dir = null;
+            config = null;
+            SpecConfigTTool.setBasicConfig(systemcOn);
+        }
+        return b;
+    }
+
+    protected boolean saveProject() {
+        if (file == null) {
+            if (dir != null)
+                createFileDialog();
+            else {
+                int returnVal = jfc.showSaveDialog(frame);
+                if (returnVal == JFileChooser.APPROVE_OPTION) {
+                    file = jfc.getSelectedFile();
+                    file = FileUtils.addFileExtensionIfMissing(file, TFileFilter.getExtension());
+                }
+            }
+        }
+
+        return mainSave();
+    }
+
+    public boolean mainSave() {
+        if (checkFileForSave(file)) {
+            try {
+                if (gtm == null) {
+                    throw new Exception("Internal model Error 1");
+                }
+                String s = gtm.makeXMLFromTurtleModeling(-1);
+                if (s == null) {
+                    throw new Exception("Internal model Error 2");
+                }
+                FileOutputStream fos = new FileOutputStream(file);
+                fos.write(s.getBytes());
+                fos.close();
+                updateLastOpenFile(file);
+                setMode(MODEL_SAVED);
+                String title = "TTool: " + file.getAbsolutePath();
+                if (!frame.getTitle().equals(title)) {
+                    frame.setTitle(title);
+                }
+                if (lotosfile == null) {
+                    makeLotosFile();
+                }
+                return true;
+            } catch (Exception e) {
+                JOptionPane.showMessageDialog(frame, "File could not be saved because " + e.getMessage(), "File Error", JOptionPane.INFORMATION_MESSAGE);
+                return false;
+            }
+        }
+        return false;
+    }
+
+    public boolean checkFileForOpen(File file) {
+        boolean ok = true;
+        String pb = "";
+
+        //TraceManager.addDev("File path=" + file.getPath() + " name=" + file.getName());
+
+        if (file == null) {
+            return false;
+        }
+
+        try {
+            if (file != null) {
+                if (!file.exists()) {
+                    pb = "File " + file + " doesn't exist";
+                    ok = false;
+                }
+                if ((ok == true) && (!file.canRead())) {
+                    pb = "File is read protected";
+                    ok = false;
+                }
+            }
+        } catch (Exception e) {
+            ok = false;
+            pb = e.getMessage();
+        }
+        if (ok == false) {
+            file = null;
+            JOptionPane.showMessageDialog(frame, pb, "File Error", JOptionPane.INFORMATION_MESSAGE);
+        }
+        return ok;
+    }
+
+    public boolean checkFileForSave(File file) {
+        boolean ok = true;
+        String pb = "";
+
+        if (file == null) {
+            return false;
+        }
+
+        try {
+            if (file != null) {
+                if (!file.exists()) {
+                    if (!file.createNewFile()) {
+                        pb = "File could not be created";
+                        ok = false;
+                    }
+                    if (!file.canWrite()) {
+                        pb = "File is write protected";
+                        ok = false;
+                    }
+                }
+            }
+        } catch (Exception e) {
+            ok = false;
+            pb = e.getMessage();
+        }
+        if (ok == false) {
+            file = null;
+            JOptionPane.showMessageDialog(frame, pb, "File Error", JOptionPane.INFORMATION_MESSAGE);
+        }
+        return ok;
+    }
+
+    public void saveLastLotos() {
+        saveLotosSpec(gtm.getLastRTLOTOSSpecification());
+    }
+
+    public void saveLastDTA() {
+        saveDTA(gtm.getLastTextualDTA(), gtm.getLastGraphicalDTA());
+    }
+
+    public void saveLastRG() {
+        saveRG(gtm.getLastTextualRG(), gtm.getLastGraphicalRG());
+    }
+
+    public void saveLastTLSA() {
+        saveTLSA(gtm.getLastTextualTLSA(), gtm.getLastGraphicalTLSA());
+    }
+
+    public void saveLastRGAUT() {
+        saveRGAUT(gtm.getLastTextualRGAUT(), gtm.getLastGraphicalRGAUT());
+    }
+
+    public void saveLastRGAUTProj() {
+        saveRGAUT(gtm.getLastTextualRGAUTProj(), gtm.getLastGraphicalRGAUTProj());
+    }
+
+    public void saveLastModifiedRG() {
+        saveRGAUT(modifiedaut, modifiedautdot);
+    }
+
+    public void importLibrary() {
+        //TDiagramPanel tdp1 = ((TDiagramPanel)(designPanels.elementAt(mainDesignTabbedPane.getSelectedIndex()));
+        //tdp1.insertLibrary(tdp1.getMinX(), tdp1.getMinY());
+        TDiagramPanel tdp1 = getCurrentTDiagramPanel();
+        if (tdp1 != null) {
+            tdp1.insertLibrary(tdp1.getMinX(), tdp1.getMinY());
+        }
+    }
+
+    public void exportLibrary() {
+        //TDiagramPanel tdp1 = (TDiagramPanel)(designPanels.elementAt(mainDesignTabbedPane.getSelectedIndex()));
+        //tdp1.saveAsLibrary();
+        getCurrentTDiagramPanel().saveAsLibrary();
+    }
+
+    public void makeLotosFile() {
+        String s = file.getAbsolutePath();
+        int l = s.length();
+        String myFile = s.substring(0, l - 4);
+        lotosfile = new File(myFile + ".lot");
+        simfile = new File(myFile + ".sim");
+        dtafile = new File(myFile + ".dta");
+        dtadotfile = new File(myFile + ".dta.dot");
+        rgfile = new File(myFile + ".rg");
+        rgdotfile = new File(myFile + ".rg.dot");
+        tlsafile = new File(myFile + ".tlsa");
+        tlsadotfile = new File(myFile + ".dot.tlsa");
+        rgautfile = new File(myFile + ".aut");
+        fc2file = new File(myFile + ".fc2");
+        bcgfile = new File(myFile + ".bcg");
+        rgautdotfile = new File(myFile + ".aut.dot");
+        rgautprojfile = new File(myFile + "_proj.aut");
+        rgautprojdotfile = new File(myFile + "_proj.aut.dot");
+    }
+
+    /**
+     * Display "Modeling has not been saved" window
+     *
+     * @param str1 (text for the left button)
+     * @param str2 (text for the right button)
+     * @return boolean (false = cancel, true = perform action)
+     * @author Fabien Tessier
+     */
+    public boolean saveBeforeAction(String str1, String str2) {
+        Object[] options = {str1, str2, "CANCEL"}; //Texts for buttons
+        JOptionPane optionPane = new JOptionPane("Modeling has not been saved", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, options, options[0]);
+        JDialog dialog = optionPane.createDialog(activetdp, "Warning"); //Use JDialog to enable navigation with arrow keys
+        dialog.setLocation((frame.getSize().width) / 2 - dialog.getWidth() / 2, (frame.getSize().height) / 2 - dialog.getHeight() / 2);
+        UIManager.put("Button.defaultButtonFollowsFocus", Boolean.TRUE);
+
+        Set<AWTKeyStroke> forwardTraversalKeys = new HashSet<AWTKeyStroke>(dialog.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
+        forwardTraversalKeys.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.VK_UNDEFINED));
+        dialog.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardTraversalKeys); //Navigation with right arrow
+
+        Set<AWTKeyStroke> backwardTraversalKeys = new HashSet<AWTKeyStroke>(dialog.getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS));
+        backwardTraversalKeys.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_LEFT, KeyEvent.VK_UNDEFINED));
+        dialog.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backwardTraversalKeys); //Navigation with left arrow
+
+        dialog.setVisible(true);
+        dialog.dispose();
+        String ret = (String) optionPane.getValue(); //Get value of the pressed button
+        if (ret == null || ret.equals("CANCEL")) {
+            return false;
+        }
+
+        if (ret.equals(str1)) {
+            saveProject();
+        }
+        return true;
+    }
+
+    public void quitApplication() {
+        boolean b = actions[TGUIAction.ACT_SAVE].isEnabled();
+        if (b) {
+            if (saveBeforeAction("SAVE and QUIT", "QUIT now") == false) {
+                return;
+            }
+
+        }
+
+        ConfigurationTTool.LastWindowAttributesX = "" + frame.getLocation().x;
+        ConfigurationTTool.LastWindowAttributesY = "" + frame.getLocation().y;
+        ConfigurationTTool.LastWindowAttributesWidth = "" + frame.getSize().width;
+        ConfigurationTTool.LastWindowAttributesHeight = "" + frame.getSize().height;
+
+        if (frame.getExtendedState() == Frame.MAXIMIZED_BOTH) {
+            ConfigurationTTool.LastWindowAttributesMax = "true";
+        } else {
+            ConfigurationTTool.LastWindowAttributesMax = "false";
+        }
+
+        try {
+            if (ConfigurationTTool.LastOpenFileDefined) {
+                if (dir != null)
+                    saveConfig();
+                ConfigurationTTool.saveConfiguration();
+                //TraceManager.addDev("Configuration written to file");
+            }
+        } catch (Exception e) {
+        }
+
+
+        System.exit(0);
+    }
+
+
+    public void cut() {
+        getCurrentTDiagramPanel().makeCut();
+    }
+
+    public void copy() {
+        getCurrentTDiagramPanel().makeCopy();
+    }
+
+    public void paste() {
+        int x = Math.min(Math.max(getCurrentTDiagramPanel().getMinX(), getCurrentTDiagramPanel().currentX), getCurrentTDiagramPanel().getMaxX());
+        int y = Math.min(Math.max(getCurrentTDiagramPanel().getMinY(), getCurrentTDiagramPanel().currentY), getCurrentTDiagramPanel().getMaxY());
+        getCurrentTDiagramPanel().makePaste(x, y);
+    }
+
+    public void delete() {
+        getCurrentTDiagramPanel().makeDelete();
+    }
+
+    public void backward() {
+        //TraceManager.addDev("backward");
+        gtm.backward();
+        setMode(MODEL_CHANGED);
+        dtree.toBeUpdated();
+    }
+
+    public void forward() {
+        //TraceManager.addDev("forward");
+        gtm.forward();
+        setMode(MODEL_CHANGED);
+        dtree.toBeUpdated();
+    }
+
+    public void zoomMore() {
+        zoom(1.25);
+    }
+
+    public void zoomLess() {
+        zoom(0.8);
+    }
+
+    public void zoom(double multFactor) {
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        tdp.setZoom(tdp.getZoom() * multFactor);
+        // tdp.updateComponentsAfterZoom();
+        updateZoomInfo();
+    }
+
+    public void updateZoomInfo() {
+        String s = "";
+        int zoom = (int) (getCurrentTDiagramPanel().getZoom() * 100);
+        if (zoom < 100) {
+            s = "0" + zoom + "%";
+        } else {
+            s += zoom + "%";
+        }
+        //TraceManager.addDev("Seeting zoom in " + getCurrentTDiagramPanel());
+        actions[TGUIAction.ACT_SHOW_ZOOM].setName(TGUIAction.ACT_SHOW_ZOOM, s);
+    }
+
+    public void oldFirstDiag() {
+        getCurrentJTabbedPane().setSelectedIndex(0);
+    }
+
+    public void backDiag() {
+        getCurrentJTabbedPane().setSelectedIndex(Math.max(0, getCurrentJTabbedPane().getSelectedIndex() - 1));
+    }
+
+    public void nextDiag() {
+        getCurrentJTabbedPane().setSelectedIndex(Math.min(getCurrentJTabbedPane().getTabCount(), getCurrentJTabbedPane().getSelectedIndex() + 1));
+    }
+
+    public void lastDiag() {
+        getCurrentJTabbedPane().setSelectedIndex(getCurrentJTabbedPane().getTabCount() - 1);
+    }
+
+    //@author: Huy TRUONG
+    //open a new External Search Dialog
+    public void showExternalSearch() {
+        String textSearchField = mainBar.search.getText();
+        List<String> listSearch = new ArrayList<String>();
+
+        if (null == this.searchBox) {
+            if (getCurrentTDiagramPanel() != null) {
+                if (getCurrentTDiagramPanel().tdmm.getSelectComponents().size() == 0) {
+                    listSearch.add(textSearchField);
+                } else {
+                    listSearch = getCurrentTDiagramPanel().tdmm.getSelectComponents();
+                    listSearch.add(0, textSearchField);
+
+                }
+                this.searchBox = new JDialogSearchBox(frame, "External Search", listSearch, getCurrentTDiagramPanel().tdmm);
+            } else
+                this.searchBox = new JDialogSearchBox(frame, "External Search", new ArrayList<String>());
+
+        } else {
+            if (this.searchBox.isShowing()) {
+                this.searchBox.setVisible(true);
+            } else {
+                this.searchBox = null;
+                showExternalSearch();
+            }
+        }
+    }
+
+    public void doInternalSearch() {
+        search(mainBar.search.getText());
+    }
+
+    public void aboutVersion() {
+        JFrameBasicText jft = new JFrameBasicText("About TTool ...", DefaultText.getAboutText(), IconManager.imgic324);
+        jft.setIconImage(IconManager.img8);
+        GraphicLib.centerOnParent(jft, 740, 800);
+        jft.setVisible(true);
+
+    }
+
+    public void showTToolConfiguration() {
+        JFrameBasicText jft = new JFrameBasicText("Your configuration of TTool ...",
+                "Default configuration:\n-----------------------\n" + ConfigurationTTool.getConfiguration(systemcOn)
+                        + "\nProject configuration:\n-----------------------\n" + SpecConfigTTool.getConfiguration(systemcOn),
+                IconManager.imgic76);
+        jft.setIconImage(IconManager.img8);
+        //jft.setSize(700, 800);
+        GraphicLib.centerOnParent(jft, 700, 800);
+        jft.setVisible(true);
+
+    }
+
+    public void aboutTURTLE() {
+        BrowserControl.startBrowerToURL("http://ttool.telecom-paristech.fr/");
+    }
+
+    public void helpTURTLE() {
+        BrowserControl.startBrowerToURL("http://ttool.telecom-paristech.fr/avatar.html");
+    }
+
+    public void helpSysMLSec() {
+        BrowserControl.startBrowerToURL("http://sysml-sec.telecom-paristech.fr/");
+    }
+
+    public void helpDIPLODOCUS() {
+        BrowserControl.startBrowerToURL("http://ttool.telecom-paristech.fr/diplodocus.html");
+    }
+
+    public void oneClickLOTOSRG() {
+        // boolean ret;
+        if (!checkModelingSyntax(true)) {
+            TraceManager.addDev("Syntax error");
+            return;
+        }
+
+        if (!generateLOTOS(true)) {
+            TraceManager.addDev("Generate LOTOS: error");
+            return;
+        }
+
+        formalValidation(true);
+    }
+
+    public void oneClickRTLOTOSRG() {
+        // boolean ret;
+        if (!checkModelingSyntax(true)) {
+            TraceManager.addDev("Syntax error");
+            return;
+        }
+
+        if (!generateRTLOTOS(true)) {
+            TraceManager.addDev("Generate RT-LOTOS: error");
+            return;
+        }
+
+        formalValidation(true);
+    }
+
+    public void modelChecking() {
+        checkModelingSyntax(false);
+    }
+
+    public boolean checkModelingSyntax(String panelName, boolean automatic) {
+        TURTLEPanel tp = getTURTLEPanel(panelName);
+        if (tp != null) {
+            return checkModelingSyntax(tp, automatic);
+        }
+
+        return false;
+    }
+
+    public boolean checkModelingSyntax(boolean automatic) {
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        if (tp != null) {
+            return checkModelingSyntax(tp, automatic);
+        }
+
+        return false;
+    }
+
+    public boolean checkModelingSyntax(TURTLEPanel tp, boolean automatic) {
+        //String msg = "";
+        boolean b = false;
+        boolean ret = false;
+
+        if (file == null) {
+            JOptionPane.showMessageDialog(frame,
+                    "The project must be saved before any simulation or formal verification can be performed",
+                    "Syntax analysis failed",
+                    JOptionPane.INFORMATION_MESSAGE);
+            return false;
+        }
+
+
+        if (tp instanceof AnalysisPanel) {
+            try {
+                b = gtm.buildTURTLEModelingFromAnalysis((AnalysisPanel) tp);
+            } catch (AnalysisSyntaxException ae) {
+                //TraceManager.addDev("Exception AnalysisSyntaxException");
+                //msg = ae.getMessage();
+                b = false;
+            }
+            expandToWarnings();
+            expandToErrors();
+            if (b) {
+                setMode(MainGUI.MODEL_OK);
+                setMode(MainGUI.GEN_DESIGN_OK);
+                ret = true;
+                if (!automatic) {
+                    JOptionPane.showMessageDialog(frame,
+                            "0 error, " + getCheckingWarnings().size() + " warning(s). You can now generate a corresponding formal (RT-LOTOS) specification or executable code (Java)",
+                            "Syntax analysis successful on analysis diagrams",
+                            JOptionPane.INFORMATION_MESSAGE);
+                }
+            } else {
+                if (!automatic) {
+                    JOptionPane.showMessageDialog(frame,
+                            "The TURTLE Analysis contains several errors",
+                            "Syntax analysis failed",
+                            JOptionPane.INFORMATION_MESSAGE);
+                }
+                setMode(MainGUI.GEN_DESIGN_OK);
+                //setMode(MainGUI.MODEL_OK);
+            }
+
+
+        } else if (tp instanceof DesignPanel) {
+            //Design
+            DesignPanel dp = (DesignPanel) tp;
+            JDialogModelChecking.validated = dp.validated;
+            JDialogModelChecking.ignored = dp.ignored;
+            LinkedList<TClassInterface> tclassesToValidate = new LinkedList<TClassInterface>();
+            JDialogModelChecking jdmc = new JDialogModelChecking(frame, tclassesToValidate, dp.tcdp.getComponentList(), "Choosing Tclasses to validate");
+            if (!automatic) {
+                GraphicLib.centerOnParent(jdmc);
+                jdmc.setVisible(true); // blocked until dialog has been closed
+            } else {
+                jdmc.closeDialog();
+            }
+            boolean overideTifChecking = jdmc.getOverideSyntaxChecking();
+            if (tclassesToValidate.size() > 0) {
+                dp.validated = JDialogModelChecking.validated;
+                dp.ignored = JDialogModelChecking.ignored;
+                b = gtm.checkTURTLEModeling(tclassesToValidate, dp, overideTifChecking);
+                expandToWarnings();
+                expandToErrors();
+                if (b) {
+                    ret = true;
+                    setMode(MainGUI.MODEL_OK);
+                    setMode(MainGUI.GEN_DESIGN_OK);
+                    if (!automatic) {
+                        JOptionPane.showMessageDialog(frame,
+                                "0 error, " + getCheckingWarnings().size() + " warning(s). You can now generate a corresponding formal (RT-LOTOS) specification or executable code (Java)",
+                                "Syntax analysis successful on design diagrams",
+                                JOptionPane.INFORMATION_MESSAGE);
+                    }
+                } else {
+                    if (!automatic) {
+                        JOptionPane.showMessageDialog(frame,
+                                "The TURTLE Modeling contains several errors",
+                                "Syntax analysis failed",
+                                JOptionPane.INFORMATION_MESSAGE);
+                    }
+                }
+            }
+
+        } else if (tp instanceof DeploymentPanel) {
+            DeploymentPanel dp = (DeploymentPanel) tp;
+            b = gtm.translateDeployment(dp);
+            expandToWarnings();
+            expandToErrors();
+            if (b) {
+                setMode(MainGUI.MODEL_OK);
+                ret = true;
+                if (!automatic) {
+                    JOptionPane.showMessageDialog(frame,
+                            "0 error, " + getCheckingWarnings().size() + " warning(s). You can now generate a corresponding formal (RT-LOTOS) specification or executable code (Java)",
+                            "Syntax analysis successful on deployment diagrams",
+                            JOptionPane.INFORMATION_MESSAGE);
+                }
+            } else {
+                if (!automatic) {
+                    JOptionPane.showMessageDialog(frame,
+                            "The TURTLE deployment contains several errors",
+                            "Syntax analysis failed",
+                            JOptionPane.INFORMATION_MESSAGE);
+                }
+            }
+
+            // FaultTree
+        } else if (tp instanceof FaultTreePanel) {
+            FaultTreePanel atp = (FaultTreePanel) tp;
+            b = gtm.translateFaultTreePanel(atp);
+            expandToWarnings();
+            expandToErrors();
+            if (b) {
+                setMode(MainGUI.FAULTTREE_SYNTAXCHECKING_OK);
+                ret = true;
+                if (!automatic) {
+                    JOptionPane.showMessageDialog(frame,
+                            "0 error, " + getCheckingWarnings().size() + " warning(s)",
+                            "Syntax analysis successful on fault tree",
+                            JOptionPane.INFORMATION_MESSAGE);
+                }
+            } else {
+                if (!automatic) {
+                    JOptionPane.showMessageDialog(frame,
+                            "The fault tree contains several errors",
+                            "Syntax analysis failed",
+                            JOptionPane.INFORMATION_MESSAGE);
+                }
+            }
+
+        } else if (tp instanceof AttackTreePanel) {
+            AttackTreePanel atp = (AttackTreePanel) tp;
+            b = gtm.translateAttackTreePanel(atp);
+            expandToWarnings();
+            expandToErrors();
+            if (b) {
+                setMode(MainGUI.ATTACKTREE_SYNTAXCHECKING_OK);
+                ret = true;
+                if (!automatic) {
+                    JOptionPane.showMessageDialog(frame,
+                            "0 error, " + getCheckingWarnings().size() + " warning(s)",
+                            "Syntax analysis successful on attack tree",
+                            JOptionPane.INFORMATION_MESSAGE);
+                }
+            } else {
+                if (!automatic) {
+                    JOptionPane.showMessageDialog(frame,
+                            "The Attack tree contains several errors",
+                            "Syntax analysis failed",
+                            JOptionPane.INFORMATION_MESSAGE);
+                }
+            }
+
+
+            // AVATAR
+        } else if (tp instanceof AvatarDesignPanel) {
+            //Design
+            AvatarDesignPanel adp = (AvatarDesignPanel) tp;
+            //JDialogModelChecking.validated = adp.validated;
+            //JDialogModelChecking.ignored = adp.ignored;
+            LinkedList<AvatarBDStateMachineOwner> blocksToValidate = new LinkedList<AvatarBDStateMachineOwner>();
+            JDialogSelectAvatarBlock jdmc = new JDialogSelectAvatarBlock(frame, blocksToValidate, adp.getAvatarBDPanel().getFullStateMachineOwnerList(), "Choosing blocks to validate", adp.getValidated(), adp.getIgnored(), adp.getOptimized());
+            if (!automatic) {
+                GraphicLib.centerOnParent(jdmc);
+                jdmc.setVisible(true); // blocked until dialog has been closed
+            } else {
+                jdmc.closeDialog();
+            }
+
+            if (jdmc.hasBeenCancelled()) {
+                return false;
+            }
+
+            adp.resetModelBacktracingProVerif();
+
+            adp.setValidated(jdmc.getValidated());
+            adp.setIgnored(jdmc.getIgnored());
+            adp.setOptimized(jdmc.getOptimized());
+
+
+            boolean optimize = jdmc.getOptimized();
+            if (blocksToValidate.size() > 0) {
+                /*adp.validated = JDialogModelChecking.validated;
+                  adp.ignored = JDialogModelChecking.ignored;*/
+                b = gtm.checkAvatarDesign(blocksToValidate, adp, optimize);
+                expandToWarnings();
+                expandToErrors();
+                if (b) {
+                    ret = true;
+                    setMode(MainGUI.AVATAR_SYNTAXCHECKING_OK);
+                    //setMode(MainGUI.GEN_DESIGN_OK);
+                    /*
+                      if (!automatic) {
+                      JOptionPane.showMessageDialog(frame,
+                      "0 error, " + getCheckingWarnings().size() + " warning(s). You can now perform simulations or formal proofs (UPPAAL)",
+                      "Syntax analysis successful on avatar design diagrams",
+                      JOptionPane.INFORMATION_MESSAGE);
+                      }
+                    */
+                } else {
+                    if (!automatic) {
+                        JOptionPane.showMessageDialog(frame,
+                                "The Avatar modeling contains several errors",
+                                "Syntax analysis failed",
+                                JOptionPane.ERROR_MESSAGE);
+                    }
+                }
+            }
+
+
+            // NC
+        }
+        //DG 6.2. 2017
+
+        else if (tp instanceof ADDPanel) {
+            //Design
+            AvatarDesignPanel adp = getFirstAvatarDesignPanelFound();
+
+            //JDialogModelChecking.validated = adp.validated;
+            //JDialogModelChecking.ignored = adp.ignored;
+            LinkedList<AvatarBDStateMachineOwner> blocksToValidate = new LinkedList<AvatarBDStateMachineOwner>();
+            JDialogSelectAvatarBlock jdmc = new JDialogSelectAvatarBlock(frame, blocksToValidate, adp.getAvatarBDPanel().getFullStateMachineOwnerList(), "Choosing blocks to validate", adp.getValidated(), adp.getIgnored(), adp.getOptimized());
+            if (!automatic) {
+                GraphicLib.centerOnParent(jdmc);
+                jdmc.setVisible(true); // blocked until dialog has been closed
+            } else {
+                jdmc.closeDialog();
+            }
+
+            if (jdmc.hasBeenCancelled()) {
+                return false;
+            }
+
+            adp.resetModelBacktracingProVerif();
+
+            adp.setValidated(jdmc.getValidated());
+            adp.setIgnored(jdmc.getIgnored());
+            adp.setOptimized(jdmc.getOptimized());
+
+
+            boolean optimize = jdmc.getOptimized();
+            if (blocksToValidate.size() > 0) {
+                /*adp.validated = JDialogModelChecking.validated;
+                  adp.ignored = JDialogModelChecking.ignored;*/
+                b = gtm.checkAvatarDesign(blocksToValidate, adp, optimize);
+                expandToWarnings();
+                expandToErrors();
+                if (b) {
+                    ret = true;
+                    setMode(MainGUI.AVATAR_SYNTAXCHECKING_OK);
+                    //setMode(MainGUI.GEN_DESIGN_OK);
+                    /*
+                      if (!automatic) {
+                      JOptionPane.showMessageDialog(frame,
+                      "0 error, " + getCheckingWarnings().size() + " warning(s). You can now perform simulations or formal proofs (UPPAAL)",
+                      "Syntax analysis successful on avatar design diagrams",
+                      JOptionPane.INFORMATION_MESSAGE);
+                      }
+                    */
+                } else {
+                    if (!automatic) {
+                        JOptionPane.showMessageDialog(frame,
+                                "The Avatar modeling contains several errors",
+                                "Syntax analysis failed",
+                                JOptionPane.ERROR_MESSAGE);
+                    }
+                }
+            }
+
+
+            // NC
+        }
+
+
+        //fin DG
+        else if (tp instanceof NCPanel) {
+            NCPanel ncp = (NCPanel) tp;
+            b = gtm.translateNC(ncp);
+            if (b) {
+                //setMode(MainGUI.MODEL_OK_NC);
+                ret = true;
+                if (!automatic) {
+                    JOptionPane.showMessageDialog(frame,
+                            "0 error, " + getCheckingWarnings().size() + " warning(s)",
+                            "Syntax analysis successful on NC diagram",
+                            JOptionPane.INFORMATION_MESSAGE);
+                }
+            } else {
+                if (!automatic) {
+                    JOptionPane.showMessageDialog(frame,
+                            "The NC diagram contains several errors",
+                            "Syntax analysis failed",
+                            JOptionPane.INFORMATION_MESSAGE);
+                }
+            }
+
+
+        } else if (tp instanceof TMLDesignPanel) {
+            TMLDesignPanel tmldp = (TMLDesignPanel) tp;
+            JDialogSelectTMLTask.validated = tmldp.validated;
+            JDialogSelectTMLTask.ignored = tmldp.ignored;
+            Vector<TGComponent> tmlTasksToValidate = new Vector<TGComponent>();
+            JDialogSelectTMLTask jdstmlt = new JDialogSelectTMLTask(frame, tmlTasksToValidate, tmldp.tmltdp.getComponentList(), "Choosing TML tasks to validate");
+            if (!automatic) {
+                GraphicLib.centerOnParent(jdstmlt);
+                jdstmlt.setVisible(true); // Blocked until dialog has been closed
+            } else {
+                jdstmlt.closeDialog();
+            }
+            if (tmlTasksToValidate.size() > 0) {
+                tmldp.validated = JDialogSelectTMLTask.validated;
+                tmldp.ignored = JDialogSelectTMLTask.ignored;
+                b = gtm.translateTMLDesign(tmlTasksToValidate, tmldp, jdstmlt.getOptimize());
+                expandToWarnings();
+                expandToErrors();
+                if (b) {
+                    //setMode(MainGUI.MODEL_OK);
+                    setMode(MainGUI.GEN_SYSTEMC_OK);
+                    setMode(MainGUI.MODEL_OK);
+                    ret = true;
+                    if (!automatic) {
+                        JOptionPane.showMessageDialog(frame,
+                                "0 error, " + getCheckingWarnings().size() + " warning(s). You can now generate make proofs (safety, security and performance) or generate executable code",
+                                "Syntax analysis successful on TML designs",
+                                JOptionPane.INFORMATION_MESSAGE);
+                    }
+                } else {
+                    if (!automatic) {
+                        JOptionPane.showMessageDialog(frame,
+                                "The TML design contains several errors",
+                                "Syntax analysis failed",
+                                JOptionPane.INFORMATION_MESSAGE);
+                    }
+                }
+            }
+        } else if (tp instanceof TMLComponentDesignPanel) {
+            TMLComponentDesignPanel tmlcdp = (TMLComponentDesignPanel) tp;
+            JDialogSelectTMLComponent.validated = tmlcdp.validated;
+            JDialogSelectTMLComponent.ignored = tmlcdp.ignored;
+            Vector<TGComponent> tmlComponentsToValidate = new Vector<TGComponent>();
+            JDialogSelectTMLComponent jdstmlc = new JDialogSelectTMLComponent(frame, tmlComponentsToValidate, tmlcdp.tmlctdp.getComponentList(), "Choosing TML components to validate");
+            if (!automatic) {
+                GraphicLib.centerOnParent(jdstmlc);
+                jdstmlc.setVisible(true); // Blocked until dialog has been closed
+            } else {
+                jdstmlc.closeDialog();
+            }
+            if (tmlComponentsToValidate.size() > 0) {
+                tmlcdp.validated = JDialogSelectTMLComponent.validated;
+                tmlcdp.ignored = JDialogSelectTMLComponent.ignored;
+                b = gtm.translateTMLComponentDesign(tmlComponentsToValidate, tmlcdp, jdstmlc.getOptimize());
+                expandToWarnings();
+                expandToErrors();
+                if (b) {
+                    //setMode(MainGUI.MODEL_OK);
+                    setMode(MainGUI.GEN_SYSTEMC_OK);
+                    setMode(MainGUI.MODEL_OK);
+                    ret = true;
+                    if (!automatic) {
+                        JOptionPane.showMessageDialog(frame,
+                                "0 error, " + getCheckingWarnings().size() + " warning(s). You can now generate make proofs (safety, security and performance) or generate executable code",
+                                "Syntax analysis successful on TML designs",
+                                JOptionPane.INFORMATION_MESSAGE);
+                    }
+                } else {
+                    if (!automatic) {
+                        JOptionPane.showMessageDialog(frame,
+                                "The TML design contains several errors",
+                                "Syntax analysis failed",
+                                JOptionPane.INFORMATION_MESSAGE);
+                    }
+                }
+            }
+        }/* else if (tp instanceof SystemCAMSPanel) { //Ajout CD
+
+            SystemCAMSPanel camsp = (SystemCAMSPanel) tp;
+            JDialogSelectSystemCAMSBlock.validated = camsp.validated;
+            JDialogSelectSystemCAMSBlock.ignored = camsp.ignored;
+            Vector<TGComponent> camsBlocksToValidate = new Vector<TGComponent>();
+            JDialogSelectSystemCAMSBlock jdsscb = new JDialogSelectSystemCAMSBlock(frame, camsBlocksToValidate, camsp.camsbdp.getComponentList(), "Block Parameter");
+            if (!automatic) {
+                GraphicLib.centerOnParent(jdsscb);
+                jdsscb.setVisible(true);
+            } else {
+                jdsscb.closeDialog();
+            }
+
+            if (camsBlocksToValidate.size() > 0) {
+                camsp.validated = JDialogSelectSystemCAMSBlock.validated;
+                camsp.ignored = JDialogSelectSystemCAMSBlock.ignored;
+                expandToWarnings();
+                expandToErrors();
+                if (b) {
+                    setMode(MainGUI.GEN_SYSTEMC_OK);
+                    setMode(MainGUI.MODEL_OK);
+                    ret = true;
+                    if (!automatic) {
+                        JOptionPane.showMessageDialog(frame,
+                                "0 error, " + getCheckingWarnings().size() + " warning(s). You can now perform verifications (safety, security, performance) or generate executable code",
+                                "Syntax analysis successful on SystemC-AMS",
+                                JOptionPane.INFORMATION_MESSAGE);
+                    }
+                } else {
+                    if (!automatic) {
+                        JOptionPane.showMessageDialog(frame,
+                                "The SystemC-AMS contains several errors",
+                                "Syntax analysis failed",
+                                JOptionPane.INFORMATION_MESSAGE);
+                    }
+                }
+            }
+
+        }*/else if (tp instanceof TMLArchiPanel) {
+            tmlap = (TMLArchiPanel) tp;
+            JDialogSelectTMLNodes.validated = tmlap.validated;
+            JDialogSelectTMLNodes.ignored = tmlap.ignored;
+            Vector<TGComponent> tmlNodesToValidate = new Vector<TGComponent>();
+            JDialogSelectTMLNodes jdstmln = new JDialogSelectTMLNodes(frame, tmlNodesToValidate, tmlap.tmlap.getComponentList(), "Choosing Nodes to validate", tmlap.tmlap.getMasterClockFrequency());
+            if (!automatic) {
+                GraphicLib.centerOnParent(jdstmln);
+                jdstmln.setVisible(true); // Blocked until dialog has been closed
+            } else {
+                jdstmln.closeDialog();
+            }
+            tmlap.tmlap.setMasterClockFrequency(jdstmln.getClock());
+
+            if (tmlNodesToValidate.size() > 0) {
+                tmlap.validated = JDialogSelectTMLNodes.validated;
+                tmlap.ignored = JDialogSelectTMLNodes.ignored;
+                //TraceManager.addDev("Ready to generate TML mapping!");
+                b = gtm.checkSyntaxTMLMapping(tmlNodesToValidate, tmlap, jdstmln.getOptimize());
+                expandToWarnings();
+                expandToErrors();
+                if (b) {
+                    //setMode(MainGUI.MODEL_OK);
+                    setMode(MainGUI.GEN_SYSTEMC_OK);
+                    setMode(MainGUI.MODEL_OK);
+                    ret = true;
+                    if (!automatic) {
+                        JOptionPane.showMessageDialog(frame,
+                                "0 error, " + getCheckingWarnings().size() + " warning(s). You can now perform verifications (safety, security, performance) or generate executable code",
+                                "Syntax analysis successful on TML mapping",
+                                JOptionPane.INFORMATION_MESSAGE);
+                    }
+                } else {
+                    if (!automatic) {
+                        JOptionPane.showMessageDialog(frame,
+                                "The TML mapping contains several errors",
+                                "Syntax analysis failed",
+                                JOptionPane.INFORMATION_MESSAGE);
+                    }
+                }
+            }
+        } else if (tp instanceof TMLCommunicationPatternPanel) {
+            TMLCommunicationPatternPanel tmlcpp = (TMLCommunicationPatternPanel) tp;
+            JDialogSelectCPDiagrams.validated = tmlcpp.validated;
+            JDialogSelectCPDiagrams.ignored = tmlcpp.ignored;
+            Vector<TGComponent> tmlDiagramsToValidate = new Vector<TGComponent>();
+            JDialogSelectCPDiagrams jdscpd = new JDialogSelectCPDiagrams(frame, tmlDiagramsToValidate, tmlcpp.tmlcpp.getComponentList(),
+                    "Choosing Diagrams to validate");
+            if (!automatic) {
+                GraphicLib.centerOnParent(jdscpd);
+                jdscpd.setVisible(true); // Blocked until dialog has been closed
+            } else {
+                jdscpd.closeDialog();
+            }
+            if (tmlDiagramsToValidate.size() > 0) {
+                tmlcpp.validated = JDialogSelectCPDiagrams.validated;
+                tmlcpp.ignored = JDialogSelectCPDiagrams.ignored;
+                TraceManager.addDev("Ready to generate TML code for Communication Patterns!");
+                b = gtm.checkSyntaxTMLCP(tmlDiagramsToValidate, tmlcpp, jdscpd.getOptimize());    //Fills a data structure
+                //translateTMLComponentDesign
+                //and should say if it is correct or contains error in the return variable b
+                expandToWarnings();
+                expandToErrors();
+                if (b) {
+                    //setMode(MainGUI.MODEL_OK);
+                    setMode(MainGUI.GEN_SYSTEMC_OK);
+                    setMode(MainGUI.MODEL_OK);
+                    ret = true;
+                    if (!automatic) {
+                        JOptionPane.showMessageDialog(frame, "0 error, " + getCheckingWarnings().size() +
+                                        " warning(s). You can now perform verifications (safety, security, performance) or generate executable code",
+                                "Syntax analysis successful on TML mapping",
+                                JOptionPane.INFORMATION_MESSAGE);
+                    }
+                } else {
+                    if (!automatic) {
+                        JOptionPane.showMessageDialog(frame, "The Communication Patterns design contains several errors", "Syntax analysis failed",
+                                JOptionPane.INFORMATION_MESSAGE);
+                    }
+                }
+            }
+        } else if (tp instanceof RequirementPanel) {
+            TDiagramPanel tdp = getCurrentTDiagramPanel();
+            if (!(tdp instanceof RequirementDiagramPanel)) {
+                if (tdp instanceof EBRDDPanel) {
+
+                    b = gtm.makeEBRDD((EBRDDPanel) tdp);
+                    if (b) {
+                        JOptionPane.showMessageDialog(frame,
+                                "0 error, " + getCheckingWarnings().size() + " warning(s).",
+                                "Syntax analysis successful on EBRDD",
+                                JOptionPane.INFORMATION_MESSAGE);
+                    } else {
+                        JOptionPane.showMessageDialog(frame,
+                                "The EBRDD contains several errors",
+                                "Syntax analysis failed",
+                                JOptionPane.INFORMATION_MESSAGE);
+                    }
+                } else {
+                    return ret;
+                }
+                //TraceManager.addDev("No syntax checking for EBRDD: not yet implemented");
+            } else {
+                RequirementDiagramPanel rdp = (RequirementDiagramPanel) tdp;
+                JDialogSelectRequirements.validated = rdp.validated;
+                JDialogSelectRequirements.ignored = rdp.ignored;
+                Vector<Requirement> reqsToValidate = new Vector<Requirement>();
+                JDialogSelectRequirements jdsreq = new JDialogSelectRequirements(frame, reqsToValidate, rdp.getComponentList(), "Choosing requirements to verify");
+
+                if (!automatic) {
+                    GraphicLib.centerOnParent(jdsreq);
+                    jdsreq.setVisible(true); // Blocked until dialog has been closed
+                }
+
+                if (reqsToValidate.size() > 0) {
+                    rdp.validated = JDialogSelectRequirements.validated;
+                    rdp.ignored = JDialogSelectRequirements.ignored;
+                    b = gtm.generateTMsForRequirementAnalysis(reqsToValidate, rdp);
+                    expandToWarnings();
+                    expandToErrors();
+                    if (b) {
+                        //setMode(MainGUI.GEN_SYSTEMC_OK);
+                        setMode(MainGUI.REQ_OK);
+                        ret = true;
+                        if (!automatic) {
+                            JOptionPane.showMessageDialog(frame,
+                                    "0 error, " + getCheckingWarnings().size() + " warning(s). You can now verify requirements' satisfiability",
+                                    "Syntax analysis successful on requirements",
+                                    JOptionPane.INFORMATION_MESSAGE);
+                        }
+
+                    } else {
+                        if (!automatic) {
+                            JOptionPane.showMessageDialog(frame,
+                                    "The requirement diagram contains several errors",
+                                    "Syntax analysis failed",
+                                    JOptionPane.INFORMATION_MESSAGE);
+                        }
+                    }
+                }
+            }
+        } else if (tp instanceof ProactiveDesignPanel) {
+            // TraceManager.addDev("!!!!!!!!!!!!1");
+            //newTurtleModeling();
+            b = gtm.translateProactiveDesign((ProactiveDesignPanel) tp);
+            expandToWarnings();
+            expandToErrors();
+            if (b) {
+                //setMode(MainGUI.MODEL_OK);
+                //setMode(MainGUI.GEN_SYSTEMC_OK);
+                setMode(MainGUI.MODEL_OK);
+                ret = true;
+                if (!automatic) {
+                    JOptionPane.showMessageDialog(frame,
+                            "0 error, " + getCheckingWarnings().size() + " warning(s). You can now generate a LOTOS,specification",
+                            "Syntax analysis successful on Proactive design",
+                            JOptionPane.INFORMATION_MESSAGE);
+                }
+
+            } else {
+                if (!automatic) {
+                    JOptionPane.showMessageDialog(frame,
+                            "The Proactive design contains several errors",
+                            "Syntax analysis failed",
+                            JOptionPane.INFORMATION_MESSAGE);
+                }
+
+            }
+        } else if (tp instanceof TURTLEOSDesignPanel) {
+            TraceManager.addDev("TURTLEOS Design Panel");
+            //TURTLEOSDesignPanel tosdp = (TURTLEOSDesignPanel) tp;
+            b = gtm.translateTURTLEOSDesign((TURTLEOSDesignPanel) tp);
+            expandToWarnings();
+            expandToErrors();
+            if (b) {
+                setMode(MainGUI.MODEL_OK);
+                ret = true;
+                if (!automatic) {
+                    JOptionPane.showMessageDialog(frame,
+                            "0 error, " + getCheckingWarnings().size() + " warning(s). You can now generate a corresponding formal specification or executable code (Java)",
+                            "Syntax analysis successful on deployment diagrams",
+                            JOptionPane.INFORMATION_MESSAGE);
+                }
+            } else {
+                if (!automatic) {
+                    JOptionPane.showMessageDialog(frame,
+                            "The TURTLE deployment contains several errors",
+                            "Syntax analysis failed",
+                            JOptionPane.INFORMATION_MESSAGE);
+                }
+            }
+        }
+        //dtree.toBeUpdated();
+        dtree.forceUpdate();
+        return ret;
+    }
+
+    public LinkedList<TAttribute> getAllAttributes() {
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        String name = getCurrentTDiagramPanel().getName();
+
+        return this.getAllAttributes(tp, name);
+    }
+
+    public LinkedList<TAttribute> getAllAttributes(TURTLEPanel tp, String name) {
+        if (tp == null) {
+            return null;
+        }
+
+        if (!(tp instanceof AvatarDesignPanel)) {
+            return null;
+        }
+        AvatarDesignPanel adp = (AvatarDesignPanel) tp;
+
+        return adp.getAllAttributes(name);
+    }
+
+
+    public LinkedList<AvatarMethod> getAllMethods() {
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        if (tp == null) {
+            return null;
+        }
+
+        if (!(tp instanceof AvatarDesignPanel)) {
+            return null;
+        }
+        AvatarDesignPanel adp = (AvatarDesignPanel) tp;
+
+        String name = getCurrentTDiagramPanel().getName();
+
+        return adp.getAllMethods(name);
+    }
+
+    public LinkedList<AvatarSignal> getAllSignals() {
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        String name = getCurrentTDiagramPanel().getName();
+        return this.getAllSignals(tp, name);
+    }
+
+    public LinkedList<AvatarSignal> getAllSignals(TURTLEPanel tp, String name) {
+        if (tp == null) {
+            return null;
+        }
+
+        if (!(tp instanceof AvatarDesignPanel)) {
+            return null;
+        }
+        AvatarDesignPanel adp = (AvatarDesignPanel) tp;
+
+        return adp.getAllSignals(name);
+    }
+
+
+    public List<AvatarBDLibraryFunction> getAllLibraryFunctions() {
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        return this.getAllLibraryFunctions(tp);
+    }
+
+    public List<AvatarBDLibraryFunction> getAllLibraryFunctions(TURTLEPanel tp) {
+        String name = getCurrentTDiagramPanel().getName();
+        return this.getAllLibraryFunctions(tp, name);
+    }
+
+    /* Note that this is here for historical purpose : Now, any block can access library functions of any
+     * other block.
+     */
+    public List<AvatarBDLibraryFunction> getAllLibraryFunctions(TURTLEPanel tp, String name) {
+        if (tp == null) {
+            return null;
+        }
+
+        if (!(tp instanceof AvatarDesignPanel)) {
+            return null;
+        }
+        AvatarDesignPanel adp = (AvatarDesignPanel) tp;
+
+        return adp.getAllLibraryFunctions(name);
+    }
+
+    public String[] getAllOutEvents() {
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        if (tp == null) {
+            return null;
+        }
+
+        if (!(tp instanceof TMLComponentDesignPanel)) {
+            return null;
+        }
+        TMLComponentDesignPanel tmlcomp = (TMLComponentDesignPanel) tp;
+
+        String name = getCurrentTDiagramPanel().getName();
+
+        return tmlcomp.getAllOutEvents(name);
+    }
+
+    public ArrayList<TGComponent> getAllLatencyChecks() {
+        TURTLEPanel tp;
+        ArrayList<TGComponent> list = new ArrayList<TGComponent>();
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            tp.getAllLatencyChecks(list);
+        }
+        return list;
+    }
+
+    public String[] getAllInEvents() {
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        if (tp == null) {
+            return null;
+        }
+        if (!(tp instanceof TMLComponentDesignPanel)) {
+            return null;
+        }
+        TMLComponentDesignPanel tmlcomp = (TMLComponentDesignPanel) tp;
+        String name = getCurrentTDiagramPanel().getName();
+        return tmlcomp.getAllInEvents(name);
+    }
+
+    public String[] getAllOutChannels() {   //this routine can be called only from a TMLComponentDesignPanel
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        if (tp == null) {
+            return null;
+        }
+        if (!(tp instanceof TMLComponentDesignPanel)) {
+            return null;
+        }
+        TMLComponentDesignPanel tmlcomp = (TMLComponentDesignPanel) tp;
+        String name = getCurrentTDiagramPanel().getName();
+        System.out.println("Name " + name);
+        return tmlcomp.getAllOutChannels(name);
+    }
+
+
+    public String[] getAllCompOutChannels() {   //this routine can be called only from a TMLComponentDesignPanel
+        //List<String> chans = new ArrayList<String>();
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        if (tp == null) {
+            return null;
+        }
+        if (!(tp instanceof TMLComponentDesignPanel)) {
+            return null;
+        }
+        TMLComponentDesignPanel tmlcomp = (TMLComponentDesignPanel) tp;
+        return tmlcomp.getCompOutChannels();
+    }
+
+    public String[] getAllCompInChannels() {   //this routine can be called only from a TMLComponentDesignPanel
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        if (tp == null) {
+            return null;
+        }
+        if (!(tp instanceof TMLComponentDesignPanel)) {
+            return null;
+        }
+        TMLComponentDesignPanel tmlcomp = (TMLComponentDesignPanel) tp;
+        return tmlcomp.getCompInChannels();
+    }
+
+
+    public String[] getAllInChannels() {    //this routine can be called only from a TMLComponentDesignPanel
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        if (tp == null) {
+            return null;
+        }
+        if (!(tp instanceof TMLComponentDesignPanel)) {
+            return null;
+        }
+        TMLComponentDesignPanel tmlcomp = (TMLComponentDesignPanel) tp;
+        String name = getCurrentTDiagramPanel().getName();
+        return tmlcomp.getAllInChannels(name);
+    }
+
+    public Vector<String> getAllCryptoConfig() {
+        TURTLEPanel tp;
+        Vector<String> list = new Vector<String>();
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof TMLComponentDesignPanel) {
+                for (String s : ((TMLComponentDesignPanel) tp).getAllCryptoConfig()) {
+                    list.add(mainTabbedPane.getTitleAt(i) + "::" + s);
+                }
+            }
+        }
+        return list;
+    }
+
+    public String[] getCurrentCryptoConfig() {
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        if (tp == null) {
+            return null;
+        }
+        if (!(tp instanceof TMLComponentDesignPanel)) {
+            return null;
+        }
+        TMLComponentDesignPanel tmlcomp = (TMLComponentDesignPanel) tp;
+        List<String> strlist = tmlcomp.getAllCryptoConfig();
+        String[] strarray = new String[strlist.size()];
+        strlist.toArray(strarray);
+        return strarray;
+    }
+
+    public String[] getAllNonce() {
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        if (tp == null) {
+            return null;
+        }
+        if (!(tp instanceof TMLComponentDesignPanel)) {
+            return null;
+        }
+        TMLComponentDesignPanel tmlcomp = (TMLComponentDesignPanel) tp;
+        List<String> strlist = tmlcomp.getAllNonce();
+        String[] strarray = new String[strlist.size()];
+        strlist.toArray(strarray);
+        return strarray;
+    }
+
+    public ArrayList<String> getAllKeys() {
+        TURTLEPanel tp;
+        ArrayList<String> list = new ArrayList<String>();
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof TMLComponentDesignPanel) {
+                for (String s : ((TMLComponentDesignPanel) tp).getAllKeys()) {
+                    list.add(s);
+                }
+            }
+        }
+        return list;
+    }
+
+    public ArrayList<TGComponent> getAllAttacks() {
+        TURTLEPanel tp;
+        ArrayList<TGComponent> list = new ArrayList<TGComponent>();
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof AttackTreePanel) {
+                for (TGComponent s : ((AttackTreePanel) tp).getAllAttacks()) {
+                    list.add(s);
+                }
+            }
+        }
+        return list;
+
+    }
+
+    public ArrayList<TGComponent> getAllFaults() {
+        TURTLEPanel tp;
+        ArrayList<TGComponent> list = new ArrayList<TGComponent>();
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof FaultTreePanel) {
+                for (TGComponent s : ((FaultTreePanel) tp).getAllFaults()) {
+                    list.add(s);
+                }
+            }
+        }
+        return list;
+
+    }
+
+    public ArrayList<TGComponent> getAllRequirements() {
+        TURTLEPanel tp;
+        ArrayList<TGComponent> list = new ArrayList<TGComponent>();
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof AvatarRequirementPanel) {
+                for (TGComponent s : ((AvatarRequirementPanel) tp).getAllRequirements()) {
+                    list.add(s);
+                }
+            }
+        }
+        return list;
+
+    }
+
+    public String[] getAllOutRequests() {
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        if (tp == null) {
+            return null;
+        }
+        if (!(tp instanceof TMLComponentDesignPanel)) {
+            return null;
+        }
+        TMLComponentDesignPanel tmlcomp = (TMLComponentDesignPanel) tp;
+        String name = getCurrentTDiagramPanel().getName();
+        return tmlcomp.getAllOutRequests(name);
+    }
+
+    public LinkedList<String> getAllTimers() {
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        if (tp == null) {
+            return null;
+        }
+
+        if (!(tp instanceof AvatarDesignPanel)) {
+            return null;
+        }
+        AvatarDesignPanel adp = (AvatarDesignPanel) tp;
+
+        String name = getCurrentTDiagramPanel().getName();
+
+        return adp.getAllTimers(name);
+    }
+
+    public List<CheckingError> getCheckingErrors() {
+        return gtm.getCheckingErrors();
+    }
+
+    public List<CheckingError> getCheckingWarnings() {
+        return gtm.getCheckingWarnings();
+    }
+
+    public void modelBacktracingProVerif(ProVerifOutputAnalyzer pvoa) {
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        if (tp == null) {
+            return;
+        }
+
+        if (tp instanceof AvatarDesignPanel) {
+            AvatarDesignPanel adp = (AvatarDesignPanel) tp;
+            adp.modelBacktracingProVerif(pvoa);
+            getCurrentTDiagramPanel().repaint();
+        } else if (tp instanceof TMLArchiPanel) {
+            /*  for (int i=0; i<tabs.size(); i++){
+                tp = (TURTLEPanel)(tabs.elementAt(i));
+                if (tp instanceof TMLComponentDesignPanel) {
+                ((TMLComponentDesignPanel)tp).modelBacktracingProVerif(pvoa);
+                }
+                }*/
+            gtm.getTMLMapping().getTMLModeling().clearBacktracing();
+            gtm.getTMLMapping().getTMLModeling().backtrace(pvoa, getTabName(tp));
+            gtm.getTML2Avatar().backtraceReachability(pvoa.getReachabilityResults());
+            gtm.getTMLMapping().getTMLModeling().backtraceAuthenticity(pvoa.getAuthenticityResults(), getTabName(tp));
+        } else if (tp instanceof TMLComponentDesignPanel) {
+            gtm.getTMLMapping().getTMLModeling().clearBacktracing();
+            gtm.getTMLMapping().getTMLModeling().backtrace(pvoa, "Default Mapping");
+            gtm.getTML2Avatar().backtraceReachability(pvoa.getReachabilityResults());
+            gtm.getTMLMapping().getTMLModeling().backtraceAuthenticity(pvoa.getAuthenticityResults(), "Default Mapping");
+        }
+        return;
+    }
+
+    public void modelBacktracingUPPAAL(Map<String, Integer> verifMap) {
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        if (tp == null) {
+            return;
+        }
+
+        if (!(tp instanceof AvatarDesignPanel)) {
+            return;
+        }
+
+        AvatarDesignPanel adp = (AvatarDesignPanel) tp;
+        adp.modelBacktracingUppaal(verifMap);
+        getCurrentTDiagramPanel().repaint();
+    }
+
+    public void generateRTLOTOS() {
+        generateRTLOTOS(false);
+    }
+
+
+    public boolean generateRTLOTOS(boolean automatic) {
+        int ret = 0;
+        if (gtm.getTURTLEModelingState() > 0) {
+            if ((ret = generateTURTLEModelingFromState(gtm.getTURTLEModelingState(), automatic, RT_LOTOS)) == -1) {
+                return false;
+            }
+        }
+
+        gtm.reinitSIM();
+        gtm.reinitDTA();
+        gtm.reinitRG();
+        gtm.reinitRGAUT();
+        gtm.reinitRGAUTPROJDOT();
+        if (ret == 0) {
+            gtm.generateRTLOTOS(lotosfile);
+        }
+        if (!automatic) {
+            JOptionPane.showMessageDialog(frame,
+                    "RT-LOTOS specification generated",
+                    "RT-LOTOS specification",
+                    JOptionPane.INFORMATION_MESSAGE);
+        }
+        dtree.toBeUpdated();
+        return true;
+    }
+
+    public void generateLOTOS() {
+        generateLOTOS(false);
+    }
+
+
+    public boolean generateLOTOS(boolean automatic) {
+        int ret = 0;
+        if (gtm.getTURTLEModelingState() > 0) {
+            ret = generateTURTLEModelingFromState(gtm.getTURTLEModelingState(), automatic, LOTOS);
+            if (ret == -1) {
+                dtree.toBeUpdated();
+                TraceManager.addDev("Generate from state failed");
+                return false;
+            }
+            /*if (!automatic && (gtm.getTURTLEModelingState() == 1)) {
+              return true;
+              }*/
+        }
+
+        //TraceManager.addDev("generate LOTOS");
+        if (ret == 0) {
+            gtm.generateFullLOTOS(lotosfile);
+            //TraceManager.addDev("LOTOS generated");
+            if (!automatic) {
+                JOptionPane.showMessageDialog(frame,
+                        "LOTOS specification generated (" + getCheckingWarnings().size() + " warning(s))",
+                        "LOTOS specification",
+                        JOptionPane.INFORMATION_MESSAGE);
+            }
+        }
+        setMode(MainGUI.RTLOTOS_OK);
+        dtree.toBeUpdated();
+        return true;
+    }
+
+    public void generateFullLOTOS() {
+        gtm.generateFullLOTOS(lotosfile);
+        dtree.toBeUpdated();
+    }
+
+    // -1 : error
+    // 0: ok
+    // 1: ok, code already generated
+    public int generateTURTLEModelingFromState(int state, boolean automatic, int generator) {
+        if (state == 1) {
+            TraceManager.addDev("Generating from state 1");
+            if (generateTIFFromMapping(automatic, generator)) {
+                return 1;
+            }
+            return -1;
+        }
+        if (state == 2) {
+            TraceManager.addDev("Generating from state 2");
+            if (generateTIFFromTMLModeling(automatic, generator)) {
+                return 0;
+            }
+            return -1;
+        }
+        if (state == 3) {
+            TraceManager.addDev("Generating from state 3 (Avatar)");
+            if (generateTIFFromAvatarSpecification(automatic, generator)) {
+                return 0;
+            }
+            return -1;
+        }
+        return -1;
+    }
+
+    public boolean generateTIFFromAvatarSpecification(boolean automatic, int generator) {
+        boolean b = gtm.translateAvatarSpecificationToTIF();
+        if (b) {
+            setMode(MainGUI.MODEL_OK);
+            return true;
+        }
+        return false;
+    }
+
+    public boolean generateTIFFromMapping(boolean automatic, int generator) {
+        boolean b;
+
+        // Scheduling options
+        JDialogScheduling jds = new JDialogScheduling(frame, this, "Mapping options", generator);
+        if (!automatic) {
+            GraphicLib.centerOnParent(jds);
+            jds.setVisible(true); // Blocked until dialog has been closed
+        } else {
+            jds.closeDialog();
+            b = gtm.translateTMLMapping(jds.getSample(), jds.getChannel(), jds.getEvent(), jds.getRequest(), jds.getExec(), jds.getBusTransfer(), jds.getScheduling(), jds.getTaskState(), jds.getChannelState(), jds.getBranching(), jds.getTerminateCPU(), jds.getTerminateCPUs(), jds.getClocked(), jds.getTickIntervalValue(), jds.getEndClocked(), jds.getCountTick(), jds.getMaxCountTick(), jds.getMaxCountTickValue(), jds.getRandomTask());
+            if (b) {
+                setMode(MainGUI.GEN_SYSTEMC_OK);
+                setMode(MainGUI.MODEL_OK);
+                return true;
+            }
+            return false;
+        }
+
+        if (!jds.isCancelled()) {
+            b = jds.hasError();
+            //gtm.translateTMLMapping(jds.getChannel(), jds.getEvent(), jds.getRequest(), jds.getExec(), jds.getBusTransfer(), jds.getScheduling(), jds.getTaskState(), jds.getChannelState(), jds.getBranching(), jds.getTerminateCPU(), jds.getTerminateCPUs(), jds.getClocked(), jds.getTickIntervalValue(), jds.getEndClocked(), jds.getCountTick(), jds.getMaxCountTick(), jds.getMaxCountTickValue(), jds.getRandomTask());
+            if (!b) {
+                //setMode(MainGUI.MODEL_OK);
+                setMode(MainGUI.GEN_SYSTEMC_OK);
+                setMode(MainGUI.MODEL_OK);
+                return true;
+                /*if (!automatic) {
+                  JOptionPane.showMessageDialog(frame,
+                  "0 error, " + getCheckingWarnings().size() + " warning(s). Formal specification can be generated",
+                  "Successful translation from the TML mapping to a formal specification",
+                  JOptionPane.INFORMATION_MESSAGE);
+                  }*/
+            } else {
+                /*if (!automatic) {
+                  JOptionPane.showMessageDialog(frame,
+                  "Formal specification generation failed: the TML mapping contains several errors",
+                  "Syntax analysis failed",
+                  JOptionPane.INFORMATION_MESSAGE);
+                  }*/
+                return false;
+            }
+        }
+
+        return false;
+    }
+
+    public boolean generateTIFFromTMLModeling(boolean automatic, int generator) {
+        return gtm.translateTMLModeling();
+    }
+
+    public void generateAUT() {
+        JDialogGenAUT jdgaut = new JDialogGenAUT(frame, this, "Generation of automata", ConfigurationTTool.BcgioPath, ConfigurationTTool.AldebaranHost, SpecConfigTTool.TGraphPath);
+        //  jdgaut.setSize(450, 600);
+        GraphicLib.centerOnParent(jdgaut, 450, 600);
+        jdgaut.setVisible(true);
+
+        //Update menu
+        Vector<String> v = jdgaut.getFiles();
+        JMenu menu = jmenubarturtle.getJMenuGraph();
+        menu.removeAll();
+        String s;
+        for (int i = 0; i < v.size(); i++) {
+            s = v.elementAt(i);
+            jmenubarturtle.addMenuItem(menu, s, this);
+        }
+
+    }
+
+    public void generateAUTS() {
+        JDialogGenAUTS jdgauts = new JDialogGenAUTS(frame, this, "Generation of automata via LOTOS", gtm.getPathCaesar(),
+                GTURTLEModeling.getPathBcgio(),
+                REMOTE_RTL_LOTOS_FILE,
+                GTURTLEModeling.getCaesarHost(), SpecConfigTTool.TGraphPath);
+        //  jdgauts.setSize(450, 600);
+        GraphicLib.centerOnParent(jdgauts, 450, 600);
+        jdgauts.setVisible(true);
+
+        //Update menu
+        /*Vector v = jdgauts.getFiles();
+          JMenu menu = jmenubarturtle.getJMenuGraph();
+          menu.removeAll();
+          String s;
+          for(int i=0; i<v.size(); i++) {
+          s = (String)(v.elementAt(i));
+          jmenubarturtle.addMenuItem(menu, s, this);
+          }*/
+
+    }
+
+    public void avatarSimulation() {
+        TraceManager.addDev("Avatar simulation");
+        jfais = new JFrameAvatarInteractiveSimulation( /*frame,*/ this, "Interactive simulation", gtm.getAvatarSpecification());
+        jfais.setIconImage(IconManager.img9);
+        // jfais.setSize(900, 600);
+        GraphicLib.centerOnParent(jfais, 900, 600);
+        jfais.setVisible(true);
+    }
+
+    public void avatarUPPAALVerification() {
+        TraceManager.addDev("Avatar uppaal fv");
+        boolean result = gtm.generateUPPAALFromAVATAR(SpecConfigTTool.UPPAALCodeDirectory);
+        if (result) {
+            formalValidation(true);
+        } else {
+            JOptionPane.showMessageDialog(frame,
+                    "" + getCheckingErrors().size() + " errors, " + getCheckingWarnings().size() + " warning(s). UPPAAL specification could NOT be generated",
+                    "Translation to UPPAAL failed",
+                    JOptionPane.INFORMATION_MESSAGE);
+            return;
+        }
+    }
+
+    public void avatarProVerifVerification() {
+        boolean limit = true;
+        TraceManager.addDev("Avatar proverif fv");
+        TURTLEPanel tp = this.getCurrentTURTLEPanel();
+        AvatarDesignPanel adp = null;
+        if (tp instanceof AvatarDesignPanel) {
+            adp = (AvatarDesignPanel) tp;
+            limit = false;
+        }
+        JDialogProverifVerification jgen = new JDialogProverifVerification(frame, this, "Security verification with ProVerif", ConfigurationTTool.ProVerifVerifierHost, SpecConfigTTool.ProVerifCodeDirectory, ConfigurationTTool.ProVerifVerifierPath, adp, limit, gtm.getCPUTaskMap());
+        // jgen.setSize(500, 450);
+        GraphicLib.centerOnParent(jgen, 600, 800);
+        jgen.setVisible(true);
+        dtree.toBeUpdated();
+    }
+
+    public void dse() {
+        TraceManager.addDev("Design space exploration");
+        JDialogDSE jdse = new JDialogDSE(frame, this, "Design Space Exploration", SpecConfigTTool.SystemCCodeDirectory, SpecConfigTTool.TMLCodeDirectory);
+        //   jdse.setSize(600,800);
+        GraphicLib.centerOnParent(jdse, 700, 800);
+        jdse.setVisible(true);
+        dtree.toBeUpdated();
+    }
+
+    public void avatarStaticAnalysis() {
+        TraceManager.addDev("Avatar static analysis invariants");
+        JDialogInvariantAnalysis jgen = new JDialogInvariantAnalysis(frame, this, "Static analysis: invariants computation");
+        //   jgen.setSize(500, 450);
+        GraphicLib.centerOnParent(jgen, 500, 450);
+        jgen.setVisible(true);
+        dtree.toBeUpdated();
+    }
+
+    public void avatarExecutableCodeGeneration() {
+        TraceManager.addDev("Avatar code generation");
+        JDialogAvatarExecutableCodeGeneration jgen = new JDialogAvatarExecutableCodeGeneration(frame, this, "Executable Code generation, compilation and execution", ConfigurationTTool.AVATARExecutableCodeHost, SpecConfigTTool.AVATARExecutableCodeDirectory, SpecConfigTTool.AVATARExecutableCodeCompileCommand, SpecConfigTTool.AVATARExecutableCodeExecuteCommand, ConfigurationTTool.AVATARExecutableSoclibCodeCompileCommand, ConfigurationTTool.AVATARExecutableSoclibCodeExecuteCommand, ConfigurationTTool.AVATARExecutableSoclibTraceFile);
+        //   jgen.setSize(500, 450);
+        GraphicLib.centerOnParent(jgen, 700, 600);
+        jgen.setVisible(true);
+        dtree.toBeUpdated();
+    }
+
+    // DG
+    public void avatarddExecutableCodeGeneration() {
+        TraceManager.addDev("Avatar code generation");
+        JDialogAvatarddExecutableCodeGeneration jgen = new JDialogAvatarddExecutableCodeGeneration(frame, this, "Executable Code generation, compilation and execution",
+                ConfigurationTTool.AVATARExecutableCodeHost,
+                ConfigurationTTool.AVATARMPSoCCodeDirectory,
+                ConfigurationTTool.AVATARMPSoCCompileCommand,
+                ConfigurationTTool.AVATARExecutableSoclibCodeExecuteCommand);
+        // jgen.setSize(500, 450);
+        GraphicLib.centerOnParent(jgen, 500, 450);
+        jgen.setVisible(true);
+        dtree.toBeUpdated();
+    }
+
+    // ---------------------------------------------------------------------
+
+    public void generateUPPAAL() {
+        generateUPPAAL(true);
+    }
+
+    public void generateUPPAAL(boolean showWindow) {
+        TraceManager.addDev("Generate UPPAAL! showwindow=" + showWindow);
+        //gtm.mergeChoices(true);
+        if (gtm.getTURTLEModelingState() > 0) {
+            //TraceManager.addDev("4173");
+            if (gtm.getTURTLEModelingState() == 3) {
+                //AVATAR
+                boolean result = gtm.generateUPPAALFromAVATAR(SpecConfigTTool.UPPAALCodeDirectory);
+                TraceManager.addDev("4177");
+                if (showWindow) {
+                    TraceManager.addDev("4178");
+                    if (result) {
+                        JOptionPane.showMessageDialog(frame,
+                                "0 error, " + getCheckingWarnings().size() + " warning(s). UPPAAL specification generated",
+                                "Successful translation to UPPAAL",
+                                JOptionPane.INFORMATION_MESSAGE);
+                    } else {
+                        JOptionPane.showMessageDialog(frame,
+                                "" + getCheckingErrors().size() + " errors, " + getCheckingWarnings().size() + " warning(s). UPPAAL specification could NOT be generated",
+                                "Translation to UPPAAL failed",
+                                JOptionPane.INFORMATION_MESSAGE);
+
+
+                    }
+                }
+                TraceManager.addDev("4196");
+                if (!result) {
+                    return;
+                }
+            } else {
+                /*if (generateTURTLEModelingFromState(gtm.getTURTLEModelingState(), false, UPPAAL) == -1) {
+                  TraceManager.addDev("4202 - UPPAAL generation failed");
+                  return;
+                  }*/
+                TraceManager.addDev("About to open the window at line 4198");
+                if (showWindow) {
+                    TURTLEPanel tp = getCurrentTURTLEPanel();
+                    boolean result = false;
+
+                    if ((tp instanceof TMLDesignPanel) || (tp instanceof TMLComponentDesignPanel)) {
+                        result = gtm.generateUPPAALFromTML(SpecConfigTTool.UPPAALCodeDirectory, false, 1024, true);
+                    }
+                    if (result != false) {
+                        formalValidation();
+                    }
+                    /*JDialogUPPAALGeneration jgen = new JDialogUPPAALGeneration(frame, this, "UPPAAL code generation", ConfigurationTTool.UPPAALCodeDirectory, JDialogUPPAALGeneration.DIPLODOCUS_MODE);
+                    //  jgen.setSize(450, 500);
+                    GraphicLib.centerOnParent(jgen, 450, 500);
+                    jgen.setVisible(true);*/
+
+                }
+                return;
+            }
+        }
+
+        TraceManager.addDev("gtm.getTURTLEModelingState() <= 0)");
+        //TraceManager.addDev("After UPPAAL");
+        if (showWindow) {
+            JDialogUPPAALGeneration jgen = new JDialogUPPAALGeneration(frame, this, "UPPAAL code generation", SpecConfigTTool.UPPAALCodeDirectory, JDialogUPPAALGeneration.TURTLE_MODE);
+            //jgen.setSize(450, 600);
+            GraphicLib.centerOnParent(jgen, 450, 600);
+            jgen.setVisible(true);
+            //dtree.toBeUpdated();
+        }
+    }
+
+    public void avatarModelChecker() {
+        TraceManager.addDev("Execute avatar model checker");
+        gtm.generateAvatarFromTML(true, false);
+        if (gtm.getAvatarSpecification() == null) {
+            TraceManager.addDev("Null avatar spec");
+            return;
+        }
+        JDialogAvatarModelChecker jmc = new JDialogAvatarModelChecker(frame, this, "Avatar: Model Checking", gtm.getAvatarSpecification(), SpecConfigTTool.TGraphPath, experimentalOn);
+        // jmc.setSize(550, 600);
+        GraphicLib.centerOnParent(jmc, 550, 600);
+        jmc.setVisible(true);
+    }
+
+
+    public List<String> generateAllAUT(String path) {
+        return gtm.generateAUT(path);
+    }
+
+    public List<String> generateAllLOTOS(String path) {
+        return gtm.generateLOTOSAUT(path);
+    }
+
+    public void generateJava() {
+
+        if (gtm.getTURTLEModelingState() == 1) {
+            if (generateTURTLEModelingFromState(gtm.getTURTLEModelingState(), false, JAVA) == -1) {
+                return;
+            }
+        }
+
+        JDialogJavaGeneration jgen = new JDialogJavaGeneration(frame, this, "Java code generation and compilation", ConfigurationTTool.JavaCodeDirectory, ConfigurationTTool.JavaCompilerPath, ConfigurationTTool.TToolClassPath, ConfigurationTTool.JavaExecutePath, ConfigurationTTool.JavaHeader);
+        //  jgen.setSize(450, 600);
+        GraphicLib.centerOnParent(jgen, 450, 600);
+        jgen.setVisible(true);
+        dtree.toBeUpdated();
+    }
+
+    public void simuJava() {
+        /*TraceManager.addDev("Generate Java");
+          gtm.generateJava("");
+          JOptionPane.showMessageDialog(frame,
+          "Java code generated",
+          "Java generator",
+          JOptionPane.INFORMATION_MESSAGE);
+          dtree.toBeUpdated();*/
+
+        JDialogJavaSimulation jgen = new JDialogJavaSimulation(frame, this, "Java simulation", ConfigurationTTool.SimuJavaCodeDirectory, ConfigurationTTool.JavaCompilerPath, ConfigurationTTool.TToolSimuClassPath, ConfigurationTTool.JavaExecutePath);
+        // jgen.setSize(450, 600);
+        GraphicLib.centerOnParent(jgen, 450, 600);
+        jgen.setVisible(true);
+        dtree.toBeUpdated();
+    }
+
+    public void generateSystemC() {
+        generateSystemC(0);
+    }
+
+    // Modes are defined in JDialogSystemCGeneration "automatic modes"
+    public void generateSystemC(int _mode) {
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        if (tp instanceof AvatarDesignPanel) {
+            avatarSimulation();
+        } else if ((tp instanceof TMLDesignPanel) || (tp instanceof TMLComponentDesignPanel) || (tp instanceof TMLArchiPanel)) {
+            JDialogSystemCGeneration jgen = new JDialogSystemCGeneration(frame, this, "Simulation Code Generation and Compilation",
+                    ConfigurationTTool.SystemCHost, SpecConfigTTool.SystemCCodeDirectory, SpecConfigTTool.SystemCCodeCompileCommand,
+                    SpecConfigTTool.SystemCCodeExecuteCommand, SpecConfigTTool.SystemCCodeInteractiveExecuteCommand, SpecConfigTTool.GGraphPath, _mode);
+            //jgen.setSize(500, 750);
+            GraphicLib.centerOnParent(jgen, 700, 750);
+            jgen.setVisible(true);
+            dtree.toBeUpdated();
+
+            /*if (jgen.isInteractiveSimulationSelected() && (mode == 0)) {
+              interactiveSimulationSystemC(jgen.getPathInteractiveExecute());
+              }*/
+        }
+    }
+
+    public void interactiveSimulationSystemC() {
+        interactiveSimulationSystemC(SpecConfigTTool.SystemCCodeInteractiveExecuteCommand + " -gpath " + SpecConfigTTool.GGraphPath);
+    }
+
+    public void interactiveSimulationSystemC(String executePath) {
+        TraceManager.addDev("MainGUI / Execute path=" + executePath);
+        List<Point> points = getListOfBreakPoints();
+
+        if (gtm == null) {
+            jfis = new JFrameInteractiveSimulation(frame, this, "Interactive simulation", ConfigurationTTool.SystemCHost, executePath, null, points);
+        } else {
+            //TraceManager.addDev("toto1");
+            if (gtm.getTMLMapping() != null) {
+                jfis = new JFrameInteractiveSimulation(frame, this, "Interactive simulation", ConfigurationTTool.SystemCHost, executePath, gtm.getTMLMapping(), points);
+            } else {
+                //TraceManager.addDev("toto2");
+                if (gtm.getArtificialTMLMapping() != null) {
+                    jfis = new JFrameInteractiveSimulation(frame, this, "Interactive simulation", ConfigurationTTool.SystemCHost, executePath, gtm.getArtificialTMLMapping(), points);
+                } else {
+                    //TraceManager.addDev("toto3");
+                    jfis = new JFrameInteractiveSimulation(frame, this, "Interactive simulation", ConfigurationTTool.SystemCHost, executePath, null, points);
+                }
+            }
+        }
+
+        jfis.setIconImage(IconManager.img9);
+        //jfis.setSize(1024, 900);
+        GraphicLib.centerOnParent(jfis, 1024, 900);
+        jfis.setVisible(true);
+    }
+
+    public void addBreakPoint(int commandId) {
+        if (jfis != null) {
+            jfis.addBreakPoint(commandId);
+        }
+    }
+
+    public void removeBreakPoint(int commandId) {
+        if (jfis != null) {
+            jfis.removeBreakPoint(commandId);
+        }
+    }
+
+    // Sent by simulation interface
+    public void removeBreakpoint(Point p) {
+        if (gtm != null) {
+            gtm.removeBreakpoint(p);
+            getCurrentTDiagramPanel().repaint();
+        }
+    }
+
+    // Sent by simulation interface
+    public void addBreakpoint(Point p) {
+        if (gtm != null) {
+            gtm.addBreakpoint(p);
+            getCurrentTDiagramPanel().repaint();
+        }
+    }
+
+    public ArrayList<Point> getListOfBreakPoints() {
+        ArrayList<Point> points = new ArrayList<Point>();
+        TURTLEPanel tp;
+
+        if (tabs != null) {
+            for (int i = 0; i < tabs.size(); i++) {
+                tp = tabs.elementAt(i);
+                if (tp instanceof TMLDesignPanel) {
+                    ((TMLDesignPanel) tp).getListOfBreakPoints(points);
+                }
+                if (tp instanceof TMLComponentDesignPanel) {
+                    ((TMLComponentDesignPanel) tp).getListOfBreakPoints(points);
+                }
+            }
+        }
+        return points;
+    }
+
+
+    // Returns null if failed
+    // Otherwise the path of the generated file
+    public String generateTMLTxt() {
+        String path = ConfigurationTTool.FILEPath;
+        if (file != null) {
+            path = file.getAbsolutePath();
+        }
+        TraceManager.addDev("Generating TML code: " + file.getAbsolutePath());
+        if (gtm.generateTMLTxt(path)) {
+            TraceManager.addDev("Done TML generation");
+            return ConfigurationTTool.TMLCodeDirectory;
+        }
+
+        return null;
+
+    }
+
+    public String generateCCode() {
+
+        //        String path = ConfigurationTTool.FILEPath;
+        //        if( file != null ) {
+        //            path = file.getAbsolutePath();
+        //        }
+        JDialogCCodeGeneration jgen = new JDialogCCodeGeneration(frame, this, "Application code generation and compilation",
+                SpecConfigTTool.CCodeDirectory,
+                "make -C " + SpecConfigTTool.CCodeDirectory,
+                gtm);
+        //   jgen.setSize(500, 750);
+        GraphicLib.centerOnParent(jgen, 500, 750);
+        jgen.setVisible(true);
+        //dtree.toBeUpdated();
+        //gtm.generateCCode( path );
+        return null;
+    }
+
+    public void generateDesign() {
+        if (gtm.getTURTLEModelingState() == 1) {
+            if (generateTURTLEModelingFromState(gtm.getTURTLEModelingState(), false, DESIGN) == -1) {
+                return;
+            }
+        }
+
+        //TraceManager.addDev("Generate design");
+        gtm.generateDesign();
+    }
+
+    public void saveSIM() {
+        gtm.saveSIM(simfile);
+    }
+
+    public void saveDTA() {
+        gtm.saveDTA(dtafile);
+    }
+
+    public void saveDTADOT() {
+        gtm.saveDTADOT(dtadotfile);
+    }
+
+    public void saveRG() {
+        gtm.saveRG(rgfile);
+    }
+
+    public void saveTLSA() {
+        gtm.saveTLSA(tlsafile);
+    }
+
+    public String saveRGAut() {
+        gtm.saveRGAut(rgautfile);
+        return rgautfile.getAbsolutePath();
+    }
+
+    public String saveFC2(String data) {
+        gtm.saveInFile(fc2file, data);
+        return fc2file.getAbsolutePath();
+    }
+
+    public String saveBCG(String data) {
+        gtm.saveInFile(bcgfile, data);
+        return bcgfile.getAbsolutePath();
+    }
+
+    public void saveRGDOT() {
+        gtm.saveRGDOT(rgdotfile);
+    }
+
+    public void saveTLSADOT() {
+        gtm.saveTLSADOT(tlsadotfile);
+    }
+
+    public String saveRGAutDOT() {
+        gtm.saveRGAutDOT(rgautdotfile);
+        return rgautdotfile.getAbsolutePath();
+    }
+
+    public void saveRGAutProj() {
+        gtm.saveRGAutProj(rgautprojfile);
+    }
+
+    public void saveRGAutProjDOT() {
+        gtm.saveRGAutProjDOT(rgautprojdotfile);
+    }
+
+    public void checkCode() {
+        if (gtm.getLanguageID() == GTURTLEModeling.RT_LOTOS) {
+            JDialogTextProcess jdtp = new JDialogTextProcess(frame,
+                    "Checking RT-LOTOS specification with RTL",
+                    gtm.getPathRTL() + " __FILENAME -max-spec-t-1",
+                    REMOTE_RTL_LOTOS_FILE,
+                    gtm.getLastRTLOTOSSpecification(),
+                    gtm.getHost());
+            //jdtp.setSize(450, 600);
+            GraphicLib.centerOnParent(jdtp, 450, 600);
+            jdtp.setVisible(true);
+            dtree.toBeUpdated();
+        } else if (gtm.getLanguageID() == GTURTLEModeling.LOTOS) {
+            JDialogLOTOSAnalysis jdla = new JDialogLOTOSAnalysis(frame,
+                    this, "Checking LOTOS specification with CAESAR",
+                    gtm.getPathCaesar(),
+                    REMOTE_RTL_LOTOS_FILE,
+                    gtm.getLastRTLOTOSSpecification(),
+                    GTURTLEModeling.getCaesarHost());
+            //  jdla.setSize(450, 600);
+            GraphicLib.centerOnParent(jdla, 450, 600);
+            jdla.setVisible(true);
+            dtree.toBeUpdated();
+        }
+    }
+
+
+    public void simulation() {
+        if (gtm.getLanguageID() == GTURTLEModeling.RT_LOTOS) {
+            JDialogSimulation jds = new JDialogSimulation(frame,
+                    this,
+                    "Intensive simulation with RTL",
+                    gtm.getPathRTL(),
+                    REMOTE_RTL_LOTOS_FILE,
+                    gtm.getLastRTLOTOSSpecification(),
+                    gtm.getHost());
+            //jds.setSize(450, 600);
+            GraphicLib.centerOnParent(jds, 450, 600);
+            jds.setVisible(true);
+            dtree.toBeUpdated();
+        } else if (gtm.getLanguageID() == GTURTLEModeling.LOTOS) {
+
+        }
+    }
+
+    public void formalValidation() {
+        formalValidation(false);
+    }
+
+    public void formalValidation(boolean automatic) {
+        formalValidation(automatic, getCurrentTURTLEPanel());
+    }
+
+    public boolean formalValidation(boolean automatic, String diagramName) {
+        TURTLEPanel tp = getTURTLEPanel(diagramName);
+        if (tp != null) {
+            formalValidation(automatic, tp);
+            return true;
+        }
+        return false;
+    }
+
+
+    public void formalValidation(boolean automatic, TURTLEPanel _tp) {
+        if (gtm.getLanguageID() == GTURTLEModeling.RT_LOTOS) {
+            JDialogFormalValidation jdfv = new JDialogFormalValidation(frame,
+                    this,
+                    "Formal Validation with RTL",
+                    gtm.getPathRTL(),
+                    gtm.getPathDTA2DOT(),
+                    gtm.getPathRGSTRAP(),
+                    gtm.getPathRG2TLSA(),
+                    REMOTE_RTL_LOTOS_FILE,
+                    gtm.getLastRTLOTOSSpecification(),
+                    gtm.getHost(),
+                    GTURTLEModeling.getHostAldebaran(),
+                    GTURTLEModeling.getPathBcgio());
+            jdfv.setAutomatic(automatic);
+            //   jdfv.setSize(450, 600);
+            GraphicLib.centerOnParent(jdfv, 450, 600);
+            jdfv.setVisible(true);
+            dtree.toBeUpdated();
+        } else if (gtm.getLanguageID() == GTURTLEModeling.LOTOS) {
+            JDialogLOTOSValidation jdla = new JDialogLOTOSValidation(frame,
+                    this, "Generating RG with CAESAR",
+                    gtm.getPathCaesar(),
+                    gtm.getPathCaesarOpen(),
+                    GTURTLEModeling.getPathBcgio(),
+                    gtm.getPathBcgmerge(),
+                    REMOTE_RTL_LOTOS_FILE,
+                    gtm.getLastRTLOTOSSpecification(),
+                    GTURTLEModeling.getCaesarHost());
+            jdla.setAutomatic(automatic);
+            // jdla.setSize(450, 600);
+            GraphicLib.centerOnParent(jdla, 450, 600);
+            jdla.setVisible(true);
+            dtree.toBeUpdated();
+        } else if (gtm.getLanguageID() == GTURTLEModeling.UPPAAL) {
+            JDialogUPPAALValidation jduv = new JDialogUPPAALValidation(frame,
+                    this, "Formal Verification with UPPAAL",
+                    gtm.getPathUPPAALVerifier(),
+                    gtm.getPathUPPAALFile(),
+                    REMOTE_UPPAAL_FILE,
+                    gtm.getLastUPPAALSpecification().getStringSpec(),
+                    gtm.getUPPAALVerifierHost(),
+                    _tp);
+            // jduv.setSize(450, 600);
+            GraphicLib.centerOnParent(jduv, 650, 600);
+            jduv.setVisible(true);
+            dtree.toBeUpdated();
+        } else if (gtm.getLanguageID() == GTURTLEModeling.MATRIX) {
+            JDialogTMatrixManagement jdfv = new JDialogTMatrixManagement(frame,
+                    this,
+                    "Observers's Based Formal Verification",
+                    gtm.getRequirementModeling(),
+                    gtm.getPathRTL(),
+                    gtm.getPathDTA2DOT(),
+                    gtm.getPathRGSTRAP(),
+                    gtm.getPathRG2TLSA(),
+                    REMOTE_RTL_LOTOS_FILE,
+                    gtm.getHost(),
+                    GTURTLEModeling.getHostAldebaran(),
+                    GTURTLEModeling.getPathBcgio());
+            // jdfv.setSize(550, 600);
+            jdfv.setIconImage(IconManager.img8);
+            GraphicLib.centerOnParent(jdfv, 550, 600);
+            jdfv.setVisible(true);
+            dtree.toBeUpdated();
+        }
+    }
+
+    public void projection() {
+        TClassDiagramPanel tcdp = null;
+        if (getCurrentTURTLEPanel() instanceof DesignPanel) {
+            tcdp = ((DesignPanel) (getCurrentTURTLEPanel())).tcdp;
+        }
+        JDialogProjection jdfv = new JDialogProjection(frame,
+                this,
+                tcdp,
+                gtm.getTURTLEModeling(),
+                GTURTLEModeling.getHostAldebaran(),
+                GTURTLEModeling.getPathAldebaran(),
+                gtm.getPathBcgmin(),
+                GTURTLEModeling.getPathBcgio(),
+                gtm.getLastRGAUT(),
+                REMOTE_ALDEBARAN_AUT_FILE,
+                "Minimization using Aldebaran");
+        // jdfv.setSize(900, 700);
+        GraphicLib.centerOnParent(jdfv, 900, 700);
+        jdfv.setVisible(true);
+    }
+
+    public void modifyGraph() {
+        JDialogGraphModification jdgm;
+        if (gtm == null) {
+            jdgm = new JDialogGraphModification(frame,
+                    GTURTLEModeling.getHostAldebaran(),
+                    GTURTLEModeling.getPathBcgio(),
+                    "graph",
+                    "Minimization using Aldebaran",
+                    null, null);
+        } else {
+            jdgm = new JDialogGraphModification(frame,
+                    GTURTLEModeling.getHostAldebaran(),
+                    GTURTLEModeling.getPathBcgio(),
+                    "graph",
+                    "Minimization using Aldebaran",
+                    gtm.getLastRGAUT(),
+                    gtm.getLastTextualRGAUTProj());
+        }
+        //jdgm.setSize(600, 500);
+        GraphicLib.centerOnParent(jdgm, 600, 500);
+        jdgm.setVisible(true);
+        modifiedaut = jdgm.getGraphAUT();
+        modifiedautdot = jdgm.getGraphDOT();
+        if (modifiedautdot != null) {
+            actions[TGUIAction.ACT_VIEW_MODIFIEDAUTDOT].setEnabled(true);
+            actions[TGUIAction.ACT_SAVE_AUTMODIFIED].setEnabled(true);
+        }
+        //gtm.modifyMinimizedGraph();
+    }
+
+    public void bisimulation() {
+        JDialogBisimulation jdb = new JDialogBisimulation(frame,
+                GTURTLEModeling.getHostAldebaran(),
+                GTURTLEModeling.getPathAldebaran(),
+                REMOTE_ALDEBARAN_BISIMU_FILE1,
+                REMOTE_ALDEBARAN_BISIMU_FILE2,
+                "Bisimulation using Aldebaran");
+        //  jdb.setSize(650, 800);
+        GraphicLib.centerOnParent(jdb, 650, 800);
+        jdb.setVisible(true);
+        //TraceManager.addDev("Bisimulation");
+    }
+
+    public void bisimulationCADP() {
+        JDialogBisimulationBisimulator jdb = new JDialogBisimulationBisimulator(frame,
+                GTURTLEModeling.getCaesarHost(),
+                GTURTLEModeling.getPathBisimulator(),
+                GTURTLEModeling.getPathBcgio(),
+                REMOTE_BISIMULATOR_FILE1,
+                REMOTE_BISIMULATOR_FILE2,
+                "Bisimulation using BISIMULATOR");
+        //   jdb.setSize(650, 800);
+        GraphicLib.centerOnParent(jdb, 650, 800);
+        jdb.setVisible(true);
+        //TraceManager.addDev("Bisimulation");
+    }
+
+    public void seekDeadlockAUT() {
+        String dataAUT = gtm.getLastTextualRGAUT();
+
+        JFrameDeadlock jfd = new JFrameDeadlock("Potential deadlocks", dataAUT);
+        jfd.setIconImage(IconManager.img8);
+        //jfd.setSize(600, 600);
+        GraphicLib.centerOnParent(jfd, 600, 600);
+        jfd.setVisible(true);
+    }
+
+    public void seekDeadlockSavedAUT() {
+        String graph[] = loadAUTGraph();
+        if (graph != null) {
+            JFrameDeadlock jfd = new JFrameDeadlock("Potential deadlocks on " + graph[0], graph[1]);
+            jfd.setIconImage(IconManager.img8);
+            // jfd.setSize(600, 600);
+            GraphicLib.centerOnParent(jfd, 600, 600);
+            jfd.setVisible(true);
+        }
+    }
+
+    public void showAUTFromString(String title, String data) {
+        /*JFrameStatistics jfs = new JFrameStatistics(title, data);
+          jfs.setIconImage(IconManager.img8);
+          jfs.setSize(600, 600);
+          GraphicLib.centerOnParent(jfs);
+          jfs.setVisible(true);*/
+        ThreadGUIElement t = new ThreadGUIElement(frame, 0, title, data, "Analyzing graph... Please wait", null, null, true);
+        t.go();
+    }
+
+    public void showAUTFromGraph(String title, AUTGraph graph) {
+        /*JFrameStatistics jfs = new JFrameStatistics(title, data);
+          jfs.setIconImage(IconManager.img8);
+          jfs.setSize(600, 600);
+          GraphicLib.centerOnParent(jfs);
+          jfs.setVisible(true);*/
+        ThreadGUIElement t = new ThreadGUIElement(frame, 0, title, null, "Analyzing graph... Please wait", graph, null, true);
+        t.go();
+    }
+
+    public void showAUT(String title, String data, AUTGraph graph) {
+        ThreadGUIElement t = new ThreadGUIElement(frame, 0, title, data, "Analyzing graph... Please wait", graph, null, true);
+        t.go();
+    }
+
+    public void showAUTFromRG(String title, RG rg) {
+        ThreadGUIElement t = new ThreadGUIElement(frame, 0, title, rg.data, "Analyzing graph... Please wait", rg.graph, rg, true);
+        t.go();
+    }
+
+    public void displayAUTFromRG(String title, RG rg) {
+        ThreadGUIElement t = new ThreadGUIElement(frame, 0, title, rg.data, "Analyzing graph... Please wait", rg.graph, rg, false);
+        t.go();
+    }
+
+    public void showPMAUT(String title, String data) {
+        TraceManager.addDev("Power management analysis");
+        JFramePowerManagementAnalysis jfpma = new JFramePowerManagementAnalysis(title, data);
+        jfpma.setIconImage(IconManager.img8);
+        //  jfpma.setSize(600, 600);
+        GraphicLib.centerOnParent(jfpma, 600, 600);
+        jfpma.setVisible(true);
+    }
+
+    public void NC() {
+        TraceManager.addDev("NC");
+        JFrameNC jfnc = new JFrameNC("Network Calculus", gtm.getNCS());
+        jfnc.setIconImage(IconManager.img8);
+        //   jfnc.setSize(600, 600);
+        GraphicLib.centerOnParent(jfnc, 600, 600);
+        jfnc.setVisible(true);
+        TraceManager.addDev("Done");
+
+        /*JFrameStatistics jfs = new JFrameStatistics(title, data);
+          jfs.setIconImage(IconManager.img8);
+          jfs.setSize(600, 600);
+          GraphicLib.centerOnParent(jfs);
+          jfs.setVisible(true);*/
+    }
+
+    public void statAUT() {
+        showAUTFromString("Analysis on the last RG (AUT format)", gtm.getLastTextualRGAUT());
+    }
+
+    public RG setLastRGDiplodocus(String graphName) {
+        TraceManager.addDev("setting last RG diplodocus");
+        //lastDiploRG = graphName;
+        // Loadng the graph
+        // Adding RG to the tree on the left
+        try {
+            String fileName = SpecConfigTTool.TGraphPath + "/" + graphName + ".aut";
+            File f = new File(fileName);
+            String spec = loadFile(f);
+            RG rg = new RG(graphName);
+            rg.data = spec;
+            //rg.nbOfStates = amc.getNbOfStates();
+            //rg.nbOfTransitions = amc.getNbOfLinks();
+            addRG(rg);
+            lastDiploRG = rg;
+            return rg;
+        } catch (Exception e) {
+            TraceManager.addDev("RG creation in the left tree failed");
+            return null;
+        }
+    }
+
+    public void statAUTDiplodocus() {
+        if (lastDiploRG == null) {
+            JOptionPane.showMessageDialog(frame,
+                    "The file could not be loaded:",
+                    "Error",
+                    JOptionPane.INFORMATION_MESSAGE);
+            return;
+        }
+        showAUTFromRG(lastDiploRG.name, lastDiploRG);
+        //String spec = loadFile(new File(ConfigurationTTool.TGraphPath + "/" + lastDiploRG + ".aut"));
+
+        //showAUTFromString("Analysis on the last DIPLODOCUS RG", spec);
+    }
+
+    public void statAUTProj() {
+        showAUTFromString("Analysis on the last minimized RG (A>UT format)", gtm.getLastTextualRGAUTProj());
+    }
+
+    public void statSavedAUT() {
+        //TraceManager.addDev("toto");
+        String graph[] = loadAUTGraph();
+        if (graph != null) {
+            showAUTFromString("Analysis on " + graph[0], graph[1]);
+        }
+    }
+
+    public void pmAUT() {
+        showPMAUT("Power Management Analysis on the last RG (AUT format)", gtm.getLastTextualRGAUT());
+    }
+
+    public void pmAUTProj() {
+        showPMAUT("Power Management Analysis on the last minimized RG (AUT format)", gtm.getLastTextualRGAUTProj());
+    }
+
+    public void pmSavedAUT() {
+        //TraceManager.addDev("toto");
+        String graph[] = loadAUTGraph();
+        if (graph != null) {
+            showPMAUT("Power Management Analysis on " + graph[0], graph[1]);
+        }
+    }
+
+    public void showFormalSpecification() {
+        if (gtm.getLanguageID() == GTURTLEModeling.RT_LOTOS) {
+            showFormalSpecification("RT-LOTOS Specification #" + gtm.getNbRTLOTOS(), gtm.getLastRTLOTOSSpecification());
+        } else if (gtm.getLanguageID() == GTURTLEModeling.LOTOS) {
+            showFormalSpecification("LOTOS Specification #" + gtm.getNbRTLOTOS(), gtm.getLastRTLOTOSSpecification());
+        } else if (gtm.getLanguageID() == GTURTLEModeling.PROVERIF) {
+            showFormalSpecification("Last ProVerif Specification", gtm.getLastProVerifSpecification());
+        }
+    }
+
+    public void showFormalSpecification(String title, String data) {
+        JFrameText jft = new JFrameText(title, data);
+        jft.setIconImage(IconManager.img8);
+        //    jft.setSize(600, 600);
+        GraphicLib.centerOnParent(jft, 600, 600);
+        jft.setVisible(true);
+    }
+
+    public void showJavaCode() {
+        if (javaframe == null) {
+            javaframe = new JFrameCode("JavaCode", "", "");
+            javaframe.setIconImage(IconManager.img8);
+            // javaframe.setSize(350, 350);
+            GraphicLib.centerOnParent(javaframe, 350, 350);
+            javaframe.setVisible(true);
+        } else {
+            javaframe.setVisible(true);
+        }
+    }
+
+    public void showBirdEyesView() {
+        if (birdframe == null) {
+            birdframe = new JFrameBird(this);
+            birdframe.setIconImage(IconManager.img8);
+            //   birdframe.setSize(150, 100);
+            GraphicLib.centerOnParent(birdframe, 150, 100);
+            birdframe.setVisible(true);
+        } else {
+            birdframe.setVisible(true);
+        }
+    }
+
+    public void showEmbeddedBirdEyesView() {
+        //TraceManager.addDev("Embedded!");
+        if (jbp.getGo()) {
+            jbp.setGo(false);
+        } else {
+            jbp.startProcess();
+        }
+    }
+
+    public void drawBird() {
+        if (jbp.getGo()) {
+            jbp.repaint();
+        }
+
+        if (birdframe != null) {
+            birdframe.updatePanel();
+        }
+    }
+
+    public void unsetBirdFrame() {
+        birdframe = null;
+    }
+
+    public void setJavaPreCode(TGComponent tgc) {
+        if (javaframe != null) {
+            if (tgc == null) {
+                javaframe.setPreCode("");
+                return;
+            }
+            if (tgc.hasPreJavaCode()) {
+                javaframe.setPreCode(tgc.getPreJavaCode());
+            } else {
+                javaframe.setPreCode("");
+            }
+        }
+    }
+
+    public void setJavaPostCode(TGComponent tgc) {
+        if (javaframe != null) {
+            if (tgc == null) {
+                javaframe.setPostCode("");
+                return;
+            }
+            if (tgc.hasPostJavaCode()) {
+                javaframe.setPostCode(tgc.getPostJavaCode());
+            } else {
+                javaframe.setPostCode("");
+            }
+        }
+    }
+
+    public void showSuggestedDesign() {
+        JFrameText jft = new JFrameText("Suggested Design #" + gtm.getNbSuggestedDesign(), gtm.getLastTextualDesign());
+        jft.setIconImage(IconManager.img8);
+        //  jft.setSize(600, 600);
+        GraphicLib.centerOnParent(jft, 600, 600);
+        jft.setVisible(true);
+    }
+
+    public void showSavedRTLOTOS() {
+        String spec[] = loadLotosSpec();
+        if ((spec != null) && (spec[0] != null) && (spec[1] != null)) {
+            JFrameText jft = new JFrameText("RT-LOTOS Specification: " + spec[0], spec[1]);
+            jft.setIconImage(IconManager.img8);
+            // jft.setSize(600, 600);
+            GraphicLib.centerOnParent(jft, 600, 600);
+            jft.setVisible(true);
+        }
+    }
+
+    public void showSimulationTrace() {
+        gtm.showSIM(1);
+    }
+
+    public void showSimulationTraceChrono() {
+        gtm.showSIM(2);
+    }
+
+    public void showDTA() {
+        String s = gtm.showDTA();
+        if (s != null) {
+            JOptionPane.showMessageDialog(frame,
+                    "The DTA could not be displayed: " + s,
+                    "Error",
+                    JOptionPane.INFORMATION_MESSAGE);
+        }
+    }
+
+    public void showWave() {
+        RemoteExecutionThread ret = new RemoteExecutionThread(ConfigurationTTool.SystemCHost, null, null, ConfigurationTTool.GTKWavePath + " vcddump.vcd");
+        ret.start();
+    }
+
+    public void showRG() {
+        String s = gtm.showRG();
+        if (s != null) {
+            JOptionPane.showMessageDialog(frame,
+                    "The RG could not be displayed: " + s,
+                    "Error",
+                    JOptionPane.INFORMATION_MESSAGE);
+        }
+    }
+
+    public void showTLSA() {
+        String s = gtm.showTLSA();
+        if (s != null) {
+            JOptionPane.showMessageDialog(frame,
+                    "The TLSA could not be displayed: " + s,
+                    "Error",
+                    JOptionPane.INFORMATION_MESSAGE);
+        }
+    }
+
+    public void showRGAut() {
+        String s = gtm.showRGAut();
+        if (s != null) {
+            JOptionPane.showMessageDialog(frame,
+                    "The RG could not be displayed: " + s,
+                    "Error",
+                    JOptionPane.INFORMATION_MESSAGE);
+        }
+    }
+
+    public void showRGAutProj() {
+        String s = gtm.showRGAutProj();
+        if (s != null) {
+            JOptionPane.showMessageDialog(frame,
+                    "The RG could not be displayed: " + s,
+                    "Error",
+                    JOptionPane.INFORMATION_MESSAGE);
+        }
+    }
+
+    public void showRGDiplodocus() {
+        if (lastDiploRG == null) {
+            JOptionPane.showMessageDialog(frame,
+                    "The RG was not yet generated",
+                    "Error",
+                    JOptionPane.INFORMATION_MESSAGE);
+            return;
+        }
+        TraceManager.addDev("Showing diplo RG");
+        displayAUTFromRG(lastDiploRG.name, lastDiploRG);
+
+    }
+
+    public void showModifiedAUTDOT() {
+        String s = GTURTLEModeling.runDOTTY(modifiedautdot);
+        if (s != null) {
+            JOptionPane.showMessageDialog(frame,
+                    "The RG could not be displayed: " + s,
+                    "Error",
+                    JOptionPane.INFORMATION_MESSAGE);
+        }
+    }
+
+    public void showGGraph() {
+        String graph[] = loadGGraph();
+        if (graph != null) {
+            String s = GTURTLEModeling.showGGraph(graph[1]);
+            if (s != null) {
+                JOptionPane.showMessageDialog(frame,
+                        "The graph could not be displayed: " + s,
+                        "Error",
+                        JOptionPane.INFORMATION_MESSAGE);
+            }
+        }
+    }
+
+    public void viewAutomata(String file) {
+        //TraceManager.addDev("viewing: " + file);
+        String graph[] = loadGGraph(file);
+        if (graph != null) {
+            String s = GTURTLEModeling.showGGraph(graph[1]);
+            if (s != null) {
+                JOptionPane.showMessageDialog(frame,
+                        "The graph could not be displayed: " + s,
+                        "Error",
+                        JOptionPane.INFORMATION_MESSAGE);
+            }
+        }
+    }
+
+    public void executeUserCommand(String host, String command) {
+        RemoteExecutionThread ret = new RemoteExecutionThread(host, null, null, command);
+        ret.start();
+        TraceManager.addDev("User command ->" + command + "<- started on host " + host);
+    }
+
+
+    public void screenCapture() {
+        //Select file
+        File file = selectFileForCapture();
+        if (file == null)
+            return;
+
+        Toolkit toolkit = Toolkit.getDefaultToolkit();
+        Dimension screenSize = toolkit.getScreenSize();
+        Rectangle screenRect = new Rectangle(screenSize);
+        performScreenCapture(screenRect, file);
+    }
+
+    public void windowCapture() {
+        //Select file
+        File file = selectFileForCapture();
+        if (file == null)
+            return;
+
+        Rectangle screenRect = new Rectangle(frame.getLocation().x, frame.getLocation().y, frame.getWidth(), frame.getHeight());
+        performScreenCapture(screenRect, file);
+    }
+
+    public void diagramCapture() {
+        if (tabs.size() < 1) {
+            JOptionPane.showMessageDialog(frame,
+                    "No diagram is under edition",
+                    "Error",
+                    JOptionPane.INFORMATION_MESSAGE);
+            return;
+        }
+
+        File file = selectFileForCapture();
+        if (file == null)
+            return;
+
+        TDiagramPanel tdp1 = getCurrentTDiagramPanel();
+        if (tdp1 != null) {
+            BufferedImage image = tdp1.performMinimalCapture();
+            writeImageCapture(image, file, true);
+        }
+    }
+
+    public void svgDiagramCapture() {
+
+        TraceManager.addDev("SVG capture ");
+
+        if (tabs.size() < 1) {
+            JOptionPane.showMessageDialog(frame,
+                    "No diagram is under edition",
+                    "Error",
+                    JOptionPane.INFORMATION_MESSAGE);
+            return;
+        }
+
+        File file = selectSVGFileForCapture(true);
+
+        if (file == null)
+            return;
+
+        TDiagramPanel tdp1 = getCurrentTDiagramPanel();
+        if (tdp1 != null) {
+            String s = tdp1.svgCapture();
+            try {
+                FileUtils.saveFile(file.getAbsolutePath(), s);
+            } catch (Exception e) {
+                JOptionPane.showMessageDialog(frame,
+                        "File could not be saved: " + e.getMessage(),
+                        "Error",
+                        JOptionPane.INFORMATION_MESSAGE);
+                return;
+            }
+            JOptionPane.showMessageDialog(frame,
+                    "The capture was correctly performed and saved in " + file.getAbsolutePath(),
+                    "Save in svg format ok",
+                    JOptionPane.INFORMATION_MESSAGE);
+        }
+    }
+
+    public void allDiagramCapture() {
+        if (tabs.size() < 1) {
+            JOptionPane.showMessageDialog(frame,
+                    "No diagram is under edition",
+                    "Error",
+                    JOptionPane.INFORMATION_MESSAGE);
+            return;
+        }
+
+        File file = selectFileForCapture();
+        if (file == null)
+            return;
+
+        TURTLEPanel tp;// = getCurrentTURTLEPanel();
+        TDiagramPanel tdp1;
+        BufferedImage image;
+        File file1;
+        String name = file.getAbsolutePath();
+        name = name.substring(0, name.length() - 4);
+
+        //boolean actions;
+        for (int j = 0; j < tabs.size(); j++) {
+            tp = tabs.get(j);
+            for (int i = 0; i < tp.panels.size(); i++) {
+                tdp1 = tp.panels.elementAt(i);
+                tdp1.repaint();
+                image = tdp1.performMinimalCapture();
+                if (i < 10) {
+                    file1 = new File(name + "0" + i + "__" + tdp1.getName());
+                } else {
+                    file1 = new File(name + i + "__" + tdp1.getName());
+                }
+                file1 = FileUtils.addFileExtensionIfMissing(file1, TImgFilter.getExtension());
+                if (!writeImageCapture(image, file1, false)) {
+                    JOptionPane.showMessageDialog(frame,
+                            "Diagrams could NOT be captured in png format",
+                            "Capture failed",
+                            JOptionPane.INFORMATION_MESSAGE);
+                    return;
+                }
+                if (i == 0) {
+                    if (!writeImageCapture(image, file, false)) {
+                        JOptionPane.showMessageDialog(frame,
+                                "Diagrams could NOT be captured in png format",
+                                "Capture failed",
+                                JOptionPane.INFORMATION_MESSAGE);
+                        return;
+                    }
+                }
+            }
+        }
+
+        JOptionPane.showMessageDialog(frame,
+                "All diagrams were sucessfully captured in png format",
+                "Capture ok",
+                JOptionPane.INFORMATION_MESSAGE);
+    }
+
+    public void allDiagramCaptureSvg() {
+        if (tabs.size() < 1) {
+            JOptionPane.showMessageDialog(frame,
+                    "No diagram is under edition",
+                    "Error",
+                    JOptionPane.INFORMATION_MESSAGE);
+            return;
+        }
+
+        File file = selectSVGFileForCapture(false);
+        if (file == null)
+            return;
+
+        TURTLEPanel tp;// = getCurrentTURTLEPanel();
+        TDiagramPanel tdp1;
+        //  BufferedImage image;
+        File file1;
+        String name = file.getAbsolutePath();
+        name = name.substring(0, name.length() - 4);
+
+        //boolean actions;
+        for (int j = 0; j < tabs.size(); j++) {
+            tp = tabs.get(j);
+            for (int i = 0; i < tp.panels.size(); i++) {
+                tdp1 = tp.panels.elementAt(i);
+                tdp1.repaint();
+
+                //tdp1.performMinimalCapture();
+                String svgImg = tdp1.svgCapture();
+
+                if (i < 10) {
+                    file1 = new File(name + j + "_" + "0" + i + "__" + tdp1.getName());
+                } else {
+                    file1 = new File(name + j + "_" + i + "__" + tdp1.getName());
+                }
+                file1 = FileUtils.addFileExtensionIfMissing(file1, TSVGFilter.getExtension());
+                try {
+                    TraceManager.addDev("Saving in file:" + file1.getAbsolutePath());
+                    FileUtils.saveFile(file1, svgImg);
+                } catch (Exception e) {
+                    JOptionPane.showMessageDialog(frame,
+                            "Diagrams could NOT be captured in svg format",
+                            "Capture failed",
+                            JOptionPane.INFORMATION_MESSAGE);
+                    return;
+                }
+
+            }
+        }
+
+        JOptionPane.showMessageDialog(frame,
+                "All diagrams were sucessfully captured in svg format",
+                "Capture ok",
+                JOptionPane.INFORMATION_MESSAGE);
+    }
+
+    public void selectedCapture() {
+        File file = selectFileForCapture();
+        if (file == null)
+            return;
+        BufferedImage image = getCurrentTDiagramPanel().performSelectedCapture();
+        writeImageCapture(image, file, true);
+    }
+
+    public File selectFileForCapture() {
+        File file = null;
+        jfcimg.setCurrentDirectory(new File(SpecConfigTTool.IMGPath));
+        int returnVal = jfcimg.showSaveDialog(frame);
+        if (returnVal == JFileChooser.CANCEL_OPTION)
+            return null;
+
+        if (returnVal == JFileChooser.APPROVE_OPTION) {
+            file = jfcimg.getSelectedFile();
+            file = FileUtils.addFileExtensionIfMissing(file, TImgFilter.getExtension());
+
+        }
+        if (!checkFileForSave(file)) {
+            JOptionPane.showMessageDialog(frame,
+                    "The capture could not be performed: invalid file",
+                    "Error",
+                    JOptionPane.INFORMATION_MESSAGE);
+            return null;
+        }
+        return file;
+    }
+
+    public File selectSVGFileForCapture(boolean checkForSave) {
+        File file = null;
+        jfcimgsvg.setCurrentDirectory(new File(SpecConfigTTool.IMGPath));
+        int returnVal = jfcimgsvg.showSaveDialog(frame);
+        if (returnVal == JFileChooser.CANCEL_OPTION)
+            return null;
+
+        if (returnVal == JFileChooser.APPROVE_OPTION) {
+            file = jfcimgsvg.getSelectedFile();
+            file = FileUtils.addFileExtensionIfMissing(file, TSVGFilter.getExtension());
+
+        }
+        if (checkForSave) {
+            if (!checkFileForSave(file)) {
+                JOptionPane.showMessageDialog(frame,
+                        "The capture could not be performed: invalid file",
+                        "Error",
+                        JOptionPane.INFORMATION_MESSAGE);
+                return null;
+            }
+        }
+        return file;
+    }
+
+
+    public void performScreenCapture(Rectangle rect, File file) {
+        frame.paint(frame.getGraphics());
+        try {
+            Robot robot = new Robot();
+            BufferedImage image = robot.createScreenCapture(rect);
+            // save captured image to PNG file
+            ImageIO.write(image, "png", file);
+        } catch (Exception e) {
+            JOptionPane.showMessageDialog(frame,
+                    "The capture could not be performed:" + e.getMessage(),
+                    "Error",
+                    JOptionPane.INFORMATION_MESSAGE);
+            return;
+        }
+        JOptionPane.showMessageDialog(frame,
+                "The capture was correctly performed",
+                "Screen capture ok",
+                JOptionPane.INFORMATION_MESSAGE);
+        return;
+    }
+
+    public boolean writeImageCapture(BufferedImage image, File file, boolean info) {
+        frame.paint(frame.getGraphics());
+        try {
+            // save captured image to PNG file
+            ImageIO.write(image, "png", file);
+        } catch (Exception e) {
+            JOptionPane.showMessageDialog(frame,
+                    "The capture could not be performed:" + e.getMessage(),
+                    "Error",
+                    JOptionPane.INFORMATION_MESSAGE);
+            return false;
+        }
+        if (info) {
+            JOptionPane.showMessageDialog(frame,
+                    "The capture was correctly performed and saved in " + file.getAbsolutePath(),
+                    "Screen capture ok",
+                    JOptionPane.INFORMATION_MESSAGE);
+        }
+        return true;
+    }
+
+    public void generateDocumentation() {
+        //TraceManager.addDev("Documentation");
+        ThreadGUIElement t = new ThreadGUIElement(frame, 1, tabs, mainTabbedPane, SpecConfigTTool.DocGenPath, file.getName(), "Documentation", "Generating documentation ... Please wait");
+        t.go();
+        /*DocumentationGenerator docgen = new DocumentationGenerator(tabs, mainTabbedPane, ConfigurationTTool.IMGPath, file.getName());
+          docgen.setFirstHeadingNumber(2);
+          if (docgen.generateDocumentation()) {
+          JOptionPane.showMessageDialog(frame,
+          "All done!",
+          "Documentation generation",
+          JOptionPane.INFORMATION_MESSAGE);
+          } else {
+          JOptionPane.showMessageDialog(frame,
+          "The documentation generation could not be performed",
+          "Error",
+          JOptionPane.INFORMATION_MESSAGE);
+          }*/
+        //TraceManager.addDev("Documentation=" + docgen.getDocumentation());
+    }
+
+    public void generateDocumentationReq() {
+        TraceManager.addDev("Frame Req");
+        JDialogRequirementTable jdrt = new JDialogRequirementTable(frame, "Selecting table columns");
+        GraphicLib.centerOnParent(jdrt);
+        jdrt.setVisible(true);
+        if (!jdrt.hasBeenCancelled()) {
+            Point[] pts = jdrt.getColumnsInfo();
+            if (pts != null) {
+                for (int i = 0; i < pts.length; i++) {
+                    TraceManager.addDev("" + i + ": (" + pts[i].x + ", " + pts[i].y + ")");
+                }
+
+                JFrameRequirementTable jfrt = new JFrameRequirementTable("Requirement table", tabs, mainTabbedPane, pts);
+                jfrt.setIconImage(IconManager.img8);
+                //jfrt.setSize(1024, 768);
+                GraphicLib.centerOnParent(jfrt, 1024, 768);
+                jfrt.setVisible(true);
+            } else {
+                TraceManager.addDev("No column to print");
+            }
+        }
+        TraceManager.addDev("Done");
+    }
+
+    public int getTypeButtonSelected() {
+        return typeButtonSelected;
+    }
+
+    public Plugin getPluginSelected() {
+        return pluginSelected;
+    }
+
+    public void actionOnButton(int type, int id) {
+        typeButtonSelected = type;
+        idButtonSelected = id;
+        pluginSelected = null;
+        //TDiagramPanel tdp1 = ((TURTLEPanel)(tabs.elementAt(mainTabbedPane.getSelectedIndex()))).tdp;
+        TDiagramPanel tdp1 = getCurrentTDiagramPanel();
+        //TraceManager.addDev("Selected TDiagramPanel=" + tdp1.getName());
+        tdp1.repaint();
+    }
+
+    public void actionOnButton(int type, Plugin _p) {
+        typeButtonSelected = type;
+        idButtonSelected = TGComponentManager.COMPONENT_PLUGIN;
+        pluginSelected = _p;
+        //TDiagramPanel tdp1 = ((TURTLEPanel)(tabs.elementAt(mainTabbedPane.getSelectedIndex()))).tdp;
+        TDiagramPanel tdp1 = getCurrentTDiagramPanel();
+        //TraceManager.addDev("Selected TDiagramPanel=" + tdp1.getName());
+        tdp1.repaint();
+    }
+
+    public int getIdButtonSelected() {
+        return idButtonSelected;
+    }
+
+    public void addTClass(TURTLEPanel tp, String s) {
+        if (!(tp instanceof DesignPanel)) {
+            return;
+        }
+
+        ((DesignPanel) tp).addTActivityDiagram(s);
+        setPanelMode();
+    }
+
+    public void addTOSClass(TURTLEPanel tp, String s) {
+        if (!(tp instanceof TURTLEOSDesignPanel)) {
+            return;
+        }
+
+        ((TURTLEOSDesignPanel) tp).addTURTLEOSActivityDiagram(s);
+        setPanelMode();
+    }
+
+    public void addTMLTask(TURTLEPanel tp, String s) {
+        //TraceManager.addDev("ADD TML Task=" + s);
+        if (!(tp instanceof TMLDesignPanel)) {
+            return;
+        }
+
+        ((TMLDesignPanel) tp).addTMLActivityDiagram(s);
+        setPanelMode();
+    }
+
+    public void addTMLCPrimitiveComponent(TURTLEPanel tp, String s) {
+        //TraceManager.addDev("ADD C Primitive Component=" + s);
+        if (!(tp instanceof TMLComponentDesignPanel)) {
+            return;
+        }
+
+        ((TMLComponentDesignPanel) tp).addTMLActivityDiagram(s);
+        setPanelMode();
+    }
+
+    public TMLActivityDiagramPanel getReferencedTMLActivityDiagramPanel(TDiagramPanel _tdp, String name) {
+        TURTLEPanel tp;
+        TMLActivityDiagramPanel tmladp;
+        //TraceManager.addDev("global search for: " + name);
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof TMLComponentDesignPanel) {
+                if (tp.hasTDiagramPanel(_tdp)) {
+                    tmladp = ((TMLComponentDesignPanel) tp).getTMLActivityDiagramPanel(name);
+                    if (tmladp != null) {
+                        //TraceManager.addDev("Found");
+                        return tmladp;
+                    }
+                }
+            }
+        }
+
+        TraceManager.addDev("Not found");
+        return null;
+    }
+
+    public TURTLEPanel getTURTLEPanelOfTDiagramPanel(TDiagramPanel _tdp) {
+        TURTLEPanel tp;
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof TMLComponentDesignPanel) {
+                if (tp.hasTDiagramPanel(_tdp)) {
+                    return tp;
+
+                }
+            }
+        }
+        return null;
+    }
+
+    public ArrayList<EBRDDPanel> getAllEBRDDPanels() {
+        TURTLEPanel tp;
+        ArrayList<EBRDDPanel> al = new ArrayList<EBRDDPanel>();
+        //TraceManager.addDev("global search for: " + name);
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof RequirementPanel) {
+                ((RequirementPanel) tp).addAllEBRDDPanels(al);
+            }
+        }
+
+        return al;
+    }
+
+    public ArrayList<AvatarPDPanel> getAllAvatarPDPanels() {
+        TURTLEPanel tp;
+        ArrayList<AvatarPDPanel> al = new ArrayList<AvatarPDPanel>();
+        //TraceManager.addDev("global search for: " + name);
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof AvatarRequirementPanel) {
+                ((AvatarRequirementPanel) tp).addAllAvatarPDPanels(al);
+            }
+        }
+
+        return al;
+    }
+
+    public List<TGComponent> getAllTMLComponents() {
+        TURTLEPanel tp;
+        List<TGComponent> ll = new LinkedList<TGComponent>();
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+
+            if (tp instanceof TMLComponentDesignPanel) {
+                ll.addAll(((TMLComponentDesignPanel) tp).tmlctdp.getComponentList());
+            }
+        }
+
+        return ll;
+    }
+
+    public void removeTClass(TURTLEPanel tp, String s) {
+        if (!(tp instanceof DesignPanel)) {
+            return;
+        }
+
+        for (int i = 0; i < tp.tabbedPane.getTabCount(); i++) {
+            if (tp.tabbedPane.getTitleAt(i).equals(s)) {
+                tp.tabbedPane.removeTabAt(i);
+                tp.panels.removeElementAt(i);
+                setPanelMode();
+                return;
+            }
+        }
+    }
+
+    public void removeTOSClass(TURTLEPanel tp, String s) {
+        if (!(tp instanceof TURTLEOSDesignPanel)) {
+            return;
+        }
+
+        TraceManager.addDev("Removing tab ...");
+        for (int i = 0; i < tp.tabbedPane.getTabCount(); i++) {
+            if (tp.tabbedPane.getTitleAt(i).equals(s)) {
+                tp.tabbedPane.removeTabAt(i);
+                tp.panels.removeElementAt(i);
+                setPanelMode();
+                return;
+            }
+        }
+    }
+
+    public void removeTMLTask(TURTLEPanel tp, String s) {
+        if (!(tp instanceof TMLDesignPanel)) {
+            return;
+        }
+
+        for (int i = 0; i < tp.tabbedPane.getTabCount(); i++) {
+            if (tp.tabbedPane.getTitleAt(i).equals(s)) {
+                tp.tabbedPane.removeTabAt(i);
+                tp.panels.removeElementAt(i);
+                setPanelMode();
+                return;
+            }
+        }
+    }
+
+    public void removeAvatarBlock(TURTLEPanel tp, String s) {
+        if (!(tp instanceof AvatarDesignPanel))
+            return;
+
+        for (int i = 0; i < tp.tabbedPane.getTabCount(); i++)
+            if (tp.tabbedPane.getTitleAt(i).equals(s)) {
+                tp.tabbedPane.removeTabAt(i);
+                tp.panels.removeElementAt(i);
+                this.setPanelMode();
+                return;
+            }
+    }
+
+    public void removeTMLCPrimitiveComponent(TURTLEPanel tp, String s) {
+        //TraceManager.addDev("Removing panel 0:" + s);
+        if (!(tp instanceof TMLComponentDesignPanel)) {
+            return;
+        }
+
+        //TraceManager.addDev("Removing panel 1:" + s);
+        for (int i = 0; i < tp.tabbedPane.getTabCount(); i++) {
+            if (tp.tabbedPane.getTitleAt(i).equals(s)) {
+                tp.tabbedPane.removeTabAt(i);
+                tp.panels.removeElementAt(i);
+                setPanelMode();
+                return;
+            }
+        }
+    }
+
+    // for diagrams
+    public void setEditMode() {
+        typeButtonSelected = TGComponentManager.EDIT;
+        idButtonSelected = -1;
+    }
+
+    public String getTabName(TURTLEPanel p) {
+        int index = tabs.indexOf(p);
+        if (index < 0) {
+            return "";
+        }
+        return mainTabbedPane.getTitleAt(index);
+    }
+
+    public int getMajorIndexOf(TDiagramPanel tdp) {
+        TURTLEPanel tp;
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp.panels.contains(tdp)) {
+                return i;
+            }
+        }
+
+        return -1;
+    }
+
+    public String getMajorTitle(TDiagramPanel tdp) {
+        int index = getMajorIndexOf(tdp);
+
+        if (index == -1) {
+            return "unknown";
+        }
+
+        return mainTabbedPane.getTitleAt(index);
+    }
+
+    public ArrayList<TMLComponentTaskDiagramPanel> getAllPanelsReferencingTMLCCompositeComponent(TMLCCompositeComponent tmlcc) {
+        TURTLEPanel tp;
+        ArrayList<TMLComponentTaskDiagramPanel> foundPanels = new ArrayList<TMLComponentTaskDiagramPanel>();
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof TMLComponentDesignPanel) {
+                ((TMLComponentDesignPanel) tp).tmlctdp.getPanelsUsingAComponent(tmlcc, foundPanels);
+            }
+        }
+
+        return foundPanels;
+    }
+
+    public void updateReferenceToTMLCCompositeComponent(TMLCCompositeComponent tmlcc) {
+        TURTLEPanel tp;
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof TMLComponentDesignPanel) {
+                ((TMLComponentDesignPanel) tp).tmlctdp.updateReferenceToTMLCCompositeComponent(tmlcc);
+            }
+        }
+    }
+
+    public TMLCCompositeComponent getCompositeComponent(String name) {
+        int index = name.indexOf("::");
+        if (index == -1) {
+            return null;
+        }
+
+        String panelName = name.substring(0, index);
+        String componentName = name.substring(index + 2, name.length());
+
+        TURTLEPanel tp = getTURTLEPanel(panelName);
+
+        if ((tp == null) || (!(tp instanceof TMLComponentDesignPanel))) {
+            return null;
+        }
+
+
+        return ((TMLComponentDesignPanel) (tp)).tmlctdp.getCompositeComponentByName(componentName);
+    }
+
+    public AvatarSMDPanel getAvatarSMDPanel(int indexDesign, String name) {
+
+        TURTLEPanel tp = tabs.elementAt(indexDesign);
+        if (tp == null) {
+            TraceManager.addDev("null TP");
+            return null;
+        }
+        if (tp instanceof AvatarDesignPanel) {
+            return ((AvatarDesignPanel) tp).getAvatarSMDPanel(name);
+        }
+        TraceManager.addDev("null ADP :" + name);
+        return null;
+    }
+
+    public TActivityDiagramPanel getActivityDiagramPanel(int indexDesign, String name) {
+        TURTLEPanel tp = tabs.elementAt(indexDesign);
+        if (tp == null) {
+            return null;
+        }
+        if (tp instanceof DesignPanel) {
+            return ((DesignPanel) tp).getActivityDiagramPanel(name);
+        }
+        return null;
+    }
+
+    public TURTLEOSActivityDiagramPanel getTURTLEOSActivityDiagramPanel(int indexDesign, String name) {
+        TURTLEPanel tp = tabs.elementAt(indexDesign);
+        if (tp == null) {
+            return null;
+        }
+        if (tp instanceof TURTLEOSDesignPanel) {
+            return ((TURTLEOSDesignPanel) tp).getTURTLEOSActivityDiagramPanel(name);
+        }
+        return null;
+    }
+
+    public TMLActivityDiagramPanel getTMLActivityDiagramPanel(int indexDesign, String name) {
+        TURTLEPanel tp = tabs.elementAt(indexDesign);
+        if (tp == null) {
+            return null;
+        }
+        if (tp instanceof TMLDesignPanel) {
+            return ((TMLDesignPanel) tp).getTMLActivityDiagramPanel(name);
+        }
+        if (tp instanceof TMLComponentDesignPanel) {
+            return ((TMLComponentDesignPanel) tp).getTMLActivityDiagramPanel(name);
+        }
+        return null;
+    }
+
+    public ProactiveSMDPanel getSMDPanel(int indexDesign, String name) {
+        TURTLEPanel tp = tabs.elementAt(indexDesign);
+        if (tp == null) {
+            return null;
+        }
+        if (tp instanceof ProactiveDesignPanel) {
+            return ((ProactiveDesignPanel) tp).getSMDPanel(name);
+        }
+        return null;
+    }
+
+    public int getNbActivityDiagram() {
+        TDiagramPanel tdp;
+        int cpt = 0;
+
+        for (int i = 0; i < getCurrentJTabbedPane().getTabCount(); i++) {
+            tdp = getCurrentTURTLEPanel().panels.elementAt(i);
+            if (tdp instanceof TActivityDiagramPanel) {
+                cpt++;
+            }
+        }
+        return cpt;
+    }
+
+    public void setAvatarBDName(int indexDesign, String name) {
+        TURTLEPanel tp = tabs.elementAt(indexDesign);
+        tp.tabbedPane.setTitleAt(0, name);
+    }
+
+    public void setClassDiagramName(int indexDesign, String name) {
+        TURTLEPanel tp = tabs.elementAt(indexDesign);
+        tp.tabbedPane.setTitleAt(0, name);
+    }
+
+    public void setDiplodocusMethodologyDiagramName(int indexDesign, String name) {
+        TURTLEPanel tp = tabs.elementAt(indexDesign);
+        tp.tabbedPane.setTitleAt(0, name);
+    }
+
+    public void setAvatarMethodologyDiagramName(int indexDesign, String name) {
+        TURTLEPanel tp = tabs.elementAt(indexDesign);
+        tp.tabbedPane.setTitleAt(0, name);
+    }
+
+    /*  public void setSystemCAMSDiagramName(int indexDesign, String name) {
+        TURTLEPanel tp = tabs.elementAt(indexDesign);
+        tp.tabbedPane.setTitleAt(0, name);
+	}*/
+
+    public void setSysmlsecMethodologyDiagramName(int indexDesign, String name) {
+        TURTLEPanel tp = tabs.elementAt(indexDesign);
+        tp.tabbedPane.setTitleAt(0, name);
+    }
+
+    public void setTMLTaskDiagramName(int indexDesign, String name) {
+        TURTLEPanel tp = tabs.elementAt(indexDesign);
+        tp.tabbedPane.setTitleAt(0, name);
+    }
+
+    public void setTMLComponentTaskDiagramName(int indexDesign, String name) {
+        TURTLEPanel tp = tabs.elementAt(indexDesign);
+        tp.tabbedPane.setTitleAt(0, name);
+    }
+
+    public void setTMLArchitectureDiagramName(int indexDesign, String name) {
+        TURTLEPanel tp = tabs.elementAt(indexDesign);
+        tp.tabbedPane.setTitleAt(0, name);
+    }
+
+    public void setAADName(int indexDesign, String name) {
+        TURTLEPanel tp = tabs.elementAt(indexDesign);
+        tp.tabbedPane.setTitleAt(0, name);
+    }
+
+    public void setProacticeCSDName(int indexDesign, String name) {
+        TURTLEPanel tp = tabs.elementAt(indexDesign);
+        tp.tabbedPane.setTitleAt(0, name);
+    }
+
+    public TDiagramPanel getMainTDiagramPanel(int indexPanel) {
+        if (tabs.size() > indexPanel) {
+            TURTLEPanel tp = tabs.elementAt(indexPanel);
+            return tp.tdp;
+        } else {
+            return null;
+        }
+
+    }
+
+    // TMLCP
+    public boolean isTMLCPSDCreated(int index, String s) {
+        return isTMLCPSDCreated(tabs.elementAt(index), s);
+    }
+
+    public boolean isTMLCPSDCreated(TURTLEPanel tp, String s) {
+        int index = tp.tabbedPane.indexOfTab(s);
+        if (index == -1) {
+            return false;
+        }
+        return (tp.panelAt(index) instanceof TMLSDPanel);
+    }
+
+    public boolean isTMLCPCreated(int index, String s) {
+        return isTMLCPCreated(tabs.elementAt(index), s);
+    }
+
+    public boolean isTMLCPCreated(TURTLEPanel tp, String s) {
+        int index = tp.tabbedPane.indexOfTab(s);
+        if (index == -1) {
+            return false;
+        }
+        return (tp.panelAt(index) instanceof TMLCPPanel);
+    }
+
+
+    // IOD, SD
+
+    public boolean isSDCreated(int index, String s) {
+        return isSDCreated(tabs.elementAt(index), s);
+    }
+
+    public boolean isIODCreated(int index, String s) {
+        return isIODCreated(tabs.elementAt(index), s);
+    }
+
+    public boolean isProActiveSMDCreated(int index, String s) {
+        return isProActiveSMDCreated(tabs.elementAt(index), s);
+    }
+
+    public boolean isSDCreated(TURTLEPanel tp, String s) {
+        int index = tp.tabbedPane.indexOfTab(s);
+        if (index == -1) {
+            return false;
+        }
+        return (tp.panelAt(index) instanceof ui.sd.SequenceDiagramPanel);
+    }
+
+    public boolean isSDZVCreated(int index, String s) {
+        return isSDZVCreated(tabs.elementAt(index), s);
+    }
+
+    public boolean isSDZVCreated(TURTLEPanel tp, String s) {
+        int index = tp.tabbedPane.indexOfTab(s);
+        if (index == -1) {
+            return false;
+        }
+        return (tp.panelAt(index) instanceof ui.sd2.SequenceDiagramPanel);
+    }
+
+    public boolean isUseCaseDiagramCreated(TURTLEPanel tp, String s) {
+        int index = tp.tabbedPane.indexOfTab(s);
+        if (index == -1) {
+            return false;
+        }
+        return (tp.panelAt(index) instanceof UseCaseDiagramPanel);
+    }
+
+    public boolean isAvatarCDCreated(TURTLEPanel tp, String s) {
+        int index = tp.tabbedPane.indexOfTab(s);
+        if (index == -1) {
+            return false;
+        }
+        return (tp.panelAt(index) instanceof AvatarCDPanel);
+    }
+
+    public boolean isAvatarADCreated(TURTLEPanel tp, String s) {
+        int index = tp.tabbedPane.indexOfTab(s);
+        if (index == -1) {
+            return false;
+        }
+        return (tp.panelAt(index) instanceof AvatarADPanel);
+    }
+
+    public boolean isIODCreated(TURTLEPanel tp, String s) {
+        int index = tp.tabbedPane.indexOfTab(s);
+        if (index == -1) {
+            return false;
+        }
+        return (tp.panelAt(index) instanceof InteractionOverviewDiagramPanel);
+    }
+
+    public boolean isProActiveSMDCreated(TURTLEPanel tp, String s) {
+        int index = tp.tabbedPane.indexOfTab(s);
+        if (index == -1) {
+            return false;
+        }
+        return (tp.panelAt(index) instanceof ProactiveSMDPanel);
+    }
+
+    public boolean openSequenceDiagram(String s) {
+        int index = getCurrentJTabbedPane().indexOfTab(s);
+        if (index > -1) {
+            getCurrentJTabbedPane().setSelectedIndex(index);
+            return true;
+        }
+        return false;
+    }
+
+    public boolean openSequenceDiagramZV(String s) {
+        int index = getCurrentJTabbedPane().indexOfTab(s);
+        if (index > -1) {
+            getCurrentJTabbedPane().setSelectedIndex(index);
+            return true;
+        }
+        return false;
+    }
+
+    public boolean openIODiagram(String s) {
+        int index = getCurrentJTabbedPane().indexOfTab(s);
+        if (index > -1) {
+            getCurrentJTabbedPane().setSelectedIndex(index);
+            return true;
+        }
+        return false;
+    }
+
+    // TMLCP
+    public boolean openTMLCPSequenceDiagram(String s) {
+        int index = getCurrentJTabbedPane().indexOfTab(s);
+        if (index > -1) {
+            getCurrentJTabbedPane().setSelectedIndex(index);
+            return true;
+        }
+        return false;
+    }
+
+    public boolean openTMLCPDiagram(String s) {
+        int index = getCurrentJTabbedPane().indexOfTab(s);
+        if (index > -1) {
+            getCurrentJTabbedPane().setSelectedIndex(index);
+            return true;
+        }
+        return false;
+    }
+
+
+    public boolean createTMLCPSequenceDiagram(int index, String s) {
+        return createTMLCPSequenceDiagram(tabs.elementAt(index), s);
+    }
+
+    public boolean createTMLCPSequenceDiagram(TURTLEPanel tp, String s) {
+        if (isSDCreated(tp, s)) {
+            return false;
+        }
+
+        if (!(tp instanceof TMLCommunicationPatternPanel)) {
+            return false;
+        }
+
+
+        ((TMLCommunicationPatternPanel) tp).addCPSequenceDiagram(s);
+
+        setPanelMode();
+        return true;
+    }
+
+    public boolean createUniqueTMLCPSequenceDiagram(TURTLEPanel tp, String s) {
+        int i;
+        for (i = 0; i < 1000; i++) {
+            if (!isTMLCPSDCreated(tp, s + i)) {
+                break;
+            }
+        }
+
+        ((TMLCommunicationPatternPanel) tp).addCPSequenceDiagram(s + i);
+
+        setPanelMode();
+        return true;
+    }
+
+    public boolean createTMLCPDiagram(int index, String s) {
+        return createTMLCPDiagram(tabs.elementAt(index), s);
+    }
+
+    public boolean createTMLCPDiagram(TURTLEPanel tp, String s) {
+        if (isTMLCPCreated(tp, s)) {
+            return false;
+        }
+
+        if (!(tp instanceof TMLCommunicationPatternPanel)) {
+            return false;
+        }
+
+        ((TMLCommunicationPatternPanel) tp).addCPDiagram(s);
+        setPanelMode();
+        return true;
+    }
+
+    // End of TMLCP
+
+
+    public ui.sd.SequenceDiagramPanel getSequenceDiagramPanel(int index, String s) {
+        //TraceManager.addDev("Searching for " + s);
+        TURTLEPanel tp = tabs.elementAt(index);
+        return getSequenceDiagramPanel(tp, s);
+    }
+
+
+    public ui.sd2.SequenceDiagramPanel getSequenceDiagramPanelZV(int index, String s) {
+        //TraceManager.addDev("Searching for " + s);
+        TURTLEPanel tp = tabs.elementAt(index);
+        return getSequenceDiagramPanelZV(tp, s);
+    }
+
+
+    public AttackTreeDiagramPanel getAttackTreeDiagramPanel(int index, int indexTab, String s) {
+        //TraceManager.addDev("Searching for " + s);
+        TURTLEPanel tp = tabs.elementAt(index);
+        return getAttackTreeDiagramPanel(tp, indexTab, s);
+    }
+
+    public AttackTreeDiagramPanel getAttackTreeDiagramPanel(TURTLEPanel tp, int indexTab, String s) {
+        if (tp.tabbedPane.getTitleAt(indexTab).equals(s)) {
+            return (AttackTreeDiagramPanel) (tp.panelAt(indexTab));
+        }
+        return null;
+        /*for(int i=0; i<tp.tabbedPane.getTabCount(); i++) {
+          if (tp.tabbedPane.getTitleAt(indexTab).equals(s)) {
+          if (tp.panelAt(i) instanceof AttackTreeDiagramPanel)
+          return  (AttackTreeDiagramPanel)(tp.panelAt(i));
+          }
+          }
+          return null;*/
+    }
+
+    public FaultTreeDiagramPanel getFaultTreeDiagramPanel(int index, int indexTab, String s) {
+        //TraceManager.addDev("Searching for " + s);
+        TURTLEPanel tp = tabs.elementAt(index);
+        return getFaultTreeDiagramPanel(tp, indexTab, s);
+    }
+
+    public FaultTreeDiagramPanel getFaultTreeDiagramPanel(TURTLEPanel tp, int indexTab, String s) {
+        if (tp.tabbedPane.getTitleAt(indexTab).equals(s)) {
+            return (FaultTreeDiagramPanel) (tp.panelAt(indexTab));
+        }
+        return null;
+        /*for(int i=0; i<tp.tabbedPane.getTabCount(); i++) {
+          if (tp.tabbedPane.getTitleAt(indexTab).equals(s)) {
+          if (tp.panelAt(i) instanceof AttackTreeDiagramPanel)
+          return  (AttackTreeDiagramPanel)(tp.panelAt(i));
+          }
+          }
+          return null;*/
+    }
+
+
+    public TMLCPPanel getTMLCPDiagramPanel(int index, String s) {
+        //TraceManager.addDev("Searching for " + s);
+        TURTLEPanel tp = tabs.elementAt(index);
+        return getTMLCPDiagramPanel(tp, s);
+    }
+
+    public TMLCPPanel getTMLCPDiagramPanel(TURTLEPanel tp, String s) {
+        for (int i = 0; i < tp.tabbedPane.getTabCount(); i++) {
+            if (tp.tabbedPane.getTitleAt(i).equals(s)) {
+                if (tp.panelAt(i) instanceof TMLCPPanel)
+                    return (TMLCPPanel) (tp.panelAt(i));
+            }
+        }
+        return null;
+    }
+
+    public TMLSDPanel getTMLCPSDDiagramPanel(int index, String s) {
+        //TraceManager.addDev("Searching for " + s);
+        TURTLEPanel tp = tabs.elementAt(index);
+        return getTMLCPSDDiagramPanel(tp, s);
+    }
+
+    public TMLSDPanel getTMLCPSDDiagramPanel(TURTLEPanel tp, String s) {
+        for (int i = 0; i < tp.tabbedPane.getTabCount(); i++) {
+            if (tp.tabbedPane.getTitleAt(i).equals(s)) {
+                if (tp.panelAt(i) instanceof TMLSDPanel)
+                    return (TMLSDPanel) (tp.panelAt(i));
+            }
+        }
+        return null;
+    }
+
+    public InteractionOverviewDiagramPanel getIODiagramPanel(int index, String s) {
+        //TraceManager.addDev("Searching for " + s);
+        TURTLEPanel tp = tabs.elementAt(index);
+        return getIODiagramPanel(tp, s);
+    }
+
+    public ui.sd.SequenceDiagramPanel getSequenceDiagramPanel(TURTLEPanel tp, String s) {
+        for (int i = 0; i < tp.tabbedPane.getTabCount(); i++) {
+            if (tp.tabbedPane.getTitleAt(i).equals(s)) {
+                if (tp.panelAt(i) instanceof ui.sd.SequenceDiagramPanel)
+                    return (ui.sd.SequenceDiagramPanel) (tp.panelAt(i));
+            }
+        }
+        return null;
+    }
+
+    public ui.sd2.SequenceDiagramPanel getSequenceDiagramPanelZV(TURTLEPanel tp, String s) {
+        for (int i = 0; i < tp.tabbedPane.getTabCount(); i++) {
+            if (tp.tabbedPane.getTitleAt(i).equals(s)) {
+                if (tp.panelAt(i) instanceof ui.sd2.SequenceDiagramPanel)
+                    return (ui.sd2.SequenceDiagramPanel) (tp.panelAt(i));
+            }
+        }
+        return null;
+    }
+
+    public InteractionOverviewDiagramPanel getIODiagramPanel(TURTLEPanel tp, String s) {
+        for (int i = 0; i < tp.tabbedPane.getTabCount(); i++) {
+            if (tp.tabbedPane.getTitleAt(i).equals(s)) {
+                if (tp.panelAt(i) instanceof InteractionOverviewDiagramPanel)
+                    return (InteractionOverviewDiagramPanel) (tp.panelAt(i));
+            }
+        }
+        return null;
+    }
+
+    public UseCaseDiagramPanel getUseCaseDiagramPanel(int index, int indexTab, String s) {
+        //TraceManager.addDev("Searching for " + s + " at index =" + index);
+        TURTLEPanel tp = tabs.elementAt(index);
+        return getUseCaseDiagramPanel(tp, indexTab, s);
+    }
+
+    public UseCaseDiagramPanel getUseCaseDiagramPanel(TURTLEPanel tp, int indexTab, String s) {
+        if (tp.tabbedPane.getTitleAt(indexTab).equals(s)) {
+            return (UseCaseDiagramPanel) (tp.panelAt(indexTab));
+        }
+        return null;
+    }
+
+    public boolean createSequenceDiagram(int index, String s) {
+        return createSequenceDiagram(tabs.elementAt(index), s);
+    }
+
+    public boolean createSequenceDiagram(TURTLEPanel tp, String s) {
+        if (isSDCreated(tp, s)) {
+            return false;
+        }
+
+        if (!((tp instanceof AnalysisPanel) || (tp instanceof AvatarAnalysisPanel))) {
+            return false;
+        }
+
+        if (tp instanceof AnalysisPanel) {
+            ((AnalysisPanel) tp).addSequenceDiagram(s);
+        } else if (tp instanceof AvatarAnalysisPanel) {
+            ((AvatarAnalysisPanel) tp).addSequenceDiagram(s);
+        }
+        setPanelMode();
+        return true;
+    }
+
+    public boolean createSequenceDiagramZV(int index, String s) {
+        return createSequenceDiagramZV(tabs.elementAt(index), s);
+    }
+
+    public boolean createSequenceDiagramZV(TURTLEPanel tp, String s) {
+        if (isSDCreated(tp, s)) {
+            return false;
+        }
+
+        if (!((tp instanceof AnalysisPanel) || (tp instanceof AvatarAnalysisPanel))) {
+            return false;
+        }
+
+        if (tp instanceof AnalysisPanel) {
+            ((AnalysisPanel) tp).addSequenceDiagramZV(s);
+        } else if (tp instanceof AvatarAnalysisPanel) {
+            ((AvatarAnalysisPanel) tp).addSequenceDiagramZV(s);
+        }
+        setPanelMode();
+        return true;
+    }
+
+    public boolean createUniqueSequenceDiagram(TURTLEPanel tp, String s) {
+        int i;
+        for (i = 0; i < 1000; i++) {
+            if (!isSDCreated(tp, s + i)) {
+                break;
+            }
+        }
+
+        if (tp instanceof AnalysisPanel) {
+            ((AnalysisPanel) tp).addSequenceDiagram(s + i);
+        } else if (tp instanceof AvatarAnalysisPanel) {
+            ((AvatarAnalysisPanel) tp).addSequenceDiagram(s + i);
+        }
+
+        setPanelMode();
+        return true;
+    }
+
+
+    public boolean createUniqueSequenceDiagramZV(TURTLEPanel tp, String s) {
+        int i;
+        for (i = 0; i < 1000; i++) {
+            if (!isSDCreated(tp, s + i)) {
+                break;
+            }
+        }
+
+        if (tp instanceof AnalysisPanel) {
+            ((AnalysisPanel) tp).addSequenceDiagramZV(s + i);
+        } else if (tp instanceof AvatarAnalysisPanel) {
+            ((AvatarAnalysisPanel) tp).addSequenceDiagramZV(s + i);
+        }
+
+        setPanelMode();
+        return true;
+    }
+
+    public boolean createSequenceDiagramFromUCD(TURTLEPanel tp, String s, UseCaseDiagramPanel _ucdp) {
+        if (!createUniqueSequenceDiagramZV(tp, s)) {
+            return false;
+        }
+
+        if (!((tp instanceof AnalysisPanel) || (tp instanceof AvatarAnalysisPanel))) {
+            return false;
+        }
+
+        if (tp instanceof AnalysisPanel) {
+            ((AnalysisPanel) tp).addInstancesToLastSD(_ucdp);
+        } else if (tp instanceof AvatarAnalysisPanel) {
+            ((AvatarAnalysisPanel) tp).addInstancesToLastSD(_ucdp);
+        }
+
+        return true;
+    }
+
+
+    public boolean createIODiagram(int index, String s) {
+        return createIODiagram(tabs.elementAt(index), s);
+    }
+
+    public boolean createIODiagram(TURTLEPanel tp, String s) {
+        if (isIODCreated(tp, s)) {
+            return false;
+        }
+
+        if (!(tp instanceof AnalysisPanel)) {
+            return false;
+        }
+
+        ((AnalysisPanel) tp).addIODiagram(s);
+        setPanelMode();
+        return true;
+    }
+
+    public boolean createUseCaseDiagram(int index, String s) {
+        return createUseCaseDiagram(tabs.elementAt(index), s);
+    }
+
+    public boolean createUniqueUseCaseDiagram(TURTLEPanel tp, String s) {
+        if (!((tp instanceof AnalysisPanel) || (tp instanceof AvatarAnalysisPanel))) {
+            return false;
+        }
+
+        int i;
+        for (i = 0; i < 1000; i++) {
+            if (!isUseCaseDiagramCreated(tp, s + " " + i)) {
+                break;
+            }
+        }
+
+        if (tp instanceof AnalysisPanel) {
+            ((AnalysisPanel) tp).addUseCaseDiagram(s + " " + i);
+        } else {
+            ((AvatarAnalysisPanel) tp).addUseCaseDiagram(s + " " + i);
+        }
+        setPanelMode();
+        return true;
+    }
+
+    public boolean createUseCaseDiagram(TURTLEPanel tp, String s) {
+        if (!((tp instanceof AnalysisPanel) || (tp instanceof AvatarAnalysisPanel))) {
+            return false;
+        }
+
+        if (tp instanceof AnalysisPanel) {
+            ((AnalysisPanel) tp).addUseCaseDiagram(s);
+        } else {
+            ((AvatarAnalysisPanel) tp).addUseCaseDiagram(s);
+        }
+        setPanelMode();
+        return true;
+    }
+
+    public boolean createAvatarCD(int index, String s) {
+        return createAvatarCD(tabs.elementAt(index), s);
+    }
+
+    public boolean createUniqueAvatarCD(TURTLEPanel tp, String s) {
+        if (!(tp instanceof AvatarAnalysisPanel)) {
+            return false;
+        }
+
+        int i;
+        for (i = 0; i < 1000; i++) {
+            if (!isAvatarCDCreated(tp, s + " " + i)) {
+                break;
+            }
+        }
+
+        ((AvatarAnalysisPanel) tp).addAvatarContextDiagram(s + " " + i);
+
+
+        setPanelMode();
+        return true;
+    }
+
+    public boolean createAvatarCD(TURTLEPanel tp, String s) {
+        if (!(tp instanceof AvatarAnalysisPanel)) {
+            return false;
+        }
+
+
+        ((AvatarAnalysisPanel) tp).addAvatarContextDiagram(s);
+
+
+        setPanelMode();
+        return true;
+    }
+
+    public boolean createAvatarAD(int index, String s) {
+        return createAvatarAD(tabs.elementAt(index), s);
+    }
+
+    public boolean createUniqueAvatarAD(TURTLEPanel tp, String s) {
+        if (!(tp instanceof AvatarAnalysisPanel)) {
+            return false;
+        }
+
+        int i;
+        for (i = 0; i < 1000; i++) {
+            if (!isAvatarADCreated(tp, s + " " + i)) {
+                break;
+            }
+        }
+
+        ((AvatarAnalysisPanel) tp).addAvatarActivityDiagram(s + " " + i);
+        setPanelMode();
+        return true;
+    }
+
+    public boolean createAvatarAD(TURTLEPanel tp, String s) {
+        if (!(tp instanceof AvatarAnalysisPanel)) {
+            return false;
+        }
+
+
+        ((AvatarAnalysisPanel) tp).addAvatarActivityDiagram(s);
+
+        setPanelMode();
+        return true;
+    }
+
+    //Changed by Solange from public boolean...
+    public String createProActiveSMD(int index, String s) {
+        //Adde by Solange String name at  the beginning
+        String name = createProActiveSMD(tabs.elementAt(index), s);
+        return (name); //changed from return true
+    }
+
+    //Return changed by Solange from boolean to String
+    public String createProActiveSMD(TURTLEPanel tp, String s) {
+
+        //Added by Solange. It fills the lists of components, interfaces, etc
+        TURTLEPanel tp2 = getCurrentTURTLEPanel();
+        gtm.generateLists((ProactiveDesignPanel) tp2);
+        //
+
+        if (!(tp instanceof ProactiveDesignPanel)) {
+            return null; //Changed by Solange from return false
+        }
+
+        s = ((ProactiveDesignPanel) tp).addSMD(s);
+        //Added by Solange
+        //  ProactiveSMDPanel temp=((ProactiveDesignPanel)tp).getSMDPanel(s);
+        //Added by Solange
+        //And removed by Emil
+
+        /*
+          LinkedList cmps=gtm.gpdtemp.getProCSDComponentsList();
+          for (int i=0;i<cmps.size();i++)
+          {
+          ProCSDComponent c = (ProCSDComponent)cmps.get(i);
+
+          if (c.getType()== TGComponentManager.PROCSD_COMPONENT)
+          {
+          if(c.getComponentID().equals(temp.getName()))
+          {
+          c.mySMD=temp;
+          i=cmps.size();
+          }
+          }
+          }
+        */
+        //
+        setPanelMode();
+        return (s); //Changes by Solange from return true
+    }
+
+    public boolean createAvatarRD(int index, String s) {
+        return createAvatarRD(tabs.elementAt(index), s);
+    }
+
+    public boolean createAvatarRD(TURTLEPanel tp, String s) {
+        if (!(tp instanceof AvatarRequirementPanel)) {
+            return false;
+        }
+
+        ((AvatarRequirementPanel) tp).addAvatarRD(s);
+        setPanelMode();
+        return true;
+    }
+
+    public boolean createAvatarMAD(int index, String s) {
+        return createAvatarMAD(tabs.elementAt(index), s);
+    }
+
+    public boolean createAvatarMAD(TURTLEPanel tp, String s) {
+        if (!(tp instanceof AvatarMADsPanel)) {
+            return false;
+        }
+
+        ((AvatarMADsPanel) tp).addAvatarMADPanel(s);
+        setPanelMode();
+        return true;
+    }
+
+    public boolean createAvatarPD(int index, String s) {
+        return createAvatarPD(tabs.elementAt(index), s);
+    }
+
+    public boolean createAvatarPD(TURTLEPanel tp, String s) {
+        if (!(tp instanceof AvatarRequirementPanel)) {
+            return false;
+        }
+
+        ((AvatarRequirementPanel) tp).addAvatarPD(s);
+        setPanelMode();
+        return true;
+    }
+
+    public boolean createADDDiagram(int index, String s) {
+        return createADDDiagram(tabs.elementAt(index), s);
+    }
+
+    public boolean createADDDiagram(TURTLEPanel tp, String s) {
+        if (!(tp instanceof ADDPanel)) {
+            return false;
+        }
+
+        ((ADDPanel) tp).addDeploymentPanelDiagram(s);
+        setPanelMode();
+        return true;
+    }
+
+
+    public boolean isRequirementCreated(int index, String s) {
+        return isRequirementCreated(tabs.elementAt(index), s);
+    }
+
+    public boolean isRequirementCreated(TURTLEPanel tp, String s) {
+        int index = tp.tabbedPane.indexOfTab(s);
+        if (index == -1) {
+            return false;
+        }
+        return (tp.panelAt(index) instanceof RequirementDiagramPanel);
+    }
+
+    public boolean createRequirementDiagram(int index, String s) {
+        return createRequirementDiagram(tabs.elementAt(index), s);
+    }
+
+    public boolean createRequirementDiagram(TURTLEPanel tp, String s) {
+        if (!(tp instanceof RequirementPanel)) {
+            return false;
+        }
+
+        ((RequirementPanel) tp).addRequirementDiagram(s);
+        setPanelMode();
+        return true;
+    }
+
+    public boolean createAttackTreeDiagram(int index, String s) {
+        return createAttackTreeDiagram(tabs.elementAt(index), s);
+    }
+
+    public boolean createAttackTreeDiagram(TURTLEPanel tp, String s) {
+        if (!(tp instanceof AttackTreePanel)) {
+            return false;
+        }
+
+        ((AttackTreePanel) tp).addAttackTreeDiagram(s);
+        setPanelMode();
+        return true;
+    }
+
+    public boolean createFaultTreeDiagram(int index, String s) {
+        return createFaultTreeDiagram(tabs.elementAt(index), s);
+    }
+
+    public boolean createFaultTreeDiagram(TURTLEPanel tp, String s) {
+        if (!(tp instanceof FaultTreePanel)) {
+            return false;
+        }
+
+        ((FaultTreePanel) tp).addFaultTreeDiagram(s);
+        setPanelMode();
+        return true;
+    }
+
+    public boolean createEBRDD(int index, String s) {
+        return createEBRDD(tabs.elementAt(index), s);
+    }
+
+    public boolean createEBRDD(TURTLEPanel tp, String s) {
+        if (!(tp instanceof RequirementPanel)) {
+            return false;
+        }
+
+        ((RequirementPanel) tp).addEBRDD(s);
+        setPanelMode();
+        return true;
+    }
+
+    public void generateOntologyForCurrentDiagram() {
+        TraceManager.addDev("Ontology for current diagram");
+        try {
+            TURTLEPanel tp = getCurrentTURTLEPanel();
+            String modeling = gtm.makeOneDiagramXMLFromGraphicalModel(tp, tp.tabbedPane.getSelectedIndex());
+            TraceManager.addDev("Model made: " + modeling);
+        } catch (Exception e) {
+        }
+
+    }
+
+    public void generateOntologyForCurrentSetOfDiagrams() {
+        TraceManager.addDev("Ontology for current set of diagrams");
+        try {
+            String modeling = gtm.makeXMLFromTurtleModeling(mainTabbedPane.getSelectedIndex());
+            TraceManager.addDev("Model made: " + modeling);
+        } catch (Exception e) {
+        }
+
+    }
+
+    public void generateOntologyForAllDiagrams() {
+        TraceManager.addDev("Ontology for all diagrams");
+        try {
+            /*String modeling =*/
+            gtm.makeXMLFromTurtleModeling(-1);
+            TraceManager.addDev("Model made");
+        } catch (Exception e) {
+        }
+
+    }
+
+
+    public AvatarRDPanel getAvatarRDPanel(int index, int indexTab, String s) {
+        TURTLEPanel tp = tabs.elementAt(index);
+        return getAvatarRDPanel(tp, indexTab, s);
+    }
+
+    public AvatarRDPanel getAvatarRDPanel(TURTLEPanel tp, int indexTab, String s) {
+        if (tp.tabbedPane.getTitleAt(indexTab).equals(s)) {
+            return (AvatarRDPanel) (tp.panelAt(indexTab));
+        }
+        return null;
+    }
+
+    public AvatarMADPanel getAvatarMADPanel(int index, int indexTab, String s) {
+        TURTLEPanel tp = tabs.elementAt(index);
+        return getAvatarMADPanel(tp, indexTab, s);
+    }
+
+    public AvatarMADPanel getAvatarMADPanel(TURTLEPanel tp, int indexTab, String s) {
+        if (tp.tabbedPane.getTitleAt(indexTab).equals(s)) {
+            return (AvatarMADPanel) (tp.panelAt(indexTab));
+        }
+        return null;
+    }
+
+    public AvatarPDPanel getAvatarPDPanel(int index, int indexTab, String s) {
+        TURTLEPanel tp = tabs.elementAt(index);
+        return getAvatarPDPanel(tp, indexTab, s);
+    }
+
+    public ADDDiagramPanel getAvatarADDPanel(int index, int indexTab, String s) {
+        TURTLEPanel tp = tabs.elementAt(index);
+        return getAvatarADDPanel(tp, indexTab, s);
+    }
+
+    public ADDDiagramPanel getAvatarADDPanelByIndex(int index, int indexTab) {
+        TURTLEPanel tp = tabs.elementAt(index);
+        return getAvatarADDPanelByIndex(tp, indexTab);
+    }
+
+
+    public AvatarPDPanel getAvatarPDPanel(TURTLEPanel tp, int indexTab, String s) {
+        if (tp.tabbedPane.getTitleAt(indexTab).equals(s)) {
+            return (AvatarPDPanel) (tp.panelAt(indexTab));
+        }
+        return null;
+    }
+
+    public ADDDiagramPanel getAvatarADDPanel(TURTLEPanel tp, int indexTab, String s) {
+        TraceManager.addDev("index=" + indexTab + " s=" + s + "title=" + tp.tabbedPane.getTitleAt(indexTab));
+
+        if (tp.tabbedPane.getTitleAt(indexTab).equals(s)) {
+            return (ADDDiagramPanel) (tp.panelAt(indexTab));
+        }
+        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 = tabs.elementAt(index);
+        return getAvatarCDPanel(tp, indexTab, s);
+    }
+
+
+    public AvatarCDPanel getAvatarCDPanel(TURTLEPanel tp, int indexTab, String s) {
+        if (tp.tabbedPane.getTitleAt(indexTab).equals(s)) {
+            return (AvatarCDPanel) (tp.panelAt(indexTab));
+        }
+        return null;
+    }
+
+    public AvatarADPanel getAvatarADPanel(int index, int indexTab, String s) {
+        TURTLEPanel tp = tabs.elementAt(index);
+        return getAvatarADPanel(tp, indexTab, s);
+    }
+
+
+    public AvatarADPanel getAvatarADPanel(TURTLEPanel tp, int indexTab, String s) {
+        if (tp.tabbedPane.getTitleAt(indexTab).equals(s)) {
+            return (AvatarADPanel) (tp.panelAt(indexTab));
+        }
+        return null;
+    }
+
+    public RequirementDiagramPanel getRequirementDiagramPanel(int index, String s) {
+        //TraceManager.addDev("Searching for " + s);
+        TURTLEPanel tp = tabs.elementAt(index);
+        return getRequirementDiagramPanel(tp, s);
+    }
+
+    public RequirementDiagramPanel getRequirementDiagramPanel(TURTLEPanel tp, String s) {
+        for (int i = 0; i < tp.tabbedPane.getTabCount(); i++) {
+            if (tp.tabbedPane.getTitleAt(i).equals(s)) {
+                if (tp.panelAt(i) instanceof RequirementDiagramPanel)
+                    return (RequirementDiagramPanel) (tp.panelAt(i));
+            }
+        }
+        return null;
+    }
+
+    public RequirementDiagramPanel getRequirementDiagramPanel(int index, int indexTab, String s) {
+        TURTLEPanel tp = tabs.elementAt(index);
+        return getRequirementDiagramPanel(tp, indexTab, s);
+    }
+
+
+    public RequirementDiagramPanel getRequirementDiagramPanel(TURTLEPanel tp, int indexTab, String s) {
+        if (tp.tabbedPane.getTitleAt(indexTab).equals(s)) {
+            return (RequirementDiagramPanel) (tp.panelAt(indexTab));
+        }
+        return null;
+    }
+
+    public EBRDDPanel getEBRDDPanel(int index, String s) {
+        //TraceManager.addDev("Searching for " + s);
+        TURTLEPanel tp = tabs.elementAt(index);
+        return getEBRDDPanel(tp, s);
+    }
+
+    public EBRDDPanel getEBRDDPanel(TURTLEPanel tp, String s) {
+        for (int i = 0; i < tp.tabbedPane.getTabCount(); i++) {
+            if (tp.tabbedPane.getTitleAt(i).equals(s)) {
+                if (tp.panelAt(i) instanceof EBRDDPanel)
+                    return (EBRDDPanel) (tp.panelAt(i));
+            }
+        }
+        return null;
+    }
+
+    public EBRDDPanel getEBRDDPanel(int index, int indexTab, String s) {
+        TURTLEPanel tp = tabs.elementAt(index);
+        return getEBRDDPanel(tp, indexTab, s);
+    }
+
+
+    public EBRDDPanel getEBRDDPanel(TURTLEPanel tp, int indexTab, String s) {
+        if (tp.tabbedPane.getTitleAt(indexTab).equals(s)) {
+            return (EBRDDPanel) (tp.panelAt(indexTab));
+        }
+        return null;
+    }
+
+    public void alignInstances() {
+        //TraceManager.addDev("Align instances");
+        if (getCurrentTDiagramPanel() instanceof ui.sd.SequenceDiagramPanel) {
+            ((ui.sd.SequenceDiagramPanel) (getCurrentTDiagramPanel())).alignInstances();
+            changeMade(getCurrentTDiagramPanel(), TDiagramPanel.MOVE_COMPONENT);
+            getCurrentTDiagramPanel().repaint();
+        }
+
+        if (getCurrentTDiagramPanel() instanceof ui.sd2.SequenceDiagramPanel) {
+            ((ui.sd2.SequenceDiagramPanel) (getCurrentTDiagramPanel())).alignInstances();
+            changeMade(getCurrentTDiagramPanel(), TDiagramPanel.MOVE_COMPONENT);
+            getCurrentTDiagramPanel().repaint();
+        }
+
+        if (getCurrentTDiagramPanel() instanceof TMLSDPanel) {
+            ((TMLSDPanel) (getCurrentTDiagramPanel())).alignInstances();
+            changeMade(getCurrentTDiagramPanel(), TDiagramPanel.MOVE_COMPONENT);
+            getCurrentTDiagramPanel().repaint();
+        }
+    }
+
+    public void alignPartitions() {
+        //TraceManager.addDev("Align instances");
+        if (getCurrentTDiagramPanel() instanceof AvatarADPanel) {
+            ((AvatarADPanel) (getCurrentTDiagramPanel())).alignPartitions();
+            changeMade(getCurrentTDiagramPanel(), TDiagramPanel.MOVE_COMPONENT);
+            getCurrentTDiagramPanel().repaint();
+        }
+    }
+
+    public void enhanceDiagram() {
+        getCurrentTDiagramPanel().enhance();
+    }
+
+    public JTabbedPane getCurrentJTabbedPane() {
+        return tabs.elementAt(mainTabbedPane.getSelectedIndex()).tabbedPane;
+    }
+
+    public int getCurrentSelectedIndex() {
+        return mainTabbedPane.getSelectedIndex();
+    }
+
+
+    public TDiagramPanel getCurrentTDiagramPanel() {
+        try {
+            TURTLEPanel tp = tabs.elementAt(mainTabbedPane.getSelectedIndex());
+            return tp.panels.elementAt(tp.tabbedPane.getSelectedIndex());
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    public TDiagramPanel getCurrentMainTDiagramPanel() {
+        return tabs.elementAt(mainTabbedPane.getSelectedIndex()).tdp;
+    }
+
+    public void selectDummyTab(int index) {
+        if (this.tabs.size() < index + 1)
+            return;
+        this.dummySelectedTab = this.tabs.elementAt(index);
+    }
+
+    public void forgetDummyTab() {
+        this.dummySelectedTab = null;
+    }
+
+    public TURTLEPanel getCurrentTURTLEPanel() {
+        if (this.dummySelectedTab != null)
+            return this.dummySelectedTab;
+
+        if (tabs.size() == 0) {
+            return null;
+        } else {
+            return tabs.elementAt(mainTabbedPane.getSelectedIndex());
+        }
+    }
+
+
+    public void reinitCountOfPanels() {
+        int i, j;
+        TURTLEPanel tp;
+        for (i = 0; i < mainTabbedPane.getTabCount(); i++) {
+            tp = tabs.elementAt(i);
+            for (j = 0; j < tp.tabbedPane.getTabCount(); j++) {
+                tp.panels.elementAt(j).count = 0;
+            }
+        }
+    }
+
+    public void setPanelMode() {
+        int index;
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        if (tp == null) {
+            TraceManager.addDev("null TP Panel");
+            return;
+        }
+        index = tp.tabbedPane.getSelectedIndex();
+
+        TraceManager.addDev("TP Panel: " + tp + " index=" + index);
+
+        if (index < tp.panels.size() - 1) {
+            setMode(FORWARD_DIAG);
+        } else {
+            setMode(NO_FORWARD_DIAG);
+        }
+
+        if (index > 0) {
+            setMode(BACKWARD_DIAG);
+        } else {
+            setMode(NO_BACKWARD_DIAG);
+        }
+
+        // If no edition panel, we need to deactivate previous diagram and model checking
+
+        if (index == -1) {
+            setMode(MainGUI.CREATE_NEW_PANEL);
+        }
+
+        setMode(METHO_CHANGED);
+
+    }
+
+    public void paneMADAction(ChangeEvent e) {
+        //TraceManager.addDev("Pane design action size=" + tabs.size());
+        try {
+
+            TDiagramPanel tdp1 = getCurrentTURTLEPanel().panels.elementAt(getCurrentJTabbedPane().getSelectedIndex());
+            //TraceManager.addDev("Pane design action 1");
+            if (activetdp != null) {
+                activetdp.activateActions(false);
+                unactivateDrawing();
+                activetdp.stopAddingConnector();
+            }
+            //TraceManager.addDev("Pane design action 1 on "+ tdp1.getName());
+            tdp1.activateActions(true);
+            activetdp = tdp1;
+
+            setEditMode();
+            setPanelMode();
+            //TraceManager.addDev("Pane design action 3");
+
+            // activate the   drawing   of the right pane
+            basicActivateDrawing();
+
+        } catch (Exception ex) {
+            //TraceManager.addDev("Exception pane design action");
+        }
+    }
+
+    public void paneDesignAction(ChangeEvent e) {
+        //TraceManager.addDev("Pane design action size=" + tabs.size());
+        try {
+
+            TDiagramPanel tdp1 = getCurrentTURTLEPanel().panels.elementAt(getCurrentJTabbedPane().getSelectedIndex());
+            //TraceManager.addDev("Pane design action 1");
+            if (activetdp != null) {
+                activetdp.activateActions(false);
+                unactivateDrawing();
+                activetdp.stopAddingConnector();
+            }
+            //TraceManager.addDev("Pane design action 1 on "+ tdp1.getName());
+            tdp1.activateActions(true);
+            activetdp = tdp1;
+
+            setEditMode();
+            setPanelMode();
+            //TraceManager.addDev("Pane design action 3");
+
+            // activate the   drawing   of the right pane
+            basicActivateDrawing();
+
+        } catch (Exception ex) {
+            //TraceManager.addDev("Exception pane design action");
+        }
+    }
+
+    public void paneDiplodocusMethodologyAction(ChangeEvent e) {
+        //TraceManager.addDev("Pane design action size=" + tabs.size());
+        try {
+            TDiagramPanel tdp1 = getCurrentTURTLEPanel().panels.elementAt(getCurrentJTabbedPane().getSelectedIndex());
+            //TraceManager.addDev("Pane design action 1");
+            if (activetdp != null) {
+
+                activetdp.activateActions(false);
+                unactivateDrawing();
+                activetdp.stopAddingConnector();
+            }
+            //TraceManager.addDev("Pane design action 1 on "+ tdp1.getName());
+            tdp1.activateActions(true);
+            activetdp = tdp1;
+
+            setEditMode();
+            setPanelMode();
+            //TraceManager.addDev("Pane design action 3");
+
+            // activate the   drawing   of the right pane
+            basicActivateDrawing();
+
+        } catch (Exception ex) {
+            //TraceManager.addDev("Exception pane design action");
+        }
+    }
+
+    public void paneAvatarMethodologyAction(ChangeEvent e) {
+        //TraceManager.addDev("Pane design action size=" + tabs.size());
+        try {
+
+            TDiagramPanel tdp1 = getCurrentTURTLEPanel().panels.elementAt(getCurrentJTabbedPane().getSelectedIndex());
+            //TraceManager.addDev("Pane design action 1");
+            if (activetdp != null) {
+
+                activetdp.activateActions(false);
+                unactivateDrawing();
+                activetdp.stopAddingConnector();
+            }
+            //TraceManager.addDev("Pane design action 1 on "+ tdp1.getName());
+            tdp1.activateActions(true);
+            activetdp = tdp1;
+
+            setEditMode();
+            setPanelMode();
+            //TraceManager.addDev("Pane design action 3");
+
+            // activate the   drawing   of the right pane
+            basicActivateDrawing();
+
+        } catch (Exception ex) {
+            //TraceManager.addDev("Exception pane design action");
+        }
+    }
+
+    public void paneAnalysisAction(ChangeEvent e) {
+        //TraceManager.addDev("Pane analysis action size=" + tabs.size());
+        try {
+
+            TDiagramPanel tdp1 = getCurrentTURTLEPanel().panels.elementAt(getCurrentJTabbedPane().getSelectedIndex());
+            //TraceManager.addDev("Pane analysis action 1 on " + tdp1.getName());
+            if (activetdp != null) {
+                activetdp.activateActions(false);
+                unactivateDrawing();
+                activetdp.stopAddingConnector();
+            }
+            //TraceManager.addDev("Pane analysis action 2");
+            tdp1.activateActions(true);
+            activetdp = tdp1;
+
+            setEditMode();
+            setPanelMode();
+            //TraceManager.addDev("Pane analysis action 3");
+
+            // activate the   drawing   of the right pane
+            basicActivateDrawing();
+
+        } catch (Exception ex) {
+            //TraceManager.addDev("Exception pane analysis action");
+        }
+    }
+
+    public void paneDeployAction(ChangeEvent e) {
+        //TraceManager.addDev("Pane design action size=" + tabs.size());
+        try {
+
+            TDiagramPanel tdp1 = getCurrentTURTLEPanel().panels.elementAt(getCurrentJTabbedPane().getSelectedIndex());
+            //TraceManager.addDev("Pane design action 1");
+            if (activetdp != null) {
+                activetdp.activateActions(false);
+                unactivateDrawing();
+                activetdp.stopAddingConnector();
+            }
+            //TraceManager.addDev("Pane design action 1 on "+ tdp1.getName());
+            tdp1.activateActions(true);
+            activetdp = tdp1;
+
+            setEditMode();
+            setPanelMode();
+            //TraceManager.addDev("Pane design action 3");
+
+            // activate the   drawing   of the right pane
+            basicActivateDrawing();
+
+        } catch (Exception ex) {
+            //TraceManager.addDev("Exception pane design action");
+        }
+    }
+
+    public void paneRequirementAction(ChangeEvent e) {
+        try {
+
+            TDiagramPanel tdp1 = getCurrentTURTLEPanel().panels.elementAt(getCurrentJTabbedPane().getSelectedIndex());
+            //TraceManager.addDev("Pane design action 1");
+            if (activetdp != null) {
+                activetdp.activateActions(false);
+                unactivateDrawing();
+                activetdp.stopAddingConnector();
+            }
+            //TraceManager.addDev("Pane design action 1 on "+ tdp1.getName());
+            tdp1.activateActions(true);
+            activetdp = tdp1;
+
+            setEditMode();
+            setPanelMode();
+
+            // activate the   drawing   of the right pane
+            basicActivateDrawing();
+
+        } catch (Exception ex) {
+            //TraceManager.addDev("Exception pane design action");
+        }
+    }
+
+    // nameTab : array of strings not to be removed
+    public void removeAnalysisDiagrams(String[] nameTab) {
+        int i, j;
+        String value;
+        boolean found;
+
+        for (i = 1; i < getCurrentJTabbedPane().getTabCount(); i++) {
+            value = getCurrentJTabbedPane().getTitleAt(i);
+            found = false;
+            for (j = 0; j < nameTab.length; j++) {
+                if (nameTab[j] != null) {
+                    if (nameTab[j].compareTo(value) == 0) {
+                        found = true;
+                        break;
+                    }
+
+                }
+            }
+            if (!found) {
+                TraceManager.addDev("Removing" + getCurrentJTabbedPane().getTitleAt(i));
+                getCurrentJTabbedPane().remove(i);
+                getCurrentTURTLEPanel().removeElementAt(i);
+                i--;
+            }
+        }
+    }
+
+    public void renameTab(TDiagramPanel tdp) {
+        String value;
+        int index, index1;
+
+        index = getCurrentJTabbedPane().getSelectedIndex();
+        value = getCurrentJTabbedPane().getTitleAt(index);
+
+        //String s = (String)JOptionPane.showInputDialog(this, "Name of the diagram:", JOptionPane.QUESTION_MESSAGE);
+        String s = (String) JOptionPane.showInputDialog(frame, "Name of the diagram:", "setting value", JOptionPane.PLAIN_MESSAGE, IconManager.imgic101, null, value);
+
+        if ((s != null) && (s.length() > 0)) {
+            // name already in use?
+            index1 = getCurrentJTabbedPane().indexOfTab(s);
+            /*if (methoMode == METHO_ANALYSIS) {
+              index1 = mainAnalysisTabbedPane.indexOfTab(s);
+
+              } else {
+              index1 = getCurrentJTabbedPane.indexOfTab(s);
+
+              }*/
+            if (index1 > -1) {
+                JOptionPane.showMessageDialog(frame, "Name is already in use", "Error", JOptionPane.INFORMATION_MESSAGE);
+            } else {
+                /*if (methoMode == METHO_ANALYSIS) {
+                  mainAnalysisTabbedPane.setTitleAt(index, s);
+                  } else {
+                  mainDesignTabbedPane.setTitleAt(index, s);
+                  }*/
+                if (isAValidTabName(s)) {
+                    JOptionPane.showMessageDialog(frame, "Invalid name", "Error", JOptionPane.INFORMATION_MESSAGE);
+                } else {
+                    getCurrentJTabbedPane().setTitleAt(index, s);
+                    tdp.setName(s);
+                    changeMade(tdp, TDiagramPanel.NEW_COMPONENT);
+                }
+            }
+        }
+    }
+
+    public void deleteTab(TDiagramPanel tdp) {
+        //TraceManager.addDev("Delete");
+
+        // We know the selected tab -> remove this tab
+
+        int index;
+        JTabbedPane jtp = getCurrentJTabbedPane();
+        index = jtp.getSelectedIndex();
+        getCurrentTURTLEPanel().panels.removeElementAt(index);
+        jtp.remove(index);
+
+        // Signal the change
+        changeMade(tdp, TDiagramPanel.CHANGE_VALUE_COMPONENT);
+
+    }
+
+    private void basicActivateDrawing() {
+        activetdp.setDraw(true);
+        if (activetdp.mode == TDiagramPanel.SELECTED_COMPONENTS) {
+            setMode(MainGUI.CUTCOPY_OK);
+            setMode(MainGUI.EXPORT_LIB_OK);
+        } else {
+            setMode(MainGUI.CUTCOPY_KO);
+            setMode(MainGUI.EXPORT_LIB_KO);
+        }
+    }
+
+    private void unactivateDrawing() {
+        activetdp.setDraw(false);
+    }
+
+    public void paneAction(ChangeEvent e) {
+        //TraceManager.addDev("Pane action");
+        TDiagramPanel tdp1 = getCurrentTDiagramPanel();
+        if (tdp1 != null) {
+            //TraceManager.addDev("Stop Adding connector in maingui");
+            tdp1.stopAddingConnector();
+        }
+
+        try {
+            if (getCurrentTURTLEPanel() instanceof DesignPanel) {
+                setMethodologicalMode(METHO_DESIGN);
+                paneDesignAction(e);
+            } else if (getCurrentTURTLEPanel() instanceof AnalysisPanel) {
+                setMethodologicalMode(METHO_ANALYSIS);
+                paneAnalysisAction(e);
+            } else {
+                setMethodologicalMode(METHO_DEPLOY);
+                paneDeployAction(e);
+            }
+
+            if ((getCurrentTURTLEPanel() instanceof AvatarDesignPanel) || (getCurrentTURTLEPanel() instanceof AvatarRequirementPanel) || (getCurrentTURTLEPanel() instanceof AttackTreePanel) || (getCurrentTURTLEPanel() instanceof FaultTreePanel) || (getCurrentTURTLEPanel() instanceof ADDPanel)) {
+                mainBar.showAvatarActions(true);
+            } else if ((getCurrentTURTLEPanel() instanceof TMLDesignPanel) || (getCurrentTURTLEPanel() instanceof TMLComponentDesignPanel) || (getCurrentTURTLEPanel() instanceof TMLArchiPanel)) {
+                mainBar.showDiplodocusActions(true);
+            } else {
+                mainBar.showAvatarActions(false);
+            }
+
+            setMode(PANEL_CHANGED);
+
+            setEditMode();
+            setPanelMode();
+
+
+        } catch (Exception ex) {
+            //TraceManager.addDev("Exception pane action: " + ex.getMessage());
+        }
+    }
+
+    public JFrame getFrame() {
+        return frame;
+    }
+
+    public boolean newTClassName(TURTLEPanel tp, String old, String niou) {
+        JTabbedPane jtp = tp.tabbedPane;
+        for (int i = 0; i < jtp.getTabCount(); i++) {
+            if (jtp.getTitleAt(i).equals(niou)) {
+                return false;
+            }
+        }
+        //TraceManager.addDev("old " + old + " niou " + niou);
+        for (int i = 0; i < jtp.getTabCount(); i++) {
+            //TraceManager.addDev("Tab " + i + " = " + mainTabbedPane.getTitleAt(i));
+            if (jtp.getTitleAt(i).equals(old)) {
+                jtp.setTitleAt(i, niou);
+                jtp.setToolTipTextAt(i, "Opens the activity diagram of " + niou);
+                TDiagramPanel tdp;
+                //change panel name
+                for (int j = 0; j < tp.panels.size(); j++) {
+                    tdp = tp.panels.elementAt(j);
+                    if (tdp.getName().equals(old)) {
+                        tdp.setName(niou);
+                    }
+                }
+
+                return true;
+            }
+        }
+        // internal error
+        ErrorGUI.exit(ErrorGUI.ERROR_TAB);
+        return false;
+    }
+
+    public boolean newTOSClassName(TURTLEPanel tp, String old, String niou) {
+        JTabbedPane jtp = tp.tabbedPane;
+        for (int i = 0; i < jtp.getTabCount(); i++) {
+            if (jtp.getTitleAt(i).equals(niou)) {
+                return false;
+            }
+        }
+        //TraceManager.addDev("old " + old + " niou " + niou);
+        for (int i = 0; i < jtp.getTabCount(); i++) {
+            //TraceManager.addDev("Tab " + i + " = " + mainTabbedPane.getTitleAt(i));
+            if (jtp.getTitleAt(i).equals(old)) {
+                jtp.setTitleAt(i, niou);
+                jtp.setToolTipTextAt(i, "Opens the TURTLE-OS activity diagram of " + niou);
+                TDiagramPanel tdp;
+                //change panel name
+                for (int j = 0; j < tp.panels.size(); j++) {
+                    tdp = tp.panels.elementAt(j);
+                    if (tdp.getName().equals(old)) {
+                        tdp.setName(niou);
+                    }
+                }
+
+                return true;
+            }
+        }
+        // internal error
+        ErrorGUI.exit(ErrorGUI.ERROR_TAB);
+        return false;
+    }
+
+    public boolean newTMLTaskName(TURTLEPanel tp, String old, String niou) {
+        //TraceManager.addDev("Panel=" + tp + " Old  task name = " + old + " New task name=" + niou);
+        JTabbedPane jtp = tp.tabbedPane;
+        for (int i = 0; i < jtp.getTabCount(); i++) {
+            //TraceManager.addDev("jtp  = " + jtp.getTitleAt(i));
+            if (jtp.getTitleAt(i).equals(niou)) {
+                return false;
+            }
+        }
+        //TraceManager.addDev("old " + old + " niou " + niou);
+        for (int i = 0; i < jtp.getTabCount(); i++) {
+            //TraceManager.addDev("Tab " + i + " = " + mainTabbedPane.getTitleAt(i));
+            //TraceManager.addDev("jtp  = " + jtp.getTitleAt(i));
+            if (jtp.getTitleAt(i).equals(old)) {
+                jtp.setTitleAt(i, niou);
+                jtp.setToolTipTextAt(i, "Opens the TML activity diagram of " + niou);
+                TDiagramPanel tdp;
+                //change panel name
+                for (int j = 0; j < tp.panels.size(); j++) {
+                    tdp = tp.panels.elementAt(j);
+                    if (tdp.getName().equals(old)) {
+                        tdp.setName(niou);
+                        //TraceManager.addDev("Renamed to " + niou);
+                    }
+                }
+
+                return true;
+            }
+        }
+        // internal error
+        ErrorGUI.exit(ErrorGUI.ERROR_TAB);
+        return false;
+    }
+
+    public boolean nameComponentInUse(TURTLEPanel tp, String old, String niou) {
+        JTabbedPane jtp = tp.tabbedPane;
+        for (int i = 0; i < jtp.getTabCount(); i++) {
+            if (jtp.getTitleAt(i).equals(niou)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public boolean newTMLComponentTaskName(TURTLEPanel tp, String old, String niou) {
+        JTabbedPane jtp = tp.tabbedPane;
+        for (int i = 0; i < jtp.getTabCount(); i++) {
+            if (jtp.getTitleAt(i).equals(niou)) {
+                return false;
+            }
+        }
+        TraceManager.addDev("old " + old + " niou " + niou);
+        for (int i = 0; i < jtp.getTabCount(); i++) {
+            TraceManager.addDev("Tab " + i + " = " + mainTabbedPane.getTitleAt(i));
+            if (jtp.getTitleAt(i).equals(old)) {
+                jtp.setTitleAt(i, niou);
+                jtp.setToolTipTextAt(i, "Opens the TML activity diagram of " + niou);
+                TDiagramPanel tdp;
+                //change panel name
+                for (int j = 0; j < tp.panels.size(); j++) {
+                    tdp = tp.panels.elementAt(j);
+                    if (tdp.getName().equals(old)) {
+                        tdp.setName(niou);
+                    }
+                }
+
+                return true;
+            }
+        }
+        // internal error
+        ErrorGUI.exit(ErrorGUI.ERROR_TAB);
+        return false;
+    }
+
+    public void cloneTab(int index) {
+        String s = gtm.makeXMLFromTurtleModeling(index, "_cloned");
+        try {
+            gtm.loadModelingFromXML(s);
+            changeMade(null, -1);
+        } catch (MalformedModelingException mme) {
+            JOptionPane.showMessageDialog(frame, "Modeling could not be loaded (unsupported file) ", "Error when loading modeling", JOptionPane.INFORMATION_MESSAGE);
+            frame.setTitle("TTool: unamed project");
+        }
+
+    }
+
+    public void cloneRenameTab(int index, String s) {
+        cloneTab(index);
+        mainTabbedPane.setTitleAt(tabs.size() - 1, mainTabbedPane.getTitleAt(index) + "_" + s);
+    }
+
+    public void requestRemoveTab(int index) {
+        if (index >= tabs.size()) {
+            return;
+        }
+
+        tabs.removeElementAt(index);
+        mainTabbedPane.remove(index);
+        changeMade(null, -1);
+    }
+
+    public void requestMoveRightTab(int index) {
+        //TraceManager.addDev("Move right");
+        if (index > tabs.size() - 2) {
+            return;
+        }
+        requestMoveTabFromTo(index, index + 1);
+        changeMade(null, -1);
+    }
+
+    public void requestMoveLeftTab(int index) {
+        //TraceManager.addDev("Move left");
+        if (index < 1) {
+            return;
+        }
+        requestMoveTabFromTo(index, index - 1);
+        changeMade(null, -1);
+    }
+
+    public void requestMoveTabFromTo(int src, int dst) {
+
+        // Get all the properties
+        Component comp = mainTabbedPane.getComponentAt(src);
+        String label = mainTabbedPane.getTitleAt(src);
+        Icon icon = mainTabbedPane.getIconAt(src);
+        Icon iconDis = mainTabbedPane.getDisabledIconAt(src);
+        String tooltip = mainTabbedPane.getToolTipTextAt(src);
+        boolean enabled = mainTabbedPane.isEnabledAt(src);
+        int keycode = mainTabbedPane.getMnemonicAt(src);
+        int mnemonicLoc = mainTabbedPane.getDisplayedMnemonicIndexAt(src);
+        Color fg = mainTabbedPane.getForegroundAt(src);
+        Color bg = mainTabbedPane.getBackgroundAt(src);
+
+        // Remove the tab
+        mainTabbedPane.remove(src);
+
+        // Add a new tab
+        mainTabbedPane.insertTab(label, icon, comp, tooltip, dst);
+
+        // Restore all properties
+        mainTabbedPane.setDisabledIconAt(dst, iconDis);
+        mainTabbedPane.setEnabledAt(dst, enabled);
+        mainTabbedPane.setMnemonicAt(dst, keycode);
+        mainTabbedPane.setDisplayedMnemonicIndexAt(dst, mnemonicLoc);
+        mainTabbedPane.setForegroundAt(dst, fg);
+        mainTabbedPane.setBackgroundAt(dst, bg);
+
+        TURTLEPanel o = tabs.elementAt(src);
+        tabs.removeElementAt(src);
+        tabs.insertElementAt(o, dst);
+
+        mainTabbedPane.setSelectedIndex(dst);
+    }
+
+    public void requestRenameTab(int index) {
+        String oldName = mainTabbedPane.getTitleAt(index);
+        String s = (String) JOptionPane.showInputDialog(frame, "Name: ", "Renaming a tab", JOptionPane.PLAIN_MESSAGE, IconManager.imgic101, null, mainTabbedPane.getTitleAt(index));
+        if ((s != null) && (s.length() > 0)) {
+            // name already in use?
+            if (s.compareTo(oldName) != 0) {
+                if (isAValidTabName(s) && (!isTabNameUsed(s))) {
+                    renameInMethodo(mainTabbedPane.getTitleAt(index), s);
+                    mainTabbedPane.setTitleAt(index, s);
+                    changeMade(getCurrentTDiagramPanel(), /*((TURTLEPanel)(tabs.elementAt(index))).tdp*/TDiagramPanel.MOVE_COMPONENT);
+
+                    TURTLEPanel tp = tabs.elementAt(index);
+                    if ((tp instanceof TMLDesignPanel) || (tp instanceof TMLComponentDesignPanel)) {
+                        renameMapping(oldName, s);
+                    }
+                } else {
+                    JOptionPane.showMessageDialog(frame, "Invalid name", "Error", JOptionPane.INFORMATION_MESSAGE);
+                }
+
+            }
+        }
+        changeMade(null, -1);
+    }
+
+    /**
+     * Check if a name is already used by another TURTLEPanel tab
+     *
+     * @param name
+     * @return true if the name matches another tab name
+     * @author Fabien Tessier
+     */
+    public boolean isTabNameUsed(String name) {
+        for (int i = 0; i < mainTabbedPane.getTabCount(); i++) {
+            if (mainTabbedPane.getTitleAt(i).equals(name))
+                return true;
+        }
+        return false;
+    }
+
+    /**
+     * Rename reference to the tab in Diplodocus Methodology
+     *
+     * @param oldname
+     * @param newname
+     * @author Fabien Tessier
+     */
+    public void renameInMethodo(String oldname, String newname) {
+        for (TURTLEPanel tp : tabs) {
+            if (tp instanceof DiplodocusMethodologyPanel) {
+                DiplodocusMethodologyDiagramPanel dmdp = (DiplodocusMethodologyDiagramPanel) tp.tdp;
+                for (TGComponent tgc : dmdp.componentList)
+                    for (TGComponent tgc2 : tgc.tgcomponent) {
+                        if (tgc2.getValue().equals(oldname))
+                            tgc2.setValue(newname);
+                    }
+            }
+        }
+    }
+
+    public void renameMapping(String oldName, String newName) {
+        TURTLEPanel tp;
+
+        for (int i = 0; i < mainTabbedPane.getTabCount(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof TMLArchiPanel) {
+                ((TMLArchiPanel) tp).renameMapping(oldName, newName);
+            }
+        }
+
+    }
+
+    public void renameDeployment(String oldName, String newName) {
+        TURTLEPanel tp;
+
+        for (int i = 0; i < mainTabbedPane.getTabCount(); i++) {
+            tp = tabs.elementAt(i);
+            if (tp instanceof ADDPanel) {
+                ((ADDPanel) tp).renameDeployment(oldName, newName);
+            }
+        }
+
+    }
+
+    public boolean selectTDiagramPanel(TDiagramPanel tdp) {
+        return (selectTab(getPoint(tdp)) == tdp);
+    }
+
+    public boolean selectTab(TURTLEPanel tp, String s) {
+        int j;
+        int index1 = tabs.indexOf(tp);
+
+        if (mainTabbedPane.getSelectedIndex() != index1) {
+            mainTabbedPane.setSelectedIndex(index1);
+        }
+
+        for (j = 0; j < tp.tabbedPane.getTabCount(); j++) {
+            if (tp.tabbedPane.getTitleAt(j).equals(s)) {
+                tp.tabbedPane.setSelectedIndex(j);
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public boolean selectTab(String s) {
+        return selectTab(getCurrentTURTLEPanel(), s);
+    }
+
+    public void openTMLTaskActivityDiagram(String panel, String tab) {
+        int index = mainTabbedPane.indexOfTab(panel);
+        if (index != -1) {
+            mainTabbedPane.setSelectedIndex(index);
+        }
+        openTMLTaskActivityDiagram(tab);
+    }
+
+    public void openTMLTaskActivityDiagram(String tab) {
+        selectTab(getCurrentTURTLEPanel(), tab);
+    }
+
+    public void refreshCurrentPanel() {
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if (tdp != null) {
+            tdp.repaint();
+        }
+    }
+
+    public void openAVATARSMD(String tab) {
+        TDiagramPanel cur = getCurrentTDiagramPanel();
+        selectTab(getCurrentTURTLEPanel(), tab);
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if (tdp == cur) {
+            tdp.repaint();
+        }
+    }
+
+    public boolean selectHighLevelTab(String s) {
+        TURTLEPanel tp = getTURTLEPanel(s);
+        if (s != null) {
+            selectTab(tp);
+            return true;
+        }
+        return false;
+    }
+
+    public TDiagramPanel selectTab(Point p) {
+        mainTabbedPane.setSelectedIndex(p.x);
+        TURTLEPanel tp = tabs.elementAt(p.x);
+        tp.tabbedPane.setSelectedIndex(p.y);
+        return tp.panels.elementAt(p.y);
+
+    }
+
+    public Point getCurrentSelectedPoint() {
+        Point p = new Point();
+
+        p.x = mainTabbedPane.getSelectedIndex();
+        if (getCurrentTURTLEPanel() == null) {
+            p.y = -1;
+        } else {
+            p.y = getCurrentTURTLEPanel().tabbedPane.getSelectedIndex();
+        }
+
+        return p;
+    }
+
+    public Point getPoint(TDiagramPanel tdp) {
+        Point p = new Point();
+
+        int index;
+        TURTLEPanel tp;
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            index = tp.panels.indexOf(tdp);
+            if (index > -1) {
+                p.x = i;
+                p.y = index;
+                return p;
+            }
+        }
+        p.x = 0;
+        p.y = 0;
+
+        return p;
+    }
+
+    public DesignPanel getDesignPanel(String name) {
+        int index = mainTabbedPane.indexOfTab(name);
+        try {
+            TURTLEPanel tp = tabs.elementAt(index);
+
+            if (tp instanceof DesignPanel) {
+                return (DesignPanel) tp;
+            } else {
+                return null;
+            }
+        } catch (Exception e) {
+            return null;
+        }
+    }
+    //---------------------------------- DDD ------------------------------------
+    // return current deployment panel
+
+    public ADDDiagramPanel getDeploymentPanel() {
+        ADDDiagramPanel deploymentDiagram = null; //(ADDDiagramPanel)activetdp;
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        Vector<TDiagramPanel> ps = tp.panels;
+        for (TDiagramPanel panel : ps) {
+            if (panel instanceof ADDDiagramPanel) {
+                deploymentDiagram = (ADDDiagramPanel) panel;
+            }
+        }
+        if (deploymentDiagram == null)
+            System.err.println("No ADDDiagramPanel found : MainGUI.getDeploymentPanel()");
+        return deploymentDiagram;
+    }
+
+
+    public ADDDiagramPanel getFirstAvatarDeploymentPanelFound() {
+        ADDDiagramPanel adp = null;
+        for (int i = 0; i < tabs.size(); i++)
+            if (tabs.get(i) instanceof ADDPanel) {
+                adp = ((ADDPanel) tabs.get(i)).tmladd;
+            }
+        if (adp == null)
+            System.err.println("No AvatarDeployment Panel Found : MainGUI.getFirstAvatarDeploymentPanelFound()");
+        return adp;
+    }
+
+
+    // find the first Design Panel in MainGUI.tabs
+
+    public AvatarDesignPanel getFirstAvatarDesignPanelFound() {
+        AvatarDesignPanel adp = null;
+        for (int i = 0; i < tabs.size(); i++)
+            if (tabs.get(i) instanceof AvatarDesignPanel) {
+                adp = (AvatarDesignPanel) tabs.get(i);
+            }
+        if (adp == null)
+            System.err.println("No AvatarDesign Panel Found : MainGUI.getFirstAvatarDesignPanel()");
+        return adp;
+    }
+
+
+    public void extracDeploymentDiagramToFile() {
+
+        ADDDiagramPanel deploymentDiagramPanel = getDeploymentPanel();
+        AvatarDesignPanel designDiagramPanel = getFirstAvatarDesignPanelFound();
+
+        AvatarDeploymentPanelTranslator avdeploymenttranslator = new AvatarDeploymentPanelTranslator(deploymentDiagramPanel);
+        /*AvatarddSpecification avddspec =*/
+        avdeploymenttranslator.getAvatarddSpecification();
+
+
+        AvatarDesignPanelTranslator avdesigntranslator = new AvatarDesignPanelTranslator(designDiagramPanel);
+        List<AvatarBDStateMachineOwner> adp = designDiagramPanel.getAvatarBDPanel().getFullStateMachineOwnerList();
+        /*AvatarSpecification avaspec =*/
+        avdesigntranslator.generateAvatarSpecification(adp);
+
+        //DG
+        //LinkedList<AvatarComponent> components = AvatarddSpecification.getComponents();
+        //AvatarToFile tofile;
+        //tofile =  new AvatarToFile(components,avaspec);
+        //tofile.extracParamToFile();
+    }
+
+    public void avatarToSoclib() {
+        //DG 6.2. appelee nulle part?
+
+        ADDDiagramPanel deploymentDiagramPanel = getDeploymentPanel();
+        AvatarDesignPanel designDiagramPanel = getFirstAvatarDesignPanelFound();
+
+        AvatarDeploymentPanelTranslator avdeploymenttranslator = new AvatarDeploymentPanelTranslator(deploymentDiagramPanel);
+        AvatarddSpecification avddspec = avdeploymenttranslator.getAvatarddSpecification();
+
+
+        AvatarDesignPanelTranslator avdesigntranslator = new AvatarDesignPanelTranslator(designDiagramPanel);
+
+        LinkedList<AvatarBDStateMachineOwner> adp = designDiagramPanel.getAvatarBDPanel().getFullStateMachineOwnerList();
+        AvatarSpecification avaspec = avdesigntranslator.generateAvatarSpecification(adp);
+
+        // Generator for block tasks and application main file
+
+        TasksAndMainGenerator gene = new TasksAndMainGenerator(avddspec, avaspec);
+        gene.generateSoclib(false, false);
+        try {
+            //System.err.println("ok");
+            gene.saveInFiles(TasksAndMainGenerator.getGeneratedPath());
+        } catch (FileException e) {
+            System.err.println("FileException : MainGUI.avatarToSoclib()");
+        }
+
+    }
+    //--------------------end DDD------------------------------------------------
+
+    public boolean selectMainTab(String id) {
+        TURTLEPanel tp;
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            if (getTabName(tp).compareTo(id) == 0) {
+                selectTab(tp);
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public void selectTab(TURTLEPanel tp) {
+        int index1 = tabs.indexOf(tp);
+        mainTabbedPane.setSelectedIndex(index1);
+    }
+
+    public void selectTab(TDiagramPanel tdp) {
+        int index;
+        TURTLEPanel tp;
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            index = tp.panels.indexOf(tdp);
+            if (index > -1) {
+                selectTab(tp);
+                tp.tabbedPane.setSelectedIndex(index);
+            }
+        }
+    }
+
+    public void toggleAttributes() {
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if ((tdp != null) && (tdp instanceof TClassDiagramPanel)) {
+            //TraceManager.addDev("Toggle attributes");
+            TClassDiagramPanel tdcp = (TClassDiagramPanel) tdp;
+            tdcp.setAttributesVisible(!tdcp.areAttributesVisible());
+            tdcp.checkAllMySize();
+            tdcp.repaint();
+            changeMade(tdcp, TDiagramPanel.CHANGE_VALUE_COMPONENT);
+        }
+    }
+
+    // AVATAR Simulation
+    public void setAVATARIDs(boolean b) {
+        TDiagramPanel.AVATAR_ID_ON = b;
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if (tdp != null) {
+            tdp.repaint();
+        }
+    }
+
+    public void toggleAVATARIDs() {
+        setAVATARIDs(!TDiagramPanel.AVATAR_ID_ON);
+        TraceManager.addDev("AVATAR id: " + TDiagramPanel.AVATAR_ID_ON);
+    }
+
+    // For simulation purpose
+    public void resetAllDIPLOIDs() {
+        TURTLEPanel tp;
+
+        for (int i = 0; i < tabs.size(); i++) {
+            tp = tabs.elementAt(i);
+            tp.resetAllDIPLOIDs();
+        }
+    }
+
+    public void toggleDiploIDs() {
+        setDiploIDs(!TDiagramPanel.DIPLO_ID_ON);
+    }
+
+    public void toggleTEPEIDs() {
+        setTEPEIDs(!TDiagramPanel.TEPE_ID_ON);
+    }
+
+    public void toggleDiploAnimate() {
+        setDiploAnimate(!TDiagramPanel.DIPLO_ANIMATE_ON);
+    }
+
+    public int isRunningAvatarComponent(TGComponent _tgc) {
+        if (jfais.isVisible()) {
+            if (jfais.isRunningComponent(_tgc)) {
+                return 1;
+            }
+            if (jfais.isSelectedComponentFromTransaction(_tgc)) {
+                return 2;
+            }
+        }
+        return 0;
+    }
+
+    public String[] hasMessageInformationForAvatarConnector(AvatarBDPortConnector _conn) {
+        if (jfais.isVisible()) {
+            return jfais.getFirstMessagesOnEachConnectorSide(_conn);
+        }
+        return null;
+    }
+
+    public void setDiploAnimate(boolean b) {
+        TDiagramPanel.DIPLO_ANIMATE_ON = b;
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if (tdp != null) {
+            tdp.repaint();
+        }
+    }
+
+    public void setAvatarAnimate(boolean b) {
+        TDiagramPanel.AVATAR_ANIMATE_ON = b;
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if (tdp != null) {
+            tdp.repaint();
+        }
+    }
+
+    public void setDiploIDs(boolean b) {
+        TDiagramPanel.DIPLO_ID_ON = b;
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if (tdp != null) {
+            tdp.repaint();
+        }
+    }
+
+    public void setTEPEIDs(boolean b) {
+        TDiagramPanel.TEPE_ID_ON = b;
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if (tdp != null) {
+            tdp.repaint();
+        }
+    }
+
+    public void setTransationProgression(boolean b) {
+        TDiagramPanel.DIPLO_TRANSACTION_PROGRESSION_ON = b;
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if (tdp != null) {
+            tdp.repaint();
+        }
+    }
+
+    public synchronized RunningInfo isRunningID(int id) {
+        if (runningIDs == null) {
+            return null;
+        }
+
+        for (RunningInfo ri : runningIDs) {
+            if (ri.id == id) {
+                return ri;
+            }
+        }
+
+        return null;
+    }
+
+    public synchronized ArrayList<SimulationTransaction> getTransactions(int id) {
+        if (transactionMap == null) {
+            return null;
+        }
+
+        return transactionMap.get(id);
+    }
+
+    public synchronized void addLatencyVals(int id, String[] latency) {
+        if (latencyMap != null) {
+            //System.out.println("Adding latency...");
+            if (!latencyMap.containsKey(id)) {
+                ConcurrentHashMap<String, String> map = new ConcurrentHashMap<String, String>();
+                latencyMap.put(id, map);
+            }
+            latencyMap.get(id).put(latency[0], latency[1]);
+            //System.out.println(latencyMap);
+        }
+        //      System.out.println(latencyMap);
+    }
+
+    public synchronized ConcurrentHashMap<String, String> getLatencyVals(int id) {
+        //      System.out.println(id + " " + latencyMap);
+        if (latencyMap != null) {
+            return latencyMap.get(id);
+        }
+        return null;
+    }
+
+    public synchronized ConcurrentHashMap<String, String> getStatus(int id) {
+        if (statusMap == null) {
+            return null;
+        }
+
+        return statusMap;
+    }
+
+    public String getStatus(String s) {
+        if (statusMap == null) {
+            return null;
+        }
+        return statusMap.get(s);
+    }
+
+    public synchronized LoadInfo isLoadID(int id) {
+        if (loadIDs == null) {
+            return null;
+        }
+
+        for (LoadInfo li : loadIDs) {
+            if (li.id == id) {
+                return li;
+            }
+        }
+
+        return null;
+    }
+
+    public void resetReachability() {
+        //TraceManager.addDev("Reset reachability");
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        if (tp != null) {
+            tp.resetReachability();
+        }
+    }
+
+    public void resetLiveness() {
+        TURTLEPanel tp = getCurrentTURTLEPanel();
+        if (tp != null) {
+            tp.resetLiveness();
+        }
+    }
+
+
+    public synchronized void resetRunningID() {
+        if (runningIDs != null) {
+            runningIDs.clear();
+        }
+        runningIDs = null;
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if (tdp != null) {
+            tdp.repaint();
+        }
+    }
+
+    public synchronized void resetLoadID() {
+        if (loadIDs != null) {
+            loadIDs.clear();
+        }
+        loadIDs = null;
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if (tdp != null) {
+            tdp.repaint();
+        }
+    }
+
+    public synchronized void resetTransactions() {
+        transactionMap.clear();
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if (tdp != null) {
+            tdp.repaint();
+        }
+    }
+
+    public synchronized void resetStatus() {
+        statusMap.clear();
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if (tdp != null) {
+            tdp.repaint();
+        }
+    }
+
+    public synchronized void addRunningIDTaskState(int _id, String _state) {
+        if (runningIDs == null) {
+            return;
+        }
+
+        if (_state == null) {
+            _state = "unknown";
+        }
+
+        for (RunningInfo ri : runningIDs) {
+            if (ri.id == _id) {
+                ri.state = _state.toLowerCase();
+                //TraceManager.addDev("Updated state on UML diagram");
+                TDiagramPanel tdp = getCurrentTDiagramPanel();
+                if (tdp != null) {
+                    tdp.repaint();
+                }
+                return;
+            }
+        }
+
+    }
+
+    public synchronized void addRunningID(int _id, int _nextCommand, String _progression, String _startTime, String _finishTime, String _transStartTime, String _transFinishTime, String _state) {
+        if (runningIDs == null) {
+            runningIDs = new ArrayList<RunningInfo>();
+        }
+        RunningInfo ri = new RunningInfo();
+        if (_state == null) {
+            _state = "unknown";
+        }
+        ri.id = _id;
+        ri.nextCommand = _nextCommand;
+        ri.progression = _progression;
+        ri.startTime = _startTime;
+        ri.finishTime = _finishTime;
+        ri.transStartTime = _transStartTime;
+        ri.transFinishTime = _transFinishTime;
+        ri.state = _state.toLowerCase();
+        runningIDs.add(ri);
+        //TraceManager.addDev("Running id " + id +  " added");
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if (tdp != null) {
+            tdp.repaint();
+        }
+    }
+
+    public synchronized void addTransaction(int _id, SimulationTransaction st) {
+        if (transactionMap.containsKey(_id)) {
+            if (!transactionMap.get(_id).contains(st)) {
+                transactionMap.get(_id).add(st);
+            }
+        } else {
+            ArrayList<SimulationTransaction> ts = new ArrayList<SimulationTransaction>();
+            ts.add(st);
+            transactionMap.put(_id, ts);
+        }
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if (tdp != null) {
+            tdp.repaint();
+        }
+    }
+
+    public synchronized void addStatus(String task, String stat) {
+        statusMap.put(task, stat);
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if (tdp != null) {
+            tdp.repaint();
+        }
+    }
+
+    public synchronized void addLoadInfo(int _id, double _load, long _energy) {
+        if (loadIDs == null) {
+            loadIDs = new ArrayList<LoadInfo>();
+        }
+
+        removeLoadId(_id);
+        LoadInfo li = new LoadInfo();
+        li.id = _id;
+        li.load = _load;
+        li.energy = _energy;
+        loadIDs.add(li);
+        //TraceManager.addDev("Running id " + _id +  " added load=" + _load);
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if (tdp != null) {
+            tdp.repaint();
+        }
+    }
+
+    public synchronized void removeRunningId(Integer id) {
+        if (runningIDs == null) {
+            return;
+        }
+
+        for (RunningInfo ri : runningIDs) {
+            if (ri.id == id.intValue()) {
+                runningIDs.remove(ri);
+                //TraceManager.addDev("Running id " + i +  " removed");
+                return;
+            }
+        }
+        getCurrentTDiagramPanel().repaint();
+    }
+
+    public synchronized void removeLoadId(int _id) {
+        if (loadIDs == null) {
+            return;
+        }
+
+        for (LoadInfo li : loadIDs) {
+            if (li.id == _id) {
+                loadIDs.remove(li);
+                //TraceManager.addDev("Running id " + i +  " removed");
+                return;
+            }
+        }
+        getCurrentTDiagramPanel().repaint();
+    }
+
+    public void toggleGates() {
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if ((tdp != null) && (tdp instanceof TClassDiagramPanel)) {
+            //TraceManager.addDev("Toggle gates");
+            TClassDiagramPanel tdcp = (TClassDiagramPanel) tdp;
+            tdcp.setGatesVisible(!tdcp.areGatesVisible());
+            tdcp.checkAllMySize();
+            tdcp.repaint();
+            changeMade(tdcp, TDiagramPanel.CHANGE_VALUE_COMPONENT);
+        }
+    }
+
+    public void toggleSynchro() {
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if ((tdp != null) && (tdp instanceof TClassDiagramPanel)) {
+            //TraceManager.addDev("Toggle synchro");
+            TClassDiagramPanel tdcp = (TClassDiagramPanel) tdp;
+            tdcp.setSynchroVisible(!tdcp.areSynchroVisible());
+            tdcp.checkAllMySize();
+            tdcp.repaint();
+            changeMade(tdcp, TDiagramPanel.CHANGE_VALUE_COMPONENT);
+        }
+    }
+
+    public void toggleJava() {
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if ((tdp != null) && (tdp instanceof TActivityDiagramPanel)) {
+            //TraceManager.addDev("Toggle synchro");
+            TActivityDiagramPanel tadp = (TActivityDiagramPanel) tdp;
+            tadp.setJavaVisible(!tadp.isJavaVisible());
+            tadp.checkAllMySize();
+            tadp.repaint();
+            changeMade(tadp, TDiagramPanel.CHANGE_VALUE_COMPONENT);
+        }
+    }
+
+    public void toggleInternalComment() {
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if (tdp != null) {
+            tdp.setInternalCommentVisible((tdp.getInternalCommentVisible() + 1) % 3);
+            tdp.checkAllMySize();
+            tdp.repaint();
+            changeMade(tdp, TDiagramPanel.CHANGE_VALUE_COMPONENT);
+        }
+    }
+
+    public void toggleAttr() {
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if (tdp != null) {
+            //TraceManager.addDev("Toggle attributes");
+            tdp.setAttributes((tdp.getAttributeState() + 1) % 3);
+            tdp.checkAllMySize();
+            tdp.repaint();
+            changeMade(tdp, TDiagramPanel.CHANGE_VALUE_COMPONENT);
+        }
+    }
+
+    public void toggleChannels() {
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if ((tdp != null) && (tdp instanceof TMLTaskDiagramPanel)) {
+            //TraceManager.addDev("Toggle attributes");
+            TMLTaskDiagramPanel tmltdp = (TMLTaskDiagramPanel) tdp;
+            tmltdp.setChannelsVisible(!tmltdp.areChannelsVisible());
+            tmltdp.checkAllMySize();
+            tmltdp.repaint();
+            changeMade(tmltdp, TDiagramPanel.CHANGE_VALUE_COMPONENT);
+        }
+    }
+
+    public void toggleEvents() {
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if ((tdp != null) && (tdp instanceof TMLTaskDiagramPanel)) {
+            //TraceManager.addDev("Toggle attributes");
+            TMLTaskDiagramPanel tmltdp = (TMLTaskDiagramPanel) tdp;
+            tmltdp.setEventsVisible(!tmltdp.areEventsVisible());
+            tmltdp.checkAllMySize();
+            tmltdp.repaint();
+            changeMade(tmltdp, TDiagramPanel.CHANGE_VALUE_COMPONENT);
+        }
+    }
+
+    public void toggleRequests() {
+        TDiagramPanel tdp = getCurrentTDiagramPanel();
+        if ((tdp != null) && (tdp instanceof TMLTaskDiagramPanel)) {
+            //TraceManager.addDev("Toggle attributes");
+            TMLTaskDiagramPanel tmltdp = (TMLTaskDiagramPanel) tdp;
+            tmltdp.setRequestsVisible(!tmltdp.areRequestsVisible());
+            tmltdp.checkAllMySize();
+            tmltdp.repaint();
+            changeMade(tmltdp, TDiagramPanel.CHANGE_VALUE_COMPONENT);
+        }
+    }
+
+    public boolean isAValidTabName(String name) {
+        return name.matches("((\\w)*(\\s)*)*");
+    }
+
+
+    public void windowClosing(WindowEvent e) {
+        //frame.setVisible(false);
+        quitApplication();
+    }
+
+    public void windowClosed(WindowEvent e) {
+    }
+
+    public void windowOpened(WindowEvent e) {
+    }
+
+    public void windowIconified(WindowEvent e) {
+    }
+
+    public void windowDeiconified(WindowEvent e) {
+    }
+
+    public void windowActivated(WindowEvent e) {
+    }
+
+    public void windowDeactivated(WindowEvent e) {
+    }
+
+
+    // TGUIACtions Event listener
+
+    public void keyTyped(KeyEvent e) {
+        TraceManager.addDev("KEY TYPED");
+    }
+
+    public void keyPressed(KeyEvent e) {
+        TraceManager.addDev("KEY PRESSED: ");
+    }
+
+    public void keyReleased(KeyEvent e) {
+        TraceManager.addDev("KEY RELEASED: ");
+    }
+
+    public void actionPerformed(ActionEvent evt) {
+        String command = evt.getActionCommand();
+        //TraceManager.addDev("Command:" + command);
+        TDiagramPanel tdp1 = getCurrentTDiagramPanel();
+        if (tdp1 != null) {
+            //TraceManager.addDev("Stop Adding connector in maingui");
+            tdp1.stopAddingConnector();
+        }
+
+        ActionPerformer.actionPerformed(this, evt, command, tdp1);
+
+
+    }
+
+    private class PopupListener extends MouseAdapter /* popup menus onto tabs */ {
+        private MainGUI mgui;
+        private JPopupMenu menu;
+
+        private JMenuItem rename, remove, moveRight, moveLeft, newDesign, newAnalysis, newDeployment, newRequirement/*, newTMLDesign*/, newTMLComponentDesign, newTMLArchi, newProactiveDesign, newTURTLEOSDesign,
+                newNCDesign, sort, clone, newAttackTree, newFaultTree, newAVATARBD, newAVATARRequirement, newMAD, newTMLCP, newTMLMethodo, newAvatarMethodo, newAVATARDD, newSysmlsecMethodo, newSystemCAMS;
+        private JMenuItem newAVATARAnalysis;
+
+        public PopupListener(MainGUI _mgui) {
+            mgui = _mgui;
+            createMenu();
+        }
+
+        public void mousePressed(MouseEvent e) {
+            if (activetdp != null)
+                activetdp.tdmm.setSelection(-1, -1);
+            checkForPopup(e);
+        }
+
+        public void mouseReleased(MouseEvent e) {
+            if (activetdp != null)
+                activetdp.tdmm.setSelection(-1, -1);
+            checkForPopup(e);
+        }
+
+        public void mouseClicked(MouseEvent e) {
+            if (activetdp != null)
+                activetdp.tdmm.setSelection(-1, -1);
+            checkForPopup(e);
+        }
+
+        private void checkForPopup(MouseEvent e) {
+            if (e.isPopupTrigger()) {
+                Component c = e.getComponent();
+                //TraceManager.addDev("e =" + e + " Component=" + c);
+                updateMenu(mgui.getCurrentSelectedIndex());
+                menu.show(c, e.getX(), e.getY());
+            }
+        }
+
+        private void createMenu() {
+            rename = createMenuItem("Rename");
+            remove = createMenuItem("Remove");
+            moveLeft = createMenuItem("Move to the left");
+            moveRight = createMenuItem("Move to the right");
+            sort = createMenuItem("Sort");
+            clone = createMenuItem("Clone");
+            newAnalysis = createMenuItem("New TURTLE Analysis");
+            newDesign = createMenuItem("New TURTLE Design");
+            newDeployment = createMenuItem("New TURTLE Deployment");
+
+            newAttackTree = createMenuItem("New Attack Tree");
+            newFaultTree = createMenuItem("New Fault Tree");
+
+            newRequirement = createMenuItem("New TURTLE Requirement Diagram");
+
+            newTMLMethodo = createMenuItem("New DIPLODOCUS Methodology");
+
+            /*newTMLDesign =*/
+            createMenuItem("New Partitioning - Design");
+            newTMLComponentDesign = createMenuItem("New Partitioning - Functional view");
+            newTMLArchi = createMenuItem("New Partitioning - Architecture and Mapping");
+            newTMLCP = createMenuItem("New Partitioning - Communication Pattern");
+            newSystemCAMS = createMenuItem("New SystemC-AMS Block Diagram"); //ajout CD
+            newProactiveDesign = createMenuItem("New Proactive Design");
+            newTURTLEOSDesign = createMenuItem("New TURTLE-OS Design");
+            newNCDesign = createMenuItem("New Network Calculus Design");
+            newMAD = createMenuItem("New Modeling Assumptions Diagram");
+            newAVATARRequirement = createMenuItem("New Requirement Diagrams");
+            newAVATARAnalysis = createMenuItem("New Analysis");
+            newAVATARBD = createMenuItem("New Design");
+            newAVATARDD = createMenuItem("New Deployment Diagram");
+            newAvatarMethodo = createMenuItem("New AVATAR Methodology");
+            newSysmlsecMethodo = createMenuItem("New SysML-Sec Methodology");
+
+            menu = new JPopupMenu("Views");
+            menu.add(moveLeft);
+            menu.add(moveRight);
+
+            menu.addSeparator();
+
+            menu.add(rename);
+            menu.add(remove);
+
+            menu.addSeparator();
+
+            menu.add(sort);
+
+            menu.addSeparator();
+
+            menu.add(clone);
+
+            menu.addSeparator();
+
+            // TURTLE first and other old profiles. Old way
+            if (!avatarOnly) {
+                if (turtleOn) {
+                    menu.add(newRequirement);
+                    menu.add(newAnalysis);
+                    menu.add(newDesign);
+                    menu.add(newDeployment);
+                    menu.addSeparator();
+                }
+
+                if (osOn) {
+                    menu.add(newTURTLEOSDesign);
+                    menu.addSeparator();
+                    //TraceManager.addDev("OS is on");
+                } else {
+                    //TraceManager.addDev("OS is off");
+                }
+
+                if (proactiveOn) {
+                    menu.add(newProactiveDesign);
+                    menu.addSeparator();
+                }
+
+                if (ncOn) {
+                    menu.add(newNCDesign);
+                    menu.addSeparator();
+                }
+
+            }
+
+
+            // Methodologies
+            if (!avatarOnly) {
+                if (systemcOn) {
+                    menu.add(newTMLMethodo);
+                }
+
+            }
+
+            if (avatarOn) {
+                menu.add(newAvatarMethodo);
+                menu.add(newSysmlsecMethodo);
+            }
+            menu.addSeparator();
+
+
+            //diagrams
+            if (!avatarOnly) {
+                if (systemcOn) {
+
+                    //menu.add(newTMLMethodo);
+                    //menu.add(newTMLDesign);
+                    menu.add(newTMLComponentDesign);
+                    menu.add(newTMLCP);
+                    menu.add(newTMLArchi);
+                    menu.addSeparator();
+                    menu.add(newSystemCAMS);//ajout CD
+                    menu.addSeparator();
+                }
+            }
+
+            if (avatarOn) {
+                //               menu.addSeparator();
+                //menu.add(newAvatarMethodo);
+
+                menu.add(newMAD);
+                menu.add(newAVATARRequirement);
+                menu.add(newAttackTree);
+                menu.add(newFaultTree);
+                menu.add(newAVATARAnalysis);
+                menu.add(newAVATARBD);
+                if (experimentalOn) {
+                    menu.add(newAVATARDD);
+                }
+            }
+
+        }
+
+
+        private JMenuItem createMenuItem(String s) {
+            JMenuItem item = new JMenuItem(s);
+            item.setActionCommand(s);
+            item.addActionListener(listener);
+            return item;
+        }
+
+        private void updateMenu(int index) {
+            //TraceManager.addDev("UpdateMenu index=" + index);
+            if (index < 1) {
+                moveLeft.setEnabled(false);
+            } else {
+                moveLeft.setEnabled(true);
+            }
+
+            if (index + 1 < mgui.tabs.size()) {
+                moveRight.setEnabled(true);
+            } else {
+                moveRight.setEnabled(false);
+            }
+
+            if (index < 0) {
+                rename.setEnabled(false);
+                remove.setEnabled(false);
+                clone.setEnabled(false);
+            } else {
+                rename.setEnabled(true);
+                remove.setEnabled(true);
+                clone.setEnabled(true);
+            }
+
+            if (mgui.mainTabbedPane.getTabCount() < 2) {
+                sort.setEnabled(false);
+            } else {
+                sort.setEnabled(true);
+            }
+        }
+
+        private Action listener = new AbstractAction() {
+
+            /**
+             *
+             */
+            private static final long serialVersionUID = -3632935027104753332L;
+
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                JMenuItem item = (JMenuItem) e.getSource();
+                String ac = item.getActionCommand();
+                if (ac.equals("Rename")) {
+                    mgui.requestRenameTab(mainTabbedPane.getSelectedIndex());
+                } else if (ac.equals("Remove")) {
+                    mgui.requestRemoveTab(mainTabbedPane.getSelectedIndex());
+                } else if (ac.equals("Move to the left")) {
+                    mgui.requestMoveLeftTab(mainTabbedPane.getSelectedIndex());
+                } else if (ac.equals("Move to the right")) {
+                    mgui.requestMoveRightTab(mainTabbedPane.getSelectedIndex());
+                } else if (ac.equals("Sort")) {
+                    GraphicLib.sortJTabbedPane(mgui.mainTabbedPane, mgui.tabs, 0, mgui.mainTabbedPane.getTabCount());
+                    mgui.changeMade(null, -1);
+                } else if (ac.equals("Clone")) {
+                    mgui.cloneTab(mainTabbedPane.getSelectedIndex());
+                } else if (ac.equals("New TURTLE Analysis")) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newAnalysis();
+                } else if (ac.equals("New TURTLE Design")) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newDesign();
+                } else if (ac.equals("New TURTLE Deployment")) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newDeployment();
+                } else if (e.getSource() == newAttackTree) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newAttackTree();
+                } else if (e.getSource() == newFaultTree) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newFaultTree();
+                } else if (ac.equals("New TURTLE Requirement Diagram")) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newRequirement();
+                } else if (e.getSource() == newTMLMethodo) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newDiplodocusMethodology();
+                } else if (e.getSource() == newAvatarMethodo) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newAvatarMethodology();
+                } else if (e.getSource() == newSysmlsecMethodo) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newSysmlsecMethodology();
+                } else if (ac.equals("New DIPLODOCUS Design")) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newTMLDesign();
+                } else if (e.getSource() == newTMLComponentDesign) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newTMLComponentDesign();
+                } else if (e.getSource() == newTMLCP) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newTMLCP();
+                } else if (e.getSource() == newTMLArchi) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newTMLArchi();
+                } else if (ac.equals("New Proactive Design")) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newProactiveDesign();
+                } else if (ac.equals("New TURTLE-OS Design")) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newTURTLEOSDesign();
+                } else if (e.getSource() == newNCDesign) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newNCDesign();
+                } else if (e.getSource() == newAVATARBD) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newAvatarBD();
+                } else if (e.getSource() == newAVATARDD) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newADD();
+                } else if (e.getSource() == newAVATARRequirement) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newAvatarRequirement();
+                } else if (e.getSource() == newMAD) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newAvatarMADs();
+                } else if (e.getSource() == newAVATARAnalysis) {
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newAvatarAnalysis();
+                } /*else if (e.getSource() == newSystemCAMS) { //ajout CD
+                    ModeManager.setMode(CREATE_NEW_PANEL, actions, mainBar, mgui);
+                    mgui.newSystemCAMS();
+		    }*/
+            }
+        };
+    }
+
+
+    /**
+     * This adapter is constructed to handle mouse over component events.
+     */
+    private class MouseHandler extends MouseAdapter {
+
+        private JLabel label;
+
+        /**
+         * ctor for the adapter.
+         *
+         * @param label the JLabel which will recieve value of the
+         *              Action.LONG_DESCRIPTION key.
+         */
+        public MouseHandler(JLabel label) {
+            setLabel(label);
+        }
+
+        public void setLabel(JLabel label) {
+            this.label = label;
+        }
+
+        @Override
+        public void mouseEntered(MouseEvent evt) {
+            if (evt.getSource() instanceof AbstractButton) {
+                AbstractButton button = (AbstractButton) evt.getSource();
+                Action action = button.getAction();
+                if (action != null) {
+                    String message = (String) action.getValue(Action.LONG_DESCRIPTION);
+                    label.setText(message);
+                }
+            }
+        }
+
+    }
+
+    // Get the currently opened architecture panel
+    public TMLArchiPanel getCurrentArchiPanel() {
+        return tmlap;
+    }
+} // Class MainGUI
diff --git a/src/main/resources/ui/TDiagramPanel.java b/src/main/resources/ui/TDiagramPanel.java
new file mode 100755
index 0000000000..fe0c5c5221
--- /dev/null
+++ b/src/main/resources/ui/TDiagramPanel.java
@@ -0,0 +1,3643 @@
+/* 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.GenericTree;
+import myutil.GraphicLib;
+import myutil.SVGGraphics;
+import myutil.TraceManager;
+import ui.atd.ATDBlock;
+import ui.avatarad.AvatarADActivity;
+import ui.avatarbd.AvatarBDBlock;
+import ui.avatarbd.AvatarBDDataType;
+import ui.avatarbd.AvatarBDLibraryFunction;
+import ui.avatarcd.AvatarCDBlock;
+import ui.avatarmad.AvatarMADAssumption;
+import ui.avatarrd.AvatarRDRequirement;
+import ui.avatarsmd.AvatarSMDState;
+import ui.cd.*;
+/*import ui.het.CAMSBlock;
+import ui.het.CAMSBlockConnector;
+import ui.het.CAMSBlockDiagramPanel;
+import ui.het.CAMSConnectingPoint;*/
+import ui.ncdd.NCEqNode;
+import ui.ncdd.NCRouteArtifact;
+import ui.ncdd.NCSwitchNode;
+import ui.ncdd.NCTrafficArtifact;
+import ui.oscd.TOSClass;
+import ui.req.Requirement;
+import ui.tmlcd.TMLTaskOperator;
+import ui.tmlcompd.TMLCCompositeComponent;
+import ui.tmlcompd.TMLCPrimitiveComponent;
+import ui.tmlcompd.TMLCRecordComponent;
+import ui.window.JDialogCode;
+import ui.window.JDialogNote;
+import ui.window.JDialogSearchBox;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.image.BufferedImage;
+import java.util.*;
+import java.util.List;
+
+// AVATAR
+
+/**
+ * Class TDiagramPanel
+ * High level panel for all kind of TURTLE diagrams
+ * Creation: 21/12/2003
+ *
+ * @author Ludovic APVRILLE
+ * @version 1.0 21/12/2003
+ */
+public abstract class TDiagramPanel extends JPanel implements GenericTree {
+
+    protected TDiagramMouseManager tdmm;
+    protected PanelKeyListener pkl;
+
+    // for tracking changes
+    public static final int NEW_COMPONENT = 0;
+    public static final int NEW_CONNECTOR = 1;
+    public static final int REMOVE_COMPONENT = 2;
+    public static final int CHANGE_VALUE_COMPONENT = 3;
+    public static final int MOVE_COMPONENT = 4;
+    public static final int MOVE_CONNECTOR = 5;
+
+    // Issue #14
+    public static final int DIAGRAM_RESIZED = 6;
+
+    // For cut/copy/paste
+    public static String copyData;
+    /*private static int copyX;
+      private static int copyY;
+      private static int copyMaxId;*/
+
+    protected String name;
+
+    protected List<TGComponent> componentList;
+    protected TGConnectingPoint selectedConnectingPoint;
+    //protected CAMSConnectingPoint selectedCAMSConnectingPoints;
+    protected TGComponent componentPointed;
+    protected TGComponent componentPopup;
+    protected TToolBar ttb;
+    protected TGComponent fatherOfRemoved;
+    //author:huytruong
+    protected TGComponent componentHovered;
+
+    // popupmenus
+    protected ActionListener menuAL;
+    protected JPopupMenu diagramMenu;
+    protected JPopupMenu componentMenu;
+    protected JPopupMenu selectedMenu;
+    protected int popupX, popupY;
+    protected JMenuItem remove, edit, clone, bringFront, bringBack, makeSquare, setJavaCode, removeJavaCode, setInternalComment, removeInternalComment, attach, detach, hide, unhide, search, enableDisable, setAsCryptoBlock, setAsRegularBlock;
+    protected JMenuItem checkAccessibility, checkInvariant, checkMasterMutex, checkLatency;
+    protected JMenuItem gotoReference;
+    protected JMenuItem breakpoint;
+    protected JMenuItem paste, insertLibrary, upX, upY, downX, downY, fitToContent, backToMainDiagram;
+    protected JMenuItem cut, copy, saveAsLibrary, captureSelected;
+    //author:huytruong
+    //search dialog
+    protected JDialogSearchBox j;
+    //--
+
+    // Main window
+    protected MainGUI mgui;
+
+    // Mouse pointer
+    public int currentX;
+    public int currentY;
+
+    //drawing area
+    private int minLimit = 10;
+    private int maxX = 2500;
+    private int maxY = 1500;
+    private final int limit = 10;
+    // Issue #14 Useless data
+//    private final int minimumXSize = 900;
+//    private final int minimumYSize = 900;
+    protected final int increment = 500;
+
+    private double zoom = 1.0;
+    //   private boolean zoomed = false;
+
+    private boolean draw;
+
+    // Issue #14 point 10: Always use the current graphics
+    //private Graphics lastGraphics;
+
+    // MODE
+    public int mode;
+
+    public static final int NORMAL = 0;
+    public static final int MOVING_COMPONENT = 1;
+    public static final int ADDING_CONNECTOR = 2;
+    public static final int MOVE_CONNECTOR_SEGMENT = 3;
+    public static final int MOVE_CONNECTOR_HEAD = 4;
+    public static final int SELECTING_COMPONENTS = 5;
+    public static final int SELECTED_COMPONENTS = 6;
+    public static final int MOVING_SELECTED_COMPONENTS = 7;
+    public static final int RESIZING_COMPONENT = 8;
+
+    // when adding connector or moving a connector head
+    protected int x1;
+    protected int y1;
+    protected int x2;
+    protected int y2;
+    protected Vector<Point> listPoint;
+    protected TGConnectingPoint p1, p2;
+    //    protected CAMSConnectingPoint cp1, cp2;
+    protected int type;
+
+    // For component selection
+    protected int initSelectX;
+    protected int initSelectY;
+    protected int currentSelectX;
+    protected int currentSelectY;
+    protected int xSel, ySel, widthSel, heightSel;
+    protected int sel = 5;
+    protected boolean showSelectionZone = false;
+    protected boolean selectedTemp = true;
+    protected boolean select = false;
+
+    private boolean isScaled;
+    private boolean overcomeShowing = false;
+    private boolean drawingMain = true;
+
+
+    //protected Image offScreenBuffer;
+
+    public JScrollDiagramPanel jsp;
+
+    // for translation process
+    public int count = 0;
+
+    // Panels
+    public TURTLEPanel tp;
+
+    // For displaying or not parameters
+    protected boolean synchroVisible = true, attributesVisible = true, gatesVisible = true, channelVisible = true;
+    protected boolean javaVisible = false;
+    protected int internalCommentVisible = 0;
+    protected boolean channelsVisible = true, eventsVisible = true, requestsVisible = true;
+    protected int attributesOn = 0;
+
+    public final int OFF = 0;
+    public final int PARTIAL = 1;
+    public final int FULL = 2;
+
+    int adjustMode = 0;
+
+    // DIPLO ID -> for simulation purpose
+    public static boolean DIPLO_ANIMATE_ON;
+    public static boolean DIPLO_ID_ON;
+    public static boolean DIPLO_TRANSACTION_PROGRESSION_ON;
+
+    // TEPE ID -> for simulation purpose
+    public static boolean TEPE_ID_ON;
+
+    // AVATAR ID -> for simulation purpose
+    public static boolean AVATAR_ID_ON;
+    public static boolean AVATAR_ANIMATE_ON;
+
+
+    public boolean drawable = true;
+    public static final int MOVE_SPEED = 1; //Speed of component moving with arrow keys
+
+
+    // Constructor
+    public TDiagramPanel(MainGUI _mgui, TToolBar _ttb) {
+        setBackground(ColorManager.DIAGRAM_BACKGROUND);
+        //setBackground(Color.red);
+        //setMinimumSize(new Dimension(1000, 1000));
+        //setMaximumSize(new Dimension(1000, 1000));
+        setPreferredSize(new Dimension(maxX + limit, maxY + limit));
+        componentList = new LinkedList<>();
+        mgui = _mgui;
+        ttb = _ttb;
+        mode = NORMAL;
+
+        tdmm = new TDiagramMouseManager(this);
+        addMouseListener(tdmm);
+        addMouseMotionListener(tdmm);
+
+        pkl = new PanelKeyListener(this);
+        addKeyListener(pkl);
+
+        setFocusable(true);
+
+        buildPopupMenus();
+    }
+
+    // Abstract operations
+    public abstract boolean actionOnDoubleClick(TGComponent tgc);
+
+    public abstract boolean actionOnAdd(TGComponent tgc);
+
+    public abstract boolean actionOnRemove(TGComponent tgc);
+
+    public abstract boolean actionOnValueChanged(TGComponent tgc);
+
+    public abstract String getXMLHead();
+
+    public abstract String getXMLTail();
+
+    public abstract String getXMLSelectedHead();
+
+    public abstract String getXMLSelectedTail();
+
+    public abstract String getXMLCloneHead();
+
+    public abstract String getXMLCloneTail();
+
+    public void setName(String _name) {
+        name = _name;
+    }
+
+    public double getZoom() {
+        return zoom;
+    }
+
+    /*public int getFontSize() {
+      return (int)(Math.round(7.5*zoom+4.5));
+      }*/
+
+    public int getFontSize() {
+        return (int) (Math.round(12 * zoom));
+    }
+
+    private FontMetrics savedFontMetrics = null;
+
+    public int stringWidth(Graphics g, String str) {
+        if (this.savedFontMetrics == null)
+            this.savedFontMetrics = g.getFontMetrics(new Font(Font.SANS_SERIF, Font.PLAIN, this.getFontSize()));
+        return this.savedFontMetrics.stringWidth(str);
+    }
+
+    public void forceZoom(double _zoom) {
+        zoom = _zoom;
+    }
+
+    public void setZoom(double _zoom) {
+        //TraceManager.addDev("Begin Setting zoom of " + getName() + " to " + zoom + " current zoom=" + zoom + " maxX=" + maxX + " maxY=" + maxY);
+
+        final double zoomChange = _zoom / zoom;
+
+        if (_zoom < zoom) {
+            if (zoom > 0.199) {
+                zoom = _zoom;
+                this.savedFontMetrics = null;
+            }
+        } else {
+            if (zoom < 5) {
+                zoom = _zoom;
+                this.savedFontMetrics = null;
+            }
+        }
+
+        // Issue #14: We need to resize the diagram as well
+        final int maxXPrev = maxX;
+        final int maxYPrev = maxY;
+        maxX = (int) Math.round(zoomChange * maxX);
+        maxY = (int) Math.round(zoomChange * maxY);
+
+        if (maxXPrev != maxX || maxYPrev != maxY) {
+            mgui.changeMade(this, DIAGRAM_RESIZED);
+            updateSize();
+        }
+
+        updateComponentsAfterZoom();
+
+        //TraceManager.addDev("end Setting zoom of " + getName() + " to " + zoom + " maxX=" + maxX + " maxY=" + maxY);
+    }
+
+    public boolean isDrawingMain() {
+        return drawingMain;
+    }
+
+    protected void updateComponentsAfterZoom() {
+        //TraceManager.addDev("Zoom factor=" + zoom);
+        boolean change = false;
+
+        for (TGComponent tgc : this.componentList) {
+            //TraceManager.addDev("Testing for " + tgc.getClass());
+
+            if (tgc instanceof ScalableTGComponent) {
+                ((ScalableTGComponent) tgc).rescale(zoom);
+                change = true;
+            }
+        }
+
+        if (change) {
+            mgui.changeMade(this, MOVE_COMPONENT);
+            repaint();
+        }
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String toString() {
+        return name;
+    }
+
+    public void removeAll() {
+        this.componentList = new LinkedList<>();
+    }
+
+
+    public void setInternalCommentVisible(int mode) {
+        internalCommentVisible = mode;
+    }
+
+    public int getInternalCommentVisible() {
+        return internalCommentVisible;
+    }
+
+    public void structureChanged() {
+        for (TGComponent tgc : this.componentList)
+            tgc.TDPStructureChanged();
+    }
+
+    public void setAttributes(int _attr) {
+        attributesOn = _attr;
+    }
+
+    public int getAttributeState() {
+        return attributesOn;
+    }
+
+    public void valueChanged() {
+        for (TGComponent tgc : this.componentList)
+            tgc.TDPvalueChanged();
+    }
+
+    public int makeLovelyIds(int id) {
+        for (TGComponent tgc : this.componentList)
+            id = tgc.makeLovelyIds(id);
+
+        return id;
+    }
+
+    public void selectTab(String name) {
+        mgui.selectTab(tp, name);
+    }
+
+
+    @Override
+    protected void paintComponent(Graphics g) {
+        paintMycomponents(g);
+    }
+
+    public void paintMycomponents(Graphics g) {
+        paintMycomponents(g, true, 1, 1);
+    }
+
+    public void basicPaintMyComponents(Graphics g) {
+        TGComponent tgc;
+        for (int i = componentList.size() - 1; i >= 0; i--) {
+            tgc = this.componentList.get(i);
+            if (!tgc.isHidden()) {
+                //TraceManager.addDev("Painting " + tgc.getName() + " x=" + tgc.getX() + " y=" + tgc.getY());
+                tgc.draw(g);
+            } else {
+                //TraceManager.addDev("Ignoring " + tgc.getName() + " x=" + tgc.getX() + " y=" + tgc.getY());
+            }
+        }
+    }
+
+    private Font fontToUse = null;
+
+    public void paintMycomponents(Graphics g, boolean b, double w, double h) {
+        if (!drawable) {
+            return;
+        }
+
+
+        if (this.fontToUse == null)
+            this.fontToUse = g.getFont();
+        else
+            g.setFont(fontToUse);
+
+        // this.lastGraphics = g;
+        this.drawingMain = b;
+
+        if (!this.overcomeShowing && !this.isShowing()) {
+            TraceManager.addDev("Not showing!" + tp);
+            return;
+        }
+
+        try {
+            super.paintComponent(g);
+        } catch (Exception e) {
+            TraceManager.addDev("Got exception: " + e.getMessage());
+            return;
+        }
+
+        if (!this.draw)
+            return;
+
+        // Draw Components
+        if (w != 1.0 || h != 1.0) {
+            ((Graphics2D) g).scale(w, h);
+            this.isScaled = true;
+        } else {
+            this.isScaled = false;
+        }
+
+        // Draw every non hidden component
+        TGComponent tgc;
+        for (int i = this.componentList.size() - 1; i >= 0; i--) {
+            tgc = this.componentList.get(i);
+            if (tgc.isHidden())
+                continue;
+
+            tgc.draw(g);
+
+            // CONNECTING POINTS
+            if (this.mgui.getTypeButtonSelected() != TGComponentManager.EDIT)
+                tgc.drawTGConnectingPoint(g, this.mgui.getIdButtonSelected());
+
+            if (this.mode == MOVE_CONNECTOR_HEAD)
+                tgc.drawTGConnectingPoint(g, this.type);
+
+            if (this.javaVisible && (tgc.hasPostJavaCode() || tgc.hasPreJavaCode()))
+                tgc.drawJavaCode(g);
+
+	    //            if (this instanceof CAMSBlockDiagramPanel) //Connecting points should always be visible in System-C AMS panels
+	    //   tgc.drawTGConnectingPoint(g, this.type);
+        }
+
+        // Draw name of component selected
+        if (this.componentPointed != null) {
+            String name1 = this.componentPointed.getName();
+            if (this.componentPointed.hasFather())
+                name1 = this.componentPointed.getTopLevelName() + ": " + name1;
+        }
+
+        //Draw component being added
+        if (this.mode == ADDING_CONNECTOR) {
+            // Drawing connector
+            g.setColor(Color.red);
+            this.drawConnectorBeingAdded(g);
+            g.drawLine(x1, y1, x2, y2);
+        }
+
+        if (this.mode == SELECTING_COMPONENTS) {
+            g.setColor(Color.black);
+            GraphicLib.dashedRect(g,
+                    Math.min(this.initSelectX, this.currentSelectX),
+                    Math.min(this.initSelectY, this.currentSelectY),
+                    Math.abs(this.currentSelectX - this.initSelectX),
+                    Math.abs(this.currentSelectY - this.initSelectY));
+            if (mgui.isExperimentalOn()) {
+                g.drawString("" + currentSelectX, this.currentSelectX, initSelectY + 10);
+                g.drawString("" + currentSelectY, initSelectX, currentSelectY);
+            }
+        }
+
+        if ((this.mode == SELECTED_COMPONENTS || this.mode == MOVING_SELECTED_COMPONENTS) && this.selectedTemp) {
+            if (this.showSelectionZone) {
+                if (this.mode == MOVING_SELECTED_COMPONENTS)
+                    g.setColor(ColorManager.MOVING_0);
+                else
+                    g.setColor(ColorManager.POINTER_ON_ME_0);
+
+                GraphicLib.setMediumStroke(g);
+            } else {
+                g.setColor(ColorManager.NORMAL_0);
+            }
+            GraphicLib.dashedRect(g, xSel, ySel, widthSel, heightSel);
+            g.fillRect(xSel - sel, ySel - sel, 2 * sel, 2 * sel);
+            g.fillRect(xSel - sel + widthSel, ySel - sel, 2 * sel, 2 * sel);
+            g.fillRect(xSel - sel, ySel - sel + heightSel, 2 * sel, 2 * sel);
+            g.fillRect(xSel - sel + widthSel, ySel - sel + heightSel, 2 * sel, 2 * sel);
+            if (showSelectionZone) {
+                GraphicLib.setNormalStroke(g);
+            }
+        }
+
+        // Draw new Component head
+        if (mode == MOVE_CONNECTOR_HEAD) {
+            g.setColor(ColorManager.MOVING_0);
+            GraphicLib.dashedLine(g, x1, y1, x2, y2);
+        }
+
+        if ((this instanceof TDPWithAttributes) && (getAttributeState() != 0)) {
+            //TraceManager.addDev("Tdp with attributes");
+            for (int i = this.componentList.size() - 1; i >= 0; i--) {
+                tgc = this.componentList.get(i);
+                if (!tgc.isHidden()) {
+                    tgc.drawWithAttributes(g);
+                }
+            }
+        }
+
+        if (b)
+            mgui.drawBird();
+    }
+
+    public boolean isScaled() {
+        return isScaled;
+    }
+
+    public void drawConnectorBeingAdded(Graphics g) {
+        int s = listPoint.size();
+        Point p3, p4;
+        if (s > 0) {
+            p3 = listPoint.elementAt(0);
+            g.drawLine(p1.getX(), p1.getY(), p3.x, p3.y);
+            for (int i = 0; i < s - 1; i++) {
+                p3 = listPoint.elementAt(i);
+                p4 = listPoint.elementAt(i + 1);
+                g.drawLine(p3.x, p3.y, p4.x, p4.y);
+            }
+        }
+    }
+
+    /*protected void drawDIPLOID(Graphics g) {
+      if (!(tdp instanceof TMLActivityDiagramPanel)) {
+      return;
+      }
+
+      Color c = g.getColor();
+      g.setColor(ColorManager.DIPLOID);
+
+      TGComponent tgc;
+      for(int i=componentList.size()-1; i>=0; i--) {
+      tgc = (TGComponent)(componentList.get(i));
+      if (!tgc.isHidden()) {
+      if (tgc.getDIPLOID
+      g.drawString(tgc.getDIPLOID(), x+width, y.height + 5);
+      }
+      }
+
+      g.setColor(c);
+      }*/
+
+    public void loadFromXML(String s) {
+        this.componentList = new LinkedList<>();
+
+        mode = NORMAL;
+    }
+
+    public StringBuffer saveSelectedInXML() {
+        StringBuffer s = componentsInXML(true);
+        if (s == null) {
+            return null;
+        }
+        StringBuffer sb = new StringBuffer(getXMLSelectedHead());
+        sb.append("\n");
+        sb.append(s);
+        sb.append("\n");
+        sb.append(getXMLSelectedTail());
+
+        //TraceManager.addDev("xml of selected components:" + sb);
+
+        return sb;
+    }
+
+    public StringBuffer saveInXML() {
+        StringBuffer s = componentsInXML(false);
+        if (s == null) {
+            return null;
+        }
+
+        StringBuffer sb = new StringBuffer(getXMLHead());
+        sb.append("\n");
+        sb.append(s);
+        sb.append("\n");
+        sb.append(getXMLTail());
+        return sb;
+    }
+
+    public StringBuffer saveComponentInXML(TGComponent tgc) {
+        StringBuffer sb = new StringBuffer(getXMLCloneHead());
+        sb.append("\n");
+        sb.append(tgc.saveInXML());
+        sb.append("\n");
+        sb.append(getXMLCloneTail());
+        //TraceManager.addDev("sb=\n" + sb);
+        return sb;
+    }
+
+    private StringBuffer componentsInXML(boolean selected) {
+        StringBuffer sb = new StringBuffer();
+        StringBuffer s;
+
+        //Added by Solange to see the components in the list
+        //    LinkedList<TGComponent> ruteoList = this.componentList;
+        //
+        for (TGComponent tgc : this.componentList) {
+            if ((selected == false) || (tgc.isSelected())) {
+                s = tgc.saveInXML();
+                if (s == null) {
+                    return null;
+                }
+                sb.append(s);
+                sb.append("\n");
+            }
+        }
+
+        return sb;
+    }
+
+
+    public void activateActions(boolean b) {
+        ttb.setActive(b);
+    }
+
+    // Selecting components
+    public int selectComponentInRectangle(int x, int y, int width, int height) {
+        //TraceManager.addDev("select components in rectangle x=" + x + " y=" + y + " width=" +width + " height=" + height);
+        int cpt = 0;
+
+        for (TGComponent tgc : this.componentList) {
+            if (tgc.areAllInRectangle(x, y, width, height)) {
+                tgc.select(true);
+                //TraceManager.addDev("Selection of " + tgc);
+                tgc.setState(TGState.SELECTED);
+                cpt++;
+            } else {
+                //TraceManager.addDev("unselection of " + tgc);
+                tgc.select(false);
+                tgc.setState(TGState.NORMAL);
+            }
+        }
+
+        return cpt;
+    }
+
+    public void setSelectedTGConnectingPoint(TGConnectingPoint p) {
+        selectedConnectingPoint = p;
+    }
+
+    //author: huytruong
+    public byte hoveredComponent(int x, int y) {
+        TGComponent tgcTmp;
+        //int state;
+        //boolean b = false;
+        boolean hoveredElementFound = false;
+        byte info = 0;
+
+
+        TGComponent tmp = componentHovered;
+        componentHovered = null;
+
+        for (TGComponent tgc : this.componentList) {
+            //state = tgc.getState();
+            tgcTmp = tgc.isOnMeHL(x, y);
+            if (tgcTmp != null) {
+                if (!hoveredElementFound) {
+                    componentHovered = tgcTmp;
+                    tgc.setState(TGState.POINTER_ON_ME);
+                    hoveredElementFound = true;
+                    info = 2;
+                } else {
+                    tgc.setState(TGState.NORMAL);
+                }
+            } else {
+                tgc.setState(TGState.NORMAL);
+            }
+        }
+
+        if (tmp != componentHovered) {
+            info++;
+        }
+
+        return info;
+    }
+
+    //author:huytruong
+    public TGComponent componentHovered() {
+        return componentHovered;
+    }
+    //--
+
+    // Highlighting elements
+
+    // -> 0 No highlighted component, no change
+    // -> 1 No highlighted, change
+    // -> 2 One component highlighted, no change
+    // -> 3 One component highlighted, change
+    public byte highlightComponent(int x, int y) {
+        TGComponent tgcTmp;
+        //int state;
+        //boolean b = false;
+        boolean pointedElementFound = false;
+        byte info = 0;
+
+
+        TGComponent tmp = componentPointed;
+        componentPointed = null;
+        this.setToolTipText(null);
+        for (TGComponent tgc : this.componentList) {
+            //state = tgc.getState();
+            tgcTmp = tgc.isOnMeHL(x, y);
+            if ((tgcTmp != null && (!select || tgcTmp.isClickSelected())) || tgc.isClickSelected()) {
+                if (!pointedElementFound) {
+                    componentPointed = tgcTmp;
+                    if (componentPointed == null)
+                        componentPointed = tgc;
+                    tgc.setState(TGState.POINTED);
+                    String tooltip = componentPointed.getToolTipText();
+                    if (tooltip != null && tooltip.length() > 0) {
+                        this.setToolTipText(tooltip);
+                    }
+                    String tmpinfo = componentPointed.getStatusInformation();
+                    if (tmpinfo != null) {
+                        mgui.setStatusBarText(tmpinfo);
+                    }
+                    pointedElementFound = true;
+                    info = 2;
+                } else {
+                    tgc.setState(TGState.NORMAL);
+                }
+            } else {
+                if (tgcTmp != null && tgcTmp.father != null)
+                    tgc.setState(TGState.POINTED);
+                else
+                    tgc.setState(TGState.NORMAL);
+            }
+        }
+
+        if (tmp != componentPointed) {
+            info++;
+        }
+
+        return info;
+    }
+
+    public void highlightTGComponent(TGComponent tgc) {
+        if (!this.componentList.contains(tgc.getTopFather())) {
+            return;
+        }
+
+        highlightComponent(-1, -1);
+
+
+        if (tgc.getState() == TGState.NORMAL) {
+            if (tgc.getTopFather() == tgc) {
+                tgc.setSelectedInternalTGComponent(null);
+            } else {
+                tgc.getTopFather().setSelectedInternalTGComponent(tgc);
+            }
+            tgc.getTopFather().setState(TGState.POINTED);
+            componentPointed = tgc;
+            repaint();
+        }
+    }
+
+
+    public TGComponent componentPointed() {
+        return componentPointed;
+    }
+
+    public void updateJavaCode() {
+        mgui.setJavaPreCode(componentPointed);
+        mgui.setJavaPostCode(componentPointed);
+    }
+
+    public TGConnectingPoint findConnectingPoint(int id) {
+        TGConnectingPoint p;
+
+        for (TGComponent tgc : this.componentList) {
+            p = tgc.findConnectingPoint(id);
+            if (p != null) {
+                return p;
+            }
+        }
+        return null;
+
+    }
+
+    public TGComponent findComponentWithId(int id) {
+        for (TGComponent tgc1 : this.componentList) {
+            TGComponent tgc2 = tgc1.containsLoadedId(id);
+            if (tgc2 != null)
+                return tgc2;
+        }
+
+        return null;
+    }
+
+    public TGConnector findTGConnectorStartingAt(CDElement c) {
+        for (TGComponent tgc : this.componentList)
+            if (tgc instanceof TGConnector) {
+                TGConnector tgco = (TGConnector) tgc;
+                if (tgco.isP1(c))
+                    return tgco;
+            }
+
+        return null;
+    }
+
+    public TGConnector findTGConnectorEndingAt(CDElement c) {
+        for (TGComponent tgc : this.componentList)
+            if (tgc instanceof TGConnector) {
+                TGConnector tgco = (TGConnector) tgc;
+                if (tgco.isP2(c))
+                    return tgco;
+            }
+
+        return null;
+    }
+
+
+    public TGConnector findTGConnectorUsing(CDElement c) {
+        for (TGComponent tgc : this.componentList)
+            if (tgc instanceof TGConnector) {
+                TGConnector tgco = (TGConnector) tgc;
+                if (tgco.isP1(c))
+                    return tgco;
+                if (tgco.isP2(c))
+                    return tgco;
+            }
+
+        return null;
+    }
+
+    public boolean highlightOutAndFreeConnectingPoint(int x, int y, int type) {
+        boolean b = false;
+        boolean pointedElementFound = false;
+        selectedConnectingPoint = null;
+
+        for (TGComponent tgc : this.componentList)
+            if (pointedElementFound)
+                b = tgc.setStateTGConnectingPoint(TGConnectingPoint.NORMAL) || b;
+            else {
+                b = tgc.setStateTGConnectingPoint(TGConnectingPoint.NORMAL) || b;
+                TGConnectingPoint cp = tgc.getFreeTGConnectingPointAtAndCompatible(x, y, type);
+                if ((cp != null) && (cp.isOut()) && (cp.isFree()) && (cp.isCompatibleWith(type))) {
+                    selectedConnectingPoint = cp;
+                    pointedElementFound = true;
+                    b = cp.setState(TGConnectingPoint.SELECTED) || b;
+                } else
+                    b = tgc.setStateTGConnectingPoint(TGConnectingPoint.NORMAL) || b;
+            }
+
+        return b;
+    }
+
+    public boolean highlightInAndFreeConnectingPoint(int x, int y, int type) {
+        TGConnectingPoint cp;
+        //   int state;
+        boolean b = false;
+        boolean pointedElementFound = false;
+        selectedConnectingPoint = null;
+
+        for (TGComponent tgc : this.componentList) {
+            if (pointedElementFound == true) {
+                b = tgc.setStateTGConnectingPoint(TGConnectingPoint.NORMAL) || b;
+            }
+            if (pointedElementFound == false) {
+                cp = tgc.getFreeTGConnectingPointAtAndCompatible(x, y, type);
+                if ((cp != null) && (cp.isIn()) && (cp.isFree())) {
+                    selectedConnectingPoint = cp;
+                    pointedElementFound = true;
+                    b = cp.setState(TGConnectingPoint.SELECTED) || b;
+                } else {
+                    b = tgc.setStateTGConnectingPoint(TGConnectingPoint.NORMAL) || b;
+                }
+            }
+        }
+        return b;
+    }
+
+
+    public TGConnectingPoint getSelectedTGConnectingPoint() {
+        return selectedConnectingPoint;
+    }
+
+    /*    public CAMSConnectingPoint getSelectedCAMSConnectingPoint() {
+        return selectedCAMSConnectingPoints;
+	}*/
+
+    // Adding component
+    public TGComponent addComponent(int x, int y, boolean swallow) {
+        //TraceManager.addDev("Add component");
+        TGComponent tgc = addComponent(x, y, mgui.getIdButtonSelected(), swallow);
+        if (tgc instanceof ComponentPluginInterface) {
+            ((ComponentPluginInterface) tgc).setPlugin(mgui.getPluginSelected());
+        }
+        return tgc;
+    }
+
+    public TGComponent addComponent(int x, int y, int id, boolean swallow) {
+        TGComponent tgc = TGComponentManager.addComponent(x, y, id, this);
+        addComponent(tgc, x, y, swallow, true);
+        return tgc;
+    }
+
+    // return true if swallowed
+    public boolean addComponent(TGComponent tgc, int x, int y, boolean swallow, boolean addToList) {
+        boolean ret = false;
+        //TraceManager.addDev("add component " + tgc.getName());
+        if (tgc != null) {
+            if ((swallow) && (tgc instanceof SwallowedTGComponent)) {
+                //TraceManager.addDev("Swallowed component !");
+                SwallowTGComponent stgc = findSwallowTGComponent(x, y, tgc);
+                if (stgc != null) {
+                    if (stgc.addSwallowedTGComponent(tgc, x, y)) {
+                        tgc.wasSwallowed();
+                        ret = true;
+                    } else {
+                        if (addToList) {
+                            componentList.add(0, tgc);
+                        }
+                    }
+                } else {
+                    if (addToList) {
+                        componentList.add(0, tgc);
+                    }
+                }
+            } else {
+                if (addToList) {
+                    componentList.add(0, tgc);
+                }
+            }
+        }
+
+        if (tgc instanceof SpecificActionAfterAdd) {
+            ((SpecificActionAfterAdd) tgc).specificActionAfterAdd();
+        }
+
+        return ret;
+    }
+
+    public SwallowTGComponent findSwallowTGComponent(int x, int y) {
+        return findSwallowTGComponent(x, y, null);
+    }
+
+    public SwallowTGComponent findSwallowTGComponent(int x, int y, TGComponent tgcdiff) {
+        for (TGComponent tgc : this.componentList)
+            if ((tgc instanceof SwallowTGComponent) && (tgc.isOnMeHL(x, y) != null) && (tgc != tgcdiff))
+                return ((SwallowTGComponent) tgc);
+
+        return null;
+    }
+
+    public void addBuiltComponent(TGComponent tgc) {
+        if (tgc != null) {
+            this.componentList.add(tgc);
+        }
+    }
+
+    public void addBuiltConnector(TGConnector tgc) {
+        if (tgc != null) {
+            this.componentList.add(tgc);
+        }
+    }
+
+    public List<TGComponent> getComponentList() {
+        return this.componentList;
+    }
+
+    public List<TGComponent> getAllComponentList() {
+
+        List<TGComponent> ll = new LinkedList<TGComponent>();
+        ll.addAll(this.componentList);
+
+        for (TGComponent tgc : this.componentList)
+            ll.addAll(tgc.getRecursiveAllInternalComponent());
+
+        return ll;
+    }
+
+    // Adding connector
+    public void addingTGConnector() {
+        listPoint = new Vector<Point>();
+        p1 = getSelectedTGConnectingPoint();
+        x1 = p1.getX();
+        y1 = p1.getY();
+        selectedConnectingPoint.setFree(false);
+    }
+
+    public void setAddingTGConnector(int _x2, int _y2) {
+        x2 = _x2;
+        y2 = _y2;
+    }
+
+    public void addPointToTGConnector(int x, int y) {
+        listPoint.addElement(new Point(x, y));
+        x1 = x;
+        y1 = y;
+    }
+
+    public void finishAddingConnector(TGConnectingPoint p2) {
+        TGConnector tgco = TGComponentManager.addConnector(p1.getX(), p1.getY(), mgui.getIdButtonSelected(), this, p1, p2, listPoint);
+        if (tgco != null) {
+            TraceManager.addDev("Adding connector");
+            p2.setFree(false);
+            this.componentList.add(0, tgco);
+            if (tgco instanceof SpecificActionAfterAdd) {
+                ((SpecificActionAfterAdd) tgco).specificActionAfterAdd();
+            }
+            stopAddingConnector(false);
+            p1.setFree(false);
+            p1 = null;
+            p2 = null;
+        } else {
+            TraceManager.addDev("Cancel adding connector");
+            p2.setFree(true);
+            stopAddingConnector(true);
+            p1.setFree(true);
+        }
+    }
+
+    // true if connector not added
+    public void stopAddingConnector(boolean b) {
+        if (p1 != null) {
+            p1.setFree(true);
+        }
+        x1 = -1;
+        x2 = -1;
+        y1 = -1;
+        y2 = -1;
+        listPoint = null;
+    }
+
+    /*   public void addingCAMSConnector() {
+        listPoint = new Vector<Point>();
+        cp1 = getSelectedCAMSConnectingPoint();
+        x1 = cp1.getX();
+        y1 = cp1.getY();
+        selectedConnectingPoint.setFree(false);
+    }
+
+    public void setAddingCAMSConnector(int _x2, int _y2) {
+        x2 = _x2;
+        y2 = _y2;
+    }
+
+    public void addPointToCAMSConnector(int x, int y) {
+        listPoint.addElement(new Point(x, y));
+        x1 = x;
+        y1 = y;
+	}*/
+
+    /*  public void finishAddingConnector(CAMSConnectingPoint cp2) {
+        CAMSBlockConnector camsco = TGComponentManager.addCAMSConnector(cp1.getX(), cp1.getY(), mgui.getIdButtonSelected(), this, cp1, cp2, listPoint);
+        if (camsco != null) {
+            TraceManager.addDev("Adding connector");
+            cp2.setFree(false);
+            this.componentList.add(0, camsco);
+            if (camsco instanceof SpecificActionAfterAdd) {
+                ((SpecificActionAfterAdd) camsco).specificActionAfterAdd();
+            }
+            stopAddingConnector(false);
+            cp1.setFree(false);
+            cp1 = null;
+            cp2 = null;
+        } else {
+            TraceManager.addDev("Cancel adding connector");
+            cp2.setFree(true);
+            stopAddingConnector(true);
+            cp1.setFree(true);
+        }
+	}*/
+
+// -------------mark
+
+
+    public void setMovingHead(int _x1, int _y1, int _x2, int _y2) {
+        x1 = _x1;
+        y1 = _y1;
+        x2 = _x2;
+        y2 = _y2;
+    }
+
+    public void setConnectorHead(TGComponent tgc) {
+        type = TGComponentManager.getType(tgc);
+        //TraceManager.addDev("class tgc=" + tgc.getClass());
+        //TraceManager.addDev("type=" + type);
+    }
+
+
+    // Multi-select
+    public void setSelectingComponents(int x, int y) {
+        x = Math.min(Math.max((int) (Math.floor(minLimit * zoom)), x), (int) (Math.ceil(maxX * zoom)));
+        y = Math.min(Math.max((int) (Math.floor(minLimit * zoom)), y), (int) (Math.ceil(maxY * zoom)));
+        //        x = Math.min(Math.max(minLimit*zoom, x), maxX*zoom);
+        //y = Math.min(Math.max(minLimit*zoom, y), maxY*zoom);
+        initSelectX = x;
+        currentSelectX = x;
+        initSelectY = y;
+        currentSelectY = y;
+    }
+
+    public void updateSelectingComponents(int x, int y) {
+        //x = Math.min(Math.max((int) Math.floor(minLimit * zoom), x), (int) Math.ceil(maxX * zoom));
+        //y = Math.min(Math.max((int) Math.floor(minLimit * zoom), y), (int) Math.ceil(maxY * zoom));
+        x = Math.min(Math.max(minLimit, x), maxX);
+        y = Math.min(Math.max(minLimit, y), maxY);
+        currentSelectX = x;
+        currentSelectY = y;
+
+        selectComponentInRectangle(Math.min(currentSelectX, initSelectX), Math.min(currentSelectY, initSelectY), Math.abs(currentSelectX - initSelectX), Math.abs(currentSelectY - initSelectY));
+    }
+
+    public void endSelectComponents() {
+        int nb = selectComponentInRectangle(Math.min(currentSelectX, initSelectX), Math.min(currentSelectY, initSelectY), Math.abs(currentSelectX - initSelectX), Math.abs(currentSelectY - initSelectY));
+        if (nb == 0) {
+            mode = NORMAL;
+            mgui.setMode(MainGUI.CUTCOPY_KO);
+            mgui.setMode(MainGUI.EXPORT_LIB_KO);
+            mgui.actions[TGUIAction.MOVE_ENABLED].setEnabled(false);
+            mgui.actions[TGUIAction.ACT_DELETE].setEnabled(false);
+        } else {
+            TraceManager.addDev("Number of selected components:" + nb);
+            mode = SELECTED_COMPONENTS;
+            mgui.setMode(MainGUI.CUTCOPY_OK);
+            mgui.setMode(MainGUI.EXPORT_LIB_OK);
+            mgui.actions[TGUIAction.MOVE_ENABLED].setEnabled(true);
+            mgui.actions[TGUIAction.ACT_DELETE].setEnabled(true);
+            showSelectionZone = true;
+            xSel = Math.min(currentSelectX, initSelectX);
+            ySel = Math.min(currentSelectY, initSelectY);
+            widthSel = Math.abs(currentSelectX - initSelectX);
+            heightSel = Math.abs(currentSelectY - initSelectY);
+        }
+    }
+
+    public void unselectSelectedComponents() {
+        for (TGComponent tgc : this.componentList) {
+            tgc.select(false);
+            tgc.setState(TGState.NORMAL);
+        }
+    }
+
+    /**
+     * Unselect all components (triggered when a single click is done)
+     *
+     * @author Fabien Tessier
+     */
+    public void unselectClickSelectedComponents() {
+        for (TGComponent tgc : this.componentList) {
+            tgc.select(false);
+            tgc.clickSelect(false);
+            tgc.setState(TGState.NORMAL);
+            for (TGComponent tgcTmp : tgc.getRecursiveAllInternalComponent()) {
+                tgcTmp.select(false);
+                tgcTmp.clickSelect(false);
+                tgcTmp.setState(TGState.NORMAL);
+            }
+        }
+    }
+
+    public boolean showSelectionZone(int x, int y) {
+        if (GraphicLib.isInRectangle(x, y, xSel, ySel, widthSel, heightSel)) {
+            if (!showSelectionZone) {
+                showSelectionZone = true;
+                return true;
+            } else {
+                return false;
+            }
+        } else {
+            if (showSelectionZone) {
+                showSelectionZone = false;
+                return true;
+            } else {
+                return false;
+            }
+        }
+    }
+
+    public void setMovingSelectedComponents() {
+        for (TGComponent tgc : this.componentList)
+            if (tgc.isSelected())
+                tgc.setState(TGState.MOVING);
+    }
+
+    public void setStopMovingSelectedComponents() {
+        for (TGComponent tgc : this.componentList)
+            if (tgc.isSelected())
+                tgc.setState(TGState.SELECTED);
+    }
+
+    public int getXSelected() {
+        return xSel;
+    }
+
+    public int getYSelected() {
+        return ySel;
+    }
+
+    public boolean isInSelectedRectangle(int x, int y) {
+        return GraphicLib.isInRectangle(x, y, xSel, ySel, widthSel, heightSel);
+    }
+
+    public void moveSelected(int x, int y) {
+        x = Math.min(Math.max(minLimit, x), maxX - widthSel);
+        y = Math.min(Math.max(minLimit, y), maxY - heightSel);
+
+        int oldX = xSel;
+        int oldY = ySel;
+        xSel = x;
+        ySel = y;
+        for (TGComponent tgc : this.componentList)
+            if (tgc.isSelected()) {
+                if ((xSel-oldX != 0 ) || (ySel-oldY != 0 )) {
+                    /*TraceManager.addDev("" + tgc + " is selected oldX=" + xSel +
+                            " oldY=" + oldY + " xSel=" + xSel + " ySel=" + ySel);*/
+                }
+                tgc.forceMove(xSel - oldX, ySel - oldY);
+
+            }
+    }
+
+    public TGComponent nextSelectedComponent() {
+        for (TGComponent tgc : this.componentList)
+            if (tgc.isSelected())
+                return tgc;
+
+        return null;
+    }
+
+    public Vector<TCDTClass> selectedTclasses() {
+        Vector<TCDTClass> v = null;
+
+        for (TGComponent tgc : this.componentList)
+            if ((tgc.isSelected()) && (tgc instanceof TCDTClass)) {
+                if (v == null)
+                    v = new Vector<TCDTClass>();
+
+                v.addElement((TCDTClass) tgc);
+            }
+
+        return v;
+    }
+
+    public Vector<TOSClass> selectedTURTLEOSClasses() {
+        Vector<TOSClass> v = null;
+
+        for (TGComponent tgc : this.componentList)
+            if ((tgc.isSelected()) && (tgc instanceof TOSClass)) {
+                if (v == null)
+                    v = new Vector<TOSClass>();
+                v.addElement((TOSClass) tgc);
+            }
+
+        return v;
+    }
+
+    public Vector<TMLTaskOperator> selectedTMLTasks() {
+        Vector<TMLTaskOperator> v = null;
+
+        for (TGComponent tgc : this.componentList)
+            if ((tgc.isSelected()) && (tgc instanceof TMLTaskOperator)) {
+                if (v == null)
+                    v = new Vector<TMLTaskOperator>();
+                v.addElement((TMLTaskOperator) tgc);
+            }
+
+        return v;
+    }
+
+    public Vector<AvatarBDBlock> selectedAvatarBDBlocks() {
+        Vector<AvatarBDBlock> v = null;
+
+        for (TGComponent tgc : this.componentList)
+            if ((tgc.isSelected()) && (tgc instanceof AvatarBDBlock)) {
+                if (v == null)
+                    v = new Vector<AvatarBDBlock>();
+                v.addElement((AvatarBDBlock) tgc);
+                v.addAll(((AvatarBDBlock) tgc).getFullBlockList());
+            }
+
+        return v;
+    }
+
+    public Vector<TMLCPrimitiveComponent> selectedCPrimitiveComponent() {
+        Vector<TMLCPrimitiveComponent> v = null;
+
+        for (TGComponent tgc : this.componentList)
+            if (tgc.isSelected()) {
+                if (tgc instanceof TMLCPrimitiveComponent) {
+                    if (v == null)
+                        v = new Vector<TMLCPrimitiveComponent>();
+                    v.addElement((TMLCPrimitiveComponent) tgc);
+                }
+
+                if (tgc instanceof TMLCCompositeComponent) {
+                    if (v == null)
+                        v = new Vector<TMLCPrimitiveComponent>();
+                    v.addAll(((TMLCCompositeComponent) (tgc)).getAllPrimitiveComponents());
+                }
+            }
+
+        return v;
+    }
+
+    // For Design panels (TURTLE, TURTLE-OS, etc.)
+    public TClassSynchroInterface getTClass1ToWhichIamConnected(CompositionOperatorInterface coi) {
+
+        TGConnector tgca = getTGConnectorAssociationOf(coi);
+        TGComponent tgc;
+        if (tgca != null) {
+            tgc = getTopComponentToWhichBelongs(tgca.getTGConnectingPointP1());
+            if ((tgc != null) && (tgc instanceof TClassInterface)) {
+                return (TClassSynchroInterface) tgc;
+            }
+        }
+        return null;
+    }
+
+    public TClassSynchroInterface getTClass2ToWhichIamConnected(CompositionOperatorInterface coi) {
+
+        TGConnector tgca = getTGConnectorAssociationOf(coi);
+        TGComponent tgc;
+        if (tgca != null) {
+            tgc = getTopComponentToWhichBelongs(tgca.getTGConnectingPointP2());
+            if ((tgc != null) && (tgc instanceof TClassInterface)) {
+                return (TClassSynchroInterface) tgc;
+            }
+        }
+        return null;
+    }
+
+    public TGConnector getTGConnectorAssociationOf(CompositionOperatorInterface coi) {
+        int i;
+        TGConnectingPoint p1, p2;
+        TGConnector tgco;
+        TGConnectorAttribute tgca;
+        TGComponent tgc;
+
+        for (i = 0; i < coi.getNbConnectingPoint(); i++) {
+            p1 = coi.tgconnectingPointAtIndex(i);
+            tgco = getConnectorConnectedTo(p1);
+            if ((tgco != null) && (tgco instanceof TGConnectorAttribute)) {
+                tgca = (TGConnectorAttribute) tgco;
+                if (p1 == tgca.getTGConnectingPointP1()) {
+                    p2 = tgca.getTGConnectingPointP2();
+                } else {
+                    p2 = tgca.getTGConnectingPointP1();
+                }
+
+                // p2 now contains the connecting point of a association
+                tgc = getComponentToWhichBelongs(p2);
+                if ((tgc != null) && (!p2.isFree()) && (tgc instanceof TGConnectorAssociation)) {
+                    return (TGConnectorAssociation) tgc;
+                }
+            }
+        }
+        return null;
+    }
+
+
+    // Popup menus
+
+    private void buildComponentPopupMenu(TGComponent tgc, int x, int y) {
+        // Component Menu
+        componentMenu = new JPopupMenu();
+
+        componentMenu.add(remove);
+        componentMenu.add(edit);
+        componentMenu.add(clone);
+        componentMenu.add(bringFront);
+        componentMenu.add(bringBack);
+        componentMenu.add(enableDisable);
+        componentMenu.add(makeSquare);
+        componentMenu.addSeparator();
+        componentMenu.add(attach);
+        componentMenu.add(detach);
+        componentMenu.addSeparator();
+        componentMenu.add(hide);
+        componentMenu.add(unhide);
+        componentMenu.addSeparator();
+        componentMenu.add(setAsCryptoBlock);
+        componentMenu.add(setAsRegularBlock);
+        componentMenu.add(setJavaCode);
+        componentMenu.add(removeJavaCode);
+        componentMenu.add(setInternalComment);
+        componentMenu.add(removeInternalComment);
+        componentMenu.add(checkAccessibility);
+        componentMenu.add(checkInvariant);
+        componentMenu.add(checkLatency);
+        componentMenu.add(gotoReference);
+        componentMenu.add(checkMasterMutex);
+        componentMenu.add(breakpoint);
+
+        //author: huytruong
+        componentMenu.add(search);
+
+        tgc.addActionToPopupMenu(componentMenu, menuAL, x, y);
+    }
+
+    protected void buildDiagramPopupMenu() {
+        // Component Menu
+        diagramMenu = new JPopupMenu();
+
+        diagramMenu.add(paste);
+        diagramMenu.addSeparator();
+        diagramMenu.add(insertLibrary);
+        diagramMenu.addSeparator();
+        diagramMenu.add(upX);
+        diagramMenu.add(upY);
+        diagramMenu.add(downX);
+        diagramMenu.add(downY);
+        diagramMenu.add(fitToContent);
+        diagramMenu.add(backToMainDiagram);
+    }
+
+    private void buildSelectedPopupMenu() {
+        selectedMenu = new JPopupMenu();
+
+        selectedMenu.add(cut);
+        selectedMenu.add(copy);
+        selectedMenu.addSeparator();
+        selectedMenu.add(saveAsLibrary);
+        selectedMenu.addSeparator();
+        selectedMenu.add(captureSelected);
+    }
+
+
+    private void buildPopupMenus() {
+        menuAL = new ActionListener() {
+
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                popupAction(e);
+            }
+        };
+
+        remove = new JMenuItem("Remove");
+        remove.addActionListener(menuAL);
+
+        edit = new JMenuItem("Edit");
+        edit.addActionListener(menuAL);
+
+        clone = new JMenuItem("Clone");
+        clone.addActionListener(menuAL);
+
+        enableDisable = new JMenuItem("Enable/Disable");
+        enableDisable.addActionListener(menuAL);
+
+        bringFront = new JMenuItem("Bring to front");
+        bringFront.addActionListener(menuAL);
+
+        bringBack = new JMenuItem("Send to back");
+        bringBack.addActionListener(menuAL);
+
+        makeSquare = new JMenuItem("Make Square");
+        makeSquare.addActionListener(menuAL);
+
+        attach = new JMenuItem("Attach to a component");
+        attach.addActionListener(menuAL);
+
+        detach = new JMenuItem("Detach from a component");
+        detach.addActionListener(menuAL);
+
+        hide = new JMenuItem("Hide internal components");
+        hide.addActionListener(menuAL);
+
+        unhide = new JMenuItem("Show internal components");
+        unhide.addActionListener(menuAL);
+
+
+        setAsCryptoBlock = new JMenuItem("Set as crypto block");
+        setAsCryptoBlock.addActionListener(menuAL);
+
+        setAsRegularBlock = new JMenuItem("Set as regular block");
+        setAsRegularBlock.addActionListener(menuAL);
+
+        setJavaCode = new JMenuItem("Set Java code");
+        setJavaCode.addActionListener(menuAL);
+
+        removeJavaCode = new JMenuItem("Remove Java code");
+        removeJavaCode.addActionListener(menuAL);
+
+        setInternalComment = new JMenuItem("Set internal comment");
+        setInternalComment.addActionListener(menuAL);
+
+        removeInternalComment = new JMenuItem("Remove internal comment");
+        removeInternalComment.addActionListener(menuAL);
+
+        checkAccessibility = new JMenuItem("Check for Reachability / Liveness");
+        checkAccessibility.addActionListener(menuAL);
+
+        checkInvariant = new JMenuItem("Check for mutual exclusion");
+        checkInvariant.addActionListener(menuAL);
+
+        checkLatency = new JMenuItem("Set latency measurement checkpoint");
+        checkLatency.addActionListener(menuAL);
+
+        checkMasterMutex = new JMenuItem("Search for other states in mutual exclusion with");
+        checkMasterMutex.addActionListener(menuAL);
+
+        breakpoint = new JMenuItem("Add / remove breakpoint");
+        breakpoint.addActionListener(menuAL);
+
+        gotoReference = new JMenuItem("Go to reference");
+        gotoReference.addActionListener(menuAL);
+
+        search = new JMenuItem("External Search");
+        search.addActionListener(menuAL);
+
+        // Diagram Menu
+
+        paste = new JMenuItem("Paste");
+        paste.addActionListener(menuAL);
+
+        insertLibrary = new JMenuItem("Insert Library");
+        insertLibrary.addActionListener(menuAL);
+
+        upX = new JMenuItem("Increase diagram width");
+        upX.addActionListener(menuAL);
+
+        upY = new JMenuItem("Increase diagram height");
+        upY.addActionListener(menuAL);
+
+        downX = new JMenuItem("Decrease diagram width");
+        downX.addActionListener(menuAL);
+
+        downY = new JMenuItem("Decrease diagram height");
+        downY.addActionListener(menuAL);
+
+        fitToContent = new JMenuItem("Adjust diagram size to content");
+        fitToContent.addActionListener(new ActionListener() {
+
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                fitDiagramSizeToContent();
+            }
+        });
+
+        //Issue #62: Provide quick navigation to main diagram
+        backToMainDiagram = new JMenuItem("Back to main diagram");
+        backToMainDiagram.addActionListener(new ActionListener() {
+
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                tp.tabbedPane.setSelectedIndex(0);
+            }
+        });
+
+        // Selected Menu
+        cut = new JMenuItem("Cut");
+        cut.addActionListener(menuAL);
+
+        copy = new JMenuItem("Copy");
+        copy.addActionListener(menuAL);
+
+        saveAsLibrary = new JMenuItem("Save as library");
+        saveAsLibrary.addActionListener(menuAL);
+
+        captureSelected = new JMenuItem("Save as an Image");
+        captureSelected.addActionListener(menuAL);
+    }
+
+    public int getIncrement() {
+        return increment;
+    }
+
+    // Issue #14
+    private void fitDiagramSizeToContent() {
+        maxX = getRealMaxX();
+        maxY = getRealMaxY();
+        mgui.changeMade(this, DIAGRAM_RESIZED);
+        updateSize();
+    }
+
+    private boolean canFitDiagramSizeToContent() {
+        return maxX != getRealMaxX() || maxY != getRealMaxY();
+    }
+
+    private void increaseDiagramWidth() {
+        maxX += increment;
+        mgui.changeMade(this, DIAGRAM_RESIZED);
+        updateSize();
+    }
+
+    private void increaseDiagramHeight() {
+        maxY += increment;
+        mgui.changeMade(this, DIAGRAM_RESIZED);
+        updateSize();
+    }
+
+    private boolean canDecreaseMaxX() {
+        return maxX - increment >= getRealMaxX();
+    }
+
+    private void decreaseDiagramWidth() {
+        if (canDecreaseMaxX()) {
+            maxX -= increment;
+            mgui.changeMade(this, DIAGRAM_RESIZED);
+            updateSize();
+        }
+    }
+
+    private boolean canDecreaseMaxY() {
+        return maxY - increment >= getRealMaxY();
+    }
+
+    private void decreaseDiagramHeight() {
+        if (canDecreaseMaxY()) {
+            maxY -= increment;
+            mgui.changeMade(this, DIAGRAM_RESIZED);
+            updateSize();
+        }
+    }
+
+    private void popupAction(ActionEvent e) {
+        if (e.getSource() == remove) {
+            removeComponent(componentPopup);
+            mgui.changeMade(this, REMOVE_COMPONENT);
+            componentPopup = null;
+            repaint();
+            return;
+        }
+
+        if (e.getSource() == clone) {
+            cloneComponent(componentPopup.getTopFather());
+            repaint();
+            return;
+        }
+
+        if (e.getSource() == enableDisable) {
+            componentPopup.setEnabled(!componentPopup.isEnabled());
+            getGUI().changeMade(this, CHANGE_VALUE_COMPONENT);
+            repaint();
+            return;
+        }
+
+        if (e.getSource() == edit) {
+            if (componentPopup.doubleClick(mgui.getFrame(), 0, 0)) {
+                getGUI().changeMade(this, CHANGE_VALUE_COMPONENT);
+                repaint();
+            }
+            return;
+        }
+
+        if (e.getSource() == bringFront) {
+            bringToFront(componentPopup);
+            mgui.changeMade(this, MOVE_COMPONENT);
+            repaint();
+            return;
+        }
+
+        if (e.getSource() == bringBack) {
+            bringToBack(componentPopup);
+            mgui.changeMade(this, MOVE_COMPONENT);
+            repaint();
+            return;
+        }
+
+        if (e.getSource() == makeSquare) {
+            ((TGConnector) componentPopup).makeSquareWithoutMovingTGComponents();
+            mgui.changeMade(this, MOVE_CONNECTOR);
+            repaint();
+            return;
+        }
+
+        if (e.getSource() == attach) {
+            attach(componentPopup);
+            mgui.changeMade(this, MOVE_CONNECTOR);
+            repaint();
+            return;
+        }
+
+        if (e.getSource() == detach) {
+            detach(componentPopup);
+            mgui.changeMade(this, MOVE_CONNECTOR);
+            repaint();
+            return;
+        }
+
+        if (e.getSource() == hide) {
+            hide(componentPopup, true);
+            mgui.changeMade(this, MOVE_CONNECTOR);
+            repaint();
+            return;
+        }
+
+        if (e.getSource() == unhide) {
+            hide(componentPopup, false);
+            mgui.changeMade(this, MOVE_CONNECTOR);
+            repaint();
+            return;
+        }
+
+        if (e.getSource() == setJavaCode) {
+            boolean pre, post;
+            pre = (componentPopup instanceof PreJavaCode);
+            post = (componentPopup instanceof PostJavaCode);
+            JDialogCode jdc = new JDialogCode(mgui.getFrame(), "Setting java code", componentPopup.getPreJavaCode(), pre, componentPopup.getPostJavaCode(), post);
+            GraphicLib.centerOnParent(jdc);
+            jdc.setVisible(true); // blocked until dialog has been closed
+
+            componentPopup.setPreJavaCode(jdc.getPreCode());
+            componentPopup.setPostJavaCode(jdc.getPostCode());
+            mgui.changeMade(this, CHANGE_VALUE_COMPONENT);
+            repaint();
+            return;
+        }
+
+        if ((e.getSource() == setAsCryptoBlock) || (e.getSource() == setAsRegularBlock)) {
+
+            if (componentPopup instanceof AvatarBDBlock) {
+                AvatarBDBlock bd = (AvatarBDBlock) componentPopup;
+                if (bd.isCryptoBlock()) {
+                    bd.removeCryptoElements();
+                } else {
+                    bd.addCryptoElements();
+                }
+                repaint();
+                return;
+            }
+        }
+
+
+        if (e.getSource() == removeJavaCode) {
+            componentPopup.setPreJavaCode(null);
+            componentPopup.setPostJavaCode(null);
+            mgui.changeMade(this, CHANGE_VALUE_COMPONENT);
+            repaint();
+            return;
+        }
+
+        if (e.getSource() == setInternalComment) {
+            JDialogNote jdn = new JDialogNote(mgui.getFrame(), "Setting an internal comment", componentPopup.getInternalComment());
+            GraphicLib.centerOnParent(jdn);
+            jdn.setVisible(true); // blocked until dialog has been closed
+            componentPopup.setInternalComment(jdn.getText());
+            mgui.changeMade(this, CHANGE_VALUE_COMPONENT);
+            repaint();
+
+            return;
+        }
+
+        if (e.getSource() == removeInternalComment) {
+            componentPopup.setInternalComment(null);
+            mgui.changeMade(this, CHANGE_VALUE_COMPONENT);
+            repaint();
+            return;
+        }
+
+        if (e.getSource() == checkAccessibility) {
+            if (componentPopup instanceof CheckableAccessibility) {
+                componentPopup.setCheckableAccessibility(!componentPopup.getCheckableAccessibility());
+
+                // Issue #35: Enable the save button so that the change can be saved
+                mgui.changeMade(this, CHANGE_VALUE_COMPONENT);
+            }
+        }
+
+        if (e.getSource() == checkInvariant) {
+            if (componentPopup instanceof CheckableInvariant) {
+                componentPopup.setCheckableInvariant(!componentPopup.getCheckableInvariant());
+            }
+        }
+        if (e.getSource() == checkLatency) {
+            if (componentPopup instanceof CheckableLatency) {
+                componentPopup.setCheckLatency(!componentPopup.getCheckLatency());
+            }
+        }
+
+        if (e.getSource() == gotoReference) {
+            if (componentPopup instanceof LinkedReference) {
+                //Code for navigating to the diagram
+                if (componentPopup.reference != null) {
+                    TDiagramPanel refTDP = componentPopup.reference.getTDiagramPanel();
+                    if (refTDP != null) {
+                        mgui.selectTab(refTDP.tp);
+                        mgui.selectTab(refTDP);
+                        refTDP.highlightTGComponent(componentPopup.reference);
+                    }
+
+                }
+
+            }
+        }
+
+        if (e.getSource() == checkMasterMutex) {
+
+            if (componentPopup instanceof CheckableInvariant) {
+
+                TGComponent tmptgc = mgui.hasCheckableMasterMutex();
+                //TraceManager.addDev("Element with Master mutex: " + tmptgc);
+                if ((tmptgc != null) && (tmptgc != componentPopup)) {
+                    tmptgc.setMasterMutex(false);
+                }
+                mgui.removeAllMutualExclusionWithMasterMutex();
+                componentPopup.setMasterMutex(!componentPopup.getMasterMutex());
+                componentPopup.setMutexWith(TGComponent.MUTEX_NOT_YET_STUDIED);
+            }
+        }
+
+
+        if (e.getSource() == breakpoint) {
+            if (componentPopup instanceof AllowedBreakpoint) {
+                componentPopup.setBreakpoint(!componentPopup.getBreakpoint());
+                if (componentPopup.getDIPLOID() != -1) {
+                    if (componentPopup.getBreakpoint()) {
+                        mgui.addBreakPoint(componentPopup.getDIPLOID());
+                    } else {
+                        mgui.removeBreakPoint(componentPopup.getDIPLOID());
+                    }
+                }
+            }
+        }
+
+        //author: huytruong
+        //event for selecting "search" option in popup menu
+        if (e.getSource() == search) {
+            mgui.showExternalSearch();
+            return;
+        }
+        //--
+
+        if (e.getSource() == upX) {
+            increaseDiagramWidth();
+//            maxX += increment;
+//            updateSize();
+            return;
+        }
+
+        if (e.getSource() == upY) {
+            increaseDiagramHeight();
+//            maxY += increment;
+//            updateSize();
+            return;
+        }
+
+        if (e.getSource() == downX) {
+
+            // Issue #14
+            decreaseDiagramWidth();
+//        	maxX -= increment;
+//            updateSize();
+            return;
+        }
+
+        if (e.getSource() == downY) {
+
+            // Issue #14
+            decreaseDiagramHeight();
+//            maxY -= increment;
+//            updateSize();
+            return;
+        }
+
+        /*if (e.getSource() == rename) {
+          mgui.renameTab(this);
+          return;
+          }
+
+          if (e.getSource() == delete) {
+          mgui.deleteTab(this);
+          return;
+          }*/
+
+        if (e.getSource() == cut) {
+            makeCut();
+            return;
+        }
+
+        if (e.getSource() == copy) {
+            makeCopy();
+        }
+
+        if (e.getSource() == saveAsLibrary) {
+            saveAsLibrary();
+        }
+
+        if (e.getSource() == captureSelected) {
+            captureSelected();
+        }
+
+        if (e.getSource() == paste) {
+            makePaste(popupX, popupY);
+            return;
+        }
+
+        if (e.getSource() == insertLibrary) {
+            insertLibrary(popupX, popupY);
+            return;
+        }
+
+        if (componentPopup != null) {
+            if (componentPopup.eventOnPopup(e)) {
+                mgui.changeMade(this, CHANGE_VALUE_COMPONENT);
+                repaint();
+                return;
+            }
+        }
+    }
+
+    public void openPopupMenu(int x, int y) {
+        popupX = x;
+        popupY = y;
+        if (componentPointed != null) {
+            componentPopup = componentPointed;
+            buildComponentPopupMenu(componentPopup, x, y);
+            setComponentPopupMenu();
+            componentMenu.show(this, x, y);
+            //TraceManager.addDev("closed");
+        } else if ((mode == SELECTED_COMPONENTS) && (GraphicLib.isInRectangle(x, y, xSel, ySel, widthSel, heightSel))) {
+            buildSelectedPopupMenu();
+            setSelectedPopupMenu();
+            selectedMenu.show(this, x, y);
+        } else {
+            buildDiagramPopupMenu();
+            setDiagramPopupMenu();
+            diagramMenu.show(this, x, y);
+        }
+    }
+
+    private void setComponentPopupMenu() {
+
+        //author: huytruong
+        search.setEnabled(true);
+
+
+        if (!componentPointed.isRemovable()) {
+            remove.setEnabled(false);
+        } else {
+            remove.setEnabled(true);
+        }
+
+        if (!componentPointed.isEditable()) {
+            edit.setEnabled(false);
+        } else {
+            edit.setEnabled(true);
+        }
+
+        if (componentPointed.isCloneable()) {
+            /*if (componentPointed.hasFather()) {
+              clone.setEnabled(false);
+              } else {*/
+            clone.setEnabled(true);
+            //}
+        } else {
+            clone.setEnabled(false);
+        }
+
+        if (componentPointed instanceof CanBeDisabled) {
+            /*if (componentPointed.hasFather()) {
+              clone.setEnabled(false);
+              } else {*/
+            enableDisable.setEnabled(true);
+            //}
+        } else {
+            enableDisable.setEnabled(false);
+        }
+
+        if (componentPointed instanceof SwallowedTGComponent) {
+            if (componentPointed.getFather() == null) {
+                attach.setEnabled(true);
+                detach.setEnabled(false);
+            } else {
+                attach.setEnabled(false);
+                detach.setEnabled(true);
+            }
+        } else {
+            attach.setEnabled(false);
+            detach.setEnabled(false);
+        }
+
+        if (componentPointed instanceof HiddenInternalComponents) {
+            boolean hidden = ((HiddenInternalComponents) componentPointed).areInternalsHidden();
+            hide.setEnabled(!hidden);
+            unhide.setEnabled(hidden);
+        } else {
+            hide.setEnabled(false);
+            unhide.setEnabled(false);
+        }
+
+        if (componentPointed instanceof TGConnector) {
+            /*if (componentPointed.hasFather()) {
+              clone.setEnabled(false);
+              } else {*/
+            makeSquare.setEnabled(true);
+            //}
+        } else {
+            makeSquare.setEnabled(false);
+        }
+
+        if ((componentPointed instanceof PreJavaCode) || (componentPointed instanceof PostJavaCode)) {
+            setJavaCode.setEnabled(true);
+            removeJavaCode.setEnabled(true);
+        } else {
+            setJavaCode.setEnabled(false);
+            removeJavaCode.setEnabled(false);
+        }
+
+        if (componentPointed instanceof AvatarBDBlock) {
+            AvatarBDBlock block = (AvatarBDBlock) componentPointed;
+            setAsCryptoBlock.setEnabled(!block.isCryptoBlock());
+            setAsRegularBlock.setEnabled(block.isCryptoBlock());
+        } else {
+            setAsRegularBlock.setEnabled(false);
+            setAsCryptoBlock.setEnabled(false);
+        }
+
+
+        if (componentPointed instanceof EmbeddedComment) {
+            setInternalComment.setEnabled(true);
+            removeInternalComment.setEnabled(true);
+        } else {
+            setInternalComment.setEnabled(false);
+            removeInternalComment.setEnabled(false);
+        }
+
+        if (componentPointed instanceof CheckableAccessibility) {
+            checkAccessibility.setEnabled(true);
+        } else {
+            checkAccessibility.setEnabled(false);
+
+        }
+
+        if (componentPointed instanceof CheckableLatency) {
+            checkLatency.setEnabled(true);
+        } else {
+            checkLatency.setEnabled(false);
+
+        }
+
+
+        if (componentPointed instanceof LinkedReference) {
+            gotoReference.setEnabled(true);
+        } else {
+            gotoReference.setEnabled(false);
+
+        }
+
+        if (componentPointed instanceof CheckableInvariant) {
+            checkInvariant.setEnabled(true);
+            checkMasterMutex.setEnabled(true);
+        } else {
+            checkInvariant.setEnabled(false);
+            checkMasterMutex.setEnabled(false);
+        }
+
+        if (componentPointed instanceof AllowedBreakpoint) {
+            breakpoint.setEnabled(true);
+        } else {
+            breakpoint.setEnabled(false);
+        }
+    }
+
+    private void setDiagramPopupMenu() {
+        paste.setEnabled(copyData != null);
+        insertLibrary.setEnabled(true);
+
+//        if (maxX < minimumXSize + increment) {
+//            downX.setEnabled(false);
+//        } else {
+        // Issue #14
+        downX.setEnabled(canDecreaseMaxX());
+//        }
+
+//        if (maxY < minimumYSize + increment) {
+//            downY.setEnabled(false);
+//        } else {
+        // Issue #14
+        downY.setEnabled(canDecreaseMaxY());
+//        }
+
+        fitToContent.setEnabled(canFitDiagramSizeToContent());
+
+        //Issue #62: Provide quick navigation to main diagram 
+        backToMainDiagram.setEnabled(tp.tabbedPane.getSelectedIndex() != 0);
+    }
+
+    private void setSelectedPopupMenu() {
+        cut.setEnabled(true);
+        copy.setEnabled(true);
+    }
+
+    public void makeCut() {
+        copyData = mgui.gtm.makeXMLFromSelectedComponentOfADiagram(this, getMaxIdSelected(), xSel, ySel);
+        removeAllSelectedComponents();
+        mgui.changeMade(this, REMOVE_COMPONENT);
+        mode = NORMAL;
+        mgui.setMode(MainGUI.PASTE_OK);
+        repaint();
+    }
+
+    public void makeCopy() {
+        copyData = mgui.gtm.makeXMLFromSelectedComponentOfADiagram(this, getMaxIdSelected(), xSel, ySel);
+        mgui.setMode(MainGUI.PASTE_OK);
+        return;
+    }
+
+    public void saveAsLibrary() {
+        String data = mgui.gtm.makeXMLFromSelectedComponentOfADiagram(this, getMaxIdSelected(), xSel, ySel);
+        mgui.saveAsLibrary(data);
+        return;
+    }
+
+    private void captureSelected() {
+        mgui.selectedCapture();
+    }
+
+    public void makeDelete() {
+        //TraceManager.addDev("make delete");
+        if (nextSelectedComponent() != null) {
+            removeAllSelectedComponents();
+        } else if (componentPointed != null) {
+            removeComponent(componentPointed);
+        } else {
+            return;
+        }
+        mode = NORMAL;
+        tdmm.setSelection(-1, -1);
+        mgui.setMode(MainGUI.CUTCOPY_KO);
+        mgui.setMode(MainGUI.EXPORT_LIB_KO);
+        mgui.changeMade(this, REMOVE_COMPONENT);
+        repaint();
+    }
+
+    public void makePaste(int X, int Y) {
+        if (copyData != null) {
+            try {
+                mgui.gtm.copyModelingFromXML(this, copyData, X, Y);
+            } catch (MalformedModelingException mme) {
+                TraceManager.addDev("Paste Exception: " + mme.getMessage());
+                JOptionPane.showMessageDialog(mgui.getFrame(), "Exception", "Paste failed", JOptionPane.INFORMATION_MESSAGE);
+            }
+            mgui.changeMade(this, NEW_COMPONENT);
+            repaint();
+        }
+    }
+
+    public void insertLibrary(int X, int Y) {
+        String data = mgui.loadLibrary();
+        //TraceManager.addDev(data);
+        if (data != null) {
+            try {
+                mgui.gtm.copyModelingFromXML(this, data, X, Y);
+            } catch (MalformedModelingException mme) {
+                TraceManager.addDev("Insert Library Exception: " + mme.getMessage());
+                JOptionPane.showMessageDialog(mgui.getFrame(), "Exception", "insertion of library has failed", JOptionPane.INFORMATION_MESSAGE);
+            }
+            mgui.changeMade(this, NEW_COMPONENT);
+            repaint();
+            // Added by Solange. It fills the lists of components, interfaces, etc
+            if (tp instanceof ProactiveDesignPanel)
+                mgui.gtm.generateLists((ProactiveDesignPanel) tp);
+            //
+        }
+    }
+
+    public void bringToBack(TGComponent tgc) {
+        if ((tgc instanceof SwallowedTGComponent) && (tgc.getFather() != null)) {
+            tgc.getFather().bringToBack(tgc);
+        } else {
+            tgc = tgc.getTopFather();
+            //TraceManager.addDev("Bring front: " + tgc.getName());
+            int index = componentList.indexOf(tgc);
+            if (index > -1) {
+                //TraceManager.addDev("Ok bring");
+                componentList.remove(index);
+                componentList.add(tgc);
+            }
+        }
+    }
+
+    public void bringToFront(TGComponent tgc) {
+        if ((tgc instanceof SwallowedTGComponent) && (tgc.getFather() != null)) {
+            tgc.getFather().bringToFront(tgc);
+        } else {
+            tgc = tgc.getTopFather();
+            int index = componentList.indexOf(tgc);
+            if (index > -1) {
+                componentList.remove(index);
+                componentList.add(0, tgc);
+            }
+        }
+    }
+
+    private void removeAllSelectedComponents() {
+        TGComponent tgc = nextSelectedComponent();
+        while (tgc != null) {
+            removeComponent(tgc);
+            tgc = nextSelectedComponent();
+        }
+    }
+
+    // operations
+    public void removeComponent(TGComponent tgc) {
+        fatherOfRemoved = tgc.getFather();
+
+        for (TGComponent t : this.componentList)
+            if (t == tgc) {
+                removeConnectors(tgc);
+                if (tgc instanceof TGConnector) {
+                    TGConnector tgcon = (TGConnector) tgc;
+                    tgcon.getTGConnectingPointP1().setFree(true);
+                    tgcon.getTGConnectingPointP2().setFree(true);
+                }
+                componentList.remove(tgc);
+                actionOnRemove(tgc);
+                tgc.actionOnRemove();
+                return;
+            } else {
+                //TraceManager.addDev("Testing remove internal component");
+                if (t.removeInternalComponent(tgc)) {
+                    //TraceManager.addDev("Remove internal component");
+                    removeConnectors(tgc);
+                    return;
+                }
+            }
+    }
+
+    private void removeConnectors(TGComponent tgc) {
+        for (int i = 0; i < tgc.getNbConnectingPoint(); i++) {
+            TGConnectingPoint cp = tgc.tgconnectingPointAtIndex(i);
+            Iterator<TGComponent> iterator = this.componentList.iterator();
+            while (iterator.hasNext()) {
+                TGComponent t = iterator.next();
+                if (t instanceof TGConnector) {
+                    TGConnector tgcon = (TGConnector) t;
+                    if ((cp == tgcon.getTGConnectingPointP1()) || (cp == tgcon.getTGConnectingPointP2())) {
+                        iterator.remove();
+                        actionOnRemove(t);
+                        tgcon.getTGConnectingPointP1().setFree(true);
+                        tgcon.getTGConnectingPointP2().setFree(true);
+                        for (int k = 0; k < tgcon.getNbConnectingPoint(); k++)
+                            removeOneConnector(tgcon.tgconnectingPointAtIndex(k));
+                    }
+                }
+            }
+        }
+
+        for (int i = 0; i < tgc.getNbInternalTGComponent(); i++)
+            removeConnectors(tgc.getInternalTGComponent(i));
+    }
+
+    public void removeOneConnector(TGConnectingPoint cp) {
+        Iterator<TGComponent> iterator = this.componentList.iterator();
+        while (iterator.hasNext()) {
+            TGComponent t = iterator.next();
+            if (t instanceof TGConnector) {
+                TGConnector tgcon = (TGConnector) t;
+                if ((cp == tgcon.getTGConnectingPointP1()) || (cp == tgcon.getTGConnectingPointP2())) {
+                    iterator.remove();
+                    actionOnRemove(t);
+                    tgcon.getTGConnectingPointP1().setFree(true);
+                    tgcon.getTGConnectingPointP2().setFree(true);
+                    System.out.println("removing...");
+                    TraceManager.addDev("Removed one connector!");
+                    for (int k = 0; k < tgcon.getNbConnectingPoint(); k++)
+                        removeOneConnector(tgcon.tgconnectingPointAtIndex(k));
+                }
+            }
+        }
+    }
+
+    public void cloneComponent(TGComponent _tgc) {
+        // copy
+        String clone = mgui.gtm.makeXMLFromComponentOfADiagram(this, _tgc, getMaxIdSelected(), _tgc.getX(), _tgc.getY());
+
+        //TraceManager.addDev("clone=\n"+ clone);
+
+        // paste
+
+        try {
+            mgui.gtm.copyModelingFromXML(this, clone, _tgc.getX() + 50, _tgc.getY() + 25);
+        } catch (MalformedModelingException mme) {
+            TraceManager.addDev("Clone Exception: " + mme.getMessage());
+            JOptionPane.showMessageDialog(mgui.getFrame(), "Clone creation failed", "Exception", JOptionPane.INFORMATION_MESSAGE);
+        }
+        bringToBack(_tgc);
+        mgui.changeMade(this, NEW_COMPONENT);
+    }
+
+    public MainGUI getGUI() {
+        return mgui;
+    }
+
+
+    public int getRawMinX() {
+        return minLimit;
+    }
+
+    public int getRawMaxX() {
+        return maxX;
+    }
+
+    public int getRawMinY() {
+        return minLimit;
+    }
+
+    public int getRawMaxY() {
+        return maxY;
+    }
+
+    public int getMaxX() {
+        //return maxX;
+        return (int) Math.ceil(maxX * zoom);
+    }
+
+    public int getMinX() {
+        return (int) Math.floor(minLimit * zoom);
+    }
+
+    public int getMinY() {
+        return (int) Math.floor(minLimit * zoom);
+        //return minLimit*zoom;
+    }
+
+    public int getMaxY() {
+        //return maxY;
+        return (int) Math.ceil(maxY * zoom);
+    }
+
+    public void setMaxX(int x) {
+        maxX = x;
+
+    }
+
+    public void setMinX(int x) {
+        minLimit = x;
+    }
+
+    public void setMinY(int y) {
+        minLimit = y;
+    }
+
+    public void setMaxY(int y) {
+        maxY = y;
+    }
+
+    public void updateSize() {
+        setPreferredSize(new Dimension(maxX + limit, maxY + limit));
+        revalidate();
+    }
+
+    public void attach(TGComponent tgc) {
+        if (tgc instanceof SwallowedTGComponent && tgc.tdp.addComponent(tgc, tgc.getX(), tgc.getY(), true, false))
+            // Component was attached -> must be removed from the list
+            this.componentList.remove(tgc);
+    }
+
+    public void detach(TGComponent tgc) {
+        if ((tgc instanceof SwallowedTGComponent) && (tgc.getFather() != null)) {
+            ((SwallowTGComponent) tgc.getFather()).removeSwallowedTGComponent(tgc);
+            tgc.setFather(null);
+            this.componentList.add(tgc);
+            tgc.wasUnswallowed();
+            bringToFront(tgc);
+        }
+    }
+
+    public void hide(TGComponent tgc, boolean hide) {
+        if (tgc instanceof HiddenInternalComponents) {
+            ((HiddenInternalComponents) tgc).setInternalsHidden(hide);
+        }
+    }
+
+    public String sizeParam() {
+        String s = " minX=\"" + getRawMinX() + "\"";
+        s += " maxX=\"" + getRawMaxX() + "\"";
+        s += " minY=\"" + getRawMinY() + "\"";
+        s += " maxY=\"" + getRawMaxY() + "\"";
+        return s;
+    }
+
+    public String zoomParam() {
+        String s = " zoom=\"" + getZoom() + "\"";
+        return s;
+    }
+
+    //returns the highest id amongst its components
+    public int getMaxId() {
+        int ret = 0;
+        for (TGComponent tgc : this.componentList)
+            ret = Math.max(ret, tgc.getMaxId());
+
+        return ret;
+    }
+
+    public int getMaxIdSelected() {
+        int ret = 0;
+        for (TGComponent tgc : this.componentList)
+            if (tgc.isSelected())
+                ret = Math.max(ret, tgc.getMaxId());
+
+        return ret;
+    }
+
+    public void setDraw(boolean b) {
+        draw = b;
+    }
+
+    public boolean getDraw() {
+        return draw;
+    }
+
+    public TToolBar getToolBar() {
+        return ttb;
+    }
+
+    // tell the other component connected to this connecting point
+    public TGConnector getConnectorConnectedTo(TGConnectingPoint p) {
+        for (TGComponent tgc : this.componentList)
+            if (tgc instanceof TGConnector) {
+                TGConnector tgco = (TGConnector) tgc;
+                if ((tgco.getTGConnectingPointP1() == p) || (tgco.getTGConnectingPointP2() == p))
+                    return tgco;
+            }
+
+        return null;
+    }
+
+    public TGComponent getNextTGComponent(TGComponent tgc, int index) {
+        TGConnectingPoint pt2;
+        TGConnector tgcon = getNextTGConnector(tgc, index);
+
+        if (tgcon == null) {
+            //TraceManager.addDev("TGCon is null");
+            return null;
+        }
+
+        pt2 = tgcon.getTGConnectingPointP2();
+
+        if (pt2 == null) {
+            return null;
+        }
+
+        return getTopComponentToWhichBelongs(pt2);
+    }
+
+    public TGConnector getNextTGConnector(TGComponent tgc, int index) {
+        TGConnectingPoint pt1;//, pt2;
+
+        pt1 = tgc.getNextTGConnectingPoint(index);
+
+        if (pt1 == null) {
+            //TraceManager.addDev("pt1 is null");
+            return null;
+        }
+
+        return getConnectorConnectedTo(pt1);
+    }
+
+    public TGComponent getTopComponentToWhichBelongs(TGConnectingPoint p) {
+        TGComponent tgc = getComponentToWhichBelongs(p);
+        if (tgc != null) {
+            return tgc.topTGComponent();
+        }
+        return null;
+    }
+
+    public TGComponent getComponentToWhichBelongs(TGConnectingPoint p) {
+        for (TGComponent tgc1 : this.componentList) {
+            TGComponent tgc2 = tgc1.belongsToMeOrSon(p);
+            if (tgc2 != null)
+                return tgc2;
+        }
+
+        return null;
+    }
+
+    public static TGComponent getComponentToWhichBelongs(List<TGComponent> components, TGConnectingPoint p) {
+        for (TGComponent tgc1 : components) {
+            TGComponent tgc2 = tgc1.belongsToMeOrSon(p);
+            if (tgc2 != null)
+                return tgc2;
+        }
+
+        return null;
+    }
+
+    public void getAllLatencyChecks(ArrayList<TGComponent> _list) {
+        for (TGComponent tgc : this.componentList) {
+            if (tgc.getCheckLatency()) {
+                _list.add(tgc);
+            }
+        }
+    }
+
+    public void getAllCheckedTGComponent(ArrayList<TGComponent> _list) {
+        for (TGComponent tgc : this.componentList)
+            if (tgc.hasCheckedAccessibility())
+                _list.addAll(tgc.getAllCheckedAccessibility());
+    }
+
+    public void getAllCheckableTGComponent(ArrayList<TGComponent> _list) {
+        for (TGComponent tgc : this.componentList)
+            if (tgc instanceof CheckableAccessibility)
+                _list.addAll(tgc.getAllCheckableAccessibility());
+    }
+
+    public void getAllCheckableInvariantTGComponent(ArrayList<TGComponent> _list) {
+        for (TGComponent tgc : this.componentList)
+            if (tgc.hasCheckableInvariant())
+                _list.addAll(tgc.getAllCheckableInvariant());
+    }
+
+    // Main Tree
+    public int getChildCount() {
+        return this.componentList.size();
+    }
+
+    public Object getChild(int index) {
+        return this.componentList.get(index);
+    }
+
+    public int getIndexOfChild(Object child) {
+        return this.componentList.indexOf(child);
+    }
+
+    //Tclass
+    private class NameChecker {
+        public boolean isNameAlreadyTaken(TGComponent o, String name) {
+            // Must deal with the case where mutliple the tested component
+            // inherit from multiple classes / interfaces.
+            // In such case we execute all check*** functions until one
+            // returns true, in which case we can return true;
+            return (o instanceof TClassInterface && this.checkTClassInterface((TClassInterface) o, name))
+                    || (o instanceof TCDTData && this.checkTCDTData((TCDTData) o, name))
+                    || (o instanceof TCDTObject && this.checkTCDTObject((TCDTObject) o, name))
+                    || (o instanceof TOSClass && this.checkTOSClass((TOSClass) o, name))
+                    || (o instanceof Requirement && this.checkRequirement((Requirement) o, name))
+                    || (o instanceof TMLCPrimitiveComponent && this.checkTMLCPrimitiveComponent((TMLCPrimitiveComponent) o, name))
+                    || (o instanceof TMLCRecordComponent && this.checkTMLCRecordComponent((TMLCRecordComponent) o, name))
+                    || (o instanceof TMLCCompositeComponent && this.checkTMLCCompositeComponent((TMLCCompositeComponent) o, name))
+                    || (o instanceof TMLTaskInterface && this.checkTMLTaskInterface((TMLTaskInterface) o, name))
+                    || (o instanceof ATDBlock && this.checkATDBlock((ATDBlock) o, name))
+                    || (o instanceof AvatarBDBlock && this.checkAvatarBDBlock((AvatarBDBlock) o, name))
+                    || (o instanceof AvatarCDBlock && this.checkAvatarCDBlock((AvatarCDBlock) o, name))
+                    || (o instanceof AvatarSMDState && this.checkAvatarSMDState((AvatarSMDState) o, name))
+                    || (o instanceof AvatarADActivity && this.checkAvatarADActivity((AvatarADActivity) o, name))
+                    || (o instanceof AvatarMADAssumption && this.checkAvatarMADAssumption((AvatarMADAssumption) o, name))
+                    || (o instanceof AvatarRDRequirement && this.checkAvatarRDRequirement((AvatarRDRequirement) o, name))
+                    || (o instanceof NCEqNode && this.checkNCEqNode((NCEqNode) o, name))
+                    || (o instanceof NCSwitchNode && this.checkNCSwitchNode((NCSwitchNode) o, name))
+                    || (o instanceof AvatarBDDataType && this.checkAvatarBDDataType((AvatarBDDataType) o, name))
+                    || (o instanceof AvatarBDLibraryFunction && this.checkAvatarBDLibraryFunction((AvatarBDLibraryFunction) o, name));
+        }
+
+        public boolean checkTClassInterface(TClassInterface o, String name) {
+            return false;
+        }
+
+        public boolean checkTCDTData(TCDTData o, String name) {
+            return false;
+        }
+
+        public boolean checkTCDTObject(TCDTObject o, String name) {
+            return false;
+        }
+
+        public boolean checkTOSClass(TOSClass o, String name) {
+            return false;
+        }
+
+        public boolean checkRequirement(Requirement o, String name) {
+            return false;
+        }
+
+        public boolean checkTMLCPrimitiveComponent(TMLCPrimitiveComponent o, String name) {
+            return false;
+        }
+
+        public boolean checkTMLCRecordComponent(TMLCRecordComponent o, String name) {
+            return false;
+        }
+
+        public boolean checkTMLCCompositeComponent(TMLCCompositeComponent o, String name) {
+            return false;
+        }
+
+        public boolean checkTMLTaskInterface(TMLTaskInterface o, String name) {
+            return false;
+        }
+
+        public boolean checkATDBlock(ATDBlock o, String name) {
+            return false;
+        }
+
+        public boolean checkAvatarBDBlock(AvatarBDBlock o, String name) {
+            return false;
+        }
+
+        public boolean checkAvatarCDBlock(AvatarCDBlock o, String name) {
+            return false;
+        }
+
+        public boolean checkAvatarSMDState(AvatarSMDState o, String name) {
+            return false;
+        }
+
+        public boolean checkAvatarADActivity(AvatarADActivity o, String name) {
+            return false;
+        }
+
+        public boolean checkAvatarMADAssumption(AvatarMADAssumption o, String name) {
+            return false;
+        }
+
+        public boolean checkAvatarRDRequirement(AvatarRDRequirement o, String name) {
+            return false;
+        }
+
+        public boolean checkNCEqNode(NCEqNode o, String name) {
+            return false;
+        }
+
+        public boolean checkNCSwitchNode(NCSwitchNode o, String name) {
+            return false;
+        }
+
+        public boolean checkAvatarBDDataType(AvatarBDDataType o, String name) {
+            return false;
+        }
+
+        public boolean checkAvatarBDLibraryFunction(AvatarBDLibraryFunction o, String name) {
+            return false;
+        }
+    }
+
+    private boolean isNameUnique(String name, NameChecker checker) {
+        for (TGComponent o : this.componentList)
+            if (checker.isNameAlreadyTaken(o, name))
+                return false;
+        return true;
+    }
+
+    private String findGoodName(String name, NameChecker checker) {
+        // index >= 0 catch overflows
+        for (int index = 0; index >= 0; index++) {
+            String tryName = name + index;
+            if (this.isNameUnique(tryName, checker))
+                return tryName;
+        }
+
+        throw new RuntimeException("Integer Overflow");
+    }
+
+    public String findTClassName(String name) {
+        return this.findGoodName(name, new NameChecker() {
+            public boolean checkTClassInterface(TClassInterface o, String name) {
+                return o.getClassName().equals(name);
+            }
+
+            public boolean checkTCDTData(TCDTData o, String name) {
+                return o.getValue().equals(name);
+            }
+        });
+    }
+
+    public String findTOSClassName(String name) {
+        return this.findGoodName(name, new NameChecker() {
+            public boolean checkTOSClass(TOSClass o, String name) {
+                return o.getClassName().equals(name);
+            }
+        });
+    }
+
+    public String findRequirementName(String name) {
+        return this.findGoodName(name, new NameChecker() {
+            public boolean checkRequirement(Requirement o, String name) {
+                return o.getRequirementName().equals(name);
+            }
+        });
+    }
+
+    public String findTMLPrimitiveComponentName(String name) {
+        return this.findGoodName(name, new NameChecker() {
+            public boolean checkTMLCPrimitiveComponent(TMLCPrimitiveComponent o, String name) {
+                return o.getValue().equals(name);
+            }
+
+            public boolean checkTMLCRecordComponent(TMLCRecordComponent o, String name) {
+                return o.getValue().equals(name);
+            }
+
+            public boolean checkTMLCCompositeComponent(TMLCCompositeComponent o, String name) {
+                for (int i = 0; i < o.getNbInternalTGComponent(); i++)
+                    if (this.isNameAlreadyTaken(o.getInternalTGComponent(i), name))
+                        return true;
+                return false;
+            }
+        });
+    }
+
+    public String findTMLRecordComponentName(String name) {
+        return this.findTMLPrimitiveComponentName(name);
+    }
+
+    public String findTMLTaskName(String name) {
+        return this.findGoodName(name, new NameChecker() {
+            public boolean checkTMLTaskInterface(TMLTaskInterface o, String name) {
+                return o.getTaskName().equals(name);
+            }
+        });
+    }
+
+    public String findBlockName(String name) {
+        return this.findGoodName(name, new NameChecker() {
+            public boolean checkATDBlock(ATDBlock o, String name) {
+                return o.getName().equals(name);
+            }
+        });
+    }
+
+    public String findAvatarBDBlockName(String name) {
+        return this.findGoodName(name, new NameChecker() {
+            public boolean checkAvatarBDBlock(AvatarBDBlock o, String name) {
+                if (o.getValue().equals(name))
+                    return true;
+                return o.hasInternalBlockWithName(name);
+            }
+
+            public boolean checkAvatarBDLibraryFunction(AvatarBDLibraryFunction o, String name) {
+                return o.getFunctionName().equals(name);
+            }
+
+            public boolean checkAvatarBDDataType(AvatarBDDataType o, String name) {
+                return o.getDataTypeName().equals(name);
+            }
+        });
+    }
+
+    public String findAvatarCDBlockName(String name) {
+        return this.findGoodName(name, new NameChecker() {
+            public boolean checkAvatarCDBlock(AvatarCDBlock o, String name) {
+                if (o.getValue().equals(name))
+                    return true;
+                return o.hasInternalBlockWithName(name);
+            }
+        });
+    }
+
+    /*   public String findCAMSBlockName(String name) {
+        return this.findGoodName(name, new NameChecker() {
+            public boolean checkCAMSBlock(CAMSBlock o, String name) {
+                if (o.getValue().equals(name))
+                    return true;
+                return o.hasBlockWithName();
+            }
+        });
+	}*/
+
+    public String findAvatarSMDStateName(String name) {
+        return this.findGoodName(name, new NameChecker() {
+            public boolean checkAvatarSMDState(AvatarSMDState o, String name) {
+                if (o.getValue().equals(name))
+                    return true;
+                return o.hasInternalStateWithName(name);
+            }
+        });
+    }
+
+    public String findAvatarADActivityName(String name) {
+        return this.findGoodName(name, new NameChecker() {
+            public boolean checkAvatarADActivity(AvatarADActivity o, String name) {
+                if (o.getValue().equals(name))
+                    return true;
+                return o.hasInternalActivityWithName(name);
+            }
+        });
+    }
+
+    public String findAvatarAssumptionName(String name, int start) {
+        return this.findGoodName(name, new NameChecker() {
+            public boolean checkAvatarMADAssumption(AvatarMADAssumption o, String name) {
+                return o.getValue().equals(name);
+            }
+        });
+    }
+
+    public String findAvatarRequirementName(String name, int start) {
+        return this.findGoodName(name, new NameChecker() {
+            public boolean checkAvatarRDRequirement(AvatarRDRequirement o, String name) {
+                return o.getValue().equals(name);
+            }
+        });
+    }
+
+    public String findAvatarRequirementID(String id) {
+        try {
+            // intid >= 0 catch overflows
+            for (int intid = Integer.decode(id).intValue(); intid >= 0; intid++) {
+                boolean ok = true;
+                for (TGComponent o : this.componentList)
+                    if (o instanceof AvatarRDRequirement) {
+                        AvatarRDRequirement areq = (AvatarRDRequirement) o;
+                        int otherid = Integer.decode(areq.getID()).intValue();
+                        if (intid == otherid) {
+                            ok = false;
+                            break;
+                        }
+                    }
+
+                if (ok)
+                    return Integer.toString(intid);
+            }
+        } catch (NumberFormatException e) {
+            return id;
+        }
+
+        throw new RuntimeException("Integer Overflow");
+    }
+
+    public String findTObjectName(String name) {
+        return this.findGoodName(name, new NameChecker() {
+            public boolean checkTCDTObject(TCDTObject o, String name) {
+                return o.getObjectName().equals(name);
+            }
+            //            public boolean checkTCDTClass (TCDTClass o, String name) {
+            //                return o.getClassName ().startsWith (name);
+            //            }
+        });
+    }
+
+    public String findTObjectName(String name1, String name2) {
+        // index >= 0 catch overflows
+        for (int index = 0; index >= 0; index++) {
+            boolean ok = true;
+            String tryName = name1 + index;
+
+            for (TGComponent o : this.componentList)
+                if (o instanceof TCDTObject && ((TCDTObject) o).getObjectName().equals(tryName))
+                    ok = false;
+
+            if (ok && this.isTObjectNameUnique(tryName + name2))
+                return tryName;
+        }
+
+
+        throw new RuntimeException("Integer Overflow");
+    }
+
+    public String findNodeName(String name) {
+        return this.findGoodName(name, new NameChecker() {
+            public boolean checkNCEqNode(NCEqNode o, String name) {
+                if (o.getName().equals(name))
+                    return true;
+                for (NCTrafficArtifact arti : o.getArtifactList())
+                    if (arti.getValue().equals(name))
+                        return true;
+                return false;
+            }
+
+            public boolean checkNCSwitchNode(NCSwitchNode o, String name) {
+                if (o.getName().equals(name))
+                    return true;
+                for (NCRouteArtifact arti : o.getArtifactList())
+                    if (arti.getValue().equals(name))
+                        return true;
+                return false;
+            }
+            //            public boolean checkNCConnectorNode (NCConnectorNode o, String name) {
+            //                return o.getInterfaceName ().equals (name);
+            //            }
+        });
+    }
+
+    public String findInterfaceName(String name) {
+        return this.findNodeName(name);
+    }
+
+    public boolean isAlreadyATClassName(String name) {
+        return !this.isTClassNameUnique(name);
+    }
+
+    public boolean isAlreadyATMLTaskName(String name) {
+        return !this.isTMLTaskNameUnique(name);
+    }
+
+    public boolean isAlreadyAnAvatarBDBlockName(String name) {
+        return !this.isAvatarBlockNameUnique(name);
+    }
+
+    public boolean isAlreadyATMLPrimitiveComponentName(String name) {
+        return !this.isNameUnique(name, new NameChecker() {
+            public boolean checkTMLCPrimitiveComponent(TMLCPrimitiveComponent o, String name) {
+                return o.getValue().equals(name);
+            }
+
+            public boolean checkTMLCRecordComponent(TMLCRecordComponent o, String name) {
+                return o.getValue().equals(name);
+            }
+
+            public boolean checkTMLCCompositeComponent(TMLCCompositeComponent o, String name) {
+                for (int i = 0; i < o.getNbInternalTGComponent(); i++)
+                    if (this.isNameAlreadyTaken(o.getInternalTGComponent(i), name))
+                        return true;
+                return false;
+            }
+        });
+    }
+
+    public boolean isAlreadyATOSClassName(String name) {
+        return !this.isTOSClassNameUnique(name);
+    }
+
+    public boolean isTClassNameUnique(String name) {
+        return this.isNameUnique(name, new NameChecker() {
+            public boolean checkTClassInterface(TClassInterface o, String name) {
+                return o.getClassName().equals(name);
+            }
+
+            public boolean checkTCDTData(TCDTData o, String name) {
+                return o.getValue().equals(name);
+            }
+        });
+    }
+
+    public boolean isTOSClassNameUnique(String name) {
+        return this.isNameUnique(name, new NameChecker() {
+            public boolean checkTOSClass(TOSClass o, String name) {
+                return o.getClassName().equals(name);
+            }
+        });
+    }
+
+    public boolean isTMLTaskNameUnique(String name) {
+        return this.isNameUnique(name, new NameChecker() {
+            public boolean checkTMLTaskInterface(TMLTaskInterface o, String name) {
+                return o.getTaskName().equals(name);
+            }
+        });
+    }
+
+    public boolean isBlockNameUnique(String name) {
+        return this.isNameUnique(name, new NameChecker() {
+            public boolean checkATDBlock(ATDBlock o, String name) {
+                return o.getName().equals(name);
+            }
+        });
+    }
+
+    /**
+     * Check if any other <b>block, library function or data type</b>
+     * (contrary to what the name suggests) has this name.
+     *
+     * @param name The name to check.
+     * @return true if the name is unique, false otherwise.
+     */
+    public boolean isAvatarBlockNameUnique(String name) {
+        return this.isNameUnique(name, new NameChecker() {
+            public boolean checkAvatarBDBlock(AvatarBDBlock o, String name) {
+                if (o.getValue().equals(name))
+                    return true;
+                return o.hasInternalBlockWithName(name);
+            }
+
+            public boolean checkAvatarBDLibraryFunction(AvatarBDLibraryFunction o, String name) {
+                return o.getFunctionName().equals(name);
+            }
+
+            public boolean checkAvatarBDDataType(AvatarBDDataType o, String name) {
+                return o.getDataTypeName().equals(name);
+            }
+        });
+    }
+
+    public boolean isNCNameUnique(String name) {
+        return this.isNameUnique(name, new NameChecker() {
+            public boolean checkNCEqNode(NCEqNode o, String name) {
+                if (o.getName().equals(name))
+                    return true;
+                for (NCTrafficArtifact arti : o.getArtifactList())
+                    if (arti.getValue().equals(name))
+                        return true;
+                return false;
+            }
+
+            public boolean checkNCSwitchNode(NCSwitchNode o, String name) {
+                if (o.getName().equals(name))
+                    return true;
+                for (NCRouteArtifact arti : o.getArtifactList())
+                    if (arti.getValue().equals(name))
+                        return true;
+                return false;
+            }
+            //            public boolean checkNCConnectorNode (NCConnectorNode o, String name) {
+            //                return o.getInterfaceName ().equals (name);
+            //            }
+        });
+    }
+
+    public boolean isRequirementNameUnique(String name) {
+        return this.isNameUnique(name, new NameChecker() {
+            public boolean checkRequirement(Requirement o, String name) {
+                return o.getRequirementName().equals(name);
+            }
+        });
+    }
+
+    public boolean isTObjectNameUnique(String name) {
+        // FIXME: this is not coherent with findTObjectName !!!
+        return this.isNameUnique(name, new NameChecker() {
+            public boolean checkTClassInterface(TClassInterface o, String name) {
+                return o.getClassName().equals(name);
+            }
+        });
+    }
+
+    public void setMaxPanelSize(int x, int y) {
+        maxX = x;
+        maxY = y;
+        updateSize();
+    }
+
+    // For compatibility with ttool v0.41
+    // Assumes no internal duplicate id
+    public void checkForDuplicateId() {
+        for (int i = 0; i < componentList.size(); i++) {
+            TGComponent tgc1 = componentList.get(i);
+            for (int j = 0; j < componentList.size(); j++)
+                if (j != i) {
+                    TGComponent tgc2 = componentList.get(j);
+                    tgc2 = tgc2.getIfId(tgc1.getId());
+                    if (tgc2 != null) {
+                        //TraceManager.addDev("*** Same ID ***");
+                        //TraceManager.addDev("tgc1" + tgc1.getClass());
+                        //TraceManager.addDev("tgc2" + tgc2.getClass());
+                    }
+                }
+        }
+    }
+
+    /*public void findTGComponentWithId(int id, int index) {
+      TGComponent tgc;
+
+      for(int i=index; i<componentList.size(); i++) {
+
+      }
+      }*/
+
+    public Vector<TCDTClass> getTClasses() {
+        Vector<TCDTClass> v = new Vector<TCDTClass>();
+
+        for (TGComponent o : this.componentList)
+            if (o instanceof TCDTClass)
+                v.add((TCDTClass) o);
+
+        return v;
+    }
+
+    public Vector<String> getAllDataTypes() {
+        Vector<String> v = new Vector<String>();
+
+        for (TGComponent tgc : this.componentList)
+            if (tgc instanceof AvatarBDDataType)
+                v.add(((AvatarBDDataType) (tgc)).getDataTypeName());
+
+        return v;
+    }
+
+    public void removeSynchronizedGates(List<TAttribute> v, TClassInterface t, TCDSynchroGateList tcdsgl) {
+        for (TGComponent tgc : this.componentList)
+            if (tgc instanceof TCDCompositionOperatorWithSynchro) {
+                TCDCompositionOperatorWithSynchro tgso = (TCDCompositionOperatorWithSynchro) tgc;
+
+                if (((tgso.getT1() == t) || (tgso.getT2() == t)) && tgso.getSynchroGateList() != tcdsgl) {
+                    LinkedList<TTwoAttributes> ttwoattrib = tgso.getSynchroGateList().getGates();
+                    for (TTwoAttributes tt : ttwoattrib)
+                        if (tt.t1 == t)
+                            v.remove(tt.ta1);
+                        else
+                            v.remove(tt.ta2);
+                }
+            }
+    }
+
+    public boolean isASynchronizedGate(TAttribute ta) {
+        for (TGComponent tgc : this.componentList)
+            if (tgc instanceof TCDCompositionOperatorWithSynchro) {
+                TCDCompositionOperatorWithSynchro tgso = (TCDCompositionOperatorWithSynchro) tgc;
+                LinkedList<TTwoAttributes> ttwoattrib = tgso.getSynchroGateList().getGates();
+                for (TTwoAttributes tt : ttwoattrib)
+                    if ((tt.ta1 == ta) || (tt.ta2 == ta))
+                        return true;
+            }
+
+        return false;
+    }
+
+    public boolean hasAlreadyAnInstance(TCDTObject to) {
+        for (TGComponent o : this.componentList)
+            if ((o instanceof TClassInterface) && (!o.equals(to))) {
+                TClassInterface t = (TClassInterface) o;
+                if (t.getClassName().compareTo(to.getClassName()) == 0)
+                    return true;
+            }
+
+        return false;
+    }
+
+    // updates attributes and gates
+    public void updateInstances(TCDTClass tc) {
+        for (TGComponent o : this.componentList)
+            if (o instanceof TCDTObject) {
+                TCDTObject to = (TCDTObject) o;
+                if (to.getMasterTClass() == tc) {
+                    to.updateAttributes(tc.getAttributes());
+                    to.updateGates(tc.getGates());
+                }
+            }
+    }
+
+    public void resetAllInstancesOf(TCDTClass tc) {
+        for (TGComponent o : this.componentList)
+            if (o instanceof TCDTObject) {
+                TCDTObject to = (TCDTObject) o;
+                if (to.getMasterTClass() == tc)
+                    to.reset();
+            }
+    }
+
+    public TCDTClass findTClassByName(String name) {
+        for (TGComponent o : this.componentList)
+            if (o instanceof TCDTClass) {
+                TCDTClass tc = (TCDTClass) o;
+                if (tc.getClassName().compareTo(name) == 0)
+                    return tc;
+            }
+
+        return null;
+    }
+
+    public MainGUI getMGUI() {
+        return mgui;
+    }
+
+    public BufferedImage performMinimalCapture() {
+        int w = this.getWidth();
+        int h = this.getHeight();
+        boolean b = draw;
+        BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
+        Graphics2D g = image.createGraphics();
+        g.setFont(getGraphics().getFont());
+//        if (lastGraphics != null) {
+//            g.setFont(lastGraphics.getFont());
+//        }
+        draw = true;
+        //paintMycomponents(g);
+        overcomeShowing = true;
+        paintMycomponents(g, false, 1, 1);
+        //this.paint(g);
+        overcomeShowing = false;
+        //g.dispose();
+        int x = getRealMinX();
+        int y = getRealMinY();
+        w = getRealMaxX() - x;
+        h = getRealMaxY() - y;
+        //TraceManager.addDev("x=" + x + " y=" + y + " w=" + w + " h=" + h + " getWidth = " + this.getWidth() + " getHeight = " + this.getHeight());
+        x = x - 5;
+        y = y - 5;
+        w = w + 10;
+        h = h + 10;
+        w = Math.max(0, w);
+        h = Math.max(0, h);
+        x = Math.max(5, x);
+        y = Math.max(5, y);
+        w = Math.min(w, getWidth() - x);
+        h = Math.min(h, getHeight() - y);
+        //TraceManager.addDev("x=" + x + " y=" + y + " w=" + w + " h=" + h + " getWidth = " + this.getWidth() + " getHeight = " + this.getHeight());
+        image = image.getSubimage(x, y, w, h);
+        g.dispose();
+        draw = b;
+        return image;
+    }
+
+    public BufferedImage performSelectedCapture() {
+        int w = this.getWidth();
+        int h = this.getHeight();
+        BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
+        Graphics2D g = image.createGraphics();
+
+        // Issue #14 point 10: Always use the current graphics
+        g.setFont(getGraphics().getFont());
+//        if (lastGraphics != null) {
+//            g.setFont(lastGraphics.getFont());
+//        }
+        selectedTemp = false;
+        Color colorTmp = ColorManager.SELECTED_0;
+        ColorManager.SELECTED_0 = ColorManager.NORMAL_0;
+        this.paint(g);
+        selectedTemp = true;
+        ColorManager.SELECTED_0 = colorTmp;
+        g.dispose();
+        image = image.getSubimage(xSel, ySel, widthSel, heightSel);
+        return image;
+    }
+
+    private int getRealMinX() {
+        int res = maxX;
+
+        for (TGComponent tgc : this.componentList) {
+            int cur = tgc.getCurrentMinX();
+            //TraceManager.addDev("cur=" + cur + " res=" + res + " tgc=" + tgc.getName());
+            if (cur < res)
+                res = cur;
+        }
+
+        res = Math.max(0, res);
+
+        if (res == maxX) {
+            return 0;
+        }
+
+        return res;
+    }
+
+    private int getRealMinY() {
+        int res = maxY;
+
+        for (TGComponent tgc : this.componentList) {
+            int cur = tgc.getCurrentMinY();
+            if (cur < res)
+                res = cur;
+        }
+
+        res = Math.max(0, res);
+
+        if (res == maxY) {
+            return 0;
+        }
+
+        return res;
+    }
+
+    public int getRealMaxX() {
+        int res = limit;
+
+        for (TGComponent tgc : this.componentList) {
+            res = Math.max(res, tgc.getCurrentMaxX());
+//            
+//            if (cur > res) {
+//                res = cur;
+//            }
+        }
+
+        return res;
+    }
+
+    public int getRealMaxY() {
+        int res = limit;
+
+        for (TGComponent tgc : this.componentList) {
+            res = Math.max(res, tgc.getCurrentMaxY());
+//            int cur = tgc.getCurrentMaxY();
+//            if (cur > res)
+//                res = cur;
+        }
+
+        return res;
+    }
+
+    public boolean isSelectedTemp() {
+        return selectedTemp;
+    }
+
+    public TGComponent getSecondTGComponent(TGConnector tgco) {
+        TGConnectingPoint p = tgco.getTGConnectingPointP2();
+
+        for (TGComponent tgc : this.componentList)
+            if (tgc.belongsToMe(p))
+                return tgc;
+
+        return null;
+    }
+
+    public boolean isFree(ArtifactTClassGate atg) {
+        return false;
+    }
+
+    // Toggle management
+    public boolean areAttributesVisible() {
+        return true;
+    }
+
+    public boolean areGatesVisible() {
+        return true;
+    }
+
+    public boolean areSynchroVisible() {
+        return true;
+    }
+
+    public void checkAllMySize() {
+        for (TGComponent tgc : this.componentList)
+            tgc.checkAllMySize();
+    }
+
+    public void enhance() {
+    }
+
+    public void autoAdjust() {
+        for (TGComponent tgc : this.componentList)
+            if (tgc instanceof TGAutoAdjust)
+                ((TGAutoAdjust) tgc).autoAdjust(adjustMode);
+
+        adjustMode = (adjustMode + 1) % 2;
+
+        repaint();
+    }
+
+    public boolean hasAutoConnect() {
+        return false;
+    }
+
+    public void autoConnect(TGComponent added) {
+
+
+        boolean cond = hasAutoConnect();
+
+        if (!cond) {
+            return;
+        }
+
+        int i, j;
+
+        //TraceManager.addDev("Autoconnect");
+
+        Vector<Point> listPoint = new Vector<Point>();
+
+        // Vector v = new Vector();
+
+        int distance = 100;
+        TGConnectingPoint found = null;
+        int distanceTmp;
+
+        boolean cd1, cd2;
+
+        TGConnectingPoint tgcp, tgcp1;
+
+        TGConnector tgco;
+
+        for (i = 0; i < added.getNbConnectingPoint(); i++) {
+
+            tgcp = added.getTGConnectingPointAtIndex(i);
+            if (tgcp.isFree() && tgcp.isCompatibleWith(added.getDefaultConnector())) {
+
+                // Try to connect that connecting point
+                found = null;
+                distance = 100;
+
+                for (TGComponent tgc : this.componentList)
+                    if (tgc != added) {
+                        for (j = 0; j < tgc.getNbConnectingPoint(); j++) {
+                            tgcp1 = tgc.getTGConnectingPointAtIndex(j);
+                            if ((tgcp1 != null) && tgcp1.isFree()) {
+                                if (tgcp1.isCompatibleWith(added.getDefaultConnector())) {
+                                    cd1 = tgcp1.isIn() && tgcp.isOut() && (tgcp1.getY() > tgcp.getY());
+                                    cd2 = tgcp.isIn() && tgcp1.isOut() && (tgcp1.getY() < tgcp.getY());
+                                    if (cd1 || cd2) {
+                                        distanceTmp = (int) (Math.sqrt(Math.pow(tgcp1.getX() - tgcp.getX(), 2) + Math.pow(tgcp1.getY() - tgcp.getY(), 2)));
+                                        if (distanceTmp < distance) {
+                                            distance = distanceTmp;
+                                            found = tgcp1;
+                                        }
+                                    }
+                                }
+                            }
+                        }
+
+                    }
+                if (found != null) {
+                    //TraceManager.addDev("Adding connector");
+                    if (found.isIn()) {
+                        tgco = TGComponentManager.addConnector(tgcp.getX(), tgcp.getY(), added.getDefaultConnector(), this, tgcp, found, listPoint);
+                    } else {
+                        tgco = TGComponentManager.addConnector(found.getX(), found.getY(), added.getDefaultConnector(), this, found, tgcp, listPoint);
+                    }
+                    found.setFree(false);
+                    tgcp.setFree(false);
+                    this.componentList.add(tgco);
+                    //TraceManager.addDev("Connector added");
+                }
+            }
+        }
+        //TraceManager.addDev("End Autoconnect");
+    }
+
+    public void resetAllDIPLOIDs() {
+        for (TGComponent tgc : this.componentList)
+            tgc.setDIPLOID(-1);
+    }
+
+    public void resetReachability() {
+        for (TGComponent tgc : this.componentList)
+            tgc.setHierarchyReachability(TGComponent.ACCESSIBILITY_UNKNOWN);
+        ;
+    }
+
+    public void resetLiveness() {
+        for (TGComponent tgc : this.componentList)
+            tgc.setHierarchyLiveness(TGComponent.ACCESSIBILITY_UNKNOWN);
+        ;
+    }
+
+
+    public void getListOfBreakPoints(java.util.List<Point> points, int taskID) {
+        for (TGComponent tgc : this.componentList)
+            if (tgc.getBreakpoint() && (tgc.getDIPLOID() != -1)) {
+                boolean found = false;
+                for (int i = 0; i < points.size(); i++)
+                    if (points.get(i).y == tgc.getDIPLOID()) {
+                        found = true;
+                        break;
+                    }
+
+                if (!found) {
+                    Point p = new Point(taskID, tgc.getDIPLOID());
+                    points.add(p);
+                }
+            }
+    }
+
+    public String svgCapture() {
+        int w = this.getWidth();
+        int h = this.getHeight();
+        int x = getRealMinX();
+        int y = getRealMinY();
+        w = getRealMaxX() - x;
+        h = getRealMaxY() - y;
+        //TraceManager.addDev("x=" + x + " y=" + y + " w=" + w + " h=" + h + " getWidth = " + this.getWidth() + " getHeight = " + this.getHeight());
+        x = x - 5;
+        y = y - 5;
+        w = w + 10;
+        h = h + 10;
+        w = Math.max(0, w);
+        h = Math.max(0, h);
+        x = Math.max(5, x);
+        y = Math.max(5, y);
+        w = Math.min(w, getWidth() - x);
+        h = Math.min(h, getHeight() - y);
+
+
+        StringBuffer sb = new StringBuffer("<?xml version=\"1.0\" standalone=\"no\"?>\n");
+        sb.append("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
+        //sb.append(" width=\"" + (w+x) + "\" height=\"" + (h+y) + "\" viewbox=\"" + x + " " + y + " " + w + " " + h + "\">\n");
+        sb.append("<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"");
+        sb.append(" width=\"" + (w + x) + "\" height=\"" + (h + y) + "\" viewbox=\"" + x + " " + y + " " + w + " " + h + "\">\n");
+
+        // Issue #14 point 10: Somehow the last graphics that was used is different than the actual one leading
+        // to an error in calculating string lengths
+        final SVGGraphics svgg = new SVGGraphics((Graphics2D) getGraphics());
+//      SVGGraphics svgg = new SVGGraphics((Graphics2D)lastGraphics);
+
+        RepaintManager.currentManager(this).setDoubleBufferingEnabled(false);
+        //this.paint(svgg);
+        //TraceManager.addDev("Painting for svg");
+        basicPaintMyComponents(svgg);
+        //TraceManager.addDev("Painting for svg done");
+        sb.append(svgg.getSVGString());
+        RepaintManager.currentManager(this).setDoubleBufferingEnabled(true);
+
+        sb.append("</svg>");
+
+        return sb.toString();
+    }
+
+    public void stopAddingConnector() {
+        //TraceManager.addDev("Stop Adding connector in tdp");
+        if (tdmm != null) {
+            tdmm.stopAddingConnector();
+        }
+    }
+
+    public boolean changeStateMachineTabName(String oldValue, String newValue) {
+        int stateMachineTab = -1;
+        for (int i = 0; i < this.tp.tabbedPane.getTabCount(); i++) {
+            if (this.tp.tabbedPane.getTitleAt(i).equals(newValue))
+                return false;
+
+            if (this.tp.tabbedPane.getTitleAt(i).equals(oldValue))
+                stateMachineTab = i;
+        }
+
+        if (stateMachineTab < 0)
+            return false;
+
+        this.tp.tabbedPane.setTitleAt(stateMachineTab, newValue);
+        this.tp.tabbedPane.setToolTipTextAt(stateMachineTab, "Opens the state machine of " + newValue);
+
+        //change panel name
+        for (int j = 0; j < this.tp.panels.size(); j++) {
+            TDiagramPanel tdp = this.tp.panels.elementAt(j);
+            if (tdp.getName().equals(oldValue))
+                tdp.setName(newValue);
+        }
+
+        return true;
+    }
+
+    public void searchForText(String text, Vector<Object> elements) {
+        TraceManager.addDev("Searching for " + text + " in " + this);
+
+        for (TGComponent tgc : this.componentList)
+            tgc.searchForText(text, elements);
+    }
+
+    public MainGUI getMainGUI() { //Ajout CD pour creation d'un panel depuis un block
+        return mgui;
+    }
+
+    public boolean isSelect() {
+        return select;
+    }
+
+    public void setSelect(boolean b) {
+        select = b;
+    }
+
+    public void upComponent() {
+        TGComponent tgc = componentPointed;
+        if (tgc != null && tgc.moveable) {
+            tgc.setMoveCd(tgc.x, tgc.y - MOVE_SPEED);
+            repaint();
+        }
+    }
+
+    public void downComponent() {
+        TGComponent tgc = componentPointed;
+        if (tgc != null && tgc.moveable) {
+            tgc.setMoveCd(tgc.x, tgc.y + MOVE_SPEED);
+            repaint();
+        }
+    }
+
+    public void leftComponent() {
+        TGComponent tgc = componentPointed;
+        if (tgc != null && tgc.moveable) {
+            tgc.setMoveCd(tgc.x - MOVE_SPEED, tgc.y);
+            repaint();
+        }
+    }
+
+    public void rightComponent() {
+        TGComponent tgc = componentPointed;
+        if (tgc != null && tgc.moveable) {
+            tgc.setMoveCd(tgc.x + MOVE_SPEED, tgc.y);
+            repaint();
+        }
+    }
+
+    public void upComponents() {
+        moveSelected(xSel, ySel - MOVE_SPEED);
+        repaint();
+    }
+
+    public void downComponents() {
+        moveSelected(xSel, ySel + MOVE_SPEED);
+        repaint();
+    }
+
+    public void leftComponents() {
+        moveSelected(xSel - MOVE_SPEED, ySel);
+        repaint();
+    }
+
+    public void rightComponents() {
+        moveSelected(xSel + MOVE_SPEED, ySel);
+        repaint();
+    }
+
+    public void setComponentPointed(TGComponent tgc) {
+        componentPointed = tgc;
+    }
+
+    public TDiagramMouseManager getMouseManager() {
+        return tdmm;
+    }
+}
diff --git a/src/main/resources/ui/TGUIAction.java b/src/main/resources/ui/TGUIAction.java
new file mode 100755
index 0000000000..5aadb346b1
--- /dev/null
+++ b/src/main/resources/ui/TGUIAction.java
@@ -0,0 +1,1326 @@
+/* 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.cecil.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 ui.util.IconManager;
+
+import javax.swing.*;
+import javax.swing.event.EventListenerList;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+
+import myutil.*;
+
+
+/**
+ * Class TGUIAction
+ *
+ * Creation: 21/12/2003
+ * @version 1.1 11/07/2006
+ * @author Ludovic APVRILLE, Emil Salageanu
+ * @see TGComponent
+ */
+public class TGUIAction extends AbstractAction {
+
+    private static final long serialVersionUID = -4942930048930203001L;
+
+    // Actions
+    public static final int ACT_NEW = 0;
+    public static final int ACT_NEW_PROJECT = 471;
+    public static final int ACT_NEW_DESIGN = 100;
+    public static final int ACT_NEW_ANALYSIS = 101;
+    public static final int ACT_OPEN = 1;
+    public static final int ACT_OPEN_PROJECT = 472;
+    public static final int ACT_OPEN_FROM_NETWORK = 455;
+    public static final int ACT_OPEN_LAST = 154;
+    public static final int ACT_MERGE = 228;
+    public static final int ACT_SAVE = 2;
+
+    public static final int ACT_SAVE_AS_PROJECT = 31;
+    public static final int ACT_SAVE_AS_MODEL = 475;
+    public static final int ACT_SAVE_TIF = 213;
+    public static final int ACT_OPEN_TIF = 214;
+    public static final int ACT_OPEN_SD = 268;
+    public static final int ACT_QUIT = 3;
+
+    public static final int ACT_SAVE_LOTOS = 64;
+    public static final int ACT_SAVE_DTA = 65;
+    public static final int ACT_SAVE_RG = 66;
+    public static final int ACT_SAVE_TLSA = 74;
+    public static final int ACT_SAVE_AUT = 67;
+    public static final int ACT_SAVE_AUTPROJ = 68;
+    public static final int ACT_SAVE_AUTMODIFIED = 232;
+
+    public static final int ACT_TURTLE_WEBSITE = 117;
+    public static final int ACT_TURTLE_DOCUMENTATION = 118;
+    public static final int ACT_DIPLODOCUS_DOCUMENTATION = 242;
+    public static final int ACT_SYSMLSEC_DOCUMENTATION = 426;
+    public static final int ACT_ABOUT = 4;
+    public static final int ACT_ENHANCE = 160;
+    public static final int ACT_TTOOL_CONFIGURATION = 323;
+
+
+    public static final int TCD_EDIT = 5;
+    public static final int TCD_NEW_TCLASS = 6;
+    public static final int TCD_NEW_TOBJECT = 50;
+    public static final int TCD_NEW_TDATA = 111;
+    public static final int TCD_ASSOCIATION = 7;
+    public static final int AD_EDIT = 8;
+    public static final int AD_CONNECTOR = 9;
+    public static final int AD_ACTION_STATE = 10;
+    public static final int AD_PARALLEL = 11;
+    public static final int AD_SEQUENCE = 51;
+    public static final int AD_PREEMPTION = 52;
+    public static final int AD_CHOICE = 12;
+    public static final int AD_STOP = 13;
+    public static final int AD_JUNCTION = 14;
+    public static final int AD_DETERMINISTIC_DELAY = 15;
+    public static final int AD_NON_DETERMINISTIC_DELAY = 16;
+    public static final int AD_DELAY_NON_DETERMINISTIC_DELAY = 49;
+    public static final int AD_TIME_LIMITED_OFFER = 17;
+    public static final int AD_TIME_LIMITED_OFFER_WITH_LATENCY = 18;
+    public static final int AD_TIME_CAPTURE = 269;
+    public static final int TCD_PARALLEL_OPERATOR = 19;
+    public static final int TCD_CONNECTOR_ATTRIBUTE = 20;
+    public static final int TCD_SEQUENCE_OPERATOR = 21;
+    public static final int TCD_PREEMPTION_OPERATOR = 22;
+    public static final int TCD_SYNCHRO_OPERATOR = 23;
+    public static final int TCD_INVOCATION_OPERATOR = 48;
+    public static final int TCD_ASSOCIATION_NAVIGATION = 24;
+    public static final int AD_START = 43;
+    public static final int AD_ARRAY_GET = 261;
+    public static final int AD_ARRAY_SET = 262;
+
+    public static final int IOD_EDIT = 77;
+    public static final int IOD_CHOICE = 78;
+    public static final int IOD_START = 79;
+    public static final int IOD_STOP = 80;
+    public static final int IOD_PARALLEL = 81;
+    public static final int IOD_PREEMPTION = 98;
+    public static final int IOD_SEQUENCE = 159;
+    public static final int IOD_JUNCTION = 82;
+    public static final int IOD_CONNECTOR = 83;
+    public static final int IOD_REF_SD = 84;
+    public static final int IOD_REF_IOD = 158;
+
+    public static final int SD_EDIT = 85;
+    public static final int SD_INSTANCE = 86;
+    public static final int SD_CONNECTOR_MESSAGE_ASYNC = 87;
+    public static final int SD_CONNECTOR_MESSAGE_SYNC = 88;
+    public static final int SD_ABSOLUTE_TIME_CONSTRAINT = 89;
+    public static final int SD_TIME_INTERVAL = 188;
+    public static final int SD_RELATIVE_TIME_CONSTRAINT = 90;
+    public static final int SD_RELATIVE_TIME_CONSTRAINT_CONNECTOR = 91;
+    public static final int SD_ACTION_STATE = 92;
+    public static final int SD_GUARD = 212;
+    public static final int SD_TIMER_SETTING = 93;
+    public static final int SD_TIMER_EXPIRATION = 94;
+    public static final int SD_TIMER_CANCELLATION = 95;
+    public static final int SD_COREGION = 96;
+    public static final int SD_ALIGN_INSTANCES = 97;
+
+    public static final int SDZV_EDIT = 440;
+    public static final int SDZV_INSTANCE = 441;
+    public static final int SDZV_CONNECTOR_MESSAGE_ASYNC = 442;
+    public static final int SDZV_CONNECTOR_MESSAGE_SYNC = 443;
+    public static final int SDZV_ABSOLUTE_TIME_CONSTRAINT = 444;
+    public static final int SDZV_TIME_INTERVAL = 445;
+    public static final int SDZV_RELATIVE_TIME_CONSTRAINT = 446;
+    public static final int SDZV_RELATIVE_TIME_CONSTRAINT_CONNECTOR = 447;
+    public static final int SDZV_ACTION_STATE = 448;
+    public static final int SDZV_GUARD = 449;
+    public static final int SDZV_TIMER_SETTING = 450;
+    public static final int SDZV_TIMER_EXPIRATION = 451;
+    public static final int SDZV_TIMER_CANCELLATION = 452;
+    public static final int SDZV_COREGION = 453;
+    public static final int SDZV_ALIGN_INSTANCES = 454;
+
+
+    public static final int UCD_EDIT = 104;
+    public static final int UCD_ACTOR = 105;
+    public static final int UCD_ACTORBOX = 333;
+    public static final int UCD_USECASE = 106;
+    public static final int UCD_CONNECTOR_ACTOR_UC = 107;
+    public static final int UCD_CONNECTOR_INCLUDE = 108;
+    public static final int UCD_CONNECTOR_EXTEND = 109;
+    public static final int UCD_CONNECTOR_SPECIA = 110;
+    public static final int UCD_BORDER = 161;
+
+    public static final int TMLTD_EDIT = 127;
+    public static final int TMLTD_TASK = 128;
+    public static final int TMLTD_CHANNEL = 129;
+    public static final int TMLTD_REQ = 130;
+    public static final int TMLTD_EVENT = 131;
+    public static final int TMLTD_CONNECTOR = 132;
+    public static final int TMLTD_ASSOC = 133;
+
+    public static final int TMLCTD_EDIT = 233;
+    public static final int TMLCTD_CCOMPONENT = 234;
+    public static final int TMLCTD_CREMOTECOMPONENT = 246;
+    public static final int TMLCTD_CPORT = 237;
+    public static final int TMLCTD_PORT_CONNECTOR = 238;
+    public static final int TMLCTD_PCOMPONENT = 239;
+    public static final int TMLCTD_COPORT = 240;
+    public static final int TMLCTD_RCOMPONENT = 330;
+    public static final int TMLCTD_JOIN = 393;
+    public static final int TMLCTD_FORK = 394;
+
+
+    public static final int TMLAD_EDIT = 134;
+    public static final int TMLAD_CONNECTOR = 135;
+    public static final int TMLAD_ACTION_STATE = 136;
+    public static final int TMLAD_CHOICE = 137;
+    public static final int TMLAD_STOP = 138;
+    public static final int TMLAD_START = 139;
+    public static final int TMLAD_JUNCTION = 140;
+    public static final int TMLAD_EXECI = 141;
+    public static final int TMLAD_EXECI_INTERVAL = 152;
+    public static final int TMLAD_EXECC = 243;
+    public static final int TMLAD_EXECC_INTERVAL = 244;
+    public static final int TMLAD_DELAY = 248;
+    public static final int TMLAD_INTERVAL_DELAY = 249;
+    public static final int TMLAD_WRITE_CHANNEL = 142;
+    public static final int TMLAD_SEND_REQUEST = 143;
+    public static final int TMLAD_SEND_EVENT = 144;
+    public static final int TMLAD_WAIT_EVENT = 145;
+    public static final int TMLAD_NOTIFIED_EVENT = 203;
+    public static final int TMLAD_READ_CHANNEL = 146;
+    public static final int TMLAD_FOR_LOOP = 147;
+    public static final int TMLAD_FOR_STATIC_LOOP = 226;
+    public static final int TMLAD_FOR_EVER_LOOP = 255;
+    public static final int TMLAD_SEQUENCE = 156;
+    public static final int TMLAD_UNORDERED_SEQUENCE = 322;
+    public static final int TMLAD_SELECT_EVT = 206;
+    public static final int TMLAD_RANDOM = 245;
+    public static final int TMLAD_READ_REQUEST_ARG = 335;
+
+    public static final int TMLAD_ENCRYPT = 430;
+    public static final int TMLAD_DECRYPT = 431;
+
+    public static final int TMLARCHI_EDIT = 216;
+    public static final int TMLARCHI_LINK = 217;
+    public static final int TMLARCHI_CPUNODE = 218;
+    public static final int TMLARCHI_BUSNODE = 221;
+    public static final int TMLARCHI_CPNODE = 392;
+    public static final int TMLARCHI_ARTIFACT = 219;
+    public static final int TMLARCHI_COMMUNICATION_ARTIFACT = 222;
+    public static final int TMLARCHI_PORT_ARTIFACT = 412;
+    public static final int TMLARCHI_EVENT_ARTIFACT = 395;
+    public static final int TMLARCHI_HWANODE = 223;
+    public static final int TMLARCHI_CAMSNODE = 461;
+    public static final int TMLARCHI_MEMORYNODE = 224;
+    public static final int TMLARCHI_DMANODE = 364;
+    public static final int TMLARCHI_BRIDGENODE = 225;
+    public static final int TMLARCHI_KEY = 435;
+    public static final int TMLARCHI_FIREWALL = 436;
+    public static final int TMLARCHI_FPGANODE = 474;
+
+    public static final int TMLCP_EDIT = 378;
+    public static final int TMLCP_CONNECTOR = 379;
+    public static final int TMLCP_REF_SD = 380;
+    public static final int TMLCP_REF_CP = 381;
+    public static final int TMLCP_FORK = 382;
+    public static final int TMLCP_JOIN = 383;
+    public static final int TMLCP_START = 384;
+    public static final int TMLCP_STOP = 385;
+    public static final int TMLCP_CHOICE = 386;
+    public static final int TMLCP_JUNCTION = 387;
+    public static final int TMLCP_FOR_LOOP = 416;
+
+    public static final int TMLSD_STORAGE_INSTANCE = 388;
+    public static final int TMLSD_CONTROLLER_INSTANCE = 396;
+    public static final int TMLSD_TRANSFER_INSTANCE = 397;
+    public static final int TMLSD_ACTION_STATE = 389;
+    public static final int TMLSD_MESSAGE_ASYNC = 390;
+    public static final int TMLSD_EDIT = 391;
+
+    public static final int CAMS_EDIT = 458;
+    public static final int CAMS_BLOCK_TDF = 459;
+    public static final int CAMS_CONNECTOR = 460;
+    public static final int CAMS_BLOCK_DE = 475;
+    public static final int CAMS_PORT_TDF = 476;
+    public static final int CAMS_PORT_DE = 477;
+    public static final int CAMS_PORT_CONVERTER = 478;
+    public static final int CAMS_CLUSTER = 479;
+
+    public static final int EBRDD_EDIT = 271;
+    public static final int EBRDD_CONNECTOR = 272;
+    public static final int EBRDD_START = 273;
+    public static final int EBRDD_STOP = 274;
+    public static final int EBRDD_CHOICE = 275;
+    public static final int EBRDD_ERC = 276;
+    public static final int EBRDD_ACTION = 277;
+    public static final int EBRDD_FOR_LOOP = 278;
+    public static final int EBRDD_SEQUENCE = 279;
+    public static final int EBRDD_ESO = 280;
+    public static final int EBRDD_ERB = 281;
+    public static final int EBRDD_CONNECTOR_ERC = 282;
+    public static final int EBRDD_VARIABLE_DECLARATION = 283;
+
+    // TURTLE-OS
+    public static final int TOS_TCLASS = 189;
+    public static final int TOS_ASSOCIATION = 190;
+    public static final int TOS_ASSOCIATION_NAVIGATION = 191;
+    public static final int TOS_CONNECTOR_ATTRIBUTE = 192;
+    public static final int TOS_CALL_OPERATOR = 193;
+    public static final int TOS_EVT_OPERATOR = 205;
+
+    public static final int TOSAD_ACTION_STATE = 194;
+    public static final int TOSAD_CONNECTOR = 195;
+    public static final int TOSAD_CHOICE = 196;
+    public static final int TOSAD_START_STATE = 197;
+    public static final int TOSAD_STOP_STATE = 198;
+    public static final int TOSAD_JUNCTION = 199;
+    public static final int TOSAD_TIME_INTERVAL = 200;
+    public static final int TOSAD_INT_TIME_INTERVAL = 201;
+
+    //ProActive State Machine Diagram
+    public static final int PROSMD_EDIT = 168;
+    public static final int PROSMD_STOP = 169;
+    public static final int PROSMD_START = 170;
+    public static final int PROSMD_CONNECTOR = 172;
+    public static final int PROSMD_SENDMSG = 173;
+    public static final int PROSMD_GETMSG = 175;
+    public static final int PROSMD_CHOICE = 176;
+    public static final int PROSMD_JUNCTION = 183;
+    public static final int PROSMD_SUBMACHINE = 184;
+    public static final int PROSMD_ACTION = 185;
+    public static final int PROSMD_PARALLEL = 186;
+    public static final int PROSMD_STATE = 187;
+
+    public static final int PROCSD_EDIT = 171;
+    public static final int PROCSD_COMPONENT = 174;
+    //Delegate port action removed, by Solange
+    //public static final int PROCSD_DELEGATE_PORT = 177;
+    public static final int PROCSD_CONNECTOR = 178;
+    public static final int PROCSD_CONNECTOR_DELEGATE = 182;
+    public static final int PROCSD_INTERFCE=179;
+    public static final int PROCSD_IN_PORT = 180;
+    public static final int PROCSD_OUT_PORT = 181;
+    public static final int PROCSD_CONNECTOR_PORT_INTERFACE = 209;
+
+    public static final int TDD_EDIT = 119;
+    public static final int TDD_LINK = 120;
+    public static final int TDD_NODE = 121;
+    public static final int TDD_ARTIFACT = 122;
+
+    // NC
+    public static final int NCDD_EDIT = 250;
+    public static final int NCDD_LINK = 251;
+    public static final int NCDD_EQNODE = 252;
+    public static final int NCDD_SWITCHNODE = 254;
+    public static final int NCDD_TRAFFIC_ARTIFACT = 253;
+    public static final int NCDD_ROUTE_ARTIFACT = 256;
+    public static final int ACT_NC = 257;
+
+    // SysML Requirements
+
+    public static final int TREQ_REQUIREMENT = 163;
+    public static final int TREQ_OBSERVER = 166;
+    public static final int TREQ_EBRDD = 270;
+    public static final int TREQ_DERIVE = 164;
+    public static final int TREQ_VERIFY = 165;
+    public static final int TREQ_COPY = 258;
+    public static final int TREQ_COMPOSITION = 259;
+
+    public static final int ATD_BLOCK = 284;
+    public static final int ATD_ATTACK = 285;
+    public static final int ATD_ATTACK_CONNECTOR = 286;
+    public static final int ATD_COMPOSITION_CONNECTOR = 288;
+    public static final int ATD_CONSTRAINT = 287;
+    public static final int ATD_COUNTERMEASURE = 456;
+    public static final int ATD_COUNTERMEASURE_CONNECTOR = 457;
+
+    public static final int FTD_BLOCK = 465;
+    public static final int FTD_FAULT = 466;
+    public static final int FTD_FAULT_CONNECTOR = 467;
+    public static final int FTD_COMPOSITION_CONNECTOR = 468;
+    public static final int FTD_CONSTRAINT = 469;
+    public static final int FTD_COUNTERMEASURE = 470;
+    public static final int FTD_COUNTERMEASURE_CONNECTOR = 473;
+
+    // AVATAR Block Diagram
+    public static final int ABD_BLOCK = 289;
+    public static final int ABD_CRYPTOBLOCK = 332;
+    public static final int ABD_DATATYPE = 324;
+    public static final int ABD_COMPOSITION_CONNECTOR = 290;
+    public static final int ABD_PORT_CONNECTOR = 295;
+    public static final int ABD_LIBRARYFUNCTION = 428;
+    public static final int ABD_CRYPTOLIBRARYFUNCTION = 429;
+
+    // AVATAR State Machine
+    public static final int ASMD_EDIT = 291;
+    public static final int ASMD_CONNECTOR = 292;
+    public static final int ASMD_START = 293;
+    public static final int ASMD_STOP = 294;
+    public static final int ASMD_SEND_SIGNAL = 296;
+    public static final int ASMD_RECEIVE_SIGNAL = 297;
+    public static final int ASMD_LIBRARY_FUNCTION_CALL = 432;
+    public static final int ASMD_PARALLEL = 298;
+    public static final int ASMD_STATE = 299;
+    public static final int ASMD_CHOICE = 325;
+    public static final int ASMD_RANDOM = 326;
+    public static final int ASMD_SET_TIMER = 327;
+    public static final int ASMD_RESET_TIMER = 328;
+    public static final int ASMD_EXPIRE_TIMER = 329;
+
+    // AVATAR Requirement
+    public static final int ARD_EDIT = 300;
+    public static final int ARD_REQUIREMENT = 301;
+    public static final int ARD_PROPERTY = 302;
+    public static final int ARD_ELEMENT_REFERENCE = 423;
+    public static final int ARD_VERIFY_CONNECTOR = 303;
+    public static final int ARD_DERIVE_CONNECTOR = 304;
+    public static final int ARD_REFINE_CONNECTOR = 343;
+    public static final int ARD_SATISFY_CONNECTOR = 422;
+    public static final int ARD_COPY_CONNECTOR = 305;
+    public static final int ARD_COMPOSITION_CONNECTOR = 306;
+
+    // AVATAR Assumptions
+    public static final int AMAD_EDIT = 370;
+    public static final int AMAD_ASSUMPTION = 371;
+    public static final int AMAD_DIAGRAM_REFERENCE = 372;
+    public static final int AMAD_ELEMENT_REFERENCE = 373;
+    public static final int AMAD_COMPOSITION_CONNECTOR = 374;
+    public static final int AMAD_BELONGSTOCOMPOSITION_CONNECTOR = 417;
+    public static final int AMAD_IMPACT_CONNECTOR = 375;
+    public static final int AMAD_MEET_CONNECTOR = 377;
+    public static final int AMAD_VERSIONING_CONNECTOR = 376;
+
+    //AVATAR Deployment diagram
+    public static final int ADD_EDIT = 398;
+    public static final int ADD_LINK = 399;
+    public static final int ADD_CPUNODE = 400;
+    public static final int ADD_BUSNODE = 420;
+    public static final int ADD_BLOCKARTIFACT = 402;
+    public static final int ADD_TTYNODE = 403;
+    public static final int ADD_RAMNODE = 404;
+    public static final int ADD_ROMNODE = 405;
+    public static final int ADD_DMANODE = 406;
+    public static final int ADD_BRIDGENODE = 407;
+    public static final int ADD_ICUNODE = 408;
+    public static final int ADD_COPROMWMRNODE = 409;
+    public static final int ADD_TIMERNODE = 410;
+    public static final int ADD_CHANNELARTIFACT = 411;
+    public static final int ADD_VGMNNODE = 401;
+    public static final int ADD_CROSSBARNODE = 421;
+
+    // -------------------------------------------------------------
+    public static final int DEPLOY_AVATAR_DIAGRAM = 418;
+    public static final int EXTRAC_DEPLOY_PARAM_TO_FILE = 419;
+    // --------------------------------------------------------------------
+
+
+
+
+    // AVATAR Parametric Diagrams
+    public static final int APD_EDIT = 307;
+    public static final int APD_BLOCK = 308;
+    public static final int APD_LOGICAL_CONSTRAINT = 309;
+    public static final int APD_TEMPORAL_CONSTRAINT = 310;
+    public static final int APD_ATTRIBUTE = 311;
+    public static final int APD_SIGNAL = 312;
+    public static final int APD_ALIAS = 313;
+    public static final int APD_BOOLEQ = 314;
+    public static final int APD_ATTRIBUTE_SETTING = 315;
+    public static final int APD_PROPERTY = 316;
+    public static final int APD_PROPERTY_RELATION = 317;
+    public static final int APD_ATTRIBUTE_CONNECTOR = 318;
+    public static final int APD_SIGNAL_CONNECTOR = 319;
+    public static final int APD_PROPERTY_CONNECTOR = 320;
+    public static final int APD_COMPOSITION_CONNECTOR = 321;
+
+    // AVATAR context Diagrams
+    public static final int ACD_EDIT = 344;
+    public static final int ACD_BLOCK = 345;
+    public static final int ACD_COMPOSITION_CONNECTOR = 346;
+    public static final int ACD_ACTOR_STICKMAN = 347;
+    public static final int ACD_ACTOR_BOX = 348;
+    public static final int ACD_ASSOCIATION_CONNECTOR = 349;
+
+    // AVATAR Activity Diagrams
+    public static final int AAD_EDIT = 350;
+    public static final int AAD_ASSOCIATION_CONNECTOR = 351;
+    public static final int AAD_START_STATE = 352;
+    public static final int AAD_STOP_STATE = 353;
+    public static final int AAD_CHOICE = 354;
+    public static final int AAD_JUNCTION = 355;
+    public static final int AAD_PARALLEL = 356;
+    public static final int AAD_ACTIVITY = 357;
+    public static final int AAD_ACTION = 358;
+    public static final int AAD_STOP_FLOW = 359;
+    public static final int AAD_ACCEPT_EVENT_ACTION = 360;
+    public static final int AAD_SEND_SIGNAL_ACTION = 361;
+    public static final int AAD_PARTITION = 362;
+    public static final int AAD_ALIGN_PARTITION = 363;
+
+
+    public static final int ACT_MODEL_CHECKING = 25;
+    public static final int ACT_GEN_RTLOTOS = 27;
+    public static final int ACT_GEN_LOTOS = 155;
+    public static final int ACT_GEN_UPPAAL = 204;
+    public static final int ACT_AVATAR_MODEL_CHECKER = 433;
+    public static final int ACT_GEN_JAVA = 112;
+    public static final int ACT_SIMU_JAVA = 167;
+    public static final int ACT_GEN_SYSTEMC = 148;
+    public static final int ACT_SIMU_SYSTEMC = 263;
+    public static final int ACT_GEN_TMLTXT = 215;
+    public static final int ACT_GEN_CCODE = 413;
+    public static final int ACT_GEN_AUT = 157;
+    public static final int ACT_GEN_AUTS = 202;
+    public static final int ACT_GEN_DESIGN = 103;
+    public static final int ACT_CHECKCODE = 28;
+    public static final int ACT_SIMULATION = 29;
+    public static final int ACT_VALIDATION = 30;
+    public static final int ACT_PROJECTION = 54;
+    public static final int ACT_GRAPH_MODIFICATION = 230;
+    public static final int ACT_BISIMULATION = 69;
+    public static final int ACT_BISIMULATION_CADP = 229;
+    public static final int ACT_DEADLOCK_SEEKER_AUT = 75;
+    public static final int ACT_DEADLOCK_SEEKER_SAVED_AUT = 76;
+
+
+    public static final int ACT_ONECLICK_LOTOS_RG = 210;
+    public static final int ACT_ONECLICK_RTLOTOS_RG = 211;
+
+    public static final int ACT_VIEW_RTLOTOS = 32;
+    public static final int ACT_VIEW_SUGGESTED_DESIGN = 99;
+
+    public static final int ACT_BACKWARD = 33;
+    public static final int ACT_FORWARD = 34;
+
+    public static final int ACT_FIRST_DIAG = 35;
+    public static final int ACT_BACK_DIAG = 36;
+    public static final int ACT_NEXT_DIAG = 37;
+    public static final int ACT_LAST_DIAG = 38;
+
+    public static final int ACT_VIEW_JAVA = 113;
+    public static final int ACT_VIEW_DTADOT = 39;
+    public static final int ACT_VIEW_RGDOT = 40;
+    public static final int ACT_VIEW_TLSADOT = 73;
+    public static final int ACT_VIEW_RGAUTDOT = 53;
+    public static final int ACT_VIEW_STAT_AUT = 70;
+    public static final int ACT_VIEW_STAT_AUTDIPLODOCUS = 342;
+    public static final int ACT_VIEW_RGAUTPROJDOT = 55;
+    public static final int ACT_VIEW_MODIFIEDAUTDOT = 231;
+    public static final int ACT_VIEW_STAT_AUTPROJ = 71;
+    public static final int ACT_VIEW_SIM = 41;
+    public static final int ACT_VIEW_SIM_CHRONO = 102;
+    public static final int ACT_VIEW_SAVED_LOT = 62;
+    public static final int ACT_VIEW_SAVED_DOT = 63;
+    public static final int ACT_VIEW_STAT_SAVED_AUT = 72;
+    public static final int ACT_VIEW_BIRDEYES = 115;
+    public static final int ACT_VIEW_BIRDEYES_EMB = 116;
+    public static final int ACT_VIEW_WAVE = 153;
+    public static final int ACT_VIEW_RG_DIPLODOCUS = 341;
+
+    public static final int ACT_VIEW_PM_AUT = 265;
+    public static final int ACT_VIEW_PM_AUTPROJ = 266;
+    public static final int ACT_VIEW_PM_SAVED_AUT = 267;
+
+    public static final int UML_NOTE = 42;
+    public static final int PRAGMA = 424;
+    public static final int SAFETY_PRAGMA = 425;
+    public static final int PERFORMANCE_PRAGMA = 438;
+    public static final int AVATAR_FIREWALL = 437;
+
+    public static final int ACT_CUT = 44;
+    public static final int ACT_COPY = 45;
+    public static final int ACT_PASTE = 46;
+    public static final int ACT_DELETE = 47;
+    public static final int ACT_SUPPR = 462;
+
+    public static final int ACT_ZOOM_MORE = 235;
+    public static final int ACT_ZOOM_LESS = 236;
+    public static final int ACT_SHOW_ZOOM = 241;
+
+    public static final int ACT_IMPORT_LIB = 56;
+    public static final int ACT_EXPORT_LIB = 57;
+
+    public static final int ACT_SCREEN_CAPTURE = 58;
+    public static final int ACT_TTOOL_WINDOW_CAPTURE = 59;
+    public static final int ACT_DIAGRAM_CAPTURE = 60;
+    public static final int ACT_SVG_DIAGRAM_CAPTURE = 366;
+    public static final int ACT_ALL_DIAGRAM_CAPTURE = 114;
+    public static final int ACT_ALL_DIAGRAM_CAPTURE_SVG = 427;
+    public static final int ACT_SELECTED_CAPTURE = 61;
+
+    public static final int ACT_GEN_DOC = 247;
+    public static final int ACT_GEN_DOC_REQ = 260;
+
+    public static final int ACT_TOGGLE_ATTRIBUTES = 123;
+    public static final int ACT_TOGGLE_GATES = 124;
+    public static final int ACT_TOGGLE_SYNCHRO = 125;
+
+    public static final int ACT_TOGGLE_CHANNELS = 149;
+    public static final int ACT_TOGGLE_EVENTS = 150;
+    public static final int ACT_TOGGLE_REQUESTS = 151;
+
+    public static final int ACT_TOGGLE_JAVA = 126;
+    public static final int ACT_TOGGLE_ATTR = 220;
+
+    public static final int ACT_TOGGLE_DIPLO_ID = 264;
+    public static final int ACT_TOGGLE_AVATAR_ID = 334;
+    public static final int ACT_TOGGLE_TEPE_ID = 336;
+
+    public static final int ACT_TOGGLE_INTERNAL_COMMENT = 227;
+
+    public static final int CONNECTOR_COMMENT = 162;
+
+    public static final int EXTERNAL_ACTION_1 = 207;
+    public static final int EXTERNAL_ACTION_2 = 208;
+
+    public static final int ACT_AVATAR_SIM = 339;
+    public static final int ACT_AVATAR_FV_UPPAAL = 337;
+    public static final int ACT_AVATAR_FV_PROVERIF = 338;
+    public static final int ACT_AVATAR_FV_STATICANALYSIS = 365;
+    public static final int ACT_AVATAR_EXECUTABLE_GENERATION = 340;
+
+    public static final int ACT_DSE = 434;
+
+    // Ontologies
+    public static final int ACT_GENERATE_ONTOLOGIES_CURRENT_DIAGRAM = 367;
+    public static final int ACT_GENERATE_ONTOLOGIES_CURRENT_SET_OF_DIAGRAMS = 369;
+    public static final int ACT_GENERATE_ONTOLOGIES_ALL_DIAGRAMS = 368;
+
+    //Action for the help button created by Solange
+    public static final int PRUEBA_1 = 205;
+
+    //Action for the external Search
+    //@author Huy TRUONG.
+    public static final int ACT_EXTERNAL_SEARCH = 414;
+    public static final int ACT_INTERNAL_SEARCH = 415;
+    //--
+
+    public static final int MOVE_ENABLED = 463;
+    public static final int FIRST_DIAGRAM = 464;
+    
+    public static final int NB_ACTION = 480;
+
+    private static final TAction [] actions = new TAction[NB_ACTION];
+
+    private EventListenerList listeners;
+
+    public static final String JLF_IMAGE_DIR = "";
+
+    public static final String LARGE_ICON = "LargeIcon";
+
+    public TGUIAction(TAction _t) {
+        putValue(Action.ACTION_COMMAND_KEY, _t.ACTION_COMMAND_KEY);
+        putValue(Action.NAME, _t.NAME);
+        putValue(Action.SMALL_ICON, _t.SMALL_ICON);
+        putValue(LARGE_ICON, _t.LARGE_ICON);
+        putValue(Action.SHORT_DESCRIPTION, _t.SHORT_DESCRIPTION);
+        putValue(Action.LONG_DESCRIPTION, _t.LONG_DESCRIPTION);
+    }
+
+    public TGUIAction(int id) {
+        if (actions[0] == null) {
+            init();
+        }
+        if (actions[id] == null) {
+            return ;
+        }
+
+        putValue(Action.NAME, actions[id].NAME);
+        putValue(Action.SMALL_ICON, actions[id].SMALL_ICON);
+        putValue(LARGE_ICON, actions[id].LARGE_ICON);
+        putValue(Action.SHORT_DESCRIPTION, actions[id].SHORT_DESCRIPTION);
+        putValue(Action.LONG_DESCRIPTION, actions[id].LONG_DESCRIPTION);
+        //putValue(Action.MNEMONIC_KEY, new Integer(actions[id].MNEMONIC_KEY));
+        if (actions[id].MNEMONIC_KEY != 0) {
+            if (actions[id].hasControl) {
+                putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(actions[id].KEY, java.awt.event.InputEvent.CTRL_MASK));
+            } else {
+                if ((actions[id].MNEMONIC_KEY >= 37 && actions[id].MNEMONIC_KEY <= 40) || actions[id].MNEMONIC_KEY == KeyEvent.VK_DELETE) //handling for arrow and delete keys
+                    putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(actions[id].MNEMONIC_KEY, 0));
+                else
+                    putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(actions[id].KEY));
+            }
+        }
+        putValue(Action.ACTION_COMMAND_KEY, actions[id].ACTION_COMMAND_KEY);
+
+        if ((id == EXTERNAL_ACTION_1) && (ConfigurationTTool.ExternalCommand1 != null) && (ConfigurationTTool.ExternalCommand1.length()) > 0) {
+            setLongDescription(EXTERNAL_ACTION_1, ConfigurationTTool.ExternalCommand1);
+        }
+        if ((id == EXTERNAL_ACTION_2) && (ConfigurationTTool.ExternalCommand2 != null) && (ConfigurationTTool.ExternalCommand2.length()) > 0) {
+            setLongDescription(EXTERNAL_ACTION_2, ConfigurationTTool.ExternalCommand2);
+        }
+    }
+
+    public void setName(int index, String name) {
+        actions[index].NAME = name;
+        putValue(Action.NAME, actions[index].NAME);
+    }
+
+    public void setLongDescription(int index, String description) {
+        actions[index].LONG_DESCRIPTION = description;
+        putValue(Action.LONG_DESCRIPTION, actions[index].LONG_DESCRIPTION);
+    }
+
+    public void init() {
+        actions[ACT_NEW] = new TAction("new-command", "New Model", IconManager.imgic20, IconManager.imgic21, "New Model" , "New model", 'N');
+        actions[ACT_NEW_PROJECT] = new TAction("new-project-command", "New project", IconManager.imgic20_proj, IconManager.imgic21_proj, "New project", "New project", 0);
+        actions[ACT_NEW_DESIGN] = new TAction("new-command-design", "New design", IconManager.imgic14, IconManager.imgic14, "New design", "New TURTLE design", 0);
+        actions[ACT_NEW_ANALYSIS] = new TAction("new-command-analysis", "New analysis", IconManager.imgic17, IconManager.imgic17, "New analysis", "New TURTLE analysis", 0);
+        actions[ACT_OPEN] = new TAction("open-command","Open Model", IconManager.imgic22, IconManager.imgic23, "Open Model", "Open an existing TTool model",'O', true);
+        actions[ACT_OPEN_PROJECT] = new TAction("open-project-command","Open project", IconManager.imgic22_proj, IconManager.imgic23_proj, "Open project", "Open an existing TTool project",'O', true);
+        actions[ACT_OPEN_FROM_NETWORK] = new TAction("open-command-from-network","Open project from TTool repository", IconManager.imgic22_net, IconManager.imgic23_net, "Open project from TTool repository", "Open an existing TTool model from the TTool repository (TTool website)",'0', true);
+        actions[ACT_OPEN_LAST] = new TAction("openlast-command","Open file: " + ConfigurationTTool.LastOpenFile, IconManager.imgic22, IconManager.imgic23, "Open: " + ConfigurationTTool.LastOpenFile, "Open the lastly saved TTool model", 0);
+        actions[ACT_MERGE] = new TAction("merge-command","Merge", IconManager.imgic22, IconManager.imgic23, "Merge", "Merge the current TTool modeling with another one saved in a file ", 0);
+        actions[ACT_SAVE] = new TAction("save-command", "Save",IconManager.imgic24, IconManager.imgic25, "Save", "Save an opened or a new TTool modeling", 'S', true);
+        actions[ACT_SAVE_TIF] = new TAction("save-tif-command", "Save TIF specification",IconManager.imgic24, IconManager.imgic25, "Save TIF Specification", "Save in TIF a TURTLE modeling", 0);
+        actions[ACT_OPEN_TIF] = new TAction("open-tif-command", "Open TIF specification",IconManager.imgic24, IconManager.imgic25, "Open TIF Specification", "Open a TURTLE modeling given in TIF", 0);
+        actions[ACT_OPEN_SD] = new TAction("open-sd-command", "Open MSC specification",IconManager.imgic24, IconManager.imgic25, "Open MSC Specification", "Open a MSC specification given in xml format", 0);
+        actions[ACT_SAVE_AS_PROJECT] = new TAction("saveasproject-command", "Save as Project",IconManager.imgic24, IconManager.imgic25, "Save as Project", "Save an opened or a new TTool modeling under a new project", 0);
+        actions[ACT_SAVE_AS_MODEL] = new TAction("saveasmodel-command", "Save as Model",IconManager.imgic24, IconManager.imgic25, "Save as Model", "Save an opened or a new TTool modeling under a new model", 0);
+        actions[ACT_QUIT] = new TAction("quit-command", "Quit", IconManager.imgic26, IconManager.imgic27, "Quit",  "Quit TTool", 'Q');
+
+        actions[ACT_SAVE_LOTOS] = new TAction("save-last-lotos", "Save last RT-LOTOS specification",IconManager.imgic24, IconManager.imgic25, "Save last RT-LOTOS specification", "Save the lastest automatically generated RT-LOTOS specification", 0);
+        actions[ACT_SAVE_DTA] = new TAction("save-last-dta", "Save last DTA",IconManager.imgic24, IconManager.imgic25, "Save last DTA", "Save the lastest built DTA", 0);
+        actions[ACT_SAVE_RG] = new TAction("save-last-rg", "Save last RG",IconManager.imgic24, IconManager.imgic25, "Save last RG", "Save the lastest built RG", 0);
+        actions[ACT_SAVE_TLSA] = new TAction("save-last-tlsa", "Save last TLSA",IconManager.imgic24, IconManager.imgic25, "Save last TLSA", "Save the lastest generated TLSA", 0);
+        actions[ACT_SAVE_AUT] = new TAction("save-last-rg-aut", "Save last RG (AUT format)",IconManager.imgic24, IconManager.imgic25, "Save last RG (AUT format)", "Save the lastest built RG (AUT Format)", 0);
+        actions[ACT_SAVE_AUTPROJ] = new TAction("save-last-rg-autproj", "Save last minimized RG (AUT format)",IconManager.imgic24, IconManager.imgic25, "Save last minimized RG (AUT format)", "Save the lastest minimized RG (AUT Format)", 0);
+        actions[ACT_SAVE_AUTMODIFIED] = new TAction("save-last-rg-modified", "Save last modified RG (AUT format)",IconManager.imgic24, IconManager.imgic25, "Save last modified RG (AUT format)", "Save the lastest modified RG (AUT Format)", 0);
+
+        actions[ACT_IMPORT_LIB] = new TAction("import-lib-command", "Import library", IconManager.imgic338, IconManager.imgic339, "Import library",  "Import a TTool library", 'E');
+        actions[ACT_EXPORT_LIB] = new TAction("export-lib-command", "Export library", IconManager.imgic340, IconManager.imgic341, "Export library",  "Export a TTool library", 'I');
+
+        actions[ACT_CUT] = new TAction("cut-command", "Cut",IconManager.imgic330, IconManager.imgic331, "Cut", "Cut selected components", 'X', true);
+        actions[ACT_COPY] = new TAction("copy-command", "Copy", IconManager.imgic332, IconManager.imgic333, "Copy", "Copy selected components", 'C', true);
+        actions[ACT_PASTE] = new TAction("paste-command", "Paste",IconManager.imgic334, IconManager.imgic335, "Paste", "Paste - if possible - previously cut / copied components at the minimal position of the currently opened diagram", 'V', true);
+        actions[ACT_SUPPR] = new TAction("delete-command", "Delete", IconManager.imgic336, IconManager.imgic337, "Delete", "Delete selected components", KeyEvent.VK_DELETE);
+        actions[ACT_DELETE] = new TAction("delete-command", "Delete", IconManager.imgic336, IconManager.imgic337, "Delete", "Delete selected components", KeyEvent.VK_BACK_SPACE);
+
+        actions[ACT_ZOOM_MORE] = new TAction("zoommore-command", "Zoom +", IconManager.imgic316, IconManager.imgic317, "Zoom +", "Zoom +", '0');
+        actions[ACT_ZOOM_LESS] = new TAction("zoomless-command", "Zoom -", IconManager.imgic314, IconManager.imgic315, "Zoom -", "Zoom -", '0');
+        actions[ACT_SHOW_ZOOM] = new TAction("showzoom-command", "100%", null, null, "Zoom value", "Zoom value", '0');
+
+        actions[ACT_BACKWARD] = new TAction("backward-command", "Undo",IconManager.imgic40, IconManager.imgic41, "Undo", "One operation before", 'Z', true);
+        actions[ACT_FORWARD] = new TAction("forward-command", "Redo", IconManager.imgic42, IconManager.imgic43, "Redo", "One operation ahead", 'Y', true);
+
+        actions[ACT_FIRST_DIAG] = new TAction("firstdiag-command", "First diagram",IconManager.imgic44, IconManager.imgic45, "First diagram", "Open the first diagram", 'A');
+        actions[ACT_BACK_DIAG] = new TAction("backdiag-command", "Previous diagram", IconManager.imgic46, IconManager.imgic47, "Previous diagram", "Open the previous diagram", 'P', true);
+        actions[ACT_NEXT_DIAG] = new TAction("nextdiag-command", "Next diagram",IconManager.imgic48, IconManager.imgic49, "Next diagram", "Open the next diagram", 'F', true);
+        actions[ACT_LAST_DIAG] = new TAction("lastdiag-command", "Last diagram", IconManager.imgic50, IconManager.imgic51, "Last diagram", "Open the last diagram", 'E');
+
+        actions[ACT_TOGGLE_ATTRIBUTES] = new TAction("toggle-att-command", "Show / hide Attributes",IconManager.imgic132, IconManager.imgic132, "Show / hide Attributes", "Show / hide Attributes", '0');
+        actions[ACT_TOGGLE_GATES] = new TAction("toggle-gate-command", "Show / hide Gates",IconManager.imgic134, IconManager.imgic134, "Show / hide Gates", "Show / hide Gates", '0');
+        actions[ACT_TOGGLE_SYNCHRO] = new TAction("toggle-synchro-command", "Show / hide Synchronization gates",IconManager.imgic136, IconManager.imgic136, "Show / hide Synchronization gates", "Show / hide Synchronization gates", '0');
+
+        actions[ACT_TOGGLE_JAVA] = new TAction("toggle-java-command", "Show / hide Java code", IconManager.imgic138, IconManager.imgic138, "Show / hide Java code", "Show / hide Java code", '0');
+        actions[ACT_TOGGLE_ATTR] = new TAction("toggle-attr-command", "Show / hide attributes (OFF -> partial -> Full)", IconManager.imgic138, IconManager.imgic138, "Show / hide element attributes (OFF -> Partial -> Full)", "Show / hide attributes (OFF -> Partial -> Full)", '0');
+
+        actions[ACT_TOGGLE_DIPLO_ID] = new TAction("toggle-tml-id", "Show / hide DIPLODOCUS IDs", IconManager.imgic138, IconManager.imgic138, "Show / hide DIPLODOCUS IDs", "Show / hide DIPLODOCUS IDs", '0');
+        actions[ACT_TOGGLE_AVATAR_ID] = new TAction("toggle-avatar-id", "Show / hide AVATAR IDs", IconManager.imgic138, IconManager.imgic138, "Show / hide AVATAR IDs", "Show / hide AVATAR IDs", '0');
+        actions[ACT_TOGGLE_TEPE_ID] = new TAction("toggle-tepe-id", "Show / hide TEPE IDs", IconManager.imgic138, IconManager.imgic138, "Show / hide TEPE IDs", "Show / hide TEPE IDs", '0');
+
+        actions[ACT_TOGGLE_INTERNAL_COMMENT] = new TAction("toggle-internal-comment-command", "Show / hide (OFF -> partial -> Full)", IconManager.imgic138, IconManager.imgic138, "Show / hide internal comments (OFF -> partial -> Full)", "Show / hide internal comments (OFF -> partial -> Full)", '0');
+
+        actions[ACT_MODEL_CHECKING] = new TAction("checking-command", "Syntax analysis", IconManager.imgic36, IconManager.imgic37, "Syntax analysis",  "Checks that all diagrams follows the TTool's syntax", '1');
+        actions[ACT_GEN_RTLOTOS] = new TAction("gen_rtlotos-command", "Generate RT-LOTOS", IconManager.imgic34, IconManager.imgic35, "Generate RT-LOTOS specification",  "Generates a RT-LOTOS specification from TTool diagrams", KeyEvent.VK_F6);
+        actions[ACT_GEN_LOTOS] = new TAction("gen_lotos-command", "Generate LOTOS", IconManager.imgic90, IconManager.imgic90, "Generate LOTOS specification",  "Generates a LOTOS specification from TTool diagrams", '0');
+        actions[ACT_ONECLICK_LOTOS_RG] = new TAction("gen_rglotos-command", "One-click LOTOS-based verification", IconManager.imgic342, IconManager.imgic342, "One-click LOTOS-based verification",  "Generates a LOTOS-based RG  from TTool diagrams", '0');
+        actions[ACT_ONECLICK_RTLOTOS_RG] = new TAction("gen_rgrtlotos-command", "Generate RT-LOTOS-based RG", IconManager.imgic342, IconManager.imgic342, "Generate RT-LOTOS-based RG ",  "Generates an RT-LOTOS-based RG  from TTool diagrams", '0');
+
+        // Issue #35: Renamed action name to be closer to actual functionality
+        actions[ACT_GEN_UPPAAL] = new TAction("gen_uppaal-command", "Safety Verification (UPPAAL)", IconManager.imgic86, IconManager.imgic86, "Safety Verification (UPPAAL)",  "Formal safety verification of TTool diagrams with UPPAAL", '0');
+
+        actions[ACT_AVATAR_MODEL_CHECKER] = new TAction("avatar-model-checker", "Safety verification", IconManager.imgic140, IconManager.imgic140, "Safety verification (Internal tool)",  "Safety verification with the internal model checker", '0');
+        actions[ACT_GEN_JAVA] = new TAction("gen_java-command", "Generate JAVA", IconManager.imgic38, IconManager.imgic39, "Generate JAVA",  "Generates Java code from TURTLE diagrams", 0);
+        actions[ACT_SIMU_JAVA] = new TAction("gen_simujava-command", "Java-based simulation", IconManager.imgic38, IconManager.imgic39, "JAVA-based simualtion",  "Simulate diagrams using Java language", 0);
+        //@author: Huy TRUONG
+        //action for button External Search and Internal Sarch
+        actions[ACT_EXTERNAL_SEARCH] = new TAction("external_search-command", "External Search", IconManager.imgic5113, IconManager.imgic5113, "External Search",  "External Search Interface", 0);
+        actions[ACT_INTERNAL_SEARCH] = new TAction("internal_search-command", "Internal Search", IconManager.imgic5114, IconManager.imgic5114, "Internal Search",  "Internal Search Interface", 0);
+        //--
+        actions[ACT_GEN_SYSTEMC] = new TAction("gen_systemc-command", "Generate simulation code", IconManager.imgic61, IconManager.imgic61, "Generate code for simulation",  "Generates code for simulation", 0);
+        actions[ACT_SIMU_SYSTEMC] = new TAction("simu_systemc", "Interactive Simulation", IconManager.imgic61, IconManager.imgic61, "Interactive simulation",  "Interactive simulation ", 0);
+        actions[ACT_GEN_TMLTXT] = new TAction("gen_tmltxt-command", "Generate TML / TMAP in text format", IconManager.imgic66, IconManager.imgic66, "Generate TML / TMAP in text format",  "Generates TML / TMAP code in text format from TML Design diagrams", 0);
+        actions[ACT_GEN_CCODE] = new TAction("gen_CCode-command", "Generate C code", IconManager.imgic68, IconManager.imgic68, "Generate C code",  "Generate C code from DIPLODOCUS deployment diagrams", 0);
+        actions[ACT_GEN_AUT] = new TAction("gen_aut-command", "Generate automata", IconManager.imgic64, IconManager.imgic64, "Generate automata",  "Generates automata from TML Design diagrams", 0);
+        actions[ACT_GEN_AUTS] = new TAction("gen_auts-command", "Generate automata via LOTOS", IconManager.imgic64, IconManager.imgic64, "Generate automata via LOTOS",  "Generates automata from TML Design diagrams, using LOTOS", 0);
+        actions[ACT_GEN_DESIGN] = new TAction("gen_design-command", "Generate Design", IconManager.imgic58, IconManager.imgic59, "Generate Design from analysis",  "Generates a TURTLE design from a TURTLE analysis", 0);
+        actions[ACT_CHECKCODE] = new TAction("gen_checkcode-command", "Check syntax of formal code", IconManager.imgic312, IconManager.imgic312, "Check syntax of formal code",  "Gives as input to the corresponding tool the lastly generated formal specification", 0);
+        actions[ACT_SIMULATION] = new TAction("gen_sim-command", "Run intensive simulation", IconManager.imgic312, IconManager.imgic312, "Run simulation",  "Generate a simulation trace for the lastly generated formal specification", '0');
+        actions[ACT_VALIDATION] = new TAction("gen_val-command", "Formal Verification", IconManager.imgic310, IconManager.imgic310, "Formal verification",  "Generate an automata (DTA, RG) from the lastly generated formal specification", '0');
+        actions[ACT_PROJECTION] = new TAction("proj_val-command", "Make minimization", IconManager.imgic310, IconManager.imgic310, "Make minimization",  "Minimize a RG using Aldebaran", KeyEvent.VK_F9);
+        actions[ACT_GRAPH_MODIFICATION] = new TAction("graph_modification-command", "Modify minimized graph", IconManager.imgic310, IconManager.imgic310, "Modify minimized graph",  "Modify minimized graph according to a selected function", 0);
+        actions[ACT_BISIMULATION] = new TAction("bisimulation-command", "Make bisimulation (Aldebaran)", IconManager.imgic310, IconManager.imgic310, "Make bisimulation (Aldebaran)",  "Perform bisimulations using Aldebaran", KeyEvent.VK_F10);
+        actions[ACT_BISIMULATION_CADP] = new TAction("bisimulation-cadp-command", "Make bisimulation (BISIMULATOR)", IconManager.imgic310, IconManager.imgic310, "Make bisimulation (BISIMULATOR)",  "Perform bisimulations using BISIMULATOR", KeyEvent.VK_F10);
+        actions[ACT_DEADLOCK_SEEKER_AUT] = new TAction("deadlockseeker-command", "Search for Deadlocks on last AUT graph", IconManager.imgic310, IconManager.imgic310, "Search for deadlocks (last AUT graph)",  "Display all states with no exit transitions (potential deadlocks on lastly generated AUT graph)", 0);
+        actions[ACT_DEADLOCK_SEEKER_SAVED_AUT] = new TAction("deadlockseekersavedaut-command", "Search for Deadlocks on saved AUT graph", IconManager.imgic310, IconManager.imgic310, "Search for deadlocks (saved AUT graph)",  "Display all states with no exit transitions (potential deadlocks on previously saved AUT graph)", 0);
+        actions[ACT_VIEW_STAT_AUT] = new TAction("viewstataut-command", "Analysis (last AUT graph)", IconManager.imgic28, IconManager.imgic29, "Analysis (last AUT graph)",  "Analysis on the last generated reachability graph generated in AUT (Aldebaran) format", 0);
+        actions[ACT_VIEW_STAT_AUTDIPLODOCUS] = new TAction("viewstatautdiplodocus-command", "Analysis (last DIPLODOCUS graph)", IconManager.imgic28, IconManager.imgic29, "Analysis (last DIPLODOCUS graph)",  "Analysis on the last DIPLODOCUS reachability graph generated by the simulator", 0);
+        actions[ACT_VIEW_STAT_AUTPROJ] = new TAction("viewstatautproj-command", "Analysis (last minimized AUT graph)", IconManager.imgic28, IconManager.imgic29, "Analysis (last minimized AUT graph)",  "Analysis on the last minimized reachability graph  in AUT (Aldebaran) format", 0);
+        actions[ACT_VIEW_STAT_SAVED_AUT] = new TAction("viewstatsavedautproj-command", "Analysis (last saved RG)", IconManager.imgic28, IconManager.imgic29, "Analysis (last saved RG)",  "Analysis on a save dgraph", 0);
+        actions[ACT_VIEW_PM_AUT] = new TAction("viewpmaut-command", "Power Management Analysis (last AUT graph)", IconManager.imgic28, IconManager.imgic29, "Power Management Analysis (last AUT graph)",  "Power Management Analysis on the last generated reachability graph generated in AUT (Aldebaran) format", 0);
+        actions[ACT_VIEW_PM_AUTPROJ] = new TAction("viewpmautproj-command", "Power Management Analysis (last minimized AUT graph)", IconManager.imgic28, IconManager.imgic29, "Power Management Analysis (last minimized AUT graph)",  "Power Management Analysis on the last minimized reachability graph  in AUT (Aldebaran) format", 0);
+        actions[ACT_VIEW_PM_SAVED_AUT] = new TAction("viewpmsavedautproj-command", "Power Management Analysis (saved AUT graph)", IconManager.imgic28, IconManager.imgic29, "Power Management Analysis (saved AUT graph)",  "Power Management Analysis on a graph saved in AUT (Aldebaran) format", 0);
+        actions[ACT_DSE] = new TAction("auto-dse", "Automated Design Space Exploration", IconManager.imgic89, IconManager.imgic89, "Automated Design Space Exploration", "Find the optimal mapping and security additions automatically",0);
+        // AVATAR
+        actions[ACT_AVATAR_SIM] = new TAction("avatar-simu", "Interactive simulation", IconManager.imgic18, IconManager.imgic18, "Interactive simulation",  "Interactive simulation of the AVATAR design under edition", '2');
+        actions[ACT_AVATAR_FV_UPPAAL] = new TAction("avatar-formal-verification-uppaal", "Safety formal verification with UPPAAL (Safety)", IconManager.imgic86, IconManager.imgic86, "Formal verification with UPPAAL (Safety)",  "Formal verification with UPPAAL (Safety) of the AVATAR design under edition", '3');
+        actions[ACT_AVATAR_FV_PROVERIF] = new TAction("avatar-formal-verification-proverif", "Security verification (ProVerif)", IconManager.imgic88, IconManager.imgic88, "Security verification (ProVerif)",  "Security formal verification (with ProVerif)", '4');
+        actions[ACT_AVATAR_FV_STATICANALYSIS] = new TAction("avatar-formal-verification-staticanalysis", "Safety analysis (invariants)", IconManager.imgic96, IconManager.imgic96, "Safaty analysis (invariants)",  "Safety analysis using the invariant tecnique", '5');
+        actions[ACT_AVATAR_EXECUTABLE_GENERATION] = new TAction("avatar-executable-generation", "Code generation" , IconManager.imgic94, IconManager.imgic94, "Code generation",  "Generation of C-POSIX executable code from AVATAR design under edition", '6');
+
+
+        actions[ACT_VIEW_JAVA] = new TAction("view-java", "Display Java code", IconManager.imgic38, IconManager.imgic39, "Display Java code",  "Display the java code of the pointed component", 0);
+        actions[ACT_VIEW_RTLOTOS] = new TAction("view-rtlotos", "Show last formal specification", IconManager.imgic302, IconManager.imgic302, "Show formal specification",  "Display the lastest generated formal specification", 0);
+        actions[ACT_VIEW_SUGGESTED_DESIGN] = new TAction("view-suggested-design", "Show last suggested design", IconManager.imgic302, IconManager.imgic302, "Show suggested design",  "Display the lastest generated suggested design", 0);
+        actions[ACT_VIEW_SIM] = new TAction("view-sim", "Show last simulation trace (timing order)", IconManager.imgic318, IconManager.imgic319, "Show last simulation trace (timing order)",  "Display the lastest generated simulation trace in function of action time", 0);
+        actions[ACT_VIEW_SIM_CHRONO] = new TAction("view-sim-chrono", "Show last simulation trace (chronological order)", IconManager.imgic318, IconManager.imgic319, "Show last simulation trace (chronological order)",  "Display the lastest generated simulation trace in function of action chronological order", 0);
+        actions[ACT_VIEW_DTADOT] = new TAction("view-dtadot", "Show last DTA", IconManager.imgic306, IconManager.imgic306, "Show DTA",  "Display the lastest generated DTA", 0);
+        actions[ACT_VIEW_RGDOT] = new TAction("view-rgdot", "Show last RG", IconManager.imgic308, IconManager.imgic308, "Show RG",  "Display the lastest generated RG", 0);
+        actions[ACT_VIEW_TLSADOT] = new TAction("view-tlsadot", "Show last TLSA", IconManager.imgic308, IconManager.imgic308, "Show TLSA",  "Display the lastest generated TLSA", 0);
+        actions[ACT_VIEW_RGAUTDOT] = new TAction("view-rgdot-aut", "Show last RG (AUT format)", IconManager.imgic308, IconManager.imgic308, "Show RG (aldebaran)",  "Display the lastest generated RG (Aldebaran format)", 0);
+        actions[ACT_VIEW_RGAUTPROJDOT] = new TAction("view-rgdot-aut-proj", "View minimized RG", IconManager.imgic308, IconManager.imgic308, "View minimized RG",  "Display the lastest minimized RG", 0);
+        actions[ACT_VIEW_MODIFIEDAUTDOT] = new TAction("view-modified-aut-dot", "View modified RG", IconManager.imgic308, IconManager.imgic308, "View modified RG",  "Display the lastest modified RG", 0);
+        actions[ACT_VIEW_SAVED_LOT] = new TAction("view-saved-lot", "View RT-LOTOS specification", IconManager.imgic308, IconManager.imgic308, "View RT-LOTOS specification",  "Display a RT-LOTOS specification previously saved", 0);
+        actions[ACT_VIEW_SAVED_DOT] = new TAction("view-saved-dot", "View saved graph", IconManager.imgic308, IconManager.imgic308, "View saved graph",  "Display a previously saved graph (DTA, RG, AUT)", 0);
+        actions[ACT_VIEW_BIRDEYES] = new TAction("view-birdeyes", "Show external bird eyes view", IconManager.imgic56, IconManager.imgic57, "Show external bird eyes view",  "Bird eyes view of the diagram under edition", 0);
+        actions[ACT_VIEW_BIRDEYES_EMB] = new TAction("view-birdeyes-emb", "Hide / Show embedded bird eyes view", IconManager.imgic56, IconManager.imgic57, "Hide / Show embedded bird eyes view",  "Embedded bird eyes view of the diagram under edition", 0);
+        actions[ACT_VIEW_WAVE] = new TAction("view-wave", "View wave", IconManager.imgic56, IconManager.imgic57, "View wave",  "Use gtkwave to display various signals of the lastly performed simulation", 0);
+        actions[ACT_VIEW_RG_DIPLODOCUS] = new TAction("view-rg-diplodocus", "Show last DIPLODOCUS RG", IconManager.imgic308, IconManager.imgic308, "Show last DIPLODOCUS RG",  "Display the lastest RG generated by the DIPLODOCUS simulator", 0);
+
+
+        actions[ACT_SCREEN_CAPTURE] = new TAction("screen-capture", "Screen capture", IconManager.imgic338, IconManager.imgic339, "Screen capture",  "Capture the screen", 0);
+        actions[ACT_TTOOL_WINDOW_CAPTURE] = new TAction("tool-window-capture", "TTool Window capture", IconManager.imgic338, IconManager.imgic339, "Main window capture",  "Capture the main window", 0);
+        actions[ACT_DIAGRAM_CAPTURE] = new TAction("diagram-capture", "Current diagram capture (PNG)", IconManager.imgic338, IconManager.imgic339, "Diagram capture",  "Capture the currenlty opened diagram", 0);
+        actions[ACT_SVG_DIAGRAM_CAPTURE] = new TAction("svg-diagram-capture", "Current diagram capture (SVG)", IconManager.imgic338, IconManager.imgic339, "Diagram capture (SVG)",  "Capture the currenlty opened diagram in svg format", 0);
+        actions[ACT_ALL_DIAGRAM_CAPTURE] = new TAction("all-diagram-capture", "All diagrams capture (PNG)", IconManager.imgic338, IconManager.imgic339, "All diagram capture (PNG)",  "Capture in png images the currenlty opened set of diagram (analysis, design, etc.)", 0);
+        actions[ACT_ALL_DIAGRAM_CAPTURE_SVG] = new TAction("all-diagram-capture-svg", "All diagrams capture (SVG)", IconManager.imgic338, IconManager.imgic339, "All diagram capture (SVG)",  "Capture in svg images the currenlty opened set of diagram (analysis, design, etc.)", 0);
+        actions[ACT_SELECTED_CAPTURE] = new TAction("selected-capture", "Capture of selected components", IconManager.imgic338, IconManager.imgic339, "Capture of selected components",  "Capture the selected components of the currently opened diagram", 0);
+        actions[ACT_GEN_DOC] = new TAction("gen-doc", "Documentation generation", IconManager.imgic28, IconManager.imgic28, "Documentation generation",  "Documentation may be automatically generated, in html format, from edited diagrams", 0);
+        actions[ACT_GEN_DOC_REQ] = new TAction("gen-doc-req", "SysML requirements documentation", IconManager.imgic28, IconManager.imgic28, "SysML requirements documentation",  "SysML requirements documentation is displayed in an array, and may be further automatically generated in html format", 0);
+
+        actions[ACT_ABOUT] = new TAction("about-command", "About", IconManager.imgic30, IconManager.imgic31, "About", "TTool information", 0);
+        actions[ACT_TURTLE_WEBSITE] = new TAction("turtle-website-command", "TTool's website", IconManager.imgic30, IconManager.imgic31, "TTool's website", "Various information (e.g., documentation) on TTool", 0);
+        actions[ACT_TURTLE_DOCUMENTATION] = new TAction("turtle-docu-command", "AVATAR online help", IconManager.imgic30, IconManager.imgic31, "AVATAR online help", "AVATAR online help", 0);
+        actions[ACT_DIPLODOCUS_DOCUMENTATION] = new TAction("diplo-docu-command", "DIPLODOCUS online help", IconManager.imgic30, IconManager.imgic31, "DIPLODOCUS online help", "DIPLODOCUS online help", 0);
+
+        // Issue # 34: SysMLSec help was using the command of DIPLODOCUS resulting in SysMLSec help being displayed instead
+        actions[ACT_SYSMLSEC_DOCUMENTATION] = new TAction("sysmlsec-docu-command", "SysML-Sec online help", IconManager.imgic30, IconManager.imgic31, "SysML-Sec online help", "SysML-Sec online help", 0);
+        //      actions[ACT_SYSMLSEC_DOCUMENTATION] = new TAction("diplo-docu-command", "SysML-Sec online help", IconManager.imgic30, IconManager.imgic31, "SysML-Sec online help", "SysML-Sec online help", 0);
+        actions[ACT_TTOOL_CONFIGURATION] = new TAction("configuration-command", "Configuration", IconManager.imgic76, IconManager.imgic77, "Configuration", "Configuration loaded at startup", 0);
+
+        actions[ACT_ENHANCE] = new TAction("enhance-command", "Enhance", IconManager.imgic28, IconManager.imgic29, "Enhance", "Automatically enhance diagram", 0);
+
+        actions[CONNECTOR_COMMENT] = new TAction("add-comment-connector", "Add Comment connector", IconManager.imgic65, IconManager.imgic65, "Comment connector", "Add a Connector between a UML note and a component in the currently opened diagram", 0);
+
+        //for the new action created by Solange
+        actions[PRUEBA_1] = new TAction("Help for color of the ports", "Help for color of the ports", IconManager.imgic2111, IconManager.imgic2111, "Help for color of the ports", "Help for color of the ports",0);
+
+        actions[TCD_EDIT] = new TAction("edit-class-diagram", "Edit class diagram", IconManager.imgic100, IconManager.imgic101, "Edit Class Diagram", "Make it possible to edit the currently opened class diagram", 0);
+        actions[TCD_NEW_TCLASS] = new TAction("add-tclass", "Add Tclass", IconManager.imgic104, IconManager.imgic104, "Tclass", "Add a TClass to the currently opened class diagram", 0);
+        actions[TCD_NEW_TOBJECT] = new TAction("add-tobject", "Add Tobject", IconManager.imgic128, IconManager.imgic128, "Tobject", "Add a TObject (= instance of a TClass) to the currently opened class diagram", 0);
+        actions[TCD_NEW_TDATA] = new TAction("add-tdata", "Add Tdata", IconManager.imgic130, IconManager.imgic130, "Tdata", "Add a Tdata (= TURTLE data) to the currently opened class diagram", 0);
+        actions[TCD_ASSOCIATION] = new TAction("add-association", "Add association", IconManager.imgic102, IconManager.imgic102, "Association", "Add an association between two tclasses of the currently opened class diagram", 0);
+        actions[AD_EDIT] = new TAction("edit-activity-diagram", "Edit activity diagram", IconManager.imgic200, IconManager.imgic201, "Edit Activity Diagram", "Make it possible to edit the currently opened activity diagram", 0);
+        actions[AD_CONNECTOR] = new TAction("add-ad-connector", "Add AD Connector", IconManager.imgic202, IconManager.imgic202, "ADConnector", "Add a Connector between two components of the currently opnened activity diagram", 0);
+        actions[AD_ACTION_STATE] = new TAction("add-action-state", "Add Action State", IconManager.imgic204, IconManager.imgic204, "Action state", "Add an action state (i.e. synchronization on gate, variable modification, process spawning) to the currently opened activity diagram", 0);
+        actions[AD_PARALLEL] = new TAction("add-parallel", "Add Parallel", IconManager.imgic206, IconManager.imgic206, "Parallel", "Add a parallel or synchro operator to the currently opened activity diagram", 0);
+        actions[AD_SEQUENCE] = new TAction("add-sequence", "Add Sequence", IconManager.imgic226, IconManager.imgic226, "Sequence", "Add a sequence operator to the currently opened activity diagram", 0);
+        actions[AD_PREEMPTION] = new TAction("add-preemption", "Add Preemption", IconManager.imgic228, IconManager.imgic228, "Preemption", "Add a preemption operator to the currently opened activity diagram", 0);
+        actions[AD_CHOICE] = new TAction("add-choice", "Add Choice", IconManager.imgic208, IconManager.imgic208, "Choice", "Add a choice - non-deterministic or guarded - to the currently opened activity diagram", 0);
+        actions[AD_START] = new TAction("add-start", "Add Start state", IconManager.imgic222, IconManager.imgic222, "Start", "Add a start state to the currently opened activity diagram", 0);
+        actions[AD_STOP] = new TAction("add-stop", "Add Stop", IconManager.imgic210, IconManager.imgic210, "Stop", "Add a termination state to the currently opened activity diagram", 0);
+        actions[AD_JUNCTION] = new TAction("add-juunction", "Add Junction", IconManager.imgic212, IconManager.imgic212, "Junction", "Add a junction with three inputs to the currently opened activity diagram", 0);
+        actions[AD_DETERMINISTIC_DELAY] = new TAction("add-deterministic-delay", "Add Deterministic Delay", IconManager.imgic214, IconManager.imgic214, "Deterministic Delay", "Add a deterministic delay to the currently opened activity diagram", 0);
+        actions[AD_NON_DETERMINISTIC_DELAY] = new TAction("add-non-deterministic-delay", "Add Non-Deterministic Delay", IconManager.imgic216, IconManager.imgic216, "Non-Deterministic Delay", "Add a non-deterministic delay to the currently opened activity diagram", 0);
+        actions[AD_DELAY_NON_DETERMINISTIC_DELAY] = new TAction("add-time-interval", "Add Time Interval", IconManager.imgic224, IconManager.imgic224, "Time interval", "Add a time interval to the currently opened activity diagram", 0);
+        actions[AD_TIME_LIMITED_OFFER] = new TAction("add-time-limited-offer", "Add Time-Limited offer", IconManager.imgic218, IconManager.imgic218, "Time-Limited Offer", "Add a time-limited offer to the currently opened activity diagram", 0);
+        actions[AD_TIME_LIMITED_OFFER_WITH_LATENCY] = new TAction("add-time-limited-offer-with-latency", "Add Time-Limited offer with a non-deterministic delay", IconManager.imgic220, IconManager.imgic220, "Time-Limited Offer with non-deterministic delay", "Adds a time-limited offer, beginning with a non-deterministic delay, to the currently opened activity diagram", 0);
+        actions[AD_TIME_CAPTURE] = new TAction("add-time-capture", "Time capture", IconManager.imgic204, IconManager.imgic204, "Action time capture", "Add a time capture operator to the currently opened activity diagram", 0);
+        actions[AD_ARRAY_GET] = new TAction("add-array-get", "Add array get element", IconManager.imgic230, IconManager.imgic230, "Array get element", "Add an array get element action to the currently opened activity diagram", 0);
+        actions[AD_ARRAY_SET] = new TAction("add-array-set", "Add array set element", IconManager.imgic232, IconManager.imgic232, "Array set element", "Add an array set element action to the currently opened activity diagram", 0);
+
+        actions[ADD_EDIT] = new TAction("edit-add-diagram", "Edit AVATAR deployment diagram", IconManager.imgic100, IconManager.imgic101, "Edit AVATAR deployment diagram", "Make it possible to edit the currently opened AVATAR deployment diagram", 0);
+        actions[ADD_LINK] = new TAction("add-add-link", "Add a link", IconManager.imgic202, IconManager.imgic202, "Link", "Add a link between two nodes of the currently opened AVATAR deployment diagram", 0);
+        actions[ADD_CPUNODE] = new TAction("add-add-cpunode", "Add a CPU", IconManager.imgic1100, IconManager.imgic1100, "CPU", "Add a cpu node to the currently opened AVATAR deployment diagram", 0);
+
+        actions[ADD_BUSNODE] = new TAction("add-add-busnode", "Add a Bus", IconManager.imgic1102, IconManager.imgic1102, "Bus", "Add a bus node to the currently opened AVATAR deployment diagram", 0);
+        actions[ADD_VGMNNODE] = new TAction("add-add-vgmnnode", "Add a VGMN", IconManager.imgic1102, IconManager.imgic1102, "VGMN", "Add a VGMN node to the currently opened AVATAR deployment diagram", 0);
+        actions[ADD_CROSSBARNODE] = new TAction("add-add-crossbarnode", "Add a CROSSBAR", IconManager.imgic1102, IconManager.imgic1102, "Crossbar", "Add a Crossbar node to the currently opened AVATAR deployment diagram", 0);
+
+        actions[ADD_TTYNODE] = new TAction("add-add-tty", "Add a TTY node", IconManager.imgic1108, IconManager.imgic1108, "TTY", "Add a tty node to the currently opened AVATAR deployment diagram", 0);
+        actions[ADD_BLOCKARTIFACT] = new TAction("add-add-blockartifact", "Map an AVATAR block", IconManager.imgic702, IconManager.imgic702, "Map an AVATAR block", "Map an AVATAR block onto a node in the currently opened AVATAR deployment diagram", 0);
+        // julien ----------------------------------------------------------------------------------
+        actions[DEPLOY_AVATAR_DIAGRAM] = new TAction("DEPLOY", "DEPLOY",IconManager.imgic94, IconManager.imgic94, "Generate DEPLOY Soclib", "DEPLOY diagram without check syntax", 0);
+
+        actions[EXTRAC_DEPLOY_PARAM_TO_FILE] = new TAction("FILE", "FILE",IconManager.imgic340,IconManager.imgic340, "Extrac attributes to File", "Extrac attributes to specified File", 0);
+        // -----------------------------------------------------------------------------------------
+
+        actions[ADD_CHANNELARTIFACT] = new TAction("add-add-channelartifact", "Map an AVATAR Channel", IconManager.imgic702, IconManager.imgic702, "Map an AVATAR channel", "Map an AVATAR channel onto a memory in the currently opened AVATAR deployment diagram", 0);
+        actions[ADD_BRIDGENODE] = new TAction("add-add-bridgenode", "Add a Bridge", IconManager.imgic1104, IconManager.imgic1104, "Bridge node", "Add a bridge node to the currently opened AVATAR deployment diagram", 0);
+        actions[ADD_RAMNODE] = new TAction("add-add-ramnode", "Add a RAM", IconManager.imgic1108, IconManager.imgic1108, "RAM", "Add a RAM node to the currently opened AVATAR deployment diagram", 0);
+        actions[ADD_ROMNODE] = new TAction("add-add-romnode", "Add a ROM", IconManager.imgic1108, IconManager.imgic1108, "ROM", "Add a memory node to the currently opened AVATAR deployment diagram", 0);
+        actions[ADD_DMANODE] = new TAction("add-add-dmanode", "Add a DMA", IconManager.imgic1110, IconManager.imgic1110, "DMA", "Add a DMA node to the currently opened AVATAR deployment diagram", 0);
+        actions[ADD_ICUNODE] = new TAction("add-add-icunode", "Add an ICU", IconManager.imgic1112, IconManager.imgic1112, "ICU", "Add a ICU node to the currently opened AVATAR deployment diagram", 0);
+        actions[ADD_COPROMWMRNODE] = new TAction("add-add-copromwmrnode", "Add a MWMR Copro", IconManager.imgic1114, IconManager.imgic1114, "MWMR Copro", "Add a DMA node to the currently opened AVATAR deployment diagram", 0);
+        actions[ADD_TIMERNODE] = new TAction("add-add-timernode", "Add a Timer", IconManager.imgic1116, IconManager.imgic1116, "Timer", "Add a timer node to the currently opened AVATAR deployment diagram", 0);
+
+
+        actions[TCD_PARALLEL_OPERATOR] = new TAction("add-parallel-operator", "Add Parallel composition operator", IconManager.imgic112, IconManager.imgic112, "Parallel composition operator", "Add a Parallel composition operator to the currently opened class diagram", 0);
+        actions[TCD_CONNECTOR_ATTRIBUTE] = new TAction("add-attribute-connector", "Connects an association to a composition operator", IconManager.imgic108, IconManager.imgic108, "Attributes an association with a composition operator", "Adds a connector between an association and a composition operator to the currently opened class diagram", 0);
+        actions[TCD_SEQUENCE_OPERATOR] = new TAction("add-sequence-operator", "Add Sequence composition operator", IconManager.imgic114, IconManager.imgic114, "Sequence composition operator", "Add a Sequence composition operator to the currently opened class diagram", 0);
+        actions[TCD_PREEMPTION_OPERATOR] = new TAction("add-preemption-operator", "Add Preemption composition operator", IconManager.imgic116, IconManager.imgic116, "Preemption composition operator", "Add a Preemption composition operator to the currently opened class diagram", 0);
+        actions[TCD_SYNCHRO_OPERATOR] = new TAction("add-synchro-operator", "Add Synchro composition operator", IconManager.imgic110, IconManager.imgic110, "Synchro composition operator", "Adds a Synchro composition operator to the currently opened class diagram", 0);
+        actions[TCD_INVOCATION_OPERATOR] = new TAction("add-invocation-operator", "Add Invocation composition operator", IconManager.imgic126, IconManager.imgic126, "Invocation composition operator", "Adds an invocation composition operator to the currently opened class diagram", 0);
+        actions[TCD_ASSOCIATION_NAVIGATION] = new TAction("add-association-navigation", "Add association with navigation", IconManager.imgic106, IconManager.imgic108, "Association with navigation", "Adds an association with a navigation indication between two tclasses of the currently opened class diagram", 0);
+        actions[UML_NOTE] = new TAction("edit-note", "Add a note to a diagram", IconManager.imgic320, IconManager.imgic321, "Add a comment", "Add a comment to the currently opened TTool diagram", 0);
+        actions[PRAGMA] = new TAction("pragma", "Security pragmas", IconManager.imgic6000, IconManager.imgic6001, "Security pragmas", "Add security pragmas to the currently opened TTool diagram", 0);
+        actions[SAFETY_PRAGMA] = new TAction("safety_pragma", "Add a safety (UPPAAL) property to a diagram", IconManager.imgic6002, IconManager.imgic6003, "Safety property (UPPAAL)", "Add a safety (UPPAAL) property to the currently opened TTool diagram", 0);
+        actions[PERFORMANCE_PRAGMA] = new TAction("performance_pragma", "Add a performance property to a diagram", IconManager.imgic6004, IconManager.imgic6005, "Performance property", "Add a performance property to the currently opened TTool diagram", 0);
+        actions[AVATAR_FIREWALL] = new TAction("avatar_firewall", "Add an avatar firewall to a diagram", IconManager.imgic7001, IconManager.imgic7001, "Add an avatar firewall", "Add an avatar firewall to the currently opened TTool diagram", 0);
+
+        actions[IOD_EDIT] = new TAction("edit-io-diagram", "Edit interaction overview diagram", IconManager.imgic100, IconManager.imgic101, "Edit interaction overview diagram", "Make it possible to edit the currently opened interaction overview diagram", 0);
+        actions[IOD_CONNECTOR] = new TAction("add-iod-connector", "Add IOD Connector", IconManager.imgic202, IconManager.imgic202, "Connector", "Add a Connector between two components of the currently opened interaction overview diagram", 0);
+        actions[IOD_REF_SD] = new TAction("add-ref-sd", "Add reference to a SD", IconManager.imgic400, IconManager.imgic400, "Reference to a SD", "Add a reference to a sequence diagram", 0);
+        actions[IOD_REF_IOD] = new TAction("add-ref-iod", "Add reference to an IOD", IconManager.imgic400, IconManager.imgic400, "Reference to an IOD", "Add a reference to an interaction overview diagram", 0);
+        actions[IOD_PARALLEL] = new TAction("add-iod-parallel", "Add Parallel", IconManager.imgic206, IconManager.imgic206, "Parallel", "Add a parallel or synchro operator to the currently opened interaction overview diagram", 0);
+        //actions[AD_SEQUENCE] = new TAction("add-sequence", "Add Sequence", IconManager.imgic226, IconManager.imgic226, "Sequence", "Add a sequence operator to the currently opened activity diagram", 0);
+        actions[IOD_PREEMPTION] = new TAction("add-iod-preemption", "Add Preemption", IconManager.imgic402, IconManager.imgic402, "Preemption", "Add a preemption operator to the currently opened interaction overview diagram", 0);
+        actions[IOD_SEQUENCE] = new TAction("add-iod-sequence", "Add Sequence", IconManager.imgic226, IconManager.imgic226, "Sequence", "Add a sequence operator to the currently opened interaction overview diagram", 0);
+        actions[IOD_CHOICE] = new TAction("add-iod-choice", "Add Choice", IconManager.imgic208, IconManager.imgic208, "Choice", "Add a choice - non-deterministic or guarded - to the currently opened interaction overview diagram", 0);
+        actions[IOD_START] = new TAction("add-iod-start", "Add Start state", IconManager.imgic222, IconManager.imgic222, "Start", "Add a start state to the currently opened interaction overview diagram", 0);
+        actions[IOD_STOP] = new TAction("add-iod-stop", "Add Stop", IconManager.imgic210, IconManager.imgic210, "Stop", "Add a termination state to the currently opened interaction overview diagram", 0);
+        actions[IOD_JUNCTION] = new TAction("add-iod-junction", "Add Junction", IconManager.imgic212, IconManager.imgic212, "Junction", "Add a junction with three inputs to the currently opened interaction overview diagram", 0);
+
+        actions[SD_EDIT] = new TAction("edit-sd-diagram", "Edit sequence diagram", IconManager.imgic100, IconManager.imgic101, "Edit sequence diagram", "Make it possible to edit the currently opened sequence diagram", 0);
+        actions[SD_INSTANCE] = new TAction("add-sd-instance", "Add an instance", IconManager.imgic500, IconManager.imgic500, "Instance", "Add a new instance  to the currently opened sequence diagram", 0);
+        actions[SD_CONNECTOR_MESSAGE_ASYNC] = new TAction("add-sd-connector-message-async", "Add asynchronous message", IconManager.imgic504, IconManager.imgic504, "Asynchronous message", "Add an asynchronous message between two instances of the currently opened sequence diagram", 0);
+        actions[SD_CONNECTOR_MESSAGE_SYNC] = new TAction("add-sd-connector-message-sync", "Add synchronous message", IconManager.imgic502, IconManager.imgic502, "Synchronous message", "Add an synchronous message between two instances of the currently opened sequence diagram", 0);
+        actions[SD_ABSOLUTE_TIME_CONSTRAINT] = new TAction("add-sd-atc", "Absolute time constraint", IconManager.imgic506, IconManager.imgic506, "Absolute time constraint", "Add an absolute time constraint to the currently opened sequence diagram", 0);
+        actions[SD_RELATIVE_TIME_CONSTRAINT] = new TAction("add-sd-rtc", "Relative time constraint", IconManager.imgic508, IconManager.imgic508, "Relative time constraint", "Add a relative time constraint to the currently opened sequence diagram", 0);
+        actions[SD_RELATIVE_TIME_CONSTRAINT_CONNECTOR] = new TAction("add-sd-rtc-c", "Connect two relative time constraint lines", IconManager.imgic510, IconManager.imgic510, "Relative time constraint connector", "Add a connection between two relative time constraint lines of the currently opened sequence diagram", 0);
+        actions[SD_ACTION_STATE] = new TAction("add-sd-action-state", "Action state", IconManager.imgic512, IconManager.imgic512, "Action state", "Add an action state to the currently opened sequence diagram", 0);
+        actions[SD_GUARD] = new TAction("add-sd-guard", "Guard", IconManager.imgic524, IconManager.imgic524, "Guard", "Add a guard (non-deterministic, else, end) to the currently opened sequence diagram", 0);
+        actions[SD_TIMER_SETTING] = new TAction("add-sd-timer-set-state", "Timer setting", IconManager.imgic514, IconManager.imgic514, "Timer setting", "Add a timer setting to the currently opened sequence diagram", 0);
+        actions[SD_TIME_INTERVAL] = new TAction("add-sd-time-interval", "Time interval", IconManager.imgic224, IconManager.imgic224, "Time interval", "Add a time interval to the currently opened sequence diagram", 0);
+        actions[SD_TIMER_EXPIRATION] = new TAction("add-sd-timer-expiration-state", "Timer expiration", IconManager.imgic516, IconManager.imgic516, "Timer expiration", "Add a timer expiration to the currently opened sequence diagram", 0);
+        actions[SD_TIMER_CANCELLATION] = new TAction("add-sd-timer-cancellation-state", "Timer cancellation", IconManager.imgic518, IconManager.imgic518, "Timer cancellation", "Add a timer cancellation to the currently opened sequence diagram", 0);
+        actions[SD_COREGION] = new TAction("add-sd-coregion", "Coregion", IconManager.imgic520, IconManager.imgic520, "Coregion", "Add a coregion to the currently opened sequence diagram", 0);
+        actions[SD_ALIGN_INSTANCES] = new TAction("add-sd-align_instances", "Align instances", IconManager.imgic522, IconManager.imgic522, "Align instances", "align instances of the currently opened sequence diagram", 0);
+
+        actions[SDZV_EDIT] = new TAction("edit-sdzv-diagram", "Edit sequence diagram", IconManager
+
+.imgic100, IconManager.imgic101, "Edit sequence diagram", "Make it possible to edit the currently opened sequence diagram", 0);
+        actions[SDZV_INSTANCE] = new TAction("add-sdzv-instance", "Add an instance", IconManager.imgic500, IconManager.imgic500, "Instance", "Add a new instance  to the currently opened sequence diagram", 0);
+        actions[SDZV_CONNECTOR_MESSAGE_ASYNC] = new TAction("add-sdzv-connector-message-async", "Add asynchronous message", IconManager.imgic504, IconManager.imgic504, "Asynchronous message", "Add an asynchronous message between two instances of the currently opened sequence diagram", 0);
+        actions[SDZV_CONNECTOR_MESSAGE_SYNC] = new TAction("add-sdzv-connector-message-sync", "Add synchronous message", IconManager.imgic502, IconManager.imgic502, "Synchronous message", "Add an synchronous message between two instances of the currently opened sequence diagram", 0);
+        actions[SDZV_ABSOLUTE_TIME_CONSTRAINT] = new TAction("add-sdzv-atc", "Absolute time constraint", IconManager.imgic506, IconManager.imgic506, "Absolute time constraint", "Add an absolute time constraint to the currently opened sequence diagram", 0);
+        actions[SDZV_RELATIVE_TIME_CONSTRAINT] = new TAction("add-sdzv-rtc", "Relative time constraint", IconManager.imgic508, IconManager.imgic508, "Relative time constraint", "Add a relative time constraint to the currently opened sequence diagram", 0);
+        actions[SDZV_RELATIVE_TIME_CONSTRAINT_CONNECTOR] = new TAction("add-sdzv-rtc-c", "Connect two relative time constraint lines", IconManager.imgic510, IconManager.imgic510, "Relative time constraint connector", "Add a connection between two relative time constraint lines of the currently opened sequence diagram", 0);
+        actions[SDZV_ACTION_STATE] = new TAction("add-sdzv-action-state", "Action state", IconManager.imgic512, IconManager.imgic512, "Action state", "Add an action state to the currently opened sequence diagram", 0);
+        actions[SDZV_GUARD] = new TAction("add-sdzv-guard", "Guard", IconManager.imgic524, IconManager.imgic524, "Guard", "Add a guard (non-deterministic, else, end) to the currently opened sequence diagram", 0);
+        actions[SDZV_TIMER_SETTING] = new TAction("add-sdzv-timer-set-state", "Timer setting", IconManager.imgic514, IconManager.imgic514, "Timer setting", "Add a timer setting to the currently opened sequence diagram", 0);
+        actions[SDZV_TIME_INTERVAL] = new TAction("add-sdzv-time-interval", "Time interval", IconManager.imgic224, IconManager.imgic224, "Time interval", "Add a time interval to the currently opened sequence diagram", 0);
+        actions[SDZV_TIMER_EXPIRATION] = new TAction("add-sdzv-timer-expiration-state", "Timer expiration", IconManager.imgic516, IconManager.imgic516, "Timer expiration", "Add a timer expiration to the currently opened sequence diagram", 0);
+        actions[SDZV_TIMER_CANCELLATION] = new TAction("add-sdzv-timer-cancellation-state", "Timer cancellation", IconManager.imgic518, IconManager.imgic518, "Timer cancellation", "Add a timer cancellation to the currently opened sequence diagram", 0);
+        actions[SDZV_COREGION] = new TAction("add-sdzv-coregion", "Coregion", IconManager.imgic520, IconManager.imgic520, "Coregion", "Add a coregion to the currently opened sequence diagram", 0);
+        actions[SDZV_ALIGN_INSTANCES] = new TAction("add-sdzv-align_instances", "Align instances", IconManager.imgic522, IconManager.imgic522, "Align instances", "align instances of the currently opened sequence diagram", 0);
+
+        actions[UCD_EDIT] = new TAction("edit-ucd-diagram", "Edit use case diagram", IconManager.imgic100, IconManager.imgic101, "Edit use case diagram", "Make it possible to edit the currently opened use case diagram", 0);
+        actions[UCD_ACTOR] = new TAction("add-actor", "Add an actor", IconManager.imgic600, IconManager.imgic600, "Actor", "Add an actor to the currently opened use case diagram", 0);
+        actions[UCD_ACTORBOX] = new TAction("add-actor-box", "Add an actor (box format)", IconManager.imgic614, IconManager.imgic614, "Actor (box format)", "Add an actor in box format to the currently opened use case diagram", 0);
+        actions[UCD_USECASE] = new TAction("add-usecase", "Add a use case", IconManager.imgic602, IconManager.imgic602, "Add a use case", "Add a use case to the currently opened use case diagram", 0);
+        actions[UCD_BORDER] = new TAction("add-border", "Add a border", IconManager.imgic612, IconManager.imgic612, "Add a border", "Add a border to the currently opened use case diagram", 0);
+        actions[UCD_CONNECTOR_ACTOR_UC] = new TAction("add-connector-actor-uc", "actor <-> use case", IconManager.imgic604, IconManager.imgic604, "Actor <-> use case", "Add a connector between an actor and a use case of the currently opened use case diagram", 0);
+        actions[UCD_CONNECTOR_INCLUDE] = new TAction("add-connector-include", "<<include>> relationship", IconManager.imgic606, IconManager.imgic606, "<<include>> relationship", "Add a <<include>> relationship to the currently opened use case diagram", 0);
+        actions[UCD_CONNECTOR_EXTEND] = new TAction("add-connector-extend", "<<extend>> relationship", IconManager.imgic608, IconManager.imgic608, "<<extend>> relationship", "Add a <<extend>> relationship to the currently opened use case diagram", 0);
+        actions[UCD_CONNECTOR_SPECIA] = new TAction("add-connector-specia", "Specialization", IconManager.imgic610, IconManager.imgic610, "specialization", "Add a specialization relationship to the currently opened use case diagram", 0);
+
+        actions[TDD_EDIT] = new TAction("edit-tdd-diagram", "Edit deployment diagram", IconManager.imgic100, IconManager.imgic101, "Edit deployment diagram", "Make it possible to edit the currently opened deployment diagram", 0);
+        actions[TDD_LINK] = new TAction("add-tdd-link", "Add a link", IconManager.imgic202, IconManager.imgic202, "Link", "Add a link between two nodes of the currently opened deployment diagram", 0);
+        actions[TDD_NODE] = new TAction("add-tdd-node", "Add a node", IconManager.imgic700, IconManager.imgic700, "Node", "Add a node to the currently opened deployment diagram", 0);
+        actions[TDD_ARTIFACT] = new TAction("add-tdd-artifact", "Add an artifact", IconManager.imgic702, IconManager.imgic702, "Artifact", "Add an artifact to the currently opened deployment diagram", 0);
+
+        actions[NCDD_EDIT] = new TAction("edit-ncdd-diagram", "Edit network calculus diagram", IconManager.imgic100, IconManager.imgic101, "Edit network calculs diagram", "Make it possible to edit the currently opened network calculus diagram", 0);
+        actions[NCDD_LINK] = new TAction("add-ncdd-link", "Add a link", IconManager.imgic202, IconManager.imgic202, "Link", "Add a link between two nodes of the currently opened network calculus diagram", 0);
+        actions[NCDD_EQNODE] = new TAction("add-ncdd-eqnode", "Add an equipment node", IconManager.imgic700, IconManager.imgic700, "Add an equipment node", "Add an equipment node to the currently opened network calculus diagram", 0);
+        actions[NCDD_SWITCHNODE] = new TAction("add-ncdd-switchnode", "Add a switch node", IconManager.imgic700, IconManager.imgic700, "Add a switch node", "Add a switch node to the currently opened network calculus diagram", 0);
+        actions[NCDD_TRAFFIC_ARTIFACT] = new TAction("add-ncdd-traffic", "Add a traffic", IconManager.imgic702, IconManager.imgic702, "Traffic", "Add a traffic to the currently opened network calculus diagram", 0);
+        actions[NCDD_ROUTE_ARTIFACT] = new TAction("add-ncdd-route", "Add a route", IconManager.imgic702, IconManager.imgic702, "Route", "Add a route to the currently opened network calculus diagram", 0);
+        actions[ACT_NC] = new TAction("gen_nc-command", "Network calculus", IconManager.imgic3000, IconManager.imgic3000, "Network calculus",  "Perform network calculus from  UML diagrams", '0');
+
+
+
+        actions[TMLTD_EDIT] = new TAction("edit-tmlcd-diagram", "Edit TML Task diagram", IconManager.imgic100, IconManager.imgic101, "Edit TML task diagram", "Make it possible to edit the currently opened TML task diagram", 0);
+        actions[TMLTD_TASK] = new TAction("add-tmlcd-task", "Add a TML Task", IconManager.imgic806, IconManager.imgic806, "Add a TML task", "Add a TML task to the currently opened TML task diagram", 0);
+        actions[TMLTD_CHANNEL] = new TAction("add-tmlcd-channel", "Add a channel operator", IconManager.imgic802, IconManager.imgic802, "Add a channel operator", "Add a channel operator to the currently opened TML task diagram", 0);
+        actions[TMLTD_REQ] = new TAction("add-tmlcd-req", "Add a request operator", IconManager.imgic804, IconManager.imgic804, "Add a request operator", "Add a request operator to the currently opened TML task diagram", 0);
+        actions[TMLTD_EVENT] = new TAction("add-tmlcd-event", "Add an event operator", IconManager.imgic800, IconManager.imgic800, "Add an event operator", "Add an event operator to the currently opened TML task diagram", 0);
+        actions[TMLTD_ASSOC] = new TAction("add-tmlcd-assoc", "Add an association between two TML tasks", IconManager.imgic202, IconManager.imgic202, "Add an association between two TML tasks", "Add an association between two TML tasks to the currently opened TML task diagram", 0);
+        actions[TMLTD_CONNECTOR] = new TAction("add-tmlcd-connector", "Connect an operator to an association", IconManager.imgic108, IconManager.imgic108, "Connect an operator to an association", "Connect an operator to an asociation onto the currently opened TML task diagram", 0);
+
+        actions[TMLCTD_EDIT] = new TAction("edit-tmlccd-diagram", "Edit TML Component Task diagram", IconManager.imgic100, IconManager.imgic101, "Edit TML Component Task diagram", "Make it possible to edit the currently opened TML Component Task diagram", 0);
+        actions[TMLCTD_CCOMPONENT] = new TAction("add-tmlccd-ccomponent", "Add a composite component", IconManager.imgic1200, IconManager.imgic1200, "Add a composite component", "Add a composite component to the currently opened TML component Task diagram", 0);
+        actions[TMLCTD_CREMOTECOMPONENT] = new TAction("add-tmlcremotecd-ccomponent", "Add a reference to a composite component", IconManager.imgic1200, IconManager.imgic1200, "Add a reference to a composite component", "Add a reference to a composite component to the currently opened TML component Task diagram", 0);
+        actions[TMLCTD_PCOMPONENT] = new TAction("add-tmlccd-pcomponent", "Add a primitive component", IconManager.imgic1202, IconManager.imgic1202, "Add a primitive component", "Add a primitive component to the currently opened TML component Task diagram", 0);
+        actions[TMLCTD_CPORT] = new TAction("add-tmlccd-cport", "Add a composite port", IconManager.imgic1204, IconManager.imgic1204, "Add a composite port", "Add a composite port to the currently opened TML component Task diagram", 0);
+        actions[TMLCTD_COPORT] = new TAction("add-tmlccd-coport", "Add a primitive port", IconManager.imgic1206, IconManager.imgic1206, "Add a primitive port", "Add a primitive port to the currently opened TML component Task diagram", 0);
+        actions[TMLCTD_PORT_CONNECTOR] = new TAction("add-tmlccd-port-connector", "Add a connector between two ports", IconManager.imgic202, IconManager.imgic202, "Add a connector between two ports", "Add a connector between two ports of the currently opened TML component Task diagram", 0);
+        actions[TMLCTD_RCOMPONENT] = new TAction("add-tmlccd-rcomponent", "Add a record component", IconManager.imgic1202, IconManager.imgic1202, "Add a record component", "Add a record component to the currently opened TML component Task diagram", 0);
+        actions[TMLCTD_FORK] = new TAction("add-tmlccd-fork", "Add a channel fork", IconManager.imgic1210, IconManager.imgic1210, "Add a channel fork", "Add a fork channel port to the currently opened TML component Task diagram", 0);
+        actions[TMLCTD_JOIN] = new TAction("add-tmlccd-join", "Add a channel join", IconManager.imgic1212, IconManager.imgic1212, "Add a channel join", "Add a join channel port to the currently opened TML component Task diagram", 0);
+
+        actions[TMLAD_EDIT] = new TAction("edit-tmlad-diagram", "Edit TML Task activity diagram", IconManager.imgic100, IconManager.imgic101, "Edit TML task activity diagram", "Make it possible to edit the currently opened TML task activity diagram", 0);
+        actions[TMLAD_CONNECTOR] = new TAction("add-tmlad-connector", "Connect two operators together", IconManager.imgic202, IconManager.imgic202, "Connect two operators together", "Connect two operators of the currently opened TML task activity diagram", 0);
+        actions[TMLAD_ACTION_STATE] = new TAction("add-tmlad-action-state", "Add Action State", IconManager.imgic204, IconManager.imgic204, "Action state", "Add an action state (i.e. variable modification, operation call) to the currently opened TML activity diagram", 0);
+        actions[TMLAD_CHOICE] = new TAction("add-tmlad-choice", "Add Choice", IconManager.imgic208, IconManager.imgic208, "Choice", "Add a choice - non-deterministic or guarded - to the currently opened TML Task activity diagram", 0);
+        actions[TMLAD_START] = new TAction("add-tmladd-start", "Add Start state", IconManager.imgic222, IconManager.imgic222, "Start", "Add a start state to the currently opened TML activity diagram", 0);
+        actions[TMLAD_STOP] = new TAction("add-tmlad-stop", "Add Stop", IconManager.imgic210, IconManager.imgic210, "Stop", "Add a termination state to the currently opened TML task activity diagram", 0);
+        actions[TMLAD_JUNCTION] = new TAction("add-tmlad-junction", "Add Junction", IconManager.imgic212, IconManager.imgic212, "Junction", "Add a junction with three inputs to the currently opened TML task activity diagram", 0);
+        actions[TMLAD_EXECI] = new TAction("add-tmlad-execi", "EXECI", IconManager.imgic910, IconManager.imgic910, "EXECI", "Add an EXECI delay to the currently opened TML task activity diagram", 0);
+        actions[TMLAD_EXECI_INTERVAL] = new TAction("add-tmlad-execi-int", "EXECI (time interval)", IconManager.imgic914, IconManager.imgic914, "EXECI (time interval)", "Add an EXECI time interval to the currently opened TML task activity diagram", 0);
+        actions[TMLAD_EXECC] = new TAction("add-tmlad-execc", "EXECC", IconManager.imgic920, IconManager.imgic920, "EXECC", "Add an EXECC delay to the currently opened TML task activity diagram", 0);
+        actions[TMLAD_EXECC_INTERVAL] = new TAction("add-tmlad-execc-int", "EXECC (time interval)", IconManager.imgic922, IconManager.imgic922, "EXECC (time interval)", "Add an EXECC time interval to the currently opened TML task activity diagram", 0);
+        actions[TMLAD_DELAY] = new TAction("add-tmlad-delay", "DELAY[]", IconManager.imgic214, IconManager.imgic214, "DELAY[]", "Add a physical delay to the currently opened TML task activity diagram", 0);
+        actions[TMLAD_INTERVAL_DELAY] = new TAction("add-tmlad-interval-delay", "DELAY[,]", IconManager.imgic224, IconManager.imgic224, "DELAY[,]", "Add a physical interval delay to the currently opened TML task activity diagram", 0);
+        actions[TMLAD_WRITE_CHANNEL] = new TAction("add-tmladd-write-channel", "Write in channel", IconManager.imgic900, IconManager.imgic900, "Write in channel", "Add a write to channel operator opened TML activity diagram", 0);
+        actions[TMLAD_SEND_REQUEST] = new TAction("add-tmladd-send-request", "Send request", IconManager.imgic902, IconManager.imgic902, "Send request", "Add a send request operator to the currently opened TML activity diagram", 0);
+        actions[TMLAD_SEND_EVENT] = new TAction("add-tmladd-send-event", "Send event", IconManager.imgic904, IconManager.imgic904, "Send event", "Add a send event operator to the currently opened TML activity diagram", 0);
+        actions[TMLAD_WAIT_EVENT] = new TAction("add-tmladd-wait-event", "Wait event", IconManager.imgic908, IconManager.imgic908, "Wait event", "Add a wait event operator to the currently opened TML activity diagram", 0);
+        actions[TMLAD_NOTIFIED_EVENT] = new TAction("add-tmladd-notified-event", "Notified event", IconManager.imgic918, IconManager.imgic918, "Notified event", "Add a notified event operator to the currently opened TML activity diagram", 0);
+        actions[TMLAD_READ_CHANNEL] = new TAction("add-tmladd-read-channel", "Read in channel", IconManager.imgic906, IconManager.imgic906, "Read in channel", "Add a read to channel operator opened TML activity diagram", 0);
+        actions[TMLAD_FOR_LOOP] = new TAction("add-tmlad-for-loop", "Loop (for)", IconManager.imgic912, IconManager.imgic912, "Loop (for)", "Add a for loop to the currently opened TML activity diagram", 0);
+        actions[TMLAD_FOR_STATIC_LOOP] = new TAction("add-tmlad-for-static-loop", "Static loop (for)", IconManager.imgic912, IconManager.imgic912, "Static loop (for)", "Add a static for loop to the currently opened TML activity diagram", 0);
+        actions[TMLAD_FOR_EVER_LOOP] = new TAction("add-tmlad-for-ever-loop", "Loop for ever", IconManager.imgic926, IconManager.imgic926, "Loop for ever", "Add a loop-for-ever operator to the currently opened TML activity diagram", 0);
+        actions[TMLAD_SEQUENCE] = new TAction("add-tmlad-sequence", "Sequence", IconManager.imgic226, IconManager.imgic226, "Sequence", "Add a sequence to the currently opened TML activity diagram", 0);
+        actions[TMLAD_UNORDERED_SEQUENCE] = new TAction("add-tmlad-unordered-sequence", "Random sequence", IconManager.imgic928, IconManager.imgic928, "Random sequence", "Add a random sequence to the currently opened TML activity diagram", 0);
+        actions[TMLAD_SELECT_EVT] = new TAction("add-tmlad-select-evt", "Add select event", IconManager.imgic916, IconManager.imgic916, "Select event", "Add a selection between events to the currently opened TML Task activity diagram", 0);
+        actions[TMLAD_RANDOM] = new TAction("add-tmlad-random", "Add random", IconManager.imgic924, IconManager.imgic924, "Select random", "Add a random operator to the currently opened TML Task activity diagram", 0);
+        actions[TMLAD_READ_REQUEST_ARG] = new TAction("add-tmladd-read-request-arg", "Reading request arguments", IconManager.imgic930, IconManager.imgic930, "Reading request arguments", "Add a reading request argument operator to the currently opened TML activity diagram", 0);
+
+
+
+        actions[TMLAD_ENCRYPT] = new TAction("add-tmlad-encrypt", "Add Encryption", IconManager.imgic940, IconManager.imgic940, "Encryption", "Add an encryption operator to the currently opened TML Task activity diagram", 0);
+        actions[TMLAD_DECRYPT] = new TAction("add-tmlad-decrypt", "Add Decryption", IconManager.imgic941, IconManager.imgic941, "Decryption", "Add a decryption operator to the currently opened TML Task activity diagram", 0);
+
+
+        actions[EBRDD_EDIT] = new TAction("edit-ebrdd-diagram", "Edit EBRDD", IconManager.imgic100, IconManager.imgic101, "Edit EBRDD", "Make it possible to edit the currently opened Event-Based Requirement Description Diagram", 0);
+        actions[EBRDD_CONNECTOR] = new TAction("add-ebrdd-connector", "Connect two operators together", IconManager.imgic202, IconManager.imgic202, "Connect two operators together", "Connect two operators of the currently opened Event-Based Requirement Description Diagram", 0);
+        actions[EBRDD_START] = new TAction("add-ebrdd-start", "Add Start state", IconManager.imgic222, IconManager.imgic222, "Start", "Add a start state to the currently opened Event-Based Requirement Description Diagram", 0);
+        actions[EBRDD_STOP] = new TAction("add-ebrdd-stop", "Add Stop", IconManager.imgic210, IconManager.imgic210, "Stop", "Add a termination state to the currently opened  Event-Based Requirement Description Diagram", 0);
+        actions[EBRDD_CHOICE] = new TAction("add-ebrdd-choice", "Add Choice", IconManager.imgic208, IconManager.imgic208, "Choice", "Add a deterministic choice to the currently opened Event-Based Requirement Description Diagram", 0);
+        actions[EBRDD_ERC] = new TAction("add-ebrdd-erc", "Add ERC", IconManager.imgic1050, IconManager.imgic1050, "Event Reception Container", "Add an Event Reception Container to the currently opened Event-Based Requirement Description Diagram", 0);
+        actions[EBRDD_ACTION] = new TAction("add-ebrdd-action", "Add Action", IconManager.imgic204, IconManager.imgic204, "Action", "Add an Action to the currently opened Event-Based Requirement Description Diagram", 0);
+        actions[EBRDD_FOR_LOOP] = new TAction("add-ebrdd-for-loop", "Loop (for)", IconManager.imgic912, IconManager.imgic912, "Loop (for)", "Add a for loop to the currently opened Event-Based Requirement Description Diagram", 0);
+        actions[EBRDD_SEQUENCE] = new TAction("add-ebrdd-sequence", "Sequence", IconManager.imgic226, IconManager.imgic226, "Sequence", "Add a sequence to the currently opened Event-Based Requirement Description Diagram", 0);
+        actions[EBRDD_CONNECTOR_ERC] = new TAction("add-ebrdd-erc-connector", "Connect two ESO / ERB operators together", IconManager.imgic1052, IconManager.imgic1052, "Connect two ESO / ERB operators together", "Connect two ESO / ERB operators of the currently opened Event-Based Requirement Description Diagram", 0);
+        actions[EBRDD_ESO] = new TAction("add-ebrdd-eso", "Add ESO", IconManager.imgic1054, IconManager.imgic1054, "Event Sequencing Operator", "Add an Event Sequencing Operator to the currently opened Event-Based Requirement Description Diagram", 0);
+        actions[EBRDD_ERB] = new TAction("add-ebrdd-erb", "Add ERB", IconManager.imgic1056, IconManager.imgic1056, "Event Reaction Block", "Add an Event Reaction Block to the currently opened Event-Based Requirement Description Diagram", 0);
+        actions[EBRDD_VARIABLE_DECLARATION] = new TAction("add-ebrdd-var-dec", "Add Variable Declaration", IconManager.imgic1060, IconManager.imgic1060, "Add Variable Declaration", "Add a variable declaration block to the currently opened Event-Based Requirement Description Diagram", 0);
+
+        actions[TMLARCHI_EDIT] = new TAction("edit-tmlarchi-diagram", "Edit DIPLODOCUS architecture diagram", IconManager.imgic100, IconManager.imgic101, "Edit DIPLODOCUS architecture diagram", "Make it possible to edit the currently opened DIPLODOCUS architecture diagram", 0);
+        actions[TMLARCHI_LINK] = new TAction("add-tmlarchi-link", "Add a link", IconManager.imgic202, IconManager.imgic202, "Link", "Add a link between two nodes of the currently opened DIPLODOCUS architecture diagram", 0);
+        actions[TMLARCHI_CPUNODE] = new TAction("add-tmlarchi-cpunode", "Add a CPU node", IconManager.imgic1100, IconManager.imgic1100, "CPU node", "Add a cpu node to the currently opened DIPLODOCUS architecture diagram", 0);
+        actions[TMLARCHI_FPGANODE] = new TAction("add-tmlarchi-fpganode", "Add a FPGA node", IconManager.imgic1120, IconManager.imgic1120, "FPGA node", "Add a fpga node to the currently opened DIPLODOCUS architecture diagram", 0);
+        actions[TMLARCHI_BUSNODE] = new TAction("add-tmlarchi-busnode", "Add a Bus node", IconManager.imgic1102, IconManager.imgic1102, "Bus node", "Add a bus node to the currently opened DIPLODOCUS architecture diagram", 0);
+        actions[TMLARCHI_CPNODE] = new TAction("add-tmlarchi-cpnode", "Add a Communication pattern node", IconManager.imgic1102, IconManager.imgic1102, "CP node", "Add a communication pattern node to the currently opened DIPLODOCUS architecture diagram", 0);
+        actions[TMLARCHI_ARTIFACT] = new TAction("add-tmlarchi-artifact", "Map a task", IconManager.imgic702, IconManager.imgic702, "Map a task", "Map a task onto a node in the currently opened DIPLODOCUS architecture diagram", 0);
+        actions[TMLARCHI_COMMUNICATION_ARTIFACT] = new TAction("add-tmlarchi-communication-artifact", "Map a channel", IconManager.imgic702, IconManager.imgic702, "Map a channel", "Map a channel onto a node in the currently opened DIPLODOCUS architecture diagram", 0);
+        actions[TMLARCHI_PORT_ARTIFACT] = new TAction("add-tmlarchi-port-artifact", "Map a port", IconManager.imgic702, IconManager.imgic702, "Map a port", "Map a port onto a node in the currently opened DIPLODOCUS architecture diagram", 0);
+        actions[TMLARCHI_EVENT_ARTIFACT] = new TAction("add-tmlarchi-event-artifact", "Map an event / request", IconManager.imgic702, IconManager.imgic702, "Map an event/request", "Map an event or a request onto a node in the currently opened DIPLODOCUS architecture diagram", 0);
+        actions[TMLARCHI_BRIDGENODE] = new TAction("add-tmlarchi-bridgenode", "Add a Bridge node", IconManager.imgic1104, IconManager.imgic1104, "Bridge node", "Add a bridge node to the currently opened DIPLODOCUS architecture diagram", 0);
+        actions[TMLARCHI_HWANODE] = new TAction("add-tmlarchi-hwanode", "Add a hardware accelerator node", IconManager.imgic1106, IconManager.imgic1106, "Hardware accelerator node", "Add a hardware accelerator node to the currently opened DIPLODOCUS architecture diagram", 0);
+        actions[TMLARCHI_CAMSNODE] = new TAction("add-tmlarchi-camsnode", "Add a System C-AMS node", IconManager.imgic1106, IconManager.imgic1106, "System C-AMS node", "Add a System C-AMS node to the currently open DIPLODOCUS architecture diagram", 0);
+        actions[TMLARCHI_MEMORYNODE] = new TAction("add-tmlarchi-memorynode", "Add a memory node", IconManager.imgic1108, IconManager.imgic1108, "Memory node", "Add a memory node to the currently opened DIPLODOCUS architecture diagram", 0);
+        actions[TMLARCHI_DMANODE] = new TAction("add-tmlarchi-dmanode", "Add a DMA node", IconManager.imgic1110, IconManager.imgic1110, "DMA node", "Add a DMA node to the currently opened DIPLODOCUS architecture diagram", 0);
+        actions[TMLARCHI_KEY] = new TAction("add-tmlarchi-key", "Map a key", IconManager.imgic1118, IconManager.imgic1118, "Map a key", "Map a key onto a node in the currently opened DIPLODOCUS architecture diagram", 0);
+        actions[TMLARCHI_FIREWALL] = new TAction("add-tmlarchi-firewall", "Add a Firewall", IconManager.imgic7001, IconManager.imgic7001, "Add a Firewall", "Add a Firewall in the currently opened DIPLODOCUS architecture diagram",0);
+
+        actions[TMLCP_EDIT] = new TAction("edit-tmlcp-diagram", "Edit communication pattern diagram", IconManager.imgic100, IconManager.imgic101, "Edit communication pattern diagram", "Make it possible to edit the currently opened communication pattern diagram", 0);
+        actions[TMLCP_CONNECTOR] = new TAction("add-tmlcp-connector", "Add CP Connector", IconManager.imgic202, IconManager.imgic202, "Connector", "Add a Connector between two components of the currently opened communication pattern diagram", 0);
+        actions[TMLCP_REF_SD] = new TAction("add-ref-sd-tmlcp", "Add reference to a SD", IconManager.imgic400, IconManager.imgic400, "Reference to a SD", "Add a reference to a sequence diagram in the the currently opened communication pattern diagram", 0);
+        actions[TMLCP_REF_CP] = new TAction("add-ref-cp-tmlcp", "Add reference to a CP", IconManager.imgic400, IconManager.imgic400, "Reference to an AD", "Add a reference to a communication pattern diagram in the currently opened communication pattern diagram", 0);
+        actions[TMLCP_FORK] = new TAction("add-tmlcp-fork", "Add fork", IconManager.imgic206, IconManager.imgic206, "Fork", "Add a fork to the currently opened communication pattern diagram", 0);
+        actions[TMLCP_JOIN] = new TAction("add-tmlcp-join", "Add join", IconManager.imgic206, IconManager.imgic206, "Join", "Add a join to the currently opened communication pattern diagram", 0);
+        actions[TMLCP_CHOICE] = new TAction("add-tmlcp-choice", "Add Choice", IconManager.imgic208, IconManager.imgic208, "Choice", "Add a choice - non-deterministic or guarded - to the currently opened communication pattern diagram", 0);
+        actions[TMLCP_START] = new TAction("add-tmlcp-start", "Add Start state", IconManager.imgic222, IconManager.imgic222, "Start", "Add a start state to the currently opened communication pattern diagram", 0);
+        actions[TMLCP_STOP] = new TAction("add-tmlcp-stop", "Add Stop", IconManager.imgic210, IconManager.imgic210, "Stop", "Add a termination state to the currently opened communication pattern diagram", 0);
+        actions[TMLCP_JUNCTION] = new TAction("add-tmlcp-junction", "Add Junction", IconManager.imgic212, IconManager.imgic212, "Junction", "Add a junction with three inputs to the currently opened communication pattern diagram", 0);
+        actions[TMLCP_FOR_LOOP] = new TAction("add-tmlcp-forloop", "Add loop", IconManager.imgic912, IconManager.imgic912, "Loop", "Add a for loop to the currently opened communication pattern diagram", 0);
+
+        actions[TMLSD_EDIT] = new TAction("edit-tmlsd-diagram", "Edit CP-SD diagram", IconManager.imgic100, IconManager.imgic101, "Edit the Sequence Diagram", "Make it possible to edit the currently opened communication pattern sequence diagram", 0);
+        actions[TMLSD_MESSAGE_ASYNC] = new TAction("add-tmlsd-messageasync", "Add async msg", IconManager.imgic202, IconManager.imgic202, "Asynchronous message", "Add an asynchronous message between two components of the currently opened communication pattern sequence diagram", 0);
+        actions[TMLSD_STORAGE_INSTANCE] = new TAction("add-storage-instance-tmlsd", "Storage instance", IconManager.imgic500, IconManager.imgic500, "Storage instance", "Add a storage instance to the currently opened communication pattern sequence diagram", 0);
+        actions[TMLSD_TRANSFER_INSTANCE] = new TAction("add-transfer-instance-tmlsd", "Transfer instance", IconManager.imgic500, IconManager.imgic500, "Transfer instance", "Add a transfer instance to the currently opened communication pattern sequence diagram", 0);
+        actions[TMLSD_CONTROLLER_INSTANCE] = new TAction("add-controller-instance-tmlsd", "Controller instance", IconManager.imgic500, IconManager.imgic500, "Controller instance", "Add a controller instance to the currently opened communication pattern sequence diagram", 0);
+        actions[TMLSD_ACTION_STATE] = new TAction("add-action-tmlsd", "Action state", IconManager.imgic512, IconManager.imgic512, "Action state", "Add an action state to the currently opened communication pattern sequence diagram", 0);
+
+        //System C-AMS
+        actions[CAMS_EDIT] = new TAction("add-action-C-AMS", "Action state", IconManager.imgic100, IconManager.imgic101, "Action state", "Add an action state to the currently opened SystemC-AMS diagram", 0);
+        actions[CAMS_BLOCK_TDF] = new TAction("C-AMS-block-TDF", "Add a TDF block", IconManager.imgic5000, IconManager.imgic5000, "TDF block", "Add a TDF block to the currently opened SystemC-AMS Diagram", 0);
+        actions[CAMS_BLOCK_DE] = new TAction("C-AMS-block-DE", "Add a DE block", IconManager.imgic5000, IconManager.imgic5000, "DE block", "Add a DE block to the currently opened SystemC-AMS Diagram", 0);
+        actions[CAMS_CONNECTOR] = new TAction("C-AMS-connector", "Add a connection", IconManager.imgic202, IconManager.imgic202, "Connector", "Connects two block of the currently opened SystemC-AMS Diagram", 0);
+        actions[CAMS_PORT_TDF] = new TAction("C-AMS-port-TDF", "Add a TDF port", IconManager.imgic8000, IconManager.imgic8000, "TDF port", "Add a TDF port to the currently opened SystemC-AMS Diagram", 0);
+        actions[CAMS_PORT_DE] = new TAction("C-AMS-port-DE", "Add a DE port", IconManager.imgic8001, IconManager.imgic8001, "DE port", "Add a DE port to the currently opened SystemC-AMS Diagram", 0);
+        actions[CAMS_PORT_CONVERTER] = new TAction("C-AMS-port-converter", "Add a converter port", IconManager.imgic8003, IconManager.imgic8003, "Converter port", "Add a converter port to the currently opened SystemC-AMS Diagram", 0);
+        actions[CAMS_CLUSTER] = new TAction("C-AMS-cluster", "Add a cluster", IconManager.imgic5000, IconManager.imgic5000, "Cluster", "Add a cluster to the currently opened SystemC-AMS Diagram", 0);
+
+
+        //ProActive State Machine Diagram
+        actions[PROSMD_EDIT] = new TAction("edit-prosmd-diagram", "Edit ProActive state machine diagram", IconManager.imgic100, IconManager.imgic101, "Edit ProActive state machine diagram", "Make it possible to edit the currently opened ProActive state machine diagram", 0);
+        actions[PROSMD_START] = new TAction("add-prosmd-start", "Add Start state", IconManager.imgic222, IconManager.imgic222, "Start", "Add a start state to the currently opened ProActive state machine diagram", 0);
+        actions[PROSMD_STOP] = new TAction("add-prosmd-stop", "Add Stop", IconManager.imgic210, IconManager.imgic210, "Stop", "Add a termination state to the currently opened ProActive state machine diagram", 0);
+        actions[PROSMD_CONNECTOR] = new TAction("add-prosmd-connector", "Connect two operators together", IconManager.imgic202, IconManager.imgic202, "Connect two operators together", "Connect two operators of the currently opened ProActive state machine diagram", 0);
+        actions[PROSMD_SENDMSG] = new TAction("add-prosmd-sendmsg", "Send msg", IconManager.imgic2000, IconManager.imgic2000, "Send msg", "Add a send message to the currently opened ProActive state machine diagram", 0);
+        actions[PROSMD_GETMSG] = new TAction("add-prosmd-getmsg", "Get msg", IconManager.imgic2002, IconManager.imgic2002, "Get msg", "Add a get message to the currently opened ProActive state machine diagram", 0);
+        actions[PROSMD_CHOICE] = new TAction("add-prosmd-choice", "Choice", IconManager.imgic2004,IconManager.imgic2004,"Choice operator","Add a choice operator to the currently opened ProActive state machine diagram",0);
+        actions[PROSMD_JUNCTION] = new TAction("add-prosmd-junction", "Junction", IconManager.imgic2006,IconManager.imgic2006,"Junction operator","Add a junction operator to the currently opened ProActive state machine diagram",0);
+        actions[PROSMD_SUBMACHINE] = new TAction("add-prosmd-submachine", "Submachine", IconManager.imgic2008,IconManager.imgic2008,"Submachine","Add a submachine to the currently opened ProActive state machine diagram",0);
+        actions[PROSMD_ACTION] = new TAction("add-prosmd-action", "Action", IconManager.imgic2010,IconManager.imgic2010,"Action","Add an action to the currently opened ProActive state machine diagram",0);
+        actions[PROSMD_PARALLEL] = new TAction("add-prosmd-nondeterministic-choice", "Nondeterministic choice operator", IconManager.imgic206,IconManager.imgic206,"Parallel operator","Add a parallel operator to the currently opened ProActive state machine diagram",0);
+        actions[PROSMD_STATE] = new TAction("add-prosmd-state", "State ", IconManager.imgic2012,IconManager.imgic2012,"State ","Add state to the currently opened ProActive state machine diagram",0);
+
+        //ProcActive Composite Structure Diagram
+        actions[PROCSD_EDIT] = new TAction("edit-procsd-diagram", "Edit ProActive composite stucture diagram", IconManager.imgic100, IconManager.imgic101, "Edit ProActive composite structure diagram", "Make it possible to edit the currently opened ProActive composite structure diagram", 0);
+        actions[PROCSD_COMPONENT] = new TAction("add-procsd-component", "Add component", IconManager.imgic2100, IconManager.imgic2100, "Add component", "Add a component to the currently opened ProActive composite structure diagram", 0);
+        //Delegate port action removed, by Solange
+        //actions[PROCSD_DELEGATE_PORT] = new TAction("add-procsd-delegate-port", "Add a delegate port", IconManager.imgic2102, IconManager.imgic2102, "Add a delegate port", "Add a delegate port to a component", 0);
+        actions[PROCSD_CONNECTOR] = new TAction("add-procsd-connector", "Connect two ports together", IconManager.imgic2110, IconManager.imgic2110, "Connect two ports together", "An interface coresponds to this conector", 0);
+        actions[PROCSD_CONNECTOR_DELEGATE] = new TAction("add-procsd-connector-delegate", "Delegates the message", IconManager.imgic202, IconManager.imgic202, "Delegates the message ", "It transmits the message between the border and an inside component of a composite.", 0);
+        actions[PROCSD_INTERFCE] = new TAction("add-procsd-interface", "Add an interface", IconManager.imgic2104, IconManager.imgic2104,"Add an interface", "an interface describes the messages wich pass through a connection", 0);
+        actions[PROCSD_IN_PORT] = new TAction("add-procsd-in-port", "Add in port", IconManager.imgic2106, IconManager.imgic2106, "Add in port", "Add an in port to a component. An in port coresponds to a offered/server interface", 0);
+        actions[PROCSD_OUT_PORT] = new TAction("add-procsd-out-port", "Add out port", IconManager.imgic2108, IconManager.imgic2108, "Add out port", "Add an out port to a component. An out port coresponds to an requiered/client  interface", 0);
+        actions[PROCSD_CONNECTOR_PORT_INTERFACE] = new TAction("add-port-to-interface-connector", "Connect a port to an interface definition", IconManager.imgic108, IconManager.imgic108, "Connects a port to an interface definition", "Port to interface connector", 0);
+
+        actions[ACT_TOGGLE_CHANNELS] = new TAction("toggle-ch-command", "Show / hide Channels",IconManager.imgic808, IconManager.imgic808, "Show / hide channels", "Show / hide channels", '0');
+        actions[ACT_TOGGLE_EVENTS] = new TAction("toggle-evt-command", "Show / hide Events",IconManager.imgic810, IconManager.imgic810, "Show / hide events", "Show / hide events", '0');
+        actions[ACT_TOGGLE_REQUESTS] = new TAction("toggle-req-command", "Show / hide Synchronization Requests",IconManager.imgic812, IconManager.imgic812, "Show / hide requests", "Show / hide requests", '0');
+
+        // Requirement diagrams
+        actions[TREQ_REQUIREMENT] = new TAction("add-treq-requirement", "Add a requirement", IconManager.imgic1002, IconManager.imgic1002, "Requirement", "Add a requirement to the currently opened requirement diagram", 0);
+        actions[TREQ_OBSERVER] = new TAction("add-treq-observer", "Add an observer", IconManager.imgic1004, IconManager.imgic1004, "Observer", "Add an observer to the currently opened requirement diagram", 0);
+        actions[TREQ_EBRDD] = new TAction("add-treq-ebrdd", "Add a reference to an EBRDD", IconManager.imgic1014, IconManager.imgic1014, "EBRDD", "Add an EBRDD-based observer to the currently opened requirement diagram", 0);
+        actions[TREQ_DERIVE] = new TAction("add-treq-derive", "Add a <<deriveReqt>> link", IconManager.imgic1008, IconManager.imgic1008, "DeriveReqt", "Add a <<deriveReqt>> link between two requirements of the currently opened requirement diagram", 0);
+        actions[TREQ_VERIFY] = new TAction("add-treq-verify", "Add a <<verify>> link", IconManager.imgic1006, IconManager.imgic1006, "Verify", "Add a <<verify>> link between an observer and a requirement of the currently opened requirement diagram", 0);
+        actions[TREQ_COPY] = new TAction("add-treq-copy", "Add a <<copy>> link", IconManager.imgic1010, IconManager.imgic1010, "Copy", "Add a <<copy>> link between two requirements of the currently opened requirement diagram", 0);
+        actions[TREQ_COMPOSITION] = new TAction("add-treq-composition", "Add a <<derive>> link", IconManager.imgic1012, IconManager.imgic1012, "Composition", "Add a <<copy>> link between two requirements of the currently opened requirement diagram", 0);
+
+
+        // Attack Tree Diagrams
+        actions[ATD_BLOCK] = new TAction("atd-block", "Add a block", IconManager.imgic1070, IconManager.imgic1070, "Block", "Add a SysML Block to the currently opened attack tree diagram", 0);
+        actions[ATD_ATTACK] = new TAction("atd-attack", "Add an attack", IconManager.imgic1072, IconManager.imgic1072, "Attack", "Add an attack (i.e. a SysML value type) to the currently opened attack tree diagram", 0);
+        actions[ATD_ATTACK_CONNECTOR] = new TAction("atd-attack-connector", "Add a connector between attacks /constraints", IconManager.imgic1080, IconManager.imgic1080, "Connector", "Add a connector between attacks / constraints of the currently opened attack tree diagram", 0);
+        actions[ATD_COMPOSITION_CONNECTOR] = new TAction("atd-composition-connector", "Add a composition connector between blocks", IconManager.imgic1076, IconManager.imgic1076, "Composition connector", "Add a composition between blocks of the currently opened attack tree diagram", 0);
+        actions[ATD_CONSTRAINT] = new TAction("atd-constraint", "Add a constraint", IconManager.imgic1078, IconManager.imgic1078, "Constraint", "Add a constraint to the currently opened attack tree diagram", 0);
+        actions[ATD_COUNTERMEASURE] = new TAction("atd-countermeasure", "Add a countermeasure", IconManager.imgic1082, IconManager.imgic1082, "Countermeasure", "Add a countermeasure to the currently opened attack tree diagram", 0);
+        actions[ATD_COUNTERMEASURE_CONNECTOR] = new TAction("atd-countermeasure-connector", "Add a connector between attacks / countermeasures", IconManager.imgic1084, IconManager.imgic1084, "Connect countermeasure", "Add a connector between attacks / countermeasures of the currently opened attack tree diagram", 0);
+
+	// Fault Tree Diagrams
+        actions[FTD_BLOCK] = new TAction("ftd-block", "Add a block", IconManager.imgic1070, IconManager.imgic1070, "Block", "Add a SysML Block to the currently opened fault tree diagram", 0);
+        actions[FTD_FAULT] = new TAction("ftd-fault", "Add a fault", IconManager.imgic1416, IconManager.imgic1416, "Fault", "Add a fault (i.e. a SysML value type) to the currently opened fault tree diagram", 0);
+        actions[FTD_FAULT_CONNECTOR] = new TAction("ftd-fault-connector", "Add a connector between faults /constraints", IconManager.imgic1080, IconManager.imgic1080, "Connector", "Add a connector between faults / constraints of the currently opened fault tree diagram", 0);
+        actions[FTD_COMPOSITION_CONNECTOR] = new TAction("ftd-composition-connector", "Add a composition connector between blocks", IconManager.imgic1076, IconManager.imgic1076, "Composition connector", "Add a composition between blocks of the currently opened fault tree diagram", 0);
+        actions[FTD_CONSTRAINT] = new TAction("ftd-constraint", "Add a constraint", IconManager.imgic1078, IconManager.imgic1078, "Constraint", "Add a constraint to the currently opened fault tree diagram", 0);
+        actions[FTD_COUNTERMEASURE] = new TAction("ftd-countermeasure", "Add a countermeasure", IconManager.imgic1082, IconManager.imgic1082, "Countermeasure", "Add a countermeasure to the currently opened fault tree diagram", 0);
+        actions[FTD_COUNTERMEASURE_CONNECTOR] = new TAction("ftd-countermeasure-connector", "Add a connector between faults / countermeasures", IconManager.imgic1084, IconManager.imgic1084, "Connect countermeasures", "Add a connector between faults / countermeasures of the currently opened fault tree diagram", 0);
+
+        // TURTLE-OS
+        actions[TOS_TCLASS] = new TAction("add-tclass-os", "Add Tclass", IconManager.imgic104, IconManager.imgic104, "Tclass", "Add a TClass to the currently opened class diagram", 0);
+        actions[TOS_ASSOCIATION] = new TAction("add-association-tos", "Add association", IconManager.imgic102, IconManager.imgic102, "Association", "Add an association between two tclasses of the currently opened TURTLE-OS class diagram", 0);
+        actions[TOS_ASSOCIATION_NAVIGATION] = new TAction("add-association-nav-tos", "Add association with navigation", IconManager.imgic106, IconManager.imgic106, "Association with navigation", "Add an association with navigation between two tclasses of the currently opened TURTLE-OS class diagram", 0);
+        actions[TOS_CONNECTOR_ATTRIBUTE] = new TAction("add-attribute-connector-tos", "Connects an association to a composition operator", IconManager.imgic108, IconManager.imgic108, "Attributes an association with a composition operator", "Adds a connector between an association and a composition operator to the currently opened TURTLE-OS class diagram", 0);
+        actions[TOS_CALL_OPERATOR] = new TAction("add-call-operator", "Add Call composition operator", IconManager.imgic126, IconManager.imgic126, "Call composition operator", "Adds a call composition operator to the currently opened TURTLE-OS class diagram", 0);
+        actions[TOS_EVT_OPERATOR] = new TAction("add-evt-operator", "Add Evt composition operator", IconManager.imgic126, IconManager.imgic126, "Evt composition operator", "Adds an evt composition operator to the currently opened TURTLE-OS class diagram", 0);
+        actions[TOSAD_ACTION_STATE] = new TAction("add-action-state-osad", "Add Action State", IconManager.imgic204, IconManager.imgic204, "Action state", "Add an action state (i.e. synchronization on gate, variable modification, call on protected object) to the currently opened TURTLE-OS activity diagram", 0);
+        actions[TOSAD_CONNECTOR] = new TAction("add-tosad-connector", "Connect two operators together", IconManager.imgic202, IconManager.imgic202, "Connect two operators together", "Connect two operators of the currently opened TURTLE-OS activity diagram", 0);
+        actions[TOSAD_CHOICE] = new TAction("add-tosad-choice", "Add Choice", IconManager.imgic208, IconManager.imgic208, "Choice", "Add a choice - non-deterministic or guarded - to the currently opened TURTLE-OS activity diagram", 0);
+        actions[TOSAD_START_STATE] = new TAction("add-tosad-start", "Add Start state", IconManager.imgic222, IconManager.imgic222, "Start", "Add a start state to the currently opened TURTLKE-OS activity diagram", 0);
+        actions[TOSAD_STOP_STATE] = new TAction("add-tosad-stop", "Add Stop", IconManager.imgic210, IconManager.imgic210, "Stop", "Add a termination state to the currently opened TURTLE-OS activity diagram", 0);
+        actions[TOSAD_JUNCTION] = new TAction("add-tosad-junction", "Add Junction", IconManager.imgic212, IconManager.imgic212, "Junction", "Add a junction with three inputs to the currently opened TURTLE-OS activity diagram", 0);
+        actions[TOSAD_TIME_INTERVAL] = new TAction("add-tosad-time-interval", "Add Time Interval", IconManager.imgic224, IconManager.imgic224, "Time interval", "Add a time interval to the currently opened TURTLE-OS activity diagram", 0);
+        actions[TOSAD_INT_TIME_INTERVAL] = new TAction("add-tosad-int-time-interval", "Add Interruptible Time Interval", IconManager.imgic224, IconManager.imgic224, "Interruptible time interval", "Add an interruptible time interval to the currently opened TURTLE-OS activity diagram", 0);
+
+        actions[EXTERNAL_ACTION_1] = new TAction("user-command-1", "User command 1", IconManager.imgic338, IconManager.imgic338, "User command 1", "Execute the user command #1", '0');
+        actions[EXTERNAL_ACTION_2] = new TAction("user-command-2", "User command 2", IconManager.imgic338, IconManager.imgic338, "User command 2", "Execute the user command #2", '0');
+
+        // AVATAR Block Diagrams
+        actions[ABD_BLOCK] = new TAction("abd-block", "Add a block", IconManager.imgic5000, IconManager.imgic5000, "Block", "Add a SysML Block to the currently opened AVATAR Block Diagram", 0);
+        actions[ABD_CRYPTOBLOCK] = new TAction("abd-cryptoblock", "Add a crypto block", IconManager.imgic5000, IconManager.imgic5000, "Crypto block", "Add a SysML Crypto Block to the currently opened AVATAR Block Diagram", 0);
+        actions[ABD_DATATYPE] = new TAction("abd-datatype", "Add a data type", IconManager.imgic5034, IconManager.imgic5034, "Data type", "Add a SysML Block representing a Data Type to the currently opened AVATAR Block Diagram", 0);
+        actions[ABD_COMPOSITION_CONNECTOR] = new TAction("abd-composition-connector", "Add a composition connector between blocks", IconManager.imgic5002, IconManager.imgic5002, "Composition connector", "Add a composition between blocks of the currently opened AVATAR Block Diagram", 0);
+        actions[ABD_PORT_CONNECTOR] = new TAction("abd-port-connector", "Add a composition connector between blocks", IconManager.imgic5004, IconManager.imgic5004, "Port connector", "Add a port link between blocks of the currently opened AVATAR Block Diagram", 0);
+        actions[ABD_LIBRARYFUNCTION] = new TAction("abd-libraryfunction", "Add a library function", IconManager.imgic5070, IconManager.imgic5000, "Library Function", "Add a Library Function to the currently opened AVATAR Block Diagram", 0);
+        actions[ABD_CRYPTOLIBRARYFUNCTION] = new TAction("abd-cryptolibraryfunction", "Add a crypto library function", IconManager.imgic5070, IconManager.imgic5000, "Crypto library function", "Add a Crypto Library Function to the currently opened AVATAR Block Diagram", 0);
+
+        // AVATAR State Machine Diagrams
+        actions[ASMD_EDIT] = new TAction("edit-asmd-diagram", "Edit AVATAR state machine diagram", IconManager.imgic100, IconManager.imgic101, "Edit AVATAR state machine diagram", "Make it possible to edit the currently opened AVATAR state machine diagram", 0);
+        actions[ASMD_CONNECTOR] = new TAction("add-asmd-connector", "Connect two operators together", IconManager.imgic202, IconManager.imgic202, "Connect two operators together", "Connect two operators of the currently opened AVATAR state machine diagram", 0);
+        actions[ASMD_START] = new TAction("add-asmd-start", "Add Start state", IconManager.imgic222, IconManager.imgic222, "Start", "Add a start state to the currently opened AVATAR state machine diagram", 0);
+        actions[ASMD_STOP] = new TAction("add-asmd-stop", "Add Stop", IconManager.imgic210, IconManager.imgic210, "Stop", "Add a termination state to the currently opened AVATAR state machine diagram", 0);
+        actions[ASMD_SEND_SIGNAL] = new TAction("add-asmd-sendsignal", "Send signal", IconManager.imgic2014, IconManager.imgic2014, "Send signal", "Add a send signal operator to the currently opened AVATAR state machine diagram", 0);
+        actions[ASMD_RECEIVE_SIGNAL] = new TAction("add-asmd-receivesignal", "Receive signal", IconManager.imgic2016, IconManager.imgic2016, "Receive signal", "Add a receive signal operator to the currently opened AVATAR state machine diagram", 0);
+        // TODO: change icon
+        actions[ASMD_LIBRARY_FUNCTION_CALL] = new TAction("add-asmd-libraryfunctioncall", "Library function call", IconManager.imgic2018, IconManager.imgic2018, "Library function call", "Add a library function call to the currently opened AVATAR state machine diagram", 0);
+        actions[ASMD_PARALLEL] = new TAction("add-asmd-parallel", "Parallel", IconManager.imgic206, IconManager.imgic206, "Parallel", "Add a parallel operator to the currently opened AVATAR state machine diagram", 0);
+        actions[ASMD_STATE] = new TAction("add-asmd-state", "State", IconManager.imgic5036, IconManager.imgic5036, "State", "Add a new state to the currently opened AVATAR state machine diagram", 0);
+        actions[ASMD_CHOICE] = new TAction("add-asmd-choice", "Add Choice", IconManager.imgic208, IconManager.imgic208, "Choice", "Add a choice - non-deterministic or guarded - to the currently opened AVATAR state machine diagram", 0);
+        actions[ASMD_RANDOM] = new TAction("add-asmd-random", "Add random", IconManager.imgic924, IconManager.imgic924, "Select random", "Add a random operator to the currently opened AVATAR State Machine diagram", 0);
+        actions[ASMD_SET_TIMER] = new TAction("add-asmd-setrimer", "Set timer", IconManager.imgic5038, IconManager.imgic5038, "Set timer", "Add a set timer operator to the currently opened AVATAR State Machine diagram", 0);
+        actions[ASMD_RESET_TIMER] = new TAction("add-asmd-resettimer", "Reset timer", IconManager.imgic5040, IconManager.imgic5040, "Reset timer", "Add a reset timer operator to the currently opened AVATAR State Machine diagram", 0);
+        actions[ASMD_EXPIRE_TIMER] = new TAction("add-asmd-expiretimer", "Timer expiration", IconManager.imgic5042, IconManager.imgic5042, "Wait for timer expiration", "Add a timer expiration operator to the currently opened AVATAR State Machine diagram", 0);
+
+
+        // AVATAR Modeling Assumptions Diagram
+        actions[AMAD_EDIT] = new TAction("edit-amad-diagram", "Edit AVATAR Modeling Assumptions Diagram", IconManager.imgic100, IconManager.imgic101, "Edit AVATAR Modeling Assumptions Diagram", "Make it possible to edit the currently opened AVATAR Modeling Assumption diagram", 0);
+        actions[AMAD_ASSUMPTION] = new TAction("add-amad-assumption", "Add an assumption", IconManager.imgic5060, IconManager.imgic5060, "Assumption", "Add an assumption to the currently opened avatar Modeling Assumptions Diagram", 0);
+        actions[AMAD_DIAGRAM_REFERENCE] = new TAction("add-amad-diagram-reference", "Add a diagram reference", IconManager.imgic5058, IconManager.imgic5058, "Diagram reference", "Add a diagram reference to the currently opened avatar Modeling Assumptions Diagram", 0);
+        actions[AMAD_ELEMENT_REFERENCE] = new TAction("add-amad-element-reference", "Add a reference to an modeling element", IconManager.imgic5062, IconManager.imgic5062, "Element reference", "Add a reference to an model element in the currently opened avatar Modeling Assumptions Diagram", 0);
+        actions[AMAD_COMPOSITION_CONNECTOR] = new TAction("add-amad-composition", "Add a composite link", IconManager.imgic1012, IconManager.imgic1012, "Composite", "Add a composite link between two assumptions of the currently opened avatar Modeling Assumptions diagram", 0);
+        actions[AMAD_VERSIONING_CONNECTOR] = new TAction("add-amad-versioning", "Add a versioning link", IconManager.imgic5064, IconManager.imgic5064, "Versioning", "Add a versioning link between two assumptions of the currently opened avatar Modeling Assumptions diagram", 0);
+        actions[AMAD_IMPACT_CONNECTOR] = new TAction("add-amad-impact", "Add an impact link", IconManager.imgic5066, IconManager.imgic5066, "Impact", "Add an impact link between two references to model elements, in the currently opened avatar Modeling Assumptions diagram", 0);
+        actions[AMAD_MEET_CONNECTOR] = new TAction("add-amad-meet", "Add an meet link", IconManager.imgic5066, IconManager.imgic5066, "Meet", "Add an meet link between a model element and an assumption in the currently opened Avatar Modeling Assumptions diagram", 0);
+        actions[AMAD_BELONGSTOCOMPOSITION_CONNECTOR] = new TAction("amad-belongstocomposition-connector", "Add a composition connector between references", IconManager.imgic5002, IconManager.imgic5002, "Composition connector", "Add a composition between blocks of the currently opened Avatar Modeling Assumptions diagram", 0);
+
+        // AVATAR Requirement Diagrams
+        actions[ARD_EDIT] = new TAction("edit-ard-diagram", "Edit Requirement Diagram", IconManager.imgic100, IconManager.imgic101, "Edit Requirement Diagram", "Make it possible to edit the currently opened Requirement Diagram", 0);
+        actions[ARD_REQUIREMENT] = new TAction("add-ard-requirement", "Add a requirement", IconManager.imgic5006, IconManager.imgic5006, "Requirement", "Add a requirement to the currently opened requirement diagram", 0);
+        actions[ARD_PROPERTY] = new TAction("add-ard-property", "Add a property", IconManager.imgic5008, IconManager.imgic5008, "Property", "Add a reference to a property of the currently opened requirement diagram", 0);
+        actions[ARD_ELEMENT_REFERENCE] = new TAction("add-ard-element-reference", "Add a reference to an element", IconManager.imgic5068, IconManager.imgic5068, "Element Reference", "Add a reference to an element of the currently opened requirement diagram", 0);
+        actions[ARD_DERIVE_CONNECTOR] = new TAction("add-ard-derive", "Add a <<deriveReqt>> link", IconManager.imgic1008, IconManager.imgic1008, "DeriveReqt", "Add a <<deriveReqt>> link between two requirements of the currently opened requirement diagram", 0);
+        actions[ARD_SATISFY_CONNECTOR] = new TAction("add-ard-satisfy", "Add a <<satisfy>> link", IconManager.imgic1018, IconManager.imgic1018, "Satisfy", "Add a <<satisfy>> link between two requirements of the currently opened requirement diagram", 0);
+
+        actions[ARD_REFINE_CONNECTOR] = new TAction("add-ard-refine", "Add a <<refine>> link", IconManager.imgic1016, IconManager.imgic1016, "refine", "Add a <<refine>> link between two requirements of the currently opened requirement diagram", 0);
+        actions[ARD_VERIFY_CONNECTOR] = new TAction("add-ard-verify", "Add a <<verify>> link", IconManager.imgic1006, IconManager.imgic1006, "Verify", "Add a <<verify>> link between an observer and a requirement of the currently opened requirement diagram", 0);
+        actions[ARD_COPY_CONNECTOR] = new TAction("add-ard-copy", "Add a <<copy>> link", IconManager.imgic1010, IconManager.imgic1010, "Copy", "Add a <<copy>> link between two requirements of the currently opened requirement diagram", 0);
+        actions[ARD_COMPOSITION_CONNECTOR] = new TAction("add-ard-composition", "Add a  composition link", IconManager.imgic1012, IconManager.imgic1012, "Composition", "Add a composition link between two requirements of the currently opened requirement diagram", 0);
+
+        // AVATAR Parametric Diagrams
+        actions[APD_EDIT] = new TAction("edit-apd-diagram", "Edit AVATAR Parametric Diagrams", IconManager.imgic100, IconManager.imgic101, "Edit AVATAR Parametric Diagram", "Make it possible to edit the currently opened AVATAR Parametric Diagram", 0);
+        actions[APD_BLOCK] = new TAction("apd-block", "Add a block", IconManager.imgic5000, IconManager.imgic5000, "Block", "Add a SysML Block to the currently opened AVATAR Parametric Diagram", 0);
+        actions[APD_LOGICAL_CONSTRAINT] = new TAction("apd-logical-constraint", "Add a Logical Constraint", IconManager.imgic5028, IconManager.imgic5028, "Logical Constraint", "Add a Logical Constraint to the currently opened AVATAR Parametric Diagram", 0);
+        actions[APD_TEMPORAL_CONSTRAINT] = new TAction("apd-temporal-constraint", "Add a Temporal Constraint", IconManager.imgic5030, IconManager.imgic5030, "Temporal Constraint", "Add a Temporal Constraint to the currently opened AVATAR Parametric Diagram", 0);
+        actions[APD_ATTRIBUTE] = new TAction("apd-attribute", "Add a attribute", IconManager.imgic5010, IconManager.imgic5010, "Attribute", "Add an attribute to the currently opened AVATAR Parametric Diagram", 0);
+        actions[APD_SIGNAL] = new TAction("apd-signal", "Add a signal", IconManager.imgic5022, IconManager.imgic5022, "Signal", "Add an signal to the currently opened AVATAR Parametric Diagram", 0);
+        actions[APD_ALIAS] = new TAction("apd-alias", "Add a alias", IconManager.imgic5032, IconManager.imgic5032, "Alias", "Add an alias to the currently opened AVATAR Parametric Diagram", 0);
+        actions[APD_BOOLEQ] = new TAction("apd-booleq", "Add a boolean equation", IconManager.imgic5014, IconManager.imgic5014, "boolean equation", "Add a boolean equation to the currently opened AVATAR Parametric Diagram", 0);
+        actions[APD_ATTRIBUTE_SETTING] = new TAction("apd-attribute-setting", "Setting attributes", IconManager.imgic5012, IconManager.imgic5012, "Setting attributes", "Add an attribute affectation to the currently opened AVATAR Parametric Diagram", 0);
+        actions[APD_PROPERTY] = new TAction("apd-property", "Add a property", IconManager.imgic5026, IconManager.imgic5026, "Property", "Add a property to the currently opened AVATAR Parametric Diagram", 0);
+        actions[APD_PROPERTY_RELATION] = new TAction("apd-property-relation", "Add a property relation", IconManager.imgic5024, IconManager.imgic5024, "Property relation", "Add a property relation to the currently opened AVATAR Parametric Diagram", 0);
+        actions[APD_ATTRIBUTE_CONNECTOR] = new TAction("apd-attribute-connector", "Add a connector between attribute elements", IconManager.imgic5016, IconManager.imgic5016, "Connector between attributes", "Add a connector between attributes to the currently opened AVATAR Parametric Diagram", 0);
+        actions[APD_SIGNAL_CONNECTOR] = new TAction("apd-signal-connector", "Add a connector between signal elements", IconManager.imgic5018, IconManager.imgic5018, "Connector between signals", "Add a connector between signals to the currently opened AVATAR Parametric Diagram", 0);
+        actions[APD_PROPERTY_CONNECTOR] = new TAction("apd-property-connector", "Add a connector between property elements", IconManager.imgic5020, IconManager.imgic5020, "Connector between properties", "Add a connector between properties to the currently opened AVATAR Parametric Diagram", 0);
+        actions[APD_COMPOSITION_CONNECTOR] = new TAction("apd-composition-connector", "Add a composition between blocks", IconManager.imgic5002, IconManager.imgic5002, "Composition between blocks", "Add a composition between blocks to the currently opened AVATAR Parametric Diagram", 0);
+
+        // AVATAR Context Diagrams
+        actions[ACD_EDIT] = new TAction("edit-acd-diagram", "Edit AVATAR Context Diagrams", IconManager.imgic100, IconManager.imgic101, "Edit AVATAR Context Diagram", "Make it possible to edit the currently opened AVATAR Context Diagram", 0);
+        actions[ACD_BLOCK] = new TAction("acd-block", "Add a block", IconManager.imgic5000, IconManager.imgic5000, "Block", "Add a SysML Block to the currently opened AVATAR Context Diagram", 0);
+        actions[ACD_COMPOSITION_CONNECTOR] = new TAction("acd-composition-connector", "Add a composition between blocks", IconManager.imgic5002, IconManager.imgic5002, "Composition between blocks", "Add a composition between blocks to the currently opened AVATAR Context Diagram", 0);
+        actions[ACD_ASSOCIATION_CONNECTOR] = new TAction("acd-association-connector", "Add an association", IconManager.imgic5044, IconManager.imgic5044, "Association", "Add an association between blocks to the currently opened AVATAR Context Diagram", 0);
+        actions[ACD_ACTOR_STICKMAN] = new TAction("acd-add-actor", "Add an actor (stickman format)", IconManager.imgic600, IconManager.imgic600, "Actor", "Add a stickman actor to the currently opened AVATAR Context diagram", 0);
+        actions[ACD_ACTOR_BOX] = new TAction("acd-add-actor-box", "Add an actor (box format)", IconManager.imgic614, IconManager.imgic614, "Actor (box format)", "Add a box actor  to the currently opened AVATAR Context diagram", 0);
+
+        // AVATAR Activity Diagrams
+        actions[AAD_EDIT] = new TAction("edit-aad-diagram", "Edit AVATAR Activity Diagrams", IconManager.imgic100, IconManager.imgic101, "Edit AVATAR Activity Diagram", "Make it possible to edit the currently opened AVATAR Activity Diagram", 0);
+        actions[AAD_ASSOCIATION_CONNECTOR] = new TAction("aad-association-connector", "Add an association", IconManager.imgic202, IconManager.imgic202, "Association", "Add an association between blocks to the currently opened AVATAR Activity Diagram", 0);
+        actions[AAD_START_STATE] = new TAction("add-add-start", "Add Start state", IconManager.imgic222, IconManager.imgic222, "Start", "Add a start state to the currently opened activity diagram", 0);
+        actions[AAD_STOP_STATE] = new TAction("add-aad-stop", "Add Stop", IconManager.imgic210, IconManager.imgic210, "Stop", "Add a termination state to the currently opened activity diagram", 0);
+        actions[AAD_CHOICE] = new TAction("add-aad-choice", "Add Choice", IconManager.imgic208, IconManager.imgic208, "Choice", "Add a choice to the currently opened Avatar activity diagram", 0);
+        actions[AAD_JUNCTION] = new TAction("add-aad-junction", "Junction", IconManager.imgic212, IconManager.imgic212, "Junction", "Add a junction with three inputs to the currently opened avatar activity diagram", 0);
+        actions[AAD_PARALLEL] = new TAction("add-adparallel", "Parallel", IconManager.imgic206, IconManager.imgic206, "Parallel", "Add a parallel  operator to the currently opened avatar activity diagram", 0);
+        actions[AAD_ACTIVITY] = new TAction("add-aad-activity", "Activity", IconManager.imgic5048, IconManager.imgic5048, "Activity", "Add a new activity to the currently opened AVATAR avatar activity diagram", 0);
+        actions[AAD_ACTION] = new TAction("add-aad-action", "Action", IconManager.imgic204, IconManager.imgic204, "Action", "Add a new action to the currently opened AVATAR avatar activity diagram", 0);
+        actions[AAD_STOP_FLOW] = new TAction("add-aad-stop-flow", "Stop flow", IconManager.imgic5046, IconManager.imgic5046, "Stop flow", "Add a stop flow state to the currently opened avatar activity diagram", 0);
+        actions[AAD_SEND_SIGNAL_ACTION] = new TAction("add-add-send-signal-action", "Send signal", IconManager.imgic5050, IconManager.imgic5050, "Send signal", "Add a send signal operator to the currently opened avatar activity diagram", 0);
+        actions[AAD_ACCEPT_EVENT_ACTION] = new TAction("add-add-accept-event-action", "Accept event", IconManager.imgic5056, IconManager.imgic5056, "Accept event", "Add an accept event operator to the currently opened avatar activity diagram", 0);
+        actions[AAD_PARTITION] = new TAction("add-add-partition", "Partition", IconManager.imgic5052, IconManager.imgic5052, "Partition", "Add a partition to the currently opened avatar activity diagram", 0);
+        actions[AAD_ALIGN_PARTITION] = new TAction("add-aad-align_partitions", "Align partitions", IconManager.imgic5054, IconManager.imgic5054, "Align partitions", "Align partitions of the currently opened avatar activity diagram", 0);
+
+        // Ontologies
+        actions[ACT_GENERATE_ONTOLOGIES_CURRENT_DIAGRAM] = new TAction("generate-ontology-current-diagram", "Generate ontology (current diagram)", IconManager.imgic338, IconManager.imgic339, "Generate ontology (current diagram)",  "Generate the ontology for the diagram under edition", 0);
+        actions[ACT_GENERATE_ONTOLOGIES_CURRENT_SET_OF_DIAGRAMS] = new TAction("generate-ontology-current-set-of-diagrams", "Generate ontology (current set of diagrams)", IconManager.imgic338, IconManager.imgic339, "Generate ontology (current set of diagrams)",  "Generate the ontology for the current set of diagrams under edition", 0);
+        actions[ACT_GENERATE_ONTOLOGIES_ALL_DIAGRAMS] = new TAction("generate-ontology-all-diagrams", "Generate ontology (all diagrams)", IconManager.imgic338, IconManager.imgic339, "Generate ontology (all diagrams)",  "Generate the ontology for the diagrams under edition", 0);
+
+        actions[MOVE_ENABLED] = new TAction("Move", "Move enabled", IconManager.imgic780, IconManager.imgic780, "Move enabled (shift + arrow)", "Move", 0);
+	actions[FIRST_DIAGRAM] = new TAction("FirstDiagram", "First Diagram", IconManager.imgic142, IconManager.imgic142, "Switch the the first diagram", "Switch to the first diagram", 0);
+    }
+
+
+    public String getActionCommand()  {
+        return (String)getValue(Action.ACTION_COMMAND_KEY);
+    }
+
+    public String getShortDescription()  {
+        return (String)getValue(Action.SHORT_DESCRIPTION);
+    }
+
+    public String getLongDescription()  {
+        return (String)getValue(Action.LONG_DESCRIPTION);
+    }
+
+    public void actionPerformed(ActionEvent evt)  {
+        //System.out.println("Action performed");
+        if (listeners != null) {
+            Object[] listenerList = listeners.getListenerList();
+
+            // Recreate the ActionEvent and stuff the value of the ACTION_COMMAND_KEY
+            ActionEvent e = new ActionEvent(evt.getSource(), evt.getID(),
+                                            (String)getValue(Action.ACTION_COMMAND_KEY));
+            for (int i = 0; i <= listenerList.length-2; i += 2) {
+                ((ActionListener)listenerList[i+1]).actionPerformed(e);
+            }
+        }
+    }
+
+    public void addActionListener(ActionListener l)  {
+        if (listeners == null) {
+            listeners = new EventListenerList();
+        }
+        //TraceManager.addDev("Action listener added");
+        listeners.add(ActionListener.class, l);
+    }
+
+    public void removeActionListener(ActionListener l)  {
+        if (listeners == null) {
+            return;
+        }
+        listeners.remove(ActionListener.class, l);
+    }
+}
diff --git a/src/main/resources/ui/syscams/SysCAMSBlockDE.java b/src/main/resources/ui/syscams/SysCAMSBlockDE.java
new file mode 100644
index 0000000000..27cb244370
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSBlockDE.java
@@ -0,0 +1,67 @@
+/* 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.syscams;
+
+import ui.TDiagramPanel;
+import ui.TGComponent;
+
+/**
+ * Class SysCAMSBlockDE
+ * Primitive Component. To be used in SystemC-AMS component task diagrams 
+ * Creation: 23/04/2018
+ * @version 1.0 23/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSBlockDE extends SysCAMSPrimitiveComponent {
+	private int period;
+
+	public SysCAMSBlockDE(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos,
+			TGComponent _father, TDiagramPanel _tdp) {
+		super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+	}
+
+	public int getPeriod() {
+		return period;
+	}
+
+	public void setPeriod(int period) {
+		this.period = period;
+	}
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSBlockTDF.java b/src/main/resources/ui/syscams/SysCAMSBlockTDF.java
new file mode 100644
index 0000000000..a354f6566f
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSBlockTDF.java
@@ -0,0 +1,76 @@
+/* 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.syscams;
+
+import ui.TDiagramPanel;
+import ui.TGComponent;
+
+/**
+ * Class SysCAMSBlockTDF
+ * Primitive Component. To be used in SystemC-AMS component task diagrams 
+ * Creation: 23/04/2018
+ * @version 1.0 23/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSBlockTDF extends SysCAMSPrimitiveComponent {
+	private int period;
+	private String processCode;
+
+	public SysCAMSBlockTDF(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos,
+			TGComponent _father, TDiagramPanel _tdp) {
+		super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+	}
+
+	public String getProcessCode() {
+		return processCode;
+	}
+
+	public void setProcessCode(String processCode) {
+		this.processCode = processCode;
+	}
+
+	public int getPeriod() {
+		return period;
+	}
+
+	public void setPeriod(int period) {
+		this.period = period;
+	}
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSChannelFacility.java b/src/main/resources/ui/syscams/SysCAMSChannelFacility.java
new file mode 100644
index 0000000000..3ac59014a0
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSChannelFacility.java
@@ -0,0 +1,180 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+import ui.*;
+
+import java.awt.*;
+
+/**
+ * Class SysCAMSChannelFacility
+ * Channel facility. To be used in SystemC-AMS component task diagrams
+ * Creation: 22/04/2018
+ * @version 1.0 22/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public abstract class SysCAMSChannelFacility extends TGCScalableWithInternalComponent {
+    protected Color myColor, portColor;
+
+    protected SysCAMSPrimitivePort inp, outp;
+    protected int inpIndex, outpIndex;
+    protected boolean conflict = false;
+    protected String conflictMessage;
+
+    public SysCAMSChannelFacility(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+
+        minWidth = 10;
+        minHeight = 10;
+
+        moveable = true;
+        editable = false;
+        removable = true;
+        userResizable = false;
+    }
+
+    public TGComponent isOnOnlyMe(int _x, int _y) {
+        if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) {
+            return this;
+        }
+        return null;
+    }
+
+    public void calculatePortColor() {
+        if (conflict) {
+            myColor = Color.red;
+        } else {
+            SysCAMSPrimitivePort port = inp;
+            if (port == null) {
+                port = outp;
+            }
+            if (port == null) {
+                portColor = null;
+                if (myColor == null) {
+                    myColor = new Color(251, 252, 155- (getMyDepth() * 10));
+                }
+            } else {
+                int typep = port.getPortType();
+                if (typep == 0) {
+                    myColor = ColorManager.TML_PORT_CHANNEL;
+                } else if (typep == 1) {
+                    myColor = ColorManager.TML_PORT_EVENT;
+                } else {
+                    myColor = ColorManager.TML_PORT_REQUEST;
+                }
+            }
+        }
+        portColor = myColor;
+    }
+
+    public void setInPort(SysCAMSPrimitivePort _inp) {
+        inp = _inp;
+        calculatePortColor();
+    }
+
+    public void setOutPort(SysCAMSPrimitivePort _outp) {
+        outp = _outp;
+        calculatePortColor();
+    }
+
+    public SysCAMSPrimitivePort getInPort() {
+        return inp;
+    }
+
+    public SysCAMSPrimitivePort getOutPort() {
+        return outp;
+    }
+
+    public int getInpIndex() {
+        return inpIndex;
+    }
+
+    public int getOutpIndex() {
+        return outpIndex;
+    }
+
+    public void setInpIndex(int _inpIndex) {
+        inpIndex = _inpIndex;
+    }
+
+    public void setOutpIndex(int _outpIndex) {
+        outpIndex = _outpIndex;
+    }
+
+    public boolean getConflict() {
+        return conflict;
+    }
+
+    public void setConflict(boolean _conflict, String _msg) {
+        conflict = _conflict;
+        myColor = null;
+        conflictMessage = _msg;
+        calculatePortColor();
+    }
+
+    public int getDefaultConnector() {
+        return TGComponentManager.CONNECTOR_PORT_TMLC;
+    }
+
+    public Color getPortColor() {
+        return portColor;
+    }
+
+    public String getAttributes() {
+        if (conflict) {
+            return conflictMessage;
+        }
+        String s = "";
+        if (inp != null) {
+            s = s + inp.getAttributes();
+            if (outp != null) {
+                s = s + "\n";
+            }
+        }
+        if (outp != null) {
+            s = s + outp.getAttributes();
+        }
+        if (conflict) {
+            s += "Error in path=" + conflict;
+        }
+        return s;
+    }
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSChannelOutPort.java b/src/main/resources/ui/syscams/SysCAMSChannelOutPort.java
new file mode 100644
index 0000000000..ed1f34c0f9
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSChannelOutPort.java
@@ -0,0 +1,68 @@
+/* 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.syscams;
+
+import ui.TDiagramPanel;
+import ui.TGComponent;
+import ui.TGComponentManager;
+
+import java.awt.*;
+
+/**
+ * Class SysCAMSChannelOutPort
+ * Channel out port. To be used in SystemC-AMS component task diagrams
+ * Creation: 22/04/2018
+ * @version 1.0 22/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSChannelOutPort extends SysCAMSPrimitivePort {
+    public SysCAMSChannelOutPort(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+        
+		initConnectingPoint(true, true, 1);
+    }
+	
+	public void drawParticularity(Graphics g) {
+	}
+	
+    public int getType() {
+        return TGComponentManager.TMLCTD_COPORT;
+    }
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSComponentTaskDiagramPanel.java b/src/main/resources/ui/syscams/SysCAMSComponentTaskDiagramPanel.java
new file mode 100644
index 0000000000..1d834b9153
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSComponentTaskDiagramPanel.java
@@ -0,0 +1,1261 @@
+/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici
+ *
+ * ludovic.apvrille AT enst.fr
+ * andrea.enrici 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.syscams;
+
+import myutil.TraceManager;
+import org.w3c.dom.Element;
+import ui.*;
+
+import java.util.*;
+
+/**
+ * Class SysCAMSComponentTaskDiagramPanel
+ * Panel for drawing SystemC-AMS elements
+ * Creation: 27/04/2018
+ * @version 1.0 27/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+@SuppressWarnings("serial")
+
+public class SysCAMSComponentTaskDiagramPanel extends TDiagramPanel implements TDPWithAttributes {
+
+    public SysCAMSComponentTaskDiagramPanel(MainGUI mgui, TToolBar _ttb) {
+        super(mgui, _ttb);
+    }
+
+    public boolean actionOnDoubleClick(TGComponent tgc) {
+        return false;
+    }
+
+    public boolean actionOnAdd(TGComponent tgc) {
+        if (tgc instanceof SysCAMSPrimitiveComponent) {
+            return true;
+        } 
+        if (tgc instanceof SysCAMSCompositePort) {
+            if (tgc.getFather() instanceof SysCAMSCompositeComponent) {
+                getMGUI().updateReferenceToSysCAMSCompositeComponent((SysCAMSCompositeComponent)(tgc.getFather()));
+            }
+        }
+
+        return true;
+    }
+
+    public boolean actionOnRemove(TGComponent tgc) {
+        if (tgc instanceof SysCAMSPortConnector) {
+            updatePorts();
+        }
+        if (tgc instanceof SysCAMSPrimitivePort) {
+            updatePorts();
+        }
+
+        if (tgc instanceof SysCAMSChannelFacility) {
+            updatePorts();
+        }
+
+        if (tgc instanceof SysCAMSCompositePort) {
+            updatePorts();
+            if (fatherOfRemoved instanceof SysCAMSCompositeComponent) {
+                getMGUI().updateReferenceToSysCAMSCompositeComponent((SysCAMSCompositeComponent)(fatherOfRemoved));
+            }
+        }
+
+        return true;
+    }
+
+    public List<SysCAMSPrimitivePort> getPortsByName(String name){
+        List<SysCAMSPrimitivePort> ports = new ArrayList<SysCAMSPrimitivePort>();
+        for (TGComponent tgc : componentList){
+
+            if (tgc instanceof SysCAMSPrimitiveComponent){
+                SysCAMSPrimitiveComponent comp = (SysCAMSPrimitiveComponent) tgc;
+                List<SysCAMSPrimitivePort> cps = comp.getAllTDFOriginPorts();
+                for (SysCAMSPrimitivePort port : cps){
+                    if (port.commName.equals(name)){
+                        ports.add(port);
+                    }
+                }
+                cps = comp.getAllTDFDestinationPorts();
+                for (SysCAMSPrimitivePort port : cps){
+                    if (port.commName.equals(name)){
+                        ports.add(port);
+                    }
+                }
+            }
+            if (tgc instanceof SysCAMSPrimitiveComponent){
+            	SysCAMSPrimitiveComponent comp = (SysCAMSPrimitiveComponent) tgc;
+            	List<SysCAMSPrimitivePort> cps = comp.getAllDEOriginPorts();
+            	for (SysCAMSPrimitivePort port : cps){
+            		if (port.commName.equals(name)){
+            			ports.add(port);
+            		}
+            	}
+            	cps = comp.getAllDEDestinationPorts();
+            	for (SysCAMSPrimitivePort port : cps){
+            		if (port.commName.equals(name)){
+            			ports.add(port);
+            		}
+            	}
+            }
+        }
+        return ports;
+    }
+
+    public boolean actionOnValueChanged(TGComponent tgc) {
+        if (tgc instanceof SysCAMSPrimitiveComponent) {
+            SysCAMSPrimitiveComponent t = (SysCAMSPrimitiveComponent)tgc;
+            mgui.newSysCAMSTaskName(tp, t.oldValue, t.getValue());
+            return true;
+        }
+        if (tgc instanceof SysCAMSCompositeComponent) {
+            SysCAMSCompositeComponent syscamscc = (SysCAMSCompositeComponent)tgc;
+            getMGUI().updateReferenceToSysCAMSCompositeComponent(syscamscc);
+        }
+        return true;
+    }
+
+    public boolean renamePrimitiveComponent(String oldValue, String newValue) {
+        return mgui.newSysCAMSComponentTaskName(tp, oldValue, newValue);
+    }
+
+    public boolean namePrimitiveComponentInUse(String oldValue, String newValue) {
+        boolean ko = mgui.nameComponentInUse(tp, oldValue, newValue);
+        return ko ? ko : nameAllRecordComponentInUse(oldValue, newValue);
+    }
+
+    public boolean nameRecordComponentInUse(String oldValue, String newValue) {
+        boolean ko = mgui.nameComponentInUse(tp, oldValue, newValue);
+        return ko? ko : nameAllRecordComponentInUse(oldValue, newValue);
+    }
+
+    public boolean isCompositeNameUsed(String newvalue) {
+        for (TGComponent tgc: this.componentList) {
+            if (tgc.getValue().equals(newvalue))
+                return true;
+        }
+        return false;
+    }
+
+    public boolean nameAllRecordComponentInUse(String oldValue, String newValue) {
+        Iterator<SysCAMSRecordComponent> iterator = getRecordComponentList().listIterator();
+        SysCAMSRecordComponent record;
+
+        while(iterator.hasNext()) {
+            record = iterator.next();
+            if (record.getName().compareTo(newValue) == 0) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public LinkedList<SysCAMSRecordComponent> getRecordComponentList() {
+        LinkedList<SysCAMSRecordComponent> ll = new LinkedList<SysCAMSRecordComponent>();
+        TGComponent tgc;
+
+        Iterator<TGComponent> iterator = componentList.listIterator();
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+            if (tgc instanceof SysCAMSRecordComponent) {
+                ll.add((SysCAMSRecordComponent) tgc);
+            }
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                ll.addAll(((SysCAMSCompositeComponent)tgc).getAllRecordComponents());
+            }
+            if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+                ll.addAll(((SysCAMSRemoteCompositeComponent)tgc).getAllRecordComponents());
+            }
+        }
+        return ll;
+    }
+
+    public List<SysCAMSPrimitiveComponent> getPrimitiveComponentList() {
+        List<SysCAMSPrimitiveComponent> ll = new LinkedList<SysCAMSPrimitiveComponent>();
+        TGComponent tgc;
+
+        Iterator<TGComponent> iterator = componentList.listIterator();
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+
+            if (tgc instanceof SysCAMSPrimitiveComponent) {
+                ll.add( (SysCAMSPrimitiveComponent) tgc );
+            }
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                ll.addAll(((SysCAMSCompositeComponent)tgc).getAllPrimitiveComponents());
+            }
+            if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+                ll.addAll(((SysCAMSRemoteCompositeComponent)tgc).getAllPrimitiveComponents());
+            }
+        }
+        return ll;
+    }
+
+    public List<SysCAMSPrimitivePort> getPortsConnectedTo(SysCAMSPrimitivePort _port, List<? extends TGComponent> componentsToTakeIntoAccount) {
+        List<TGComponent> ll;
+        List<SysCAMSPrimitivePort> ret = new LinkedList<SysCAMSPrimitivePort>();
+        Object o;
+        SysCAMSPrimitivePort p;
+
+        ll = getAllPortsConnectedTo(_port);
+        Iterator<TGComponent> li = ll.listIterator();
+
+        while(li.hasNext()) {
+            o = li.next();
+
+            if (o instanceof SysCAMSPrimitivePort) {
+                p = (SysCAMSPrimitivePort)o;
+
+                if (p.getFather() instanceof SysCAMSPrimitiveComponent) {
+                    if (componentsToTakeIntoAccount.contains(p.getFather())) {
+                        ret.add( p );
+                    }
+                }
+            }
+        }
+        return ret;
+    }
+
+    public List<TGComponent> getAllPortsConnectedTo(SysCAMSPrimitivePort _port) {
+        List<TGComponent> ll = new LinkedList<TGComponent>();
+        getAllPortsConnectedTo( ll, _port );
+        return ll;
+    }
+
+//    public List<String> getAllSysCAMSCommunicationNames(String _topname) {
+//        List<String> al = new ArrayList<String>();
+//
+//        SysCAMSPrimitiveComponent syscamsc;
+//        List<SysCAMSPrimitiveComponent> components = getPrimitiveComponentList();
+//        Iterator<SysCAMSPrimitiveComponent> iterator = components.listIterator();
+//        Iterator<SysCAMSPrimitivePort> li;//, li2;
+//        List<SysCAMSPrimitivePort> ports, portstome;
+//        String name, name1, name2;
+//        SysCAMSPrimitivePort port1, port2;
+//
+//        int j;
+//
+//        while( iterator.hasNext() ) {
+//            syscamsc = iterator.next();
+//            ports = syscamsc.getAllChannelsOriginPorts();
+//            li = ports.listIterator();
+//            while( li.hasNext() ) {
+//                port1 = li.next();
+//                portstome = getPortsConnectedTo( port1, components );
+//                Iterator<SysCAMSPrimitivePort> ite = portstome.listIterator();
+//
+//                while( ite.hasNext()) {
+//                    port2 = ite.next();
+//                    if (!port2.isOrigin()) {
+//                        String []text1 = port1.getPortName().split( "," );
+//                        String []text2 = port2.getPortName().split( "," );
+//                        for ( j = 0; j < Math.min( text1.length, text2.length ); j++ ) {
+//                            name1 = text1[j].trim();
+//                            name2 = text2[j].trim();
+//                            if( name1.equals( name2 ) ) {
+//                                name = name1;
+//                            }
+//                            else {
+//                                name = name1 + "__" + name2;
+//                            }
+//                            al.add( _topname + "::" + name );
+//                        }
+//                    }
+//                }
+//            }
+//        }
+//        return al;
+//    }
+//
+//    public List<String> getAllSysCAMSInputPorts( String _topname ) {   //the destination ports
+//        //Use HashSet to avoid returning multiple identical ports due to the presence of join nodes
+//        Set<String> al = new HashSet<String>();
+//        SysCAMSPrimitiveComponent syscamsc;
+//        List<SysCAMSPrimitiveComponent> components = getPrimitiveComponentList();
+//        Iterator<SysCAMSPrimitiveComponent> iterator = components.listIterator();
+//        Iterator<SysCAMSPrimitivePort> li;//, li2;
+//        List<SysCAMSPrimitivePort> ports, portstome;
+//        String name2;
+//        SysCAMSPrimitivePort port1, port2;
+//        int j;
+//
+//        while( iterator.hasNext() ) {
+//            syscamsc = iterator.next();
+//            ports = syscamsc.getAllChannelsOriginPorts();
+//            li = ports.listIterator();
+//            while( li.hasNext() ) {
+//                port1 = li.next();
+//                portstome = getPortsConnectedTo( port1, components );   //this prints the ports via TraceManager
+//                Iterator<SysCAMSPrimitivePort> ite = portstome.listIterator();
+//                while( ite.hasNext()) {
+//                    port2 = ite.next();
+//                    if( !port2.isOrigin() ) {
+//                        String []text1 = port1.getPortName().split( "," );
+//                        String []text2 = port2.getPortName().split( "," );
+//                        for( j = 0; j < Math.min( text1.length, text2.length ); j++ ) {
+//                            name2 = text2[j].trim();
+//                            al.add( _topname + "::" + name2 );
+//                        }
+//                    }
+//                }
+//            }
+//        }
+//        return new ArrayList<String>(al);
+//    }
+//
+//    public List<String> getAllSysCAMSEventNames( String _topname ) {
+//
+//        List<String> al = new ArrayList<String>();
+//        SysCAMSPrimitiveComponent syscamsc;
+//        List<SysCAMSPrimitiveComponent> components = getPrimitiveComponentList();
+//        Iterator<SysCAMSPrimitiveComponent> iterator = components.listIterator();
+//        Iterator<SysCAMSPrimitivePort> li;//, li2;
+//        List<SysCAMSPrimitivePort> ports, portstome;
+//        String name, name1, name2;
+//        SysCAMSPrimitivePort port1, port2;
+//        int j;
+//
+//        while( iterator.hasNext() ) {
+//            syscamsc = iterator.next() ;
+//            ports = syscamsc.getAllEventsOriginPorts();
+//            li = ports.listIterator();
+//            while( li.hasNext() ) {
+//                port1 = li.next();
+//                portstome = getPortsConnectedTo( port1, components );
+//                if ( portstome.size() == 1 ) {
+//                    port2 = portstome.get(0);
+//                    String []text1 = port1.getPortName().split( "," );
+//                    String []text2 = port2.getPortName().split( "," );
+//                    for ( j = 0; j < Math.min( text1.length, text2.length ); j++ ) {
+//                        name1 = text1[j].trim();
+//                        name2 = text2[j].trim();
+//                        if( name1.equals( name2 ) ) {
+//                            name = name1;
+//                        }
+//                        else {
+//                            name = name1 + "__" + name2;
+//                        }
+//                        al.add( _topname + "::" + name );
+//                    }
+//                }
+//            }
+//        }
+//        return al;
+//    }
+
+    public void getAllPortsConnectedTo( List<TGComponent> ll, SysCAMSPrimitivePort _port) {
+        List<TGComponent> components = getMGUI().getAllSysCAMSComponents();
+        Iterator<TGComponent> iterator = components.listIterator();
+        TGComponent tgc, tgc1, tgc2;
+        SysCAMSPortConnector portco;
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+
+            if (tgc instanceof SysCAMSPortConnector) {
+                portco = (SysCAMSPortConnector)tgc;
+                tgc1 = getComponentToWhichBelongs(components, portco.getTGConnectingPointP1());
+                tgc2 = getComponentToWhichBelongs(components, portco.getTGConnectingPointP2());
+                if ((tgc1 != null) && (tgc2 != null)) {
+                    if (tgc1 instanceof SysCAMSRemoteCompositeComponent) {
+                        tgc1 = ((SysCAMSRemoteCompositeComponent)tgc1).getPortOf(portco.getTGConnectingPointP1());
+                    }
+
+                    if (tgc2 instanceof SysCAMSRemoteCompositeComponent) {
+                        tgc2 = ((SysCAMSRemoteCompositeComponent)tgc2).getPortOf(portco.getTGConnectingPointP2());
+                    }
+                    if ((!ll.contains(tgc2) && (tgc2 != _port) && ((tgc1 == _port) || (ll.contains(tgc1))))) {
+                        ll.add(tgc2);
+                        iterator = components.listIterator();
+                    } else {
+                        if ((!ll.contains(tgc1) && (tgc1 != _port) && ((tgc2 == _port) || (ll.contains(tgc2))))) {
+                            ll.add(tgc1);
+                            iterator = components.listIterator();
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public String getXMLHead() {
+        return "<SysCAMSComponentTaskDiagramPanel name=\"" + name + "\"" + sizeParam() + displayParam() + zoomParam() +" >";
+    }
+
+    public String getXMLTail() {
+        return "</SysCAMSComponentTaskDiagramPanel>";
+    }
+
+    public String getXMLSelectedHead() {
+        return "<SysCAMSComponentTaskDiagramPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >";
+    }
+
+    public String getXMLSelectedTail() {
+        return "</SysCAMSComponentTaskDiagramPanelCopy>";
+    }
+
+    public String getXMLCloneHead() {
+        return "<SysCAMSComponentTaskDiagramPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >";
+    }
+
+    public String getXMLCloneTail() {
+        return "</SysCAMSComponentTaskDiagramPanelCopy>";
+    }
+
+    public boolean areAttributesVisible() {
+        return attributesVisible;
+    }
+
+    public boolean areChannelVisible() {
+        return synchroVisible;
+    }
+
+    public void setAttributesVisible(boolean b) {
+        attributesVisible = b;
+    }
+
+
+    public void setChannelVisible(boolean b) {
+        channelVisible = b;
+    }
+
+    public String displayParam() {
+        String s = "";
+        if (channelsVisible) {
+            s += " TDF=\"true\"";
+        } else {
+            s += " TDF=\"false\"";
+        }
+        if (eventsVisible) {
+            s += " DE=\"true\"";
+        } else {
+            s += " DE=\"false\"";
+        }
+        return s;
+    }
+
+    public ArrayList<String> getAllCompositeComponent(String _name) {
+        ArrayList<String> list = new ArrayList<String>();
+        TGComponent tgc1;
+        String s;
+        SysCAMSCompositeComponent syscamscc;
+        Iterator<TGComponent> iterator = componentList.listIterator();
+
+        while(iterator.hasNext()) {
+            tgc1 = iterator.next();
+
+            if (tgc1 instanceof SysCAMSCompositeComponent) {
+                syscamscc = (SysCAMSCompositeComponent)tgc1;
+                s = _name + "::" + syscamscc.getValue();
+                list.add(s);
+                syscamscc.getAllCompositeComponents(list, _name);
+            }
+        }
+        return list;
+    }
+
+    public String[] getCompOutTDF(){
+        List<String> chls = new ArrayList<String>();
+        TGComponent tgc;
+        Iterator<TGComponent> iterator = componentList.listIterator();
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+            if (tgc instanceof SysCAMSPrimitiveComponent) {
+                SysCAMSPrimitiveComponent comp = (SysCAMSPrimitiveComponent) tgc;
+                List<SysCAMSPrimitivePort> ll = comp.getAllTDFOriginPorts();
+                Iterator<SysCAMSPrimitivePort> ite = ll.listIterator();
+                while(ite.hasNext()) {
+                    SysCAMSPrimitivePort port = ite.next();
+                    chls.add(port.getPortName());
+                }
+            }
+        }
+        String[] chlArray = new String[chls.size()];
+        chlArray = chls.toArray(chlArray);
+        return chlArray;
+    }
+
+    public String[] getCompInTDF(){
+        List<String> chls = new ArrayList<String>();
+        TGComponent tgc;
+        Iterator<TGComponent> iterator = componentList.listIterator();
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+            if (tgc instanceof SysCAMSPrimitiveComponent) {
+                SysCAMSPrimitiveComponent comp = (SysCAMSPrimitiveComponent) tgc;
+                List<SysCAMSPrimitivePort> ll = comp.getAllTDFDestinationPorts();
+                Iterator<SysCAMSPrimitivePort> ite = ll.listIterator();
+                while(ite.hasNext()) {
+                    SysCAMSPrimitivePort port = ite.next();
+                    chls.add(port.getPortName());
+                }
+            }
+        }
+        String[] chlArray = new String[chls.size()];
+        chlArray = chls.toArray(chlArray);
+        return chlArray;
+    }
+
+    public SysCAMSPrimitiveComponent getPrimitiveComponentByName(String _name) {
+        TGComponent tgc;
+        Iterator<TGComponent> iterator = componentList.listIterator();
+        SysCAMSPrimitiveComponent tmp;
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+            if (tgc instanceof SysCAMSPrimitiveComponent) {
+                if (tgc.getValue().equals(_name)) {
+                    return ((SysCAMSPrimitiveComponent)tgc);
+                }
+            }
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                tmp = ((SysCAMSCompositeComponent)tgc).getPrimitiveComponentByName(_name);
+                if (tmp != null) {
+                    return tmp;
+                }
+            }
+            if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+                tmp = ((SysCAMSRemoteCompositeComponent)tgc).getPrimitiveComponentByName(_name);
+                if (tmp != null) {
+                    return tmp;
+                }
+            }
+        }
+        return null;
+    }
+
+    public void updateReferenceToSysCAMSCompositeComponent(SysCAMSCompositeComponent syscamscc) {
+        Iterator<TGComponent> iterator = componentList.listIterator();
+        TGComponent tgc;
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                ((SysCAMSCompositeComponent)tgc).updateReferenceToSysCAMSCompositeComponent(syscamscc);
+            }
+
+            if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+                ((SysCAMSRemoteCompositeComponent)tgc).updateReference(syscamscc);
+            }
+        }
+    }
+
+    public SysCAMSCompositeComponent getCompositeComponentByName(String _name) {
+        TGComponent tgc;
+        Iterator<TGComponent> iterator = componentList.listIterator();
+        SysCAMSCompositeComponent tmp;
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                tmp = (SysCAMSCompositeComponent)tgc;
+                if (tmp.getValue().equals(_name)) {
+                    return tmp;
+                }
+
+                if ((tmp = tmp.getCompositeComponentByName(name)) != null) {
+                    return tmp;
+                }
+            }
+        }
+        return null;
+    }
+
+    public void hideConnectors() {
+        Iterator<TGComponent> iterator = componentList.listIterator();
+        SysCAMSPortConnector connector;
+        TGComponent tgc;
+        TGComponent tgc1;
+        TGComponent tgc2;
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+
+            if (tgc instanceof SysCAMSPortConnector) {
+                connector = (SysCAMSPortConnector) tgc;
+                tgc1 = getComponentToWhichBelongs(connector.getTGConnectingPointP1());
+                tgc2 = getComponentToWhichBelongs(connector.getTGConnectingPointP2());
+                if ((tgc1 != null) && (tgc2 != null)) {
+                    if (tgc1.hasAnHiddenAncestor()) {
+                        tgc.setHidden(true);
+                    } else {
+                        if (tgc2.hasAnHiddenAncestor()) {
+                            tgc.setHidden(true);
+                        } else {
+                            tgc.setHidden(false);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public void loadExtraParameters(Element elt) {
+    }
+
+    public void setConnectorsToFront() {
+        TGComponent tgc;
+        Iterator<TGComponent> iterator = componentList.listIterator();
+        List<TGComponent> list = new ArrayList<TGComponent>();
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+            if (!(tgc instanceof TGConnector)) {
+                list.add(tgc);
+            }
+        }
+        for(TGComponent tgc1: list) {
+            componentList.remove(tgc1);
+            componentList.add(tgc1);
+        }
+    }
+
+    public void delayedLoad() {
+        Iterator<TGComponent> iterator;
+        TGComponent tgc;
+
+        iterator = componentList.listIterator();
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                ((SysCAMSCompositeComponent)(tgc)).delayedLoad();
+            }
+
+            if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+                try {
+                    ((SysCAMSRemoteCompositeComponent)(tgc)).delayedLoad();
+                } catch (Exception e) {
+                }
+            }
+        }
+    }
+
+    // Returns the faulty paths
+    public ArrayList<SysCAMSPath> updatePorts() {
+        List<SysCAMSPath> paths = makePaths();
+        ArrayList<SysCAMSPath> faultyPaths = new ArrayList<SysCAMSPath>();
+
+        // Checking rules of paths, and setting colors accordingly
+        for(SysCAMSPath path: paths) {
+            path.checkRules();
+            if (path.hasError()) {
+                TraceManager.addDev("Path error:" + path.getErrorMessage());
+                faultyPaths.add(path);
+            }
+            path.setColor();
+        }
+        return faultyPaths;
+    }
+
+    public void updatePorts_oldVersion() {
+        Iterator<TGComponent> iterator;
+        TGComponent tgc;
+
+        // Get all SysCAMSPrimitivePort
+        List<SysCAMSCompositePort> ports = new ArrayList<SysCAMSCompositePort>();
+        List<SysCAMSCompositePort> referencedports = new ArrayList<SysCAMSCompositePort>();
+        List<SysCAMSPrimitivePort> pports = new ArrayList<SysCAMSPrimitivePort>();
+        List<SysCAMSChannelFacility> facilities = new ArrayList<SysCAMSChannelFacility>();
+
+        iterator = componentList.listIterator();
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                ports.addAll(((SysCAMSCompositeComponent)tgc).getAllInternalCompositePorts());
+                pports.addAll(((SysCAMSCompositeComponent)tgc).getAllInternalPrimitivePorts());
+                referencedports.addAll(((SysCAMSCompositeComponent)tgc).getAllReferencedCompositePorts());
+            }
+            if (tgc instanceof SysCAMSPrimitiveComponent) {
+                pports.addAll(((SysCAMSPrimitiveComponent)tgc).getAllInternalPrimitivePorts());
+            }
+            if (tgc instanceof SysCAMSCompositePort) {
+                ports.add((SysCAMSCompositePort)tgc);
+            }
+            if (tgc instanceof SysCAMSPrimitivePort) {
+                pports.add((SysCAMSPrimitivePort)tgc);
+            }
+            if (tgc instanceof SysCAMSChannelFacility) {
+                facilities.add((SysCAMSChannelFacility)tgc);
+            }
+        }
+
+        // Remove All Current Links To Ports
+        for(SysCAMSCompositePort port:ports) {
+            if (!referencedports.contains(port)) {
+                port.purge();
+            }
+        }
+
+        // We take each primitive ports individually and we go thru the graph
+        ArrayList<SysCAMSChannelFacility> mets = new ArrayList<SysCAMSChannelFacility>();
+        TGConnector connector;
+        TGConnectingPoint tp;
+        String conflictMessage;
+
+        for(SysCAMSPrimitivePort pport:pports) {
+            for(int i=0; i<pport.getNbConnectingPoint(); i++) {
+                tp = pport.getTGConnectingPointAtIndex(i);
+                connector = findTGConnectorUsing(tp);
+                if (connector != null) {
+                    mets.clear();
+                    conflictMessage = propagate(pport, tp, connector, mets);
+                    TraceManager.addDev("Conflict=" + conflictMessage);
+                    analysePorts(pport, mets, (conflictMessage != null), conflictMessage);
+                } 
+            }
+        }
+    }
+
+    public String propagate(SysCAMSPrimitivePort pport, TGConnectingPoint tp, TGConnector connector, ArrayList<SysCAMSChannelFacility> mets) {
+        TGConnectingPoint tp2;
+        SysCAMSChannelFacility cp = null;
+        String conflictMessage = null;
+        String conflictMessageTmp;
+        int outindex, inindex;
+
+        if (tp == connector.getTGConnectingPointP1()) {
+            tp2 = connector.getTGConnectingPointP2();
+        } else {
+            tp2 = connector.getTGConnectingPointP1();
+        }
+
+        TGComponent tgc = (TGComponent)(tp2.getFather());
+        int index = tgc.getIndexOfTGConnectingPoint(tp2);
+
+        if (tgc instanceof SysCAMSPrimitivePort) {
+            return conflictMessage;
+        }
+
+        // Cycle?
+        if (mets.contains(tgc)) {
+            return "Connection contains a cycle";
+        }
+        if(tgc instanceof SysCAMSCompositePort) {
+            cp = (SysCAMSChannelFacility)tgc;
+            mets.add(cp);
+
+            inindex = cp.getInpIndex();
+            outindex = cp.getOutpIndex();
+            // Already positionned port?
+            if (pport.isOrigin()) {
+                if (cp.getOutPort() != null) {
+                    if (pport.getPortType() != 2) {
+                        conflictMessage = "Conflicting ports types";
+                    } else {
+                        if (cp.getOutPort().getPortType() != 2) {
+                            conflictMessage = "More than two sending non-request ports ";
+                        } else {
+                            if ((outindex<5 && index>4) || (outindex>4 && index<5)) {
+                                conflictMessage = "Sending ports on both side of a composite port";
+                            }
+                        }
+                    }
+                } else {
+                    if (inindex > -1) {
+                        if ((inindex<5 && index<5) || (inindex>4 && index>4)) {
+                            conflictMessage = "Sending and receiving ports on the same side of a composite port";
+                        }
+                    }
+                    cp.setOutPort(pport);
+                    cp.setOutpIndex(index);
+                }
+                conflictMessageTmp = explore(pport, tp2, cp, mets);
+                if (conflictMessageTmp != null) {
+                    conflictMessage = conflictMessageTmp;
+                }
+            } else {
+                if (cp.getInPort() != null) {
+                    conflictMessage = "More than two receiving ports ";
+                } else {
+                    if (outindex > -1) {
+                        if ((index<5 && outindex<5) || (index>4 && outindex>4)) {
+                            conflictMessage = "Sending and receiving ports on the same side of a composite port";
+                        }
+                    }
+                    cp.setInPort(pport);
+                    cp.setInpIndex(index);
+                }
+                conflictMessageTmp = explore(pport, tp2, cp, mets);
+                if (conflictMessageTmp != null) {
+                    conflictMessage = conflictMessageTmp;
+                }
+            }
+        } else if(tgc instanceof SysCAMSFork) {
+            // Only one out, more than one in is ok
+            // No SysCAMSJoin
+            cp = (SysCAMSChannelFacility)tgc;
+            mets.add(cp);
+
+            // Checks that "mets" contains no SysCAMSJoin
+            for(SysCAMSChannelFacility met: mets) {
+                if (met instanceof SysCAMSJoin) {
+                    conflictMessage = "Join and Fork operators are mixed in the same channel";
+                    conflictMessageTmp = explore(pport, tp2, cp, mets);
+                    if (conflictMessageTmp != null) {
+                        conflictMessage = conflictMessageTmp;
+                    }
+                    return conflictMessage;
+                }
+            }
+
+            if (pport.isOrigin()) {
+                if ((cp.getInPort() != null) && (cp.getInPort() != pport)) {
+                    conflictMessage = "More than two sending ports  in a fork architecture";
+                }
+                cp.setInPort(pport);
+                conflictMessageTmp = explore(pport, tp2, cp, mets);
+                if (conflictMessageTmp != null) {
+                    conflictMessage = conflictMessageTmp;
+                }
+            } else {
+                conflictMessage = explore(pport, tp2, cp, mets);
+            }
+        } else if(tgc instanceof SysCAMSJoin) {
+            // Only one out, more than one in is ok
+            // No SysCAMSFork
+            cp = (SysCAMSChannelFacility)tgc;
+            mets.add(cp);
+
+            // Checks that "mets" contains no SysCAMSJoin
+            for(SysCAMSChannelFacility met: mets) {
+                if (met instanceof SysCAMSFork) {
+                    conflictMessage = "Fork and Join operators are mixed in the same channel";
+                    conflictMessageTmp = explore(pport, tp2, cp, mets);
+                    if (conflictMessageTmp != null) {
+                        conflictMessage = conflictMessageTmp;
+                    }
+                    return conflictMessage;
+                }
+            }
+
+            if (!pport.isOrigin()) {
+                if ((cp.getOutPort() != null) && (cp.getOutPort() != pport)) {
+                    conflictMessage = "More than two receiving ports in a join architecture";
+                }
+                cp.setOutPort(pport);
+                conflictMessageTmp = explore(pport, tp2, cp, mets);
+                if (conflictMessageTmp != null) {
+                    conflictMessage = conflictMessageTmp;
+                }
+            } else {
+                conflictMessage = explore(pport, tp2, cp, mets);
+            }
+        }
+        if (cp != null) {
+            if ((cp.getInPort() != null) && (cp.getOutPort() != null)){
+                if (cp.getInPort().getType() != cp.getOutPort().getType()) {
+                    conflictMessage = "Ports are not compatible";
+                } else {
+                    TraceManager.addDev("ports of " + cp + " are compatible out=" + cp.getOutPort().getType() + " in=" + cp.getInPort().getType());
+                }
+            }
+        }
+        return conflictMessage;
+    }
+
+    public String explore(SysCAMSPrimitivePort pport, TGConnectingPoint _tp, SysCAMSChannelFacility cp, ArrayList<SysCAMSChannelFacility> mets) {
+        String conflictMessage = null;
+        String conflictMessageTmp;
+        TGConnectingPoint tp;
+        TGConnector connector;
+
+        for(int i=0; i<cp.getNbConnectingPoint(); i++) {
+            tp = cp.getTGConnectingPointAtIndex(i);
+            if (tp != _tp) {
+                connector = findTGConnectorUsing(tp);
+                if (connector != null) {
+                    conflictMessageTmp = propagate(pport, tp, connector, mets);
+                    if (conflictMessageTmp != null) {
+                        conflictMessage = conflictMessageTmp;
+                    }
+                }
+            }
+        }
+        return conflictMessage;
+    }
+
+    public void analysePorts(SysCAMSPrimitivePort pport, ArrayList<SysCAMSChannelFacility> mets, boolean conflict, String message) {
+        if (mets.size() == 0) {
+            return;
+        }
+        for(SysCAMSChannelFacility port: mets) {
+            port.setConflict(conflict, message);
+        }
+    }
+
+    public List<String> getAllSysCAMSTaskNames(String _topname) {
+        TGComponent tgc;
+        Iterator<TGComponent> iterator = componentList.listIterator();
+        List<String> list = new ArrayList<String>();
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+
+            if (tgc instanceof SysCAMSPrimitiveComponent) {
+                list.add(_topname + "::" + tgc.getValue());
+            }
+        }
+        return list;
+    }
+
+    public Vector<String> getAllSysCAMSTasksAttributes() {
+        TGComponent tgc;
+        Iterator<TGComponent> iterator = componentList.listIterator();
+        Vector<String> list = new Vector<String>();
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+            if( tgc instanceof SysCAMSCompositeComponent ) {
+                for( SysCAMSPrimitiveComponent primComp: ((SysCAMSCompositeComponent)tgc).getAllPrimitiveComponents() ) {
+                    for( Object o: primComp.getAttributeList() )   {
+                        String s = o.toString();
+                        list.add( primComp.getValue() + "." + s.substring( 2, s.length()-1 ) );
+                    }
+                }
+            }
+        }
+        return list;
+    }
+
+    public Vector<String> getAllRecords(SysCAMSPrimitiveComponent tgc) {
+        Vector<String> list = new Vector<String>();
+        getAllRecords((SysCAMSCompositeComponent)(tgc.getFather()), list);
+        return list;
+    }
+
+    public void getAllRecords(SysCAMSCompositeComponent comp,  Vector<String> list) {
+        TGComponent tgc;
+        if (comp == null) {
+            Iterator<TGComponent> iterator = componentList.listIterator();
+            while(iterator.hasNext()) {
+                tgc = iterator.next();
+                if (tgc instanceof SysCAMSRecordComponent) {
+                    list.add(tgc.getValue());
+                }
+            }
+            return;
+        }
+
+        for(int i=0; i<comp.getNbInternalTGComponent(); i++) {
+            tgc = comp.getInternalTGComponent(i);
+            if (tgc instanceof SysCAMSRecordComponent) {
+                list.add(tgc.getValue());
+            }
+        }
+        getAllRecords((SysCAMSCompositeComponent)(comp.getFather()), list);
+    }
+
+    public SysCAMSRecordComponent getRecordNamed(SysCAMSPrimitiveComponent tgc, String _nameOfRecord) {
+        return getRecordNamed((SysCAMSCompositeComponent)(tgc.getFather()), _nameOfRecord);
+    }
+
+    public SysCAMSRecordComponent getRecordNamed(SysCAMSCompositeComponent comp,  String _nameOfRecord) {
+        TGComponent tgc;
+        if (comp == null) {
+            Iterator<TGComponent> iterator = componentList.listIterator();
+            while(iterator.hasNext()) {
+                tgc = iterator.next();
+                if (tgc instanceof SysCAMSRecordComponent) {
+                    if (tgc.getValue().compareTo(_nameOfRecord) == 0) {
+                        return (SysCAMSRecordComponent)tgc;
+                    }
+                }
+            }
+            return null;
+        }
+        for(int i=0; i<comp.getNbInternalTGComponent(); i++) {
+            tgc = comp.getInternalTGComponent(i);
+            if (tgc instanceof SysCAMSRecordComponent) {
+                if (tgc.getValue().compareTo(_nameOfRecord) == 0) {
+                    return (SysCAMSRecordComponent)tgc;
+                }
+            }
+        }
+        return getRecordNamed((SysCAMSCompositeComponent)(comp.getFather()), _nameOfRecord);
+    }
+
+    public void findAllReferencedPanels( List<SysCAMSComponentTaskDiagramPanel> panels) {
+        if (panels.contains(this)) {
+            return;
+        }
+        panels.add(this);
+
+        Iterator<TGComponent> iterator = componentList.listIterator();
+        TGComponent tgc;
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+            if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+                SysCAMSRemoteCompositeComponent remote = (SysCAMSRemoteCompositeComponent)tgc;
+                TDiagramPanel panel = remote.getReferencedDiagram();
+                if ((panel != null) && (panel instanceof SysCAMSComponentTaskDiagramPanel)){
+                    ((SysCAMSComponentTaskDiagramPanel)panel).findAllReferencedPanels(panels);
+                }
+            }
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                //We must find all panels referencing this component
+                panels.addAll(mgui.getAllPanelsReferencingSysCAMSCompositeComponent((SysCAMSCompositeComponent)tgc));
+            }
+        }
+    }
+
+    public List<SysCAMSPath> makePaths() {
+        List<SysCAMSComponentTaskDiagramPanel> panels = new ArrayList<SysCAMSComponentTaskDiagramPanel>();
+
+        // We first find all the implicated panels
+        findAllReferencedPanels(panels);
+
+        List<SysCAMSPath> paths = new ArrayList<SysCAMSPath>();
+        Iterator<TGComponent> iterator;
+        TGComponent tgc;
+
+        // Go through the component list of all panels, and make paths. Then, go thru connectors,
+        // and merge paths until nomore merging is possible
+        for (TDiagramPanel panel: panels) {
+            iterator = panel.getComponentList().listIterator();
+            List<SysCAMSCompositePort> listcp;
+            List<SysCAMSPrimitivePort> listpp;
+
+            while(iterator.hasNext()) {
+                tgc = iterator.next();
+
+                if (tgc instanceof SysCAMSCompositeComponent) {
+                    listcp = ((SysCAMSCompositeComponent)tgc).getAllInternalCompositePorts();
+                    for(SysCAMSCompositePort cp: listcp) {
+                        addToPaths(paths, cp);
+                    }
+                    listpp = ((SysCAMSCompositeComponent)tgc).getAllInternalPrimitivePorts();
+                    for(SysCAMSPrimitivePort pp: listpp) {
+                        addToPaths(paths, pp);
+                    }
+                }
+                if (tgc instanceof SysCAMSPrimitiveComponent) {
+                    listpp = ((SysCAMSPrimitiveComponent)tgc).getAllInternalPrimitivePorts();
+                    for(SysCAMSPrimitivePort pp: listpp) {
+                        addToPaths(paths, pp);
+                    }
+                }
+                if (tgc instanceof SysCAMSPrimitivePort) {
+                    addToPaths(paths, tgc);
+                }
+                if (tgc instanceof SysCAMSChannelFacility) {
+                    addToPaths(paths, tgc);
+                }
+            }
+        }
+
+        // Use connectors to merge paths with one another
+        for (TDiagramPanel panel: panels) {
+            iterator = panel.getComponentList().listIterator();
+            SysCAMSPortConnector connector;
+            TGComponent tgc1, tgc2;
+            SysCAMSPath path1, path2;
+
+            while(iterator.hasNext()) {
+                tgc = iterator.next();
+                if (tgc instanceof SysCAMSPortConnector) {
+                    connector = (SysCAMSPortConnector)tgc;
+                    if (connector.getTGConnectingPointP1().getFather() instanceof TGComponent) {
+                        tgc1 = (TGComponent)(connector.getTGConnectingPointP1().getFather());
+                    } else {
+                        tgc1 = null;
+                    }
+                    if (connector.getTGConnectingPointP2().getFather() instanceof TGComponent) {
+                        tgc2 = (TGComponent)(connector.getTGConnectingPointP2().getFather());
+                    } else {
+                        tgc2 = null;
+                    }
+                    if (tgc1 instanceof SysCAMSRemoteCompositeComponent) {
+                        tgc1 = ((SysCAMSRemoteCompositeComponent)tgc1).getPortOf(connector.getTGConnectingPointP1());
+                    }
+                    if (tgc2 instanceof SysCAMSRemoteCompositeComponent) {
+                        tgc2 = ((SysCAMSRemoteCompositeComponent)tgc2).getPortOf(connector.getTGConnectingPointP2());
+                    }
+                    if ((tgc1 != null) && (tgc2 != null) && (tgc1 != tgc2)) {
+                        path1 = getPathOf(paths, tgc1);
+                        path2 = getPathOf(paths, tgc2);
+                        if ((path1 != null) && (path2 != null)) {
+                            // Not in the same path -> we must do a merging
+                            // and then we remove path2 from path
+                            if (path1 != path2) {
+                                path1.mergeWith(path2);
+                                paths.remove(path2);
+                            }
+                        }
+                    } else {
+                        // If there is a null component in the path, then, we must set an error in the path
+                        if ((tgc1 == null) && (tgc2 != null)) {
+                            path2 = getPathOf(paths, tgc2);
+                            path2.setErrorOfConnection(true);
+
+                        }
+                        if ((tgc2 == null) && (tgc1 != null)) {
+                            path1 = getPathOf(paths, tgc1);
+                            path1.setErrorOfConnection(true);
+                        }
+                    }
+                }
+            }
+        }
+        return paths;
+    }
+
+    public SysCAMSPath getPathOf( List<SysCAMSPath> paths, TGComponent tgc) {
+        for(SysCAMSPath path: paths) {
+            if (path.contains(tgc)) {
+                return path;
+            }
+        }
+        return null;
+    }
+
+    public void addToPaths( List<SysCAMSPath> paths, TGComponent tgc) {
+        for(SysCAMSPath path: paths) {
+            if (path.contains(tgc)) {
+                return;
+            }
+        }
+        // Create a new path
+        SysCAMSPath ph = new SysCAMSPath();
+        ph.addComponent(tgc);
+        paths.add(ph);
+    }
+
+
+    public void getPanelsUsingAComponent(SysCAMSCompositeComponent syscamscc, ArrayList<SysCAMSComponentTaskDiagramPanel> panels) {
+        Iterator<TGComponent> iterator = componentList.listIterator();
+        TGComponent tgc;
+
+        while(iterator.hasNext()) {
+            tgc = iterator.next();
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                if (((SysCAMSCompositeComponent)tgc).hasReferencesTo(syscamscc)) {
+                    panels.add(this);
+                    return;
+                }
+            }
+            if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+                if (((SysCAMSRemoteCompositeComponent)tgc).getReference() == syscamscc) {
+                    panels.add(this);
+                    return;
+                }
+            }
+        }
+    }
+
+    public String[] getAllOutDE(String nameOfComponent) {
+        SysCAMSPrimitiveComponent comp = getPrimitiveComponentByName(nameOfComponent);
+        if (comp == null) {
+            return null;
+        }
+        List<SysCAMSPrimitivePort> ll = comp.getAllDEOriginPorts();
+        String[]terms = new String[ll.size()];
+        Iterator<SysCAMSPrimitivePort> ite = ll.listIterator();
+        int i = 0;
+
+        while(ite.hasNext()) {
+            SysCAMSPrimitivePort port = ite.next();
+            terms[i] = port.getPortName();
+            i ++;
+        }
+        return terms;
+    }
+
+    public String[] getAllInDE(String nameOfComponent) {
+        SysCAMSPrimitiveComponent comp = getPrimitiveComponentByName(nameOfComponent);
+        if (comp == null) {
+            return null;
+        }
+        List<SysCAMSPrimitivePort> ll = comp.getAllDEDestinationPorts();
+        String[]terms = new String[ll.size()];
+        ListIterator<SysCAMSPrimitivePort> ite = ll.listIterator();
+        int i = 0;
+        while(ite.hasNext()) {
+            SysCAMSPrimitivePort port = ite.next();
+            terms[i] = port.getPortName();
+            i ++;
+        }
+        return terms;
+    }
+
+    public String[] getAllOutTDF(String nameOfComponent) {
+        SysCAMSPrimitiveComponent comp = getPrimitiveComponentByName(nameOfComponent);
+        if (comp == null) {
+            return null;
+        }
+        List<SysCAMSPrimitivePort> ll = comp.getAllTDFOriginPorts();
+        String[]terms = new String[ll.size()];
+        Iterator<SysCAMSPrimitivePort> ite = ll.listIterator();
+        int i = 0;
+        while(ite.hasNext()) {
+            SysCAMSPrimitivePort port = ite.next();
+            terms[i] = port.getPortName();
+            i++;
+        }
+        return terms;
+    }
+
+    public String[] getAllInTDF(String nameOfComponent) {
+        SysCAMSPrimitiveComponent comp = getPrimitiveComponentByName(nameOfComponent);
+        if (comp == null) {
+            return null;
+        }
+
+        List<SysCAMSPrimitivePort> ll = comp.getAllTDFDestinationPorts();
+        String[]terms = new String[ll.size()];
+        Iterator<SysCAMSPrimitivePort> ite = ll.listIterator();
+        int i = 0;
+
+        while(ite.hasNext()) {
+            SysCAMSPrimitivePort port = ite.next();
+            terms[i] = port.getPortName();
+            i++;
+        }
+        return terms;
+    }
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java b/src/main/resources/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java
new file mode 100644
index 0000000000..7f20e799aa
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java
@@ -0,0 +1,124 @@
+/* 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.syscams;
+
+import ui.MainGUI;
+import ui.TGUIAction;
+import ui.TToolBar;
+
+import javax.swing.*;
+
+/**
+ * Class SysCAMSComponentTaskDiagramToolBar Implements the toolbar to be used in
+ * conjunction with the panel of a SystemC-AMS diagram Creation: 22/04/2018
+ * 
+ * @version 1.0 22/04/2018
+ * @author Irina Kit Yan LEE
+ * @see SysCAMSComponentTaskDiagramPanel
+ */
+
+@SuppressWarnings("serial")
+
+public class SysCAMSComponentTaskDiagramToolBar extends TToolBar {
+
+	public SysCAMSComponentTaskDiagramToolBar(MainGUI _mgui) {
+		super(_mgui);
+	}
+
+	protected void setActive(boolean b) {
+		mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(b);
+		mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(b);
+
+		mgui.actions[TGUIAction.CAMS_EDIT].setEnabled(b);
+		mgui.actions[TGUIAction.UML_NOTE].setEnabled(b);
+		mgui.actions[TGUIAction.CAMS_CONNECTOR].setEnabled(b);
+		mgui.actions[TGUIAction.CAMS_BLOCK_TDF].setEnabled(b);
+		mgui.actions[TGUIAction.CAMS_BLOCK_DE].setEnabled(b);
+		mgui.actions[TGUIAction.CAMS_PORT_TDF].setEnabled(b);
+		mgui.actions[TGUIAction.CAMS_PORT_DE].setEnabled(b);
+		mgui.actions[TGUIAction.CAMS_PORT_CONVERTER].setEnabled(b);
+		mgui.actions[TGUIAction.CAMS_CLUSTER].setEnabled(b);
+
+		mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b);
+		mgui.actions[TGUIAction.ACT_ONECLICK_LOTOS_RG].setEnabled(b);
+		mgui.actions[TGUIAction.ACT_SIMU_SYSTEMC].setEnabled(b);
+		
+		mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(b);
+		mgui.updateZoomInfo();
+	}
+
+	protected void setButtons() {
+		JButton button;
+
+		button = this.add(mgui.actions[TGUIAction.CAMS_EDIT]);
+		button.addMouseListener(mgui.mouseHandler);
+
+		button = this.add(mgui.actions[TGUIAction.UML_NOTE]);
+		button.addMouseListener(mgui.mouseHandler);
+
+		this.addSeparator();
+		
+		button = this.add(mgui.actions[TGUIAction.CAMS_CLUSTER]);
+		button.addMouseListener(mgui.mouseHandler);
+		
+		button = this.add(mgui.actions[TGUIAction.CAMS_PORT_CONVERTER]);
+		button.addMouseListener(mgui.mouseHandler);
+		
+		this.addSeparator();
+		
+		button = this.add(mgui.actions[TGUIAction.CAMS_BLOCK_TDF]);
+		button.addMouseListener(mgui.mouseHandler);
+		
+		button = this.add(mgui.actions[TGUIAction.CAMS_PORT_TDF]);
+		button.addMouseListener(mgui.mouseHandler);
+		
+		this.addSeparator();
+				
+		button = this.add(mgui.actions[TGUIAction.CAMS_BLOCK_DE]);
+		button.addMouseListener(mgui.mouseHandler);
+		
+		button = this.add(mgui.actions[TGUIAction.CAMS_PORT_DE]);
+		button.addMouseListener(mgui.mouseHandler);
+		
+		this.addSeparator();
+		
+		button = this.add(mgui.actions[TGUIAction.CAMS_CONNECTOR]);
+		button.addMouseListener(mgui.mouseHandler);
+	}
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSCompositeComponent.java b/src/main/resources/ui/syscams/SysCAMSCompositeComponent.java
new file mode 100644
index 0000000000..fddb4ac31a
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSCompositeComponent.java
@@ -0,0 +1,633 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import ui.*;
+import ui.util.IconManager;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.ListIterator;
+
+/**
+ * Class SysCAMSCompositeComponent
+ * Composite Component. To be used in SystemC-AMS diagrams
+ * Creation: 27/04/2018
+ *
+ * @author Irina Kit Yan LEE
+ * @version 1.0 27/04/2018
+ */
+
+public class SysCAMSCompositeComponent extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent, HiddenInternalComponents {
+    private int maxFontSize = 20;
+    private int minFontSize = 4;
+    private int currentFontSize = -1;
+    private boolean displayText = true;
+    private Color myColor;
+    private int iconSize = 17;
+
+    private int textX = 15; // border for ports
+    private double dtextX = 0.0;
+
+    private boolean hiddeni;
+
+    private int compositePortNb = 0;
+
+    public SysCAMSCompositeComponent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+
+        initScaling(250, 200);
+
+        oldScaleFactor = tdp.getZoom();
+        dtextX = textX * oldScaleFactor;
+        textX = (int) dtextX;
+        dtextX = dtextX - textX;
+
+        minWidth = 1;
+        minHeight = 1;
+
+        nbConnectingPoint = 0;
+        addTGConnectingPointsComment();
+
+        nbInternalTGComponent = 0;
+
+        maxWidth = 2000;
+        maxHeight = 2000;
+
+        moveable = true;
+        editable = true;
+        removable = true;
+        userResizable = true;
+
+        value = "Cluster";
+        name = "Composite component";
+
+        myImageIcon = IconManager.imgic1200;
+    }
+
+    public void internalDrawing(Graphics g) {
+        int w;
+        int c;
+        Font f = g.getFont();
+        Font fold = f;
+
+        if (myColor == null) {
+            if (ColorManager.TML_COMPOSITE_COMPONENT == Color.white) {
+                myColor = Color.white;
+            } else {
+                myColor = Color.white;
+            }
+        }
+        if ((rescaled) && (!tdp.isScaled())) {
+            if (currentFontSize == -1) {
+                currentFontSize = f.getSize();
+            }
+            rescaled = false;
+            // Must set the font size ..
+            // Find the biggest font not greater than max_font size
+            // By Increment of 1
+            // Or decrement of 1
+            // If font is less than 4, no text is displayed
+
+            int maxCurrentFontSize = Math.max(0, Math.min(height - (2 * textX), maxFontSize));
+
+            while (maxCurrentFontSize > (minFontSize - 1)) {
+                f = f.deriveFont((float) maxCurrentFontSize);
+                g.setFont(f);
+                w = g.getFontMetrics().stringWidth(value);
+                c = width - iconSize - (2 * textX);
+                if (w < c) {
+                    break;
+                }
+                maxCurrentFontSize--;
+            }
+            currentFontSize = maxCurrentFontSize;
+            displayText = currentFontSize >= minFontSize;
+        }
+        // Zoom is assumed to be computed
+        Color col = g.getColor();
+        g.drawRect(x, y, width, height);
+        if ((width > 2) && (height > 2)) {
+            g.setColor(myColor);
+            g.fillRect(x + 1, y + 1, width - 1, height - 1);
+            g.setColor(col);
+        }
+        // Font size 
+        if (displayText) {
+            f = f.deriveFont((float) currentFontSize);
+            g.setFont(f);
+            w = g.getFontMetrics().stringWidth(value);
+            if (!(w < (width - 2 * (iconSize + textX)))) {
+                g.drawString(value, x + textX + 1, y + currentFontSize + textX);
+            } else {
+                g.drawString(value, x + (width - w) / 2, y + currentFontSize + textX);
+            }
+        }
+        g.setFont(fold);
+//		// Icon
+//		if ((width>30) && (height > (iconSize + 2*textX))) {
+//			g.drawImage(IconManager.imgic1200.getImage(), x + width - iconSize - textX, y + textX, null);
+//		}
+    }
+
+    public void rescale(double scaleFactor) {
+        dtextX = (textX + dtextX) / oldScaleFactor * scaleFactor;
+        textX = (int) (dtextX);
+        dtextX = dtextX - textX;
+        super.rescale(scaleFactor);
+    }
+
+    public TGComponent isOnOnlyMe(int _x, int _y) {
+        if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) {
+            return this;
+        }
+        return null;
+    }
+
+    public boolean editOndoubleClick(JFrame frame) {
+        String s = (String) JOptionPane.showInputDialog(frame, "Name:", "Setting component name",
+                JOptionPane.PLAIN_MESSAGE, IconManager.imgic100,
+                null,
+                getValue());
+        if ((s != null) && (s.length() > 0)) {
+            if (!TAttribute.isAValidId(s, false, false)) {
+                JOptionPane.showMessageDialog(frame,
+                        "Could not change the name of the component: the new name is not a valid name",
+                        "Error",
+                        JOptionPane.INFORMATION_MESSAGE);
+                return false;
+            }
+            if (((SysCAMSComponentTaskDiagramPanel) (tdp)).isCompositeNameUsed(s)) {
+                JOptionPane.showMessageDialog(frame,
+                        "Error: the name is already in use",
+                        "Name modification",
+                        JOptionPane.ERROR_MESSAGE);
+                return false;
+            }
+            setValueWithChange(s);
+            return true;
+        }
+        return false;
+    }
+
+    public int getType() {
+        return TGComponentManager.CAMS_CLUSTER;
+    }
+
+    public void wasSwallowed() {
+        myColor = null;
+    }
+
+    public void wasUnswallowed() {
+        myColor = null;
+        setFather(null);
+        TDiagramPanel tdp = getTDiagramPanel();
+        setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY());
+    }
+
+    public boolean acceptSwallowedTGComponent(TGComponent tgc) {
+        if (tgc instanceof SysCAMSCompositeComponent) {
+            return true;
+        }
+        if (tgc instanceof SysCAMSRecordComponent) {
+            return true;
+        }
+        if (tgc instanceof SysCAMSPrimitiveComponent) {
+            return true;
+        }
+        if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+            return true;
+        }
+        return tgc instanceof SysCAMSCompositePort;
+    }
+
+    public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) {
+        boolean swallowed = false;
+
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SwallowTGComponent) {
+                if (((SwallowTGComponent) tgcomponent[i]).acceptSwallowedTGComponent(tgc)) {
+                    if (tgcomponent[i].isOnMe(x, y) != null) {
+                        swallowed = true;
+                        ((SwallowTGComponent) tgcomponent[i]).addSwallowedTGComponent(tgc, x, y);
+                        break;
+                    }
+                }
+            }
+        }
+        if (swallowed) {
+            return true;
+        }
+        if (!acceptSwallowedTGComponent(tgc)) {
+            return false;
+        }
+        // Choose its position
+
+        // Make it an internal component
+        // It's one of my son
+        tgc.setFather(this);
+        tgc.setDrawingZone(true);
+
+        //Set its coordinates
+        if (tgc instanceof SysCAMSCompositeComponent) {
+            tgc.resizeWithFather();
+        }
+
+        if (tgc instanceof SysCAMSRecordComponent) {
+            tgc.resizeWithFather();
+        }
+
+        if (tgc instanceof SysCAMSPrimitiveComponent) {
+            tgc.resizeWithFather();
+        }
+
+        if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+            tgc.resizeWithFather();
+        }
+        if (tgc instanceof SysCAMSCompositePort) {
+            tgc.resizeWithFather();
+            compositePortNb++;
+        }
+        //add it
+        addInternalComponent(tgc, 0);
+        return true;
+    }
+
+    public void removeSwallowedTGComponent(TGComponent tgc) {
+        if (tgc instanceof SysCAMSCompositePort) {
+            portRemoved();
+        }
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] == tgc) {
+                nbInternalTGComponent = nbInternalTGComponent - 1;
+                if (nbInternalTGComponent == 0) {
+                    tgcomponent = null;
+                } else {
+                    TGComponent[] tgcomponentbis = new TGComponent[nbInternalTGComponent];
+                    for (int j = 0; j < nbInternalTGComponent; j++) {
+                        if (j < i) {
+                            tgcomponentbis[j] = tgcomponent[j];
+                        }
+                        if (j >= i) {
+                            tgcomponentbis[j] = tgcomponent[j + 1];
+                        }
+                    }
+                    tgcomponent = tgcomponentbis;
+                }
+                break;
+            }
+        }
+    }
+
+    public void hasBeenResized() {
+        rescaled = true;
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                tgcomponent[i].resizeWithFather();
+            }
+            if (tgcomponent[i] instanceof SysCAMSPrimitiveComponent) {
+                tgcomponent[i].resizeWithFather();
+            }
+            if (tgcomponent[i] instanceof SysCAMSRecordComponent) {
+                tgcomponent[i].resizeWithFather();
+            }
+            if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) {
+                tgcomponent[i].resizeWithFather();
+            }
+            if (tgcomponent[i] instanceof SysCAMSCompositePort) {
+                tgcomponent[i].resizeWithFather();
+            }
+        }
+        if (getFather() != null) {
+            resizeWithFather();
+        }
+    }
+
+    public void resizeWithFather() {
+        if ((father != null) && ((father instanceof SysCAMSCompositeComponent) || (father instanceof SysCAMSPrimitiveComponent))) {
+            // Too large to fit in the father? -> resize it!
+            resizeToFatherSize();
+
+            setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight());
+            setMoveCd(x, y);
+        }
+    }
+
+    public java.util.List<SysCAMSPrimitiveComponent> getAllPrimitiveComponents() {
+        ArrayList<SysCAMSPrimitiveComponent> ll = new ArrayList<SysCAMSPrimitiveComponent>();
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                ll.addAll(((SysCAMSCompositeComponent) tgcomponent[i]).getAllPrimitiveComponents());
+            }
+            if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) {
+                ll.addAll(((SysCAMSRemoteCompositeComponent) tgcomponent[i]).getAllPrimitiveComponents());
+            }
+            if (tgcomponent[i] instanceof SysCAMSPrimitiveComponent) {
+                ll.add(((SysCAMSPrimitiveComponent) (tgcomponent[i])));
+            }
+        }
+        return ll;
+    }
+
+    public ArrayList<SysCAMSRecordComponent> getAllRecordComponents() {
+        ArrayList<SysCAMSRecordComponent> ll = new ArrayList<SysCAMSRecordComponent>();
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                ll.addAll(((SysCAMSCompositeComponent) tgcomponent[i]).getAllRecordComponents());
+            }
+            if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) {
+                ll.addAll(((SysCAMSRemoteCompositeComponent) tgcomponent[i]).getAllRecordComponents());
+            }
+
+            if (tgcomponent[i] instanceof SysCAMSRecordComponent) {
+                ll.add(((SysCAMSRecordComponent) (tgcomponent[i])));
+            }
+        }
+        return ll;
+    }
+
+    public void getAllCompositeComponents(ArrayList<String> list, String _name) {
+        String s;
+        SysCAMSCompositeComponent syscamscc;
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                syscamscc = (SysCAMSCompositeComponent) tgcomponent[i];
+                s = _name + "::" + syscamscc.getValue();
+                list.add(s);
+                syscamscc.getAllCompositeComponents(list, _name);
+            }
+        }
+    }
+
+    public ArrayList<SysCAMSCompositePort> getAllInternalCompositePorts() {
+        ArrayList<SysCAMSCompositePort> list = new ArrayList<SysCAMSCompositePort>();
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                list.addAll(((SysCAMSCompositeComponent) tgcomponent[i]).getAllInternalCompositePorts());
+            }
+            if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) {
+                list.addAll(((SysCAMSRemoteCompositeComponent) tgcomponent[i]).getAllInternalCompositePorts());
+            }
+            if (tgcomponent[i] instanceof SysCAMSCompositePort) {
+                list.add((SysCAMSCompositePort) (tgcomponent[i]));
+            }
+        }
+        return list;
+    }
+
+    public ArrayList<SysCAMSCompositePort> getAllReferencedCompositePorts() {
+        ArrayList<SysCAMSCompositePort> list = new ArrayList<SysCAMSCompositePort>();
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                list.addAll(((SysCAMSCompositeComponent) tgcomponent[i]).getAllReferencedCompositePorts());
+            }
+            if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) {
+                list.addAll(((SysCAMSRemoteCompositeComponent) tgcomponent[i]).getAllInternalCompositePorts());
+            }
+        }
+        return list;
+    }
+
+    public ArrayList<SysCAMSCompositePort> getFirstLevelCompositePorts() {
+        ArrayList<SysCAMSCompositePort> list = new ArrayList<SysCAMSCompositePort>();
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositePort) {
+                list.add((SysCAMSCompositePort) (tgcomponent[i]));
+            }
+        }
+        return list;
+    }
+
+    public ArrayList<SysCAMSPrimitivePort> getAllInternalPrimitivePorts() {
+        ArrayList<SysCAMSPrimitivePort> list = new ArrayList<SysCAMSPrimitivePort>();
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                list.addAll(((SysCAMSCompositeComponent) tgcomponent[i]).getAllInternalPrimitivePorts());
+            }
+            if (tgcomponent[i] instanceof SysCAMSPrimitiveComponent) {
+                list.addAll(((SysCAMSPrimitiveComponent) tgcomponent[i]).getAllInternalPrimitivePorts());
+            }
+        }
+        return list;
+    }
+
+    public SysCAMSPrimitiveComponent getPrimitiveComponentByName(String _name) {
+        SysCAMSPrimitiveComponent tgc;
+        ListIterator<SysCAMSPrimitiveComponent> li = getAllPrimitiveComponents().listIterator();
+
+        while (li.hasNext()) {
+            tgc = li.next();
+            if (tgc.getValue().equals(_name)) {
+                return tgc;
+            }
+        }
+        return null;
+    }
+
+    public SysCAMSCompositeComponent getCompositeComponentByName(String _name) {
+        TGComponent tgc;
+        SysCAMSCompositeComponent tmp;
+
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            tgc = tgcomponent[i];
+            if (tgc instanceof SysCAMSCompositeComponent) {
+                tmp = (SysCAMSCompositeComponent) tgc;
+                if (tmp.getValue().equals(_name)) {
+                    return tmp;
+                }
+
+                if ((tmp = tmp.getCompositeComponentByName(name)) != null) {
+                    return tmp;
+                }
+            }
+        }
+        return null;
+    }
+
+    public void setInternalsHidden(boolean hide) {
+        hiddeni = hide;
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (!(tgcomponent[i] instanceof SysCAMSCompositePort)) {
+                tgcomponent[i].setHidden(hide);
+            }
+        }
+
+        if (tdp instanceof SysCAMSComponentTaskDiagramPanel) {
+            ((SysCAMSComponentTaskDiagramPanel) tdp).hideConnectors();
+        }
+    }
+
+    public boolean areInternalsHidden() {
+        return hiddeni;
+    }
+
+    public void drawInternalComponentsWhenHidden(Graphics g) {
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositePort) {
+                tgcomponent[i].draw(g);
+            }
+        }
+    }
+
+    protected String translateExtraParam() {
+        StringBuffer sb = new StringBuffer("<extraparam>\n");
+        sb.append("<info hiddeni=\"" + hiddeni + "\" ");
+        sb.append("/>\n");
+        sb.append("</extraparam>\n");
+        return new String(sb);
+    }
+
+    public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException {
+        try {
+            NodeList nli;
+            Node n1, n2;
+            Element elt;
+
+            for (int i = 0; i < nl.getLength(); i++) {
+                n1 = nl.item(i);
+                if (n1.getNodeType() == Node.ELEMENT_NODE) {
+                    nli = n1.getChildNodes();
+                    for (int j = 0; j < nli.getLength(); j++) {
+                        n2 = nli.item(j);
+                        if (n2.getNodeType() == Node.ELEMENT_NODE) {
+                            elt = (Element) n2;
+                            if (elt.getTagName().equals("info")) {
+                                if (elt.getAttribute("hiddeni").equals("true")) {
+                                    setInternalsHidden(true);
+                                }
+                            }
+
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            throw new MalformedModelingException();
+        }
+    }
+
+    public void drawTGConnectingPoint(Graphics g, int type) {
+        for (int i = 0; i < nbConnectingPoint; i++) {
+            if (connectingPoint[i].isCompatibleWith(type)) {
+                connectingPoint[i].draw(g);
+            }
+        }
+
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (hiddeni) {
+                if (tgcomponent[i] instanceof SysCAMSCompositePort) {
+                    tgcomponent[i].drawTGConnectingPoint(g, type);
+                }
+            } else {
+                tgcomponent[i].drawTGConnectingPoint(g, type);
+            }
+        }
+    }
+
+    public String getExtendedValue() {
+        return getValuePanel() + "::" + getValue();
+    }
+
+    public void myActionWhenRemoved() {
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                tgcomponent[i].myActionWhenRemoved();
+            }
+        }
+        tdp = null;
+    }
+
+    public void updateReferenceToSysCAMSCompositeComponent(SysCAMSCompositeComponent syscamscc) {
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) {
+                ((SysCAMSRemoteCompositeComponent) tgcomponent[i]).updateReference(syscamscc);
+            }
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                ((SysCAMSCompositeComponent) tgcomponent[i]).updateReferenceToSysCAMSCompositeComponent(syscamscc);
+            }
+        }
+    }
+
+    public void delayedLoad() {
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) {
+                try {
+                    ((SysCAMSRemoteCompositeComponent) tgcomponent[i]).delayedLoad();
+                } catch (Exception e) {
+                }
+            }
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                ((SysCAMSCompositeComponent) tgcomponent[i]).delayedLoad();
+            }
+        }
+    }
+
+    public int getCompositePortNb() {
+        return compositePortNb;
+    }
+
+    public void portRemoved() {
+        compositePortNb--;
+    }
+
+    public boolean hasReferencesTo(SysCAMSCompositeComponent syscamscc) {
+        boolean b;
+
+        for (int i = 0; i < nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) {
+                b = ((SysCAMSRemoteCompositeComponent) tgcomponent[i]).getReference() == syscamscc;
+                if (b) {
+                    return true;
+                }
+            }
+            if (tgcomponent[i] instanceof SysCAMSCompositeComponent) {
+                b = ((SysCAMSCompositeComponent) tgcomponent[i]).hasReferencesTo(syscamscc);
+                if (b) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSCompositePort.java b/src/main/resources/ui/syscams/SysCAMSCompositePort.java
new file mode 100644
index 0000000000..5a8ac86da5
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSCompositePort.java
@@ -0,0 +1,325 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+import ui.*;
+import ui.util.IconManager;
+import ui.window.JDialogSysCAMSPortConverter;
+
+import java.awt.*;
+import javax.swing.ImageIcon;
+import javax.swing.JFrame;
+
+/**
+ * Class SysCAMSCompositePort
+ * Composite port. To be used in SystemC-AMS diagrams
+ * Creation: 29/04/2018
+ * @version 1.0 29/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSCompositePort extends SysCAMSChannelFacility implements SwallowedTGComponent, WithAttributes {
+	private int oldx, oldy;
+	private int halfwidth = 13;
+	private int currentOrientation = GraphicLib.NORTH;
+	protected int decPoint = 3;
+	private ImageIcon portImageIconW, portImageIconE, portImageIconN, portImageIconS;
+	public String commName;
+    
+	// Attributes
+    public String portName;
+    public int period;
+    public int rate;
+    public int delay;
+    public String type;
+    public String origin;
+	
+    public SysCAMSCompositePort(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+        
+		initScaling(2*halfwidth, 2*halfwidth);
+		
+        minWidth = 10;
+        minHeight = 10;
+        
+        nbConnectingPoint = 10;
+        connectingPoint = new TGConnectingPoint[10];
+		int i;
+		for (i=0; i<5; i++) {
+			connectingPoint[i] = new SysCAMSPortConnectingPoint(this, 0, 0, true, true, 0.5, 0.0);
+		}
+		for(i=5; i<10; i++) {
+			connectingPoint[i] = new SysCAMSPortConnectingPoint(this, 0, 0, true, true, 0.5, 1.0);
+		}
+        
+        addTGConnectingPointsComment();
+        
+        nbInternalTGComponent = 0;
+        
+		value = "";
+		name = "Composite port";
+		commName = "port";
+		
+        myImageIcon = IconManager.imgic1204;
+        portImageIconW = IconManager.imgic8002; 
+        portImageIconE = IconManager.imgic8003; 
+        portImageIconN = IconManager.imgic8004; 
+        portImageIconS = IconManager.imgic8005; 
+        
+        // Initialization of port attributes
+    	((SysCAMSPortConverter) this).setPeriod(0);
+    	((SysCAMSPortConverter) this).setDelay(0);
+    	((SysCAMSPortConverter) this).setRate(0);
+    	((SysCAMSPortConverter) this).setConvType("");
+    	((SysCAMSPortConverter) this).setOrigin("");
+    }
+    
+    public void internalDrawing(Graphics g) {
+		if ((x != oldx) | (oldy != y)) {
+			// Component has moved!
+			manageMove();
+			oldx = x;
+			oldy = y;
+		}
+		if (rescaled) {
+			rescaled = false;	
+		}
+		
+		calculatePortColor();
+		
+		// Zoom is assumed to be computed
+		Color c = g.getColor();
+		g.setColor(c);
+		
+		TGComponent tgc = getFather();
+		
+        if ((tgc != null) && (tgc instanceof SysCAMSCompositeComponent)) {
+        	if (tgc instanceof SysCAMSCompositeComponent && this instanceof SysCAMSCompositePort) {
+        		switch(currentOrientation) {
+                case GraphicLib.NORTH:
+            		g.drawRect(x-1+width/2-portImageIconN.getIconWidth()/2, y-1+height/2-portImageIconN.getIconHeight()/2, portImageIconN.getIconWidth()+2, portImageIconN.getIconHeight()+2);
+             		g.drawImage(portImageIconN.getImage(), x+width/2-portImageIconN.getIconWidth()/2, y+height/2-portImageIconN.getIconHeight()/2, null);
+                	break;
+                case GraphicLib.SOUTH:
+            		g.drawRect(x+width/2-portImageIconS.getIconWidth()/2, y+height/2-portImageIconS.getIconHeight()/2, portImageIconS.getIconWidth(), portImageIconS.getIconHeight());
+             		g.drawImage(portImageIconS.getImage(), x+width/2-portImageIconS.getIconWidth()/2, y+height/2-portImageIconS.getIconHeight()/2, null);
+                	break;
+                case GraphicLib.WEST:
+            		g.drawRect(x+width/2-portImageIconW.getIconWidth()/2, y+height/2-portImageIconW.getIconHeight()/2, portImageIconW.getIconWidth(), portImageIconW.getIconHeight());
+             		g.drawImage(portImageIconW.getImage(), x+width/2-portImageIconW.getIconWidth()/2, y+height/2-portImageIconW.getIconHeight()/2, null);
+                	break;
+                case GraphicLib.EAST:
+                default:
+            		g.drawRect(x+width/2-portImageIconE.getIconWidth()/2, y+height/2-portImageIconE.getIconHeight()/2, portImageIconE.getIconWidth(), portImageIconE.getIconHeight());
+             		g.drawImage(portImageIconE.getImage(), x+width/2-portImageIconE.getIconWidth()/2, y+height/2-portImageIconE.getIconHeight()/2, null);
+                }
+        	}
+        }
+		
+        int ft = 10;
+        if ((tgc != null) && (tgc instanceof SysCAMSPrimitiveComponent)) {
+            ft = ((SysCAMSPrimitiveComponent)tgc).getCurrentFontSize();
+        }
+        int w;
+        Font f = g.getFont();
+        Font fold = f;
+
+        int si = Math.min(8, (int)((float)ft - 2));
+        f = f.deriveFont((float)si);
+        g.setFont(f);
+        w = g.getFontMetrics().stringWidth(commName);
+        if (w < ((int)(width * 1.5))) {
+            g.drawString(commName, x, y-1);
+        }
+        
+        g.setFont(fold);
+        
+		// Draw arrow showing the connection if necessary
+		if ((!conflict) && (outp != null || inp != null)) {
+			int wayTo = currentOrientation;
+			if (inp != null) {
+				if (inpIndex > 4) {
+					wayTo = (wayTo + 2 )% 4;
+				} 
+			} else {
+				if (outpIndex < 5) {
+					wayTo = (wayTo + 2 )% 4;
+				}
+			}
+			
+			int []px = new int[3];
+			int []py = new int[3];
+			switch(wayTo) {
+				case GraphicLib.NORTH:
+				case GraphicLib.SOUTH:
+					px[0] = x+width/2;
+					px[1] = x +width/2;
+					py[0] = y;
+					py[1] = y + height;
+					break;
+				case GraphicLib.EAST:
+				case GraphicLib.WEST:
+				default:
+					px[0] = x;
+					px[1] = x +width;
+					py[0] = y+height/2;
+					py[1] = y + height/2;
+					break;
+			}
+			g.drawPolygon(px, py, 2);
+		}
+    }
+	
+	public void manageMove() {
+		if (father != null) {
+			Point p = GraphicLib.putPointOnRectangle(x+(width/2), y+(height/2), father.getX(), father.getY(), father.getWidth(), father.getHeight());
+			
+			x = p.x - width/2;
+			y = p.y - height/2;
+			
+			setMoveCd(x, y);
+			
+			int orientation = GraphicLib.getCloserOrientation(x+(width/2), y+(height/2), father.getX(), father.getY(), father.getWidth(), father.getHeight());
+			if (orientation != currentOrientation) {
+				setOrientation(orientation);
+			}
+		}
+	}
+	
+	// TGConnecting points ..
+	public void setOrientation(int orientation) {
+		currentOrientation = orientation;
+		double w0, h0,w1, h1; 
+		
+		switch(orientation) {
+			case GraphicLib.NORTH:
+				w0 = 0.5;
+				h0 = 0.0;
+				w1 = 0.5;
+				h1 = 1.0;
+				break;
+			case GraphicLib.WEST:
+				w0 = 0.0;
+				h0 = 0.5;
+				w1 = 1.0;
+				h1 = 0.5;
+				break;
+			case GraphicLib.SOUTH:
+				w1 = 0.5;
+				h1 = 0.0;
+				w0 = 0.5;
+				h0 = 1.0;
+				break;
+			case GraphicLib.EAST:
+			default:
+				w1 = 0.0;
+				h1 = 0.5;
+				w0 = 1.0;
+				h0 = 0.5;
+		}
+		
+		for (int i=0; i<5; i++) {
+			((SysCAMSPortConnectingPoint)(connectingPoint[i])).setW(w0);
+			((SysCAMSPortConnectingPoint)(connectingPoint[i])).setH(h0);
+			((SysCAMSPortConnectingPoint)(connectingPoint[i+5])).setW(w1);
+			((SysCAMSPortConnectingPoint)(connectingPoint[i+5])).setH(h1);
+		}
+	}
+    
+    public int getType() {
+        return TGComponentManager.TMLCTD_CPORT;
+    }
+	
+	public void wasSwallowed() {
+		myColor = null;
+	}
+	
+	public void wasUnswallowed() {
+		myColor = null;
+		setFather(null);
+		TDiagramPanel tdp = getTDiagramPanel();
+		setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY());
+	}
+	
+	public void resizeWithFather() {
+        if ((father != null) && (father instanceof SysCAMSCompositeComponent)) {
+			// Too large to fit in the father? -> resize it!
+            setCdRectangle(0-getWidth()/2, father.getWidth() - (getWidth()/2), 0-getHeight()/2, father.getHeight() - (getHeight()/2));
+            setMoveCd(x, y);
+			oldx = -1;
+			oldy = -1;
+        }
+    }
+	
+	public boolean editOndoubleClick(JFrame frame) {
+		JDialogSysCAMSPortConverter jtdf = new JDialogSysCAMSPortConverter((SysCAMSPortConverter) this);
+		jtdf.setVisible(true);
+    	
+        ((SysCAMSComponentTaskDiagramPanel)tdp).updatePorts();
+        return true;
+    }
+	
+	public String getPortName() {
+        return commName;
+    }
+	
+	public void setPortName(String s) {
+		commName = s;
+	}
+	
+	public void purge() {
+		inp = null;
+		outp = null;
+		conflict = false;
+		inpIndex = -1;
+		outpIndex = -1;
+		myColor = null;
+		calculatePortColor();
+	}
+	
+	public void myActionWhenRemoved() {
+		tdp = null;
+		TGComponent tgc =  getFather();
+		if (tgc instanceof SysCAMSCompositeComponent) {
+			((SysCAMSCompositeComponent)(tgc)).portRemoved();
+		}
+		father = null;
+	}
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSFork.java b/src/main/resources/ui/syscams/SysCAMSFork.java
new file mode 100644
index 0000000000..b3ec86bac7
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSFork.java
@@ -0,0 +1,111 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+import ui.*;
+import ui.util.IconManager;
+
+import java.awt.*;
+
+/**
+ * Class SysCAMSFork
+ * Fork operator. To be used in SystemC-AMS component task diagrams
+ * Creation: 22/04/2018
+ * @version 1.0 22/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSFork extends SysCAMSChannelFacility implements WithAttributes {
+    protected int radius = 11;
+    protected int decPoint = 3;
+
+    public SysCAMSFork(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+
+        initScaling(2*radius, 2*radius);
+
+        nbConnectingPoint = 7;
+        connectingPoint = new TGConnectingPoint[7];
+
+        connectingPoint[0] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.0, 0.5);
+        connectingPoint[1] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 1.0, 0.5);
+        connectingPoint[2] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 1.0, 0.5);
+        connectingPoint[3] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 0.75, 0.134);
+        connectingPoint[4] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 0.75, 0.134);
+        connectingPoint[5] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 0.75, 0.866);
+        connectingPoint[6] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 0.75, 0.866);
+
+        addTGConnectingPointsComment();
+
+        nbInternalTGComponent = 0;
+
+        value = "F";
+        name = "Composite port";
+
+        myImageIcon = IconManager.imgic1204;
+    }
+
+    public void internalDrawing(Graphics g) {
+    	radius = width / 2;
+
+        if (rescaled) {
+            rescaled = false;
+        }
+        calculatePortColor();
+
+        // Zoom is assumed to be computed
+        Color c = g.getColor();
+        if ((width > 2) && (height > 2)) {
+            g.setColor(myColor);
+            g.fillOval(x, y, radius*2, radius*2);
+            g.setColor(c);
+        }
+        g.drawOval(x, y, radius*2, radius*2);
+        g.drawLine(x, y+radius, x+radius, y+radius);
+
+        GraphicLib.arrowWithLine(g, 1, 1, 5, x+radius, y+radius, x+2*radius, y+radius, false);
+        GraphicLib.arrowWithLine(g, 1, 1, 5, x+radius, y+radius, x+3*radius/2, (int)(y+(0.134*radius)), false);
+        GraphicLib.arrowWithLine(g, 1, 1, 5, x+radius, y+radius, x+3*radius/2, (int)(y+2*radius-(0.134*radius)), false);
+    }
+
+    public int getType() {
+        return TGComponentManager.TMLCTD_FORK;
+    }
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSJoin.java b/src/main/resources/ui/syscams/SysCAMSJoin.java
new file mode 100644
index 0000000000..7bd2da8532
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSJoin.java
@@ -0,0 +1,115 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+import ui.*;
+import ui.util.IconManager;
+
+import java.awt.*;
+
+/**
+ * Class SysCAMSJoin
+ * Join operator. To be used in SystemC-AMS component task diagrams
+ * Creation: 22/04/2018
+ * @version 1.0 22/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSJoin extends SysCAMSChannelFacility implements WithAttributes {
+    protected int radius = 11;
+    protected int decPoint = 3;
+
+    public SysCAMSJoin(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+
+        initScaling(2*radius, 2*radius);
+
+        nbConnectingPoint = 7;
+        connectingPoint = new TGConnectingPoint[7];
+
+        // output
+        connectingPoint[0] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 1.0, 0.5);
+        // input
+        connectingPoint[1] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.0, 0.5);
+        connectingPoint[2] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.0, 0.5);
+        connectingPoint[3] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.25, 0.134);
+        connectingPoint[4] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.25, 0.134);
+        connectingPoint[5] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.25, 0.866);
+        connectingPoint[6] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.25, 0.866);
+
+        addTGConnectingPointsComment();
+
+        nbInternalTGComponent = 0;
+
+        value = "J";
+        name = "Composite port";
+
+        myImageIcon = IconManager.imgic1204;
+    }
+
+    public void internalDrawing(Graphics g) {
+
+	radius = width / 2;
+
+        if (rescaled) {
+            rescaled = false;
+        }
+
+        calculatePortColor();
+
+        // Zoom is assumed to be computed
+        Color c = g.getColor();
+        if ((width > 2) && (height > 2)) {
+            g.setColor(myColor);
+            g.fillOval(x, y, radius*2, radius*2);
+            g.setColor(c);
+        }
+        g.drawOval(x, y, radius*2, radius*2);
+        g.drawLine(x, y+radius, x+radius, y+radius);
+        g.drawLine(x+radius/2, (int)(y+(0.134*radius)), x+radius, y+radius);
+        g.drawLine(x+radius/2, (int)(y+2*radius-(0.134*radius)), x+radius, y+radius);
+
+        GraphicLib.arrowWithLine(g, 1, 1, 5, x+radius, y+radius, x+2*radius, y+radius, false);
+    }
+
+    public int getType() {
+        return TGComponentManager.TMLCTD_JOIN;
+    }
+}
diff --git a/src/main/resources/ui/syscams/SysCAMSPath.java b/src/main/resources/ui/syscams/SysCAMSPath.java
new file mode 100644
index 0000000000..9b05b7de2d
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSPath.java
@@ -0,0 +1,360 @@
+/* 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.syscams;
+
+import ui.TGComponent;
+import java.util.ArrayList;
+
+/**
+ * Class SysCAMSPath
+ * Notion of Path. To be used to analyze the correctness of paths in the model
+ * Creation: 07/05/2018
+ * @version 1.0 07/05/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSPath  {
+
+    public ArrayList<SysCAMSPrimitivePort> producerPorts;
+    public ArrayList<SysCAMSPrimitivePort> consumerPorts;
+
+    // Facilities
+    public ArrayList<SysCAMSCompositePort> cports;
+    public ArrayList<SysCAMSFork> forks;
+    public ArrayList<SysCAMSJoin> joins;
+
+    private boolean errorOfConnection = false;
+
+    private int errorNumber;
+    private TGComponent faultyComponent;
+
+
+    private String[] errors = {"Fork and Join operators in the same path",
+                               "Must have at least one sender",
+                               "Must have at least one receiver",
+                               "More than one sender in a path with a fork",
+                               "Senders and receivers are not of the same kind",
+                               "One of more element of the path is badly connected",
+                               "Events are not compatible with fork/join",
+                               "Requests are not compatible with fork/join",
+                               "Events/requests must all have the same parameters",
+                               "Channels and events can have only one input and one output"
+    };
+
+    public SysCAMSPath() {
+        cports = new ArrayList<SysCAMSCompositePort>();
+        producerPorts = new ArrayList<SysCAMSPrimitivePort>();
+        consumerPorts = new ArrayList<SysCAMSPrimitivePort>();
+        forks = new ArrayList<SysCAMSFork>();
+        joins = new ArrayList<SysCAMSJoin>();
+    }
+
+    public void addComponent(TGComponent _tgc) {
+        if (_tgc instanceof SysCAMSCompositePort) {
+            cports.add((SysCAMSCompositePort)_tgc);
+        }
+        if (_tgc instanceof SysCAMSPrimitivePort) {
+            SysCAMSPrimitivePort p = (SysCAMSPrimitivePort)_tgc;
+            if (p.isOrigin()) {
+                producerPorts.add(p);
+            } else {
+                consumerPorts.add(p);
+            }
+        }
+        if (_tgc instanceof SysCAMSFork) {
+            forks.add((SysCAMSFork)_tgc);
+        }
+        if (_tgc instanceof SysCAMSJoin) {
+            joins.add((SysCAMSJoin)_tgc);
+        }
+    }
+
+    public void setErrorOfConnection(boolean _err) {
+        errorOfConnection = _err;
+    }
+
+    public boolean getErrorOfConnection() {
+        return errorOfConnection;
+    }
+
+    public boolean contains(TGComponent tgc) {
+        if (cports.contains(tgc)) {
+            return true;
+        }
+        if (producerPorts.contains(tgc)) {
+            return true;
+        }
+        if (consumerPorts.contains(tgc)) {
+            return true;
+        }
+        if (forks.contains(tgc)) {
+            return true;
+        }
+        return joins.contains(tgc);
+    }
+
+    public void mergeWith(SysCAMSPath _path) {
+        cports.addAll(_path.cports);
+        producerPorts.addAll(_path.producerPorts);
+        consumerPorts.addAll(_path.consumerPorts);
+        forks.addAll(_path.forks);
+        joins.addAll(_path.joins);
+        setErrorOfConnection(getErrorOfConnection() || _path.getErrorOfConnection());
+    }
+
+    public boolean hasError() {
+        return (errorNumber != -1);
+    }
+
+    public String getErrorMessage() {
+        if (hasError()) {
+            return errors[errorNumber];
+        }
+        return "";
+    }
+
+    public TGComponent getFaultyComponent() {
+        return faultyComponent;
+    }
+
+    public void checkRules() {
+        errorNumber = -1;
+
+        //rule0: fork or join, but not both
+        if ((forks.size() > 0) && (joins.size() >0)) {
+            faultyComponent = forks.get(0);
+            errorNumber = 0;
+        }
+
+        //rule1: Must have at least one producer
+        if (producerPorts.size() == 0) {
+            errorNumber = 1;
+            if ((consumerPorts != null) && (consumerPorts.size() > 0)) {
+                faultyComponent = consumerPorts.get(0);
+            }
+        }
+
+        //rule2: Must have at least one receiver
+        if (consumerPorts.size() == 0) {
+            errorNumber = 2;
+            if ((producerPorts != null) && (producerPorts.size() > 0)) {
+                faultyComponent = producerPorts.get(0);
+            }
+        }
+
+        //rule3: If fork: must have only one producer
+        if ((forks.size() > 0) && (producerPorts.size() >1)) {
+            errorNumber = 3;
+            faultyComponent = forks.get(0);
+        }
+
+        //rule4: producers and consumers must be of the same type
+        if ((consumerPorts.size()>0) && (producerPorts.size()>0)) {
+            int type = consumerPorts.get(0).getPortType();
+            for (SysCAMSPrimitivePort porto: producerPorts) {
+                if (porto.getPortType() != type) {
+                    errorNumber = 4;
+                    faultyComponent = porto;
+                    break;
+                }
+            }
+            for (SysCAMSPrimitivePort porti: consumerPorts) {
+                if (porti.getPortType() != type) {
+                    errorNumber = 4;
+                    faultyComponent = porti;
+                    break;
+                }
+            }
+        }
+
+        //rule5: Error of connection
+        if (errorOfConnection) {
+            errorNumber = 5;
+        }
+
+        //rule7: requests cannot be connected through fork or join
+        if ((forks.size() > 0) || (joins.size() >0)) {
+            // Look for event, either at origin, or at destination
+            for (SysCAMSPrimitivePort porto: producerPorts) {
+                if (porto.getPortType() == 2) {
+                    errorNumber = 7;
+                    faultyComponent = porto;
+                    break;
+                }
+            }
+            for (SysCAMSPrimitivePort porti: consumerPorts) {
+                if (porti.getPortType() == 2) {
+                    errorNumber = 7;
+                    faultyComponent = porti;
+                    break;
+                }
+            }
+        }
+
+        //rule8: all events/requests with the same parameters
+//        if ((forks.size() > 0) || (joins.size() >0)) {
+//            if (producerPorts != null && producerPorts.size() > 0) {
+//                SysCAMSPrimitivePort referencePort = producerPorts.get(0);
+//                if (referencePort != null) {
+//                    if ((referencePort.getPortType() == 1) ||(referencePort.getPortType() == 2)) {
+//                        // Event or request found
+//                        // We now check that they are all compatible with the reference
+//                        for (SysCAMSPrimitivePort porto: producerPorts) {
+//                            if (!(porto.hasSameParametersThan(referencePort))) {
+//                                errorNumber = 8;
+//                                faultyComponent = porto;
+//                                break;
+//                            }
+//                        }
+//
+//                        for (SysCAMSPrimitivePort porti: consumerPorts) {
+//                            if (!(porti.hasSameParametersThan(referencePort))) {
+//                                errorNumber = 8;
+//                                faultyComponent = porti;
+//                                break;
+//                            }
+//                        }
+//                    }
+//                }
+//            }
+//        }
+
+        // rule9: if no fork, no join, no request: one to one communication
+        boolean foundReq = true;
+        if ((forks.size() == 0) && (joins.size() == 0)) {
+            if (producerPorts != null && producerPorts.size() > 0) {
+                SysCAMSPrimitivePort referencePort = producerPorts.get(0);
+                if (referencePort != null) {
+                    if (referencePort.getPortType() != 2) {
+                        foundReq = false;
+                    }
+                }
+            }
+            if (!foundReq) {
+                if (producerPorts.size() > 1) {
+                    errorNumber = 9;
+                    faultyComponent = producerPorts.get(1);
+                } else if (consumerPorts.size() > 1) {
+                    errorNumber = 9;
+                    faultyComponent = consumerPorts.get(1);
+                }
+            }
+        }
+    }
+
+    public void setColor() {
+        // For each channel facility,
+        // set the inp and outp primitive ports if possible (otherwise, null)
+        // if no error: set conflict to false
+        // If error -> set the conflict to true
+
+        for (SysCAMSFork fork: forks) {
+            if (producerPorts.size() > 0) {
+                fork.setOutPort(producerPorts.get(0));
+            } else {
+                fork.setOutPort(null);
+            }
+
+            if (consumerPorts.size() > 0) {
+                fork.setInPort(consumerPorts.get(0));
+            } else {
+                fork.setInPort(null);
+            }
+
+            if (hasError()) {
+                fork.setConflict(hasError(), errors[errorNumber]);
+            } else {
+                fork.setConflict(false, "");
+            }
+        }
+
+        for (SysCAMSJoin join: joins) {
+            if (producerPorts.size() > 0) {
+                join.setOutPort(producerPorts.get(0));
+            } else {
+                join.setOutPort(null);
+            }
+
+            if (consumerPorts.size() > 0) {
+                join.setInPort(consumerPorts.get(0));
+            } else {
+                join.setInPort(null);
+            }
+            if (hasError()) {
+                join.setConflict(hasError(), errors[errorNumber]);
+            } else {
+                join.setConflict(false, "");
+            }
+        }
+
+        for (SysCAMSCompositePort port: cports) {
+            if (producerPorts.size() > 0) {
+                port.setOutPort(producerPorts.get(0));
+            } else {
+                port.setOutPort(null);
+            }
+
+            if (consumerPorts.size() > 0) {
+                port.setInPort(consumerPorts.get(0));
+            } else {
+                port.setInPort(null);
+            }
+            if (hasError()) {
+                port.setConflict(hasError(), errors[errorNumber]);
+            } else {
+                port.setConflict(false, "");
+            }
+        }
+
+        for (SysCAMSPrimitivePort pport: producerPorts) {
+            if (hasError()) {
+                pport.setConflict(hasError(), errors[errorNumber]);
+            } else {
+                pport.setConflict(false, "");
+            }
+        }
+        for (SysCAMSPrimitivePort cport: consumerPorts) {
+            if (hasError()) {
+                cport.setConflict(hasError(), errors[errorNumber]);
+            } else {
+                cport.setConflict(false, "");
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSPortConnectingPoint.java b/src/main/resources/ui/syscams/SysCAMSPortConnectingPoint.java
new file mode 100644
index 0000000000..2482024935
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSPortConnectingPoint.java
@@ -0,0 +1,64 @@
+/* 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.syscams;
+
+import ui.CDElement;
+import ui.TGComponentManager;
+import ui.TGConnectingPointWidthHeight;
+
+/**
+ * Class SysCAMSPortConnectingPoint
+ * Definition of connecting points on which connectors of SystemC-AMS Component Task diagrams can be connected
+ * Creation: 22/04/2018
+ * @version 1.0 22/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSPortConnectingPoint extends TGConnectingPointWidthHeight{
+    public SysCAMSPrimitivePort port;
+	public boolean positionned;
+	
+    public SysCAMSPortConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) {
+        super(_container, _x, _y, _in, _out, _w, _h);
+    }
+    
+    public boolean isCompatibleWith(int type) {
+        return type == TGComponentManager.CONNECTOR_PORT_TMLC;
+    }
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSPortConnector.java b/src/main/resources/ui/syscams/SysCAMSPortConnector.java
new file mode 100644
index 0000000000..6766b226e7
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSPortConnector.java
@@ -0,0 +1,139 @@
+/* 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.syscams;
+
+import ui.*;
+import ui.util.IconManager;
+
+import java.awt.*;
+import java.util.Vector;
+
+/**
+ * Class SysCAMSPortConnector
+ * Connector used in SystemC-AMS Component task diagrams
+ * Creation: 27/04/2018
+ * @version 1.0 27/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public  class SysCAMSPortConnector extends TGConnector implements ScalableTGComponent, SpecificActionAfterAdd,  SpecificActionAfterMove{
+    protected double oldScaleFactor;
+
+    public SysCAMSPortConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) {
+        super(_x, _y,  _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint);
+        myImageIcon = IconManager.imgic202;
+        value = "Connector between ports";
+        editable = false;
+        oldScaleFactor = tdp.getZoom();
+        p1 = _p1;	
+        p2 = _p2;
+    }
+
+    public TGConnectingPoint get_p1(){
+    	return p1;
+	}
+
+    public TGConnectingPoint get_p2(){
+    	return p2;
+	}
+
+    protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){
+        try {
+            SysCAMSPortConnectingPoint pt1 = (SysCAMSPortConnectingPoint)p1;
+            SysCAMSPortConnectingPoint pt2 = (SysCAMSPortConnectingPoint)p2;
+            if (!pt1.positionned) {
+                pt1.positionned = true;
+                if (pt1.getFather() instanceof SysCAMSPrimitivePort) {
+                    pt1.port = (SysCAMSPrimitivePort)(pt1.getFather());
+                }
+            }
+            if (!pt2.positionned) {
+                pt2.positionned = true;
+                if (pt2.getFather() instanceof SysCAMSPrimitivePort) {
+                    pt2.port = (SysCAMSPrimitivePort)(pt2.getFather());
+                }
+            }
+            if ((pt1.port != null) && (pt2.port != null)) {
+                String name1 = pt1.port.getPortName();
+                String name2 = pt2.port.getPortName();
+                if (name1.equals(name2)) {
+                    int w = g.getFontMetrics().stringWidth(name1);
+                    Font fold = g.getFont();
+                    Font f = fold.deriveFont(Font.ITALIC, (float)(tdp.getFontSize()));
+                    g.setFont(f);
+                    g.drawString(name1, (x1 + x2 - w)/2, (y1 + y2)/2);
+                    g.setFont(fold);
+                }
+            }
+            g.drawLine(x1, y1, x2, y2);
+            return;
+        } catch (Exception e) {
+        }
+        g.drawLine(x1, y1, x2, y2);
+    }
+
+    public void rescale(double scaleFactor){
+        int xx, yy;
+
+        for(int i=0; i<nbInternalTGComponent; i++) {
+            xx = tgcomponent[i].getX();
+            yy = tgcomponent[i].getY();
+            tgcomponent[i].dx = (tgcomponent[i].dx + xx) / oldScaleFactor * scaleFactor;
+            tgcomponent[i].dy = (tgcomponent[i].dy + yy) / oldScaleFactor * scaleFactor;
+            xx = (int)(tgcomponent[i].dx);
+            tgcomponent[i].dx = tgcomponent[i].dx - xx;
+            yy = (int)(tgcomponent[i].dy);
+            tgcomponent[i].dy = tgcomponent[i].dy - yy;
+            tgcomponent[i].setCd(xx, yy);
+        }
+        oldScaleFactor = scaleFactor;
+    }
+
+    public int getType() {
+        return TGComponentManager.CONNECTOR_PORT_TMLC;
+    }
+
+    public void specificActionAfterAdd() {
+        ((SysCAMSComponentTaskDiagramPanel)tdp).updatePorts();
+    }
+
+    public void specificActionAfterMove() {
+        ((SysCAMSComponentTaskDiagramPanel)tdp).updatePorts();
+    }
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSPortConverter.java b/src/main/resources/ui/syscams/SysCAMSPortConverter.java
new file mode 100644
index 0000000000..ceaf066a16
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSPortConverter.java
@@ -0,0 +1,57 @@
+package ui.syscams;
+
+import ui.TDiagramPanel;
+import ui.TGComponent;
+
+public class SysCAMSPortConverter extends SysCAMSCompositePort {
+	private int period;
+	private int rate;
+	private int delay;
+	private String origin;
+	private String convType;
+	
+	public SysCAMSPortConverter(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos,
+			TGComponent _father, TDiagramPanel _tdp) {
+		super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+	}
+
+	public int getPeriod() {
+		return period;
+	}
+
+	public void setPeriod(int period) {
+		this.period = period;
+	}
+
+	public int getRate() {
+		return rate;
+	}
+
+	public void setRate(int rate) {
+		this.rate = rate;
+	}
+
+	public int getDelay() {
+		return delay;
+	}
+
+	public void setDelay(int delay) {
+		this.delay = delay;
+	}
+
+	public String getOrigin() {
+		return origin;
+	}
+
+	public void setOrigin(String origin) {
+		this.origin = origin;
+	}
+
+	public String getConvType() {
+		return convType;
+	}
+
+	public void setConvType(String convType) {
+		this.convType = convType;
+	}
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSPortDE.java b/src/main/resources/ui/syscams/SysCAMSPortDE.java
new file mode 100644
index 0000000000..5f837c6d98
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSPortDE.java
@@ -0,0 +1,62 @@
+package ui.syscams;
+
+import java.awt.Graphics;
+
+import ui.TDiagramPanel;
+import ui.TGComponent;
+
+public class SysCAMSPortDE extends SysCAMSPrimitivePort {
+	private int period;
+	private int rate;
+	private int delay;
+	private String origin;
+	private String DEType;
+	
+	public SysCAMSPortDE(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father,
+			TDiagramPanel _tdp) {
+		super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+	}
+
+	public String getDEType() {
+		return DEType;
+	}
+
+	public void setDEType(String DEType) {
+		this.DEType = DEType;
+	}
+
+	public String getOrigin() {
+		return origin;
+	}
+
+	public void setOrigin(String origin) {
+		this.origin = origin;
+	}
+
+	public int getPeriod() {
+		return period;
+	}
+
+	public void setPeriod(int period) {
+		this.period = period;
+	}
+
+	public int getRate() {
+		return rate;
+	}
+
+	public void setRate(int rate) {
+		this.rate = rate;
+	}
+
+	public int getDelay() {
+		return delay;
+	}
+
+	public void setDelay(int delay) {
+		this.delay = delay;
+	}
+
+	public void drawParticularity(Graphics g) {
+	}	
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSPortTDF.java b/src/main/resources/ui/syscams/SysCAMSPortTDF.java
new file mode 100644
index 0000000000..afc054a3a0
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSPortTDF.java
@@ -0,0 +1,62 @@
+package ui.syscams;
+
+import java.awt.Graphics;
+
+import ui.TDiagramPanel;
+import ui.TGComponent;
+
+public class SysCAMSPortTDF extends SysCAMSPrimitivePort {
+	private int period;
+	private int rate;
+	private int delay;
+	private String origin;
+	private String TDFType;
+	
+	public SysCAMSPortTDF(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father,
+			TDiagramPanel _tdp) {
+		super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+	}
+	
+	public String getTDFType() {
+		return TDFType;
+	}
+
+	public void setTDFType(String tDFType) {
+		TDFType = tDFType;
+	}
+
+	public String getOrigin() {
+		return origin;
+	}
+
+	public void setOrigin(String origin) {
+		this.origin = origin;
+	}
+
+	public int getPeriod() {
+		return period;
+	}
+
+	public void setPeriod(int period) {
+		this.period = period;
+	}
+
+	public int getRate() {
+		return rate;
+	}
+
+	public void setRate(int rate) {
+		this.rate = rate;
+	}
+
+	public int getDelay() {
+		return delay;
+	}
+
+	public void setDelay(int delay) {
+		this.delay = delay;
+	}
+
+	public void drawParticularity(Graphics g) {
+	}
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSPrimitiveComponent.java b/src/main/resources/ui/syscams/SysCAMSPrimitiveComponent.java
new file mode 100644
index 0000000000..152f6ea18b
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSPrimitiveComponent.java
@@ -0,0 +1,620 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import ui.*;
+import ui.util.IconManager;
+//import ui.window.JDialogAttribute;
+import ui.window.JDialogSysCAMSBlockDE;
+import ui.window.JDialogSysCAMSBlockTDF;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.Vector;
+
+/**
+ * Class SysCAMSPrimitiveComponent
+ * Primitive Component. To be used in SystemC-AMSdiagrams
+ * Creation: 27/04/2018
+ * @version 1.0 27/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSPrimitiveComponent extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent, WithAttributes {
+    private int maxFontSize = 14;
+    private int minFontSize = 4;
+    private int currentFontSize = -1;
+    private boolean displayText = true;
+    private Color myColor;
+
+	private boolean isAttacker=false;
+    // Icon
+    private int iconSize = 15;
+//    private boolean iconIsDrawn = false;
+
+    // Attributes
+    public HashMap<String, Integer> attrMap = new HashMap<String, Integer>();
+    public String mappingName;
+    protected LinkedList<TAttribute> myAttributes;
+    private int textX = 15; // border for ports
+    private double dtextX = 0.0;
+
+    public String oldValue;
+
+    public SysCAMSPrimitiveComponent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+
+        initScaling(200, 150);
+
+        oldScaleFactor = tdp.getZoom();
+        dtextX = textX * oldScaleFactor;
+        textX = (int)dtextX;
+        dtextX = dtextX - textX;
+
+        minWidth = 1;
+        minHeight = 1;
+
+        nbConnectingPoint = 0;
+
+        addTGConnectingPointsComment();
+
+        nbInternalTGComponent = 0;
+
+        moveable = true;
+        multieditable = true;
+        editable = true;
+        removable = true;
+        userResizable = true;
+
+        if (this instanceof SysCAMSBlockTDF) {
+        	value = "TDF_Block";
+        } else if (this instanceof SysCAMSBlockDE) {
+        	value = "DE_Block";
+        }
+        
+//        oldValue = value;
+//        setName("Primitive component");
+        name = "Primitive component";
+        
+        myImageIcon = IconManager.imgic1202;
+
+        myAttributes = new LinkedList<TAttribute> ();
+
+        actionOnAdd();
+    }
+
+    public void internalDrawing(Graphics g) {
+        int w;
+        Font f = g.getFont();
+        Font fold = f;
+
+        if (myColor == null) {
+            if (ColorManager.TML_COMPOSITE_COMPONENT == Color.white) {
+                myColor = Color.white;
+            } else {
+            	if (this instanceof SysCAMSBlockTDF) {
+            		myColor = Color.lightGray;
+            	} else {
+            		myColor = Color.white;
+            	}
+            }
+        }
+        if ((rescaled) && (!tdp.isScaled())) {
+            if (currentFontSize == -1) {
+                currentFontSize = f.getSize();
+            }
+            rescaled = false;
+            // Must set the font size ..
+            // Find the biggest font not greater than max_font size
+            // By Increment of 1
+            // Or decrement of 1
+            // If font is less than 4, no text is displayed
+
+            int maxCurrentFontSize = Math.max(0, Math.min(height-(2*textX), maxFontSize));
+            f = f.deriveFont((float)maxCurrentFontSize);
+            g.setFont(f);
+            while(maxCurrentFontSize > (minFontSize-1)) {
+                if (g.getFontMetrics().stringWidth(value) < (width - iconSize - (2 * textX))) {
+                    break;
+                }
+                maxCurrentFontSize --;
+                f = f.deriveFont((float)maxCurrentFontSize);
+                g.setFont(f);
+            }
+            currentFontSize = maxCurrentFontSize;
+            if(currentFontSize <minFontSize) {
+                displayText = false;
+            } else {
+                displayText = true;
+                f = f.deriveFont((float)currentFontSize);
+                g.setFont(f);
+            }
+        }
+
+        // Zoom is assumed to be computed
+        Color c = g.getColor();
+        g.drawRect(x, y, width, height);
+        if ((width > 2) && (height > 2)) {
+            g.setColor(myColor);
+            g.fillRect(x+1, y+1, width-1, height-1);
+            g.setColor(c);
+        }
+
+        // Font size
+        if (displayText) {
+            f = f.deriveFont((float)currentFontSize);
+            g.setFont(f);
+            w = g.getFontMetrics().stringWidth(value);
+            if (w > (width - 2 * (iconSize + textX))) {
+                g.drawString(value, x + textX + 1, y + currentFontSize + textX);
+                
+                if (this instanceof SysCAMSBlockTDF) {
+                	String s = "Tm = " + ((SysCAMSBlockTDF) this).getPeriod();
+                	g.drawString(s, x + textX + 1, y + height - currentFontSize - textX);
+                } else if (this instanceof SysCAMSBlockDE) {
+                	String s = "Tm = " + ((SysCAMSBlockDE) this).getPeriod();
+                	g.drawString(s, x + textX + 1, y + height - currentFontSize - textX);
+                }
+            } else {
+                g.drawString(value, x + (width - w)/2, y + currentFontSize + textX);
+                if (this instanceof SysCAMSBlockTDF) {
+                	String s = "Tm = " + ((SysCAMSBlockTDF) this).getPeriod();
+                	w = g.getFontMetrics().stringWidth(s);
+                	g.drawString(s, x + (width - w)/2, y + height - currentFontSize - textX);
+                } else if (this instanceof SysCAMSBlockDE) {
+                	String s = "Tm = " + ((SysCAMSBlockDE) this).getPeriod();
+                	w = g.getFontMetrics().stringWidth(s);
+                	g.drawString(s, x + (width - w)/2, y + height - currentFontSize - textX);
+                }
+            }
+        }
+
+//        // Icon
+//        if ((width>30) && (height > (iconSize + 2*textX))) {
+//            iconIsDrawn = true;
+//            g.drawImage(IconManager.imgic1200.getImage(), x + width - iconSize - textX, y + textX, null);
+//        } else {
+//            iconIsDrawn = false;
+//        }
+//		if (isAttacker){
+//			g.drawImage(IconManager.imgic7008.getImage(), x + width - 2*iconSize - textX, y + 2*textX, null);
+//		}
+
+        // Attributes
+        if (tdp.areAttributesVisible()) {
+            int index = 0;
+            int cpt = currentFontSize + 2 * textX;
+            String attr;
+
+            TAttribute a;
+
+            int si = Math.min(12, (int)((float)currentFontSize - 2));
+
+            f = g.getFont();
+            f = f.deriveFont((float)si);
+            g.setFont(f);
+            int step = si + 2;
+
+            while(index < myAttributes.size()) {
+                cpt += step;
+                if (cpt >= (height - textX)) {
+                    break;
+                }
+                a = myAttributes.get (index);
+                attr = a.toString();
+                w = g.getFontMetrics().stringWidth(attr);
+                if ((w + (2 * textX) + 1) < width) {
+                    g.drawString(attr, x + textX, y + cpt);
+                    drawVerification(g, x + textX, y+ cpt, a.getConfidentialityVerification());
+                } else {
+                    attr = "...";
+                    w = g.getFontMetrics().stringWidth(attr);
+                    if ((w + textX + 2) < width) {
+                        g.drawString(attr, x + textX + 1, y + cpt);
+                    } else {
+                        // skip attribute
+                        cpt -= step;
+                    }
+                }
+                index ++;
+            }
+        }
+        g.setFont(fold);
+    }
+     public void drawVerification(Graphics g, int x, int y, int checkConfStatus){
+        Color c = g.getColor();
+        Color c1;
+        switch(checkConfStatus) {
+        case TAttribute.CONFIDENTIALITY_OK:
+            c1 = Color.green;
+            break;
+        case TAttribute.CONFIDENTIALITY_KO:
+            c1 = Color.red;
+            break;
+        default:
+            return;
+        }
+		g.drawOval(x-10, y-10, 6, 9);
+		g.setColor(c1);
+		g.fillRect(x-12, y-5, 9, 7);
+		g.setColor(c);
+		g.drawRect(x-12, y-5, 9, 7);
+    }
+
+    public void rescale(double scaleFactor){
+        dtextX = (textX + dtextX) / oldScaleFactor * scaleFactor;
+        textX = (int)(dtextX);
+        dtextX = dtextX - textX;
+        super.rescale(scaleFactor);
+    }
+
+    public TGComponent isOnOnlyMe(int _x, int _y) {
+        if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) {
+            return this;
+        }
+        return null;
+    }
+
+
+	public boolean isAttacker(){
+		return isAttacker;
+	}
+
+    public boolean editOndoubleClick(JFrame frame, int _x, int _y) {
+//        // On the icon?
+//        if (iconIsDrawn) {
+//            if (GraphicLib.isInRectangle(_x, _y, x + width - iconSize - textX, y + textX, iconSize, iconSize)) {
+//            	tdp.getMouseManager().setSelection(-1, -1);
+//                tdp.selectTab(getValue());
+//                return true;
+//            }
+//        }
+        // On the name ?
+//        if ((displayText) && (_y <= (y + currentFontSize + textX))) {
+////            oldValue = value;
+//            String s = (String)JOptionPane.showInputDialog(frame, "Name:", "Setting component name",
+//                                                           JOptionPane.PLAIN_MESSAGE, IconManager.imgic100,
+//                                                           null,
+//                                                           getValue());
+//            if ((s != null) && (s.length() > 0)) {
+//                // Check whether this name is already in use, or not
+//                if (!TAttribute.isAValidId(s, false, false)) {
+//                    JOptionPane.showMessageDialog(frame,
+//                                                  "Could not change the name of the component: the new name is not a valid name",
+//                                                  "Error",
+//                                                  JOptionPane.INFORMATION_MESSAGE);
+//                    return false;
+//                }
+//                if (oldValue.compareTo(s) != 0) {
+//                    if (((SysCAMSComponentTaskDiagramPanel)(tdp)).namePrimitiveComponentInUse(oldValue, s)) {
+//                        JOptionPane.showMessageDialog(frame,
+//                                                      "Error: the name is already in use",
+//                                                      "Name modification",
+//                                                      JOptionPane.ERROR_MESSAGE);
+//                        return false;
+//                    }
+//                }
+//                if (((SysCAMSComponentTaskDiagramPanel)(tdp)).isCompositeNameUsed(s)) {
+//                    JOptionPane.showMessageDialog(frame,
+//                                                  "Error: the name is already in use",
+//                                                  "Name modification",
+//                                                  JOptionPane.ERROR_MESSAGE);
+//                    return false;
+//                }
+//    			setComponentName(s);
+//                setValueWithChange(s);
+////				isAttacker = s.contains("Attacker");
+//                rescaled = true;
+//                return true;
+//
+//            }
+//            return false;
+//        }
+
+        // And so -> attributes!
+//        JDialogAttribute jda = new JDialogAttribute(myAttributes, null, frame, "Setting attributes of " + value, "Attribute");
+//        setJDialogOptions(jda);
+//        GraphicLib.centerOnParent(jda, 650, 375);
+        if (this instanceof SysCAMSBlockTDF) {
+        	JDialogSysCAMSBlockTDF jtdf = new JDialogSysCAMSBlockTDF((SysCAMSBlockTDF) this);
+        	jtdf.setVisible(true);
+        } else {
+        	JDialogSysCAMSBlockDE jde = new JDialogSysCAMSBlockDE((SysCAMSBlockDE) this);
+        	jde.setVisible(true);
+    	}	
+//        jda.setVisible(true); // blocked until dialog has been closed
+        rescaled = true;
+        return true;
+
+    }
+
+//    protected void setJDialogOptions(JDialogAttribute jda) {
+//        jda.addAccess(TAttribute.getStringAccess(TAttribute.PUBLIC));
+//        jda.addAccess(TAttribute.getStringAccess(TAttribute.PRIVATE));
+//        jda.addType(TAttribute.getStringType(TAttribute.NATURAL), true);
+//        jda.addType(TAttribute.getStringType(TAttribute.BOOLEAN), true);
+//
+//        Vector<String> records = ((SysCAMSComponentTaskDiagramPanel)(tdp)).getAllRecords(this);
+//        for(String s: records) {
+//            jda.addType(s, false);
+//        }
+//        jda.enableInitialValue(true);
+//        jda.enableRTLOTOSKeyword(true);
+//        jda.enableJavaKeyword(false);
+//        jda.enableTMLKeyword(false);
+//    }
+
+    public Vector<String> getAllRecords() {
+        return ((SysCAMSComponentTaskDiagramPanel)(tdp)).getAllRecords(this);
+    }
+
+    public SysCAMSRecordComponent getRecordNamed(String _nameOfRecord) {
+        return ((SysCAMSComponentTaskDiagramPanel)(tdp)).getRecordNamed(this, _nameOfRecord);
+    }
+
+    public int getType() {
+        return TGComponentManager.TMLCTD_PCOMPONENT;
+    }
+
+    public void wasSwallowed() {
+        myColor = null;
+    }
+
+    public void wasUnswallowed() {
+        myColor = null;
+        setFather(null);
+        TDiagramPanel tdp = getTDiagramPanel();
+        setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY());
+    }
+
+    public boolean acceptSwallowedTGComponent(TGComponent tgc) {
+        return tgc instanceof SysCAMSPrimitivePort;
+    }
+
+    public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) {
+        //TraceManager.addDev("Add swallow component");
+        // Choose its position
+        // Make it an internal component
+        // It's one of my son
+        //Set its coordinates
+        if (tgc instanceof SysCAMSPrimitivePort) {
+            tgc.setFather(this);
+            tgc.setDrawingZone(true);
+            tgc.resizeWithFather();
+            addInternalComponent(tgc, 0);
+            return true;
+        }
+        return false;
+    }
+
+    public void removeSwallowedTGComponent(TGComponent tgc) {
+        removeInternalComponent(tgc);
+    }
+
+    public void hasBeenResized() {
+        rescaled = true;
+        for(int i=0; i<nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSPrimitivePort) {
+                tgcomponent[i].resizeWithFather();
+            }
+        }
+        if (getFather() != null) {
+            resizeWithFather();
+        }
+    }
+
+    public void resizeWithFather() {
+        if ((father != null) && (father instanceof SysCAMSCompositeComponent)) {
+            // Too large to fit in the father? -> resize it!
+            resizeToFatherSize();
+
+            setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight());
+            setMoveCd(x, y);
+        }
+    }
+
+    public int getChildCount() {
+        return myAttributes.size() + nbInternalTGComponent + 1;
+    }
+
+    public Object getChild(int index) {
+        if (index == 0) {
+            return value;
+        } else {
+            if (index <= myAttributes.size()) {
+                return myAttributes.get (index-1);
+            } else {
+                return tgcomponent[index-1-myAttributes.size()];
+            }
+        }
+    }
+
+    public int getIndexOfChild(Object child) {
+        if (child instanceof String) {
+            return 0;
+        } else {
+            if (myAttributes.indexOf(child) > -1) {
+                return myAttributes.indexOf(child) + 1;
+            } else {
+                for(int i=0; i<nbInternalTGComponent; i++) {
+                    if (tgcomponent[i] == child) {
+                        return myAttributes.size() + 1 + i;
+                    }
+                }
+            }
+        }
+        return -1;
+    }
+
+    protected String translateExtraParam() {
+        TAttribute a;
+        StringBuffer sb = new StringBuffer("<extraparam>\n");
+			sb.append("<Data isAttacker=\"");
+            sb.append(isAttacker() ? "Yes": "No");
+	        sb.append("\" />\n");
+        for(int i=0; i<myAttributes.size(); i++) {
+            a = myAttributes.get (i);
+            sb.append("<Attribute access=\"");
+            sb.append(a.getAccess());
+            sb.append("\" id=\"");
+            sb.append(a.getId());
+            sb.append("\" value=\"");
+            sb.append(a.getInitialValue());
+            sb.append("\" type=\"");
+            sb.append(a.getType());
+            sb.append("\" typeOther=\"");
+            sb.append(a.getTypeOther());
+            sb.append("\" />\n");
+        }
+        sb.append("</extraparam>\n");
+        return new String(sb);
+    }
+
+    public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{
+        try {
+            NodeList nli;
+            Node n1, n2;
+            Element elt;
+            int access, type;
+            String typeOther;
+            String id, valueAtt;
+
+            for(int i=0; i<nl.getLength(); i++) {
+                n1 = nl.item(i);
+                if (n1.getNodeType() == Node.ELEMENT_NODE) {
+                    nli = n1.getChildNodes();
+                    for(int j=0; j<nli.getLength(); j++) {
+                        n2 = nli.item(j);
+                        if (n2.getNodeType() == Node.ELEMENT_NODE) {
+                            elt = (Element) n2;
+							if (elt.getTagName().equals("Data")) {
+                                isAttacker = elt.getAttribute("isAttacker").equals("Yes");
+							}
+                            if (elt.getTagName().equals("Attribute")) {
+                                access = Integer.decode(elt.getAttribute("access")).intValue();
+                                type = Integer.decode(elt.getAttribute("type")).intValue();
+                                try {
+                                    typeOther = elt.getAttribute("typeOther");
+                                } catch (Exception e) {
+                                    typeOther = "";
+                                }
+                                id = elt.getAttribute("id");
+                                valueAtt = elt.getAttribute("value");
+
+                                if (valueAtt.equals("null")) {
+                                    valueAtt = "";
+                                }
+                                if ((TAttribute.isAValidId(id, false, false)) && (TAttribute.isAValidInitialValue(type, valueAtt))) {
+                                    TAttribute ta = new TAttribute(access, id, valueAtt, type, typeOther);
+                                    myAttributes.add (ta);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            throw new MalformedModelingException();
+        }
+    }
+
+    public int getCurrentFontSize() {
+        return currentFontSize;
+    }
+
+    public java.util.List<TAttribute> getAttributeList() {
+        return myAttributes;
+    }
+
+    public java.util.List<SysCAMSPrimitivePort> getAllTDFOriginPorts() {
+        return getAllPorts(0, true);
+    }
+
+    public java.util.List<SysCAMSPrimitivePort> getAllTDFDestinationPorts() {
+        return getAllPorts(0, false);
+    }
+
+    public java.util.List<SysCAMSPrimitivePort> getAllDEOriginPorts() {
+        return getAllPorts(1, true);
+    }
+
+    public java.util.List<SysCAMSPrimitivePort> getAllDEDestinationPorts() {
+        return getAllPorts(1, false);
+    }
+
+    public java.util.List<SysCAMSPrimitivePort> getAllPorts(int _type, boolean _isOrigin) {
+    	java.util.List<SysCAMSPrimitivePort> ret = new LinkedList<SysCAMSPrimitivePort>();
+        SysCAMSPrimitivePort port;
+
+        for(int i=0; i<nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSPrimitivePort) {
+                port = (SysCAMSPrimitivePort)tgcomponent[i];
+                if ((port.getPortType() == _type) && (port.isOrigin() == _isOrigin)) {
+                    ret.add(port);
+                }
+            }
+        }
+        return ret;
+    }
+
+    public java.util.List<SysCAMSPrimitivePort> getAllInternalPrimitivePorts() {
+    	java.util.List<SysCAMSPrimitivePort> list = new ArrayList<SysCAMSPrimitivePort>();
+        for(int i=0; i<nbInternalTGComponent; i++) {
+            if (tgcomponent[i] instanceof SysCAMSPrimitivePort) {
+                list.add((SysCAMSPrimitivePort)(tgcomponent[i]));
+            }
+        }
+        return list;
+    }
+
+    public String getAttributes() {
+        String attr = "";
+        for (TAttribute a: myAttributes) {
+            attr +=  a.toAvatarString() + "\n";
+        }
+        return attr;
+    }
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSPrimitivePort.java b/src/main/resources/ui/syscams/SysCAMSPrimitivePort.java
new file mode 100644
index 0000000000..2e79885b2f
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSPrimitivePort.java
@@ -0,0 +1,878 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import ui.*;
+import ui.tmlad.TMLADNotifiedEvent;
+import ui.tmlad.TMLADReadChannel;
+import ui.tmlad.TMLADSendEvent;
+import ui.tmlad.TMLADSendRequest;
+import ui.tmlad.TMLADWaitEvent;
+import ui.tmlad.TMLADWriteChannel;
+import ui.tmldd.TMLArchiCPNode;
+import ui.tmldd.TMLArchiPortArtifact;
+import ui.util.IconManager;
+import ui.window.JDialogSysCAMSPortDE;
+import ui.window.JDialogSysCAMSPortTDF;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * Class SysCAMSPrimitivePort
+ * Primitive port. To be used in SystemC-AMS diagrams
+ * Creation: 27/04/2018
+ * @version 1.0 27/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public abstract class SysCAMSPrimitivePort extends TGCScalableWithInternalComponent implements SwallowedTGComponent, LinkedReference, WithAttributes {
+    protected Color myColor;
+    protected int orientation;
+    protected int oldx, oldy;
+    protected int halfwidth = 13;
+    protected int currentOrientation = GraphicLib.NORTH;
+
+    protected int nbMaxAttribute = 5;
+    protected TType list[];
+    protected int maxSamples = 8;
+    protected int widthSamples = 4;
+    protected boolean isFinite = false;
+    protected boolean isBlocking = false;
+    public boolean isOrigin = true;
+    public int typep = 0;
+    protected int oldTypep = typep;
+    public String commName;
+
+    protected boolean isLossy;
+    protected boolean isPostex = false;
+    protected boolean isPrex = false;
+    protected int lossPercentage;
+    protected int maxNbOfLoss; //-1 means no max
+
+    //Security Verification
+    public int checkConfStatus;
+
+    public int checkSecConfStatus;
+    public String secName="";
+
+    public int checkWeakAuthStatus;
+    public int checkStrongAuthStatus;
+    public boolean checkConf;
+    public boolean checkAuth;
+    public static int NOCHECK= 0;
+    public static int TOCHECK = 1;
+    public static int CHECKED_CONF = 2;
+    public static int CHECKED_UNCONF = 3;
+
+    public String mappingName="???";
+    protected int decPoint = 3;
+
+    protected boolean conflict = false;
+    protected String conflictMessage;
+    protected String dataFlowType = "VOID";
+    protected String associatedEvent = "VOID";
+
+    public int verification;
+    
+    private ImageIcon portImageIconTDF, portImageIconDE;
+    
+    public SysCAMSPrimitivePort(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+
+        initScaling(2*halfwidth, 2*halfwidth);
+
+        minWidth = 1;
+        minHeight = 1;
+
+        nbConnectingPoint = 1;
+        connectingPoint = new TGConnectingPoint[1];
+		for (int i=0; i<1; i++) {
+			connectingPoint[i] = new SysCAMSPortConnectingPoint(this, 0, 0, true, true, 0.5, 0.0);
+		}
+        
+        addTGConnectingPointsComment();
+
+        nbInternalTGComponent = 0;
+
+        moveable = true;
+        editable = true;
+        removable = true;
+        userResizable = false;
+        checkConf=false;
+        commName = "comm";
+        makeValue();
+        setName("Primitive port");
+        checkConfStatus= NOCHECK;
+        list = new TType[nbMaxAttribute];
+        for(int i=0; i<nbMaxAttribute; i++) {
+            list[i] = new TType();
+        }
+        myImageIcon = IconManager.imgic1206;
+        portImageIconTDF = IconManager.imgic8000;
+        portImageIconDE = IconManager.imgic8001;
+        
+        // Initialization of port attributes
+        if (this instanceof SysCAMSPortTDF) {
+        	((SysCAMSPortTDF) this).setTDFType("");
+        } else if (this instanceof SysCAMSPortDE) {
+        	((SysCAMSPortDE) this).setDEType("");
+        }
+    }
+
+    public void initConnectingPoint(boolean in, boolean out, int nb) {
+        nbConnectingPoint = nb;
+        connectingPoint = new TGConnectingPoint[nb];
+        int i;
+        for (i=0; i<nbConnectingPoint; i++) {
+            connectingPoint[i] = new SysCAMSPortConnectingPoint(this, 0, 0, in, out, 0.5, 0.0);
+        }
+    }
+
+    public Color getMyColor() {
+        return myColor;
+    }
+
+    public void internalDrawing(Graphics g) {
+        if ((x != oldx) | (oldy != y)) {
+            // Component has moved!
+            manageMove();
+            oldx = x;
+            oldy = y;
+        }
+        calculatePortColor();
+
+        if (rescaled) {
+            rescaled = false;
+        }
+
+        // Zoom is assumed to be computed
+        Color c = g.getColor();
+        g.setColor(c);
+         
+        TGComponent tgc = getFather();
+        if ((tgc != null) && (tgc instanceof SysCAMSPrimitiveComponent)) {
+        	if (tgc instanceof SysCAMSBlockTDF && this instanceof SysCAMSPortTDF) {
+        		g.drawRect(x+width/2-portImageIconTDF.getIconWidth()/2, y+height/2-portImageIconTDF.getIconHeight()/2, portImageIconTDF.getIconWidth(), portImageIconTDF.getIconHeight());
+        		g.drawImage(portImageIconTDF.getImage(), x+width/2-portImageIconTDF.getIconWidth()/2, y+height/2-portImageIconTDF.getIconHeight()/2, null);
+        	} else if (tgc instanceof SysCAMSBlockDE && this instanceof SysCAMSPortDE) {
+        		g.drawRect(x+width/2-portImageIconDE.getIconWidth()/2, y+height/2-portImageIconDE.getIconHeight()/2, portImageIconDE.getIconWidth(), portImageIconDE.getIconHeight());
+        		g.drawImage(portImageIconDE.getImage(), x+width/2-portImageIconDE.getIconWidth()/2, y+height/2-portImageIconDE.getIconHeight()/2, null);
+        	}
+        }
+        
+        int ft = 10;
+        if ((tgc != null) && (tgc instanceof SysCAMSPrimitiveComponent)) {
+            ft = ((SysCAMSPrimitiveComponent)tgc).getCurrentFontSize();
+        }
+        int w;
+        Font f = g.getFont();
+        Font fold = f;
+
+        int si = Math.min(8, (int)((float)ft - 2));
+        f = f.deriveFont((float)si);
+        g.setFont(f);
+        w = g.getFontMetrics().stringWidth(commName);
+        if (w < ((int)(width * 1.5))) {
+            g.drawString(commName, x, y-1);
+        }
+
+        if (checkConf && isOrigin){
+            drawConfVerification(g);
+        }
+        if (checkAuth && !isOrigin){
+            drawAuthVerification(g);
+        }
+        g.setFont(fold);
+
+        drawParticularity(g);
+    }
+
+    public abstract void drawParticularity(Graphics g);
+
+    public void drawAuthVerification(Graphics g){
+        int lockwidth=(int) (16*tdp.getZoom());
+        int lockheight=(int) (16*tdp.getZoom());
+
+        int xc=(int) (18*tdp.getZoom());
+        int yc= (int) (12*tdp.getZoom());
+
+        int xoffset= (int) (20*tdp.getZoom());
+        int yoffset= (int) (18*tdp.getZoom());
+
+        int ovalwidth=(int) (10*tdp.getZoom());
+        int ovalheight=(int) (15*tdp.getZoom());
+        g.drawString(secName, x-xc*2/3, y+yc*2/3);
+        Color c = g.getColor();
+        Color c1;
+        Color c2;
+        switch(checkStrongAuthStatus) {
+        case 2:
+            c1 = Color.green;
+            break;
+        case 3:
+            c1 = Color.red;
+            break;
+        default:
+            c1 = Color.gray;
+        }
+        switch(checkWeakAuthStatus) {
+        case 2:
+            c2 = Color.green;
+            break;
+        case 3:
+            c2 = Color.red;
+            break;
+        default:
+            c2= c1;
+        }
+        g.drawOval(x-xc, y+yc, ovalwidth, ovalheight);
+        g.setColor(c1);
+        int[] xps = new int[]{x-xoffset, x-xoffset, x-xoffset+lockwidth};
+        int[] yps = new int[]{y+yoffset, y+yoffset+lockheight, y+yoffset+lockheight};
+        int[] xpw = new int[]{x-xoffset+lockwidth, x-xoffset+lockwidth, x-xoffset};
+        int[] ypw = new int[]{y+yoffset+lockheight, y+yoffset, y+yoffset};
+        g.fillPolygon(xps, yps,3);
+
+        g.setColor(c2);
+        g.fillPolygon(xpw, ypw, 3);
+        g.setColor(c);
+        g.drawPolygon(xps, yps,3);
+        g.drawPolygon(xpw, ypw, 3);
+        g.drawString("S", x-xoffset+1, y+yc+yoffset);
+        g.drawString("W", x-xoffset+lockwidth/2, y+yc+ovalheight);
+        if (checkStrongAuthStatus ==3){
+            g.drawLine(x-xoffset, y+yoffset*3/2, x-xoffset/2, y+yoffset+yc);
+            g.drawLine(x-xoffset, y+yoffset+yc, x-xoffset/2, y+yoffset*3/2);
+        }
+        if (checkWeakAuthStatus==3 || checkStrongAuthStatus==3 && checkWeakAuthStatus <2){
+            g.drawLine(x-xc*2/3, y+yoffset, x-xc/3, y+yc+lockheight);
+            g.drawLine(x-xc*2/3, y+yc+lockheight, x-xc/3, y+yoffset);
+        }
+    }
+
+    public void drawConfVerification(Graphics g){
+        int lockwidth=(int) (9*tdp.getZoom());
+        int lockheight=(int) (7*tdp.getZoom());
+        int yoffset = 3*lockheight;
+
+        int ovalwidth=(int) (6*tdp.getZoom());
+        int ovalheight=(int) (9*tdp.getZoom());
+
+        Color c = g.getColor();
+        Color c1;
+        switch(checkConfStatus) {
+        case 1:
+            c1 = Color.gray;
+            break;
+        case 2:
+            c1 = Color.green;
+            break;
+        case 3:
+            c1 = Color.red;
+            break;
+        default:
+            return;
+        }
+        g.drawString(mappingName, x-lockwidth*2, y-lockheight);
+        g.drawOval(x-ovalwidth*2, y, ovalwidth, ovalheight);
+        g.setColor(c1);
+        g.fillRect(x-lockwidth*3/2, y+lockheight/2, lockwidth, lockheight);
+        g.setColor(c);
+        g.drawRect(x-lockwidth*3/2, y+lockheight/2, lockwidth, lockheight);
+        if (checkConfStatus==3){
+            g.drawLine(x-lockwidth*2, y, x, y+lockheight*2);
+            g.drawLine(x-lockwidth*2, y+lockheight*2, x, y);
+        }
+        if (!secName.equals("")){
+            switch(checkSecConfStatus) {
+            case 1:
+                c1 = Color.gray;
+                break;
+            case 2:
+                c1 = Color.green;
+                break;
+            case 3:
+                c1 = Color.red;
+                break;
+            default:
+                return;
+            }
+            g.drawString(secName, x-lockwidth*2, y+lockheight*3);
+            g.drawOval(x-ovalwidth*2, y+yoffset, ovalwidth, ovalheight);
+            g.setColor(c1);
+            g.fillRect(x-lockwidth*3/2, y+lockheight/2+yoffset, lockwidth, lockheight);
+            g.setColor(c);
+            g.drawRect(x-lockwidth*3/2, y+lockheight/2+yoffset, lockwidth, lockheight);
+        }
+    }
+
+    public void manageMove() {
+        if (father != null) {
+            Point p = GraphicLib.putPointOnRectangle(x+(width/2), y+(height/2), father.getX(), father.getY(), father.getWidth(), father.getHeight());
+
+            x = p.x - width/2;
+            y = p.y - height/2;
+
+            setMoveCd(x, y);
+
+            int orientation = GraphicLib.getCloserOrientation(x+(width/2), y+(height/2), father.getX(), father.getY(), father.getWidth(), father.getHeight());
+            if (orientation != currentOrientation) {
+                setOrientation(orientation);
+            }
+        }
+    }
+
+    // TGConnecting points ..
+    public void setOrientation(int orientation) {
+        currentOrientation = orientation;
+        double w0, h0;
+
+        switch(orientation) {
+        case GraphicLib.NORTH:
+            w0 = 0.5;
+            h0 = 0.0;
+            break;
+        case GraphicLib.WEST:
+            w0 = 0.0;
+            h0 = 0.5;
+            break;
+        case GraphicLib.SOUTH:
+            w0 = 0.5;
+            h0 = 1.0;
+            break;
+        case GraphicLib.EAST:
+        default:
+            w0 = 1.0;
+            h0 = 0.5;
+        }
+
+        for (int i=0; i<nbConnectingPoint; i++) {
+            ((SysCAMSPortConnectingPoint) connectingPoint[i]).setW(w0);
+            ((SysCAMSPortConnectingPoint) connectingPoint[i]).setH(h0);
+        }
+    }
+
+    public TGComponent isOnOnlyMe(int _x, int _y) {
+        if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) {
+            return this;
+        }
+        return null;
+    }
+
+    public void wasSwallowed() {
+        myColor = null;
+    }
+
+    public void wasUnswallowed() {
+        myColor = null;
+        setFather(null);
+        TDiagramPanel tdp = getTDiagramPanel();
+        setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY());
+    }
+
+    public void resizeWithFather() {
+        if ((father != null) && (father instanceof SysCAMSPrimitiveComponent)) {
+            // Too large to fit in the father? -> resize it!
+            //resizeToFatherSize();
+            setCdRectangle(0-getWidth()/2, father.getWidth() - (getWidth()/2), 0-getHeight()/2, father.getHeight() - (getHeight()/2));
+            setMoveCd(x, y);
+            oldx = -1;
+            oldy = -1;
+        }
+    }
+
+    public boolean editOndoubleClick(JFrame frame) {
+//        int oldSample = maxSamples;
+//
+//        Vector<String> otherTypes;
+//
+//        if (getFather() == null) {
+//            otherTypes = new Vector<String>();
+//        } else {
+//            SysCAMSPrimitiveComponent tgc = (SysCAMSPrimitiveComponent)(getFather());
+//            otherTypes = tgc.getAllRecords();
+//        }
+//        Vector<TGComponent> refs = new Vector<TGComponent>();
+//        for (TGComponent req: tdp.getMGUI().getAllRequirements()){
+//            if (req instanceof AvatarRDRequirement){
+//                refs.add(req);
+//            }
+//        }
+
+//        JDialogTMLCompositePort jda = new JDialogTMLCompositePort(commName, typep, list[0], list[1], list[2], list[3], list[4], isOrigin, isFinite, isBlocking, ""+maxSamples, ""+widthSamples, isLossy, lossPercentage, maxNbOfLoss, frame, "Port properties", otherTypes, dataFlowType, associatedEvent, isPrex, isPostex, checkConf, checkAuth, reference, refs);
+//        GraphicLib.centerOnParent(jda, 350, 700 );
+//        jda.setVisible( true );
+//        dataFlowType = jda.getDataFlowType();
+//        associatedEvent = jda.getAssociatedEvent();
+//        isPrex = jda.isChannelPrex();
+//        isPostex = jda.isChannelPostex();
+
+//        TraceManager.addDev( "The Data flow type is: " + dataFlowType );
+//        TraceManager.addDev( "The Associated event is: " + associatedEvent );
+
+//        if (jda.hasNewData()) {
+//            try {
+//                maxSamples = Integer.decode(jda.getMaxSamples()).intValue();
+//                widthSamples = Integer.decode(jda.getWidthSamples()).intValue();
+//                if (maxSamples < 1) {
+//                    maxSamples = oldSample;
+//                    JOptionPane.showMessageDialog(frame, "Non valid value: " + maxSamples + ": Should be at least 1", "Error", JOptionPane.INFORMATION_MESSAGE);
+//                    return false;
+//                }
+//                isOrigin = jda.isOrigin();
+//                isFinite = jda.isFinite();
+//                isBlocking = jda.isBlocking();
+//                setPortName(jda.getParamName());
+//                commName = jda.getParamName();
+//                isLossy = jda.isLossy();
+//                lossPercentage = jda.getLossPercentage();
+//                maxNbOfLoss = jda.getMaxNbOfLoss();
+//                oldTypep = typep;
+//                typep = jda.getPortType();
+//                checkConf = jda.checkConf;
+//                reference = jda.getReference();
+//                if (checkConf){
+//                    if (checkConfStatus == NOCHECK){
+//                        checkConfStatus = TOCHECK;
+//                    }
+//                }
+//                else {
+//                    if (checkConfStatus != NOCHECK){
+//                        checkConfStatus = NOCHECK;
+//                    }
+//                }
+//                checkAuth = jda.checkAuth;
+//                if (checkStrongAuthStatus < 2){
+//                	checkStrongAuthStatus = 1;
+//                	checkWeakAuthStatus = 1;
+//                }
+//                for(int i=0; i<nbMaxAttribute; i++) {
+//                    list[i].setType(jda.getStringType(i));
+//                }
+//            } catch (Exception e) {
+//                JOptionPane.showMessageDialog(frame, "Non valid value: " + e.getMessage(), "Error", JOptionPane.INFORMATION_MESSAGE);
+//                return false;
+//            }
+//        }
+    	
+    	if (this instanceof SysCAMSPortTDF) {
+    		JDialogSysCAMSPortTDF jtdf = new JDialogSysCAMSPortTDF((SysCAMSPortTDF) this);
+    		jtdf.setVisible(true);
+    	} else {
+    		JDialogSysCAMSPortDE jde = new JDialogSysCAMSPortDE((SysCAMSPortDE) this);
+    		jde.setVisible(true);
+    	}
+    	
+        ((SysCAMSComponentTaskDiagramPanel)tdp).updatePorts();
+        return true;
+    }
+
+    protected String translateExtraParam() {
+        TType a;
+        StringBuffer sb = new StringBuffer("<extraparam>\n");
+        sb.append("<Prop commName=\"");
+        sb.append(commName);
+        sb.append("\" commType=\"" + typep);
+        sb.append("\" origin=\"");
+        if (isOrigin) {
+            sb.append("true");
+        } else {
+            sb.append("false");
+        }
+        sb.append("\" finite=\"");
+        if (isFinite) {
+            sb.append("true");
+        } else {
+            sb.append("false");
+        }
+        sb.append("\" blocking=\"");
+        if (isBlocking) {
+            sb.append("true");
+        } else {
+            sb.append("false");
+        }
+        sb.append("\" maxSamples=\"" + maxSamples);
+        sb.append("\" widthSamples=\"" + widthSamples);
+        sb.append("\" isLossy=\"" + isLossy);
+        sb.append("\" isPrex=\"" + isPrex);
+        sb.append("\" isPostex=\"" + isPostex);
+        sb.append("\" lossPercentage=\"" + lossPercentage);
+        sb.append("\" maxNbOfLoss=\"" + maxNbOfLoss);
+        sb.append("\" dataFlowType=\"" + dataFlowType);
+        sb.append("\" associatedEvent=\"" + associatedEvent);
+        sb.append("\" checkConf=\"" + checkConf);
+        sb.append("\" checkConfStatus=\"" + checkConfStatus);
+        sb.append("\" checkAuth=\"" + checkAuth);
+        sb.append("\" checkWeakAuthStatus=\"" + checkWeakAuthStatus);
+        sb.append("\" checkStrongAuthStatus=\"" + checkStrongAuthStatus);
+        sb.append("\" />\n");
+        for(int i=0; i<nbMaxAttribute; i++) {
+            a = list[i];
+            sb.append("<Type");
+            sb.append(" type=\"");
+            sb.append(a.getType());
+            sb.append("\" typeOther=\"");
+            sb.append(a.getTypeOther());
+            sb.append("\" />\n");
+        }
+        sb.append("</extraparam>\n");
+        return new String(sb);
+    }
+
+    public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{
+        try {
+            NodeList nli;
+            Node n1, n2;
+            Element elt;
+            int typeAtt;
+            String typeOther;
+            int nbAttribute = 0;
+
+            for(int i=0; i<nl.getLength(); i++) {
+                n1 = nl.item(i);
+                if (n1.getNodeType() == Node.ELEMENT_NODE) {
+                    nli = n1.getChildNodes();
+                    for(int j=0; j<nli.getLength(); j++) {
+                        n2 = nli.item(j);
+                        if (n2.getNodeType() == Node.ELEMENT_NODE) {
+                            elt = (Element) n2;
+                            if ((elt.getTagName().equals("Type")) && (nbAttribute < nbMaxAttribute)) {
+                                typeAtt = Integer.decode(elt.getAttribute("type")).intValue();
+                                try {
+                                    typeOther = elt.getAttribute("typeOther");
+                                } catch (Exception e) {
+                                    typeOther = "";
+                                }
+                                TType ta = new TType(typeAtt, typeOther);
+                                list[nbAttribute] = ta;
+                                nbAttribute ++;
+                            }
+                            if (elt.getTagName().equals("Prop")) {
+                                commName = elt.getAttribute("commName");
+                                try {
+                                    typep = Integer.decode(elt.getAttribute("commType")).intValue();
+                                    maxSamples = Integer.decode(elt.getAttribute("maxSamples")).intValue();
+                                    widthSamples = Integer.decode(elt.getAttribute("widthSamples")).intValue();
+                                } catch (Exception e) {
+                                }
+                                try {
+                                    lossPercentage = Integer.decode(elt.getAttribute("lossPercentage")).intValue();
+                                    maxNbOfLoss = Integer.decode(elt.getAttribute("maxNbOfLoss")).intValue();
+                                    dataFlowType = elt.getAttribute("dataFlowType");
+                                    associatedEvent = elt.getAttribute("associatedEvent");
+                                    checkConf = (elt.getAttribute("checkConf").compareTo("true")==0);
+                                    if (checkConf){
+                                        checkConfStatus=TOCHECK;
+                                    }
+                                    checkAuth = (elt.getAttribute("checkAuth").compareTo("true")==0);
+                                    isLossy = (elt.getAttribute("isLossy").compareTo("true") ==0);
+                                    isPrex = (elt.getAttribute("isPrex").compareTo("true") ==0);
+                                    isPostex = (elt.getAttribute("isPostex").compareTo("true") ==0);
+                                } catch (Exception e) {
+                                    lossPercentage = 0;
+                                    maxNbOfLoss = -1;
+                                    isLossy = false;
+                                }
+                                try {
+                                    isBlocking = (elt.getAttribute("blocking").compareTo("true") ==0);
+                                    isOrigin = (elt.getAttribute("origin").compareTo("true") ==0);
+                                    isFinite = (elt.getAttribute("finite").compareTo("true") ==0);
+
+                                } catch (Exception e) {}
+                            }
+                            makeValue();
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            throw new MalformedModelingException();
+        }
+    }
+
+    public void makeValue() {
+        value = getPortTypeName() + " " + getPortName();
+    }
+
+    public String getPortName() {
+        return commName;
+    }
+
+    public int getPortType() {
+        return typep;
+    }
+
+    public String getPortTypeName() {
+        switch(typep) {
+        case 0:
+            return "Channel";
+        case 1:
+            return "Event";
+        case 2:
+        default:
+            return "Request";
+        }
+    }
+
+    public boolean isBlocking() {
+        return isBlocking;
+    }
+
+    public boolean isFinite() {
+        return isFinite;
+    }
+
+    public int getMax() {
+        return maxSamples;
+    }
+
+    public int getSize() {
+        return widthSamples;
+    }
+
+    public boolean isOrigin() {
+        return isOrigin;
+    }
+
+    public int getNbMaxAttribute() {
+        return nbMaxAttribute;
+    }
+
+    public TType getParamAt(int index) {
+        return list[index];
+    }
+    public void setParam(int index, TType t){
+        list[index] = t;
+    }
+
+    public int getDefaultConnector() {
+        return TGComponentManager.CONNECTOR_PORT_TMLC;
+    }
+
+    public String getAttributes() {
+        String attr = "";
+        if (isOrigin()) {
+            attr += "out ";
+        } else {
+            attr += "in ";
+        }
+        attr += getPortTypeName() + ": ";
+        attr += getPortName() + "\n";
+        // Channel
+        if (typep == 0) {
+            if (!isBlocking()) {
+                attr += "N";
+            }
+            attr += "B";
+            if (isOrigin()) {
+                attr += "W\n";
+                attr += "Width (in B): " + getSize() + "\n";
+                if (isFinite()) {
+                    attr += "Max samples: " + getNbMaxAttribute() + "\n";
+                } else {
+                    attr += "Infinite\n";
+                }
+            } else {
+                attr += "R\n";
+            }
+            // Event and Request
+        } else {
+            attr += "(";
+            for(int i=0; i<nbMaxAttribute; i++) {
+                if (i!=0) {
+                    attr += ",";
+                }
+                attr += TType.getStringType(list[i].getType());
+            }
+            attr += ")\n";
+            if (typep == 1) {
+                if (isOrigin()) {
+                    if (!isFinite()) {
+                        attr += "Infinite FIFO\n";
+                    } else {
+                        if (isBlocking()) {
+                            attr += "Blocking ";
+                        } else {
+                            attr += "Non-blocking ";
+                        }
+                        attr += "finite FIFO: " + getMax() + "\n";
+                    }
+                }
+            }
+        }
+        if (conflict) {
+            attr += "Error in path=" + conflictMessage;
+        }
+        return attr;
+    }
+
+    public boolean isLossy() {
+        return isLossy && isOrigin;
+    }
+
+    public int getLossPercentage() {
+        return lossPercentage;
+    }
+
+    public int getMaxNbOfLoss() {
+        return maxNbOfLoss;
+    }
+
+    public boolean getConflict() {
+        return conflict;
+    }
+
+    public void setConflict(boolean _conflict, String _msg) {
+        conflict = _conflict;
+        myColor = null;
+        conflictMessage = _msg;
+        calculatePortColor();
+    }
+
+    public void calculatePortColor() {
+        if (conflict) {
+            myColor = Color.red;
+        } else {
+//            if (typep == 0) {
+//                myColor = ColorManager.TML_PORT_CHANNEL;
+//            } else if (typep == 1) {
+//                myColor = ColorManager.TML_PORT_EVENT;
+//            } else {
+//                myColor = ColorManager.TML_PORT_REQUEST;
+//            }
+        	if (this instanceof SysCAMSPortTDF) {
+        		myColor = Color.lightGray;
+        	} else {
+        		myColor = Color.white;
+        	}
+        }
+    }
+
+    public String getDataFlowType() {
+        return dataFlowType;
+    }
+
+    public boolean isPrex() {
+        return isPrex;
+    }
+
+    public boolean isPostex() {
+        return isPostex;
+    }
+
+    public String getAssociatedEvent() {
+        return associatedEvent;
+    }
+
+    public boolean hasSameParametersThan(SysCAMSPrimitivePort _p) {
+        for(int i=0; i<5; i++) {
+            if (!(getParamAt(i).equals(_p.getParamAt(i)))) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    public void setPortName(String s) {
+        for (TURTLEPanel tp : tdp.getMainGUI().tabs) {
+            for (TDiagramPanel t : tp.getPanels()) {
+                for (TGComponent t2 : t.getComponentList()) {
+                    if (t2 instanceof TMLArchiCPNode) {
+                        TMLArchiCPNode tacn = (TMLArchiCPNode) t2;
+                        for (TGComponent tgc : tacn.getRecursiveAllInternalComponent()) {
+                            if (tgc instanceof TMLArchiPortArtifact) {
+                                TMLArchiPortArtifact tapi = (TMLArchiPortArtifact) tgc;
+                                String tmp = tapi.getValue().replaceAll("(?i)" + commName + "$", s);
+                                tapi.setValue(tmp);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        if ( (father != null) && (father instanceof SysCAMSPrimitiveComponent)) {
+            String name = father.getValue();
+            TURTLEPanel tp = tdp.getMainGUI().getCurrentTURTLEPanel();
+            for (TDiagramPanel t : tp.getPanels()) {
+                if (t.getName().compareTo(name) == 0) {
+                    for (TGComponent t2 : t.getComponentList()) {
+                        if (t2 instanceof TMLADWriteChannel) {
+                            TMLADWriteChannel twc = (TMLADWriteChannel) t2;
+                            if (twc.getChannelName().equals(commName))
+                                twc.setChannelName(s);
+                        }
+                        if (t2 instanceof TMLADReadChannel) {
+                            TMLADReadChannel trc = (TMLADReadChannel) t2;
+                            if (trc.getChannelName().equals(commName))
+                                trc.setChannelName(s);
+                        }
+                        if (t2 instanceof TMLADSendEvent) {
+                            TMLADSendEvent tse = (TMLADSendEvent) t2;
+                            if (tse.getEventName().equals(commName))
+                                tse.setEventName(s);
+                        }
+                        if (t2 instanceof TMLADSendRequest) {
+                            TMLADSendRequest tsr = (TMLADSendRequest) t2;
+                            if (tsr.getRequestName().equals(commName))
+                                tsr.setRequestName(s);
+                        }
+                        if (t2 instanceof TMLADWaitEvent) {
+                            TMLADWaitEvent twe = (TMLADWaitEvent) t2;
+                            if (twe.getEventName().equals(commName))
+                                twe.setEventName(s);
+                        }
+                        if (t2 instanceof TMLADNotifiedEvent) {
+                            TMLADNotifiedEvent tne = (TMLADNotifiedEvent) t2;
+                            if (tne.getEventName().equals(commName))
+                                tne.setEventName(s);
+                        }
+                    }
+                    t.repaint();
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSRecordComponent.java b/src/main/resources/ui/syscams/SysCAMSRecordComponent.java
new file mode 100644
index 0000000000..b74e5adab7
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSRecordComponent.java
@@ -0,0 +1,420 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import ui.*;
+import ui.util.IconManager;
+import ui.window.JDialogAttribute;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.LinkedList;
+
+/**
+ * Class SysCAMSRecordComponent
+ * Record Component. To be used in SystemC-AMS component task diagrams
+ * Creation: 22/04/2018
+ * @version 1.0 22/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSRecordComponent extends TGCScalableWithInternalComponent implements SwallowedTGComponent {
+	private int maxFontSize = 14;
+	private int minFontSize = 4;
+	private int currentFontSize = -1;
+	private boolean displayText = true;
+	private Color myColor;
+	
+	// Icon
+	private int iconSize = 15;
+	
+	// Attributes
+	protected LinkedList<TAttribute> myAttributes;
+	private int textX = 15; // border for ports
+	private double dtextX = 0.0;
+	
+	public String oldValue;
+    
+    public SysCAMSRecordComponent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+        
+		initScaling(200, 150);
+		
+		oldScaleFactor = tdp.getZoom();
+		dtextX = textX * oldScaleFactor;
+		textX = (int)dtextX;
+		dtextX = dtextX - textX;
+		
+        minWidth = 1;
+        minHeight = 1;
+        
+        nbConnectingPoint = 0;
+       
+        addTGConnectingPointsComment();
+        
+        nbInternalTGComponent = 0;
+        
+        moveable = true;
+        multieditable = true;
+		editable = true;
+        removable = true;
+        userResizable = true;
+        
+		value = tdp.findTMLRecordComponentName("Record_");
+		oldValue = value;
+		setName("Record component");
+		
+        myImageIcon = IconManager.imgic1202;
+		
+		myAttributes = new LinkedList<TAttribute> ();
+		
+		actionOnAdd();
+    }
+    
+    public void internalDrawing(Graphics g) {
+		int w;
+		Font f = g.getFont();
+		Font fold = f;
+		
+		if (myColor == null) {
+			myColor = new Color(193, 218, 241- (getMyDepth() * 10), 200);
+		}
+		
+		if ((rescaled) && (!tdp.isScaled())) {
+			
+			if (currentFontSize == -1) {
+				currentFontSize = f.getSize();
+			}
+			rescaled = false;
+			// Must set the font size ..
+			// Find the biggest font not greater than max_font size
+			// By Increment of 1
+			// Or decrement of 1
+			// If font is less than 4, no text is displayed
+			
+			int maxCurrentFontSize = Math.max(0, Math.min(height-(2*textX), maxFontSize));
+			
+			f = f.deriveFont((float)maxCurrentFontSize);
+			g.setFont(f);
+			while(maxCurrentFontSize > (minFontSize-1)) {
+				if (g.getFontMetrics().stringWidth(value) < (width - iconSize - (2 * textX))) {
+					break;
+				}
+				maxCurrentFontSize --;
+				f = f.deriveFont((float)maxCurrentFontSize);
+				g.setFont(f);
+			}
+			
+			currentFontSize = maxCurrentFontSize;
+			
+			if(currentFontSize <minFontSize) {
+				displayText = false;
+			} else {
+				displayText = true;
+				f = f.deriveFont((float)currentFontSize);
+				g.setFont(f);
+			}
+		}
+		
+		// Zoom is assumed to be computed
+		Color c = g.getColor();
+		g.drawRect(x, y, width, height);
+		if ((width > 2) && (height > 2)) {
+			g.setColor(myColor);
+			g.fillRect(x+1, y+1, width-1, height-1);
+			g.setColor(c);
+		}
+		
+        // Font size 
+		if (displayText) {
+			f = f.deriveFont((float)currentFontSize);
+			g.setFont(f);
+			w = g.getFontMetrics().stringWidth(value);
+			if (w > (width - 2 * (iconSize + textX))) {
+				g.drawString(value, x + textX + 1, y + currentFontSize + textX);
+			} else {
+				g.drawString(value, x + (width - w)/2, y + currentFontSize + textX);
+			}
+		}
+		
+		// Icon
+		if ((width>30) && (height > (iconSize + 2*textX))) {
+			g.drawImage(IconManager.imgic1200.getImage(), x + width - iconSize - textX, y + textX, null);
+		} 
+
+		// Attributes
+		if (tdp.areAttributesVisible()) {
+			int index = 0;
+			int cpt = currentFontSize + 2 * textX;
+			String attr;
+			
+			TAttribute a;
+           
+			int si = Math.min(12, (int)((float)currentFontSize - 2));
+			
+			f = g.getFont();
+			f = f.deriveFont((float)si);
+			g.setFont(f);
+			int step = si + 2;
+			
+			while(index < myAttributes.size()) {
+				cpt += step;
+				if (cpt >= (height - textX)) {
+					break;
+				}
+				a = myAttributes.get (index);
+				attr = a.toString();
+				w = g.getFontMetrics().stringWidth(attr);
+				if ((w + (2 * textX) + 1) < width) {
+					g.drawString(attr, x + textX, y + cpt);
+				} else {
+					attr = "...";
+					w = g.getFontMetrics().stringWidth(attr);
+					if ((w + textX + 2) < width) {
+						g.drawString(attr, x + textX + 1, y + cpt);
+					} else {
+						// skip attribute
+						cpt -= step;
+					}
+				}
+				index ++;
+			}
+		}
+		g.setFont(fold);
+    }
+	
+	public void rescale(double scaleFactor){
+		dtextX = (textX + dtextX) / oldScaleFactor * scaleFactor;
+		textX = (int)(dtextX);
+		dtextX = dtextX - textX; 
+		
+		super.rescale(scaleFactor);
+	}
+    
+    public TGComponent isOnOnlyMe(int _x, int _y) {
+		if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) {
+            return this;
+        }
+        return null;
+    }
+    
+    public boolean editOndoubleClick(JFrame frame, int _x, int _y) {
+		// On the name ?
+		if ((displayText) && (_y <= (y + currentFontSize + textX))) {
+			oldValue = value;
+			String s = (String)JOptionPane.showInputDialog(frame, "Name:", "Setting component name",
+			JOptionPane.PLAIN_MESSAGE, IconManager.imgic100,
+			null,
+			getValue());
+			if ((s != null) && (s.length() > 0)) {
+				// Check whether this name is already in use, or not 
+				
+				if (!TAttribute.isAValidId(s, false, false)) {
+					JOptionPane.showMessageDialog(frame,
+						"Could not change the name of the component: the new name is not a valid name",
+						"Error",
+						JOptionPane.INFORMATION_MESSAGE);
+					return false;
+				}
+				
+				if (((SysCAMSComponentTaskDiagramPanel)(tdp)).nameRecordComponentInUse(oldValue, s)) {
+					JOptionPane.showMessageDialog(frame,
+						"Error: the name is already in use",
+						"Name modification",
+						JOptionPane.ERROR_MESSAGE);
+					return false;
+				} else {
+					setValueWithChange(s);
+					rescaled = true;
+					return true;
+				}
+			}
+			return false;
+		}
+		
+		// And so -> attributes!
+		JDialogAttribute jda = new JDialogAttribute(myAttributes, null, frame, "Setting fields of " + value, "Field");
+        setJDialogOptions(jda);
+        GraphicLib.centerOnParent(jda, 650, 375);
+        jda.setVisible(true); // blocked until dialog has been closed
+		rescaled = true;
+		return true;
+    }
+	
+	protected void setJDialogOptions(JDialogAttribute jda) {
+        jda.addAccess(TAttribute.getStringAccess(TAttribute.PUBLIC));
+        jda.addAccess(TAttribute.getStringAccess(TAttribute.PRIVATE));
+        jda.addType(TAttribute.getStringType(TAttribute.NATURAL), true);
+        jda.addType(TAttribute.getStringType(TAttribute.BOOLEAN), true);
+		jda.enableInitialValue(true);
+        jda.enableRTLOTOSKeyword(true);
+        jda.enableJavaKeyword(false);
+    }
+    
+    public int getType() {
+        return TGComponentManager.TMLCTD_RCOMPONENT;
+    }
+	
+	public void wasSwallowed() {
+		myColor = null;
+	}
+	
+	public void wasUnswallowed() {
+		myColor = null;
+		setFather(null);
+		TDiagramPanel tdp = getTDiagramPanel();
+		setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY());
+	}
+    
+    public void hasBeenResized() {
+		rescaled = true;
+		
+		if (getFather() != null) {
+			resizeWithFather();
+		}
+    }
+	
+	public void resizeWithFather() {
+        if ((father != null) && (father instanceof SysCAMSCompositeComponent)) {
+			// Too large to fit in the father? -> resize it!
+			resizeToFatherSize();
+			
+            setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight());
+            setMoveCd(x, y);
+        }
+    }
+	
+	public int getChildCount() {
+        return myAttributes.size();
+    }
+    
+    public Object getChild(int index) {
+		if (index == 0) {
+			return value;
+		} else {
+			return myAttributes.get (index-1);
+		}
+    }
+    
+    public int getIndexOfChild(Object child) {
+		if (child instanceof String) {
+			return 0;
+		} else {
+			return myAttributes.indexOf(child) + 1;
+		}
+    }
+    
+    protected String translateExtraParam() {
+        TAttribute a;
+        StringBuffer sb = new StringBuffer("<extraparam>\n");
+        for(int i=0; i<myAttributes.size(); i++) {
+            a = myAttributes.get (i);
+            sb.append("<Attribute access=\"");
+            sb.append(a.getAccess());
+            sb.append("\" id=\"");
+            sb.append(a.getId());
+            sb.append("\" value=\"");
+            sb.append(a.getInitialValue());
+            sb.append("\" type=\"");
+            sb.append(a.getType());
+            sb.append("\" typeOther=\"");
+            sb.append(a.getTypeOther());
+            sb.append("\" />\n");
+        }
+        sb.append("</extraparam>\n");
+        return new String(sb);
+    }
+    
+    public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{
+        try {
+            NodeList nli;
+            Node n1, n2;
+            Element elt;
+            int access, type;
+            String typeOther;
+            String id, valueAtt;
+            
+            for(int i=0; i<nl.getLength(); i++) {
+                n1 = nl.item(i);
+                if (n1.getNodeType() == Node.ELEMENT_NODE) {
+                    nli = n1.getChildNodes();
+                    for(int j=0; j<nli.getLength(); j++) {
+                        n2 = nli.item(j);
+                        if (n2.getNodeType() == Node.ELEMENT_NODE) {
+                            elt = (Element) n2;
+                            if (elt.getTagName().equals("Attribute")) {
+                                access = Integer.decode(elt.getAttribute("access")).intValue();
+                                type = Integer.decode(elt.getAttribute("type")).intValue();
+                                try {
+                                    typeOther = elt.getAttribute("typeOther");
+                                } catch (Exception e) {
+                                    typeOther = "";
+                                }
+                                id = elt.getAttribute("id");
+                                valueAtt = elt.getAttribute("value");
+                                
+                                if (valueAtt.equals("null")) {
+                                    valueAtt = "";
+                                }
+                                if ((TAttribute.isAValidId(id, false, false)) && (TAttribute.isAValidInitialValue(type, valueAtt))) {
+                                    TAttribute ta = new TAttribute(access, id, valueAtt, type, typeOther);
+                                    myAttributes.add (ta);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            throw new MalformedModelingException();
+        }
+    }
+	
+	public int getCurrentFontSize() {
+		return currentFontSize;
+	}
+	
+	public LinkedList<TAttribute> getAttributes() {
+		return myAttributes;
+	}
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSReferencePortConnectingPoint.java b/src/main/resources/ui/syscams/SysCAMSReferencePortConnectingPoint.java
new file mode 100644
index 0000000000..88945a228f
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSReferencePortConnectingPoint.java
@@ -0,0 +1,122 @@
+/* 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.syscams;
+
+import ui.CDElement;
+import ui.TGComponent;
+
+/**
+ * Class SysCAMSReferencePortConnectingPoint
+ * Definition of referenced connecting points on which connectors of SystemC-AMS Component Task diagrams can be connected
+ * Creation: 27/04/2018
+ * @version 1.0 27/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSReferencePortConnectingPoint extends SysCAMSPortConnectingPoint{
+    
+	private SysCAMSCompositePort port;
+	
+    public SysCAMSReferencePortConnectingPoint(SysCAMSCompositePort _port, CDElement _container, double _w, double _h) {
+        super(_container, 0, 0, true, true, _w, _h);
+		port = _port;
+    }
+	
+	public void setPort(SysCAMSCompositePort _port) {
+		port = _port;
+	}
+	
+	public SysCAMSCompositePort getPort() {
+		return port;
+	}
+	
+	public static double getDecX(SysCAMSCompositePort _port) {
+		if (_port != null) {
+			TGComponent tgc = _port.getFather();
+			if (tgc != null) {
+				int x1 = _port.getX() + _port.getWidth()/2;
+				int x2 = tgc.getX();
+				int w1 = tgc.getWidth();
+				return ((double)x1 - x2) / w1;
+			}
+		}
+		return 0;
+	}
+	
+	public double getDecX() {
+		if (port != null) {
+			return getDecX(port);
+		}
+		return 0;
+	}
+	
+	public static double getDecY(SysCAMSCompositePort _port) {
+		if (_port != null) {
+			TGComponent tgc = _port.getFather();
+			if (tgc != null) {
+				int y1 = _port.getY() + _port.getHeight()/2;
+				int y2 = tgc.getY();
+				int h1 = tgc.getHeight();
+				return ((double)y1 - y2) / h1;
+			}
+		}
+		return 0;
+	}
+	
+	public double getDecY() {
+		if (port != null) {
+			return getDecY(port);
+		}
+		return 0;
+	}
+	
+	public int getX() {
+		if (container != null) {
+			return x + container.getX() + (int)(container.getWidth() * getDecX());
+		}
+		return x;
+    }
+    
+    public int getY() {
+		if (container != null) {
+			return y + container.getY() + (int)(container.getHeight() * getDecY());
+		}
+		return y;
+    }
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSRemoteCompositeComponent.java b/src/main/resources/ui/syscams/SysCAMSRemoteCompositeComponent.java
new file mode 100644
index 0000000000..b85c1ea3c7
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSRemoteCompositeComponent.java
@@ -0,0 +1,596 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+import myutil.TraceManager;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import ui.*;
+import ui.util.IconManager;
+//import ui.window.JDialogTMLRemoteCompositeComponent;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.ArrayList;
+
+/**
+* Class SysCAMSRemoteCompositeComponent
+* Composite Component. To be used in SystemC-AMS diagrams
+ * Creation: 27/04/2018
+ * @version 1.0 27/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSRemoteCompositeComponent extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent {
+	private int maxFontSize = 20;
+	private int minFontSize = 4;
+	private int currentFontSize = -1;
+	private boolean displayText = true;
+	private Color myColor;
+	private int iconSize = 17;
+	private boolean iconIsDrawn = false;
+	
+	private int textX = 15; // border for ports
+	private double dtextX = 0.0;	
+	
+	private int defaultDiag = 10;
+	private double ddefaultDiag = 0.0;
+	
+	private SysCAMSCompositeComponent syscamscc;
+	private ArrayList<SysCAMSCompositePort> ports;
+	
+	private NodeList nl;
+    
+    public SysCAMSRemoteCompositeComponent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+        
+		initScaling(250, 200);
+		
+		oldScaleFactor = tdp.getZoom();
+		dtextX = textX * oldScaleFactor;
+		textX = (int)dtextX;
+		dtextX = dtextX - textX;
+		
+        minWidth = 1;
+        minHeight = 1;
+        
+        nbConnectingPoint = 0;
+        nbInternalTGComponent = 0;
+        
+        moveable = true;
+        editable = true;
+        removable = true;
+        userResizable = true;
+		multieditable = true;
+        
+		value = "No reference";
+		name = "Remote composite component";
+		
+		ports = new ArrayList<SysCAMSCompositePort>();
+		
+        myImageIcon = IconManager.imgic1200;
+    }
+	
+	public void updateReference(SysCAMSCompositeComponent syscamsccc) {
+		if (syscamscc == syscamsccc) {
+			updateReference();
+		}
+	}
+	
+	public void updateReference() {
+		if (syscamscc != null) {
+			if (syscamscc.getTDiagramPanel() == null) {
+				syscamscc = null;
+				value =  "No reference";
+			} else {
+				// Update
+				value = syscamscc.getExtendedValue();
+				updatePorts();
+			}
+		}
+	}
+    
+    public void internalDrawing(Graphics g) {
+		int w;
+		int c;
+		Font f = g.getFont();
+		Font fold = f;
+		
+		if (syscamscc == null) {
+			// Use value to find the component
+			syscamscc = tdp.getMGUI().getSysCAMSCompositeComponent(value);
+			if (syscamscc == null) {
+				value =  "No reference";
+			}
+		} else {
+			if (syscamscc.getTDiagramPanel() == null) {
+				syscamscc = null;
+				value =  "No reference";
+			} else {
+				if (ports.size() != syscamscc.getCompositePortNb()) {
+					updateReference();
+				}
+			}
+		}
+		if (myColor == null) {
+			myColor = new Color(251, 252, 200- (getMyDepth() * 10), 200);
+		}
+		
+		if ((rescaled) && (!tdp.isScaled())) {
+			if (currentFontSize == -1) {
+				currentFontSize = f.getSize();
+			}
+			rescaled = false;
+			// Must set the font size ..
+			// Find the biggest font not greater than max_font size
+			// By Increment of 1
+			// Or decrement of 1
+			// If font is less than 4, no text is displayed
+			int maxCurrentFontSize = Math.max(0, Math.min(height-(2*textX), maxFontSize));
+			while(maxCurrentFontSize > (minFontSize-1)) {
+				f = f.deriveFont((float)maxCurrentFontSize);
+				g.setFont(f);
+				w = g.getFontMetrics().stringWidth(value);
+				c = width - iconSize - (2 * textX);
+				if (w < c) {
+					break;
+				}
+				maxCurrentFontSize --;
+			}
+			currentFontSize = maxCurrentFontSize;
+            displayText = currentFontSize >= minFontSize;
+		}
+		
+		// Zoom is assumed to be computed
+		Color col = g.getColor();
+		g.drawRect(x, y, width, height);
+		if ((width > 2) && (height > 2)) {
+			g.setColor(myColor);
+			g.fillRect(x+1, y+1, width-1, height-1);
+			g.setColor(col);
+		}
+		
+        // Font size 
+		if (displayText) {
+			f = f.deriveFont((float)currentFontSize);
+			g.setFont(f);
+			w = g.getFontMetrics().stringWidth(value);
+			if (!(w < (width - 2 * (iconSize + textX)))) {
+				g.drawString(value, x + textX + 1, y + currentFontSize + textX);
+			} else {
+				g.drawString(value, x + (width - w)/2, y + currentFontSize + textX);
+			}
+		}
+		g.setFont(fold);
+		
+		// Icon
+		if ((width>30) && (height > (iconSize + 2*textX))) {
+			g.drawImage(IconManager.imgic1200.getImage(), x + width - iconSize - textX, y + textX, null);
+			iconIsDrawn = true;
+		} else {
+			iconIsDrawn = false;
+		}
+    }
+	
+	public void rescale(double scaleFactor){
+		dtextX = (textX + dtextX) / oldScaleFactor * scaleFactor;
+		textX = (int)(dtextX);
+		dtextX = dtextX - textX; 
+		
+		ddefaultDiag = (defaultDiag + ddefaultDiag) / oldScaleFactor * scaleFactor;
+		defaultDiag = (int)(ddefaultDiag);
+		ddefaultDiag = ddefaultDiag - defaultDiag; 
+		
+		super.rescale(scaleFactor);
+	}
+    
+    public TGComponent isOnOnlyMe(int _x, int _y) {
+		if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) {
+            return this;
+        }
+        return null;
+    }
+    
+    public boolean editOndoubleClick(JFrame frame, int _x, int _y) {
+		// On the icon?
+		if (iconIsDrawn && (syscamscc != null)) {
+			if (GraphicLib.isInRectangle(_x, _y, x + width - iconSize - textX, y + textX, iconSize, iconSize)) {
+				boolean b = tdp.getMGUI().selectHighLevelTab(syscamscc.getValuePanel());
+				if (b) {
+					return false;
+				}
+			}
+		}
+		
+//		JDialogTMLRemoteCompositeComponent dialog = new JDialogTMLRemoteCompositeComponent(frame, "Setting referenced component", this);
+//        GraphicLib.centerOnParent(dialog, 400, 350);
+//        dialog.setVisible( true ); // blocked until dialog has been closed
+//        
+//		if (!dialog.isRegularClose()) {
+//			return false;
+//		}
+//		
+//		if (dialog.getReferenceComponentName() == null) {
+//			return false;
+//		}
+//		
+//		if (dialog.getReferenceComponentName().length() != 0) {
+//			tmlcc = getTDiagramPanel().getMGUI().getCompositeComponent(dialog.getReferenceComponentName());
+//			if (tmlcc != null ){
+//				updateReference();
+//				rescaled = true;
+//			}
+//			tdp.repaint();
+//		}
+		return false;
+    }
+	
+	protected String translateExtraParam() {
+        StringBuffer sb = new StringBuffer("<extraparam>\n");
+		sb.append("<info ref=\"" + value + "\" "); 
+        sb.append("/>\n");
+		
+		for (SysCAMSCompositePort port: ports) {
+			sb.append("<port id=\"" + port.getId() + "\" />\n");
+		}
+        sb.append("</extraparam>\n");
+        return new String(sb);
+    }
+	
+	public void loadExtraParam(NodeList _nl, int decX, int decY, int decId) throws MalformedModelingException{
+		nl = _nl;
+	}
+	
+	public void delayedLoad() throws MalformedModelingException {
+        try {
+            NodeList nli;
+            Node n1, n2;
+            Element elt;
+			int j, k;
+			int index;
+			int cptk = 0;
+			SysCAMSRemotePortCompositeComponent pcc;
+			TGConnectingPoint[] old = null;
+			ArrayList<SysCAMSCompositePort> tmp = null;
+			
+            for(int i=0; i<nl.getLength(); i++) {
+                n1 = nl.item(i);
+                if (n1.getNodeType() == Node.ELEMENT_NODE) {
+                    nli = n1.getChildNodes();
+                    for(j=0; j<nli.getLength(); j++) {
+                        n2 = nli.item(j);
+                        if (n2.getNodeType() == Node.ELEMENT_NODE) {
+                            elt = (Element) n2;
+                            if (elt.getTagName().equals("info")) {
+								value = elt.getAttribute("ref");
+								syscamscc = getTDiagramPanel().getMGUI().getSysCAMSCompositeComponent(value);
+								if (syscamscc != null ){
+									updateReference();
+									rescaled = true;
+									tmp = ports;
+									ports = new ArrayList<SysCAMSCompositePort>();
+									for (SysCAMSCompositePort port: tmp) {
+										ports.add(port);
+									}
+								}
+							}
+							
+							if (elt.getTagName().equals("port")) {
+								if (old == null) {
+									old =  connectingPoint;
+									connectingPoint = new TGConnectingPoint[nbConnectingPoint];
+								}
+								try {
+									int portid = Integer.decode(elt.getAttribute("id")).intValue();
+									
+									for (SysCAMSCompositePort port: tmp) {
+										if (port.getId() == portid) {
+											index = tmp.indexOf(port);
+											for (k=index*5; k<(index+1)*5; k++) {
+												// Must update position of connecting point
+												connectingPoint[k] = old[cptk];
+												
+												if ((k % 5) == 0) {
+													if (nbInternalTGComponent > (k/5)) {
+														pcc = (SysCAMSRemotePortCompositeComponent)(tgcomponent[k/5]);
+														if (pcc != null) {
+															pcc.setElements(port, (SysCAMSReferencePortConnectingPoint)(connectingPoint[k]));
+														}
+													}
+												}
+												((SysCAMSReferencePortConnectingPoint)(connectingPoint[k])).setPort(port);
+												if (connectingPoint[k] == null) {
+													TraceManager.addDev("null cp");
+												}
+												cptk ++;
+											}
+											break;
+										}
+									}
+								} catch (Exception e) {
+								}
+							}
+							
+                        }
+                    }
+                }
+            }
+			// Make paths
+			((SysCAMSComponentTaskDiagramPanel)getTDiagramPanel()).makePaths();
+        } catch (Exception e) {
+            throw new MalformedModelingException();
+        }
+    }
+    
+    public int getType() {
+        return TGComponentManager.TMLCTD_CREMOTECOMPONENT;
+    }
+	
+	public void wasSwallowed() {
+		myColor = null;
+	}
+	
+	public void wasUnswallowed() {
+		myColor = null;
+		setFather(null);
+		TDiagramPanel tdp = getTDiagramPanel();
+		setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY());
+	}
+
+	public void hasBeenResized() {
+		rescaled = true;
+		if (getFather() != null) {
+			resizeWithFather();
+		}
+    }
+	
+	public void resizeWithFather() {
+        if ((father != null) && ((father instanceof SysCAMSCompositeComponent) ||(father instanceof SysCAMSPrimitiveComponent))) {
+			// Too large to fit in the father? -> resize it!
+			resizeToFatherSize();
+            setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight());
+            setMoveCd(x, y);
+        }
+    }
+	
+	public java.util.List<SysCAMSPrimitiveComponent> getAllPrimitiveComponents() {
+		if (syscamscc == null) {
+			return new ArrayList<SysCAMSPrimitiveComponent>();
+		}
+		return syscamscc.getAllPrimitiveComponents();
+	}
+	
+	public java.util.List<SysCAMSRecordComponent> getAllRecordComponents() {
+		if (syscamscc == null) {
+			return new ArrayList<SysCAMSRecordComponent>();
+		}
+		return syscamscc.getAllRecordComponents();
+	}
+	
+	public java.util.List<SysCAMSCompositePort> getAllInternalCompositePorts() {
+		java.util.List<SysCAMSCompositePort> list = new ArrayList<SysCAMSCompositePort>();
+		if (syscamscc == null) {
+			return list;
+		}
+		return syscamscc.getAllInternalCompositePorts();
+	}
+	
+	public ArrayList<SysCAMSPrimitivePort> getAllInternalPrimitivePorts() {
+		ArrayList<SysCAMSPrimitivePort> list = new ArrayList<SysCAMSPrimitivePort>();
+		if (syscamscc == null) {
+			return list;
+		}
+		return syscamscc.getAllInternalPrimitivePorts();
+	}
+	
+	public SysCAMSPrimitiveComponent getPrimitiveComponentByName(String _name) {
+		if (syscamscc == null) {
+			return null;
+		}
+		return syscamscc.getPrimitiveComponentByName(_name);
+	}
+	
+	public void drawTGConnectingPoint(Graphics g, int type) {
+        for (int i=0; i<nbConnectingPoint; i++) {
+            if (connectingPoint[i].isCompatibleWith(type)) {
+                connectingPoint[i].draw(g);
+            }
+        }
+    }
+	
+	// 5 tgconnecting per port: we show only them toward the exterior of the component
+	// Add to ports the new port and remove to ports the removed ports
+	// Update tgconnecting points accordingly. Those points should point to their original ones so as to be sure to be drawn at the right place
+	// to a list of those points, keep that list, and then, generate a array of those points.
+	public void updatePorts() {
+		ArrayList<SysCAMSCompositePort> list = syscamscc.getFirstLevelCompositePorts();
+		int cpt=0;
+		
+		int i, j;
+		SysCAMSCompositePort tmp;
+		SysCAMSReferencePortConnectingPoint point;
+		
+		// Close attention to the list
+		boolean change = true;
+		if (list.size() != ports.size()) {
+			change = true;
+		} else {
+			for (SysCAMSCompositePort port: ports) {
+				if (!list.contains(port)) {
+					change = true;
+					break;
+				}
+			}
+		}
+		
+		if (change) {
+			TraceManager.addDev("change on  ports!");
+			// Delete unused ports and 
+			ArrayList<SysCAMSReferencePortConnectingPoint> points = new ArrayList<SysCAMSReferencePortConnectingPoint>();
+			cpt=0;
+			
+			for(i=0; i<ports.size(); i++) {
+				tmp = ports.get(i);
+				if (list.contains(tmp)) {
+					for (j=cpt; j<cpt+5; j++) {
+						points.add((SysCAMSReferencePortConnectingPoint)(connectingPoint[cpt]));
+					}
+				} else {
+					ports.remove(tmp);
+					for (j=cpt; j<cpt+5; j++) {
+						tdp.removeOneConnector(connectingPoint[cpt]);
+						// Shall we remove the connecting points?
+					}
+					i --;
+				}
+				cpt = cpt + 5;
+			}
+			// Add new ports
+			for (SysCAMSCompositePort port1: list) {
+				if (!ports.contains(port1)) {
+					ports.add(port1);
+					for(j=0; j<5; j++) {
+						point = new SysCAMSReferencePortConnectingPoint(port1, this, 0.5, 0.5);
+						points.add(point);
+					}
+				}
+			}
+			
+			if (nbConnectingPoint == points.size()) {
+			} else {
+				nbConnectingPoint = points.size();
+				SysCAMSRemotePortCompositeComponent tgp;
+				connectingPoint = new TGConnectingPoint[nbConnectingPoint];
+				nbInternalTGComponent = nbConnectingPoint/5;
+				tgcomponent = new TGComponent[nbInternalTGComponent];
+				cpt = 0;
+				int cpttg = 0;
+				
+				for(SysCAMSPortConnectingPoint pt: points) {
+					connectingPoint[cpt] = pt;
+					if ((cpt % 5) == 0) {
+						tgp = new SysCAMSRemotePortCompositeComponent(getX(), getY(), 0, 0, 10, 10, false, this, tdp);
+						tgp.setElements(ports.get(cpttg), (SysCAMSReferencePortConnectingPoint)pt);
+						tgcomponent[cpttg] = tgp;
+						cpttg ++;
+					}
+					cpt ++;
+				}
+			}
+		}
+	}
+	
+	public TGComponent getPortOf(TGConnectingPoint tp) {
+		if (ports == null) {
+			return null;
+		}
+		for (int i=0; i<nbConnectingPoint; i++) {
+			if (connectingPoint[i] == tp) {
+				if (i/5 < ports.size()) {
+					return ports.get(i/5);
+				}
+			}
+		}
+		return null;
+	}
+	
+	public boolean setIdTGConnectingPoint(int num, int id) {
+		int i;
+		try {
+			if (connectingPoint == null) {
+				nbConnectingPoint = num + 1;
+				connectingPoint = new TGConnectingPoint[nbConnectingPoint];
+				for(i=0; i<nbConnectingPoint; i++) {
+					connectingPoint[i] = new SysCAMSReferencePortConnectingPoint(null, this, 0.5, 0.5);
+				}
+			} else {
+				if (num >= nbConnectingPoint) {
+					nbConnectingPoint = num + 1;
+					TGConnectingPoint[] old = connectingPoint;
+					connectingPoint = new TGConnectingPoint[nbConnectingPoint];
+					for(i=0; i<old.length; i++) {
+						connectingPoint[i] = old[i];
+					}
+					for(i=old.length; i<nbConnectingPoint; i++) {
+						connectingPoint[i] = new SysCAMSReferencePortConnectingPoint(null, this, 0.5, 0.5);
+					}
+				}
+			}
+			connectingPoint[num].forceId(id);
+			return true;
+		} catch (Exception e) {
+			TraceManager.addDev("Exception remote 1:" + e.getMessage());
+			return false;
+		}
+    }
+
+	public boolean acceptSwallowedTGComponent(TGComponent tgc) {
+        return tgc instanceof SysCAMSRemotePortCompositeComponent;
+	}
+	
+    public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) {
+		if (!acceptSwallowedTGComponent(tgc)) {
+			return false;
+		}
+		tgc.setFather(this);
+        tgc.setDrawingZone(true);
+		addInternalComponent(tgc, 0);
+		return true;
+	}
+	
+    public void removeSwallowedTGComponent(TGComponent tgc) {
+	}
+	
+	public String getAttributes() {
+		return "";
+	}
+	
+	public TDiagramPanel getReferencedDiagram() {
+		if (syscamscc == null) {
+			return null;
+		}
+		return syscamscc.getTDiagramPanel();
+	}
+	
+	public SysCAMSCompositeComponent getReference() {
+		return syscamscc;
+	}
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/syscams/SysCAMSRemotePortCompositeComponent.java b/src/main/resources/ui/syscams/SysCAMSRemotePortCompositeComponent.java
new file mode 100644
index 0000000000..6d43d81325
--- /dev/null
+++ b/src/main/resources/ui/syscams/SysCAMSRemotePortCompositeComponent.java
@@ -0,0 +1,138 @@
+/* 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.syscams;
+
+import myutil.GraphicLib;
+import ui.*;
+import ui.util.IconManager;
+
+import java.awt.*;
+
+/**
+ * Class SysCAMSRemotePortCompositeComponent
+ * Port referencing the port of a composite component
+ * Creation: 22/04/2018
+ * @version 1.0 22/04/2018
+ * @author Irina Kit Yan LEE
+ */
+
+public class SysCAMSRemotePortCompositeComponent extends TGCWithInternalComponent implements SwallowedTGComponent, WithAttributes {
+    private SysCAMSCompositePort port;
+	SysCAMSReferencePortConnectingPoint point;
+	private int defaultDiag = 10;
+	private Color myColor = new Color(251, 252, 200);
+	
+    public SysCAMSRemotePortCompositeComponent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
+        super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
+        
+		nbConnectingPoint = 0;
+        nbInternalTGComponent = 0;
+		
+		moveable = false;
+        editable = false;
+        removable = false;
+		userResizable = false;
+		multieditable = false;
+		
+		value = "Reference Port";
+		name = "Reference Port";
+		
+		myImageIcon = IconManager.imgic1200;
+    }
+	
+	public void internalDrawing(Graphics g) {
+		int xp, yp;
+		Color pc = myColor;
+		Color col = g.getColor();
+		
+		if (port != null) {
+			pc = port.getPortColor();
+			if (pc == null) {
+				pc = myColor;
+			}
+		}
+		
+		if (point != null) {
+			xp = point.getX() - (defaultDiag / 2);
+			yp = point.getY() - (defaultDiag / 2);
+			x = point.getX();
+			y = point.getY() ;
+			forceSize(0, 0);
+			g.setColor(pc);
+			g.fillOval(xp, yp, defaultDiag+1, defaultDiag+1);
+			g.setColor(col);
+			g.drawOval(xp, yp, defaultDiag, defaultDiag);
+		}
+	}
+	
+	public void setElements(SysCAMSCompositePort _port, SysCAMSReferencePortConnectingPoint _point) {
+		port = _port;
+		point = _point;
+	}
+	
+	public SysCAMSCompositePort getPort() {
+		return port;
+	}
+	
+	public String getAttributes() {
+		if (port != null) {
+			return port.getAttributes();
+		}
+		return "";
+	}
+	
+	public TGComponent isOnOnlyMe(int x1, int y1) {
+        if (point == null) {
+			return null;
+		}
+		
+		int xp, yp;
+		xp = point.getX() - (defaultDiag / 2);
+		yp = point.getY() - (defaultDiag / 2);
+		
+        if (GraphicLib.isInRectangle(x1, y1, xp, yp, defaultDiag, defaultDiag)) {
+            return this;
+        }
+        return null;
+    }
+	
+	 public int getType() {
+        return TGComponentManager.TMLCTD_CREMOTEPORTCOMPONENT;
+    }
+}
\ No newline at end of file
diff --git a/src/main/resources/ui/util/camsconverterportE.gif b/src/main/resources/ui/util/camsconverterportE.gif
new file mode 100644
index 0000000000000000000000000000000000000000..a0b9f06cb96c24c74b40065d8985c6abaa6025e7
GIT binary patch
literal 132
zcmZ?wbhEHb6krfw_{abP*4Ebl|Nm!TU{L(e?dKX2?CcoeYNTht%m@+k%uP&B^-WCA
zOwQ&@Pt46tv^CH(F$F;e#h)w;A`Jf-bU?;{3}j$ZnbN=V^jgNnH4B(TRvg{+NhIR>
Z#KuSMb5qQvQg^Lg;9~u)SDlr?8US1BD0Tn<

literal 0
HcmV?d00001

diff --git a/src/main/resources/ui/util/camsconverterportN.gif b/src/main/resources/ui/util/camsconverterportN.gif
new file mode 100644
index 0000000000000000000000000000000000000000..72165975e4f0239b3f58dc7a26ea0e7e4c3bccb3
GIT binary patch
literal 111
zcmZ?wbhEHb6krfw_{hY-z`$T_ZT<iMe+C8y#h)x7K7-<aZqMAr^i<!(^vvXJ-t@%W
z+(cUgJrh$CQ&R>VkP?t)1}5bx{VPweWn5gNb0IZ&U&d?pmZTSw2Q8)@>YS9oz2edu
Kt8ca94AuaoG9wrO

literal 0
HcmV?d00001

diff --git a/src/main/resources/ui/util/camsconverterportS.gif b/src/main/resources/ui/util/camsconverterportS.gif
new file mode 100644
index 0000000000000000000000000000000000000000..e2ce184b7136bfa6f1763032dc78fb93442a7d7e
GIT binary patch
literal 111
zcmZ?wbhEHb6krfw_{hY-z`$T_ZT<iMe+C8y#h)x7K7-<aZqMAr^i<!(^vvXJ-t@%W
z+(cUgJrh$CQ&R>VkP?t)1}5bx{VPweWn5gd;Fi>jt(L84GZWe;+&es@t!l%YUmlyB
Lua^ZeFjxZs%XB2`

literal 0
HcmV?d00001

diff --git a/src/main/resources/ui/util/camsconverterportW.gif b/src/main/resources/ui/util/camsconverterportW.gif
new file mode 100644
index 0000000000000000000000000000000000000000..fd2af4f477d57323015b6249ba4d5b70ff66265e
GIT binary patch
literal 132
zcmZ?wbhEHb6krfw_{abP*4Ebl|Nm!TU{L(e?dKX2?CcoeYNTht%m@+k%uP&B^-WCA
zOwQ&@Pt46tv^CH(F$F;e#h)w;A`Jf-bU?;{3}j$ZnbN=V^jgNnH5?HFFLp*q&r^L^
Y-rLSu<)jt1^pw)29IJ1=+^h`N05cgTkpKVy

literal 0
HcmV?d00001

diff --git a/src/main/resources/ui/util/camsdeport.gif b/src/main/resources/ui/util/camsdeport.gif
new file mode 100644
index 0000000000000000000000000000000000000000..0d8c64d4df64153abf70d51fd6dbfb8d3a98f2e0
GIT binary patch
literal 119
zcmZ?wbhEHb6krfw_`twmZEgMk|9{2*+<vYh!Oo5Wu10zW%!~{S42u7`J#!P&Q+*TD
zGn2FV(i3xY6KxIjOiV$LLGdRGg9yWa1|0?l1_qE(3{0{;{VPweWmsIpb0IZ&Uq<%7
U)&&ns9|y8snq~Fww-|#p04?bzX#fBK

literal 0
HcmV?d00001

diff --git a/src/main/resources/ui/util/camstdfport.gif b/src/main/resources/ui/util/camstdfport.gif
new file mode 100644
index 0000000000000000000000000000000000000000..105d5cbc715f18610dba65e9cb98f654ba602aa0
GIT binary patch
literal 132
zcmZ?wbhEHb6krfw_{abP*4Ebl|Nm!TU{L(e?dKX2?CcoeYNTht%m@+k%uP&B^-WCA
zOwQ&@Pt46tv^CH(F$F;e#h)w;A`Jf-bU?;{3}j$ZnbN=V^jgNnH4AP@z1V8mdNwnm
Zy+*-7?wLm3%8k4FU97+Ls<Sd!0{~tBC{O?Z

literal 0
HcmV?d00001

-- 
GitLab