From bcf82ecbd11674107a726bfee85a3a870e488dd5 Mon Sep 17 00:00:00 2001
From: apvrille <ludovic.apvrille@eurecom.fr>
Date: Mon, 14 May 2018 17:46:06 +0200
Subject: [PATCH] Improvement on saving AMS components. Also, making AMS
 diagrams accessible only with experimental on

---
 src/main/java/ui/GTURTLEModeling.java         |   4 +-
 src/main/java/ui/MainGUI.java                 |   6 +-
 .../java/ui/SysCAMSComponentDesignPanel.java  |   2 +-
 src/main/java/ui/TDiagramPanel.java           |   1 +
 src/main/java/ui/TURTLEPanel.java             |   1 +
 .../ui/syscams/SysCAMSCompositeComponent.java | 917 +++++++++---------
 6 files changed, 467 insertions(+), 464 deletions(-)

diff --git a/src/main/java/ui/GTURTLEModeling.java b/src/main/java/ui/GTURTLEModeling.java
index ce15d3899b..5c525837dc 100644
--- a/src/main/java/ui/GTURTLEModeling.java
+++ b/src/main/java/ui/GTURTLEModeling.java
@@ -145,6 +145,7 @@ import java.util.List;
 
 //Communication Pattern javaCC parser
 //import compiler.tmlCPparser.*;
