diff --git a/src/Main.java b/src/Main.java index e3bf0c2189f33ff4a17f8c53d0227119cf36cc9f..aef252120f7fa4398d6d81ccbc6bf837b72718f0 100755 --- a/src/Main.java +++ b/src/Main.java @@ -81,7 +81,7 @@ public class Main implements ActionListener { //System.out.println("hellu"); img = (new ImageIcon(imageURL)).getImage(); splashFrame = JStartingWindow.splash(img, "Starting ttool"); - splashFrame.setLicenceMessage("An open-source toolkit from:"); + //splashFrame.setLicenceMessage("An open-source toolkit from:"); splashFrame.setMiddleMessage("version " + DefaultText.getVersion()); //System.out.println("helly"); } else { diff --git a/src/myutil/HTMLCodeGeneratorForTables.java b/src/myutil/HTMLCodeGeneratorForTables.java new file mode 100755 index 0000000000000000000000000000000000000000..cea0f095abc7a8395fdfb11d4ad62df2fcf2659b --- /dev/null +++ b/src/myutil/HTMLCodeGeneratorForTables.java @@ -0,0 +1,134 @@ +/**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 HTMLCodeGeneratorForTables + * HTML code generator for AbstractTableModel + * Creation: 20/02/2009 + * @version 1.0 20/02/2009 + * @author Ludovic APVRILLE + * @see + */ + +package myutil; + +import java.util.*; +//import java.awt.*; +import javax.swing.table.*; +import java.text.*; + +import ui.*; + +public class HTMLCodeGeneratorForTables { + + public HTMLCodeGeneratorForTables() { + } + + public StringBuffer getHTMLCode(ArrayList<AbstractTableModel> atms, ArrayList<String> titles, String mainTitle) { + StringBuffer sb = new StringBuffer(); + int max = Math.min(atms.size(), titles.size()); + + + sb.append("<html>\n"); + sb.append(getHTMLHeader(mainTitle)); + + sb.append("<body>\n"); + sb.append("<center><h1>" + mainTitle + "</h1></center>\n"); + + for (int i=0; i<max; i++) { + sb.append(getHTMLCode(atms.get(i), titles.get(i))); + } + + sb.append("</body>\n</html>"); + + return sb; + } + + + + public StringBuffer getHTMLCode(AbstractTableModel atm, String title) { + int i, j; + String s; + + StringBuffer sb = new StringBuffer("\n<BR><BR>\n<TABLE BORDER>\n"); + sb.append("<CAPTION><B>" + title + "</B></CAPTION>\n"); + + // Top part of table + sb.append("<TR>"); + for(j=0; j<atm.getColumnCount(); j++) { + sb.append("<TH BGCOLOR=\"#C0C0C0\"> " + atm.getColumnName(j) + " </TH> "); + } + sb.append("</TR>\n"); + + // Table itself + for(i=0; i<atm.getRowCount(); i++) { + sb.append("<TR>"); + for(j=0; j<atm.getColumnCount(); j++) { + s = atm.getValueAt(i, j).toString(); + if (s.length() == 0) { + s = "-"; + } + sb.append("<TD> " + s + " </TD> "); + } + sb.append("</TR>\n"); + } + + // End of table + sb.append("</TABLE>\n\n"); + + return sb; + + } + + public String getHTMLHeader(String mainTitle) { + GregorianCalendar calendar = (GregorianCalendar)GregorianCalendar.getInstance(); + Date date = calendar.getTime(); + SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm"); + String formattedDate = formatter.format(date); + + String tmpdoc=""; + tmpdoc += "<!----- Automatically generated by TTool version "; + tmpdoc += DefaultText.getVersion(); + tmpdoc += " generation date: " + formattedDate; + tmpdoc += "---->\n"; + tmpdoc += "\n<head>\n<title>"; + tmpdoc += mainTitle; + tmpdoc += "</title>\n</head>\n"; + return tmpdoc; + } + +} \ No newline at end of file diff --git a/src/translator/TURTLEModelChecker.java b/src/translator/TURTLEModelChecker.java index fc2b5826a59f67042069aa98c4f0988f43835047..7cf37e81e087768dcd793b2a14b96b136bc056a7 100755 --- a/src/translator/TURTLEModelChecker.java +++ b/src/translator/TURTLEModelChecker.java @@ -400,7 +400,7 @@ public class TURTLEModelChecker { if ((action!= null) && (action.length() > 0)) { parsing(t, ad1, "actiongate", action, errors); } else { - System.out.println("null action on gate=" + ((ADActionStateWithGate)ad1).getGate().getName() + action); + //System.out.println("null action on gate=" + ((ADActionStateWithGate)ad1).getGate().getName() + action); } } else if (ad1 instanceof ADActionStateWithParam) { diff --git a/src/translator/TURTLEModeling.java b/src/translator/TURTLEModeling.java index 5d4c40d8b168647a361bc2bc48a1d5cc2f72643e..4ed3cb9739529d2daef8648881c4513a00433820 100755 --- a/src/translator/TURTLEModeling.java +++ b/src/translator/TURTLEModeling.java @@ -1250,6 +1250,9 @@ public class TURTLEModeling { if (adc instanceof ADActionStateWithGate) { adag = (ADActionStateWithGate)adc; s = adag.getActionValue(); + if (s == null) { + return 0; + } s = Conversion.replaceAllChar(s, ' ', ""); s = removeReducedActionOps(s); index = s.indexOf("?" + namebis); diff --git a/src/ui/AnalysisPanelTranslator.java b/src/ui/AnalysisPanelTranslator.java index 1e5fba27a93500410a3328ac6adcb37f9fff4ff2..6a0fbb975ae98190eacfbb08e5c78f7e39662f83 100755 --- a/src/ui/AnalysisPanelTranslator.java +++ b/src/ui/AnalysisPanelTranslator.java @@ -487,6 +487,9 @@ public class AnalysisPanelTranslator { } if (tgc instanceof TGConnectorMessageAsyncSD) { + if (!((TGConnectorMessageAsyncSD)(tgc)).isMessageWellFormed()) { + throw new AnalysisSyntaxException("Badly formatted synchronous exchange:" + ((TGConnectorMessageSyncSD)(tgc)).getMessage() +" in instance "+ sdi1.getInstanceName() + " in sequence diagram " + sdp.getName()); + } evt1 = new Evt(Evt.SEND_MSG, ((TGConnectorMessageAsyncSD)(tgc)).getFirstPartMessage() + "__" + ins1.getName() + "_to_" + ins2.getName() + ((TGConnectorMessageAsyncSD)(tgc)).getSecondPartMessage(), ins1); correspondance.addCor(evt1, tgc); diff --git a/src/ui/DesignPanelTranslator.java b/src/ui/DesignPanelTranslator.java index 166817e8639ffdfe103c376e0a2e94cfffb4184c..5d9068ee5f7eb16bcf58f7c5845be09a4de1ad37 100755 --- a/src/ui/DesignPanelTranslator.java +++ b/src/ui/DesignPanelTranslator.java @@ -1,46 +1,46 @@ /**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 DesignPanelTranslator - * Creation: 17/08/2006 - * @author Ludovic APVRILLE - * @see - */ +* +* 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 DesignPanelTranslator +* Creation: 17/08/2006 +* @author Ludovic APVRILLE +* @see +*/ package ui; @@ -53,6 +53,7 @@ import ui.ad.*; import ui.cd.*; import translator.*; +import ui.window.*; import ui.osad.*; @@ -60,34 +61,36 @@ import ui.osad.*; public class DesignPanelTranslator { protected TURTLEDesignPanelInterface dp; protected Vector checkingErrors; - protected CorrespondanceTGElement listE; - + protected CorrespondanceTGElement listE; // usual list + protected CorrespondanceTGElement listB; // list for particular element -> first element of group of blocks + public DesignPanelTranslator(TURTLEDesignPanelInterface _dp) { dp = _dp; reinit(); } - + public void reinit() { checkingErrors = new Vector(); listE = new CorrespondanceTGElement(); + listB = new CorrespondanceTGElement(); } - + public Vector getErrors() { return checkingErrors; } - + public Vector getWarnings() { return null; } - + public CorrespondanceTGElement getCorrespondanceTGElement() { return listE; } - + public TURTLEModeling generateTURTLEModeling() { Vector tclasses = new Vector(); TGComponent tgc; - + ListIterator iterator = dp.getStructurePanel().getComponentList().listIterator(); while(iterator.hasNext()) { tgc = (TGComponent)(iterator.next()); @@ -95,25 +98,25 @@ public class DesignPanelTranslator { tclasses.add(tgc); } } - + return generateTURTLEModeling(tclasses, ""); } - + public TURTLEModeling generateTURTLEModeling(Vector tclasses, String preName) { TURTLEModeling tmodel = new TURTLEModeling(); addTClasses(dp, tclasses, preName, tmodel); addRelations(dp, tmodel); return tmodel; } - + private void addCheckingError(CheckingError ce) { if (checkingErrors == null) { checkingErrors = new Vector(); } checkingErrors.addElement(ce); } - - + + public void addTClasses(TURTLEDesignPanelInterface dp, Vector tclasses, String preName, TURTLEModeling tm) { TDiagramPanel tdp; // search for class diagram panels @@ -122,34 +125,35 @@ public class DesignPanelTranslator { addTClassesFromPanel((TClassDiagramPanel)tdp, tclasses, preName, tm); }*/ if (tdp instanceof ClassDiagramPanelInterface) { - addTClassesFromPanel((ClassDiagramPanelInterface)tdp, tclasses, preName, tm); + addTClassesFromPanel(tdp, (ClassDiagramPanelInterface)tdp, tclasses, preName, tm); } } - - private void addTClassesFromPanel(ClassDiagramPanelInterface tdp, Vector tclasses, String preName, TURTLEModeling tm) { + + private void addTClassesFromPanel(TDiagramPanel diag, ClassDiagramPanelInterface tdp, Vector tclasses, String preName, TURTLEModeling tm) { 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, tm); + addTClassFromTClassInterface((TClassInterface)tgc, diag, tdp, preName, tm); } } } - - private void addTClassFromTClassInterface(TClassInterface tgc, ClassDiagramPanelInterface tdp, String preName, TURTLEModeling tm) { + + private void addTClassFromTClassInterface(TClassInterface tgc, TDiagramPanel diag, ClassDiagramPanelInterface tdp, String preName, TURTLEModeling tm) { //System.out.println("Adding TClass: " + tgc.getClassName()); TClass t = new TClass(preName + tgc.getClassName(), tgc.isStart()); - + Vector v; - int i; + int i, j; TAttribute a; Param p; Gate g; boolean internal; int type; - + int value; + // Attributes v = tgc.getAttributes(); for(i=0; i<v.size(); i++) { @@ -171,12 +175,33 @@ public class DesignPanelTranslator { t.addParameter(p); //System.out.println("Adding queuenat parameter"); } - + + if (a.getType() == TAttribute.ARRAY_NAT) { + try { + value = Integer.decode(a.getInitialValue()).intValue(); + } catch (Exception e) { + CheckingError ce = new CheckingError(CheckingError.STRUCTURE_ERROR, "Error on the size of array " + a.getId()); + ce.setTClass(t); + ce.setTDiagramPanel(diag); + addCheckingError(ce); + return; + } + for(j=0; j<value; j++) { + p = new Param(a.getId() + "__" + j, Param.NAT, "0"); + p.setAccess(a.getAccessString()); + t.addParameter(p); + } + p = new Param(a.getId() + "__size", Param.NAT, a.getInitialValue()); + p.setAccess(a.getAccessString()); + t.addParameter(p); + //System.out.println("Adding queuenat parameter"); + } + if (a.getType() == TAttribute.OTHER) { addTDataAttributes(a, t, tdp, tm); } } - + // Gates v = tgc.getGates(); for(i=0; i<v.size(); i++) { @@ -189,8 +214,8 @@ public class DesignPanelTranslator { case TAttribute.OUTGATE: type = Gate.OUTGATE; break; - case - TAttribute.INGATE: + case + TAttribute.INGATE: type = Gate.INGATE; break; default: @@ -202,16 +227,16 @@ public class DesignPanelTranslator { t.addGate(g); } } - - + + tm.addTClass(t); listE.addCor(t, (TGComponent)tgc, preName); - + // Activity Diagram buildActivityDiagram(t); - + } - + private void addTDataAttributes(TAttribute a, TClass t, ClassDiagramPanelInterface tdp, TURTLEModeling tm) { //System.out.println("Find data: " + a.getId() + " getTypeOther=" + a.getTypeOther()); if (tdp instanceof TClassDiagramPanel) { @@ -223,7 +248,7 @@ public class DesignPanelTranslator { addCheckingError(ce); return ; } - + Vector v = tdata.getAttributes(); TAttribute b; Param p; for(int i=0; i<v.size(); i++) { @@ -246,33 +271,33 @@ public class DesignPanelTranslator { } } } - + } - + private void buildActivityDiagram(TClass t) { int j; //TActivityDiagramPanel tadp; ActivityDiagramPanelInterface adpi; TDiagramPanel tdp; //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()); } - + adpi = tci.getBehaviourDiagramPanel(); if (adpi == null) { return; } - + tdp = (TDiagramPanel)adpi; - + // search for start state LinkedList list = adpi.getComponentList(); Iterator iterator = list.listIterator(); @@ -289,7 +314,7 @@ public class DesignPanelTranslator { cptStart ++; } } - + if (tss == null) { CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "No start state in the activity diagram of " + name); ce.setTClass(t); @@ -297,7 +322,7 @@ public class DesignPanelTranslator { 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); @@ -305,7 +330,7 @@ public class DesignPanelTranslator { addCheckingError(ce); return; } - + ADStart ads; //ADActionState ada; ADActionStateWithGate adag; @@ -324,17 +349,17 @@ public class DesignPanelTranslator { 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()) { @@ -353,17 +378,17 @@ public class DesignPanelTranslator { } 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)); + //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); + //System.out.println("s1=" + s1); /*if (s1 == null) { System.out.println("oh ho !"); }*/ @@ -380,7 +405,7 @@ public class DesignPanelTranslator { return; } s1 = TURTLEModeling.addTypeToDataReceiving(t, s1); - System.out.println("Adding type done s1=" + s1); + //System.out.println("Adding type done s1=" + s1); adag.setActionValue(s1); listE.addCor(adag, tgc); } else if ((p != null) && (nbActions == 1)){ @@ -396,7 +421,7 @@ public class DesignPanelTranslator { 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 @@ -410,7 +435,7 @@ public class DesignPanelTranslator { ce.setTDiagramPanel(tdp); addCheckingError(ce); } - + p = t.getParamFromActionState(sTmp); if (p == null) { ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Action state (1) (" + s + "): \"" + sTmp + "\" is not a correct expression"); @@ -420,7 +445,7 @@ public class DesignPanelTranslator { addCheckingError(ce); } } - + adamp = new ADActionStateWithMultipleParam(); ad.addElement(adamp); adamp.setActionValue(TURTLEModeling.manageDataStructures(t, s)); @@ -433,7 +458,179 @@ public class DesignPanelTranslator { addCheckingError(ce); //System.out.println("Bad action state found " + s); } - + + } else if (tgc instanceof TADArrayGetState) { + TADArrayGetState ags = (TADArrayGetState)tgc; + sTmp = ags.getIndex(); + try { + nbActions = Integer.decode(sTmp).intValue(); + + p = t.getParamByName(ags.getVariable()); + if (p == null) { + CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Array setting: " + ags.getVariable() + ": unknown variable"); + ce.setTClass(t); + ce.setTGComponent(tgc); + ce.setTDiagramPanel(tdp); + addCheckingError(ce); + } else { + adap = new ADActionStateWithParam(p); + p = t.getParamByName(ags.getArray() + "__" + nbActions); + if (p == null) { + CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Array setting: " + ags.getArray() + "[" + ags.getIndex() + "]: unknown array or wrong index"); + ce.setTClass(t); + ce.setTGComponent(tgc); + ce.setTDiagramPanel(tdp); + addCheckingError(ce); + } else { + ad.addElement(adap); + adap.setActionValue(TURTLEModeling.manageDataStructures(t, ags.getArray() + "__" + nbActions)); + listE.addCor(adap, tgc); + listB.addCor(adap, tgc); + } + } + } catch (Exception e) { + // Index is not an absolute value + System.out.println("Index is not an absolute value"); + Gate error = t.addNewGateIfApplicable("arrayOverflow"); + + ADChoice choice1 = new ADChoice(); + ADJunction junc = new ADJunction(); + ADStop stop1 = new ADStop(); + ADActionStateWithGate adag1 = new ADActionStateWithGate(error); + + ad.addElement(choice1); + ad.addElement(junc); + ad.addElement(stop1); + ad.addElement(adag1); + + String basicGuard = "(" + ags.getIndex() + ")"; + + p = t.getParamByName(ags.getArray() + "__size"); + + if (p == null) { + CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Array setting: " + ags.getArray() + "[" + ags.getIndex() + "]: unknown array or wrong index"); + ce.setTClass(t); + ce.setTGComponent(tgc); + ce.setTDiagramPanel(tdp); + addCheckingError(ce); + } else { + int size = 2; + try { + size = Integer.decode(p.getValue()).intValue(); + } catch (Exception e0) { + } + + p = t.getParamByName(ags.getVariable()); + + if (p == null) { + CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Array setting: " + ags.getVariable() + ": unknown variable"); + ce.setTClass(t); + ce.setTGComponent(tgc); + ce.setTDiagramPanel(tdp); + addCheckingError(ce); + } else { + for(int i=0; i<size; i++) { + //System.out.println("Adding guard: [" + basicGuard + "== " + i + "]"); + choice1.addGuard("[" + basicGuard + " == " + i + "]"); + adap = new ADActionStateWithParam(p); + ad.addElement(adap); + adap.setActionValue(TURTLEModeling.manageDataStructures(t, ags.getArray() + "__" + i)); + choice1.addNext(adap); + adap.addNext(junc); + } + + choice1.addGuard("[" + basicGuard + "> (" + ags.getArray() + "__size - 1)]"); + choice1.addNext(adag1); + adag1.addNext(stop1); + + listE.addCor(junc, tgc); + listB.addCor(choice1, tgc); + + } + } + } + + } else if (tgc instanceof TADArraySetState) { + TADArraySetState ass = (TADArraySetState)tgc; + sTmp = ass.getIndex(); + try { + nbActions = Integer.decode(sTmp).intValue(); + p = t.getParamByName(ass.getArray() + "__" + nbActions); + if (p == null) { + CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Array setting: " + ass.getArray() + "[" + ass.getIndex() + "]: unknown array or wrong index"); + ce.setTClass(t); + ce.setTGComponent(tgc); + ce.setTDiagramPanel(tdp); + addCheckingError(ce); + } else { + adap = new ADActionStateWithParam(p); + ad.addElement(adap); + adap.setActionValue(TURTLEModeling.manageDataStructures(t, ass.getExpr())); + listE.addCor(adap, tgc); + listB.addCor(adap, tgc); + } + + } catch (Exception e) { + // Index is not an absolute value + System.out.println("Set: Index is not an absolute value"); + Gate error = t.addNewGateIfApplicable("arrayOverflow"); + + ADChoice choice1 = new ADChoice(); + ADJunction junc = new ADJunction(); + ADStop stop1 = new ADStop(); + ADActionStateWithGate adag1 = new ADActionStateWithGate(error); + + ad.addElement(choice1); + ad.addElement(junc); + ad.addElement(stop1); + ad.addElement(adag1); + + String basicGuard = "(" + ass.getIndex() + ")"; + + p = t.getParamByName(ass.getArray() + "__size"); + + if (p == null) { + CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Array setting: " + ass.getArray() + "[" + ass.getIndex() + "]: unknown array or wrong index"); + ce.setTClass(t); + ce.setTGComponent(tgc); + ce.setTDiagramPanel(tdp); + addCheckingError(ce); + } else { + int size = 2; + try { + size = Integer.decode(p.getValue()).intValue(); + } catch (Exception e0) { + } + + for(int i=0; i<size; i++) { + //System.out.println("Adding guard: [" + basicGuard + "== " + i + "]"); + p = t.getParamByName(ass.getArray() + "__" + i); + if (p == null) { + CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, "Array setting: " + ass.getArray() + "[" + ass.getIndex() + "]: unknown array or wrong index"); + ce.setTClass(t); + ce.setTGComponent(tgc); + ce.setTDiagramPanel(tdp); + addCheckingError(ce); + } else { + choice1.addGuard("[" + basicGuard + " == " + i + "]"); + adap = new ADActionStateWithParam(p); + ad.addElement(adap); + adap.setActionValue(TURTLEModeling.manageDataStructures(t, ass.getExpr())); + choice1.addNext(adap); + adap.addNext(junc); + } + + choice1.addGuard("[" + basicGuard + "> (" + ass.getArray() + "__size - 1)]"); + choice1.addNext(adag1); + adag1.addNext(stop1); + + listE.addCor(junc, tgc); + listB.addCor(choice1, tgc); + + } + } + } + } else if (tgc instanceof TADChoice) { adch = new ADChoice(); ad.addElement(adch); @@ -520,7 +717,7 @@ public class DesignPanelTranslator { addCheckingError(ce); //System.out.println("Bad time limited offer found " + s); } - + // TURTLE-OS AD } else if (tgc instanceof TOSADTimeInterval) { adti = new ADTimeInterval(); @@ -552,7 +749,7 @@ public class DesignPanelTranslator { s = s.substring(0, s.length()-1); } nbActions = Conversion.nbChar(s, ';') + 1; - + if (nbActions>1) { CheckingError ce = new CheckingError(CheckingError.BEHAVIOR_ERROR, s + " should not start with a '=='"); ce.setTClass(t); @@ -563,7 +760,7 @@ public class DesignPanelTranslator { //s = TURTLEModeling.manageDataStructures(t, s); g = t.getGateFromActionState(s); p = t.getParamFromActionState(s); - + if (p != null) { adap = new ADActionStateWithParam(p); ad.addElement(adap); @@ -579,12 +776,12 @@ public class DesignPanelTranslator { //System.out.println("Nb Actions in state: " + nbActions); } } - + TGConnectingPoint p1, p2; //TGConnectorFullArrow tgco; TGComponent tgc1, tgc2, tgc3; ADComponent ad1, ad2; - + // Managing Java code iterator = list.listIterator(); while(iterator.hasNext()) { @@ -602,7 +799,7 @@ public class DesignPanelTranslator { } } } - + // Connecting elements TGConnectorBetweenElementsInterface tgcbei; iterator = list.listIterator(); @@ -612,7 +809,7 @@ public class DesignPanelTranslator { tgcbei = (TGConnectorBetweenElementsInterface)tgc; p1 = tgcbei.getTGConnectingPointP1(); p2 = tgcbei.getTGConnectingPointP2(); - + // identification of connected components tgc1 = null; tgc2 = null; for(j=0; j<list.size(); j++) { @@ -624,12 +821,26 @@ public class DesignPanelTranslator { tgc2 = tgc3; } } - + // connecting turtle modeling components if ((tgc1 != null) && (tgc2 != null)) { //ADComponent ad1, ad2; - ad1 = listE.getADComponentByIndex(tgc1, tdp.count); - ad2 = listE.getADComponentByIndex(tgc2, tdp.count); + + //System.out.println("tgc1 = " + tgc1.getValue() + " tgc2= "+ tgc2.getValue()); + + /*if ((tgc1 instanceof TADArrayGetState) || (tgc1 instanceof TADArraySetState)) { + ad1 = listE.getADComponent(tgc1); + } else {*/ + ad1 = listE.getADComponentByIndex(tgc1, tdp.count); + //} + if ((tgc2 instanceof TADArrayGetState) || (tgc2 instanceof TADArraySetState)) { + ad2 = listB.getADComponent(tgc2); + } else { + ad2 = listE.getADComponentByIndex(tgc2, tdp.count); + } + + //System.out.println("ad1 = " + ad1 + " ad2= "+ ad2); + if ((ad1 == null) || (ad2 == null)) { //System.out.println("Correspondance issue"); } @@ -662,21 +873,21 @@ public class DesignPanelTranslator { // Increasing count of this panel tdp.count ++; } - + public void addRelations(TURTLEDesignPanelInterface dp, String prename, TURTLEModeling tm) { addRelationFromPanel(dp.getStructurePanel(), prename, tm); } - + public void addRelations(TURTLEDesignPanelInterface dp, TURTLEModeling tm) { addRelationFromPanel(dp.getStructurePanel(), "", tm); } - + private void addRelationFromPanel(ClassDiagramPanelInterface tdp, String prename, TURTLEModeling tm) { LinkedList list = tdp.getComponentList(); Iterator iterator = list.listIterator(); // search for Composition Operator TGComponent tgc; - + while(iterator.hasNext()) { tgc = (TGComponent)(iterator.next()); if (tgc instanceof CompositionOperatorInterface) { @@ -684,55 +895,55 @@ public class DesignPanelTranslator { } } } - + private void addRelationFromCompositionOperator(CompositionOperatorInterface tco, ClassDiagramPanelInterface tdp, String prename, TURTLEModeling tm) { TClassInterface t1 = tdp.getTClass1ToWhichIamConnected(tco); TClassInterface t2 = tdp.getTClass2ToWhichIamConnected(tco); - + TGConnector 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(CompositionOperatorInterface tco) { if (tco instanceof TCDParallelOperator) { return Relation.PAR; @@ -749,36 +960,36 @@ public class DesignPanelTranslator { } 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; - + 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); } } } - + } diff --git a/src/ui/DocumentationGenerator.java b/src/ui/DocumentationGenerator.java index f07f6078c6fa8ad75c93e5a76ee59a3c83c78280..0167953e4ba0475f91c7b25ab9d0991fd541b00d 100644 --- a/src/ui/DocumentationGenerator.java +++ b/src/ui/DocumentationGenerator.java @@ -67,7 +67,7 @@ public class DocumentationGenerator implements SteppedAlgorithm, StoppableGUIEle private Vector panels; // TURTLEPanels private JTabbedPane mainTabbedPane; private int firstHeadingNumber = 1; - private String title = "TTool project:"; + private static String title = "TTool project:"; private String fileName = "doc.html"; private String path; private String projectName; @@ -107,7 +107,7 @@ public class DocumentationGenerator implements SteppedAlgorithm, StoppableGUIEle title = _title; } - public String getTitle() { + public static String getTitle() { return title; } @@ -148,7 +148,7 @@ public class DocumentationGenerator implements SteppedAlgorithm, StoppableGUIEle doc = ""; doc += "<html>\n"; - doc += getDocumentationHeader(); + doc += getDocumentationHeader(projectName); doc += "<body>\n"; doc +="<center><h1>" + title + "</h1></center>\n"; @@ -241,7 +241,7 @@ public class DocumentationGenerator implements SteppedAlgorithm, StoppableGUIEle return (int)((cpt*100) / total); } - public String getDocumentationHeader() { + public String getDocumentationHeader(String _projectName) { GregorianCalendar calendar = (GregorianCalendar)GregorianCalendar.getInstance(); Date date = calendar.getTime(); SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm"); @@ -253,7 +253,7 @@ public class DocumentationGenerator implements SteppedAlgorithm, StoppableGUIEle tmpdoc += " generation date: " + formattedDate; tmpdoc += "---->\n"; tmpdoc += "\n<head>\n<title>"; - tmpdoc += getTitle() + ": " +projectName; + tmpdoc += getTitle() + ": " +_projectName; tmpdoc += "</title>\n</head>\n"; return tmpdoc; } diff --git a/src/ui/IconManager.java b/src/ui/IconManager.java index 5a6c020acafa39207134c47be6f869d090787b09..187a315641be74fabb1692ec5f34a5987d7e3790 100755 --- a/src/ui/IconManager.java +++ b/src/ui/IconManager.java @@ -83,6 +83,7 @@ public class IconManager { public static ImageIcon imgic200, imgic201, imgic202, imgic204, imgic206, imgic208; public static ImageIcon imgic210, imgic212, imgic214, imgic216, imgic218; public static ImageIcon imgic220, imgic222, imgic224, imgic226, imgic228; + public static ImageIcon imgic230, imgic232; //Common to all diagrams public static ImageIcon imgic302, imgic304, imgic306, imgic308; @@ -267,6 +268,8 @@ public class IconManager { private static String icon224 = "images/adtimeinterval.gif"; private static String icon226 = "images/adsequence.gif"; private static String icon228 = "images/adpreemption.gif"; + private static String icon230 = "images/arrayget.gif"; + private static String icon232 = "images/arrayset.gif"; private static String icon302 = "images/text1.gif"; //private static String icon303 = "images/text1.gif"; @@ -545,6 +548,8 @@ public class IconManager { imgic224 = getIcon(icon224); imgic226 = getIcon(icon226); imgic228 = getIcon(icon228); + imgic230 = getIcon(icon230); + imgic232 = getIcon(icon232); imgic302 = getIcon(icon302); imgic304 = getIcon(icon304); diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index 2a6abc8e9864a6ea451cf05c68f3032e5ae2f790..4e3d709e408ff97e4786c2755397cf1968de54fe 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -5141,6 +5141,10 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { actionOnButton(TGComponentManager.CONNECTOR, TGComponentManager.CONNECTOR_AD_DIAGRAM); } else if (command.equals(actions[TGUIAction.AD_ACTION_STATE].getActionCommand())) { actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TAD_ACTION_STATE); + } else if (command.equals(actions[TGUIAction.AD_ARRAY_GET].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TAD_ARRAY_GET); + } else if (command.equals(actions[TGUIAction.AD_ARRAY_SET].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TAD_ARRAY_SET); } else if (command.equals(actions[TGUIAction.AD_PARALLEL].getActionCommand())) { actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TAD_PARALLEL); } else if (command.equals(actions[TGUIAction.AD_SEQUENCE].getActionCommand())) { diff --git a/src/ui/TAttribute.java b/src/ui/TAttribute.java index 3d79f205f2807e742d8ceb2ac3be7162d6d9fa66..31727f2fc34e895a7d7df8e4af2278bf43f365e0 100755 --- a/src/ui/TAttribute.java +++ b/src/ui/TAttribute.java @@ -67,6 +67,7 @@ public class TAttribute { public final static int BOOLEAN = 4; public final static int OTHER = 5; public final static int QUEUE_NAT = 6; + public final static int ARRAY_NAT = 7; private int access; @@ -167,6 +168,9 @@ public class TAttribute { } public static boolean isAValidInitialValue(int type, String value) { + boolean b; + int val; + switch(type) { case NATURAL: return value.matches("\\d*"); @@ -181,6 +185,20 @@ public class TAttribute { return ((value == null) ||(value.equals(""))); case QUEUE_NAT: return ((value == null) ||(value.equals("")) || (value.equals("nil"))); + case ARRAY_NAT: + if (value == null) { + return false; + } + + try { + val = Integer.decode(value).intValue(); + } catch (Exception e) { + return false; + } + if (val > 0) { + return true; + } + return false; default: return false; } @@ -227,6 +245,8 @@ public class TAttribute { return INGATE; } else if (s.equals("Queue_nat")) { return QUEUE_NAT; + } else if (s.equals("Array_nat")) { + return ARRAY_NAT; } else if (!s.equals("")) { return OTHER; } @@ -265,6 +285,8 @@ public class TAttribute { return "Other"; case QUEUE_NAT: return "Queue_nat"; + case ARRAY_NAT: + return "Array_nat"; default: return ""; } @@ -277,20 +299,29 @@ public class TAttribute { } else { myType = getStringType(type); } + if ((initialValue == null) || (initialValue.equals(""))) { return getStringAccess(access) + " " + id + " : " + myType + ";"; } else { - return getStringAccess(access) + " " + id + " = " + getInitialValue() + " : " + myType + ";"; + if (type == ARRAY_NAT) { + return getStringAccess(access) + " " + id + " [" + getInitialValue() + "] : " + myType + ";"; + } else { + return getStringAccess(access) + " " + id + " = " + getInitialValue() + " : " + myType + ";"; + } } } public String toNameAndValue() { - if ((initialValue == null) || (initialValue.equals(""))) { - return id + ";"; - } else { - return id + " = " + getInitialValue() + ";"; - - } + if (type == ARRAY_NAT) { + return id + "[" + getInitialValue() + "]"; + } else { + if ((initialValue == null) || (initialValue.equals(""))) { + return id + ";"; + } else { + return id + " = " + getInitialValue() + ";"; + + } + } } // comparison on id only diff --git a/src/ui/TGComponentManager.java b/src/ui/TGComponentManager.java index 43ae62e96101e19b1edcfc08f6a0584fe487ae70..7cef5f8d01e697a42fe4656eda1e719d07ccf6e5 100755 --- a/src/ui/TGComponentManager.java +++ b/src/ui/TGComponentManager.java @@ -86,6 +86,8 @@ public class TGComponentManager { public static final int TAD_DELAY_NON_DETERMINISTIC_DELAY = 20; public static final int TAD_CHOICE = 19; public static final int TAD_TIME_LIMITED_OFFER_WITH_LATENCY = 10; + public static final int TAD_ARRAY_GET = 25; + public static final int TAD_ARRAY_SET = 26; public static final int CONNECTOR_AD_DIAGRAM = 101; @@ -279,6 +281,12 @@ public class TGComponentManager { break; case TAD_ACTION_STATE: tgc = new TADActionState(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case TAD_ARRAY_GET: + tgc = new TADArrayGetState(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case TAD_ARRAY_SET: + tgc = new TADArraySetState(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; case TAD_TIME_LIMITED_OFFER: tgc = new TADTimeLimitedOffer(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); @@ -626,6 +634,10 @@ public class TGComponentManager { return TAD_START_STATE; } else if (tgc instanceof TADActionState) { return TAD_ACTION_STATE; + } else if (tgc instanceof TADArrayGetState) { + return TAD_ARRAY_GET; + } else if (tgc instanceof TADArraySetState) { + return TAD_ARRAY_SET; } else if (tgc instanceof TADTimeLimitedOffer) { return TAD_TIME_LIMITED_OFFER; } else if (tgc instanceof TADJunction) { diff --git a/src/ui/TGUIAction.java b/src/ui/TGUIAction.java index 20d3f76af2914b492af8d62b850b8568722e39df..7386fb907e0d80151405c0dce5e22305a309d008 100755 --- a/src/ui/TGUIAction.java +++ b/src/ui/TGUIAction.java @@ -112,6 +112,8 @@ public class TGUIAction extends AbstractAction { public static final int TCD_INVOCATION_OPERATOR = 48; public static final int TCD_ASSOCIATION_NAVIGATION = 24; public static final int AD_START = 43; + public static final int AD_ARRAY_GET = 261; + public static final int AD_ARRAY_SET = 262; public static final int IOD_EDIT = 77; public static final int IOD_CHOICE = 78; @@ -369,7 +371,7 @@ public class TGUIAction extends AbstractAction { public static final int PRUEBA_1 = 205; - public static final int NB_ACTION = 261; + public static final int NB_ACTION = 263; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -543,6 +545,9 @@ public class TGUIAction extends AbstractAction { actions[AD_DELAY_NON_DETERMINISTIC_DELAY] = new TAction("add-time-interval", "Add Time Interval", IconManager.imgic224, IconManager.imgic224, "Time interval", "Add a time interval to the currently opened activity diagram", 0); actions[AD_TIME_LIMITED_OFFER] = new TAction("add-time-limited-offer", "Add Time-Limited offer", IconManager.imgic218, IconManager.imgic218, "Time-Limited Offer", "Add a time-limited offer to the currently opened activity diagram", 0); actions[AD_TIME_LIMITED_OFFER_WITH_LATENCY] = new TAction("add-time-limited-offer-with-latency", "Add Time-Limited offer with a non-deterministic delay", IconManager.imgic220, IconManager.imgic220, "Time-Limited Offer with non-deterministic delay", "Adds a time-limited offer, beginning with a non-deterministic delay, to the currently opened activity diagram", 0); + actions[AD_ARRAY_GET] = new TAction("add-array-get", "Add array get element", IconManager.imgic230, IconManager.imgic230, "Array set element", "Add an array get element action to the currently opened activity diagram", 0); + actions[AD_ARRAY_SET] = new TAction("add-array-set", "Add array set element", IconManager.imgic232, IconManager.imgic232, "Array set element", "Add an array set element action to the currently opened activity diagram", 0); + actions[TCD_PARALLEL_OPERATOR] = new TAction("add-parallel-operator", "Add Parallel composition operator", IconManager.imgic112, IconManager.imgic112, "Parallel composition operator", "Add a Parallel composition operator to the currently opened class diagram", 0); actions[TCD_CONNECTOR_ATTRIBUTE] = new TAction("add-attribute-connector", "Connects an association to a composition operator", IconManager.imgic108, IconManager.imgic108, "Attributes an association with a composition operator", "Adds a connector between an association and a composition operator to the currently opened class diagram", 0); actions[TCD_SEQUENCE_OPERATOR] = new TAction("add-sequence-operator", "Add Sequence composition operator", IconManager.imgic114, IconManager.imgic114, "Sequence composition operator", "Add a Sequence composition operator to the currently opened class diagram", 0); diff --git a/src/ui/TMLComponentDesignPanel.java b/src/ui/TMLComponentDesignPanel.java index 7fdddf5fb0c658f98b801fc11842e55e043e1a40..19e6f59fb28d5d42d725744f850d797f899b260a 100755 --- a/src/ui/TMLComponentDesignPanel.java +++ b/src/ui/TMLComponentDesignPanel.java @@ -154,7 +154,7 @@ public class TMLComponentDesignPanel extends TURTLEPanel { } public String toString() { - return mgui.getTitleAt(this) + "(TML Component Design)"; + return mgui.getTitleAt(this) + "(DIPLODOCUS Component Application diagram)"; } public ArrayList<String> getAllNonMappedTMLPrimitiveComponentNames(String _name, TMLArchiDiagramPanel _tadp, boolean ref, String name) { diff --git a/src/ui/ad/TADArrayGetState.java b/src/ui/ad/TADArrayGetState.java new file mode 100755 index 0000000000000000000000000000000000000000..31faa1b9ba1cc26e7eb9de9848f2b6729abe062b --- /dev/null +++ b/src/ui/ad/TADArrayGetState.java @@ -0,0 +1,235 @@ +/**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 TADArrayGetState + * Getting the element of an array, in an activity diagram + * Creation: 20/03/2009 + * @version 1.0 20/03/2009 + * @author Ludovic APVRILLE + * @see + */ + +package ui.ad; + +import java.awt.*; +import java.awt.geom.*; +import javax.swing.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +public class TADArrayGetState extends TGCWithoutInternalComponent { + protected int lineLength = 5; + protected int textX = 5; + protected int textY = 15; + protected int arc = 5; + + // variableName = arrayName[index] + protected String variable = "x"; + protected String array = "tab"; + protected String index = "i"; + + public TADArrayGetState(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); + + width = 30; + height = 20; + minWidth = 30; + + nbConnectingPoint = 2; + connectingPoint = new TGConnectingPoint[2]; + connectingPoint[0] = new TGConnectingPointAD(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = new TGConnectingPointAD(this, 0, lineLength, false, true, 0.5, 1.0); + addTGConnectingPointsComment(); + + moveable = true; + editable = true; + removable = true; + + value = "x = tab[i]"; + name = "array get"; + + myImageIcon = IconManager.imgic230; + } + + + + public void internalDrawing(Graphics g) { + int w = g.getFontMetrics().stringWidth(value); + int w1 = Math.max(minWidth, w + 2 * textX); + if ((w1 != width) & (!tdp.isScaled())) { + setCd(x + width/2 - w1/2, y); + width = w1; + //updateConnectingPoints(); + } + 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); + + g.drawString(value, x + (width - w) / 2 , y + textY); + + /*if (accessibility) { + //g.drawString("acc", x + width - 10, y+height-10); + g.drawLine(x+width-2, y+2, x+width-6, y+6); + g.drawLine(x+width-6, y+2, x+width-2, y+6); + //System.out.println("accessibility"); + }*/ + } + + public boolean editOndoubleClick(JFrame frame) { + + String oldValue = value; + + JDialogArrayGet jdag = new JDialogArrayGet(frame, variable, array, index, "Getting value from an array"); + jdag.setSize(350, 300); + GraphicLib.centerOnParent(jdag); + jdag.show(); // blocked until dialog has been closed + + if (jdag.hasNewData() && jdag.hasValidData()) { + variable = jdag.getVariableName(); + array = jdag.getArrayName(); + index = jdag.getIndexName(); + } + + makeValue(); + + if (!oldValue.equals(value)) { + return true; + } + + return false; + + } + + public void makeValue() { + value = variable + " = " + array + "[" + index + "]"; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<Prop variable=\""); + sb.append(getVariable()); + sb.append("\" array=\""); + sb.append(getArray()); + sb.append("\" index=\""); + sb.append(getIndex()); + sb.append("\" />\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro *** " + getId()); + try { + + NodeList nli; + Node n1, n2; + Element elt; + + //System.out.println("Loading Synchronization gates"); + //System.out.println(nl.toString()); + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + //System.out.println(n1); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; i<nli.getLength(); i++) { + n2 = nli.item(i); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("Prop")) { + variable = elt.getAttribute("variable"); + array = elt.getAttribute("array"); + index = elt.getAttribute("index"); + } + } + } + } + } + + } catch (Exception e) { + //System.out.println("Exception ..."); + throw new MalformedModelingException(); + } + makeValue(); + } + + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x +width/2, y- lineLength, x+width/2, y + lineLength + height, _x, _y)) < distanceSelected) { + return this; + } + + + return null; + } + + public String getAction() { + return value; + } + + public String getVariable() { + return variable; + } + + public String getArray() { + return array; + } + + public String getIndex() { + return index; + } + + public int getType() { + return TGComponentManager.TAD_ARRAY_GET; + } + + public int getDefaultConnector() { + return TGComponentManager.CONNECTOR_AD_DIAGRAM; + } + + +} diff --git a/src/ui/ad/TActivityDiagramToolBar.java b/src/ui/ad/TActivityDiagramToolBar.java index f1ea281a20bade32d84a6d8ba571dbcb02bc2e27..f93f0292db27f62d5f513ef8a86830dcd69f083b 100755 --- a/src/ui/ad/TActivityDiagramToolBar.java +++ b/src/ui/ad/TActivityDiagramToolBar.java @@ -77,6 +77,8 @@ public class TActivityDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.AD_DELAY_NON_DETERMINISTIC_DELAY].setEnabled(b); mgui.actions[TGUIAction.AD_TIME_LIMITED_OFFER].setEnabled(b); mgui.actions[TGUIAction.AD_TIME_LIMITED_OFFER_WITH_LATENCY].setEnabled(b); + mgui.actions[TGUIAction.AD_ARRAY_GET].setEnabled(b); + mgui.actions[TGUIAction.AD_ARRAY_SET].setEnabled(b); mgui.actions[TGUIAction.ACT_TOGGLE_JAVA].setEnabled(b); mgui.actions[TGUIAction.ACT_ENHANCE].setEnabled(b); } @@ -144,7 +146,15 @@ public class TActivityDiagramToolBar extends TToolBar { button = this.add(mgui.actions[TGUIAction.AD_TIME_LIMITED_OFFER_WITH_LATENCY]); button.addMouseListener(mgui.mouseHandler); - + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.AD_ARRAY_GET]); + button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.AD_ARRAY_SET]); + button.addMouseListener(mgui.mouseHandler); + this.addSeparator(); button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_JAVA]); diff --git a/src/ui/cd/TCDAttributeBox.java b/src/ui/cd/TCDAttributeBox.java index ead47334d40480e3862938b5e0c03b4a22cfaa50..22892e2723f83ac3d7749366c7e05e9bd796adc9 100755 --- a/src/ui/cd/TCDAttributeBox.java +++ b/src/ui/cd/TCDAttributeBox.java @@ -80,6 +80,7 @@ public class TCDAttributeBox extends TGCAttributeBox { jda.addType(TAttribute.getStringType(TAttribute.NATURAL), true); jda.addType(TAttribute.getStringType(TAttribute.BOOLEAN), true); jda.addType(TAttribute.getStringType(TAttribute.QUEUE_NAT), true); + jda.addType(TAttribute.getStringType(TAttribute.ARRAY_NAT), true); //jda.enableInitialValue(true); jda.enableRTLOTOSKeyword(false); diff --git a/src/ui/images/starting_logo.gif b/src/ui/images/starting_logo.gif index 1a8a2e32ba8ba3ead073a3f42b965b926850296c..60795fedf7e469e6acee036bcd6442267e00a17d 100755 Binary files a/src/ui/images/starting_logo.gif and b/src/ui/images/starting_logo.gif differ diff --git a/src/ui/images/std_starting_logo.gif b/src/ui/images/std_starting_logo.gif index 1a8a2e32ba8ba3ead073a3f42b965b926850296c..60795fedf7e469e6acee036bcd6442267e00a17d 100755 Binary files a/src/ui/images/std_starting_logo.gif and b/src/ui/images/std_starting_logo.gif differ diff --git a/src/ui/sd/TGConnectorMessageSD.java b/src/ui/sd/TGConnectorMessageSD.java index d79e47af88547466b8d57286969c18c739df7359..4f6d3678764b85b818da09be592027441981fa57 100755 --- a/src/ui/sd/TGConnectorMessageSD.java +++ b/src/ui/sd/TGConnectorMessageSD.java @@ -92,15 +92,44 @@ public abstract class TGConnectorMessageSD extends TGConnector { } public boolean isMessageWellFormed() { + //System.out.println("Analyzing message:" + value); + int index0 = value.indexOf('('); + String name; + + if (index0 == -1) { + name = value; + } else { + name = value.substring(0, index0); + } + + if (!TAttribute.isAValidId(name, false, false)) { + return false; + } + if (index0 == -1) { return true; } + String tmp = value.trim(); - if (tmp.endsWith(")")) { - return true; + if (!tmp.endsWith(")")) { + return false; + } + + // Check for individual parameters + index0 = tmp.indexOf('('); + tmp = tmp.substring(index0+1, tmp.length()-1); + + String[] params = tmp.split(","); + for(int i=0; i<params.length; i++) { + tmp = params[i].trim(); + //System.out.println("First=" + tmp); + if (!TAttribute.isAValidId(tmp, false, false)) { + return false; + } } - return false; + + return true; } diff --git a/src/ui/window/JDialogArrayGet.java b/src/ui/window/JDialogArrayGet.java new file mode 100755 index 0000000000000000000000000000000000000000..53957c2bbae0014da5d681dca7b3a26017b41829 --- /dev/null +++ b/src/ui/window/JDialogArrayGet.java @@ -0,0 +1,232 @@ +/**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 JDialogArrayGet + * Dialog for managing parameters of action to get an element from an array + * Creation: 20/03/2008 + * @version 1.0 20/03/2008 + * @author Ludovic APVRILLE + * @see + */ + +package ui.window; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.util.*; + +import ui.*; +import ui.tmlcd.*; + +public class JDialogArrayGet extends javax.swing.JDialog implements ActionListener { + + private JPanel panel1; + private Frame frame; + + private String name; + private String variable, array, index; + + public boolean data; + + + // Panel1 + private JTextField variableText, arrayText, indexText; + private JLabel valueLabel; + + // Main Panel + private JButton closeButton; + private JButton cancelButton; + + /** Creates new form */ + public JDialogArrayGet(Frame f, String _variable, String _array, String _index, String title) { + super(f, title, true); + frame = f; + + variable = _variable; + array = _array; + index = _index; + + data = false; + + myInitComponents(); + initComponents(); + //setComponents(); + pack(); + } + + private String getValue() { + return variable + " = " + array + "[" + index + "]"; + } + + private void myInitComponents() { + } + + private void initComponents() { + Container c = getContentPane(); + GridBagLayout gridbag0 = new GridBagLayout(); + GridBagLayout gridbag1 = new GridBagLayout(); + GridBagConstraints c0 = new GridBagConstraints(); + GridBagConstraints c1 = new GridBagConstraints(); + + setFont(new Font("Helvetica", Font.PLAIN, 14)); + c.setLayout(gridbag0); + + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + panel1 = new JPanel(); + panel1.setLayout(gridbag1); + panel1.setBorder(new javax.swing.border.TitledBorder("Setting parameters")); + panel1.setPreferredSize(new Dimension(300, 150)); + + // first line panel1 + c1.gridwidth = 1; + c1.gridheight = 1; + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + c1.fill = GridBagConstraints.BOTH; + c1.gridheight = 3; + panel1.add(new JLabel("variable = array [index]"), c1); + + c1.gridwidth = 1; + c1.gridheight = 1; + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + c1.fill = GridBagConstraints.BOTH; + c1.gridheight = 3; + valueLabel = new JLabel(getValue()); + panel1.add(valueLabel, c1); + + c1.gridwidth = 1; + c1.gridheight = 1; + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.anchor = GridBagConstraints.CENTER; + panel1.add(new JLabel("variable:"), c1); + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + variableText = new JTextField(variable); + panel1.add(variableText, c1); + + c1.gridwidth = 1; + c1.gridheight = 1; + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.anchor = GridBagConstraints.CENTER; + panel1.add(new JLabel("array:"), c1); + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + arrayText = new JTextField(array); + panel1.add(arrayText, c1); + + c1.gridwidth = 1; + c1.gridheight = 1; + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.anchor = GridBagConstraints.CENTER; + panel1.add(new JLabel("index:"), c1); + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + indexText = new JTextField(index); + panel1.add(indexText, c1); + + // main panel; + c0.gridwidth = 1; + c0.gridheight = 10; + c0.weighty = 1.0; + c0.weightx = 1.0; + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + + c.add(panel1, c0); + + c0.gridheight = 1; + c0.fill = GridBagConstraints.HORIZONTAL; + closeButton = new JButton("Save and Close", IconManager.imgic25); + closeButton.addActionListener(this); + c.add(closeButton, c0); + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + cancelButton = new JButton("Cancel", IconManager.imgic27); + cancelButton.addActionListener(this); + c.add(cancelButton, c0); + } + + public void actionPerformed(ActionEvent evt) { + String command = evt.getActionCommand(); + + valueLabel.setText(getValue()); + + // Compare the action command to the known actions. + if (command.equals("Save and Close")) { + closeDialog(); + } else if (command.equals("Cancel")) { + cancelDialog(); + } + + } + + + public void closeDialog() { + data = true; + dispose(); + } + + public void cancelDialog() { + dispose(); + } + + public boolean hasNewData() { + return data; + } + + public String getVariableName() { + return variableText.getText(); + } + + public String getArrayName() { + return arrayText.getText(); + } + + public String getIndexName() { + return indexText.getText(); + } + + public boolean hasValidData() { + return ((variableText.getText().trim().length()> 0) && (arrayText.getText().trim().length() >0) && (indexText.getText().trim().length() >0)); + } + + +} diff --git a/src/ui/window/JDialogArraySet.java b/src/ui/window/JDialogArraySet.java new file mode 100755 index 0000000000000000000000000000000000000000..cc8ae45a031833494046e946e5ddce474a620282 --- /dev/null +++ b/src/ui/window/JDialogArraySet.java @@ -0,0 +1,232 @@ +/**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 JDialogArrayGet + * Dialog for managing parameters of action to get an element from an array + * Creation: 20/03/2008 + * @version 1.0 20/03/2008 + * @author Ludovic APVRILLE + * @see + */ + +package ui.window; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.util.*; + +import ui.*; +import ui.tmlcd.*; + +public class JDialogArraySet extends javax.swing.JDialog implements ActionListener { + + private JPanel panel1; + private Frame frame; + + private String name; + private String expr, array, index; + + public boolean data; + + + // Panel1 + private JTextField exprText, arrayText, indexText; + private JLabel valueLabel; + + // Main Panel + private JButton closeButton; + private JButton cancelButton; + + /** Creates new form */ + public JDialogArraySet(Frame f, String _array, String _index, String _expr, String title) { + super(f, title, true); + frame = f; + + expr = _expr; + array = _array; + index = _index; + + data = false; + + myInitComponents(); + initComponents(); + //setComponents(); + pack(); + } + + private String getValue() { + return array + "[" + index + "] = " + expr; + } + + private void myInitComponents() { + } + + private void initComponents() { + Container c = getContentPane(); + GridBagLayout gridbag0 = new GridBagLayout(); + GridBagLayout gridbag1 = new GridBagLayout(); + GridBagConstraints c0 = new GridBagConstraints(); + GridBagConstraints c1 = new GridBagConstraints(); + + setFont(new Font("Helvetica", Font.PLAIN, 14)); + c.setLayout(gridbag0); + + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + panel1 = new JPanel(); + panel1.setLayout(gridbag1); + panel1.setBorder(new javax.swing.border.TitledBorder("Setting parameters")); + panel1.setPreferredSize(new Dimension(300, 150)); + + // first line panel1 + c1.gridwidth = 1; + c1.gridheight = 1; + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + c1.fill = GridBagConstraints.BOTH; + c1.gridheight = 3; + panel1.add(new JLabel("array [index] = expr"), c1); + + c1.gridwidth = 1; + c1.gridheight = 1; + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + c1.fill = GridBagConstraints.BOTH; + c1.gridheight = 3; + valueLabel = new JLabel(getValue()); + panel1.add(valueLabel, c1); + + c1.gridwidth = 1; + c1.gridheight = 1; + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.anchor = GridBagConstraints.CENTER; + panel1.add(new JLabel("array:"), c1); + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + arrayText = new JTextField(array); + panel1.add(arrayText, c1); + + c1.gridwidth = 1; + c1.gridheight = 1; + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.anchor = GridBagConstraints.CENTER; + panel1.add(new JLabel("index:"), c1); + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + indexText = new JTextField(index); + panel1.add(indexText, c1); + + c1.gridwidth = 1; + c1.gridheight = 1; + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.anchor = GridBagConstraints.CENTER; + panel1.add(new JLabel("expr:"), c1); + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + exprText = new JTextField(expr); + panel1.add(exprText, c1); + + // main panel; + c0.gridwidth = 1; + c0.gridheight = 10; + c0.weighty = 1.0; + c0.weightx = 1.0; + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + + c.add(panel1, c0); + + c0.gridheight = 1; + c0.fill = GridBagConstraints.HORIZONTAL; + closeButton = new JButton("Save and Close", IconManager.imgic25); + closeButton.addActionListener(this); + c.add(closeButton, c0); + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + cancelButton = new JButton("Cancel", IconManager.imgic27); + cancelButton.addActionListener(this); + c.add(cancelButton, c0); + } + + public void actionPerformed(ActionEvent evt) { + String command = evt.getActionCommand(); + + valueLabel.setText(getValue()); + + // Compare the action command to the known actions. + if (command.equals("Save and Close")) { + closeDialog(); + } else if (command.equals("Cancel")) { + cancelDialog(); + } + + } + + + public void closeDialog() { + data = true; + dispose(); + } + + public void cancelDialog() { + dispose(); + } + + public boolean hasNewData() { + return data; + } + + public String getExprName() { + return exprText.getText(); + } + + public String getArrayName() { + return arrayText.getText(); + } + + public String getIndexName() { + return indexText.getText(); + } + + public boolean hasValidData() { + return ((exprText.getText().trim().length()> 0) && (arrayText.getText().trim().length() >0) && (indexText.getText().trim().length() >0)); + } + + +} diff --git a/src/ui/window/JDialogAttribute.java b/src/ui/window/JDialogAttribute.java index b650c29a3c4eaff787c078556df4da4668ee74cb..658b95f4030f3436eca71198098214b32fa03003 100755 --- a/src/ui/window/JDialogAttribute.java +++ b/src/ui/window/JDialogAttribute.java @@ -321,10 +321,15 @@ public class JDialogAttribute extends javax.swing.JDialog implements ActionListe if ((TAttribute.isAValidId(s, checkKeyword, checkJavaKeyword)) && (TAttribute.notIn(s, forbidden))){ int i = TAttribute.getAccess(o1.toString()); int j = TAttribute.getType(o2.toString()); + + if ((j == TAttribute.ARRAY_NAT) && (value.length() < 1)) { + value = "2"; + } if ((i != -1) && (j!= -1)) { if ((value.length() < 1) || (initialValue.isEnabled() == false)){ + value = ""; } else { if (!TAttribute.isAValidInitialValue(j, value)) { diff --git a/src/ui/window/JDialogProjection.java b/src/ui/window/JDialogProjection.java index d393824a001a117fe6bcc71bbc97a02c79049d44..83c1738968a2d3e68048c57736563f5e37af679c 100755 --- a/src/ui/window/JDialogProjection.java +++ b/src/ui/window/JDialogProjection.java @@ -741,7 +741,7 @@ public class JDialogProjection extends javax.swing.JDialog implements ActionList data = processCmd(cmd1); jta.append("Getting aut data\n"); - data = rshc.getFileData(fileName); + autproj = rshc.getFileData(fileName); // Print info on minimized graph p = FormatManager.nbStateTransitionRGAldebaran(autproj); diff --git a/src/ui/window/JDialogRequirement.java b/src/ui/window/JDialogRequirement.java index 1cb181339e2e9d0e00a88df768cd19b8e253e102..2830d7deed49fac5149b36b0c12cec3358ee70e2 100755 --- a/src/ui/window/JDialogRequirement.java +++ b/src/ui/window/JDialogRequirement.java @@ -57,6 +57,9 @@ import ui.*; public class JDialogRequirement extends javax.swing.JDialog implements ActionListener { + public static String[] kinds = {"Functional", "Non-functional", "Performance", "Privacy", "Confidentiality", "Non-repudiation", "Controlled access (authorization)", "Availability", "Immunity", "Integrity", "Data origin authenticity", "Freshness", "Other"}; + + private boolean regularClose; private JPanel panel1, panel2; @@ -102,6 +105,8 @@ public class JDialogRequirement extends javax.swing.JDialog implements ActionLis } private void initComponents() { + int i; + Container c = getContentPane(); GridBagLayout gridbag0 = new GridBagLayout(); GridBagLayout gridbag1 = new GridBagLayout(); @@ -180,9 +185,15 @@ public class JDialogRequirement extends javax.swing.JDialog implements ActionLis panel2.add(new JLabel("Type:"), c2); c2.gridwidth = GridBagConstraints.REMAINDER; //end row kindBox = new JComboBox(); - kindBox.addItem("Functional"); + + for(i=0; i<kinds.length; i++) { + kindBox.addItem(kinds[i]); + } + /*kindBox.addItem("Functional"); kindBox.addItem("Non functional"); kindBox.addItem("Performance"); + kindBox.addItem("Privacy"); + kindBox.addItem("Privacy"); kindBox.addItem("Other"); if (kind.compareTo("Functional") == 0) { kindBox.setSelectedIndex(0); @@ -195,7 +206,14 @@ public class JDialogRequirement extends javax.swing.JDialog implements ActionLis } if (kind.compareTo("Other") == 0) { kindBox.setSelectedIndex(3); - } + }*/ + + for(i=0; i<kinds.length; i++) { + if (kind.compareTo(kinds[i]) == 0) { + kindBox.setSelectedIndex(i); + } + } + panel2.add(kindBox, c2); c2.gridwidth = 1; diff --git a/src/ui/window/JFrameRequirementTable.java b/src/ui/window/JFrameRequirementTable.java index e23243a8093d758e9dd6484a33294d43600dd797..a17ae8b645913c5f1bd1229d2b1e70ffbe384f02 100755 --- a/src/ui/window/JFrameRequirementTable.java +++ b/src/ui/window/JFrameRequirementTable.java @@ -67,6 +67,8 @@ public class JFrameRequirementTable extends JFrame implements ActionListener /*, private Vector tabs; + private ArrayList<AbstractTableModel> atms; + private ArrayList<String> titles; //private StatisticsTableModel tm; @@ -99,6 +101,10 @@ public class JFrameRequirementTable extends JFrame implements ActionListener /*, pts = _pts; main = _main; //makeRequirements(); + + atms = new ArrayList<AbstractTableModel>(); + titles = new ArrayList<String>(); + makeComponents(); } @@ -110,7 +116,7 @@ public class JFrameRequirementTable extends JFrame implements ActionListener /*, JButton button1 = new JButton("Close", IconManager.imgic27); button1.addActionListener(this); - buttonGenerate = new JButton("Generate doc.", IconManager.imgic28); + buttonGenerate = new JButton("Generate doc.", IconManager.imgic29); buttonGenerate.addActionListener(this); JPanel jp = new JPanel(); jp.add(button1); @@ -200,6 +206,9 @@ public class JFrameRequirementTable extends JFrame implements ActionListener /*, jspRTM.getVerticalScrollBar().setUnitIncrement(10); tab.addTab(title, IconManager.imgic13, jspRTM, title); + + atms.add(rtm); + titles.add(title); } public void actionPerformed(ActionEvent evt) { @@ -218,6 +227,27 @@ public class JFrameRequirementTable extends JFrame implements ActionListener /*, private void generateDoc() { System.out.println("Generate doc"); + HTMLCodeGeneratorForTables doc = new HTMLCodeGeneratorForTables(); + String s = doc.getHTMLCode(atms, titles, "List of Requirements").toString(); + //System.out.println("HTML code:" + s); + + String path; + if (ConfigurationTTool.IMGPath.length() > 0) { + path = ConfigurationTTool.IMGPath + "/"; + } else { + path = ""; + } + path += "tablereq.html"; + + try { + FileUtils.saveFile(path, s); + } catch (FileException fe) { + System.out.println("HTML file could not be saved"); + return ; + } + + System.out.println("File generated in " + path); + } diff --git a/src/ui/window/JStartingWindow.java b/src/ui/window/JStartingWindow.java index 78b468a0d9b349870606c52eabe165f45e29fcce..e38b49058cd24324c13c8b14670ccd3d9fd8bc67 100755 --- a/src/ui/window/JStartingWindow.java +++ b/src/ui/window/JStartingWindow.java @@ -124,12 +124,12 @@ public class JStartingWindow extends Window { g.drawRect(0, 0, imgWidth - 1, imgHeight - 1); if (message != null) { - g.drawString(message, 5, imgHeight - 5); + g.drawString(message, 15, imgHeight - 5); } if (messageMiddle != null) { int w = g.getFontMetrics().stringWidth(messageMiddle); - g.drawString(messageMiddle, (imgWidth - w) / 2, imgHeight - 30); + g.drawString(messageMiddle, (imgWidth - w) / 2, imgHeight - 25); }