From 80fbfa92a9d8532a0980e20fdfb9a45e78902d6d Mon Sep 17 00:00:00 2001 From: Ludovic Apvrille <ludovic.apvrille@telecom-paristech.fr> Date: Tue, 26 May 2009 15:19:27 +0000 Subject: [PATCH] New classes for simulation --- src/ui/ColorManager.java | 13 +- src/ui/DesignPanelTranslator.java | 12 +- src/ui/GTURTLEModeling.java | 665 +++--------------- src/ui/IconManager.java | 2 +- src/ui/MainGUI.java | 57 +- src/ui/TDiagramMouseManager.java | 5 +- src/ui/TDiagramPanel.java | 108 ++- src/ui/TGCNote.java | 23 +- src/ui/TGComponent.java | 6 +- src/ui/TGConnectingPoint.java | 10 +- src/ui/TGConnectorInfo.java | 66 ++ src/ui/ad/TADActionState.java | 30 + src/ui/ad/TActivityDiagramPanel.java | 5 + src/ui/cd/TClassDiagramPanel.java | 42 ++ .../InteractiveSimulationActions.java | 158 +++++ .../InteractiveSimulationBar.java | 73 ++ .../JFrameInteractiveSimulation.java | 232 ++++-- .../MainCommandsToolBar.java | 90 +++ src/ui/tmlad/TMLActivityDiagramPanel.java | 4 + src/ui/tmlcompd/TMLCCompositeComponent.java | 20 +- src/ui/tmlcompd/TMLCPortConnector.java | 7 + src/ui/tmlcompd/TMLCPrimitiveComponent.java | 2 +- .../TMLCReferencePortConnectingPoint.java | 58 +- .../TMLCRemoteCompositeComponent.java | 182 ++++- .../TMLComponentTaskDiagramPanel.java | 31 +- src/ui/window/JDialogSystemCGeneration.java | 2 +- 26 files changed, 1179 insertions(+), 724 deletions(-) create mode 100644 src/ui/TGConnectorInfo.java create mode 100755 src/ui/interactivesimulation/InteractiveSimulationActions.java create mode 100644 src/ui/interactivesimulation/InteractiveSimulationBar.java rename src/ui/{window => interactivesimulation}/JFrameInteractiveSimulation.java (75%) create mode 100755 src/ui/interactivesimulation/MainCommandsToolBar.java diff --git a/src/ui/ColorManager.java b/src/ui/ColorManager.java index d9a489c005..0a068716af 100755 --- a/src/ui/ColorManager.java +++ b/src/ui/ColorManager.java @@ -67,12 +67,17 @@ public class ColorManager { public static final Color POINTED_0 = Color.orange; //public static final Color POINTED_0 = new Color(231, 132, 19); + public static final Color UML_NOTE_BG = new Color(189, 91, 13, 200); + public static final Color COMPOSITION_OPERATOR = Color.yellow; public static final Color ATTRIBUTE_BOX = new Color(199, 243, 105); + public static final Color ATTRIBUTE_BOX_ACTION = new Color(199, 243, 105, 125); + public static final Color GATE_BOX_ACTION = new Color(215, 241, 247, 125); public static final Color GATE_BOX = new Color(215, 241, 247); public static final Color OPERATION_BOX = new Color(243, 207, 158); public static final Color ACTIVITY_BOX = new Color(255, 208, 255); public static final Color RESIZE_POINTED = new Color(26, 114, 244); + public static final Color UNKNOWN_BOX_ACTION = new Color(239, 44, 12, 125); public static final Color REQ_ATTRIBUTE_BOX = new Color(179, 249, 179); //public static final Color REQ_ATTRIBUTE_BOX = new Color(190, 229, 158); @@ -86,11 +91,11 @@ public class ColorManager { public static final Color MEMORY_BOX = new Color(172, 234, 211); public static final Color HWA_BOX = new Color(144, 201, 211); - public static final Color TML_COMPOSITE_COMPONENT = new Color(239, 212, 176); + public static final Color TML_COMPOSITE_COMPONENT = new Color(239, 212, 176, 125); - public static final Color TML_PORT_CHANNEL = new Color(104, 229, 255); - public static final Color TML_PORT_EVENT = new Color(216, 187, 249); - public static final Color TML_PORT_REQUEST = new Color(196, 166, 122); + public static final Color TML_PORT_CHANNEL = new Color(104, 229, 255, 200); + public static final Color TML_PORT_EVENT = new Color(216, 187, 249, 200); + public static final Color TML_PORT_REQUEST = new Color(196, 166, 122, 200); public static final Color UML_NOTE = Color.lightGray; diff --git a/src/ui/DesignPanelTranslator.java b/src/ui/DesignPanelTranslator.java index a30dd99786..b6a50c67d1 100755 --- a/src/ui/DesignPanelTranslator.java +++ b/src/ui/DesignPanelTranslator.java @@ -331,6 +331,8 @@ public class DesignPanelTranslator { return; } + TADActionState tadas; + ADStart ads; //ADActionState ada; ADActionStateWithGate adag; @@ -370,6 +372,7 @@ public class DesignPanelTranslator { }*/ if (tgc instanceof TADActionState) { + tadas = (TADActionState)tgc; s = ((TADActionState)tgc).getAction(); s = s.trim(); //remove ';' if last character @@ -394,6 +397,7 @@ public class DesignPanelTranslator { }*/ //System.out.println("Adding type"); s1 = TURTLEModeling.manageGateDataStructures(t, s1); + tadas.setStateAction(TADActionState.GATE); //System.out.println("hi"); if (s1 == null) { //System.out.println("ho"); @@ -402,6 +406,7 @@ public class DesignPanelTranslator { ce.setTGComponent(tgc); ce.setTDiagramPanel(tdp); addCheckingError(ce); + tadas.setStateAction(TADActionState.UNKNOWN); return; } s1 = TURTLEModeling.addTypeToDataReceiving(t, s1); @@ -417,11 +422,13 @@ public class DesignPanelTranslator { ce.setTGComponent(tgc); ce.setTDiagramPanel(tdp); addCheckingError(ce); + tadas.setStateAction(TADActionState.UNKNOWN); } adap = new ADActionStateWithParam(p); ad.addElement(adap); adap.setActionValue(TURTLEModeling.manageDataStructures(t, t.getExprValueFromActionState(s))); listE.addCor(adap, tgc); + tadas.setStateAction(TADActionState.ATTRIBUTE); } else if ((p != null) && (nbActions > 1)){ //System.out.println("Action state with multi param found " + p.getName() + " value:" + t.getExprValueFromActionState(s)); @@ -435,6 +442,7 @@ public class DesignPanelTranslator { ce.setTGComponent(tgc); ce.setTDiagramPanel(tdp); addCheckingError(ce); + tadas.setStateAction(TADActionState.UNKNOWN); } p = t.getParamFromActionState(sTmp); @@ -444,9 +452,10 @@ public class DesignPanelTranslator { ce.setTGComponent(tgc); ce.setTDiagramPanel(tdp); addCheckingError(ce); + tadas.setStateAction(TADActionState.UNKNOWN); } } - + tadas.setStateAction(TADActionState.ATTRIBUTE); adamp = new ADActionStateWithMultipleParam(); ad.addElement(adamp); adamp.setActionValue(TURTLEModeling.manageDataStructures(t, s)); @@ -457,6 +466,7 @@ public class DesignPanelTranslator { ce.setTGComponent(tgc); ce.setTDiagramPanel(tdp); addCheckingError(ce); + tadas.setStateAction(TADActionState.UNKNOWN); //System.out.println("Bad action state found " + s); } diff --git a/src/ui/GTURTLEModeling.java b/src/ui/GTURTLEModeling.java index 5b6af1f0db..1da7c9d15d 100755 --- a/src/ui/GTURTLEModeling.java +++ b/src/ui/GTURTLEModeling.java @@ -142,6 +142,8 @@ public class GTURTLEModeling { private Vector checkingErrors; private Vector warnings; + + ArrayList<TGConnectorInfo> pendingConnectors; private Vector savedOperations; private Vector savedPanels; @@ -227,7 +229,7 @@ public class GTURTLEModeling { generateDesign(); } } catch (Exception e) { - System.out.println("Exception: " + e.getMessage()); + System.out.println("Exception on TIF: " + e.getMessage()); } return ret; } @@ -1512,579 +1514,6 @@ public class GTURTLEModeling { return warnings; } - /*private void addTClasses(DesignPanel dp, Vector tclasses, String preName) { - TDiagramPanel tdp; - // search for class diagram panels - tdp = (TDiagramPanel)(dp.panels.elementAt(0)); - if (tdp instanceof TClassDiagramPanel) { - addTClassesFromPanel((TClassDiagramPanel)tdp, tclasses, preName); - } - } - - private void addTClassesFromPanel(TClassDiagramPanel tdp, Vector tclasses, String preName) { - LinkedList list = tdp.getComponentList(); - Iterator iterator = list.listIterator(); - - // search for tclasses - TGComponent tgc; - while(iterator.hasNext()) { - tgc = (TGComponent)(iterator.next()); - if ((tgc instanceof TClassInterface) && (tclasses.contains(tgc))) { - addTClassFromTClassInterface((TClassInterface)tgc, tdp, preName); - } - } - } - - private void addTClassFromTClassInterface(TClassInterface tgc, TClassDiagramPanel tdp, String preName) { - //System.out.println("Adding TClass: " + tgc.getClassName()); - TClass t = new TClass(preName + tgc.getClassName(), tgc.isStart()); - - Vector v; - int i; - TAttribute a; - Param p; - Gate g; boolean internal; int type; - - // Attributes - v = tgc.getAttributes(); - for(i=0; i<v.size(); i++) { - a = (TAttribute)(v.elementAt(i)); - if (a.getType() == TAttribute.NATURAL) { - p = new Param(a.getId(), Param.NAT, a.getInitialValue()); - p.setAccess(a.getAccessString()); - t.addParameter(p); - } - if (a.getType() == TAttribute.BOOLEAN) { - p = new Param(a.getId(), Param.BOOL, a.getInitialValue()); - p.setAccess(a.getAccessString()); - t.addParameter(p); - } - - if (a.getType() == TAttribute.OTHER) { - addTDataAttributes(a, t, tdp); - } - } - - // Gates - v = tgc.getGates(); - for(i=0; i<v.size(); i++) { - a = (TAttribute)(v.elementAt(i)); - internal = (a.getAccess() == TAttribute.PRIVATE); - switch(a.getType()) { - case TAttribute.GATE: - type = Gate.GATE; - break; - case TAttribute.OUTGATE: - type = Gate.OUTGATE; - break; - case - TAttribute.INGATE: - type = Gate.INGATE; - break; - default: - type = -1; - } - if (type > -1) { - internal = false; // We consider all gates as public gates -> private is given for documentation purpose only - g = new Gate(a.getId(), type, internal); - t.addGate(g); - } - } - - - tm.addTClass(t); - listE.addCor(t, (TGComponent)tgc, preName); - - // Activity Diagram - buildActivityDiagram(t); - - } - - private void addTDataAttributes(TAttribute a, TClass t, TClassDiagramPanel tdp) { - //System.out.println("Find data: " + a.getId() + " getTypeOther=" + a.getTypeOther()); - TCDTData tdata = tdp.findTData(a.getTypeOther()); - if (tdata == null) { - CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Unknown type: " + a.getTypeOther()); - ce.setTClass(t); - ce.setTDiagramPanel(tdp); - addCheckingError(ce); - return ; - } - - Vector v = tdata.getAttributes(); - TAttribute b; Param p; - for(int i=0; i<v.size(); i++) { - b = (TAttribute)(v.elementAt(i)); - if (b.getType() == TAttribute.NATURAL) { - p = new Param(a.getId() + "__" + b.getId(), Param.NAT, b.getInitialValue()); - p.setAccess(a.getAccessString()); - t.addParameter(p); - } - if (b.getType() == TAttribute.BOOLEAN) { - p = new Param(a.getId() + "__" + b.getId(), Param.BOOL, b.getInitialValue()); - p.setAccess(a.getAccessString()); - t.addParameter(p); - } - } - - } - - private void buildActivityDiagram(TClass t) { - int i, j; - TActivityDiagramPanel tadp; - //t.printParams(); - - // find the panel of this TClass - TClassInterface tci = (TClassInterface)(listE.getTG(t)); - - String name = tci.getClassName(); - int index_name = name.indexOf(':'); - // instance - if (index_name != -1) { - name = name.substring(index_name+2, name.length()); - } - - tadp = tci.getActivityDiagramPanel(); - if (tadp == null) { - return; - } - - // search for start state - LinkedList list = tadp.getComponentList(); - Iterator iterator = list.listIterator(); - TGComponent tgc; - TADStartState tss = null; - int cptStart = 0; - while(iterator.hasNext()) { - tgc = (TGComponent)(iterator.next()); - if (tgc instanceof TADStartState) { - tss = (TADStartState) tgc; - cptStart ++; - } - } - - if (tss == null) { - CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "No start state in the activity diagram of " + name); - ce.setTClass(t); - ce.setTDiagramPanel(tadp); - addCheckingError(ce); - return; - } - - if (cptStart > 1) { - CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "More than one start state in the activity diagram of " + name); - ce.setTClass(t); - ce.setTDiagramPanel(tadp); - addCheckingError(ce); - return; - } - - ADStart ads; - ADActionState ada; - ADActionStateWithGate adag; - ADActionStateWithParam adap; - ADActionStateWithMultipleParam adamp; - ADChoice adch; - ADDelay add; - ADJunction adj; - ADLatency adl; - ADParallel adp; - ADSequence adseq; - ADPreempt adpre; - ADStop adst; - ADTimeInterval adti; - ADTLO adtlo; - String s, s1; - Gate g; - Param p; - - int nbActions; - String sTmp; - - // Creation of the activity diagram - ads = new ADStart(); - listE.addCor(ads, tss); - ActivityDiagram ad = new ActivityDiagram(ads); - t.setActivityDiagram(ad); - //System.out.println("Making activity diagram of " + t.getName()); - - // Creation of other elements - iterator = list.listIterator(); - while(iterator.hasNext()) { - tgc = (TGComponent)(iterator.next()); - if (tgc instanceof TADActionState) { - s = ((TADActionState)tgc).getAction(); - s = s.trim(); - //remove ';' if last character - if (s.substring(s.length()-1, s.length()).compareTo(";") == 0) { - s = s.substring(0, s.length()-1); - } - nbActions = Conversion.nbChar(s, ';') + 1; - //System.out.println("Nb Actions in state: " + nbActions); - - s = TURTLEModeling.manageDataStructures(t, s); - - g = t.getGateFromActionState(s); - p = t.getParamFromActionState(s); - if ((g != null) && (nbActions == 1)){ - //System.out.println("Action state with gate found " + g.getName() + " value:" + t.getActionValueFromActionState(s)); - adag = new ADActionStateWithGate(g); - ad.addElement(adag); - s1 = t.getActionValueFromActionState(s); - //System.out.println("s1=" + s1); - s1 = TURTLEModeling.manageGateDataStructures(t, s1); - //System.out.println("hi"); - if (s1 == null) { - //System.out.println("ho"); - CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Invalid expression: " + t.getActionValueFromActionState(s)); - ce.setTClass(t); - ce.setTGComponent(tgc); - ce.setTDiagramPanel(tadp); - addCheckingError(ce); - return; - } - s1 = TURTLEModeling.addTypeToDataReceiving(t, s1); - //System.out.println("Adding type done"); - adag.setActionValue(s1); - listE.addCor(adag, tgc); - } else if ((p != null) && (nbActions == 1)){ - //System.out.println("Action state with param found " + p.getName() + " value:" + t.getExprValueFromActionState(s)); - adap = new ADActionStateWithParam(p); - ad.addElement(adap); - adap.setActionValue(TURTLEModeling.manageDataStructures(t, t.getExprValueFromActionState(s))); - listE.addCor(adap, tgc); - } else if ((p != null) && (nbActions > 1)){ - //System.out.println("Action state with multi param found " + p.getName() + " value:" + t.getExprValueFromActionState(s)); - // Checking params - CheckingError ce; - for(j=0; j<nbActions; j++) { - sTmp = TURTLEModeling.manageDataStructures(t,((TADActionState)(tgc)).getAction(j)); - if (sTmp == null) { - ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Action state (" + s + "): \"" + s + "\" is not a correct expression"); - ce.setTClass(t); - ce.setTGComponent(tgc); - ce.setTDiagramPanel(tadp); - addCheckingError(ce); - } - - p = t.getParamFromActionState(sTmp); - if (p == null) { - ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Action state(" + s + "): \"" + sTmp + "\" is not a correct expression"); - ce.setTClass(t); - ce.setTGComponent(tgc); - ce.setTDiagramPanel(tadp); - addCheckingError(ce); - } - } - - adamp = new ADActionStateWithMultipleParam(); - ad.addElement(adamp); - adamp.setActionValue(TURTLEModeling.manageDataStructures(t, s)); - listE.addCor(adamp, tgc); - } else { - CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Action state (" + s + "): \"" + s + "\" is not a correct expression"); - ce.setTClass(t); - ce.setTGComponent(tgc); - ce.setTDiagramPanel(tadp); - addCheckingError(ce); - //System.out.println("Bad action state found " + s); - } - - } else if (tgc instanceof TADChoice) { - adch = new ADChoice(); - ad.addElement(adch); - listE.addCor(adch, tgc); - } else if (tgc instanceof TADDeterministicDelay) { - add = new ADDelay(); - ad.addElement(add); - add.setValue(TURTLEModeling.manageGateDataStructures(t, ((TADDeterministicDelay)tgc).getDelayValue())); - listE.addCor(add, tgc); - } else if (tgc instanceof TADJunction) { - adj = new ADJunction(); - ad.addElement(adj); - listE.addCor(adj, tgc); - } else if (tgc instanceof TADNonDeterministicDelay) { - adl = new ADLatency(); - ad.addElement(adl); - adl.setValue(TURTLEModeling.manageGateDataStructures(t, ((TADNonDeterministicDelay)tgc).getLatencyValue())); - listE.addCor(adl, tgc); - } else if (tgc instanceof TADParallel) { - adp = new ADParallel(); - ad.addElement(adp); - adp.setValueGate(((TADParallel)tgc).getValueGate()); - listE.addCor(adp, tgc); - } else if (tgc instanceof TADSequence) { - adseq = new ADSequence(); - ad.addElement(adseq); - listE.addCor(adseq, tgc); - } else if (tgc instanceof TADPreemption) { - adpre = new ADPreempt(); - ad.addElement(adpre); - listE.addCor(adpre, tgc); - } else if (tgc instanceof TADStopState) { - adst = new ADStop(); - ad.addElement(adst); - listE.addCor(adst, tgc); - } else if (tgc instanceof TADTimeInterval) { - adti = new ADTimeInterval(); - ad.addElement(adti); - adti.setValue(TURTLEModeling.manageGateDataStructures(t, ((TADTimeInterval)tgc).getMinDelayValue()), TURTLEModeling.manageGateDataStructures(t, ((TADTimeInterval)tgc).getMaxDelayValue())); - listE.addCor(adti, tgc); - } else if (tgc instanceof TADTimeLimitedOffer) { - s = ((TADTimeLimitedOffer)tgc).getAction(); - g = t.getGateFromActionState(s); - if (g != null) { - adtlo = new ADTLO(g); - ad.addElement(adtlo); - adtlo.setLatency("0"); - s1 = t.getActionValueFromActionState(s); - //System.out.println("Adding type"); - s1 = TURTLEModeling.manageGateDataStructures(t, s1); - s1 = TURTLEModeling.addTypeToDataReceiving(t, s1); - //System.out.println("Adding type done"); - adtlo.setAction(s1); - adtlo.setDelay(TURTLEModeling.manageGateDataStructures(t, ((TADTimeLimitedOffer)tgc).getDelay())); - listE.addCor(adtlo, tgc); - } else { - CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Time-limited offer (" + s + ", " + ((TADTimeLimitedOffer)tgc).getDelay() + "): \"" + s + "\" is not a correct expression"); - ce.setTClass(t); - ce.setTGComponent(tgc); - ce.setTDiagramPanel(tadp); - addCheckingError(ce); - //System.out.println("Bad time limited offer found " + s); - } - } else if (tgc instanceof TADTimeLimitedOfferWithLatency) { - s = ((TADTimeLimitedOfferWithLatency)tgc).getAction(); - g = t.getGateFromActionState(s); - if (g != null) { - adtlo = new ADTLO(g); - ad.addElement(adtlo); - adtlo.setLatency(TURTLEModeling.manageGateDataStructures(t, ((TADTimeLimitedOfferWithLatency)tgc).getLatency())); - s1 = t.getActionValueFromActionState(s); - //System.out.println("Adding type"); - s1 = TURTLEModeling.manageGateDataStructures(t, s1); - s1 = TURTLEModeling.addTypeToDataReceiving(t, s1); - //System.out.println("Adding type done"); - adtlo.setAction(s1); - adtlo.setDelay(TURTLEModeling.manageGateDataStructures(t, ((TADTimeLimitedOfferWithLatency)tgc).getDelay())); - listE.addCor(adtlo, tgc); - } else { - CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Time-limited offer (" + s + ", " + ((TADTimeLimitedOfferWithLatency)tgc).getLatency() + ", " + ((TADTimeLimitedOfferWithLatency)tgc).getDelay() + "): \"" + s + "\" is not a correct expression"); - ce.setTClass(t); - ce.setTGComponent(tgc); - ce.setTDiagramPanel(tadp); - addCheckingError(ce); - //System.out.println("Bad time limited offer found " + s); - } - } - } - - TGConnectingPoint p1, p2; - TGConnectorFullArrow tgco; - TGComponent tgc1, tgc2, tgc3; - ADComponent ad1, ad2; - - // Managing Java code - iterator = list.listIterator(); - while(iterator.hasNext()) { - tgc = (TGComponent)(iterator.next()); - if (tgc instanceof PreJavaCode) { - ad1 = listE.getADComponentByIndex(tgc, tadp.count); - if (ad1 != null) { - ad1.setPreJavaCode(tgc.getPreJavaCode()); - } - } - if (tgc instanceof PostJavaCode) { - ad1 = listE.getADComponentByIndex(tgc, tadp.count); - if (ad1 != null) { - ad1.setPostJavaCode(tgc.getPostJavaCode()); - } - } - } - - // Connecting elements - iterator = list.listIterator(); - while(iterator.hasNext()) { - tgc = (TGComponent)(iterator.next()); - if (tgc instanceof TGConnectorFullArrow) { - tgco = (TGConnectorFullArrow)tgc; - p1 = tgco.getTGConnectingPointP1(); - p2 = tgco.getTGConnectingPointP2(); - - // identification of connected components - tgc1 = null; tgc2 = null; - for(j=0; j<list.size(); j++) { - tgc3 = (TGComponent)(list.get(j)); - if (tgc3.belongsToMe(p1)) { - tgc1 = tgc3; - } - if (tgc3.belongsToMe(p2)) { - tgc2 = tgc3; - } - } - - // connecting turtle modeling components - if ((tgc1 != null) && (tgc2 != null)) { - //ADComponent ad1, ad2; - ad1 = listE.getADComponentByIndex(tgc1, tadp.count); - ad2 = listE.getADComponentByIndex(tgc2, tadp.count); - int index = 0; - if ((ad1 != null ) && (ad2 != null)) { - if ((tgc1 instanceof TADTimeLimitedOffer) || (tgc1 instanceof TADTimeLimitedOfferWithLatency)) { - index = tgc1.indexOf(p1) - 1; - ad1.addNextAtIndex(ad2, index); - } else if (tgc1 instanceof TADChoice) { - TADChoice tadch = (TADChoice)tgc1; - index = tgc1.indexOf(p1) - 1; - ((ADChoice)ad1).addGuard(TURTLEModeling.manageGateDataStructures(t, tadch.getGuard(index))); - ad1.addNext(ad2); - } else if ((tgc1 instanceof TADSequence) ||(tgc1 instanceof TADPreemption)){ - index = tgc1.indexOf(p1) - 1; - ad1.addNextAtIndex(ad2, index); - } else { - ad1.addNextAtIndex(ad2, index); - //System.out.println("Adding connector from " + ad1 + " to " + ad2); - } - } - } - } - } - // Increasing count of this panel - tadp.count ++; - } - - private void addCheckingError(CheckingError ce) { - if (checkingErrors == null) { - checkingErrors = new Vector(); - } - checkingErrors.addElement(ce); - } - - private void addRelations(DesignPanel dp, String prename) { - addRelationFromPanel((TClassDiagramPanel)dp.tdp, prename); - } - - private void addRelations(DesignPanel dp) { - addRelationFromPanel((TClassDiagramPanel)dp.tdp, ""); - } - - private void addRelationFromPanel(TClassDiagramPanel tdp, String prename) { - LinkedList list = tdp.getComponentList(); - Iterator iterator = list.listIterator(); - // search for Composition Operator - TGComponent tgc; - - while(iterator.hasNext()) { - tgc = (TGComponent)(iterator.next()); - if (tgc instanceof TCDCompositionOperator) { - addRelationFromCompositionOperator((TCDCompositionOperator)tgc, tdp, prename); - } - } - } - - private void addRelationFromCompositionOperator(TCDCompositionOperator tco, TClassDiagramPanel tdp, String prename) { - TClassInterface t1 = tdp.getTClass1ToWhichIamConnected(tco); - TClassInterface t2 = tdp.getTClass2ToWhichIamConnected(tco); - - TGConnectorAssociation tgco = tdp.getTGConnectorAssociationOf(tco); - - if ((t1 != null) && (t2 != null) && (tgco != null)) { - TClass tc1 = tm.getTClassWithName(prename + t1.getValue()); - TClass tc2 = tm.getTClassWithName(prename + t2.getValue()); - - if ((tc1 != null) && (tc2 != null)) { - int type = typeOf(tco); - if (type == -1) { - return; - } - - Relation r; - - if (tgco instanceof TGConnectorAssociationWithNavigation) { - r = new Relation(type, tc1, tc2, true); - } else { - r = new Relation(type, tc1, tc2, false); - } - - tm.addRelation(r); - //System.out.println("Adding " + Relation.translation(type) + " relation between " + tc1.getName() + " and " + tc2.getName()); - - // if tgco is a synchro operator -> synchronizations gates - if (tco instanceof TCDSynchroOperator) { - Vector gates = ((TCDSynchroOperator)tco).getGates(); - setGatesOf(r, gates, tc1, tc2); - } - - if (tco instanceof TCDInvocationOperator) { - Vector gates = ((TCDInvocationOperator)tco).getGates(); - setGatesOf(r, gates, tc1, tc2); - } - - // if tgco watcdog -> list of gates - if (tco instanceof TCDWatchdogOperator) { - Vector gates = ((TCDWatchdogOperator)tco).getGates(); - setWatchdogGatesOf(r, gates, tc1, tc2); - } - - } - } - } - - private int typeOf(TCDCompositionOperator tco) { - if (tco instanceof TCDParallelOperator) { - return Relation.PAR; - } else if (tco instanceof TCDPreemptionOperator) { - return Relation.PRE; - } else if (tco instanceof TCDSequenceOperator) { - return Relation.SEQ; - } else if (tco instanceof TCDSynchroOperator) { - return Relation.SYN; - } else if (tco instanceof TCDInvocationOperator) { - return Relation.INV; - } else if (tco instanceof TCDWatchdogOperator) { - return Relation.WAT; - } - return -1; - } - - private void setGatesOf(Relation r, Vector gates, TClass tc1, TClass tc2) { - TTwoAttributes tt; - Gate g1, g2; - - for(int i=0; i<gates.size(); i++) { - tt = (TTwoAttributes)(gates.elementAt(i)); - g1 = tc1.getGateByName(tt.ta1.getId()); - g2 = tc2.getGateByName(tt.ta2.getId()); - - if ((g1 != null) && (g2 != null)) { - r.addGates(g1, g2); - //System.out.println("Adding gates " + g1.getName() + " = " + g2.getName()); - } - } - } - - private void setWatchdogGatesOf(Relation r, Vector gates, TClass tc1, TClass tc2) { - TTwoAttributes tt; - TAttribute t; - Gate g1, g2; - - for(int i=0; i<gates.size(); i++) { - t = (TAttribute)(gates.elementAt(i)); - g1 = tc1.getGateByName(t.getId()); - - if (g1 != null) { - r.addGates(g1, g1); - } - } - }*/ - - - /*public static String removeForbiddenCharactersFromInput(Stirng s) { - s = Conversion.replaceAllChar(s, '&', " "); - s = Conversion.replaceAllChar(s, '"', " "); - return s; - }*/ - // SAVING AND LOADING IN XML @@ -2773,6 +2202,7 @@ public class GTURTLEModeling { TMLComponentTaskDiagramPanel tmlctdp = (TMLComponentTaskDiagramPanel)tdp; + //tmlctdp.updateReferences(); for(i=0; i<nl.getLength(); i++) { @@ -3225,6 +2655,8 @@ public class GTURTLEModeling { //designPanelNl = doc.getElementsByTagName("Design"); //analysisNl = doc.getElementsByTagName("Analysis"); + pendingConnectors = new ArrayList<TGConnectorInfo>(); + //System.out.println("nb de design=" + designPanelNl.getLength() + " nb d'analyse=" + analysisNl.getLength()); boolean error = false; for(i=0; i<panelNl.getLength(); i++) { @@ -3258,6 +2690,7 @@ public class GTURTLEModeling { throw new MalformedModelingException(); } //System.out.println("making IDs"); + makeLastLoad(); makeLovelyIds(); //System.out.println("IDs done"); } @@ -4405,7 +3838,7 @@ public class GTURTLEModeling { for(i=0; i<tgcpList.size(); i++) { p = (Point)(tgcpList.elementAt(i)); if (!tgc.setIdTGConnectingPoint(p.x, p.y)) { - System.out.println("Warning: a connecting point has been removed"); + //System.out.println("Warning: a connecting point has been removed"); //throw new MalformedModelingException(); } } @@ -4421,7 +3854,7 @@ public class GTURTLEModeling { }*/ } catch (Exception e) { - System.out.println("Exception " + e.getMessage()); + System.out.println("Exception XML Component " + e.getMessage()); throw new MalformedModelingException(); } return tgc; @@ -4474,6 +3907,7 @@ public class GTURTLEModeling { if (tgco != null) { tdp.addBuiltConnector(tgco); } else { + System.out.println("Connector error"); throw new MalformedModelingException(); } } @@ -4488,6 +3922,9 @@ public class GTURTLEModeling { TGComponent tgc; //TGComponent tgctmp; TGConnector tgco = null; + //boolean error = false; + TGConnectorInfo tgcoinfo; + //connect connectors to their real connecting point //System.out.println("Valid connectors ?"); @@ -4498,7 +3935,9 @@ public class GTURTLEModeling { p1 = tgco.getTGConnectingPointP1(); p2 = tgco.getTGConnectingPointP2(); if ((p1 instanceof TGConnectingPointTmp) && (p2 instanceof TGConnectingPointTmp)){ + //System.out.println("Searching for id " + p1.getId()); p3 = tdp.findConnectingPoint(p1.getId()); + //System.out.println("Searching for id " + p2.getId()); p4 = tdp.findConnectingPoint(p2.getId()); if (((p3 ==null) || (p4 == null)) &&(decId != 0)) { if (list.remove(tgc)) { @@ -4508,7 +3947,75 @@ public class GTURTLEModeling { } } else { if ((p3 == null) ||(p4 == null)) { - throw new MalformedModelingException(); + //warning = true; + if (p3 == null) { + //System.out.println("Error on first id"); + } + if (p4 == null) { + //System.out.println("Error on second id"); + } + tgcoinfo = new TGConnectorInfo(); + tgcoinfo.connector = tgco; + pendingConnectors.add(tgcoinfo); + System.out.println("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) { + System.out.println("Connecting error: " + connectorsToRemove.size() + " connectors have been removed"); + throw new MalformedModelingException(); + }*/ + } + + public void makeLastLoad() { + // Update references on all diagrams + //System.out.println("Updating ports"); + //mgui.updateAllPorts(); + + // Update ports on all diagrams + System.out.println("Updating references / ports"); + mgui.updateAllReferences(); + + mgui.updateAllPorts(); + + System.out.println("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)){ + System.out.println("Searching for id " + p1.getId()); + p3 = tdp.findConnectingPoint(p1.getId()); + System.out.println("Searching for id " + p2.getId()); + p4 = tdp.findConnectingPoint(p2.getId()); + if ((p3 == null) ||(p4 == null)) { + //warning = true; + if (p3 == null) { + System.out.println("Error on first id"); + } + if (p4 == null) { + System.out.println("Error on second id"); + } + System.out.println("One connector ignored"); } else { tgco.setP1(p3); p3.setFree(false); @@ -4519,6 +4026,8 @@ public class GTURTLEModeling { } } } + pendingConnectors.clear(); + System.out.println("Last load done"); } public TGConnector makeXMLConnector(Node n, TDiagramPanel tdp) throws SAXException, MalformedModelingException { @@ -4657,7 +4166,7 @@ public class GTURTLEModeling { //System.out.println("Connecting points done " + myType); } catch (Exception e) { - System.out.println("Exception generale"); + System.out.println("Exception generale connector"); throw new MalformedModelingException(); } return tgco; diff --git a/src/ui/IconManager.java b/src/ui/IconManager.java index 0d7aac4e0c..2911a2a683 100755 --- a/src/ui/IconManager.java +++ b/src/ui/IconManager.java @@ -207,7 +207,7 @@ public class IconManager { private static String icon65 = "images/concomment.gif"; private static String icon66 = "images/gentmltxt.gif"; - private static String icon70 = "images/toolbarButtonGraphics/general/SendMai16.gif"; + private static String icon70 = "images/toolbarButtonGraphics/general/SendMail16.gif"; private static String icon71 = "images/toolbarButtonGraphics/general/SendMail24.gif"; private static String icon72 = "images/toolbarButtonGraphics/general/Help16.gif"; private static String icon73 = "images/toolbarButtonGraphics/general/Help24.gif"; diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index c33d169f26..f7aab3ef57 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -64,6 +64,7 @@ import myutil.*; import ui.ad.*; import ui.cd.*; import ui.file.*; +import ui.interactivesimulation.*; import ui.iod.*; import ui.req.*; import ui.sd.*; @@ -229,6 +230,8 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { private File tlsafile; private File tlsadotfile; private File rgautfile; + private File fc2file; + private File bcgfile; private File rgautdotfile; private File rgautprojfile; private File rgautprojdotfile; @@ -830,6 +833,30 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { return list; } + public void updateAllReferences() { + TURTLEPanel tp; + + for(int i=0; i<tabs.size(); i++) { + tp = (TURTLEPanel)(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 = (TURTLEPanel)(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>(); @@ -1302,6 +1329,8 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { rgdotfile = null; tlsadotfile = null; rgautfile = null; + fc2file = null; + bcgfile = null; rgautdotfile = null; rgautprojfile = null; rgautprojdotfile = null; @@ -2020,6 +2049,8 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { 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"); @@ -2784,7 +2815,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { if (jgen.isInteractiveSimulationSelected()) { JFrameInteractiveSimulation jfis = new JFrameInteractiveSimulation(frame, this, "Interactive simulation", ConfigurationTTool.SystemCHost, jgen.getPathInteractiveExecute()); jfis.setIconImage(IconManager.img9); - jfis.setSize(800, 600); + jfis.setSize(800, 700); GraphicLib.centerOnParent(jfis); jfis.setVisible(true); } @@ -2793,7 +2824,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { public void interactiveSimulationSystemC() { JFrameInteractiveSimulation jfis = new JFrameInteractiveSimulation(frame, this, "Interactive simulation", ConfigurationTTool.SystemCHost, ConfigurationTTool.SystemCCodeInteractiveExecuteCommand); jfis.setIconImage(IconManager.img9); - jfis.setSize(800, 600); + jfis.setSize(800, 700); GraphicLib.centerOnParent(jfis); jfis.setVisible(true); } @@ -2843,6 +2874,16 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { 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); @@ -2852,8 +2893,9 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { gtm.saveTLSADOT(tlsadotfile); } - public void saveRGAutDOT() { + public String saveRGAutDOT() { gtm.saveRGAutDOT(rgautdotfile); + return rgautdotfile.getAbsolutePath(); } public void saveRGAutProj() { @@ -4699,6 +4741,15 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { public boolean selectTab(String s) { return selectTab(getCurrentTURTLEPanel(), s); } + + 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); diff --git a/src/ui/TDiagramMouseManager.java b/src/ui/TDiagramMouseManager.java index e8ee465886..35c207d0ca 100755 --- a/src/ui/TDiagramMouseManager.java +++ b/src/ui/TDiagramMouseManager.java @@ -349,7 +349,7 @@ public class TDiagramMouseManager implements MouseListener, MouseMotionListener int selected = tdp.getGUI().getTypeButtonSelected(); if ((selected == TGComponentManager.EDIT) && (e.getClickCount() == 2) && (e.getButton() == MouseEvent.BUTTON1)){ - //System.out.println("Double clickkk"); + //System.out.println("Double click"); tgc = tdp.componentPointed(); if (tgc != null) { //System.out.println("Component pointed: " + tgc.getName()); @@ -396,7 +396,8 @@ public class TDiagramMouseManager implements MouseListener, MouseMotionListener } if ((selected == TGComponentManager.COMPONENT) &&(e.getButton() == MouseEvent.BUTTON1)){ - tdp.addComponent(e.getX(), e.getY(), true); + TGComponent comp = tdp.addComponent(e.getX(), e.getY(), true); + tdp.autoConnect(comp); tdp.getGUI().setEditMode(); //System.out.println("change1"); tdp.getGUI().changeMade(tdp, TDiagramPanel.NEW_COMPONENT); diff --git a/src/ui/TDiagramPanel.java b/src/ui/TDiagramPanel.java index 340906b8d8..745c010a7d 100755 --- a/src/ui/TDiagramPanel.java +++ b/src/ui/TDiagramPanel.java @@ -91,6 +91,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { protected TGComponent componentPointed; protected TGComponent componentPopup; protected TToolBar ttb; + protected TGComponent fatherOfRemoved; // popupmenus protected ActionListener menuAL; @@ -812,13 +813,14 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { } // Adding component - public void addComponent(int x, int y, boolean swallow) { - addComponent(x, y, mgui.getIdButtonSelected(), swallow); + public TGComponent addComponent(int x, int y, boolean swallow) { + return addComponent(x, y, mgui.getIdButtonSelected(), swallow); } - public void addComponent(int x, int y, int id, boolean swallow) { + 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 @@ -1155,7 +1157,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { } return v; } - + // For Design panels (TURTLE, TURTLE-OS, etc.) public TClassSynchroInterface getTClass1ToWhichIamConnected(CompositionOperatorInterface coi) { @@ -1788,6 +1790,8 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { TGComponent t; Iterator iterator = componentList.listIterator(); + fatherOfRemoved = tgc.getFather(); + while(iterator.hasNext()) { t = (TGComponent)(iterator.next()); if (t == tgc) { @@ -1802,7 +1806,9 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { tgc.actionOnRemove(); return; } else { + //System.out.println("Testing remove internal component"); if (t.removeInternalComponent(tgc)) { + //System.out.println("Remove internal component"); removeConnectors(tgc); return; } @@ -1842,6 +1848,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { } public void removeOneConnector(TGConnectingPoint cp) { + //System.out.println("Remove one connector"); TGConnector tgcon; TGComponent t; int j, k; @@ -2071,7 +2078,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { return null; } - public TGComponent getComponentToWhichBelongs(LinkedList components, TGConnectingPoint p) { + public TGComponent getComponentToWhichBelongs(LinkedList components, TGConnectingPoint p) { TGComponent tgc1, tgc2; Iterator iterator = components.listIterator(); @@ -2413,7 +2420,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { return name; } - public String findNodeName(String name) { + public String findNodeName(String name) { boolean ok; int i; int index = 0; @@ -2427,7 +2434,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { while(iterator.hasNext()) { tgc = (TGComponent)(iterator.next()); if (tgc.getName().equals(name + index)) { - ok = false; + ok = false; } }*/ if (ok) { @@ -2452,11 +2459,11 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { tgc = (TGComponent)(iterator.next()); if (tgc instanceof NCConnectorNode) { if (((NCConnectorNode)tgc).getInterfaceName().equals(name + index)) { - ok = false; + ok = false; } } else { if (tgc.getName().equals(name + index)) { - ok = false; + ok = false; } } }*/ @@ -2525,7 +2532,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { return true; } - public boolean isNCNameUnique(String s) { + public boolean isNCNameUnique(String s) { Object o; TGComponent tgc; Vector v; @@ -2979,6 +2986,87 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { repaint(); } + + public boolean hasAutoConnect() { + return false; + } + + public void autoConnect(TGComponent added) { + + + boolean cond = hasAutoConnect(); + + if (!cond) { + return; + } + + int i, j; + + //System.out.println("Autoconnect"); + + Vector listPoint = new Vector(); + + Vector v = new Vector(); + + int distance = 100; + TGConnectingPoint found = null; + int distanceTmp; + + boolean cd1, cd2; + + TGConnectingPoint tgcp, tgcp1; + + TGConnector tgco; + + TGComponent tgc; + Iterator iterator; + + 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; + + iterator = componentList.listIterator(); + while(iterator.hasNext()) { + tgc = (TGComponent)(iterator.next()); + 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) { + //System.out.println("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); + } + componentList.add(tgco); + //System.out.println("Connector added"); + } + } + } + //System.out.println("End Autoconnect"); + } } diff --git a/src/ui/TGCNote.java b/src/ui/TGCNote.java index a7e5d7c407..d46bc51730 100755 --- a/src/ui/TGCNote.java +++ b/src/ui/TGCNote.java @@ -97,23 +97,38 @@ public class TGCNote extends TGCWithoutInternalComponent { } int h = g.getFontMetrics().getHeight(); - - for (int i = 0; i<values.length; i++) { - g.drawString(values[i], x + textX, y + textY + i* h); - } + Color c = g.getColor(); + g.drawLine(x, y, x+width, y); g.drawLine(x, y, x, y+height); g.drawLine(x, y+height, x+width-limit, y+height); g.drawLine(x+width, y, x+width, y+height - limit); + g.setColor(ColorManager.UML_NOTE_BG); + int [] px1 = {x, x+width, x + width, x + width-limit, x}; + int [] py1 = {y, y, y+height-limit, y+height, y+height}; + g.fillPolygon(px1, py1, 5); + g.setColor(c); + int [] px = {x+width, x + width - 4, x+width-10, x + width-limit}; int [] py = {y+height-limit, y + height - limit + 3, y + height - limit + 2, y +height}; g.drawPolygon(px, py, 4); + if (g.getColor() == ColorManager.NORMAL_0) { g.setColor(ColorManager.UML_NOTE); } g.fillPolygon(px, py, 4); + + g.setColor(Color.black); + for (int i = 0; i<values.length; i++) { + g.drawString(values[i], x + textX, y + textY + i* h); + } + g.setColor(c); + + + + } public void makeValue() { diff --git a/src/ui/TGComponent.java b/src/ui/TGComponent.java index 5fc1d29027..bc03b22591 100755 --- a/src/ui/TGComponent.java +++ b/src/ui/TGComponent.java @@ -1,4 +1,4 @@ -/**Copyright or � or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille * * ludovic.apvrille AT enst.fr * @@ -1873,8 +1873,6 @@ public abstract class TGComponent implements CDElement, GenericTree { //TGComponent tgc; for(int i=0; i<nbInternalTGComponent; i++) { if (tgcomponent[i] == t) { - t.actionOnRemove(); - tdp.actionOnRemove(t); nbInternalTGComponent = nbInternalTGComponent - 1; if (nbInternalTGComponent == 0) { tgcomponent = null; @@ -1890,6 +1888,8 @@ public abstract class TGComponent implements CDElement, GenericTree { } tgcomponent = tgcomponentbis; } + t.actionOnRemove(); + tdp.actionOnRemove(t); return true; } else { if (tgcomponent[i].removeInternalComponent(t)) { diff --git a/src/ui/TGConnectingPoint.java b/src/ui/TGConnectingPoint.java index ab3e651e6f..1585b5f8f2 100755 --- a/src/ui/TGConnectingPoint.java +++ b/src/ui/TGConnectingPoint.java @@ -179,11 +179,17 @@ public class TGConnectingPoint implements CDElement { } public int getX() { - return x + container.getX(); + if (container != null) { + return x + container.getX(); + } + return x; } public int getY() { - return y + container.getY(); + if (container != null) { + return y + container.getY(); + } + return y; } public int getId() { diff --git a/src/ui/TGConnectorInfo.java b/src/ui/TGConnectorInfo.java new file mode 100644 index 0000000000..fc3e52e8ac --- /dev/null +++ b/src/ui/TGConnectorInfo.java @@ -0,0 +1,66 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + * + * /** + * Class TGConnectorInfo + * Class for storing a TGConnector with diagram, and connecting point + * information. + * Creation: 25/05/2009 + * @version 1.0 25/05/2009 + * @author Ludovic APVRILLE + * @see + */ + +package ui; + +import java.awt.*; +import java.awt.event.*; +import java.awt.geom.*; +import javax.swing.*; +import java.util.*; + +import myutil.*; + +public class TGConnectorInfo { + + public TGConnector connector; + + public TGConnectorInfo() { + + } + +} diff --git a/src/ui/ad/TADActionState.java b/src/ui/ad/TADActionState.java index 9ef25b6aa7..01bf7492b0 100755 --- a/src/ui/ad/TADActionState.java +++ b/src/ui/ad/TADActionState.java @@ -57,6 +57,12 @@ public class TADActionState extends TGCOneLineText implements PreJavaCode, PostJ protected int textX = 5; protected int textY = 15; protected int arc = 5; + + protected int stateAction = 0; // 0: unchecked 1: attribute; 2: gate; 3:unknown + public static final int ATTRIBUTE = 1; + public static final int GATE = 2; + public static final int UNKNOWN = 3; + public TADActionState(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); @@ -89,7 +95,25 @@ public class TADActionState extends TGCOneLineText implements PreJavaCode, PostJ width = w1; //updateConnectingPoints(); } + + + if (stateAction > 0) { + Color c = g.getColor(); + switch(stateAction) { + case 1: + g.setColor(ColorManager.ATTRIBUTE_BOX_ACTION); + break; + case 2: + g.setColor(ColorManager.GATE_BOX_ACTION); + break; + default: + g.setColor(ColorManager.UNKNOWN_BOX_ACTION); + } + g.fillRoundRect(x, y, width, height, arc, arc); + g.setColor(c); + } g.drawRoundRect(x, y, width, height, arc, arc); + g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); @@ -152,6 +176,12 @@ public class TADActionState extends TGCOneLineText implements PreJavaCode, PostJ public int getDefaultConnector() { return TGComponentManager.CONNECTOR_AD_DIAGRAM; } + + public void setStateAction(int _stateAction) { + stateAction = _stateAction; + } + + } diff --git a/src/ui/ad/TActivityDiagramPanel.java b/src/ui/ad/TActivityDiagramPanel.java index 58449976d1..b524b981b8 100755 --- a/src/ui/ad/TActivityDiagramPanel.java +++ b/src/ui/ad/TActivityDiagramPanel.java @@ -70,6 +70,7 @@ public class TActivityDiagramPanel extends TDiagramPanel implements ActivityDiag } public boolean actionOnAdd(TGComponent tgc) { + System.out.println("Adding " + tgc); return false; } public boolean actionOnValueChanged(TGComponent tgc) { @@ -201,4 +202,8 @@ public class TActivityDiagramPanel extends TDiagramPanel implements ActivityDiag enhance(v, tgc1); } } + + public boolean hasAutoConnect() { + return true; + } } diff --git a/src/ui/cd/TClassDiagramPanel.java b/src/ui/cd/TClassDiagramPanel.java index 042d40130b..fe7d9ece5d 100755 --- a/src/ui/cd/TClassDiagramPanel.java +++ b/src/ui/cd/TClassDiagramPanel.java @@ -53,6 +53,7 @@ import org.w3c.dom.*; import ui.*; +import translator.*; public class TClassDiagramPanel extends TDiagramPanel implements ClassDiagramPanelInterface { @@ -257,5 +258,46 @@ public class TClassDiagramPanel extends TDiagramPanel implements ClassDiagramPan setSynchroVisible(true); } } + + public void makeStateActionsOf(TClassInterface tgc) { + Vector tclasses = new Vector(); + tclasses.add(tgc); + + DesignPanel dp = (DesignPanel)(mgui.getCurrentTURTLEPanel()); + DesignPanelTranslator dpt = new DesignPanelTranslator(dp); + TURTLEModeling tm = dpt.generateTURTLEModeling(tclasses, ""); + + /*String name = tgc.getClassName(); + tdp = (TDiagramPanel)(tgc.getBehaviourDiagramPanel()); + + LinkedList list = tdp.getComponentList(); + Iterator iterator = list.listIterator(); + + TADActionState action; + + TGComponent comp; + while(iterator.hasNext()) { + comp = (TGComponent)(iterator.next()); + if (comp instanceof TADActionState) { + action = (TADActionState)comp; + makeStateActionOf(tgc, action); + } + }*/ + } + + /*public void makeStateActionOf(TClassInterface tgc, TADActionState action) { + String tmp; + int index; + + String value = action.getAction(); + index = value.indexOf("=") + if (index == -1) { + // Can be only a gate + } else { + // Can be only a parameter + tmp = value.substring(0, index).trim(); + + } + }*/ } diff --git a/src/ui/interactivesimulation/InteractiveSimulationActions.java b/src/ui/interactivesimulation/InteractiveSimulationActions.java new file mode 100755 index 0000000000..7289efd23b --- /dev/null +++ b/src/ui/interactivesimulation/InteractiveSimulationActions.java @@ -0,0 +1,158 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** + * Class InteractiveSimulationActions + * + * Creation: 26/05/2009 + * @version 1.0 26/05/2009 + * @author Ludovic APVRILLE + * @see TGComponent + */ + +package ui.interactivesimulation; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; + +import javax.swing.*; +import javax.swing.event.EventListenerList; + +import ui.*; + +public class InteractiveSimulationActions extends AbstractAction { + // Actions + public static final int ACT_RUN_SIMU = 0; + public static final int ACT_STOP_SIMU = 1; + public static final int ACT_RESET_SIMU = 2; + + public static final int ACT_START_ALL = 3; + public static final int ACT_STOP_ALL = 4; + public static final int ACT_STOP_AND_CLOSE_ALL = 5; + + public static final int NB_ACTION = 6; + + + 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 InteractiveSimulationActions(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) { + putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(actions[id].MNEMONIC_KEY, java.awt.event.InputEvent.CTRL_MASK)); + } + putValue(Action.ACTION_COMMAND_KEY, actions[id].ACTION_COMMAND_KEY); + + } + + public void setName(int index, String name) { + actions[index].NAME = name; + putValue(Action.NAME, actions[index].NAME); + } + + public void init() { + actions[ACT_RUN_SIMU] = new TAction("run-simu", "Run simulation", IconManager.imgic53, IconManager.imgic53, "Run simulation", "Run simulation. works only if the simulator is \"ready\"", 'R'); + actions[ACT_STOP_SIMU] = new TAction("stop-simu", "Stop simulation", IconManager.imgic55, IconManager.imgic55, "Stop simulation", "Stop simulation. Works only if the simulator is \"busy\"", 'S'); + actions[ACT_RESET_SIMU] = new TAction("reset-simu", "Reset simulation", IconManager.imgic45, IconManager.imgic45, "Reset simulation", "Reset simulation", 'T'); + + actions[ACT_START_ALL] = new TAction("start-all", "Connect to simulator", IconManager.imgic53, IconManager.imgic53, "Connect", "Start the server - if it is not yet running - and connect to it", 'C'); + actions[ACT_STOP_ALL] = new TAction("stop-all", "Quit simulation window", IconManager.imgic27, IconManager.imgic27, "Quit simulation window", "Quit the simulation window without terminating the simulation", 'Q'); + actions[ACT_STOP_AND_CLOSE_ALL] = new TAction("stop-and-close-all", "Terminate simulation and quit", IconManager.imgic27, IconManager.imgic27, "Terminate simulation and quit", "Terminate the simulation and quit the simulation window", 'T'); + + } + + + 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(); + } + listeners.add(ActionListener.class, l); + } + + public void removeActionListener(ActionListener l) { + if (listeners == null) { + return; + } + listeners.remove(ActionListener.class, l); + } +} diff --git a/src/ui/interactivesimulation/InteractiveSimulationBar.java b/src/ui/interactivesimulation/InteractiveSimulationBar.java new file mode 100644 index 0000000000..480181342d --- /dev/null +++ b/src/ui/interactivesimulation/InteractiveSimulationBar.java @@ -0,0 +1,73 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** + * Class InteractiveSimulationBar + * Abstract toolbar to be used by simulation window + * Creation: 26/05/2009 + * @version 1.0 26/05/2009 + * @author Ludovic APVRILLE + * @see TGComponent + */ + +package ui.interactivesimulation; + +import javax.swing.*; + + +public abstract class InteractiveSimulationBar extends JToolBar { + protected JFrameInteractiveSimulation jfis; + + public InteractiveSimulationBar(JFrameInteractiveSimulation _jfis) { + super(); + jfis = _jfis; + setOrientation(SwingConstants.HORIZONTAL); + setFloatable(false) ; + setButtons(); + } + + // asbtract operations + protected abstract void setButtons(); + + protected abstract void setActive(boolean b); + +} // Class + + + + + diff --git a/src/ui/window/JFrameInteractiveSimulation.java b/src/ui/interactivesimulation/JFrameInteractiveSimulation.java similarity index 75% rename from src/ui/window/JFrameInteractiveSimulation.java rename to src/ui/interactivesimulation/JFrameInteractiveSimulation.java index 0b763d9d7a..c4eda61632 100755 --- a/src/ui/window/JFrameInteractiveSimulation.java +++ b/src/ui/interactivesimulation/JFrameInteractiveSimulation.java @@ -43,7 +43,7 @@ knowledge of the CeCILL license and that you accept its terms. * @see */ -package ui.window; +package ui.interactivesimulation; //import java.io.*; import javax.swing.*; @@ -107,7 +107,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene // Control command protected JButton resetCommand, runCommand, StopCommand; - protected JToolBar toolbarCommand; + protected MainCommandsToolBar mctb; JPanel main, mainTop, commands, infos, outputs; // from MGUI @@ -121,11 +121,10 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene private boolean threadStarted = false; private boolean gotTimeAnswerFromServer = false; - //shortest paths - //JComboBox combo1, combo2, combo3, combo4; - //JTextField combo1, combo2, combo3, combo4; - //JTextField text1, text2; - //JButton goPath, goPathL, savePath, savePathL; + // For managing actions + public InteractiveSimulationActions [] actions; + public MouseHandler mouseHandler; + public KeyListener keyHandler; public JFrameInteractiveSimulation(Frame _f, MainGUI _mgui, String _title, String _hostSystemC, String _pathExecute) { @@ -139,10 +138,22 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene mode = NOT_STARTED; + + + setBackground(new Color(50, 40, 40, 200)); + + + initActions(); makeComponents(); setComponents(); } + private JLabel createStatusBar() { + status = new JLabel("Ready..."); + status.setBorder(BorderFactory.createEtchedBorder()); + return status; + } + public void makeComponents() { JPanel jp01; //jp01.setPreferredSize(new Dimension(375, 400)); @@ -154,26 +165,41 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Container framePanel = getContentPane(); framePanel.setLayout(new BorderLayout()); + //framePanel.setBackground(new Color(50, 40, 40, 200)); + //framePanel.setForeground(new Color(255, 166, 38)); //System.out.println("Button start created"); - buttonStart = new JButton(buttonStartS, IconManager.imgic53); - buttonStart.addActionListener(this); - buttonClose = new JButton(buttonCloseS, IconManager.imgic27); - buttonClose.addActionListener(this); - buttonStopAndClose = new JButton(buttonStopAndCloseS, IconManager.imgic27); - buttonStopAndClose.addActionListener(this); + buttonStart = new JButton(actions[InteractiveSimulationActions.ACT_START_ALL]); + buttonClose = new JButton(actions[InteractiveSimulationActions.ACT_STOP_ALL]); + buttonStopAndClose = new JButton(actions[InteractiveSimulationActions.ACT_STOP_AND_CLOSE_ALL]); + //buttonStopAndClose = new JButton(buttonStopAndCloseS, IconManager.imgic27); + + + + + + // statusBar + status = createStatusBar(); + framePanel.add(status, BorderLayout.SOUTH); + + // Mouse handler + mouseHandler = new MouseHandler(status); + + JPanel mainpanel = new JPanel(new BorderLayout()); + framePanel.add(mainpanel, BorderLayout.NORTH); JPanel jp = new JPanel(); + //jp.setPreferredSize(new Dimension(800, 75)); jp.add(buttonStart); jp.add(buttonStopAndClose); jp.add(buttonClose); - framePanel.add(jp, BorderLayout.SOUTH); + mainpanel.add(jp, BorderLayout.SOUTH); GridBagLayout gridbag02 = new GridBagLayout(); GridBagConstraints c02 = new GridBagConstraints(); mainTop = new JPanel(gridbag02); - mainTop.setPreferredSize(new Dimension(800, 475)); + //mainTop.setPreferredSize(new Dimension(800, 375)); c02.gridheight = 1; c02.weighty = 1.0; c02.weightx = 1.0; @@ -183,7 +209,9 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene // Ouput textArea jta = new ScrolledJTextArea(); - jta.setMinimumSize(new Dimension(800, 200)); + jta.setMinimumSize(new Dimension(800, 400)); + jta.setRows(15); + //jta.setMaximumSize(new Dimension(800, 500)); jta.setEditable(false); jta.setMargin(new Insets(10, 10, 10, 10)); jta.setTabSize(3); @@ -191,13 +219,19 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene Font f = new Font("Courrier", Font.BOLD, 12); jta.setFont(f); jsp = new JScrollPane(jta, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - + jsp.setViewportBorder(BorderFactory.createLineBorder(Color.red)); + + //jsp.setColumnHeaderView(100); + //jsp.setRowHeaderView(30); + + + jsp.setMaximumSize(new Dimension(800, 500)); JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, mainTop, jsp); - framePanel.add(split, BorderLayout.CENTER); + mainpanel.add(split, BorderLayout.CENTER); // Commands commands = new JPanel(); - commands.setMinimumSize(new Dimension(300, 250)); + //commands.setMinimumSize(new Dimension(300, 250)); commands.setBorder(new javax.swing.border.TitledBorder("Commands")); @@ -206,16 +240,16 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene commandTab = new JTabbedPane(); // Control commands - jp01 = new JPanel(); + jp01 = new JPanel(new BorderLayout()); //jp01.setMinimumSize(new Dimension(375, 400)); - gridbag01 = new GridBagLayout(); - c01 = new GridBagConstraints(); - jp01.setLayout(gridbag01); + //gridbag01 = new GridBagLayout(); + //c01 = new GridBagConstraints(); + //jp01.setLayout(gridbag01); commandTab.addTab("Control", null, jp01, "Main control commands"); - c01.gridheight = 1; + /*c01.gridheight = 1; c01.weighty = 1.0; c01.weightx = 1.0; //c01.gridwidth = 1; @@ -237,11 +271,11 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene runCommand.addMouseListener(this); jp01.add(runCommand, c01); c01.gridheight = 1; - jp01.add(new JLabel(" "), c01); + jp01.add(new JLabel(" "), c01);*/ + + mctb = new MainCommandsToolBar(this); + jp01.add(mctb, BorderLayout.NORTH); - toolbarCommand = new JToolBar(); - toolbarCommand.setOrientation(SwingConstants.HORIZONTAL); - toolbarCommand.setFloatable(false) ; // Text commands jp01 = new JPanel(); @@ -330,27 +364,21 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene time.setForeground(Color.red); jp01.add(time, c01); + + pack(); } - public void actionPerformed(ActionEvent evt) { - String command = evt.getActionCommand(); - //System.out.println("Command:" + command); - - if (command.equals(buttonCloseS)) { - close(); - return; - } else if (command.equals(buttonStartS)) { - setComponents(); - startSimulation(); - //System.out.println("Start simulation!"); - } else if (command.equals(buttonStopAndCloseS)) { - killSimulator(); - close(); - return; - //System.out.println("Start simulation!"); - } - } + private void initActions() { + actions = new InteractiveSimulationActions[InteractiveSimulationActions.NB_ACTION]; + for(int i=0; i<InteractiveSimulationActions.NB_ACTION; i++) { + actions[i] = new InteractiveSimulationActions(i); + actions[i].addActionListener(this); + //actions[i].addKeyListener(this); + } + } + + public void setComponents() { if (mode == NOT_STARTED) { @@ -367,9 +395,10 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene boolean b = (mode == STARTED_AND_CONNECTED); sendTextCommand.setEnabled(b); - resetCommand.setEnabled(b); - runCommand.setEnabled(b); - StopCommand.setEnabled(b); + setAll(b); + //resetCommand.setEnabled(b); + //runCommand.setEnabled(b); + //StopCommand.setEnabled(b); } public void close() { @@ -561,13 +590,13 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene helpOnCommand(); } else if (e.getSource() == listTextCommands) { listTextCommands(); - } else if (e.getSource() == resetCommand) { + } /*else if (e.getSource() == resetCommand) { sendCommand("reset"); } else if (e.getSource() == runCommand) { sendCommand("run-to-next-breakpoint"); } else if (e.getSource() == StopCommand) { sendCommand("stop"); - } + }*/ } // Command management @@ -796,22 +825,42 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene public void makeStatus(String s) { status.setText(s); if (s.equals("busy")) { - runCommand.setEnabled(false); + setBusyStatus(true); + /*actions[InteractiveSimulationActions.ACT_RUN_SIMU].setEnabled(false); + actions[InteractiveSimulationActions.ACT_RESET_SIMU].setEnabled(false); + actions[InteractiveSimulationActions.ACT_STOP_SIMU].setEnabled(true);*/ + /*runCommand.setEnabled(false); resetCommand.setEnabled(false); - StopCommand.setEnabled(true); + StopCommand.setEnabled(true);*/ busyStatus = true; } if (s.equals("ready")) { - runCommand.setEnabled(true); + /*runCommand.setEnabled(true); resetCommand.setEnabled(true); - StopCommand.setEnabled(false); + StopCommand.setEnabled(false);*/ + /*actions[InteractiveSimulationActions.ACT_RUN_SIMU].setEnabled(true); + actions[InteractiveSimulationActions.ACT_RESET_SIMU].setEnabled(true); + actions[InteractiveSimulationActions.ACT_STOP_SIMU].setEnabled(false);*/ if (busyStatus) { sendCommand("time"); } - busyStatus = false; + setBusyStatus(false); } } + public void setBusyStatus(boolean b) { + actions[InteractiveSimulationActions.ACT_RUN_SIMU].setEnabled(!b); + actions[InteractiveSimulationActions.ACT_RESET_SIMU].setEnabled(!b); + actions[InteractiveSimulationActions.ACT_STOP_SIMU].setEnabled(b); + busyStatus = b; + } + + public void setAll(boolean b) { + actions[InteractiveSimulationActions.ACT_RUN_SIMU].setEnabled(b); + actions[InteractiveSimulationActions.ACT_RESET_SIMU].setEnabled(b); + actions[InteractiveSimulationActions.ACT_STOP_SIMU].setEnabled(b); + } + public static String decodeString(String s) { if (s == null) return s; @@ -827,11 +876,68 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene public void printFromServer(String s) { jta.append("Server> " + s + "\n"); } - - -// Mouse management - -public void mouseReleased(MouseEvent e) {} - - + + + // Mouse management + public void mouseReleased(MouseEvent e) {} + + + + /** + * 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; + } + + 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); + } + } + } + } + + public void actionPerformed(ActionEvent evt) { + String command = evt.getActionCommand(); + //System.out.println("Command:" + command); + + if (command.equals(actions[InteractiveSimulationActions.ACT_STOP_ALL].getActionCommand())) { + close(); + } else if (command.equals(actions[InteractiveSimulationActions.ACT_START_ALL].getActionCommand())) { + setComponents(); + startSimulation(); + //System.out.println("Start simulation!"); + } else if (command.equals(actions[InteractiveSimulationActions.ACT_STOP_AND_CLOSE_ALL].getActionCommand())) { + killSimulator(); + close(); + return; + //System.out.println("Start simulation!"); + } else if (command.equals(actions[InteractiveSimulationActions.ACT_RUN_SIMU].getActionCommand())) { + sendCommand("run-to-next-breakpoint"); + } else if (command.equals(actions[InteractiveSimulationActions.ACT_RESET_SIMU].getActionCommand())) { + sendCommand("reset"); + } else if (command.equals(actions[InteractiveSimulationActions.ACT_STOP_SIMU].getActionCommand())) { + sendCommand("stop"); + } + } + + } // Class \ No newline at end of file diff --git a/src/ui/interactivesimulation/MainCommandsToolBar.java b/src/ui/interactivesimulation/MainCommandsToolBar.java new file mode 100755 index 0000000000..d82b6138d1 --- /dev/null +++ b/src/ui/interactivesimulation/MainCommandsToolBar.java @@ -0,0 +1,90 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** + * Class MainCommandsToolBar + * Toolbar associated with interactive simulation (main commands) + * Creation: 26/05/2009 + * @version 1.0 26/05/2009 + * @author Ludovic APVRILLE + * @see + */ + +package ui.interactivesimulation; + +import javax.swing.*; +//import java.awt.*; +//import java.awt.event.*; + +import ui.*; + +public class MainCommandsToolBar extends InteractiveSimulationBar { + + + public MainCommandsToolBar(JFrameInteractiveSimulation _jfis) { + super(_jfis); + } + + protected void setActive(boolean b) { + jfis.actions[InteractiveSimulationActions.ACT_RUN_SIMU].setEnabled(b); + jfis.actions[InteractiveSimulationActions.ACT_STOP_SIMU].setEnabled(b); + jfis.actions[InteractiveSimulationActions.ACT_RESET_SIMU].setEnabled(b); + } + + protected void setButtons() { + JButton button; + + button = this.add(jfis.actions[InteractiveSimulationActions.ACT_RESET_SIMU]); + button.addMouseListener(jfis.mouseHandler); + + this.addSeparator(); + + button = this.add(jfis.actions[InteractiveSimulationActions.ACT_STOP_SIMU]); + button.addMouseListener(jfis.mouseHandler); + + button = this.add(jfis.actions[InteractiveSimulationActions.ACT_RUN_SIMU]); + button.addMouseListener(jfis.mouseHandler); + + + + } +} // Class + + + + + diff --git a/src/ui/tmlad/TMLActivityDiagramPanel.java b/src/ui/tmlad/TMLActivityDiagramPanel.java index dd7bc25e03..58d94a95f2 100755 --- a/src/ui/tmlad/TMLActivityDiagramPanel.java +++ b/src/ui/tmlad/TMLActivityDiagramPanel.java @@ -165,5 +165,9 @@ public class TMLActivityDiagramPanel extends TDiagramPanel { enhance(v, tgc1); } } + + public boolean hasAutoConnect() { + return true; + } } diff --git a/src/ui/tmlcompd/TMLCCompositeComponent.java b/src/ui/tmlcompd/TMLCCompositeComponent.java index 39fcbc8b71..cf3a200d57 100755 --- a/src/ui/tmlcompd/TMLCCompositeComponent.java +++ b/src/ui/tmlcompd/TMLCCompositeComponent.java @@ -94,6 +94,9 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp addTGConnectingPointsComment(); nbInternalTGComponent = 0; + + maxWidth = 2000; + maxHeight = 2000; moveable = true; editable = true; @@ -114,7 +117,7 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp //FontMetrics fm = g.getFontMetrics(); if (myColor == null) { - myColor = new Color(251, 252, 200- (getMyDepth() * 10)); + myColor = new Color(251, 252, 200- (getMyDepth() * 10), 200); } if ((rescaled) && (!tdp.isScaled())) { @@ -591,6 +594,21 @@ public class TMLCCompositeComponent extends TGCScalableWithInternalComponent imp } } + public void delayedLoad() { + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof TMLCRemoteCompositeComponent) { + //ColorManager.setColor(g, tgcomponent[i].getState(), 0); + try { + ((TMLCRemoteCompositeComponent)tgcomponent[i]).delayedLoad(); + } catch (Exception e) { + } + } + if (tgcomponent[i] instanceof TMLCCompositeComponent) { + ((TMLCCompositeComponent)tgcomponent[i]).delayedLoad(); + } + } + } + public int getCompositePortNb() { return compositePortNb; } diff --git a/src/ui/tmlcompd/TMLCPortConnector.java b/src/ui/tmlcompd/TMLCPortConnector.java index 5b49164e6a..95f1a191fb 100755 --- a/src/ui/tmlcompd/TMLCPortConnector.java +++ b/src/ui/tmlcompd/TMLCPortConnector.java @@ -109,8 +109,10 @@ public class TMLCPortConnector extends TGConnector implements ScalableTGCompone } }*/ + try { TMLCPortConnectingPoint pt1 = (TMLCPortConnectingPoint)p1; TMLCPortConnectingPoint pt2 = (TMLCPortConnectingPoint)p2; + if (!pt1.positionned) { pt1.positionned = true; @@ -140,6 +142,11 @@ public class TMLCPortConnector extends TGConnector implements ScalableTGCompone } g.drawLine(x1, y1, x2, y2); + return; + } catch (Exception e) { + //System.out.println("Exception " + e.getMessage()); + } + g.drawLine(x1, y1, x2, y2); //} else { diff --git a/src/ui/tmlcompd/TMLCPrimitiveComponent.java b/src/ui/tmlcompd/TMLCPrimitiveComponent.java index b458a79f83..e1a0da6258 100755 --- a/src/ui/tmlcompd/TMLCPrimitiveComponent.java +++ b/src/ui/tmlcompd/TMLCPrimitiveComponent.java @@ -120,7 +120,7 @@ public class TMLCPrimitiveComponent extends TGCScalableWithInternalComponent imp Font fold = f; if (myColor == null) { - myColor = new Color(201, 243, 188- (getMyDepth() * 10)); + myColor = new Color(201, 243, 188- (getMyDepth() * 10), 200); } if ((rescaled) && (!tdp.isScaled())) { diff --git a/src/ui/tmlcompd/TMLCReferencePortConnectingPoint.java b/src/ui/tmlcompd/TMLCReferencePortConnectingPoint.java index 41ad70862f..8de4fe9e31 100755 --- a/src/ui/tmlcompd/TMLCReferencePortConnectingPoint.java +++ b/src/ui/tmlcompd/TMLCReferencePortConnectingPoint.java @@ -58,45 +58,69 @@ public class TMLCReferencePortConnectingPoint extends TMLCPortConnectingPoint{ port = _port; } + public void setPort(TMLCCompositePort _port) { + port = _port; + } + + public TMLCCompositePort getPort() { + return port; + } + public static double getDecX(TMLCCompositePort _port) { - 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; + 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() { - return getDecX(port); + if (port != null) { + return getDecX(port); + } + return 0; } public static double getDecY(TMLCCompositePort _port) { - TGComponent tgc = _port.getFather(); - //System.out.println("getY"); - if (tgc != null) { - int y1 = _port.getY() + _port.getHeight()/2; - int y2 = tgc.getY(); - int h1 = tgc.getHeight(); - return ((double)y1 - y2) / h1; + if (_port != null) { + TGComponent tgc = _port.getFather(); + //System.out.println("getY"); + 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() { - return getDecY(port); + if (port != null) { + return getDecY(port); + } + return 0; } public int getX() { - return x + container.getX() + (int)(container.getWidth() * getDecX()); + if (container != null) { + return x + container.getX() + (int)(container.getWidth() * getDecX()); + } + return x; } public int getY() { - return y + container.getY() + (int)(container.getHeight() * getDecY()); + if (container != null) { + return y + container.getY() + (int)(container.getHeight() * getDecY()); + } + return y; } } diff --git a/src/ui/tmlcompd/TMLCRemoteCompositeComponent.java b/src/ui/tmlcompd/TMLCRemoteCompositeComponent.java index 2f20a8a0f0..42f61f49fb 100755 --- a/src/ui/tmlcompd/TMLCRemoteCompositeComponent.java +++ b/src/ui/tmlcompd/TMLCRemoteCompositeComponent.java @@ -36,13 +36,13 @@ The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. /** - * Class TMLCRemoteCompositeComponent - * Composite Component. To be used in TML component task diagrams - * Creation: 12/06/2008 - * @version 1.0 12/06/2008 - * @author Ludovic APVRILLE - * @see - */ +* Class TMLCRemoteCompositeComponent +* Composite Component. To be used in TML component task diagrams +* Creation: 12/06/2008 +* @version 1.0 12/06/2008 +* @author Ludovic APVRILLE +* @see +*/ package ui.tmlcompd; @@ -66,7 +66,8 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone private int spacePt = 3; private Color myColor; private int iconSize = 17; - + private boolean iconIsDrawn = false; + private int textX = 15; // border for ports private double dtextX = 0.0; @@ -75,6 +76,8 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone private TMLCCompositeComponent tmlcc; private ArrayList<TMLCCompositePort> ports; + + private NodeList nl; public TMLCRemoteCompositeComponent(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); @@ -93,7 +96,7 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone //connectingPoint = new TGConnectingPoint[0]; //connectingPoint[0] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.0, 0.0); - addTGConnectingPointsComment(); + //addTGConnectingPointsComment(); nbInternalTGComponent = 0; @@ -101,6 +104,7 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone editable = true; removable = true; userResizable = true; + multieditable = true; value = "No reference"; name = "Remote composite component"; @@ -157,7 +161,7 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone //FontMetrics fm = g.getFontMetrics(); if (myColor == null) { - myColor = new Color(251, 252, 200- (getMyDepth() * 10)); + myColor = new Color(251, 252, 200- (getMyDepth() * 10), 200); } if ((rescaled) && (!tdp.isScaled())) { @@ -251,6 +255,9 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone // 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; } } @@ -272,9 +279,21 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone } return null; } - + - public boolean editOndoubleClick(JFrame frame) { + public boolean editOndoubleClick(JFrame frame, int _x, int _y) { + + // On the icon? + if (iconIsDrawn && (tmlcc != null)) { + if (GraphicLib.isInRectangle(_x, _y, x + width - iconSize - textX, y + textX, iconSize, iconSize)) { + boolean b = tdp.getMGUI().selectHighLevelTab(tmlcc.getValuePanel()); + if (b) { + //System.out.println("got tab"); + return false; + } + } + } + JDialogTMLRemoteCompositeComponent dialog = new JDialogTMLRemoteCompositeComponent(frame, "Setting referenced component", this); dialog.setSize(400, 350); GraphicLib.centerOnParent(dialog); @@ -314,7 +333,15 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone 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{ + nl = _nl; + //delayedLoad(); + } + + public void delayedLoad() throws MalformedModelingException { + + //System.out.println("*** load extra synchro ***"); try { @@ -325,6 +352,9 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone int j, k; int index; int cpt; + int cptk = 0; + TMLCReferencePortConnectingPoint point; + TGConnectingPoint[] old = null; ArrayList<TMLCCompositePort> tmp = null; ArrayList<TMLCReferencePortConnectingPoint> points = new ArrayList<TMLCReferencePortConnectingPoint>(); @@ -344,43 +374,77 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone tmlcc = getTDiagramPanel().getMGUI().getCompositeComponent(value); //System.out.println("Updating references"); if (tmlcc != null ){ + //System.out.println("Found tmlcc"); updateReference(); rescaled = true; tmp = ports; ports = new ArrayList<TMLCCompositePort>(); + for (TMLCCompositePort port: tmp) { + ports.add(port); + } } } + if (elt.getTagName().equals("port")) { + if (old == null) { + old = connectingPoint; + connectingPoint = new TGConnectingPoint[nbConnectingPoint]; + } //System.out.println("Tag port"); try { int portid = Integer.decode(elt.getAttribute("id")).intValue(); + for (TMLCCompositePort port: tmp) { if (port.getId() == portid) { - ports.add(port); + //ports.add(port); + //System.out.println("Load: Adding port of id= " + portid); index = tmp.indexOf(port); + + //System.out.println("Updating port of id=" + portid ); for (k=index*5; k<(index+1)*5; k++) { - points.add((TMLCReferencePortConnectingPoint)(connectingPoint[k])); + //points.add((TMLCReferencePortConnectingPoint)(connectingPoint[k])); + // Must update position of connecting point + connectingPoint[k] = old[cptk]; + ((TMLCReferencePortConnectingPoint)(connectingPoint[k])).setPort(port); + if (connectingPoint[k] == null) { + System.out.println("null cp"); + } + //System.out.println("k =" + + k + " is set to the id of cptk=" + cptk); + cptk ++; + + //((TMLCReferencePortConnectingPoint)connectingPoint[k]).setPort(port); + //point = new TMLCReferencePortConnectingPoint(port, this, 0.5, 0.5); + //points.add(point); + //System.out.println("FormerId:" + connectingPoint[k].getId()); + //point.forceId(connectingPoint[k].getId()); + //System.out.println("Adding point of id: " + point.getId()); } // Connexion //System.out.println("Adding port of id:" + portid); break; } } - } catch (Exception e) {System.out.println("Exception: " + e.getMessage());} + } catch (Exception e) {//System.out.println("Exception TMLCRemote: " + e.getMessage()); + } } } } } } - nbConnectingPoint = points.size(); + + /*nbConnectingPoint = points.size(); + System.out.println("Size: " + points.size()); + TGConnectingPoint[] old = connectingPoint; connectingPoint = new TGConnectingPoint[nbConnectingPoint]; cpt = 0; for(TMLCPortConnectingPoint pt: points) { connectingPoint[cpt] = pt; cpt ++; - } + connectingPoint[cpt].forceId(old[cpt].getId()); + System.out.println("Setting id: " + old[cpt].getId()); + }*/ } catch (Exception e) { throw new MalformedModelingException(); @@ -402,7 +466,7 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone setFather(null); TDiagramPanel tdp = getTDiagramPanel(); setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); - + } @@ -489,7 +553,8 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone // 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(){ + public void updatePorts() { + //System.out.println("Update my ports"); ArrayList<TMLCCompositePort> list = tmlcc.getFirstLevelCompositePorts(); int cpt=0; @@ -508,7 +573,7 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone // Close attention to the list boolean change = true; if (list.size() != ports.size()) { - change = true; + change = true; } else { for (TMLCCompositePort port: ports) { if (!list.contains(port)) { @@ -519,6 +584,7 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone } if (change) { + System.out.println("change on ports!"); // Delete unused ports and ArrayList<TMLCReferencePortConnectingPoint> points = new ArrayList<TMLCReferencePortConnectingPoint>(); cpt=0; @@ -530,9 +596,11 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone points.add((TMLCReferencePortConnectingPoint)(connectingPoint[cpt])); } } else { + //System.out.println("Port to remove"); ports.remove(tmp); for (j=cpt; j<cpt+5; j++) { tdp.removeOneConnector(connectingPoint[cpt]); + // Shall we remove the connecting points? } i --; } @@ -543,6 +611,7 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone for (TMLCCompositePort port1: list) { if (!ports.contains(port1)) { ports.add(port1); + //System.out.println("Adding port of id =" + port1.getId()); //Create new connecting points /*x1 = port1.getX() + port1.getWidth()/2; y1 = port1.getY() + port1.getHeight()/2; @@ -554,28 +623,79 @@ public class TMLCRemoteCompositeComponent extends TGCScalableWithInternalCompone //point = new TMLCReferencePortConnectingPoint(port1, this, 0, 0, true, true, ((double)x1 - x2) / w, ((double)y1 - y2) / h); point = new TMLCReferencePortConnectingPoint(port1, this, 0.5, 0.5); points.add(point); + //System.out.println("Adding point on update Ports of id: " + point.getId()); } } } - nbConnectingPoint = points.size(); - connectingPoint = new TGConnectingPoint[nbConnectingPoint]; - cpt = 0; - for(TMLCPortConnectingPoint pt: points) { - connectingPoint[cpt] = pt; - cpt ++; + if (nbConnectingPoint == points.size()) { + cpt = 0; + /*for(TMLCReferencePortConnectingPoint pt: points) { + ((TMLCReferencePortConnectingPoint)(connectingPoint[cpt])).setPort(pt.getPort()); + cpt ++; + }*/ + } else { + nbConnectingPoint = points.size(); + if (connectingPoint != null) { + //System.out.println("Nb of TGconnecting point: " + connectingPoint.length); + } else { + //System.out.println("No connectingPoint"); + } + connectingPoint = new TGConnectingPoint[nbConnectingPoint]; + cpt = 0; + + for(TMLCPortConnectingPoint pt: points) { + connectingPoint[cpt] = pt; + cpt ++; + } } } } public TGComponent getPortOf(TGConnectingPoint tp) { - for (int i=0; i<nbConnectingPoint; i++) { - if (connectingPoint[i] == tp) { - return ports.get((int)(i/5)); - } + for (int i=0; i<nbConnectingPoint; i++) { + if (connectingPoint[i] == tp) { + return ports.get((int)(i/5)); + } } return null; } + + public boolean setIdTGConnectingPoint(int num, int id) { + int i; + //System.out.println("name= " + name + " nbCP=" + nbConnectingPoint + " num=" + num + "id=" + id); + try { + + if (connectingPoint == null) { + nbConnectingPoint = num + 1; + connectingPoint = new TGConnectingPoint[nbConnectingPoint]; + for(i=0; i<nbConnectingPoint; i++) { + connectingPoint[i] = new TMLCReferencePortConnectingPoint(null, this, 0.5, 0.5); + } + } else { + if (num >= nbConnectingPoint) { + nbConnectingPoint = num + 1; + TGConnectingPoint[] old = connectingPoint; + connectingPoint = new TGConnectingPoint[nbConnectingPoint]; + //System.out.println("old1"); + for(i=0; i<old.length; i++) { + connectingPoint[i] = old[i]; + } + //System.out.println("old2"); + for(i=old.length; i<nbConnectingPoint; i++) { + connectingPoint[i] = new TMLCReferencePortConnectingPoint(null, this, 0.5, 0.5); + } + //System.out.println("old3"); + } + } + + connectingPoint[num].forceId(id); + return true; + } catch (Exception e) { + System.out.println("Exception remote 1:" + e.getMessage()); + return false; + } + } } diff --git a/src/ui/tmlcompd/TMLComponentTaskDiagramPanel.java b/src/ui/tmlcompd/TMLComponentTaskDiagramPanel.java index 3f5c7f6ead..c17e76848f 100755 --- a/src/ui/tmlcompd/TMLComponentTaskDiagramPanel.java +++ b/src/ui/tmlcompd/TMLComponentTaskDiagramPanel.java @@ -113,6 +113,7 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi //resetAllInstancesOf(tgcc); return true; } + if (tgc instanceof TMLCPortConnector) { updatePorts(); } @@ -120,9 +121,12 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi updatePorts(); } if (tgc instanceof TMLCCompositePort) { + //System.out.println("tgc.getFather() = " + tgc.getFather()); updatePorts(); - if (tgc.getFather() instanceof TMLCCompositeComponent) { - getMGUI().updateReferenceToTMLCCompositeComponent((TMLCCompositeComponent)(tgc.getFather())); + //System.out.println("fatherOfRemoved = " + fatherOfRemoved); + if (fatherOfRemoved instanceof TMLCCompositeComponent) { + getMGUI().updateReferenceToTMLCCompositeComponent((TMLCCompositeComponent)(fatherOfRemoved)); + //System.out.println("Shall do the update"); } } @@ -413,6 +417,7 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi } public void updateReferenceToTMLCCompositeComponent(TMLCCompositeComponent tmlcc) { + //System.out.println("Update from " + tmlcc.getValue()); Iterator iterator = componentList.listIterator(); TGComponent tgc; @@ -651,6 +656,28 @@ public class TMLComponentTaskDiagramPanel extends TDiagramPanel implements TDPWi } } + public void delayedLoad() { + Iterator iterator; + TGComponent tgc; + + iterator = componentList.listIterator(); + + while(iterator.hasNext()) { + tgc = (TGComponent)(iterator.next()); + + if (tgc instanceof TMLCCompositeComponent) { + ((TMLCCompositeComponent)(tgc)).delayedLoad(); + } + + if (tgc instanceof TMLCRemoteCompositeComponent) { + try { + ((TMLCRemoteCompositeComponent)(tgc)).delayedLoad(); + } catch (Exception e) { + } + } + } + } + public void updatePorts() { //System.out.println("Update ports / nb of components = " + componentList.size()); Iterator iterator; diff --git a/src/ui/window/JDialogSystemCGeneration.java b/src/ui/window/JDialogSystemCGeneration.java index 8017f0fb38..7d3b8fae06 100755 --- a/src/ui/window/JDialogSystemCGeneration.java +++ b/src/ui/window/JDialogSystemCGeneration.java @@ -51,7 +51,7 @@ import java.awt.event.*; import javax.swing.*; import myutil.*; -//import tmltranslator.tosystemc.*; +import ui.interactivesimulation.*; import tmltranslator.tomappingsystemc.*; import tmltranslator.tomappingsystemc2.*; import ui.*; -- GitLab