diff --git a/src/tmltranslator/TMLCP.java b/src/tmltranslator/TMLCP.java
index 804101fa1b44a38102aa890bd3787a8a8f7c0449..0c286bff5136e7031a88f71857ffaed0210d7127 100755
--- a/src/tmltranslator/TMLCP.java
+++ b/src/tmltranslator/TMLCP.java
@@ -1,6 +1,7 @@
-/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
+/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici
 
-ludovic.apvrille AT enst.fr
+ludovic.apvrille AT telecom-paristech.fr
+andrea.enrici 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 
@@ -38,8 +39,8 @@ knowledge of the CeCILL license and that you accept its terms.
 /**
 * Class TMLCP
 * Creation: 18/02/2014
-* @version 1.0 18/02/2014
-* @author Ludovic APVRILLE
+* @version 1.1 10/06/2014
+* @author Ludovic APVRILLE, Andrea ENRICI
 * @see
 */
 
@@ -50,17 +51,21 @@ import tmltranslator.tmlcp.*;
 import myutil.*;
 
 public class TMLCP extends TMLElement {
-    private CPActivityDiagram mainCP;
-    private ArrayList<CPActivityDiagram> otherCPs; //Ref to other CPs
-    private ArrayList<CPSequenceDiagram> sds; //Ref to SDs
-	
-	
+
+	private CPActivityDiagram mainCP;
+	private ArrayList<CPActivityDiagram> otherCPs; //Ref to other CPs
+	private ArrayList<CPSequenceDiagram> sds; //Ref to SDs
 	private int hashCode;
 	private boolean hashCodeComputed = false;
 	
     
-  public TMLCP(String _name, Object _referenceObject) {
-  	super(_name, _referenceObject);
+  public TMLCP( String _name, Object _referenceObject ) {
+  	super( _name, _referenceObject );
+    init();
+  }
+
+  public TMLCP() {
+  	super( "DefaultCP", null );	//no reference to any object in the default constructor
     init();
   }
 	
diff --git a/src/tmltranslator/TMLMapping.java b/src/tmltranslator/TMLMapping.java
index 66c79026ac9d7dfdad80f4c6bd6b9571d65c5b89..f3bb4bc2bd14a4c464583c0b4caaa4332d7a0698 100755
--- a/src/tmltranslator/TMLMapping.java
+++ b/src/tmltranslator/TMLMapping.java
@@ -1,6 +1,7 @@
-/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
+/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici
 
-ludovic.apvrille AT enst.fr
+ludovic.apvrille AT telecom-paristech.fr
+andrea.enrici 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 
@@ -38,8 +39,8 @@ knowledge of the CeCILL license and that you accept its terms.
 /**
  * Class TMLMapping
  * Creation: 05/09/2007
- * @version 1.0 05/09/2007
- * @author Ludovic APVRILLE
+ * @version 1.1 10/06/2014
+ * @author Ludovic APVRILLE, Andrea ENRICI
  * @see
  */
 
@@ -49,15 +50,17 @@ import java.util.*;
 
 
 public class TMLMapping {
-    private TMLModeling tmlm;
-    private TMLArchitecture tmla;
- 
+
+	private TMLModeling tmlm;
+  private TMLArchitecture tmla;
+	private TMLCP tmlcp;
+
 	private ArrayList<HwExecutionNode> onnodes;
 	private ArrayList<TMLTask> mappedtasks;
 	private ArrayList<HwCommunicationNode> oncommnodes;
 	private ArrayList<TMLElement> mappedcommelts;
 	
-	private ArrayList<TMLCP> instancesOfCPs;
+	private ArrayList<TMLCP> mappedCPs;
 	private ArrayList<TMLElement> commEltsMappedOnCPs;
 	
 	
@@ -66,17 +69,28 @@ public class TMLMapping {
 	private int hashCode;
 	private boolean hashCodeComputed = false;
     
-    public TMLMapping(TMLModeling _tmlm, TMLArchitecture _tmla, boolean reset) {
-        tmlm = _tmlm;
+  public TMLMapping(TMLModeling _tmlm, TMLArchitecture _tmla, boolean reset) {
+  	
+		tmlm = _tmlm;
 		tmla = _tmla;
 		init();
 		
-		if (reset) {
+		if( reset ) {
 			DIPLOElement.resetID();
 		}
-    }
-	
+	}
 
+  public TMLMapping( TMLModeling _tmlm, TMLArchitecture _tmla, TMLCP _tmlcp, boolean reset ) {
+  	
+		tmlm = _tmlm;
+		tmla = _tmla;
+		tmlcp = _tmlcp;
+		init();
+		
+		if( reset ) {
+			DIPLOElement.resetID();
+		}
+	}
 	
 	public void makeMinimumMapping() {
 		HwCPU cpu;
@@ -227,10 +241,13 @@ public class TMLMapping {
 	}
 	
 	private void init() {
+
 		mappedtasks = new ArrayList<TMLTask>();
 		onnodes = new ArrayList<HwExecutionNode>();
 		oncommnodes = new ArrayList<HwCommunicationNode>();
 		mappedcommelts = new ArrayList<TMLElement>();
+		mappedCPs = new ArrayList<TMLCP>();
+		commEltsMappedOnCPs = new ArrayList<TMLElement>();
 	}
 	
 	public TMLTask getTMLTaskByCommandID(int id) {
@@ -540,4 +557,4 @@ public class TMLMapping {
 		
 		return tmla.getArchitectureComplexity();
 	}
-}
\ No newline at end of file
+}
diff --git a/src/tmltranslator/tmlcp/CPSequenceDiagram.java b/src/tmltranslator/tmlcp/CPSequenceDiagram.java
index 9045678a95f8f9d287faac9659f703a471f7893c..6fde072dfa30892d3f2413edc14a145aa674b844 100755
--- a/src/tmltranslator/tmlcp/CPSequenceDiagram.java
+++ b/src/tmltranslator/tmlcp/CPSequenceDiagram.java
@@ -67,6 +67,11 @@ public class CPSequenceDiagram  extends TMLElement {
 		init();
 	}
 
+	public CPSequenceDiagram()	{
+		super( "DefaultName", null );
+		init();
+	}
+
 	private void init() {
 		globalVariables = new ArrayList<TMLAttribute>();
 		instances = new ArrayList<TMLSDInstance>();
diff --git a/src/ui/GTMLModeling.java b/src/ui/GTMLModeling.java
index 5b5c0519e84029135e854c9e9846bc417173792e..c62b39be28176fb76ee01de08d28769dcd2093bb 100755
--- a/src/ui/GTMLModeling.java
+++ b/src/ui/GTMLModeling.java
@@ -76,8 +76,10 @@ public class GTMLModeling  {
 	
 	//private ArrayList<HwNode> nodesToTakeIntoAccount;
 	private LinkedList nodesToTakeIntoAccount;
-	TMLMapping map;
-	TMLArchitecture archi;
+
+	private TMLMapping map;
+	private TMLArchitecture archi;
+	private TMLCP cp;
 	
 	private boolean putPrefixName = false;
 	
@@ -1855,9 +1857,8 @@ public class GTMLModeling  {
 	}
 	
 	public TMLMapping translateToTMLMapping() {
+
 		tmlm = new TMLModeling(true);
-		
-		
 		archi = new TMLArchitecture();
 		map = new TMLMapping(tmlm, archi, false);
 		
@@ -1887,13 +1888,15 @@ public class GTMLModeling  {
 
 		tmlm = new TMLModeling( true );
 		archi = new TMLArchitecture();
+		//cp = new TMLCP();
+		//map = new TMLMapping( tmlm, archi, cp, false );
 		map = new TMLMapping( tmlm, archi, false );
 		
 		checkingErrors = new Vector();
 		warnings = new Vector();
 		//listE = new CorrespondanceTGElement();
 		
-		TraceManager.addDev( "Making Communication Pattern" );
+		TraceManager.addDev( "Making mapping with Communication Pattern" );
 		makeCommunicationPattern();
 		/*TraceManager.addDev( "Making TML modeling" );
 		if (!makeTMLModeling()) {	//Attention, this routine will provoke errors...
@@ -2142,9 +2145,19 @@ public class GTMLModeling  {
 		ListIterator iterator = components.listIterator();
 		Vector<TDiagramPanel> panelList = tmlcpp.getPanels();
 
+		TDiagramPanel mainCP = panelList.get(0);
+		LinkedList mainCPcomponents =  mainCP.getComponentList();	//the list of components from the main CP
+
+//		LinkedList elemList = panel.getComponentList();
+		TraceManager.addDev("Lenght of elements: " + mainCPcomponents.size() );
+		for( int k = 0; k < mainCPcomponents.size(); k++ )	{
+			TGComponent temp = (TGComponent) mainCPcomponents.get(k);
+			TraceManager.addDev( temp.getName() + "\t" + temp.getValue() );
+		}
+
 		//TO BE DONE: For the main CP
 
-		for( int i = 0; i < components.size(); i++ ) {
+		for( int i = 0; i < components.size(); i++ ) {	//The components of the Communication Pattern panel
 			tgc = (TGComponent)( components.get(i) );
 			TraceManager.addDev("Iteration: " + i + " testing " + tgc.getName() );
 			if( tgc instanceof TMLCPRefSD ) {
@@ -2159,6 +2172,7 @@ public class GTMLModeling  {
 				else {
 					names.add( refSDnode.getName() );
 					String SDname = refSDnode.getName();
+					//CPSequenceDiagram sd = new CPSequenceDiagram( SDname, null );
 					for( TDiagramPanel panel: panelList )	{
 						TraceManager.addDev("Testing panel: " + panel.getName() + " against SD ref " + SDname );
 						if( SDname.equals( panel.getName() ) )	{
@@ -2167,8 +2181,9 @@ public class GTMLModeling  {
 							TraceManager.addDev("Lenght of elements: " + elemList.size() );
 							for( int j = 0; j < elemList.size(); j++ )	{
 								TGComponent elem = (TGComponent) elemList.get(j);
-								TraceManager.addDev( elem.getName() );
+								TraceManager.addDev( elem.getName() + "\t" + elem.getValue() );
 							}
+							//cp.addSD(sd);
 							break;
 						}
 					}
diff --git a/src/ui/GTURTLEModeling.java b/src/ui/GTURTLEModeling.java
index 0bb6dd46e6af650f2ff7dd54c1c8d43031fd4e50..4f01335910d55c1182dccef21077f665db7db36f 100755
--- a/src/ui/GTURTLEModeling.java
+++ b/src/ui/GTURTLEModeling.java
@@ -144,6 +144,7 @@ public class GTURTLEModeling {
 	private TMLModeling tmlm;
 	private TMLMapping artificialtmap;
 	private TMLMapping tmap;
+	//private TMLCP tmcp;
 	private RequirementModeling rm;
 	private NCStructure ncs;
 	private MainGUI mgui;
@@ -399,7 +400,8 @@ public class GTURTLEModeling {
 
 		//TO DO: make a third branch for the syntax checking from the CP panel
 
-		//This branch is activated if doing the syntax check from the application panel
+		//This branch is activated if doing the syntax check from the application panel.
+		//It only generates the application TML text
 		if( tmap == null ) {
 			TMLTextSpecification spec = new TMLTextSpecification( _title );
 			spec.toTextFormat( tmlm );	//TMLModeling
@@ -414,7 +416,8 @@ public class GTURTLEModeling {
 				return false;
 			}
 		}
-		//This branch is activated if doing the syntax check from the architecture panel, regardless the presence of mapping artifacts
+		//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
 		else {
 			TMLMappingTextSpecification spec = new TMLMappingTextSpecification( _title );
 			spec.toTextFormat( tmap );	//TMLMapping
@@ -6174,6 +6177,7 @@ public class GTURTLEModeling {
 		tm = null;
 		tmState = 1;
 		tmap = gtmlm.translateToTMLCP();
+		//tmcp = gtmlm.translateToTMLCP();
 		listE = gtmlm.getCorrespondanceTable();
 		checkingErrors = gtmlm.getCheckingErrors();
 		
@@ -6183,9 +6187,10 @@ public class GTURTLEModeling {
 			return false;
 		}
 		else {
-			//tmap.removeAllRandomSequences();
+			//tmcp.removeAllRandomSequences();
 			if( optimize )	{
 				warningsOptimize = tmap.optimize();
+				//warningsOptimize = tmcp.optimize();
 			}
 			warnings.addAll( convertToCheckingErrorTMLErrors(warningsOptimize, tmlcpp.tmlcpp ) );
 			mgui.resetAllDIPLOIDs();
diff --git a/src/ui/TGConnectingPoint.java b/src/ui/TGConnectingPoint.java
index 1585b5f8f2351a10d8bbe1e70edfaa38625c86bf..0812f200764908c78ff0c4f66aead199805741c5 100755
--- a/src/ui/TGConnectingPoint.java
+++ b/src/ui/TGConnectingPoint.java
@@ -87,6 +87,8 @@ public class TGConnectingPoint implements CDElement {
 	public static final int EAST=1;
 	public static final int SOUTH=2;
 	public static final int WEST=3;
+
+	private TGConnector referenceToConnector;
    
     
     public TGConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out) {
@@ -281,11 +283,11 @@ public class TGConnectingPoint implements CDElement {
 	protected TGComponent getFather() {
 		return father;
 	}*/
+	public void setReferenceToConnector( TGConnector _ref )	{
+		referenceToConnector = _ref;
+	}
+	
+	public TGConnector getReferenceToConnector()	{
+		return referenceToConnector;
+	}
 }
-
-
-
-
-
-
-
diff --git a/src/ui/TGConnector.java b/src/ui/TGConnector.java
index fba896641d2ee7c57e9a5767008ea7738e580d77..aeeb56e6d369166eabf58cdeb26208144b5d9b3c 100755
--- a/src/ui/TGConnector.java
+++ b/src/ui/TGConnector.java
@@ -70,6 +70,8 @@ public abstract class TGConnector extends TGCWithInternalComponent {
     protected int DIST_Y = 20;
     
     protected boolean automaticDrawing = true; // Used when user select to enhance the diagram automatically
+
+		protected String endName, startName;	//the name of the entities attached to the connector
     
     // WARNING: point of connectors must be put first in the list of internal components ...
     
@@ -88,7 +90,9 @@ public abstract class TGConnector extends TGCWithInternalComponent {
             //System.out.println("p.x " + p.x + " p.y" + p.y + " minX" + _minX + " maxX" + _maxX);
             tgcomponent[i] = new TGCPointOfConnector(p.x, p.y, _minX, _maxX, _minY, _maxY, false, this, _tdp);
         }
-        name = "connector from " + p1.getName() + " to " + p2.getName();
+				endName = p2.getName();
+				startName = p1.getName();
+        name = "connector from " + startName + " to " + endName;
         
         canBeCloned = false;
         removable = true;
diff --git a/src/ui/tmlcp/TGConnectingPointTMLCP.java b/src/ui/tmlcp/TGConnectingPointTMLCP.java
index 0d7be55ec2e75a33ede8b0e15087bc9a5bc19303..47ba0bd579cf06d8760c0c0d2c94a721b31f5097 100755
--- a/src/ui/tmlcp/TGConnectingPointTMLCP.java
+++ b/src/ui/tmlcp/TGConnectingPointTMLCP.java
@@ -50,6 +50,8 @@ package ui.tmlcp;
 import ui.*;
 
 public class TGConnectingPointTMLCP extends  TGConnectingPointWidthHeight{
+
+
     
     public TGConnectingPointTMLCP(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) {
         super(_container, _x, _y, _in, _out, _w, _h);
@@ -64,5 +66,5 @@ public class TGConnectingPointTMLCP extends  TGConnectingPointWidthHeight{
         //System.out.println("is compatible with:false");
         return false;
     }
-    
+  
 }
diff --git a/src/ui/tmlcp/TGConnectorTMLCP.java b/src/ui/tmlcp/TGConnectorTMLCP.java
index 2b0287bb35b315557754d11112127952a3a44fd1..5f27bcf2b46e61bd601a1b9260574e149b698c64 100755
--- a/src/ui/tmlcp/TGConnectorTMLCP.java
+++ b/src/ui/tmlcp/TGConnectorTMLCP.java
@@ -59,6 +59,9 @@ public  class TGConnectorTMLCP extends TGConnector {
     public TGConnectorTMLCP(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector _listPoint) {
         super(_x, _y,  _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint);
         myImageIcon = IconManager.imgic202;
+
+				_p1.setReferenceToConnector( this );
+				_p2.setReferenceToConnector( this );
     }
     
     protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){
@@ -72,11 +75,12 @@ public  class TGConnectorTMLCP extends TGConnector {
     public int getType() {
         return TGComponentManager.CONNECTOR_TMLCP;
     }
-}
-
-
-
-
-
 
+		public void changeStartName( String _name )	{
+			name = "connector from " + _name + " to " + endName;
+		}
 
+		public void changeEndName( String _name )	{
+			name = "connector from " + startName + " to " + _name;
+		}
+}
diff --git a/src/ui/tmlcp/TMLCPChoice.java b/src/ui/tmlcp/TMLCPChoice.java
index 0017c2083bf09bc12ee5eb99b8be2b8887367eef..b51f69666b09362c0a3358518e39059821cdf614 100755
--- a/src/ui/tmlcp/TMLCPChoice.java
+++ b/src/ui/tmlcp/TMLCPChoice.java
@@ -1,6 +1,7 @@
-/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
+/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici
 
-ludovic.apvrille AT enst.fr
+ludovic.apvrille AT telecom-paristech.fr
+andrea.enrici 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 
@@ -40,7 +41,7 @@ knowledge of the CeCILL license and that you accept its terms.
  * Choice to be used in communication patterns diagrams
  * Creation: 17/02/2014
  * @version 1.0 17/02/2014
- * @author Ludovic APVRILLE
+ * @author Ludovic APVRILLE, Andrea ENRICI
  * @see
  */
 
@@ -56,6 +57,8 @@ public class TMLCPChoice extends TGCWithInternalComponent {
     private int lineLength = 10;
     private int lineOutLength = 25;
     private int textX1, textY1, textX2, textY2, textX3, textY3;
+		private static int instanceCounter = 0;
+		private int counter = 0;
     
     
     public TMLCPChoice(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
@@ -102,7 +105,9 @@ public class TMLCPChoice extends TGCWithInternalComponent {
         editable = false;
         removable = true;
         
-        name = "choice";
+				instanceCounter++;
+				counter = instanceCounter;
+        name = "choice" + Integer.toString(counter);
         
         myImageIcon = IconManager.imgic208;
     }
diff --git a/src/ui/tmlcp/TMLCPFork.java b/src/ui/tmlcp/TMLCPFork.java
index 684d5c3c7f83727cc3e7dfed0fa8c2a37ca0ac84..f8a660906b0bdb955397bf552dd5c4745384d3d2 100755
--- a/src/ui/tmlcp/TMLCPFork.java
+++ b/src/ui/tmlcp/TMLCPFork.java
@@ -1,6 +1,7 @@
-/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
+/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici
 
-ludovic.apvrille AT enst.fr
+ludovic.apvrille AT telecom-paristech.fr
+andrea.enrici 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 
@@ -53,7 +54,10 @@ import myutil.*;
 import ui.*;
 
 public class TMLCPFork extends TGCWithoutInternalComponent{
+	
 	private int lineLength = 0;
+	private static int instanceCounter = 0;
+	private int counter = 0;
 	//private int textX, textY;
 
 	public TMLCPFork(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
@@ -82,7 +86,9 @@ public class TMLCPFork extends TGCWithoutInternalComponent{
 		editable = false;
 		removable = true;
 
-		name = "fork";
+		instanceCounter++;
+		counter = instanceCounter;
+		name = "fork" + Integer.toString(counter);
 		
 		myImageIcon = IconManager.imgic206;
 	}
diff --git a/src/ui/tmlcp/TMLCPJoin.java b/src/ui/tmlcp/TMLCPJoin.java
index 0abb4b772b0f3eba3a9dda8d8152d3dfb5a65beb..5f21cc41acc4599f488eed824343a08d9f335db9 100755
--- a/src/ui/tmlcp/TMLCPJoin.java
+++ b/src/ui/tmlcp/TMLCPJoin.java
@@ -1,6 +1,7 @@
-/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
+/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici
 
-ludovic.apvrille AT enst.fr
+ludovic.apvrille AT telecom-paristech.fr
+andrea.enrici 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 
@@ -41,7 +42,7 @@ knowledge of the CeCILL license and that you accept its terms.
  * To be used in communication patterns diagrams
  * Creation: 17/02/2014
  * @version 1.0 17/02/2014
- * @author Ludovic APVRILLE
+ * @author Ludovic APVRILLE, Andrea ENRICI
  * @see 
  */
  
@@ -53,7 +54,10 @@ import myutil.*;
 import ui.*;
 
 public class TMLCPJoin extends TGCWithoutInternalComponent{
+
 	private int lineLength = 0;
+	private static int instanceCounter = 0;
+	private int counter = 0;
 	//private int textX, textY;
 
 	public TMLCPJoin(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
@@ -83,7 +87,9 @@ public class TMLCPJoin extends TGCWithoutInternalComponent{
 		editable = false;
 		removable = true;
 
-		name = "join";
+		instanceCounter++;
+		counter = instanceCounter;
+		name = "join" + Integer.toString(counter);
 		
 		myImageIcon = IconManager.imgic206;
 	}
diff --git a/src/ui/tmlcp/TMLCPJunction.java b/src/ui/tmlcp/TMLCPJunction.java
index fe56d4576a92848ed0326c68e0c8c04bb06505ed..f0e75a53eb970d5f102c9f7ed9e823bbaf65a6cd 100755
--- a/src/ui/tmlcp/TMLCPJunction.java
+++ b/src/ui/tmlcp/TMLCPJunction.java
@@ -1,6 +1,7 @@
-/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
+/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici
 
-ludovic.apvrille AT enst.fr
+ludovic.apvrille AT telecom-paristech.fr
+andrea.enrici 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 
@@ -41,7 +42,7 @@ knowledge of the CeCILL license and that you accept its terms.
  * To be used in communication patterns diagrams
  * Creation: 17/02/2014
  * @version 1.0 17/02/2014
- * @author Ludovic APVRILLE
+ * @author Ludovic APVRILLE, Andrea ENRICI
  * @see 
  */
  
@@ -54,6 +55,9 @@ import ui.*;
 
 
 public class TMLCPJunction extends TGCWithoutInternalComponent {
+
+	private static int instanceCounter = 0;
+	private int counter = 0;
 	
 	public TMLCPJunction(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);
@@ -73,7 +77,9 @@ public class TMLCPJunction extends TGCWithoutInternalComponent {
 		removable = true;
 	
 		value = "";
-		name = "junction";
+		instanceCounter++;
+		counter = instanceCounter;
+		name = "junction" + Integer.toString(counter);
 		
 		myImageIcon = IconManager.imgic212;
 	}
diff --git a/src/ui/tmlcp/TMLCPRefCP.java b/src/ui/tmlcp/TMLCPRefCP.java
index 7010474be4de370031b82da3915c6396c601aeb5..e28e62bad1582a667b9cf50205ee3c1c0dda8479 100755
--- a/src/ui/tmlcp/TMLCPRefCP.java
+++ b/src/ui/tmlcp/TMLCPRefCP.java
@@ -180,6 +180,17 @@ public class TMLCPRefCP extends TGCOneLineText {
 		"Setting Name", JOptionPane.PLAIN_MESSAGE, IconManager.imgic100, null, getName() );
     if( (s != null) && (s.length() > 0) )	{
 			setName(s);
+			//When the name of a refToCP is changed, the connector name must be updated accordingly
+			if( connectingPoint[0].getReferenceToConnector() != null )	{
+				TGConnectorTMLCP connector = (TGConnectorTMLCP) connectingPoint[0].getReferenceToConnector();
+				connector.changeEndName(s);
+				TraceManager.addDev( connector.getName() );
+				if( connectingPoint[1].getReferenceToConnector() != null )	{
+					connector = (TGConnectorTMLCP) connectingPoint[1].getReferenceToConnector();
+					connector.changeStartName(s);
+					TraceManager.addDev( connector.getName() );
+				}
+			}
 			return true;
 		}
     return false;
diff --git a/src/ui/tmlcp/TMLCPRefSD.java b/src/ui/tmlcp/TMLCPRefSD.java
index f84950b12d40dc931b42e61184d6a64311676607..ce9d00b3ef625d079b4f49baf45fb61c69d6bf9f 100755
--- a/src/ui/tmlcp/TMLCPRefSD.java
+++ b/src/ui/tmlcp/TMLCPRefSD.java
@@ -62,6 +62,7 @@ public class TMLCPRefSD extends TGCOneLineText {
     protected int textY =  15;
     protected int arc = 5;
 		private TMLSDPanel refToSD;
+//		private TGConnectorTMLCP[] connectors = new TGConnectorTMLCP[2];
 		//private int index = 0;
 
     public TMLCPRefSD(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
@@ -183,6 +184,17 @@ public class TMLCPRefSD extends TGCOneLineText {
 		"Setting Name", JOptionPane.PLAIN_MESSAGE, IconManager.imgic100, null, getName() );
     if( (s != null) && (s.length() > 0) )	{
 			setName(s);
+			//When the name of a refToSD is changed, the connector name must be updated accordingly
+			if( connectingPoint[0].getReferenceToConnector() != null )	{
+				TGConnectorTMLCP connector = (TGConnectorTMLCP) connectingPoint[0].getReferenceToConnector();
+				connector.changeEndName(s);
+				TraceManager.addDev( connector.getName() );
+				if( connectingPoint[1].getReferenceToConnector() != null )	{
+					connector = (TGConnectorTMLCP) connectingPoint[1].getReferenceToConnector();
+					connector.changeStartName(s);
+					TraceManager.addDev( connector.getName() );
+				}
+			}
 			/*if( refToSD != null )	{
 				TraceManager.addDev( "About to change the name of the Diag" );
 				refToSD.setName(s);