+//import compiler.tmlCPparser.*;
 
 /**
  * Class GTURTLEModeling
@@ -7005,7 +7006,6 @@ public class GTURTLEModeling {
             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");
@@ -7510,11 +7510,9 @@ public class GTURTLEModeling {
     }
 
     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);
diff --git a/src/main/java/ui/MainGUI.java b/src/main/java/ui/MainGUI.java
index 831b2f86f4..96a0a9eb92 100644
--- a/src/main/java/ui/MainGUI.java
+++ b/src/main/java/ui/MainGUI.java
@@ -9023,8 +9023,10 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per
                     menu.add(newTMLCP);
                     menu.add(newTMLArchi);
                     menu.addSeparator();
-                    menu.add(newSysCAMS);
-                    menu.addSeparator();
+                    if (experimentalOn) {
+                        menu.add(newSysCAMS);
+                        menu.addSeparator();
+                    }
                 }
             }
 
diff --git a/src/main/java/ui/SysCAMSComponentDesignPanel.java b/src/main/java/ui/SysCAMSComponentDesignPanel.java
index 5aba677fd0..e6cbd40e7a 100644
--- a/src/main/java/ui/SysCAMSComponentDesignPanel.java
+++ b/src/main/java/ui/SysCAMSComponentDesignPanel.java
@@ -106,7 +106,7 @@ public class SysCAMSComponentDesignPanel extends TURTLEPanel {
         jsp.getVerticalScrollBar().setUnitIncrement( MainGUI.INCREMENT );
         toolBarPanel.add(toolBarSysCAMS, BorderLayout.NORTH);
         toolBarPanel.add(jsp, BorderLayout.CENTER);
-        tabbedPane.addTab("SystemC-AMS Component Diagram", IconManager.imgic1208, toolBarPanel, "Opens SysCAMS component diagram");
+        tabbedPane.addTab("SystemC-AMS Component Diagram", IconManager.imgic1208, toolBarPanel, "SysCAMS Component Diagram");
         tabbedPane.setSelectedIndex(0);
 
         mgui.changeMade(syscamsctdp, TDiagramPanel.NEW_COMPONENT);
diff --git a/src/main/java/ui/TDiagramPanel.java b/src/main/java/ui/TDiagramPanel.java
index 17aa47f8f0..70a9e30495 100644
--- a/src/main/java/ui/TDiagramPanel.java
+++ b/src/main/java/ui/TDiagramPanel.java
@@ -662,6 +662,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree {
         //    LinkedList<TGComponent> ruteoList = this.componentList;
         //
         for (TGComponent tgc : this.componentList) {
+            //TraceManager.addDev("Considering component:" + tgc);
             if ((selected == false) || (tgc.isSelected())) {
                 s = tgc.saveInXML();
                 if (s == null) {
diff --git a/src/main/java/ui/TURTLEPanel.java b/src/main/java/ui/TURTLEPanel.java
index 8665d9bba1..b1d542fab7 100644
--- a/src/main/java/ui/TURTLEPanel.java
+++ b/src/main/java/ui/TURTLEPanel.java
@@ -149,6 +149,7 @@ public abstract class TURTLEPanel implements GenericTree {
         StringBuffer s;
 
         tdp = panels.elementAt(indexOfDiagram);
+
         s = tdp.saveInXML();
         if (s == null) {
             //System.out.println("Null diagram");
diff --git a/src/main/java/ui/syscams/SysCAMSCompositeComponent.java b/src/main/java/ui/syscams/SysCAMSCompositeComponent.java
index c99d162ece..66c46c161d 100644
--- a/src/main/java/ui/syscams/SysCAMSCompositeComponent.java
+++ b/src/main/java/ui/syscams/SysCAMSCompositeComponent.java
@@ -54,154 +54,155 @@ import java.util.ListIterator;
  * Class SysCAMSCompositeComponent
  * Composite Component. To be used in SystemC-AMS diagrams
  * Creation: 27/04/2018
- * @version 1.0 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)  {
+    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;
-		
+
+        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;
-        
+
+        maxWidth = 2000;
+        maxHeight = 2000;
+
         moveable = true;
         editable = true;
         removable = true;
         userResizable = true;
-        
-		value = "Cluster";
-		name = "Composite component";
-		
+
+        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;
+        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);
-		}
+        }
+        // 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);
+        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 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)) {
+        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());
+        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)) {
+            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);
+                        "Error: the name is already in use",
+                        "Name modification",
+                        JOptionPane.ERROR_MESSAGE);
                 return false;
             }
             setValueWithChange(s);
@@ -209,334 +210,334 @@ public class SysCAMSCompositeComponent extends TGCScalableWithInternalComponent
         }
         return false;
     }
-    
+
     public int getType() {
-        return TGComponentManager.TMLCTD_CCOMPONENT;
-    }
-	
-	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 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) {
+        if (tgc instanceof SysCAMSRecordComponent) {
             return true;
         }
-		if (tgc instanceof SysCAMSPrimitiveComponent) {
+        if (tgc instanceof SysCAMSPrimitiveComponent) {
             return true;
         }
-		if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+        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;
-		}
+        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) {
+
+        if (tgc instanceof SysCAMSRecordComponent) {
+            tgc.resizeWithFather();
+        }
+
+        if (tgc instanceof SysCAMSPrimitiveComponent) {
             tgc.resizeWithFather();
         }
-		
-		if (tgc instanceof SysCAMSPrimitiveComponent) {
+
+        if (tgc instanceof SysCAMSRemoteCompositeComponent) {
             tgc.resizeWithFather();
         }
-		
-		if (tgc instanceof SysCAMSRemoteCompositeComponent) {
+        if (tgc instanceof SysCAMSCompositePort) {
             tgc.resizeWithFather();
+            compositePortNb++;
         }
-		if (tgc instanceof SysCAMSCompositePort) {
-			tgc.resizeWithFather();
-			compositePortNb ++;
-		}
         //add it
         addInternalComponent(tgc, 0);
-		return true;
+        return true;
     }
-    
+
     public void removeSwallowedTGComponent(TGComponent tgc) {
-		if (tgc instanceof SysCAMSCompositePort) {
-			portRemoved();
-		}
-		 for(int i=0; i<nbInternalTGComponent; i++) {
+        if (tgc instanceof SysCAMSCompositePort) {
+            portRemoved();
+        }
+        for (int i = 0; i < nbInternalTGComponent; i++) {
             if (tgcomponent[i] == tgc) {
-				nbInternalTGComponent = nbInternalTGComponent - 1;
+                nbInternalTGComponent = nbInternalTGComponent - 1;
                 if (nbInternalTGComponent == 0) {
                     tgcomponent = null;
                 } else {
-                    TGComponent [] tgcomponentbis = new TGComponent[nbInternalTGComponent];
-                    for(int j=0; j<nbInternalTGComponent; j++) {
-                        if (j<i) {
+                    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];
+                        if (j >= i) {
+                            tgcomponentbis[j] = tgcomponent[j + 1];
                         }
                     }
                     tgcomponent = tgcomponentbis;
                 }
-				break;
-			}
-		 }
+                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();
-			
+        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++) {
+
+    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);
-			}
-		}
-	}
-    
+                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("<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{
+
+    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++) {
+
+            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++) {
+                    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);
-								}
-							}
-							
+                                if (elt.getAttribute("hiddeni").equals("true")) {
+                                    setInternalsHidden(true);
+                                }
+                            }
+
                         }
                     }
                 }
@@ -545,88 +546,88 @@ public class SysCAMSCompositeComponent extends TGCScalableWithInternalComponent
             throw new MalformedModelingException();
         }
     }
-	
-	public void drawTGConnectingPoint(Graphics g, int type) {
-        for (int i=0; i<nbConnectingPoint; i++) {
+
+    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 hasRefencesTo(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]).hasRefencesTo(syscamscc);
-				if (b) {
-					return true;
-				}
-			}
-		}
-		return false;
-	}
+
+        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 hasRefencesTo(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]).hasRefencesTo(syscamscc);
+                if (b) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
 }
\ No newline at end of file
-- 
GitLab