diff --git a/src/tmltranslator/TMLCP.java b/src/tmltranslator/TMLCP.java index 8f28626eb0f3f2d2592880f0cd7bc210061869d3..413f2aa9adbd9bfe1850a7300eca8155e33dc019 100755 --- a/src/tmltranslator/TMLCP.java +++ b/src/tmltranslator/TMLCP.java @@ -37,7 +37,7 @@ 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 TMLCP: data structure for the TMLTxt and the graphical2TMLTxt parsers +* Class TMLCP: data structure for the TMLCP * Creation: 18/02/2014 * @version 1.1 10/06/2014 * @author Ludovic APVRILLE, Andrea ENRICI @@ -167,44 +167,10 @@ public class TMLCP extends TMLElement { mainCP = _tmlcpSection; } - /*public void addCPActivityDiagram( TMLCPActivityDiagram _tmlcpSection ) throws UndeclaredDiagramException, MultipleDiagDeclarationsException { - - if( checkDiagramDeclaration( _tmlcpSection ) ) { - if( checkMultipleDiagramDeclaration( _tmlcpSection ) ) { - String errorMessage = "TMLCP COMPILER ERROR: activity diagram " + _tmlcpSection.getName() + " is defined multiple times"; - throw new MultipleDiagDeclarationsException( errorMessage ); - } - else { - otherCPs.add( _tmlcpSection ); - } - } - else { - String errorMessage = "TMLCP COMPILER ERROR: activity diagram " + _tmlcpSection.getName() + " undeclared"; - throw new UndeclaredDiagramException( errorMessage ); - } - }*/ - public void addCPActivityDiagram( TMLCPActivityDiagram _diag ) { otherCPs.add( _diag ); } - /* public void addCPSequenceDiagram( TMLCPSequenceDiagram _tmlsdSection ) throws UndeclaredDiagramException, MultipleDiagDeclarationsException { - - if( checkDiagramDeclaration( _tmlsdSection ) ) { - if( checkMultipleDiagramDeclaration( _tmlsdSection ) ) { - String errorMessage = "TMLCP COMPILER ERROR: sequence diagram " + _tmlsdSection.getName() + " is defined multiple times"; - throw new MultipleDiagDeclarationsException( errorMessage ); - } - else { - sds.add( _tmlsdSection ); - } - } - else { - String errorMessage = "TMLCP COMPILER ERROR: sequence diagram " + _tmlsdSection.getName() + " undeclared"; - throw new UndeclaredDiagramException( errorMessage ); - } - }*/ - public void addCPSequenceDiagram( TMLCPSequenceDiagram _sd ) { sds.add( _sd ); } diff --git a/src/tmltranslator/TMLCPSyntaxChecking.java b/src/tmltranslator/TMLCPSyntaxChecking.java new file mode 100755 index 0000000000000000000000000000000000000000..035a44b3f8e007b91db33f02067c6cb5b2ff777c --- /dev/null +++ b/src/tmltranslator/TMLCPSyntaxChecking.java @@ -0,0 +1,180 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici + * + * ludovic.apvrille AT telecom-paristech.fr + * andrea.enrici AT telecom-paristech.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * 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 TMLSyntaxChecking + * Used verifying the syntax of the TML specification for a Communication Pattern + * Creation: 05/09/2014 + * @version 1.0 05/09/2014 + * @author Ludovic APVRILLE, Andrea ENRICI + * @see + */ + + +package tmltranslator; + +import java.io.*; +import java.util.*; +import compiler.tmlparser.*; +import myutil.*; +import tmltranslator.*; +import tmltranslator.tmlcp.*; + + +public class TMLCPSyntaxChecking { + + private final String WRONG_ORIGIN_CHANNEL = "is not declared as an origin channel of the task"; + private final String WRONG_DESTINATION_CHANNEL = "is not declared as a destination channel of the task"; + private final String WRONG_ORIGIN_EVENT = "is not declared as an origin event of the task"; + private final String WRONG_DESTINATION_EVENT = "is not declared as a destination event of the task"; + private final String WRONG_ORIGIN_REQUEST = "is not declared as an origin request of the task"; + private final String SYNTAX_ERROR = "syntax error"; + private final String WRONG_VARIABLE_IDENTIFIER = "forbidden variable's name"; + private final String VARIABLE_ERROR = "variable is not used according to its type"; + private final String UNDECLARED_VARIABLE = "unknown variable"; + private final String SYNTAX_ERROR_VARIABLE_EXPECTED = "syntax error (variable expected)"; + private final String TIME_UNIT_ERROR = "unknown time unit"; + + + private ArrayList<TMLError> errors; + private ArrayList<TMLError> warnings; + private TMLCP tmlcp; + private TMLMapping mapping; + + + public TMLCPSyntaxChecking( TMLCP _tmlcp ) { + tmlcp = _tmlcp; + } + + /*public TMLCPSyntaxChecking(TMLMapping _mapping) { + mapping = _mapping; + tmlm = mapping.getTMLModeling(); + }*/ + + public void checkSyntax() { + + errors = new ArrayList<TMLError>(); + warnings = new ArrayList<TMLError>(); + + //TraceManager.addDev( "Checking syntax" ); + //Call here the routines to performan syntax checks + checkMainCP(); + checkActivityDiagrams(); + checkSequenceDiagrams(); + } + + private void checkMainCP() { + TMLCPActivityDiagram mainCP = tmlcp.getMainCP(); + } + + private void checkActivityDiagrams() { + ArrayList<TMLCPActivityDiagram> listADs = tmlcp.getCPActivityDiagrams(); + } + + private void checkSequenceDiagrams() { + ArrayList<TMLCPSequenceDiagram> listSDs = tmlcp.getCPSequenceDiagrams(); + checkVariables( listSDs ); + /*checkMessages( listSDs); + checkActions( listSDs ); + checkInstances(listSDs );*/ + } + + private void checkVariables( ArrayList<TMLCPSequenceDiagram> listSDs ) { + } + + public int hasErrors() { + if( errors == null ) { + return 0; + } + return errors.size(); + } + + public int hasWarnings() { + if( warnings == null ) { + return 0; + } + return warnings.size(); + } + + public ArrayList<TMLError> getErrors() { + return errors; + } + + public ArrayList<TMLError> getWarnings() { + return warnings; + } + + public void addError( TMLTask t, TMLActivityElement elt, String message, int type ) { + TMLError error = new TMLError( type ); + error.message = message; + error.task = t; + error.element = elt; + errors.add( error ); + } + + public String printSummary() { + String ret = ""; + if( errors.size() == 0 ) { + ret += printWarnings(); + ret += "Syntax checking: successful\n"; + ret += "No error, " + warnings.size() + " warning(s)\n"; + } + else { + ret += printErrors() + printWarnings(); + ret += "Syntax checking: failed\n"; + ret += errors.size() + " error(s), "+ warnings.size() + " warning(s)\n"; + } + return ret; + } + + public String printErrors() { + String ret = "*** ERRORS:"; + for( TMLError error: errors ) { + ret += "ERROR / task " + error.task.getName() + " / element " + error.element.getName() + ": " + error.message + "\n"; + } + return ret; + } + + public String printWarnings() { + String ret = ""; + for( TMLError error: warnings ) { + ret += "ERROR / task " + error.task.getName() + " / element: " + error.element.getName() + ": " + error.message + "\n"; + } + return ret; + } +} //End of class diff --git a/src/tmltranslator/tmlcp/TMLCPActivityDiagram.java b/src/tmltranslator/tmlcp/TMLCPActivityDiagram.java index dc0450c489fb5a744e1d0dd9f98ac87f2d4e0a81..6a48b04b7808b36655501097731fd3c89b6c9c20 100755 --- a/src/tmltranslator/tmlcp/TMLCPActivityDiagram.java +++ b/src/tmltranslator/tmlcp/TMLCPActivityDiagram.java @@ -87,48 +87,21 @@ public class TMLCPActivityDiagram extends TMLElement { sds = new ArrayList<String>(); } - public TMLCPActivityDiagram(String _name, Object _referenceObject) { - super(_name, _referenceObject); + public TMLCPActivityDiagram( String _name, Object _referenceObject ) { + super( _name, _referenceObject ); init(); } - public void addVariable( TMLAttribute _var ) /*throws UndeclaredVariableException*/ { - - if( !definedVariable( _var ) ) { - globalVariables.add( _var ); - } - else { - String errorMessage = "TMLCP COMPILER ERROR: variable " + _var.getName() + " is defined multiple times in diagram " + this.name; - //throw new UndeclaredVariableException( errorMessage ); - } + public void addVariable( TMLAttribute _var ) { + globalVariables.add( _var ); } - public void addADname( String _name ) /*throws MultipleDiagDeclarationsException, RecursionException*/ { - - if( _name.equals( this.name ) ) { - String errorMessage = "TMLCP COMPILER ERROR: detected recursion of " + _name + " in diagram " + this.name; - //throw new RecursionException( errorMessage ); - } - else { - if( !containsADDiagram( _name ) ) { - ads.add( _name ); - } - else { - String errorMessage = "TMLCP COMPILER ERROR: " + _name + " diagram is declared multiple times in diagram " + this.name; - //throw new MultipleDiagDeclarationsException( errorMessage ); - } - } + public void addADname( String _name ) { + ads.add( _name ); } - public void addSDname( String _name ) /*throws MultipleDiagDeclarationsException*/ { - - if( !containsSDDiagram( _name ) ) { - sds.add( _name ); - } - else { - String errorMessage = "TMLCP COMPILER ERROR: " + _name + " diagram is declared multiple times in diagram " + this.name; - //throw new MultipleDiagDeclarationsException( errorMessage ); - } + public void addSDname( String _name ) { + sds.add( _name ); } public boolean checkVariableNoType( TMLAttribute _attr ) { @@ -172,7 +145,7 @@ public class TMLCPActivityDiagram extends TMLElement { return ads.contains( _name ); } - public void insertInitialValue( TMLAttribute _attr, String value ) /*throws UninitializedVariableException*/ { + public void insertInitialValue( TMLAttribute _attr, String value ) { int i = 0; String str; @@ -192,8 +165,6 @@ public class TMLCPActivityDiagram extends TMLElement { } } //The variable trying to be initialized was not declared - String errorMessage = "TMLCP COMPILER ERROR: variable " + _attr.getName() + " declared but not defined in diagram " + this.name; - //throw new UninitializedVariableException( errorMessage ); } public ArrayList<TMLCPElement> getElements() { @@ -220,14 +191,6 @@ public class TMLCPActivityDiagram extends TMLElement { elements.add(_elt); } - public void checkVariable( TMLAttribute _var ) /*throws UndefinedVariableException*/ { - - if( !definedVariable( _var ) ) { - String errorMessage = "TMLCP COMPILER ERROR: variable " + _var.getName() + " undeclared in diagram " + this.name; - //throw new UndefinedVariableException( errorMessage ); - } - } - public boolean definedBoolVariable( String _name ) { TMLAttribute var; diff --git a/src/tmltranslator/tmlcp/TMLCPSequenceDiagram.java b/src/tmltranslator/tmlcp/TMLCPSequenceDiagram.java index 62acc216ebec190f534a5e3bd319ecd28e3ad46b..92a5c0a2b772fc87fe760e76a1294a6a39f95b0d 100755 --- a/src/tmltranslator/tmlcp/TMLCPSequenceDiagram.java +++ b/src/tmltranslator/tmlcp/TMLCPSequenceDiagram.java @@ -78,17 +78,6 @@ public class TMLCPSequenceDiagram extends TMLElement { items = new ArrayList<TMLSDItem>(); } - /*public void addVariable( TMLAttribute _attr ) throws MultipleVariableDeclarationException { - - if( !checkVariableUniqueness( _attr.getName() ) ) { - String errorMessage = "TMLCOMPILER ERROR: variable " + _attr.getName() + " in diagram " + this.name + " has mutliple declarations"; - throw new MultipleVariableDeclarationException( errorMessage ); - } - else { - globalVariables.add(_attr); - } - }*/ - public ArrayList<TMLSDItem> getItems() { return items; } @@ -122,18 +111,6 @@ public class TMLCPSequenceDiagram extends TMLElement { addItem( new TMLSDItem( _action.getAction(), _action.getInstanceName(), _action.getYCoord() ) ); } - //commenting the throw exception because bot needed by the graphical 2 TMLTxt compiler yet - /*public void addInstance( TMLSDInstance _elt ) throws MultipleInstanceDeclarationException { - - if( declaredInstance( _elt ) ) { - String errorMessage = "TMLCP COMPILER ERROR: instance " + _elt.getName() + " in diagram " + this.name + " declared multiple times"; - throw new MultipleInstanceDeclarationException( errorMessage ); - } - else { - instances.add( _elt ); - } - }*/ - public void addInstance( TMLSDInstance _inst ) { instances.add( _inst ); } @@ -155,7 +132,7 @@ public class TMLCPSequenceDiagram extends TMLElement { //addItem( new TMLSDItem( _msg.getName(), _msg.getSenderName(), _msg.getReceiverName(), _msg.getYCoord(), _msg.getAttributes() ) ); } - public void insertInitialValue( String _name, String value ) /*throws UninitializedVariableException*/ { + public void insertInitialValue( String _name, String value ) { int i = 0; String str; diff --git a/src/ui/GTMLModeling.java b/src/ui/GTMLModeling.java index f13163ec8aa0cd76dc372b33e0feba865a72fc78..ab98d592f33fc5ef1eb852b220fff4087aad602f 100755 --- a/src/ui/GTMLModeling.java +++ b/src/ui/GTMLModeling.java @@ -64,7 +64,6 @@ public class GTMLModeling { private TMLDesignPanel tmldp; private TMLComponentDesignPanel tmlcdp; private TMLArchiPanel tmlap; - private TMLCommunicationPatternPanel tmlcpp; private TMLModeling tmlm; private Vector checkingErrors, warnings; private LinkedList tasksToTakeIntoAccount; @@ -74,13 +73,17 @@ public class GTMLModeling { private static CorrespondanceTGElement listE; private Hashtable<String, String> table; - //private ArrayList<HwNode> nodesToTakeIntoAccount; private LinkedList nodesToTakeIntoAccount; private TMLMapping map; private TMLArchitecture archi; + + //Attributes specific to Communication Patterns private TMLCP tmlcp; + private TMLCommunicationPatternPanel tmlcpp; + private Vector<TDiagramPanel> diagramPanelsToTakeIntoAccount; + private Vector<TDiagramPanel> panels; private boolean putPrefixName = false; @@ -258,6 +261,10 @@ public class GTMLModeling { public void setNodes(Vector nodes) { nodesToTakeIntoAccount = new LinkedList(nodes); } + + public void setDiagramPanels( Vector panels ) { + diagramPanelsToTakeIntoAccount = new Vector<TDiagramPanel>( panels ); + } public Vector getCheckingErrors() { return checkingErrors; @@ -1885,25 +1892,56 @@ public class GTMLModeling { return map; // the data structure map is returned to CheckSyntaxTMLMapping in GTURTLEModeling } - //Checking the syntax of CP with mapping if present - public TMLCP translateToTMLCP() { - //tmlm = new TMLModeling( true ); - //archi = new TMLArchitecture(); + public TMLCP translateToTMLCPDataStructure() { + tmlcp = new TMLCP(); - //map = new TMLMapping( tmlm, archi, cp, false ); - //map = new TMLMapping( tmlm, archi, false ); - checkingErrors = new Vector(); warnings = new Vector(); //listE = new CorrespondanceTGElement(); - TraceManager.addDev( "Making Communication Pattern data structure to check the syntax" ); - makeCommunicationPattern(); + if( tmlcpp != null ) { + try { + TraceManager.addDev( "Making Communication Pattern data structure to check the syntax" ); + makeCPDataStructure(); //fill the data structure tmlcp + } + catch( MalformedTMLDesignException mtmlde ) { + TraceManager.addDev( "Modeling error: " + mtmlde.getMessage() ); + } + } + + TraceManager.addDev( "About to check the syntax of CPs" ); + TMLCPSyntaxChecking syntax = new TMLCPSyntaxChecking( tmlcp ); + syntax.checkSyntax(); + + CheckingError ce; + int type; + TGComponent tgc; + + /*if( syntax.hasErrors() >0 ) { + for( TMLError error: syntax.getErrors() ) { + if( error.type == TMLError.ERROR_STRUCTURE ) { + type = CheckingError.STRUCTURE_ERROR; + } + else { + type = CheckingError.BEHAVIOR_ERROR; + } + ce = new CheckingError( type, error.message ); + tgc = listE.getTG( error.element ); + if ( tgc != null ) { + ce.setTDiagramPanel( tgc.getTDiagramPanel() ); + ce.setTGComponent( tgc ); + } + ce.setTMLTask( error.task ); + checkingErrors.add( ce ); + } + }*/ + + //makeCPDataStructure(); /*if (!makeTMLModeling()) { return null; }*/ - TraceManager.addDev("Making mapping"); + //TraceManager.addDev("Making mapping"); //makeCPMapping(); //Inspect the architecture Deployment Diagram to retrieve mapping information, that is now located in one //place only: the architecture DD @@ -2126,7 +2164,7 @@ public class GTMLModeling { } } - private void makeCommunicationPattern() { + private void makeCPDataStructure() throws MalformedTMLDesignException { TGComponent tgc; ui.tmlsd.TMLSDPanel SDpanel; @@ -2146,11 +2184,12 @@ public class GTMLModeling { else if( panelList.get( panelCounter ) instanceof ui.tmlcp.TMLCPPanel ) { tmlcp.addCPActivityDiagram( createActivityDiagramDataStructure( (ui.tmlcp.TMLCPPanel) panelList.get( panelCounter ), names ) ); } - TraceManager.addDev( "PANEL number: " + panelCounter + " " + panelList.get( panelCounter ) ); + //TraceManager.addDev( "PANEL number: " + panelCounter + " " + panelList.get( panelCounter ) ); } } //End of method - private tmltranslator.tmlcp.TMLCPActivityDiagram createActivityDiagramDataStructure( ui.tmlcp.TMLCPPanel panel, ArrayList<String> names ) { + private tmltranslator.tmlcp.TMLCPActivityDiagram createActivityDiagramDataStructure( ui.tmlcp.TMLCPPanel panel, + ArrayList<String> names ) throws MalformedTMLDesignException { tmltranslator.tmlcp.TMLCPStart start; tmltranslator.tmlcp.TMLCPStop stop; @@ -2162,65 +2201,76 @@ public class GTMLModeling { tmltranslator.tmlcp.TMLCPRefAD refAD; tmltranslator.tmlcp.TMLCPRefSD refSD; + /*if (tmladp == null) { + String msg = tmlto.getValue() + " has no activity diagram"; + CheckingError ce = new CheckingError(CheckingError.STRUCTURE_ERROR, msg); + ce.setTDiagramPanel(tmldp.tmltdp); + ce.setTGComponent(tgc); + checkingErrors.add(ce); + throw new MalformedTMLDesignException(tmlto.getValue() + " msg"); + }*/ + LinkedList components = panel.getComponentList(); if( nameInUse( names, panel.getName() ) ) { - /*CheckingError ce = new CheckingError(CheckingError.STRUCTURE_ERROR, "Two nodes have the same name: " + ADpanel.getName()); + String msg = panel.getName() + " already exists"; + CheckingError ce = new CheckingError( CheckingError.STRUCTURE_ERROR, "Two diagrams have the same name: " + panel.getName() ); ce.setTDiagramPanel( tmlcpp.tmlcpp ); - ce.setTGComponent( ADpanel ); - checkingErrors.add( ce );*/ - TraceManager.addDev( "ERROR: two diagrams have the same name!" ); + //ce.setTGComponent( components ); + checkingErrors.add( ce ); + throw new MalformedTMLDesignException( msg ); + /*TraceManager.addDev( "ERROR: two diagrams have the same name!" ); System.exit(0); - return new tmltranslator.tmlcp.TMLCPActivityDiagram( "ERROR", panel ); + return new tmltranslator.tmlcp.TMLCPActivityDiagram( "ERROR", panel );*/ } else { names.add( panel.getName() ); - TraceManager.addDev("Lenght of elements: " + components.size() ); + //TraceManager.addDev("Lenght of elements: " + components.size() ); tmltranslator.tmlcp.TMLCPActivityDiagram AD = new tmltranslator.tmlcp.TMLCPActivityDiagram( panel.getName(), panel ); for( int k = 0; k < components.size(); k++ ) { TGComponent component = (TGComponent) components.get(k); if( component instanceof ui.tmlcp.TMLCPStartState ) { - TraceManager.addDev( k + " " + component.getName() + "\t" + component.getValue() ); + //TraceManager.addDev( k + " " + component.getName() + "\t" + component.getValue() ); start = new tmltranslator.tmlcp.TMLCPStart( panel.getName() + "Start", component ); AD.addTMLCPElement( start ); //CAREFUL: the elements are not added in the same order as they appear in the GUI } if( component instanceof ui.tmlcp.TMLCPStopState ) { - TraceManager.addDev( k + " " + component.getName() + "\t" + component.getValue() + "\t" + component.getY() ); + //TraceManager.addDev( k + " " + component.getName() + "\t" + component.getValue() + "\t" + component.getY() ); stop = new tmltranslator.tmlcp.TMLCPStop( panel.getName() + "Stop", component ); } if( component instanceof ui.tmlcp.TMLCPRefSD ) { - TraceManager.addDev( k + " " + component.getName() + "\t" + component.getValue() + "\t" + component.getY() ); + //TraceManager.addDev( k + " " + component.getName() + "\t" + component.getValue() + "\t" + component.getY() ); refSD = new tmltranslator.tmlcp.TMLCPRefSD( component.getName(), component ); AD.addTMLCPElement( refSD ); } if( component instanceof ui.tmlcp.TMLCPRefAD ) { - TraceManager.addDev( k + " " + component.getName() + "\t" + component.getValue() + "\t" + component.getY() ); + //TraceManager.addDev( k + " " + component.getName() + "\t" + component.getValue() + "\t" + component.getY() ); refAD = new tmltranslator.tmlcp.TMLCPRefAD( component.getName(), component ); AD.addTMLCPElement( refAD ); } if( component instanceof ui.tmlcp.TMLCPJunction ) { - TraceManager.addDev( k + " " + component.getName() + "\t" + component.getValue() + "\t" + component.getY() ); + //TraceManager.addDev( k + " " + component.getName() + "\t" + component.getValue() + "\t" + component.getY() ); junction = new tmltranslator.tmlcp.TMLCPJunction( component.getName(), component ); AD.addTMLCPElement( junction ); } if( component instanceof ui.tmlcp.TMLCPJoin ) { - TraceManager.addDev( k + " " + component.getName() + "\t" + component.getValue() + "\t" + component.getY() ); + //TraceManager.addDev( k + " " + component.getName() + "\t" + component.getValue() + "\t" + component.getY() ); join = new tmltranslator.tmlcp.TMLCPJoin( component.getName(), component ); AD.addTMLCPElement( join ); } if( component instanceof ui.tmlcp.TMLCPFork ) { - TraceManager.addDev( k + " " + component.getName() + "\t" + component.getValue() + "\t" + component.getY() ); + //TraceManager.addDev( k + " " + component.getName() + "\t" + component.getValue() + "\t" + component.getY() ); fork = new tmltranslator.tmlcp.TMLCPFork( component.getName(), component ); AD.addTMLCPElement( fork ); } if( component instanceof ui.tmlcp.TMLCPChoice ) { - TraceManager.addDev( k + component.getName() + "\t" + component.getValue() + "\t" + component.getY()); + //TraceManager.addDev( k + component.getName() + "\t" + component.getValue() + "\t" + component.getY()); choice = new tmltranslator.tmlcp.TMLCPChoice( component.getName(), ((ui.tmlcp.TMLCPChoice) component).getGuards(), component ); AD.addTMLCPElement( choice ); } if( component instanceof ui.tmlcp.TGConnectorTMLCP) { - TraceManager.addDev( k + " " + ((ui.TGConnector)component).getTGConnectingPointP1().getFather().getName() + "\t" + - ((ui.TGConnector)component).getTGConnectingPointP2().getFather().getName() + "\t" + component.getY() ); + //TraceManager.addDev( k + " " + ((ui.TGConnector)component).getTGConnectingPointP1().getFather().getName() + "\t" + + // ((ui.TGConnector)component).getTGConnectingPointP2().getFather().getName() + "\t" + component.getY() ); TMLCPconnector = new tmltranslator.tmlcp.TMLCPConnector( ((ui.tmlcp.TGConnectorTMLCP)component).getTGConnectingPointP1().getFather().getName(), ((ui.tmlcp.TGConnectorTMLCP)component).getTGConnectingPointP2().getFather().getName(), @@ -2233,7 +2283,8 @@ public class GTMLModeling { } //End of method createActivityDiagramDataStructure - private tmltranslator.tmlcp.TMLCPSequenceDiagram createSequenceDiagramDataStructure( ui.tmlsd.TMLSDPanel panel, ArrayList<String> names ) { + private tmltranslator.tmlcp.TMLCPSequenceDiagram createSequenceDiagramDataStructure( ui.tmlsd.TMLSDPanel panel, + ArrayList<String> names ) throws MalformedTMLDesignException { Vector attributes; int index1; @@ -2246,22 +2297,23 @@ public class GTMLModeling { String[] tokens; //used to get the tokens of the string for a SD attribute String delims = "[ +=:;]+"; //the delimiter chars used to parse attributes of SD instance - TraceManager.addDev( "ADDING TO DATA STRUCTURE THE DIAGRAM " + panel.getName() ); + //TraceManager.addDev( "ADDING TO DATA STRUCTURE THE DIAGRAM " + panel.getName() ); if( nameInUse( names, panel.getName() ) ) { - // Node with the same name - /*CheckingError ce = new CheckingError( CheckingError.STRUCTURE_ERROR, "Two nodes have the same name: " + SDpanel.getName() ); + String msg = panel.getName() + " already exists"; + CheckingError ce = new CheckingError( CheckingError.STRUCTURE_ERROR, "Two diagrams have the same name: " + panel.getName() ); ce.setTDiagramPanel( tmlcpp.tmlcpp ); - ce.setTGComponent( SDpanel ); - checkingErrors.add( ce );*/ - TraceManager.addDev( "ERROR: two diagrams have the same name!" ); + //ce.setTGComponent( components ); + checkingErrors.add( ce ); + throw new MalformedTMLDesignException( msg ); + /*TraceManager.addDev( "ERROR: two diagrams have the same name!" ); System.exit(0); - return new tmltranslator.tmlcp.TMLCPSequenceDiagram( "ERROR", panel ); + return new tmltranslator.tmlcp.TMLCPSequenceDiagram( "ERROR", panel );*/ } else { names.add( panel.getName() ); tmltranslator.tmlcp.TMLCPSequenceDiagram SD = new tmltranslator.tmlcp.TMLCPSequenceDiagram( panel.getName(), panel ); LinkedList elemList = panel.getComponentList(); - TraceManager.addDev("Adding to the data structure the elements of: " + panel.getName() ); + //TraceManager.addDev("Adding to the data structure the elements of: " + panel.getName() ); //order messages according to the inverse of Y coordinate for( int j = 0; j < elemList.size(); j++ ) { TGComponent elem = (TGComponent) elemList.get(j); @@ -2350,47 +2402,6 @@ public class GTMLModeling { }//End else name does not exist yet } //End of method createSequenceDiagramDataStructure - // Links between nodes - /*TGComponent tgc1, tgc2; - TGConnectingPoint p1, p2; - TMLArchiConnectorNode connector; - HwLink hwlink; - HwNode originNode; - - iterator = tmlap.tmlap.getComponentList().listIterator(); - while(iterator.hasNext()) { - tgc = (TGComponent)(iterator.next()); - if (tgc instanceof TMLArchiConnectorNode) { - //TraceManager.addDev("Found link"); - connector = (TMLArchiConnectorNode)tgc; - tgc1 = null; tgc2 = null; - p1 = connector.getTGConnectingPointP1(); - p2 = connector.getTGConnectingPointP2(); - tgc1 = tgc.getTDiagramPanel().getComponentToWhichBelongs(p1); - tgc2 = tgc.getTDiagramPanel().getComponentToWhichBelongs(p2); - if ((tgc1 != null) && (tgc2 != null)) { - //TraceManager.addDev("Not null"); - if (components.contains(tgc1) && components.contains(tgc2)) { - //TraceManager.addDev("Getting closer"); - if (tgc2 instanceof TMLArchiBUSNode) { - originNode = listE.getHwNode(tgc1); - bus = (HwBus)(listE.getHwNode(tgc2)); - if ((originNode != null) && (bus != null)) { - hwlink = new HwLink("link_" +originNode.getName() + "_to_" + bus.getName()); - hwlink.setPriority(connector.getPriority()); - hwlink.bus = bus; - hwlink.hwnode = originNode; - listE.addCor(hwlink, connector); - archi.addHwLink(hwlink); - //TraceManager.addDev("Link added"); - } - } - } - } - } - } - }*/ - private boolean makeTMLModeling() { // Determine all TML Design to be used -> TMLDesignPanels ArrayList<TMLDesignPanel> panels = new ArrayList<TMLDesignPanel>(); diff --git a/src/ui/GTURTLEModeling.java b/src/ui/GTURTLEModeling.java index 212a538c6676636b275c4fe484fb0b076f403e76..dcc9d5304d9bd9e142089e7b2ed0ad801b59a556 100755 --- a/src/ui/GTURTLEModeling.java +++ b/src/ui/GTURTLEModeling.java @@ -6400,21 +6400,32 @@ public class GTURTLEModeling { //diagram. Up to now, not taking the mapping information into account public boolean checkSyntaxTMLCP( Vector nodesToTakeIntoAccount, TMLCommunicationPatternPanel tmlcpp, boolean optimize ) { + //nodesToTakeIntoAccount is the list of SDs and ADs corresponding that compose the CP selected for syntax checking ArrayList<TMLError> warningsOptimize = new ArrayList<TMLError>(); warnings = new Vector(); mgui.setMode( MainGUI.VIEW_SUGG_DESIGN_KO ); GTMLModeling gtmlm = new GTMLModeling( tmlcpp, true ); + + TraceManager.addDev( "NodesToTakeIntoAccount :" + nodesToTakeIntoAccount.toString() ); - gtmlm.setNodes( nodesToTakeIntoAccount ); //simply transforms the parameter from a Vector to LinkedList + //Useless because nodesToTakeIntoAccount does not include the mainCP! + //gtmlm.setDiagramPanels( nodesToTakeIntoAccount ); //passes the list of nodes (SDs and ADs) to gtml as a LinkedList tmlm = null; tm = null; tmState = 1; - tmlcp = gtmlm.translateToTMLCP(); //tmlcp is the data structure for a CP corresponding to the graphical description with diagrams + //tmlcp is the data structure for a CP corresponding to the graphical description with diagrams + tmlcp = gtmlm.translateToTMLCPDataStructure(); TraceManager.addDev( "I AM ABOUT TO GENERATE THE TMLtxt CODE!" ); mgui.generateTMLTxt(); //Now generating the TMLtxt code TraceManager.addDev( "TMLtxt CODE GENERATION DONE" ); - /*listE = gtmlm.getCorrespondanceTable(); - checkingErrors = gtmlm.getCheckingErrors(); + listE = gtmlm.getCorrespondanceTable(); + //for( CorrespondanceTGElement element : listE.getNames() ) { + TraceManager.addDev( "Printing listE.getNames: " + listE.getNames().toString() ); + TraceManager.addDev( "Printing listE.getTG: " + listE.getTG().toString() ); + TraceManager.addDev( "Printing listE.getPanelNames: " + listE.getPanelNames().toString() ); + TraceManager.addDev( "Printing listE.getData: " + listE.getData().toString() ); + //} + /*checkingErrors = gtmlm.getCheckingErrors(); if( (checkingErrors != null) && (checkingErrors.size() > 0) ) { analyzeErrors();