diff --git a/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSBlocks.java b/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSBlocks.java new file mode 100755 index 0000000000000000000000000000000000000000..a1a06dfc5de8b133d63eea63479a3b1779338714 --- /dev/null +++ b/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSBlocks.java @@ -0,0 +1,126 @@ +/* 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. + */ + + + + +package heterogeneoustranslator.systemCAMStranslator; + +import javax.swing.*; +import java.awt.*; +import java.util.LinkedList; +import java.util.Vector; +import ui.*; + +/** +* Class CAMSBlocks +* Simulation Block for SystemC-AMS Diagrams +* Creation: 28/08/2017 +* @version 1.0 28/08/2017 +* @author Côme DEMARIGNY + */ + +public class CAMSBlocks{ + + private String name; + private int nbOfIn; + private int nbOfOut; + private LinkedList<TAttribute> myAttributes; + private LinkedList<CAMSSignal> mySignals; + private String [] processCode; + + + public CAMSBlocks(String _name, int _nbOfIn, int _nbOfOut, LinkedList<TAttribute> _myAttributes, LinkedList<CAMSSignal> _mySignals, String [] _processCode){ + name=_name; + nbOfIn=_nbOfIn; + nbOfOut=_nbOfOut; + myAttributes=_myAttributes; + mySignals=_mySignals; + processCode=_processCode; + + } + + public void setBlockName(String newName){ + name = newName; + } + + public void setNbOfIn(int newIn){ + nbOfIn = newIn; + } + + public void setNbOfOut(int newOut){ + nbOfOut = newOut; + } + + public void setMyAttributes(LinkedList<TAttribute> newMyAttributes){ + myAttributes = newMyAttributes; + } + + public void setMySignals(LinkedList<CAMSSignal> newMySignals){ + mySignals = newMySignals; + } + + public void setProcessCode(String[] newProcessCode){ + processCode = newProcessCode; + } + + public String getBlockName(){ + return name; + } + + public int getNbOfIn() { + return nbOfIn; + } + + public int getNbOfOut() { + return nbOfOut; + } + + public LinkedList<TAttribute> getMyAttributes(){ + return myAttributes; + } + + public LinkedList<CAMSSignal> getMySignals(){ + return mySignals; + } + + public String[] getProcessCode(){ + return processCode; + } + +} \ No newline at end of file diff --git a/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSConnection.java b/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSConnection.java new file mode 100755 index 0000000000000000000000000000000000000000..20c538e520dbc623d09b5b5b0503cbaa3180ae65 --- /dev/null +++ b/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSConnection.java @@ -0,0 +1,78 @@ +/* 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. + */ + + + + +package heterogeneoustranslator.systemCAMStranslator; + +import javax.swing.*; +import java.awt.*; +import java.util.LinkedList; +import java.util.Vector; +import ui.*; + +/** +* Class CAMSConnection +* Connection beetwen blocks for SystemC-AMS Diagrams +* Creation: 30/08/2017 +* @version 1.0 30/08/2017 +* @author Côme DEMARIGNY + */ + +public class CAMSConnection{ + + public String name; + public CAMSBlocks inputBlock, outputBlock; + public int rate; + public int type; + + public CAMSConnection(CAMSBlocks _inputBlock, CAMSBlock _outputBlock){ + inputBlock = _inputBlock; + outputBlock = _outputBlock; + } + + public CAMSBlock getInputBlock(){ + return inputBlock; + } + + public CAMSBlock getOutputBlock(){ + return outputBlock; + } + +} \ No newline at end of file diff --git a/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSSignal.java b/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSSignal.java new file mode 100755 index 0000000000000000000000000000000000000000..b945f8c401bc2f2338c6ad92848ac34b88e5337c --- /dev/null +++ b/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSSignal.java @@ -0,0 +1,109 @@ + /* 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. + */ + + + + +package heterogeneoustranslator.systemCAMStranslator; + +import myutil.GraphicLib; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import ui.*; +import ui.het.*; +import ui.util.IconManager; +import ui.window.JDialogCAMSBlocks; + +import javax.swing.*; +import java.awt.*; +import java.util.LinkedList; +import java.util.Vector; + + +/** +* Class CAMSSignal +* Signals for SystemC-AMS Diagrams +* Creation: 27/06/2017 +* @version 1.0 27/06/2017 +* @author Côme DEMARIGNY + */ +public class CAMSSignal { + + public final static int IN = 0; + public final static int OUT= 1; + public final static int INCORRECT=-1; + + private static int i=0; + + private String name; + + public int inout; + + public CAMSSignal (String _name, int _inout) { + inout = _inout; + } + + + public CAMSSignal makeclone(){ + return this; + } + + public static CAMSSignal isAValidSignal(String _name, int _inout) { + if (_inout==INCORRECT) { + return null; + } + String s = signalName(_name); + CAMSSignal cs = new CAMSSignal(s, _inout); + + return cs; + } + + public int getInout(){ + return inout; + } + + public static String signalName(String _n){ + String s=""; + s+= _n + ": " + signalID(); + return s; + } + + public static int signalID(){i++;return i;} + +} \ No newline at end of file diff --git a/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSSpecification.java b/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSSpecification.java new file mode 100755 index 0000000000000000000000000000000000000000..68829e26f1a9dbe4783acdf22988c001b4a3bc7c --- /dev/null +++ b/src/main/java/heterogeneoustranslator/systemCAMStranslator/CAMSSpecification.java @@ -0,0 +1,102 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * Daniela Genius, Lip6, UMR 7606 + * + * ludovic.apvrille AT enst.fr + * daniela.genius@lip6.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. + */ + + + + + +/* * @version 1.0 04/09/2017 + * @author Côme Demarigny */ + +package heterogeneoustranslator.systemCAMStranslator; + +import java.util.LinkedList; +import java.util.List; + +public class CAMSSpecification{ + + + private List<CAMSBlocks> blocks; + private List<CAMSSignal> signals; + private List<CAMSConnection> connections; + + + public CAMSSpecification( List<CAMSBlocks> _blocks, List<CAMSSignal> _signals, List<CAMSConnection> _connections, int _nb_target, int _nb_init){ + blocks = _blocks ; + signals = _signals ; + connections = _connections ; + nb_target = _nb_target; + nb_init = _nb_init; + } + + public List<CAMSBlock> getBlock(){ + return blocks; + } + + public List<CAMSSignals> getSignals(){ + return signals; + } + + public List<CAMSConnection> getConnection(){ + return connections; + } + + public List<CAMSBlocks> getUnconnectedBlocks(){ + List<CAMSBlocks> unconnectedBlocks; + for(CAMSBlocks block : blocks){ + for(CAMSConnections connection : connections){ + if (block == connection.getInputBlock() || block == connection.getOutputBlock()){ + break; + } + else { + unconnectedBlocks.add(block); + } + } + } + return unconnectedBlocks; + } + + public list<CAMSSignals> getunconnectedSignals(){ + list<CAMSSignals> unconnectedSignals; + return unconnectedSignals; + } + + +} diff --git a/src/main/java/ui/SystemCAMSPanel.java b/src/main/java/ui/SystemCAMSPanel.java new file mode 100755 index 0000000000000000000000000000000000000000..19587244f2999b9acaf9975317b845d3b20b6add --- /dev/null +++ b/src/main/java/ui/SystemCAMSPanel.java @@ -0,0 +1,140 @@ +/* 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. + */ + + + + +package ui; + +import myutil.GraphicLib; +import ui.het.CAMSBlockDiagramToolBar; +import ui.het.CAMSBlockDiagramPanel; +import ui.util.IconManager; +import ui.TDiagramPanel; +import ui.window.JDialogCAMSBlocks; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.util.Vector; + +/** + * Class SystemCAMSPanel + * Managenemt of TML architecture panels + * Creation: 23/06/2017 + * @version 0.1 23/06/2107 + * @author Côme DEMARIGNY + * @see MainGUI + */ +public class SystemCAMSPanel extends TURTLEPanel { + public SystemCAMSPanel scp; + public CAMSBlockDiagramPanel camsbdp; + public TURTLEPanel tp; + public TDiagramPanel tdp; + public Vector<TGComponent> validated, ignored; + + public SystemCAMSPanel(MainGUI _mgui) { + super(_mgui); + + tabbedPane = GraphicLib.createTabbedPane();//new JTabbedPane(); + + cl = new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e){ + mgui.paneDesignAction(e); + } + }; + tabbedPane.addChangeListener(cl); + tabbedPane.addMouseListener(new TURTLEPanelPopupListener(this, mgui)); + } + + public void init() { + + // Class Diagram toolbar + CAMSBlockDiagramToolBar camstoolBar = new CAMSBlockDiagramToolBar(mgui); + toolbars.add(camstoolBar); + toolBarPanel = new JPanel(); + toolBarPanel.setLayout(new BorderLayout()); + + //Class Diagram Panel + camsbdp = new CAMSBlockDiagramPanel(mgui, camstoolBar); + camsbdp.setName("SystemC-AMS Diagram"); + + // Diagram toolbar + camsbdp.tp = this; + tp = scp; + panels.add(camsbdp); // Always first in list + JScrollDiagramPanel jsp = new JScrollDiagramPanel(camsbdp); + camsbdp.jsp = jsp; + jsp.setWheelScrollingEnabled(true); + jsp.getVerticalScrollBar().setUnitIncrement( MainGUI.INCREMENT ); + toolBarPanel.add(camstoolBar, BorderLayout.NORTH); + toolBarPanel.add(jsp, BorderLayout.CENTER); + tabbedPane.addTab("SystemC-AMS Diagram", IconManager.imgic60, toolBarPanel, "opens SystemC-AMS diagram"); + tabbedPane.setSelectedIndex(0); + mgui.changeMade(camsbdp, TDiagramPanel.NEW_COMPONENT); + + + } + + public String saveHeaderInXml(String extensionToName) { + if (extensionToName == null) { + return "<Modeling type=\"SystemC-AMS\" nameTab=\"" + mgui.getTabName(this) + "\" >\n"; + } + return "<Modeling type=\"SystemC-AMS\" nameTab=\"" + mgui.getTabName(this) + extensionToName +"\" >\n"; + } + + public String saveTailInXml() { + return "</Modeling>\n\n\n"; + } + + public String toString() { + return mgui.getTitleAt(this) + " (SystemC-AMS Diagram)"; + } + + public void renameMapping(String oldName, String newName) { + if (scp != null) { + scp.renameMapping(oldName, newName); + } + } + + public CAMSBlockDiagramPanel getCAMSBlockDiagramPanel(){ + return camsbdp; + } +} diff --git a/src/main/java/ui/het/#CAMSConnectingPoint.java# b/src/main/java/ui/het/#CAMSConnectingPoint.java# new file mode 100755 index 0000000000000000000000000000000000000000..7eb970fdb7343edd87d4255cb38f36a9861cb494 --- /dev/null +++ b/src/main/java/ui/het/#CAMSConnectingPoint.java# @@ -0,0 +1,156 @@ +/* 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. + */ + + + + +package ui.het; + +import myutil.GraphicLib; +import ui.*; +import ui.window.JDialogCAMSConnectingPoint; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.geom.Point2D; +import javax.swing.*; +import java.util.Vector; + + +/** + * Class SystemCAMSConnectingPoint + * Definition of connecting points on which attribute connectors can be connected + * Creation: 27/06/2017 + * @version 1.0 27/06/2017 + * @author Côme Demarigny + */ +public class CAMSConnectingPoint extends TGConnectingPointWidthHeight { + + protected int x, y; // relative cd and center of the point + protected int state; + protected CDElement container; + private boolean free = true; + protected boolean editable= true; + + private int id; + + protected TGConnectingPointGroup cpg; + + public String type, rate, ccpName = "Connection"; + + protected boolean in; + protected boolean out; + + public JDialogCAMSConnectingPoint dialog; + + protected Color myColor; + + protected static final Color IN = Color.gray; + protected static final Color OUT = Color.black; + protected static final Color INOUT = Color.red; + protected static final Color NO = Color.white; + + + protected TGConnector referenceToConnector; + + public CAMSConnectingPoint (CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { + super(_container, _x, _y, _in, _out, _w, _h); + + if (_in) { + if (_out) { + myColor = INOUT; + } else { + myColor = IN; + } + } else { + if (_out) { + myColor = OUT; + } else { + myColor = NO; + } + } + + id = TGComponent.getGeneralId(); + TGComponent.setGeneralId(id + 1); + + } + + public void draw(Graphics g) { + int mx = getX(); + int my = getY(); + g.setColor(myColor); + g.fillRect(mx - width, my - width, width*2, height*2); + GraphicLib.doubleColorRect(g, mx - width, my - width, width*2, height*2, Color.white, Color.black); + } + + public boolean editOndoubleClick(JFrame frame) { + + if(dialog == null){ + dialog = new JDialogCAMSConnectingPoint(frame, "Setting connector attributes", this); + } + dialog.setSize(350, 300); + GraphicLib.centerOnParent(dialog); + dialog.setVisible(true); // blocked until dialog has been closed + + if (!dialog.isRegularClose()) { + return false; + } + return true; + } + + public CAMSConnectingPoint isOnMe(int _x, int _y){ + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; + } + + public String getccpName() { + return ccpName; + } + + public String getPointType() { + return type; + } + + public String getRate() { + return rate; + } + +} //class diff --git a/src/main/java/ui/het/CAMSBlock.java b/src/main/java/ui/het/CAMSBlock.java new file mode 100755 index 0000000000000000000000000000000000000000..39e050638069bfc098057c28166dd3be6bd3dc96 --- /dev/null +++ b/src/main/java/ui/het/CAMSBlock.java @@ -0,0 +1,354 @@ +/* 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. + */ + + + + +package ui.het; + +import myutil.GraphicLib; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import ui.*; +import ui.util.IconManager; +import ui.window.JDialogCAMSBlocks; +import heterogeneoustranslator.systemCAMStranslator.*; + +import javax.swing.*; +import java.awt.*; +import java.util.LinkedList; +import java.util.Vector; + + +/** +* Class CAMSBlock +* Block for SystemC-AMS Diagrams +* Creation: 27/06/2017 +* @version 1.0 27/06/2017 +* @author Côme DEMARIGNY + */ +public class CAMSBlock extends TGComponent { + private int textY1 = 15; + private int textY2 = 30; + private int derivationx = 2; + private int derivationy = 3; + private String stereotype = "block"; + + private int nbOfIn = 0; + private int nbOfOut = 0; + + protected int index = 0; + + private int maxFontSize = 12; + private int minFontSize = 4; + private int currentFontSize = -1; + private boolean displayText = true; + private int textX = 7; + + private int limitName = -1; + private int limitAttr = -1; + private int limitMethod = -1; + + public String name; + public String Value= "Block0"; + private JDialogCAMSBlocks dialog; + + // TAttribute, ProcessCode, CAMSSignal + protected LinkedList<TAttribute> myAttributes; + protected LinkedList<CAMSSignal> mySignals; + protected String [] processCode; + + //Simulation Object + private CAMSBlocks SBlock; + + public CAMSBlock (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); + tdp = _tdp; + width = 250; + height = 200; + minWidth = 150; + minHeight = 100; + + createConnectingPoints(); + + moveable = true; + editable = true; + removable = true; + userResizable = true; + + getBlockName(); + + myImageIcon = IconManager.imgic700; + + if(this.myAttributes == null){this.myAttributes = new LinkedList<TAttribute>();} + if(this.mySignals == null){this.mySignals = new LinkedList<CAMSSignal>();} + + SBlock= new CAMSBlocks(name, nbOfIn, nbOfOut, myAttributes, mySignals, processCode); + } + + public void createConnectingPoints(){ + int i; + double h; + + resetInOut(); + + if(this.mySignals!=null){ + for(i=0;i<mySignals.size();i++){ + if(mySignals.get(i).getInout()==0){ + nbOfIn++; + } else { + nbOfOut++; + } + } + } + + nbConnectingPoint = nbOfIn + nbOfOut; + + connectingPoint = new CAMSConnectingPoint[nbConnectingPoint]; + + for (i = 1; i<= nbOfIn; i++){ + h = i/(nbOfIn + 1.0); + connectingPoint[i-1] = new CAMSConnectingPoint(this, 0, 0, true, false, 0.0, h); + } + + for (i = 1; i<= nbOfOut; i++){ + h = i/(nbOfOut + 1.0); + connectingPoint[i+nbOfIn-1] = new CAMSConnectingPoint(this, 0, 0, false, true, 1.0, h); + } + + addTGConnectingPointsComment(); + } + + public void internalDrawing(Graphics g) { + Color c = g.getColor(); + g.draw3DRect(x, y, width, height, true); + + + // Top lines + g.drawLine(x, y, x + derivationx, y - derivationy); + g.drawLine(x + width, y, x + width + derivationx, y - derivationy); + g.drawLine(x + derivationx, y - derivationy, x + width + derivationx, y - derivationy); + + // Right lines + g.drawLine(x + width, y + height, x + width + derivationx, y - derivationy + height); + g.drawLine(x + derivationx + width, y - derivationy, x + width + derivationx, y - derivationy + height); + + // Filling color + g.setColor(ColorManager.HWA_BOX); + g.fill3DRect(x+1, y+1, width-1, height-1, true); + g.setColor(c); + + // Strings + String ster = "<<" + stereotype + ">>"; + int w = g.getFontMetrics().stringWidth(ster); + Font f = g.getFont(); + g.setFont(f.deriveFont(Font.BOLD)); + g.drawString(ster, x + (width - w)/2, y + textY1); + g.setFont(f); + w = g.getFontMetrics().stringWidth(name); + g.drawString(name, x + (width - w)/2, y + textY2); + + + actionOnAdd(); + } + + public void addSignal(CAMSSignal sig){ + mySignals.add(sig); + } + + public TGComponent isOnOnlyMe(int x1, int y1) { + return null; + } + + public void setState(int _s){ + } + + public TGComponent isOnMe(int _x, int _y){ + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; + } + + public String getStereotype() { + return stereotype; + + } + + public boolean editOndoubleClick(JFrame frame) { + + boolean error = false; + String errors = ""; + int tmp; + String tmpName; + boolean changeMade=false; + + if(dialog ==null){ + dialog = new JDialogCAMSBlocks(this.myAttributes, this.mySignals, null, frame, "Setting Block attributes", "Attributes", this, processCode, true); + } + setJDialogOptions(dialog); + GraphicLib.centerOnParent(dialog, 1050, 700); + dialog.setVisible( true ); // blocked until dialog has been closed + mySignals = dialog.getSignals(); + createConnectingPoints(); + getBlockName(); + setSimulationBlock(); + + + if (error) { + JOptionPane.showMessageDialog(frame, + "Invalid value for the following attributes: " + errors, + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + return true; + } + + + @Override + public void loadExtraParam(NodeList bl, int decX, int decY, int decId) throws MalformedModelingException{ + try { + + NodeList bli; + Node b1, b2; + Element elt; + String sstereotype = null, sblockName = null; + + for(int i=0; i<bl.getLength(); i++) { + b1 = bl.item(i); + //System.out.println(n1); + if (b1.getNodeType() == Node.ELEMENT_NODE) { + bli = b1.getChildNodes(); + for(int j=0; j<bli.getLength(); j++) { + b2 = bli.item(j); + if (b2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) b2; + if (elt.getTagName().equals("info")) { + sstereotype = elt.getAttribute("stereotype"); + sblockName = elt.getAttribute("blockName"); + } + if (sstereotype != null) { + stereotype = sstereotype; + } + if (sblockName != null){ + name = sblockName; + } + + if (elt.getTagName().equals("attributes")) { + + nbOfIn = Integer.decode(elt.getAttribute("nbOfIn")).intValue(); + nbOfOut =Integer.decode(elt.getAttribute("nbOfOut")).intValue(); + + } + } + } + } + } + } catch (Exception e) { + System.out.println("load failure"); + throw new MalformedModelingException(); + } + } + + public void setSimulationBlock(){ + SBlock.setBlockName(name); + SBlock.setNbOfIn(nbOfIn); + SBlock.setNbOfOut(nbOfOut); + SBlock.setMyAttributes(myAttributes); + SBlock.setMySignals(mySignals); + SBlock.setProcessCode(processCode); + } + + protected void setJDialogOptions(JDialogCAMSBlocks _jdab) { + _jdab.addAccess(TAttribute.getStringAccess(TAttribute.PRIVATE)); + _jdab.addAccess(TAttribute.getStringAccess(TAttribute.PUBLIC)); + _jdab.addType(TAttribute.getStringCAMSType(TAttribute.BOOLEAN), true); + _jdab.addType(TAttribute.getStringCAMSType(TAttribute.DOUBLE), true); + _jdab.enableInitialValue(true); + _jdab.enableRTLOTOSKeyword(false); + _jdab.enableJavaKeyword(false); + } + + public String getAttributes() { + String attr = ""; + attr += "Nb of in = " + nbOfIn + "\n"; + attr += "Nb of out = " + nbOfOut + "\n"; + + return attr; + } + + public int getType() { + return TGComponentManager.CAMS_BLOCK; + } + + public boolean hasBlockWithName(){ + return true; + } + + public void getBlockName() { + if(dialog != null) { + name = dialog.getBlockName(); + if (name.length()==0){ + name = tdp.findCAMSBlockName("Block"); + return ; + } + return ; + } + name = Value; + } + + public void resetInOut(){ + nbOfIn = 0; + nbOfOut= 0; + } + + public int getNbOfIn() { + return nbOfIn; + } + + public int getNbOfOut() { + return nbOfOut; + } + + public int getDefaultConnector() { + return TGComponentManager.CAMS_CONNECTOR; + } + +} diff --git a/src/main/java/ui/het/CAMSBlockConnector.java b/src/main/java/ui/het/CAMSBlockConnector.java new file mode 100755 index 0000000000000000000000000000000000000000..36edcd8bc817943e4d5235292b3dd35ee622489c --- /dev/null +++ b/src/main/java/ui/het/CAMSBlockConnector.java @@ -0,0 +1,302 @@ +/* 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. + */ + + + + +package ui.het; + +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import java.awt.*; +import java.awt.geom.Point2D; +import java.util.Vector; + + +/** + * Class SystemCAMSConnectingPoint + * Definition of connecting points on which attribute connectors can be connected + * Creation: 27/06/2017 + * @version 1.0 27/06/2017 + * @author Côme Demarigny + */ +public class CAMSBlockConnector extends TGConnector { + + public CAMSBlockConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, CAMSConnectingPoint _p1, CAMSConnectingPoint _p2, Vector<Point> _listPoint){ + super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); + myImageIcon = IconManager.imgic202; + + name = "connector"; + _p1.setReferenceToConnector( this ); + _p2.setReferenceToConnector( this ); + + } + + public int getType() { + return TGComponentManager.CAMS_CONNECTOR; + } + + protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ + if (Point2D.distance(x1, y1, x2, y2) < GraphicLib.longueur * 1.5) { + g.drawLine(x1, y1, x2, y2); + } else { + GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, x2, y2, true); + } + } + + // protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ + // Point p_one; + // boolean isp1; + // if (getIndexOfLastTGCPointOfConnector() == -1) { + // p_one = new Point(p1.getX(), p1.getY()); + // isp1 = true; + // } else { + // TGComponent tmpc = tgcomponent[getIndexOfLastTGCPointOfConnector()]; + // p_one = new Point(tmpc.getX(), tmpc.getY()); + // isp1 = false; + // } + + // //g.drawLine(x1, y1, x2, y2); + // Color col = g.getColor(); + // int cz = (int)(tdp.getZoom() * c); + // if (isAsynchronous()) { + // g.setColor(Color.WHITE); + // } + // g.fillRect(x2-(cz/2), y2-(cz/2), cz, cz); + // g.fillRect(p1.getX()-(cz/2), p1.getY()-(cz/2), cz, cz); + // g.setColor(col); + // if (isAsynchronous()) { + // g.drawRect(x2-(cz/2), y2-(cz/2), cz, cz); + // g.drawRect(p1.getX()-(cz/2), p1.getY()-(cz/2), cz, cz); + // if (isBlocking()) { + // g.drawLine(x2-(cz/2), y2-(cz/2), x2-(cz/2)+cz, y2-(cz/2)+cz); + // g.drawLine(x2-(cz/2), y2-(cz/2)+cz, x2-(cz/2)+cz, y2-(cz/2)); + // g.drawLine(p1.getX()-(cz/2), p1.getY()+(cz/2), p1.getX()+(cz/2), p1.getY()-(cz/2)); + // g.drawLine(p1.getX()-(cz/2), p1.getY()-(cz/2), p1.getX()+(cz/2), p1.getY()+(cz/2)); + // } + // } + + + // if (!isPrivate() /*&& !isAsynchronous()*/) { + // int czz = (int)(cz*1.4); + // int x3 = p1.getX(); + // int y3 = p1.getY(); + + // Polygon p1 = new Polygon(); + // p1.addPoint(x2-(czz/2)+czz, y2-cz); + // p1.addPoint(x2+(czz/2)+czz, y2-cz); + // p1.addPoint(x2+czz, y2-(2*czz)); + + // Polygon p2 = new Polygon(); + // p2.addPoint(x3-(czz/2)+czz, y3-cz); + // p2.addPoint(x3+(czz/2)+czz, y3-cz); + // p2.addPoint(x3+czz, y3-(2*czz)); + + // // Adding illuminatis sign at the end + // g.setColor(Color.WHITE); + // g.fillPolygon(p1); + // g.fillPolygon(p2); + + // g.setColor(col); + // g.drawPolygon(p1); + // g.drawPolygon(p2); + // g.drawOval(x2+czz-4, y2-cz-7, 8, 6); + // g.drawOval(x3+czz-4, y3-cz-7, 8, 6); + // g.fillOval(x2+czz-2, y2-cz-6, 5, 4); + // g.fillOval(x3+czz-2, y3-cz-6, 5, 4); + + // } + + + // Point p11; + // if (isp1) { + // p11 = GraphicLib.intersectionRectangleSegment(p1.getX()-(cz/2), p1.getY()-(cz/2), cz, cz, x1, y1, x2, y2); + // } else { + // p11 = new Point(p_one.x, p_one.y); + // } + // if (p11 == null) { + // p11 = new Point(p1.getX(), p1.getY()); + // //System.out.println("null point"); + // } + // Point p22 = GraphicLib.intersectionRectangleSegment(x2-(cz/2), y2-(cz/2), cz, cz, x1, y1, x2, y2); + // if (p22 == null) { + // p22 = new Point(p2.getX(), p2.getY()); + // //System.out.println("null point"); + // } + + // g.drawLine(p11.x, p11.y, p22.x, p22.y); + + // Font f = g.getFont(); + // Font fold = f; + // f = f.deriveFont((float)fontSize); + // g.setFont(f); + // int h = - decY; + // int step = fontSize + 1; + // int w; + // String s; + + + // if (((g.getColor() == ColorManager.POINTER_ON_ME_0) && (tdp.getAttributeState() == tdp.PARTIAL)) || (tdp.getAttributeState() == tdp.FULL)) { + // // Signals at origin + // if (inSignalsAtOrigin.size() > 0) { + // //g.drawString("in:", p1.getX() + decX, p1.getY() + h); + // for(String iso: inSignalsAtOrigin) { + // h += step; + // s = getShortName(iso); + // if (p1.getX() <= p2.getX()) { + // g.drawString(s, p1.getX() + decX, p1.getY() + h); + // } else { + // w = g.getFontMetrics().stringWidth(s); + // g.drawString(s, p1.getX() - decX - w, p1.getY() + h); + // } + // } + // } + // if (outSignalsAtOrigin.size() > 0) { + // //h += step; + // //g.drawString("out:", p1.getX() + decX, p1.getY() + h); + // for(String oso: outSignalsAtOrigin) { + // h += step; + // s = getShortName(oso); + // if (p1.getX() <= p2.getX()) { + // g.drawString(s, p1.getX() + decX, p1.getY() + h); + // } else { + // w = g.getFontMetrics().stringWidth(s); + // g.drawString(s, p1.getX() - decX - w, p1.getY() + h); + // } + // } + // } + // // Signals at destination + // h = - decY; + // if (outSignalsAtDestination.size() > 0) { + // //h += step; + // //g.drawString("out:", p2.getX() + decX, p2.getY() + h); + // for(String osd: outSignalsAtDestination) { + // h += step; + // s = getShortName(osd); + // if (p1.getX() > p2.getX()) { + // g.drawString(s, p2.getX() + decX, p2.getY() + h); + // } else { + // w = g.getFontMetrics().stringWidth(s); + // g.drawString(s, p2.getX() - decX - w, p2.getY() + h); + // } + // } + // } + // if (inSignalsAtDestination.size() > 0) { + // //g.drawString("in:", p2.getX() + decX, p2.getY() + h); + // for(String isd: inSignalsAtDestination) { + // h += step; + // s = getShortName(isd); + // if (p1.getX() > p2.getX()) { + // g.drawString(s, p2.getX() + decX, p2.getY() + h); + // } else { + // w = g.getFontMetrics().stringWidth(s); + // g.drawString(s, p2.getX() - decX - w, p2.getY() + h); + // } + // } + // } + // } + + // g.setFont(fold); + + // /*if (value.length() > 0) { + // Font f = g.getFont(); + // if (tdp.getZoom() < 1) { + // Font f0 = f.deriveFont((float)(fontSize*tdp.getZoom())); + // g.setFont(f0); + // } + // g.drawString(value, x2-(cz/2), y2-(cz/2)-1); + // g.setFont(f); + // }*/ + + // // Animation? + // if ((TDiagramPanel.AVATAR_ANIMATE_ON) && (isAsynchronous())){ + // //TraceManager.addDev("anim port connector: " + this); + // String messageInformation[] = tdp.getMGUI().hasMessageInformationForAvatarConnector(this); + // if (messageInformation != null) { + // if (messageInformation[0] != null) { + // g.setColor(Color.BLUE); + // g.drawString(messageInformation[0], p1.getX() + decX, p1.getY()); + // } + // if (messageInformation[1] != null) { + // g.setColor(Color.BLUE); + // g.drawString(messageInformation[1], p2.getX() + decX, p2.getY()); + // } + // g.setColor(Color.BLACK); + // } + // } + // } + + @Override + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro ***"); + try { + + NodeList nli; + Node n1, n2; + Element elt; + //int t1id; + String tmp = null; + + 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(); + + // Issue #17 copy-paste error on j index + for(int j=0; j<nli.getLength(); j++) { + n2 = nli.item(j); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + +} //class diff --git a/src/main/java/ui/het/CAMSBlockDiagramPanel.java b/src/main/java/ui/het/CAMSBlockDiagramPanel.java new file mode 100755 index 0000000000000000000000000000000000000000..b00ae26c6af890492710c3841dc5df1dada4b84c --- /dev/null +++ b/src/main/java/ui/het/CAMSBlockDiagramPanel.java @@ -0,0 +1,217 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille, Andrea Enrici + * + * ludovic.apvrille AT enst.fr + * andrea.enrici 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. + */ + + + + +package ui.het; + + +import myutil.TraceManager; +import org.w3c.dom.Element; +import ui.*; + +import java.util.*; + +/** + * Class CAMSBlockDiagramPanel + * Panel for drawing TML Blocks + * Creation: 26/06/2017 + * @version 1.0 26/06/2017 + * @author Côme DEMARIGNY + */ +public class CAMSBlockDiagramPanel extends TDiagramPanel implements TDPWithAttributes { + + public CAMSBlockDiagramPanel(MainGUI mgui, TToolBar _ttb) { + super(mgui, _ttb); + } + + public void initFromDiplodocus(){ + TGComponentManager.addComponent(100,100,TGComponentManager.CAMS_BLOCK,this); + TGComponentManager.addComponent(600,100,TGComponentManager.CAMS_BLOCK,this); + } + + public boolean actionOnDoubleClick(TGComponent tgc) { + /*if (tgc instanceof TCDTClass) { + TCDTClass t = (TCDTClass)tgc; + return mgui.newTClassName(tp, t.oldValue, t.getValue()); + } else if (tgc instanceof TCDActivityDiagramBox) { + if (tgc.getFather() instanceof TCDTClass) { + mgui.selectTab(tp, tgc.getFather().getValue()); + } else if (tgc.getFather() instanceof TCDTObject) { + TCDTObject to = (TCDTObject)(tgc.getFather()); + TCDTClass t = to.getMasterTClass(); + if (t != null) { + mgui.selectTab(tp, t.getValue()); + } + } + return false; // because no change made on any diagram + }*/ + return false; + } + + public boolean actionOnAdd(TGComponent tgc) { + return false; + } + + public boolean actionOnRemove(TGComponent tgc) { + return false; + } + + public boolean actionOnValueChanged(TGComponent tgc) { + return false; + } + + public void setConnectorsToFront() { + TGComponent tgc; + + //System.out.println("list size=" + componentList.size()); + + Iterator iterator = componentList.listIterator(); + + ArrayList<TGComponent> list = new ArrayList<TGComponent>(); + + while(iterator.hasNext()) { + tgc = (TGComponent)(iterator.next()); + if (!(tgc instanceof TGConnector)) { + list.add(tgc); + } + } + + //System.out.println("Putting to back ..."); + for(TGComponent tgc1: list) { + //System.out.println("Putting to back: " + tgc1); + componentList.remove(tgc1); + componentList.add(tgc1); + } + } + + public String getXMLHead() { + return "<CAMSBlockDiagramPanel name=\"" + name + "\"" + sizeParam() + displayParam() + zoomParam() +" >"; + } + + public String getXMLTail() { + return "</CAMSBlockDiagramPanel>"; + } + + public String getXMLSelectedHead() { + return "<CAMSBlockDiagramPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; + } + + public String getXMLSelectedTail() { + return "</CAMSBlockDiagramPanelCopy>"; + } + + public String getXMLCloneHead() { + return "<CAMSBlockDiagramPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; + } + + public String getXMLCloneTail() { + return "</CAMSBlockDiagramPanelCopy>"; + } + + + + public boolean areAttributesVisible() { + return attributesVisible; + } + + + public boolean areChannelVisible() { + return synchroVisible; + } + + public void setAttributesVisible(boolean b) { + attributesVisible = b; + } + + + public void setChannelVisible(boolean b) { + channelVisible = b; + } + + public String displayParam() { + String s = ""; + if (channelsVisible) { + s += " channels=\"true\""; + } else { + s += " channels=\"false\""; + } + if (eventsVisible) { + s += " events=\"true\""; + } else { + s += " events=\"false\""; + } + if (requestsVisible) { + s += " requests=\"true\""; + } else { + s += " requests=\"false\""; + } + + return s; + } + + public boolean areAllVisible() { + return channelsVisible && eventsVisible && requestsVisible; + } + + public boolean areChannelsVisible() { + return channelsVisible; + } + + public boolean areEventsVisible() { + return eventsVisible; + } + + public boolean areRequestsVisible() { + return requestsVisible; + } + + public void setChannelsVisible(boolean b) { + channelsVisible = b; + } + + public void setEventsVisible(boolean b) { + eventsVisible = b; + } + + public void setRequestsVisible(boolean b) { + requestsVisible = b; + } +} diff --git a/src/main/java/ui/het/CAMSBlockDiagramToolBar.java b/src/main/java/ui/het/CAMSBlockDiagramToolBar.java new file mode 100755 index 0000000000000000000000000000000000000000..993669fd52105317a60f42e93a515ea6a5ac23c3 --- /dev/null +++ b/src/main/java/ui/het/CAMSBlockDiagramToolBar.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. + */ + + + + +package ui.het; + +import ui.MainGUI; +import ui.TGUIAction; +import ui.TToolBar; + +import javax.swing.*; + +/** + * Class TMLTaskDiagramToolBar + * Implements the toolbar to be used in conjunction with the panel of a TMLTask diagram + * Creation: 26/06/2017 + * @version 1.0 26/06/2017 + * @author Côme DEMARIGNY + * @see TMLBlockDiagramToolbar + */ +public class CAMSBlockDiagramToolBar extends TToolBar { + + public CAMSBlockDiagramToolBar(MainGUI _mgui) { + super(_mgui); + + } + + protected void setActive(boolean b) { + mgui.actions[TGUIAction.CAMS_EDIT].setEnabled(b); + mgui.actions[TGUIAction.UML_NOTE].setEnabled(b); + mgui.actions[TGUIAction.CAMS_BLOCK].setEnabled(b); + mgui.actions[TGUIAction.CAMS_CONNECTOR].setEnabled(b); + + mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(true); + mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(true); + mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(true); + + mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b); + mgui.actions[TGUIAction.ACT_ONECLICK_LOTOS_RG].setEnabled(b); + mgui.actions[TGUIAction.ACT_SIMU_SYSTEMC].setEnabled(b); + + mgui.updateZoomInfo(); + } + + protected void setButtons() { + JButton button; + + button = this.add(mgui.actions[TGUIAction.CAMS_EDIT]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.UML_NOTE]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.CAMS_BLOCK]); + button.addMouseListener(mgui.mouseHandler); + + // button = this.add(mgui.actions[TGUIAction.TMLTD_ASSOC]); + // button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.CAMS_CONNECTOR]); + button.addMouseListener(mgui.mouseHandler); + + // this.addSeparator(); + + // button = this.add(mgui.actions[TGUIAction.TMLTD_TASK]); + // button.addMouseListener(mgui.mouseHandler); + + + // this.addSeparator(); + + // button = this.add(mgui.actions[TGUIAction.TMLTD_CHANNEL]); + // button.addMouseListener(mgui.mouseHandler); + + // button = this.add(mgui.actions[TGUIAction.TMLTD_EVENT]); + // button.addMouseListener(mgui.mouseHandler); + + // button = this.add(mgui.actions[TGUIAction.TMLTD_REQ]); + // button.addMouseListener(mgui.mouseHandler); + + + this.addSeparator(); + + // button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_DIPLO_ID]); + // button.addMouseListener(mgui.mouseHandler); + + } + +} // Class + + + + + diff --git a/src/main/java/ui/het/CAMSConnectingPoint.java b/src/main/java/ui/het/CAMSConnectingPoint.java new file mode 100755 index 0000000000000000000000000000000000000000..326efe6677913b409d7f3e19d53c67ae91b49e21 --- /dev/null +++ b/src/main/java/ui/het/CAMSConnectingPoint.java @@ -0,0 +1,149 @@ +/* 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. + */ + + + + +package ui.het; + +import myutil.GraphicLib; +import ui.*; +import ui.window.JDialogCAMSConnectingPoint; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.geom.Point2D; +import javax.swing.*; +import java.util.Vector; + + +/** + * Class SystemCAMSConnectingPoint + * Definition of connecting points on which attribute connectors can be connected + * Creation: 27/06/2017 + * @version 1.0 27/06/2017 + * @author Côme Demarigny + */ +public class CAMSConnectingPoint extends TGConnectingPointWidthHeight { + + protected int x, y; // relative cd and center of the point + protected int state; + protected CDElement container; + private boolean free = true; + protected boolean editable= true; + + private int id; + + protected TGConnectingPointGroup cpg; + + public String type, rate, ccpName = "Connection"; + + protected boolean in; + protected boolean out; + + public JDialogCAMSConnectingPoint dialog; + + protected Color myColor; + + protected static final Color IN = Color.gray; + protected static final Color OUT = Color.black; + protected static final Color INOUT = Color.red; + protected static final Color NO = Color.white; + + + protected TGConnector referenceToConnector; + + public CAMSConnectingPoint (CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { + super(_container, _x, _y, _in, _out, _w, _h); + + if (_in) { + if (_out) { + myColor = INOUT; + } else { + myColor = IN; + } + } else { + if (_out) { + myColor = OUT; + } else { + myColor = NO; + } + } + + id = TGComponent.getGeneralId(); + TGComponent.setGeneralId(id + 1); + + } + + public void draw(Graphics g) { + int mx = getX(); + int my = getY(); + g.setColor(myColor); + g.fillRect(mx - width, my - width, width*2, height*2); + GraphicLib.doubleColorRect(g, mx - width, my - width, width*2, height*2, Color.white, Color.black); + } + + public boolean editOndoubleClick(JFrame frame) { + + if(dialog == null){ + dialog = new JDialogCAMSConnectingPoint(frame, "Setting connector attributes", this); + } + dialog.setSize(350, 300); + GraphicLib.centerOnParent(dialog); + dialog.setVisible(true); // blocked until dialog has been closed + + if (!dialog.isRegularClose()) { + return false; + } + return true; + } + + public String getccpName() { + return ccpName; + } + + public String getPointType() { + return type; + } + + public String getRate() { + return rate; + } + +} //class diff --git a/src/main/java/ui/tmldd/TMLArchiCAMSNode.java b/src/main/java/ui/tmldd/TMLArchiCAMSNode.java new file mode 100755 index 0000000000000000000000000000000000000000..0795ccc507b311547ae7d31dc736ef27409e8056 --- /dev/null +++ b/src/main/java/ui/tmldd/TMLArchiCAMSNode.java @@ -0,0 +1,405 @@ +/* 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. + */ + + + + +package ui.tmldd; + +import myutil.GraphicLib; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import tmltranslator.HwCPU; +import ui.*; +import ui.het.*; +import ui.util.IconManager; + +import javax.swing.*; +import java.awt.*; +import java.util.Vector; + +/** + * Class TMLArchiCAMSNode + * System C-AMS Node. To be used in TML architecture diagrams. + * Creation: 06/09/2017 + * @version 1.0 06/09/2017 + * @author Côme DEMARIGNY + */ +public class TMLArchiCAMSNode extends TMLArchiNode implements SwallowTGComponent, WithAttributes { + private int textY1 = 15; + private int textY2 = 30; + private int derivationx = 2; + private int derivationy = 3; + private String stereotype = "CAMS"; + + private int byteDataSize = HwCPU.DEFAULT_BYTE_DATA_SIZE; + private int execiTime = HwCPU.DEFAULT_EXECI_TIME; + + private CAMSBlockDiagramPanel cbdp; + + + public TMLArchiCAMSNode(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 = 200; + height = 200; + minWidth = 100; + minHeight = 100; + + nbConnectingPoint = 16; + connectingPoint = new TGConnectingPoint[16]; + + connectingPoint[0] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.0, 0.0); + connectingPoint[1] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.5, 0.0); + connectingPoint[2] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 1.0, 0.0); + connectingPoint[3] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.0, 0.5); + connectingPoint[4] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 1.0, 0.5); + connectingPoint[5] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.0, 1.0); + connectingPoint[6] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.5, 1.0); + connectingPoint[7] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 1.0, 1.0); + + connectingPoint[8] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.25, 0.0); + connectingPoint[9] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.75, 0.0); + connectingPoint[10] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.0, 0.25); + connectingPoint[11] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 1.0, 0.25); + connectingPoint[12] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.0, 0.75); + connectingPoint[13] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 1.0, 0.75); + connectingPoint[14] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.25, 1.0); + connectingPoint[15] = new TMLArchiConnectingPoint(this, 0, 0, false, true, 0.75, 1.0); + + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + moveable = true; + editable = true; + removable = true; + userResizable = true; + + name = tdp.findNodeName("CAMS"); + value = "name"; + + myImageIcon = IconManager.imgic700; + } + + public void internalDrawing(Graphics g) { + Color c = g.getColor(); + g.draw3DRect(x, y, width, height, true); + + + // Top lines + g.drawLine(x, y, x + derivationx, y - derivationy); + g.drawLine(x + width, y, x + width + derivationx, y - derivationy); + g.drawLine(x + derivationx, y - derivationy, x + width + derivationx, y - derivationy); + + // Right lines + g.drawLine(x + width, y + height, x + width + derivationx, y - derivationy + height); + g.drawLine(x + derivationx + width, y - derivationy, x + width + derivationx, y - derivationy + height); + + // Filling color + g.setColor(ColorManager.HWA_BOX); + g.fill3DRect(x+1, y+1, width-1, height-1, true); + g.setColor(c); + + // Strings + String ster = "<<" + stereotype + ">>"; + int w = g.getFontMetrics().stringWidth(ster); + Font f = g.getFont(); + g.setFont(f.deriveFont(Font.BOLD)); + g.drawString(ster, x + (width - w)/2, y + textY1); + g.setFont(f); + w = g.getFontMetrics().stringWidth(name); + g.drawString(name, x + (width - w)/2, y + textY2); + + // Icon + g.drawImage(IconManager.imgic1106.getImage(), x + 4, y + 4, null); + g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + } + + public TGComponent isOnOnlyMe(int x1, int y1) { + + Polygon pol = new Polygon(); + pol.addPoint(x, y); + pol.addPoint(x + derivationx, y - derivationy); + pol.addPoint(x + derivationx + width, y - derivationy); + pol.addPoint(x + derivationx + width, y + height - derivationy); + pol.addPoint(x + width, y + height); + pol.addPoint(x, y + height); + if (pol.contains(x1, y1)) { + return this; + } + + return null; + } + + public String getStereotype() { + return stereotype; + + } + + public String getNodeName() { + return name; + } + + public boolean editOndoubleClick(JFrame frame) { + if ( cbdp == null){ + MainGUI mgui = tdp.getMainGUI(); + cbdp = mgui.addSystemCAMSPanel("System C-AMS Deployment of DIPLODOCUS Node", -1, this); + cbdp.setVisible(true); + cbdp.initFromDiplodocus(); + + } + return true; + } + + // boolean error = false; + // String errors = ""; + // int tmp; + // String tmpName; + + // JDialogHwANode dialog = new JDialogHwANode(frame, "Setting HWA attributes", this); + // // dialog.setSize(500, 450); + // GraphicLib.centerOnParent(dialog, 500, 450); + // dialog.setVisible( true ); // blocked until dialog has been closed + + // if (!dialog.isRegularClose()) { + // return false; + // } + + // if (dialog.getNodeName().length() != 0) { + // tmpName = dialog.getNodeName(); + // tmpName = tmpName.trim(); + // if (!TAttribute.isAValidId(tmpName, false, false)) { + // error = true; + // errors += "Name of the node "; + // } else { + // name = tmpName; + // } + // } + + // if (dialog.getByteDataSize().length() != 0) { + // try { + // tmp = byteDataSize; + // byteDataSize = Integer.decode(dialog.getByteDataSize()).intValue(); + // if (byteDataSize <= 0) { + // byteDataSize = tmp; + // error = true; + // errors += "Data size "; + // } + // } catch (Exception e) { + // error = true; + // errors += "Data size "; + // } + // } + + // if (dialog.getExeciTime().length() != 0) { + // try { + // tmp = execiTime; + // execiTime = Integer.decode(dialog.getExeciTime()).intValue(); + // if (execiTime < 0) { + // execiTime = tmp; + // error = true; + // errors += "execi time "; + // } + // } catch (Exception e) { + // error = true; + // errors += "execi time "; + // } + // } + + // if (dialog.getClockRatio().length() != 0) { + // try { + // tmp = clockRatio; + // clockRatio = Integer.decode(dialog.getClockRatio()).intValue(); + // if (clockRatio <= 0) { + // clockRatio = tmp; + // error = true; + // errors += "Clock divider "; + // } + // } catch (Exception e) { + // error = true; + // errors += "Clock divider "; + // } + // } + + // if (error) { + // JOptionPane.showMessageDialog(frame, + // "Invalid value for the following attributes: " + errors, + // "Error", + // JOptionPane.INFORMATION_MESSAGE); + // return false; + // } + + // return true; + // } + + + public int getType() { + return TGComponentManager.TMLARCHI_CAMSNODE; + } + + public boolean acceptSwallowedTGComponent(TGComponent tgc) { + return (tgc instanceof TMLArchiArtifact) && (nbInternalTGComponent == 0); + + } + + public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { + if ((tgc instanceof TMLArchiArtifact) && (nbInternalTGComponent == 0)){ + tgc.setFather(this); + tgc.setDrawingZone(true); + tgc.resizeWithFather(); + addInternalComponent(tgc, 0); + return true; + } + + return false; + } + + public void removeSwallowedTGComponent(TGComponent tgc) { + removeInternalComponent(tgc); + } + + + public Vector<TMLArchiArtifact> getArtifactList() { + Vector<TMLArchiArtifact> v = new Vector<TMLArchiArtifact>(); + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof TMLArchiArtifact) { + v.add( (TMLArchiArtifact) tgcomponent[i]); + } + } + + return v; + } + + public void hasBeenResized() { + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof TMLArchiArtifact) { + tgcomponent[i].resizeWithFather(); + } + } + + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<info stereotype=\"" + stereotype + "\" nodeName=\"" + name); + sb.append("\" />\n"); + sb.append("<attributes byteDataSize=\"" + byteDataSize + "\" "); + sb.append(" execiTime=\"" + execiTime + "\" "); + sb.append(" clockRatio=\"" + clockRatio + "\" "); + sb.append("/>\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + @Override + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro ***"); + try { + + NodeList nli; + Node n1, n2; + Element elt; + // int t1id; + String sstereotype = null, snodeName = null; + + 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; j<nli.getLength(); j++) { + n2 = nli.item(j); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("info")) { + sstereotype = elt.getAttribute("stereotype"); + snodeName = elt.getAttribute("nodeName"); + } + if (sstereotype != null) { + stereotype = sstereotype; + } + if (snodeName != null){ + name = snodeName; + } + + if (elt.getTagName().equals("attributes")) { + byteDataSize = Integer.decode(elt.getAttribute("byteDataSize")).intValue(); + execiTime = Integer.decode(elt.getAttribute("execiTime")).intValue(); + if ((elt.getAttribute("clockRatio") != null) && (elt.getAttribute("clockRatio").length() > 0)){ + clockRatio = Integer.decode(elt.getAttribute("clockRatio")).intValue(); + } + } + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + public int getDefaultConnector() { + return TGComponentManager.CONNECTOR_NODE_TMLARCHI; + } + + public int getByteDataSize(){ + return byteDataSize; + } + + public int getExeciTime(){ + return execiTime; + } + + + public String getAttributes() { + String attr = ""; + attr += "Data size (in byte) = " + byteDataSize + "\n"; + attr += "Execi execution time (in cycle) = " + execiTime + "\n"; + attr += "Clock divider = " + clockRatio + "\n"; + return attr; + } + + public int getComponentType() { + return CONTROLLER; + } + +} diff --git a/src/main/java/ui/window/JDialogCAMSBlocks.java b/src/main/java/ui/window/JDialogCAMSBlocks.java new file mode 100755 index 0000000000000000000000000000000000000000..7ca2bce390de7a8508009c3f8aab87be4c836ff5 --- /dev/null +++ b/src/main/java/ui/window/JDialogCAMSBlocks.java @@ -0,0 +1,840 @@ +/* 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. + */ + + + + +package ui.window; + +import myutil.Conversion; +import myutil.GraphicLib; +import ui.util.IconManager; +import ui.TGComponent; +import ui.het.CAMSBlock; +import heterogeneoustranslator.systemCAMStranslator.CAMSSignal; +import ui.TAttribute; +import ui.TDiagramPanel; + +import javax.swing.*; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Vector; +import java.util.LinkedList; + + +/** + * Class JDialogCAMSBlocks + * Dialog for managing nodes to be validated + * Creation: 23/06/2017 + * @version 0.1 23/06/2017 + * @author Côme DEMARIGNY + */ + +public class JDialogCAMSBlocks extends javax.swing.JDialog implements ActionListener, ListSelectionListener { + + private LinkedList<TAttribute> attributes, attributesPar, forbidden; + private LinkedList<Boolean> initValues; + private LinkedList<CAMSSignal> signals, signalsPar; + private boolean checkKeyword, checkJavaKeyword; + + private boolean cancelled = false; + private boolean regularClose; + + protected String [] processCode; + protected JTextArea jtaProcessCode; + protected boolean hasProcessCode; + + private JPanel panel1, panel2; + + private TDiagramPanel tdp; + private Frame frame; + private int tab; + private String defaultName; + private String previousName; + + private String attrib; // "Attributes", "Gates", etc. + + // Panel1 + private JComboBox<String> accessBox, typeBox; + private JTextField identifierText; + private JTextField initialValue; + private JTextField blockName; + private JButton addButton; + + //Panel2 + private JList<TAttribute> listAttribute; + private JTextField nbOfIn, nbOfOut; + private CAMSBlock block; + private JButton upButton; + private JButton downButton; + private JButton removeButton; + + + // Signals + private boolean hasSignals = true; + private JPanel panel5, panel6; + private JComboBox<String> signalInOutBox; + private JTextField signalText; + private JButton addSignalButton; + private JList<CAMSSignal> listSignal; + private JButton upSignalButton; + private JButton downSignalButton; + private JButton removeSignalButton; + + // Main Panel + private JButton closeButton; + private JButton cancelButton; + + /** Creates new form */ + public JDialogCAMSBlocks(LinkedList<TAttribute> _attributes, LinkedList<CAMSSignal> _signals, LinkedList<TAttribute> _forbidden, Frame _frame, String _title, String _attrib, CAMSBlock _block, String []_processCode, boolean _hasProcessCode) { + super(_frame, _title, true); + frame = _frame; + block = _block; + attributesPar = _attributes; + signalsPar = _signals; + processCode = _processCode; + attrib = _attrib; + + if (signalsPar == null) { + signalsPar = new LinkedList<CAMSSignal> (); + hasSignals = false; + } + + hasProcessCode = _hasProcessCode; + if (processCode == null) { + processCode = new String[1]; + processCode[0] = ""; + } + + + forbidden = _forbidden; + initValues = new LinkedList<Boolean> (); + this.attrib = attrib; + + attributes = new LinkedList<TAttribute> (); + signals = new LinkedList<CAMSSignal> (); + + for(TAttribute attr: this.attributesPar) + this.attributes.add (attr.makeClone()); + + // for(CAMSSignal sig: this.signalsPar) + // this.signals.add (sig.makeClone()); + pack(); + initComponents(); + myInitComponents(); + pack(); + } + + + private void myInitComponents() { + removeButton.setEnabled(false); + upButton.setEnabled(false); + downButton.setEnabled(false); + } + + private void initComponents() { + + // Issue #41 Ordering of tabbed panes + JTabbedPane tabbedPane = GraphicLib.createTabbedPane();//new JTabbedPane(); + Container c = getContentPane(); + + JPanel panelAttr = new JPanel(new BorderLayout()); + JPanel panelSignal = new JPanel(new BorderLayout()); + JPanel panelCode; + GridBagLayout gridbag0 = new GridBagLayout(); + GridBagLayout gridbag1 = new GridBagLayout(); + GridBagLayout gridbag2 = new GridBagLayout(); + // GridBagLayout gridbag3 = new GridBagLayout(); + // GridBagLayout gridbag4 = new GridBagLayout(); + GridBagLayout gridbag5 = new GridBagLayout(); + GridBagLayout gridbag6 = new GridBagLayout(); + GridBagLayout gridbag7 = new GridBagLayout(); + GridBagConstraints c0 = new GridBagConstraints(); + GridBagConstraints c1 = new GridBagConstraints(); + GridBagConstraints c2 = new GridBagConstraints(); + // GridBagConstraints c3 = new GridBagConstraints(); + // GridBagConstraints c4 = new GridBagConstraints(); + GridBagConstraints c5 = new GridBagConstraints(); + GridBagConstraints c6 = new GridBagConstraints(); + GridBagConstraints c7 = 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("Adding " + attrib)); + panel1.setPreferredSize(new Dimension(500, 500)); + panel1.setMinimumSize(new Dimension(500, 500)); + + panel2 = new JPanel(); + panel2.setLayout(gridbag2); + panel2.setBorder(new javax.swing.border.TitledBorder("Managing " + attrib)); + panel2.setPreferredSize(new Dimension(500, 500)); + panel2.setMinimumSize(new Dimension(500, 500)); + + // 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("Block Name: "), c1); + blockName = new JTextField(); + blockName.setColumns(5); + blockName.setEditable(true); + panel1.add(blockName, c1); + + c1.gridwidth = 1; + c1.gridheight = 1; + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.anchor = GridBagConstraints.CENTER; + panel1.add(new JLabel("access"), c1); + panel1.add(new JLabel("identifier"), c1); + if (attrib.equals("Attribute") || attrib.equals("Variable")) { + panel1.add(new JLabel(" "), c1); + panel1.add(new JLabel("initial value"), c1); + } + panel1.add(new JLabel(" "), c1); + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + panel1.add(new JLabel("type"), c1); + + // second line panel1 + c1.gridwidth = 2; + c1.fill = GridBagConstraints.HORIZONTAL; + c1.anchor = GridBagConstraints.CENTER; + accessBox = new JComboBox<String>(); + panel1.add(accessBox, c1); + identifierText = new JTextField(); + identifierText.setColumns(15); + identifierText.setEditable(true); + panel1.add(identifierText, c1); + + initialValue = new JTextField(); + initialValue.setColumns(5); + initialValue.setEditable(true); + + if (attrib.equals("Attribute") || attrib.equals("Variable")) { + panel1.add(new JLabel(" = "), c1); + panel1.add(initialValue, c1); + } + + panel1.add(new JLabel(" : "), c1); + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + typeBox = new JComboBox<String>(); + typeBox.addActionListener(this); + panel1.add(typeBox, c1); + + // third line panel1 + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + c1.fill = GridBagConstraints.BOTH; + c1.gridheight = 3; + panel1.add(new JLabel(" "), c1); + + // fourth line panel1 + c1.gridheight = 1; + c1.fill = GridBagConstraints.HORIZONTAL; + addButton = new JButton("Add / Modify " + attrib); + addButton.addActionListener(this); + panel1.add(addButton, c1); + + // 1st line panel2 + listAttribute = new JList<TAttribute> (this.attributes.toArray (new TAttribute[0])); + listAttribute.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + listAttribute.addListSelectionListener(this); //fixme + JScrollPane scrollPane = new JScrollPane(listAttribute); + scrollPane.setSize(500, 500); + c2.gridwidth = 2; //end row + c2.fill = GridBagConstraints.BOTH; + c2.gridheight = 5; + c2.weighty = 10.0; + c2.weightx = 10.0; + panel2.add(scrollPane, c2); + + // 2nd line panel2 + c2.weighty = 1.0; + c2.weightx = 1.0; + c2.fill = GridBagConstraints.BOTH; + c2.gridheight = 1; + panel2.add(new JLabel(""), c2); + + // third line panel2 + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + c2.fill = GridBagConstraints.HORIZONTAL; + upButton = new JButton(" Up "); + upButton.addActionListener(this); + panel2.add(upButton, c2); + + downButton = new JButton("Down"); + downButton.addActionListener(this); + panel2.add(downButton, c2); + + removeButton = new JButton("Remove " + attrib); + removeButton.addActionListener(this); + panel2.add(removeButton, c2); + + // Signals + panel5 = new JPanel(); + panel5.setLayout(gridbag5); + panel5.setBorder(new javax.swing.border.TitledBorder("Adding signals")); + panel5.setPreferredSize(new Dimension(500, 500)); + + panel6 = new JPanel(); + panel6.setLayout(gridbag6); + panel6.setBorder(new javax.swing.border.TitledBorder("Managing signals")); + panel6.setPreferredSize(new Dimension(500, 500)); + + // first line panel5 + c5.gridwidth = 1; + c5.gridheight = 1; + c5.weighty = 1.0; + c5.weightx = 1.0; + c5.gridwidth = GridBagConstraints.REMAINDER; //end row + c5.fill = GridBagConstraints.BOTH; + c5.gridheight = 3; + panel5.add(new JLabel(" "), c5); + + c5.gridwidth = 1; + c5.gridheight = 1; + c5.weighty = 1.0; + c5.weightx = 1.0; + c5.anchor = GridBagConstraints.CENTER; + c5.gridwidth = GridBagConstraints.REMAINDER; //end row + panel5.add(new JLabel("signal:"), c5); + + // second line panel5 + c5.gridwidth = 1; + c5.fill = GridBagConstraints.HORIZONTAL; + String[] v = new String[2]; + v[0] = "in"; + v[1] = "out"; + signalInOutBox = new JComboBox<String>(v); + panel5.add(signalInOutBox, c5); + signalText = new JTextField(); + signalText.setColumns(50); + signalText.setEditable(true); + panel5.add(signalText, c5); + + // third line panel5 + c5.gridwidth = GridBagConstraints.REMAINDER; //end row + c5.fill = GridBagConstraints.BOTH; + c5.gridheight = 3; + panel5.add(new JLabel(" "), c5); + + // fourth line panel5 + c5.gridheight = 1; + c5.fill = GridBagConstraints.HORIZONTAL; + addSignalButton = new JButton("Add signal"); + addSignalButton.addActionListener(this); + panel5.add(addSignalButton, c5); + + // 1st line panel6 + listSignal = new JList<CAMSSignal> (this.signals.toArray (new CAMSSignal[0])); + listSignal.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + listSignal.addListSelectionListener(this); + scrollPane = new JScrollPane(listSignal); + scrollPane.setSize(500, 500); + c6.gridwidth = GridBagConstraints.REMAINDER; //end row + c6.fill = GridBagConstraints.BOTH; + c6.gridheight = 5; + c6.weighty = 10.0; + c6.weightx = 10.0; + panel6.add(scrollPane, c6); + + // 2nd line panel4 + c6.weighty = 1.0; + c6.weightx = 1.0; + c6.fill = GridBagConstraints.BOTH; + c6.gridheight = 1; + panel6.add(new JLabel(""), c6); + + // third line panel4 + c6.gridwidth = GridBagConstraints.REMAINDER; //end row + c6.fill = GridBagConstraints.HORIZONTAL; + upSignalButton = new JButton("Up"); + upSignalButton.addActionListener(this); + panel6.add(upSignalButton, c6); + + downSignalButton = new JButton("Down"); + downSignalButton.addActionListener(this); + panel6.add(downSignalButton, c6); + + removeSignalButton = new JButton("Remove signal"); + removeSignalButton.addActionListener(this); + panel6.add(removeSignalButton, c6); + + // Prototyping + panelCode = new JPanel(); + panelCode.setLayout(gridbag7); + + panelCode.setBorder(new javax.swing.border.TitledBorder("Process code")); + // guard + c7.weighty = 1.0; + c7.weightx = 1.0; + c7.gridwidth = 1; + c7.gridheight = 1; + c7.fill = GridBagConstraints.BOTH; + c7.gridwidth = GridBagConstraints.REMAINDER; + c7.gridheight = 1; + + + panelCode.add(new JLabel("Process code of block:"), c7); + //panelCode.add(new JLabel("To implement a method m of block B: \"userImplemented_B_m(...){...}\""), c7); + jtaProcessCode = new JTextArea(); + jtaProcessCode.setEditable(true); + jtaProcessCode.setMargin(new Insets(10, 10, 10, 10)); + jtaProcessCode.setTabSize(3); + String files = ""; + if (processCode != null) { + for(int i=0; i<processCode.length; i++) { + files += processCode[i] + "\n"; + } + } + jtaProcessCode.append(files); + jtaProcessCode.setFont(new Font("times", Font.PLAIN, 12)); + JScrollPane jsp = new JScrollPane(jtaProcessCode, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + jsp.setPreferredSize(new Dimension(500, 500)); + panelCode.add(jsp, c7); + + + // main panel; + panelAttr.add(panel1, BorderLayout.WEST); + panelAttr.add(panel2, BorderLayout.EAST); + tabbedPane.addTab("Attributes", panelAttr); + + if (hasSignals) { + panelSignal.add(panel5, BorderLayout.WEST); + panelSignal.add(panel6, BorderLayout.EAST); + tabbedPane.addTab("Signals", panelSignal); + } + + if (hasProcessCode) { + tabbedPane.addTab("Process", panelCode); + } + + tabbedPane.setSelectedIndex(tab); + + //c.add(panel1, c0); + //c.add(panel2, c0); + + c0.gridwidth = 1; + c0.gridheight = 10; + c0.weighty = 1.0; + c0.weightx = 1.0; + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + c0.fill = GridBagConstraints.HORIZONTAL; + c.add(tabbedPane, c0); + + c0.gridwidth = 1; + c0.gridheight = 1; + c0.fill = GridBagConstraints.HORIZONTAL; + closeButton = new JButton("Save and Close", IconManager.imgic25); + //closeButton.setPreferredSize(new Dimension(600, 50)); + 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) { + if (evt.getSource() == typeBox) { + boolean b = initValues.get (typeBox.getSelectedIndex()).booleanValue(); + initialValue.setEnabled(b); + return; + } + + + //String command = evt.getActionCommand(); + + // Compare the action command to the known actions. + if (evt.getSource() == closeButton) { + closeDialog(); + } else if (evt.getSource() == addButton) { + addAttribute(); + } else if (evt.getSource() == cancelButton) { + cancelDialog(); + } else if (evt.getSource() == removeButton) { + removeAttribute(); + } else if (evt.getSource() == downButton) { + downAttribute(); + } else if (evt.getSource() == upButton) { + upAttribute(); + } else if (evt.getSource() == downSignalButton) { + downSignal(); + } else if (evt.getSource() == upSignalButton) { + upSignal(); + } else if (evt.getSource() == removeSignalButton) { + removeSignal(); + } else if (evt.getSource() == addSignalButton) { + addSignal(); + } + } + + public void addAccess(String s) { + accessBox.addItem(s); + } + + public void addType(String s) { + initValues.add(new Boolean(true)); + typeBox.addItem(s); + } + + public void addType(String s, boolean b) { + initValues.add(new Boolean(b)); + typeBox.addItem(s); + } + + public void enableInitialValue(boolean b) { + initialValue.setEnabled(b); + } + + public void enableRTLOTOSKeyword(boolean b) { + checkKeyword = !b; + } + + public void enableJavaKeyword(boolean b) { + checkJavaKeyword = !b; + } + + + + public void addAttribute() { + Object o1 = accessBox.getSelectedItem(); + Object o2 = typeBox.getSelectedItem(); + String s = identifierText.getText(); + String value = initialValue.getText(); + TAttribute a; + + if (s.length()>0) { + if ((TAttribute.isAValidId(s, checkKeyword, checkJavaKeyword)) && (TAttribute.notIn(s, forbidden))){ + int i = TAttribute.getAccess(o1.toString()); + int j = TAttribute.getCAMSType(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)) { + JOptionPane.showMessageDialog(frame, + "The initial value is not valid", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return; + } + } + if (j == TAttribute.OTHER) { + a = new TAttribute(i, s, value, o2.toString()); + a.isCAMS = true; + //System.out.println("New attribute: " + o2.toString()); + } else { + a = new TAttribute(i, s, value, j); + a.isCAMS = true; + } + //checks whether the same attribute already belongs to the list + int index = attributes.size(); + if (attributes.contains(a)) { + index = attributes.indexOf(a); + a = attributes.get (index); + a.setAccess(i); + if (j == TAttribute.OTHER) { + a.setTypeOther(o2.toString()); + } + a.setType(j); + a.setInitialValue(value); + } else { + attributes.add(index, a); + } + listAttribute.setListData(attributes.toArray (new TAttribute[0])); + identifierText.setText(""); + } else { + JOptionPane.showMessageDialog(frame, + "Bad access / type", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return; + } + } else { + JOptionPane.showMessageDialog(frame, + "Bad identifier: identifier already in use, or invalid identifier", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return; + } + } else { + JOptionPane.showMessageDialog(frame, + "Bad identifier", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return; + } + } + + + public void addSignal() { + String s = signalText.getText(); + CAMSSignal cs = CAMSSignal.isAValidSignal(s, signalInOutBox.getSelectedIndex()); + CAMSSignal cstmp; + int inout; + + if (cs != null) { + // Checks whether the same signal already belongs to the list + int index = -1; + for(int i=0; i<signals.size(); i++) { + cstmp = signals.get(i); + // Same id? + if (cstmp.equals(cs)) { + index = i; + break; + } + } + if(signalInOutBox.getSelectedIndex()==0){ + inout=0; + }else if(signalInOutBox.getSelectedIndex()==1){ + inout=1; + }else{ + inout=-1; + } + cs = new CAMSSignal(s,inout); + if (index == -1) { + signals.add(cs); + } else { + signals.remove (index); + signals.add (index, cs); + } + listSignal.setListData(signals.toArray (new CAMSSignal[0])); + signalText.setText(""); + + } else { + JOptionPane.showMessageDialog(frame, + "Badly formatted signal declaration", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return; + } + } + + public void removeAttribute() { + int i = listAttribute.getSelectedIndex() ; + if (i!= -1) { + TAttribute a = attributes.get (i); + a.setAccess(-1); + attributes.remove (i); + listAttribute.setListData(attributes.toArray (new TAttribute[0])); + } + } + + public void downAttribute() { + int i = listAttribute.getSelectedIndex(); + if ((i!= -1) && (i != attributes.size() - 1)) { + TAttribute o = attributes.get (i); + attributes.remove (i); + attributes.add (i+1, o); + listAttribute.setListData(attributes.toArray (new TAttribute[0])); + listAttribute.setSelectedIndex(i+1); + } + } + + public void upAttribute() { + int i = listAttribute.getSelectedIndex(); + if (i > 0) { + TAttribute o = attributes.get (i); + attributes.remove (i); + attributes.add (i-1, o); + listAttribute.setListData(attributes.toArray (new TAttribute[0])); + listAttribute.setSelectedIndex(i-1); + } + } + + public void removeSignal() { + int i = listSignal.getSelectedIndex() ; + if (i!= -1) { + signals.remove (i); + listSignal.setListData(signals.toArray (new CAMSSignal [0])); + } + } + + public void upSignal() { + int i = listSignal.getSelectedIndex(); + if (i > 0) { + CAMSSignal o = signals.get (i); + signals.remove (i); + signals.add (i-1, o); + listSignal.setListData(signals.toArray (new CAMSSignal [0])); + listSignal.setSelectedIndex(i-1); + } + } + + public void downSignal() { + int i = listSignal.getSelectedIndex(); + if ((i!= -1) && (i != signals.size() - 1)) { + CAMSSignal o = signals.get (i); + signals.remove(i); + signals.add (i+1, o); + listSignal.setListData(signals.toArray (new CAMSSignal [0])); + listSignal.setSelectedIndex(i+1); + } + } + + + public void closeDialog() { + cancelled = false; + attributesPar.clear (); + for(TAttribute attr: this.attributes) + attributesPar.add (attr); + + signalsPar.clear (); + for(CAMSSignal sig: this.signals) + signalsPar.add (sig); + + processCode = Conversion.wrapText(jtaProcessCode.getText()); + dispose(); + } + + public boolean hasBeenCancelled() { + return cancelled; + } + + public boolean isRegularClose() { + return regularClose; + } + + public void cancelDialog() { + cancelled = true; + dispose(); + } + + public void valueChanged(ListSelectionEvent e) { + int i = listAttribute.getSelectedIndex() ; + if (i == -1) { + removeButton.setEnabled(false); + upButton.setEnabled(false); + downButton.setEnabled(false); + identifierText.setText(""); + //initialValue.setText(""); + } else { + TAttribute a = attributes.get (i); + identifierText.setText(a.getId()); + initialValue.setText(a.getInitialValue()); + select(accessBox, TAttribute.getStringAccess(a.getAccess())); + if (a.getType() == TAttribute.OTHER) { + select(typeBox, a.getTypeOther()); + } else { + //select(typeBox, TAttribute.getStringCAMSType(a.getType())); //fixme + } + removeButton.setEnabled(true); + if (i > 0) { + upButton.setEnabled(true); + } else { + upButton.setEnabled(false); + } + if (i != attributes.size() - 1) { + downButton.setEnabled(true); + } else { + downButton.setEnabled(false); + } + } + + i = listSignal.getSelectedIndex() ; + if (i == -1) { + removeSignalButton.setEnabled(false); + upSignalButton.setEnabled(false); + downSignalButton.setEnabled(false); + signalText.setText(""); + //initialValue.setText(""); + } else { + CAMSSignal as = signals.get (i); + //signalText.setText(as.toBasicString()); //fixme + // signalInOutBox.setSelectedIndex(as.getInOut()); + removeSignalButton.setEnabled(true); + if (i > 0) { + upSignalButton.setEnabled(true); + } else { + upSignalButton.setEnabled(false); + } + if (i != signals.size() - 1) { + downSignalButton.setEnabled(true); + } else { + downSignalButton.setEnabled(false); + } + } + } + + public void select(JComboBox<String> jcb, String text) { + String s; + for(int i=0; i<jcb.getItemCount(); i++) { + s = jcb.getItemAt(i); + if (s.equals(text)) { + jcb.setSelectedIndex(i); + return; + } + } + } + + + public String getBlockName() { + if(blockName.getText() == null || blockName.getText() == "" || blockName.getText() == " ") { + return "Block0"; + } else { + return blockName.getText(); + } + } + + public LinkedList<CAMSSignal> getSignals(){ + return signals; + } + + public String[] getProcessCode() { + return processCode; + } + +} diff --git a/src/main/java/ui/window/JDialogCAMSConnectingPoint.java b/src/main/java/ui/window/JDialogCAMSConnectingPoint.java new file mode 100755 index 0000000000000000000000000000000000000000..cb85316df4063c7d07b5a9df519087f3bc304585 --- /dev/null +++ b/src/main/java/ui/window/JDialogCAMSConnectingPoint.java @@ -0,0 +1,211 @@ +/* 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. + */ + + + + +package ui.window; + +import ui.util.IconManager; +import ui.het.*; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +//import javax.swing.event.*; +//import java.util.*; + + +/** +* Class JDialogADDCPUNode +* Dialog for managing attributes of cpu nodes in ADD +* Creation: 02/07/2014 +* @version 1.0 02/07/2014 +* @author Ludovic APVRILLE + */ +public class JDialogCAMSConnectingPoint extends javax.swing.JDialog implements ActionListener { + + private boolean regularClose; + + private JPanel panel2; + private Frame frame; + public CAMSConnectingPoint ccp; + + protected JComboBox<String> tracemode; + private static int selectedTracemode = 0; + + + // Panel1 + protected JTextField ccpName; + + // Panel2 + protected JTextField type, rate; + + // Main Panel + private JButton closeButton; + private JButton cancelButton; + + /** Creates new form */ + public JDialogCAMSConnectingPoint(Frame _frame, String _title, CAMSConnectingPoint _ccp) { + super(_frame, _title, true); + frame = _frame; + ccp = _ccp; + + initComponents(); + myInitComponents(); + pack(); + } + + private void myInitComponents() { + } + + private void initComponents() { + Container c = getContentPane(); + GridBagLayout gridbag0 = new GridBagLayout(); + GridBagLayout gridbag1 = new GridBagLayout(); + GridBagLayout gridbag2 = new GridBagLayout(); + GridBagConstraints c0 = new GridBagConstraints(); + //GridBagConstraints c1 = new GridBagConstraints(); + GridBagConstraints c2 = new GridBagConstraints(); + + setFont(new Font("Helvetica", Font.PLAIN, 14)); + c.setLayout(gridbag0); + + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + + panel2 = new JPanel(); + panel2.setLayout(gridbag2); + panel2.setBorder(new javax.swing.border.TitledBorder("Connecting Point attributes")); + panel2.setPreferredSize(new Dimension(400, 300)); + + c2.gridwidth = 1; + c2.gridheight = 1; + c2.weighty = 1.0; + c2.weightx = 1.0; + c2.fill = GridBagConstraints.HORIZONTAL; + panel2.add(new JLabel("Connecting Point name:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + ccpName = new JTextField(ccp.getccpName(), 30); + ccpName.setEditable(true); + ccpName.setFont(new Font("times", Font.PLAIN, 12)); + panel2.add(ccpName, c2); + + c2.gridwidth = 1; + c2.gridheight = 1; + c2.weighty = 1.0; + c2.weightx = 1.0; + c2.fill = GridBagConstraints.HORIZONTAL; + + + c2.gridwidth = 1; + panel2.add(new JLabel("Type :"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + type = new JTextField(""+ccp.getPointType(), 15); + panel2.add(type, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Rate:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + rate = new JTextField(""+ccp.getRate(), 15); + panel2.add(rate, c2); + + // main panel; + c0.gridheight = 10; + c0.weighty = 1.0; + c0.weightx = 1.0; + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + c.add(panel2, c0); + + c0.gridwidth = 1; + c0.gridheight = 1; + c0.fill = GridBagConstraints.HORIZONTAL; + closeButton = new JButton("Save and Close", IconManager.imgic25); + //closeButton.setPreferredSize(new Dimension(600, 50)); + 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) { + + if (evt.getSource() == tracemode) { + selectedTracemode = tracemode.getSelectedIndex(); + } + + String command = evt.getActionCommand(); + + // Compare the action command to the known actions. + if (command.equals("Save and Close")) { + closeDialog(); + } else if (command.equals("Cancel")) { + cancelDialog(); + } + } + + public void closeDialog() { + regularClose = true; + dispose(); + } + + public void cancelDialog() { + dispose(); + } + + public boolean isRegularClose() { + return regularClose; + } + + public String getccpName() { + return ccpName.getText(); + } + + public String getPointType() { + return type.getText(); + } + + public String getRate() { + return rate.getText(); + } + +}//class \ No newline at end of file diff --git a/src/main/java/ui/window/JDialogSelectSystemCAMSBlock.java b/src/main/java/ui/window/JDialogSelectSystemCAMSBlock.java new file mode 100755 index 0000000000000000000000000000000000000000..824770268fadcfb9d5eccaa3dd8a26e97e8d3b14 --- /dev/null +++ b/src/main/java/ui/window/JDialogSelectSystemCAMSBlock.java @@ -0,0 +1,421 @@ +/* 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. + */ + + + + +package ui.window; + +import myutil.TraceManager; +import ui.util.IconManager; +import ui.TGComponent; +import ui.het.*; + +import javax.swing.*; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Arrays; +import java.util.List; +import java.util.Vector; + + +/** + * Class JDialogSelectSystemCAMSBlock + * Dialog for selecting systemC-AMS blocks + * Creation: 04/07/2017 + * @version 1.0 04/07/2017 + * @author Côme Demarigny + */ +public class JDialogSelectSystemCAMSBlock extends javax.swing.JDialog implements ActionListener, ListSelectionListener { + + public static Vector<TGComponent> validated, ignored; + private static boolean optimized = true; + + private Vector<TGComponent> val, ign, back; //val for validated, ign for ignored + + //subpanels + private JPanel panel1, panel2, panel3, panel4, panel5, panel6; + private JList<TGComponent> listIgnored; + private JList<TGComponent> listValidated; + private JButton allValidated; + private JButton addOneValidated; + private JButton addOneIgnored; + private JButton allIgnored; + protected JCheckBox optimize; + // protected JTextField clockField; + + // Main Panel + private JButton closeButton; + private JButton cancelButton; + + /* Creates new form */ + public JDialogSelectSystemCAMSBlock( Frame f, Vector<TGComponent> _back, List<TGComponent> componentList, String title ) { + super(f, title, true); + + TraceManager.addDev( "Printing list of components: " + Arrays.toString( componentList.toArray()) ); + + back = _back; + if( ( validated == null ) || ( ignored == null ) ) { + val = makeNewVal( componentList ); //componentList must already contain something. + //originally contained in componentList + ign = new Vector<TGComponent>(); //empty + //val and ign are the lists that are printed in the Syntax Analysis window + } + else { + val = validated; //validated and ignored, the public vectors come from the instance of SystemCAMSPanel + ign = ignored; + checkBlock( val, componentList ); + checkBlock( ign, componentList ); + addNewBlock( val, componentList, ign ); + } + + initComponents(); + myInitComponents(); + pack(); + } + + //From componentList, filter out all the elements which are not TMLArchiNode + private Vector<TGComponent> makeNewVal( List<TGComponent> list ) { + + Vector<TGComponent> v = new Vector<TGComponent>(); + TGComponent tgc; + + for( int i = 0; i < list.size(); i++ ) { + tgc = list.get(i); + // System.out.println(tgc); + if (tgc instanceof CAMSBlock) { + v.addElement( tgc ); + } + } + return v; + } + + private void checkBlock( Vector<TGComponent> tobeChecked, List<TGComponent> source ) { + + CAMSBlock block; + + for(int i = 0; i < tobeChecked.size(); i++ ) { + if( tobeChecked.elementAt(i) instanceof CAMSBlock ){ + block = (CAMSBlock) tobeChecked.elementAt(i); + if( !source.contains(block) ) { + tobeChecked.removeElementAt(i); + i--; + } + } + } + } + + public void addNewBlock( Vector<TGComponent> added, List<TGComponent> source, Vector<TGComponent> notSource ) { + + TGComponent tgc; + + for( int i = 0; i < source.size(); i++ ) { + tgc = source.get(i); + if( ( tgc instanceof CAMSBlock ) && ( !added.contains(tgc) ) && ( !notSource.contains(tgc) ) ) { + added.addElement( tgc ); + System.out.println("New element"); + } + } + } + + private void myInitComponents() { + setButtons(); + } + + private void initComponents() { + + Container c = getContentPane(); + GridBagLayout gridbag1 = new GridBagLayout(); + GridBagConstraints c1 = new GridBagConstraints(); + GridBagLayout gridbag2 = new GridBagLayout(); + GridBagConstraints c2 = new GridBagConstraints(); + setFont( new Font( "Helvetica", Font.PLAIN, 14) ); + c.setLayout( new BorderLayout() ); + setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); + + c.setLayout(gridbag2); + c2.weighty = 1.0; + c2.weightx = 1.0; + c2.gridwidth = 1; + c2.fill = GridBagConstraints.HORIZONTAL; + c2.gridheight = 1; + + // ignored list + panel1 = new JPanel(); + panel1.setLayout( new BorderLayout() ); + panel1.setBorder( new javax.swing.border.TitledBorder( "Diagrams ignored" ) ); + listIgnored = new JList<TGComponent>( ign ); + //listIgnored.setPreferredSize(new Dimension(200, 250)); + listIgnored.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION ); + listIgnored.addListSelectionListener( this ); + JScrollPane scrollPane1 = new JScrollPane( listIgnored ); + panel1.add( scrollPane1, BorderLayout.CENTER ); + panel1.setPreferredSize( new Dimension( 200, 250) ); + c.add( panel1, c2); + + + + // central buttons + panel3 = new JPanel(); + panel3.setLayout(gridbag1); + + c1.weighty = 1.0; + c1.weightx = 1.0; + c1.gridwidth = GridBagConstraints.REMAINDER; //end row + c1.fill = GridBagConstraints.HORIZONTAL; + c1.gridheight = 1; + + allValidated = new JButton(IconManager.imgic50); + allValidated.setPreferredSize(new Dimension(50, 25)); + allValidated.addActionListener(this); + allValidated.setActionCommand("allValidated"); + panel3.add(allValidated, c1); + + addOneValidated = new JButton(IconManager.imgic48); + addOneValidated.setPreferredSize(new Dimension(50, 25)); + addOneValidated.addActionListener(this); + addOneValidated.setActionCommand("addOneValidated"); + panel3.add(addOneValidated, c1); + + panel3.add(new JLabel(" "), c1); + + addOneIgnored = new JButton(IconManager.imgic46); + addOneIgnored.addActionListener(this); + addOneIgnored.setPreferredSize(new Dimension(50, 25)); + addOneIgnored.setActionCommand("addOneIgnored"); + panel3.add(addOneIgnored, c1); + + allIgnored = new JButton(IconManager.imgic44); + allIgnored.addActionListener(this); + allIgnored.setPreferredSize(new Dimension(50, 25)); + allIgnored.setActionCommand("allIgnored"); + panel3.add(allIgnored, c1); + + c.add(panel3, c2); + + // validated list + panel2 = new JPanel(); + panel2.setLayout( new BorderLayout() ); + panel2.setBorder( new javax.swing.border.TitledBorder( "Diagrams taken into account" ) ); + listValidated = new JList<TGComponent>( val ); + //listValidated.setPreferredSize(new Dimension(200, 250)); + listValidated.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION ); + listValidated.addListSelectionListener( this ); + JScrollPane scrollPane2 = new JScrollPane( listValidated ); + panel2.add( scrollPane2, BorderLayout.CENTER ); + panel2.setPreferredSize( new Dimension(200, 250) ); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + c.add( panel2, c2 ); + + // main panel; + panel6 = new JPanel(); + panel6.setLayout(new BorderLayout()); + + panel5 = new JPanel(); + /*GridBagLayout gridbag3 = new GridBagLayout(); + GridBagConstraints c3 = new GridBagConstraints(); + panel5.setLayout(gridbag3); + + c3.weighty = 1.0; + c3.weightx = 1.0; + c3.fill = GridBagConstraints.HORIZONTAL; + c3.gridheight = 1; + + c3.gridwidth = GridBagConstraints.REMAINDER; //end row + // optimize = new JCheckBox("Optimize TML specification"); + // optimize.setSelected(optimized); + // panel5.add(optimize, c2); + + c3.gridwidth = 1; //end row + // panel5.add(new JLabel("Master clock (in MHz)"), c2); + // c2.gridwidth = GridBagConstraints.REMAINDER; //end row + // clockField = new JTextField("" + clock); + // panel5.add(clockField, c2);*/ + + panel4 = new JPanel(); + panel4.setLayout(new FlowLayout()); + + closeButton = new JButton("Start Syntax Analysis", IconManager.imgic37); + //closeButton.setPreferredSize(new Dimension(600, 50)); + closeButton.addActionListener(this); + closeButton.setPreferredSize(new Dimension(200, 30)); + + cancelButton = new JButton("Cancel", IconManager.imgic27); + cancelButton.addActionListener(this); + cancelButton.setPreferredSize(new Dimension(200, 30)); + panel4.add(cancelButton); + panel4.add(closeButton); + + panel6.add(panel5, BorderLayout.NORTH); + panel6.add(panel4, BorderLayout.SOUTH); + + c.add(panel6, c2); + + } + + public void actionPerformed( ActionEvent evt ) { + String command = evt.getActionCommand(); + + // Compare the action command to the known actions. + if (command.equals("Start Syntax Analysis")) { + closeDialog(); + } else if (command.equals("Cancel")) { + cancelDialog(); + } else if (command.equals("addOneIgnored")) { + addOneIgnored(); + } else if (command.equals("addOneValidated")) { + addOneValidated(); + } else if (command.equals("allValidated")) { + allValidated(); + } else if (command.equals("allIgnored")) { + allIgnored(); + } + } + + + private void addOneIgnored() { + int [] list = listValidated.getSelectedIndices(); + Vector<TGComponent> v = new Vector<TGComponent>(); + TGComponent o; + for (int i=0; i<list.length; i++){ + o = val.elementAt(list[i]); + ign.addElement(o); + v.addElement(o); + } + + val.removeAll(v); + listIgnored.setListData(ign); + listValidated.setListData(val); + setButtons(); + } + + private void addOneValidated() { + int [] list = listIgnored.getSelectedIndices(); + Vector<TGComponent> v = new Vector<TGComponent>(); + TGComponent o; + + for (int i=0; i<list.length; i++){ + o = ign.elementAt(list[i]); + val.addElement(o); + v.addElement(o); + } + + ign.removeAll(v); + listIgnored.setListData(ign); + listValidated.setListData(val); + setButtons(); + } + + private void allValidated() { + val.addAll(ign); + ign.removeAllElements(); + listIgnored.setListData(ign); + listValidated.setListData(val); + setButtons(); + } + + private void allIgnored() { + ign.addAll(val); + val.removeAllElements(); + listIgnored.setListData(ign); + listValidated.setListData(val); + setButtons(); + } + + + public void closeDialog() { + + back.removeAllElements(); + + for( int i = 0; i < val.size(); i++ ) { + back.addElement( val.elementAt(i) ); + } + validated = val; + ignored = ign; + dispose(); + } + + public void cancelDialog() { + dispose(); + } + + private void setButtons() { + int i1 = listIgnored.getSelectedIndex(); + int i2 = listValidated.getSelectedIndex(); + + if (i1 == -1) { + addOneValidated.setEnabled(false); + } else { + addOneValidated.setEnabled(true); + //listValidated.clearSelection(); + } + + if (i2 == -1) { + addOneIgnored.setEnabled(false); + } else { + addOneIgnored.setEnabled(true); + //listIgnored.clearSelection(); + } + + if (ign.size() ==0) { + allValidated.setEnabled(false); + } else { + allValidated.setEnabled(true); + } + + if (val.size() ==0) { + allIgnored.setEnabled(false); + closeButton.setEnabled(false); + } else { + allIgnored.setEnabled(true); + closeButton.setEnabled(true); + } + } + + public void valueChanged(ListSelectionEvent e) { + setButtons(); + } + + public boolean getOptimize() { + return optimized; + } +}