diff --git a/modeling/scripts/TMLModel.xml b/modeling/scripts/TMLModel.xml index afdd6d255b7759e0f2a61c57163c6a419f8a1e56..3d47f24d1b404a579e0e71d5b500c4c0f9b39045 100644 --- a/modeling/scripts/TMLModel.xml +++ b/modeling/scripts/TMLModel.xml @@ -1,5 +1,124 @@ <?xml version="1.0" encoding="UTF-8"?> -<TURTLEGMODELING version="1.0beta" ANIMATE_INTERACTIVE_SIMULATION="true" ACTIVATE_PENALTIES="true" UPDATE_INFORMATION_DIPLO_SIM="true" ANIMATE_WITH_INFO_DIPLO_SIM="true" OPEN_DIAG_DIPLO_SIM="false" LAST_SELECTED_MAIN_TAB="-1" LAST_SELECTED_SUB_TAB="0"> +<TURTLEGMODELING version="1.0beta" ANIMATE_INTERACTIVE_SIMULATION="true" ACTIVATE_PENALTIES="true" UPDATE_INFORMATION_DIPLO_SIM="true" ANIMATE_WITH_INFO_DIPLO_SIM="true" OPEN_DIAG_DIPLO_SIM="false" LAST_SELECTED_MAIN_TAB="0" LAST_SELECTED_SUB_TAB="0"> + +<Modeling type="TML Component Design" nameTab="Application_withLoop_cloned" tabs="TML Component Task Diagram$Input$Output" > +<TMLComponentTaskDiagramPanel name="TML Component Task Diagram" minX="10" maxX="2500" minY="10" maxY="1500" channels="true" events="true" requests="true" considerExecOperators="true" considerTimingOperators="true" zoom="1.0" > +<COMPONENT type="1202" id="100000" index="0" uid="6e190bcf-168b-43a1-8d10-1b5c65c8202c" > +<cdparam x="900" y="350" /> +<sizeparam width="200" height="150" minWidth="150" minHeight="100" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="Primitive component" value="Input" /> +<TGConnectingPoint num="0" id="100001" /> +<TGConnectingPoint num="1" id="100002" /> +<TGConnectingPoint num="2" id="100003" /> +<TGConnectingPoint num="3" id="100004" /> +<TGConnectingPoint num="4" id="100005" /> +<TGConnectingPoint num="5" id="100006" /> +<TGConnectingPoint num="6" id="100007" /> +<TGConnectingPoint num="7" id="100008" /> +<extraparam> +<Data isAttacker="No" daemon="false" periodic="false" periodValue="" unit="ms" Operation="" /> +<Attribute access="0" id="n" value="0" type="0" typeOther="" /> +<Attribute access="0" id="m" value="0" type="0" typeOther="" /> +</extraparam> +</COMPONENT> +<SUBCOMPONENT type="1203" id="100032" index="3" uid="215662f1-39f5-4ecd-941d-96bd16831416" > +<father id="100000" num="0" /> +<cdparam x="1000" y="487" /> +<sizeparam width="26" height="26" minWidth="1" minHeight="1" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="-13" maxX="187" minY="-13" maxY="137" /> +<infoparam name="Primitive port" value="Channel comm_0" /> +<TGConnectingPoint num="0" id="100041" /> +<extraparam> +<Prop commName="comm_0" commType="1" origin="true" finite="false" blocking="true" maxSamples="8" widthSamples="4" isLossy="false" isPrex="false" isPostex="false" lossPercentage="0" maxNbOfLoss="0" dataFlowType="VOID" associatedEvent="VOID" checkConf="false" checkConfStatus="0" checkAuth="false" checkWeakAuthStatus="0" checkStrongAuthStatus="0" vc="0" /> +<Type type="0" typeOther="" /> +<Type type="0" typeOther="" /> +<Type type="0" typeOther="" /> +<Type type="0" typeOther="" /> +<Type type="0" typeOther="" /> +</extraparam> +</SUBCOMPONENT> + +<COMPONENT type="1202" id="100011" index="1" uid="e6196ad0-8252-4229-af31-21362f9605e7" > +<cdparam x="100" y="350" /> +<sizeparam width="200" height="150" minWidth="150" minHeight="100" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="Primitive component" value="Output" /> +<TGConnectingPoint num="0" id="100012" /> +<TGConnectingPoint num="1" id="100013" /> +<TGConnectingPoint num="2" id="100014" /> +<TGConnectingPoint num="3" id="100015" /> +<TGConnectingPoint num="4" id="100016" /> +<TGConnectingPoint num="5" id="100017" /> +<TGConnectingPoint num="6" id="100018" /> +<TGConnectingPoint num="7" id="100019" /> +<extraparam> +<Data isAttacker="No" daemon="false" periodic="false" periodValue="" unit="ms" Operation="" /> +<Attribute access="0" id="n" value="0" type="0" typeOther="" /> +</extraparam> +</COMPONENT> +<SUBCOMPONENT type="1203" id="100052" index="4" uid="bf44448f-5b5c-4e5f-8165-0004a0fccfe7" > +<father id="100011" num="0" /> +<cdparam x="200" y="487" /> +<sizeparam width="26" height="26" minWidth="1" minHeight="1" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="-13" maxX="187" minY="-13" maxY="137" /> +<infoparam name="Primitive port" value="Channel comm_0" /> +<TGConnectingPoint num="0" id="100061" /> +<extraparam> +<Prop commName="comm_0" commType="1" origin="true" finite="false" blocking="true" maxSamples="8" widthSamples="4" isLossy="false" isPrex="false" isPostex="false" lossPercentage="0" maxNbOfLoss="0" dataFlowType="VOID" associatedEvent="VOID" checkConf="false" checkConfStatus="0" checkAuth="false" checkWeakAuthStatus="0" checkStrongAuthStatus="0" vc="0" /> +<Type type="0" typeOther="" /> +<Type type="0" typeOther="" /> +<Type type="0" typeOther="" /> +<Type type="0" typeOther="" /> +<Type type="0" typeOther="" /> +</extraparam> +</SUBCOMPONENT> + +<CONNECTOR type="126" id="100062" index="2" uid="bb8af76d-7dc7-46e2-a011-c52e0d03db16" > +<cdparam x="1013" y="438" /> +<sizeparam width="0" height="0" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<infoparam name="connector" value="Connector between ports" /> +<P1 x="1013" y="513" id="100041" /> +<P2 x="213" y="513" id="100061" /> +<AutomaticDrawing data="true" /> +</CONNECTOR> + +</TMLComponentTaskDiagramPanel> + +<TMLActivityDiagramPanel name="Input" minX="10" maxX="2500" minY="10" maxY="1500" zoom="1.0" > +<COMPONENT type="1000" id="100009" index="0" uid="87331209-5a50-4954-a152-d0bdd0b7b078" > +<cdparam x="400" y="50" /> +<sizeparam width="15" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="start state" value="null" /> +<TGConnectingPoint num="0" id="100010" /> +</COMPONENT> + + +</TMLActivityDiagramPanel> + +<TMLActivityDiagramPanel name="Output" minX="10" maxX="2500" minY="10" maxY="1500" zoom="1.0" > +<COMPONENT type="1000" id="100020" index="0" uid="b15b4d33-e4c1-4c65-ba7b-1e73aa07ba11" > +<cdparam x="400" y="50" /> +<sizeparam width="15" height="15" minWidth="0" minHeight="0" maxWidth="2000" maxHeight="2000" minDesiredWidth="0" minDesiredHeight="0" /> +<hidden value="false" /> +<cdrectangleparam minX="10" maxX="2500" minY="10" maxY="1500" /> +<infoparam name="start state" value="null" /> +<TGConnectingPoint num="0" id="100021" /> +</COMPONENT> + + +</TMLActivityDiagramPanel> + +</Modeling> + + + </TURTLEGMODELING> \ No newline at end of file diff --git a/src/main/java/ui/DrawerTMLModeling.java b/src/main/java/ui/DrawerTMLModeling.java index 67d86951fdd80468bf071f3210bbc69d95f4753a..7dd93f13fb431aca5b52f5a4fae95a91715f545f 100644 --- a/src/main/java/ui/DrawerTMLModeling.java +++ b/src/main/java/ui/DrawerTMLModeling.java @@ -42,6 +42,8 @@ import myutil.TraceManager; import org.apache.batik.anim.timing.Trace; import tmltranslator.*; +import ui.tmlcompd.TMLCChannelOutPort; +import ui.tmlcompd.TMLCPortConnector; import ui.tmlcompd.TMLCPrimitiveComponent; import ui.tmlcompd.TMLCPrimitivePort; @@ -67,13 +69,15 @@ public class DrawerTMLModeling { private final static int YCENTER = 350; + private MainGUI mgui; private boolean hasError; private HashMap<TMLTask, TMLCPrimitiveComponent> taskMap; - public DrawerTMLModeling() { + public DrawerTMLModeling(MainGUI _mgui) { + mgui = _mgui; } // Not thread-safe @@ -105,6 +109,7 @@ public class DrawerTMLModeling { TraceManager.addDev("Adding events"); makeEvents(tmlspec, panel); + TraceManager.addDev("All done"); panel.tmlctdp.repaint(); @@ -115,7 +120,7 @@ public class DrawerTMLModeling { int nbOfTasks = tmlspec.getTasks().size(); for(Object task: tmlspec.getTasks()) { if (task instanceof TMLTask) { - boolean ret = addTask((TMLTask) task, taskID, nbOfTasks, panel); + boolean ret = addTask((TMLTask) task, taskID, nbOfTasks, panel, taskID == 0); if (!ret) return false; taskID ++; } @@ -124,25 +129,21 @@ public class DrawerTMLModeling { return true; } - private boolean addTask(TMLTask task, int id, int nbOfTasks, TMLComponentDesignPanel panel) { + private boolean addTask(TMLTask task, int id, int nbOfTasks, TMLComponentDesignPanel panel, boolean setDiagramName) { int myX = (int)(XCENTER + RADIUS * cos(2*Math.PI/nbOfTasks*id)); int myY = (int)(YCENTER + RADIUS * sin(2*Math.PI/nbOfTasks*id)); int myType = TGComponentManager.TMLCTD_PCOMPONENT; - TraceManager.addDev("myX=" + myX + " myY=" + myY); + TraceManager.addDev("myX=" + myX + " myY=" + myY + " Adding built component"); + - /*TGComponent tgc = TGComponentManager.addComponent(myX, myY, myType, panel.tmlctdp); - if (tgc == null) { - return false; - }*/ TMLCPrimitiveComponent comp = new TMLCPrimitiveComponent(myX, myY, panel.tmlctdp.getMinX(), panel.tmlctdp.getMaxX(), panel.tmlctdp.getMinY(), panel.tmlctdp.getMaxY(), - true, null, panel.tmlctdp); - comp.setValue(task.getName()); + true, null, panel.tmlctdp, task.getTaskName()); + // Adding a built component panel.tmlctdp.addBuiltComponent(comp); TraceManager.addDev("Width=" + comp.getWidth()); - //panel.tmlctdp.renamePrimitiveComponent(comp.getValue(), task.getTaskName()); for(TMLAttribute attr: task.getAttributes()) { TAttribute ta; @@ -157,6 +158,17 @@ public class DrawerTMLModeling { } taskMap.put(task, comp); + if (setDiagramName) { + String longName = task.getName(); + int index = longName.indexOf("__"); + if (index > 0) { + int indexTab = mgui.getIndexOfPanel(panel); + TraceManager.addDev("Found panel at index:" + indexTab + " ; renaming to " + longName.substring(0, index)); + if (indexTab > -1) { + mgui.renameTab(indexTab, longName.substring(0, index)); + } + } + } return true; } @@ -175,7 +187,7 @@ public class DrawerTMLModeling { private boolean makeEvents(TMLModeling tmlspec, TMLComponentDesignPanel panel) { - for(Object o: tmlspec.getChannels()) { + for(Object o: tmlspec.getEvents()) { if (o instanceof TMLEvent) { boolean ret = addEvent((TMLEvent) o, panel); if (!ret) return false; @@ -244,29 +256,56 @@ public class DrawerTMLModeling { } // Adding ports to tasks - int myX = c1.getX() + c1.getWidth() / 2; - int myY = c1.getY() + c2.getWidth() / 2; - int myType = TGComponentManager.TMLCTD_COPORT; - TraceManager.addDev("Adding port"); - TGComponent tgc = TGComponentManager.addComponent(myX, myY, myType, panel.tmlctdp); - - if (tgc == null) { + TMLCChannelOutPort p1 = addPort(c1, evt.getName(),TMLCPrimitivePort.TML_PORT_EVENT, panel ); + if (p1 == null) { + return false; + } + TMLCChannelOutPort p2 = addPort(c2, evt.getName(),TMLCPrimitivePort.TML_PORT_EVENT, panel ); + if (p2 == null) { return false; } - TMLCPrimitivePort comp = (TMLCPrimitivePort) tgc; - comp.setPortName(evt.getName()); - panel.tmlctdp.addBuiltComponent(tgc); - - // Setting the characteristics // Connecting the ports + addPortConnector(p1, p2, panel); + return true; + } + private TMLCChannelOutPort addPort(TGComponent tgc, String name, int portType, TMLComponentDesignPanel panel) { + int myX = tgc.getX() + tgc.getWidth() / 2; + int myY = tgc.getY() + tgc.getHeight() / 2; + int myType = TGComponentManager.TMLCTD_COPORT; + //TraceManager.addDev("Adding port"); + TGComponent tgcPort = TGComponentManager.addComponent(myX, myY, myType, panel.tmlctdp); + TMLCChannelOutPort comp = new TMLCChannelOutPort(myX, myY, panel.tmlctdp.getMinX(), + panel.tmlctdp.getMaxX(), panel.tmlctdp.getMinY(), panel.tmlctdp.getMaxY(), + true, null, panel.tmlctdp); - return true; + + comp.setPortName(name); + comp.setPortType(portType); + + if (tgc instanceof SwallowTGComponent) { + ((SwallowTGComponent)tgc).addSwallowedTGComponent(comp, myX, myY); + return comp; + } + return null; } + private boolean addPortConnector(TMLCChannelOutPort p1, TMLCChannelOutPort p2, TMLComponentDesignPanel panel) { + int myX = p1.getX() + p1.getWidth() / 2; + int myY = p1.getY() + p1.getHeight() / 2; + p1.getTGConnectingPointAtIndex(0).setFree(false); + p2.getTGConnectingPointAtIndex(0).setFree(false); + TMLCPortConnector conn = new TMLCPortConnector(myX, myY, panel.tmlctdp.getMinX(), + panel.tmlctdp.getMaxX(), panel.tmlctdp.getMinY(), panel.tmlctdp.getMaxY(), + true, null, panel.tmlctdp, p1.getTGConnectingPointAtIndex(0), p2.getTGConnectingPointAtIndex(0), null); + + panel.tmlctdp.addBuiltConnector(conn); + + return true; + } diff --git a/src/main/java/ui/GTURTLEModeling.java b/src/main/java/ui/GTURTLEModeling.java index d1cb372f4282089d53c67c7ccbd6391b5d8c25c5..670dec52adf209ca1d51d2f4126a17a1248435ea 100644 --- a/src/main/java/ui/GTURTLEModeling.java +++ b/src/main/java/ui/GTURTLEModeling.java @@ -2720,9 +2720,6 @@ public class GTURTLEModeling { return tmlm; } - public void setTMLModeling(TMLModeling tmlm) { - this.tmlm = tmlm; - } public TML2Avatar getTML2Avatar() { return t2a; diff --git a/src/main/java/ui/MainGUI.java b/src/main/java/ui/MainGUI.java index a3716c3adec6c3bd3d25a460a9e153094fe51434..7e8716f257e10a88d327cbd14f4382f5d529cc6f 100644 --- a/src/main/java/ui/MainGUI.java +++ b/src/main/java/ui/MainGUI.java @@ -1878,7 +1878,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per TraceManager.addDev("Draw TML Spec 2"); TMLComponentDesignPanel tmlcdp = (TMLComponentDesignPanel) (tabs.elementAt(index)); TraceManager.addDev("Draw TML Spec 3"); - DrawerTMLModeling drawer = new DrawerTMLModeling(); + DrawerTMLModeling drawer = new DrawerTMLModeling(this); drawer.drawTMLModelingPanel(tmlm, tmlcdp); TraceManager.addDev("Draw TML Spec 4"); } @@ -8341,6 +8341,10 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per } } + public void renameTab(int index, String newName) { + mainTabbedPane.setTitleAt(index, newName); + } + public void deleteTab(TDiagramPanel tdp) { // TraceManager.addDev("Delete"); @@ -8824,6 +8828,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per } + public void renameDeployment(String oldName, String newName) { TURTLEPanel tp; diff --git a/src/main/java/ui/TDiagramPanel.java b/src/main/java/ui/TDiagramPanel.java index 3c427861a6de30a219acccdf2768d9d54099f39a..770e20502efc3667f0f8a77e3bf8eaeb5912a787 100644 --- a/src/main/java/ui/TDiagramPanel.java +++ b/src/main/java/ui/TDiagramPanel.java @@ -3147,6 +3147,11 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { private String findGoodName(String name, NameChecker checker) { + + if (this.isNameUnique(name, checker)) + return name; + + // index >= 0 catch overflows for (int index = 0; index >= 0; index++) { String tryName = name + index; diff --git a/src/main/java/ui/TGConnector.java b/src/main/java/ui/TGConnector.java index 1de10ef9f9340f2c41c93cb34c35d3909de8b2d6..902b9d89b581d0771e8ad3d6a2826510507a1cd4 100644 --- a/src/main/java/ui/TGConnector.java +++ b/src/main/java/ui/TGConnector.java @@ -107,6 +107,11 @@ public abstract class TGConnector extends TGCScalableWithInternalComponent { } protected void initPoints( final Vector<Point> _listPoint ) { + if (_listPoint == null) { + nbInternalTGComponent = 0; + tgcomponent = new TGComponent[0]; + return; + } nbInternalTGComponent = _listPoint.size(); tgcomponent = new TGComponent[nbInternalTGComponent]; diff --git a/src/main/java/ui/tmlcompd/TMLCPortConnector.java b/src/main/java/ui/tmlcompd/TMLCPortConnector.java index ff96719282514655e932297189c08cc996eac3b2..fa73e267c889d5a53a6f158b4371e2c528e9bbe9 100755 --- a/src/main/java/ui/tmlcompd/TMLCPortConnector.java +++ b/src/main/java/ui/tmlcompd/TMLCPortConnector.java @@ -62,7 +62,8 @@ public class TMLCPortConnector extends TGConnector implements /* Issue #31 Scal //protected TGConnectingPoint oldp1, oldp2; - public TMLCPortConnector(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) { + public TMLCPortConnector(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"; diff --git a/src/main/java/ui/tmlcompd/TMLCPrimitiveComponent.java b/src/main/java/ui/tmlcompd/TMLCPrimitiveComponent.java index f599c5e5422997b6002f58f0f2bf4f4dbf03e91d..308335f7d9c277389148c3a7190610c18ef088d0 100755 --- a/src/main/java/ui/tmlcompd/TMLCPrimitiveComponent.java +++ b/src/main/java/ui/tmlcompd/TMLCPrimitiveComponent.java @@ -102,6 +102,16 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp public TMLCPrimitiveComponent(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); + init("TMLComp"); + } + + public TMLCPrimitiveComponent(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, + String initialName) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + init(initialName); + } + + private void init(String initialName) { // Issue #31 //minWidth = 1; @@ -129,7 +139,7 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp removable = true; userResizable = true; - value = tdp.findTMLPrimitiveComponentName("TMLComp_"); + value = tdp.findTMLPrimitiveComponentName(initialName); oldValue = value; setName("Primitive component"); @@ -140,6 +150,8 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp actionOnAdd(); } + + /*private Color choosingColor() { if (ColorManager.TML_COMPOSITE_COMPONENT == Color.white) return Color.white; diff --git a/src/main/java/ui/tmlcompd/TMLCPrimitivePort.java b/src/main/java/ui/tmlcompd/TMLCPrimitivePort.java index e10ab764ef4e9d874e76b916d50d185f3e7a54db..c9ab08af65ed2c0d468a769254cdb0af6f1a0659 100755 --- a/src/main/java/ui/tmlcompd/TMLCPrimitivePort.java +++ b/src/main/java/ui/tmlcompd/TMLCPrimitivePort.java @@ -71,6 +71,11 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent implements SwallowedTGComponent, LinkedReference, WithAttributes, TMLPortWithSecurityInformation { + public final static int TML_PORT_CHANNEL = 0; + public final static int TML_PORT_EVENT = 1; + public final static int TML_PORT_REQUEST = 2; + + public static int NOCHECK = 0; public static int TOCHECK = 1; public static int CHECKED_CONF = 2; @@ -976,6 +981,11 @@ return typep; } + public void setPortType(int _typeP) { + typep = _typeP; + } + + public String getPortTypeName() { switch (typep) { case 0: