From 84004225c2a5fcb13977d69d58ca30973a31acd6 Mon Sep 17 00:00:00 2001 From: apvrille <ludovic.apvrille@eurecom.fr> Date: Tue, 15 May 2018 14:07:15 +0200 Subject: [PATCH] Revert ":Revert "Removing files"" This reverts commit 9342b4264e2977fde1f1f3dafe1dcde921e0ce55. --- .idea/misc.xml | 2 +- doc/config.xml | 54 + .../SysCAMSSpecification.java | 150 ++ .../syscamstranslator/SysCAMSTBlockDE.java | 72 + .../syscamstranslator/SysCAMSTBlockTDF.java | 82 ++ .../syscamstranslator/SysCAMSTCluster.java | 63 + .../syscamstranslator/SysCAMSTComponent.java | 58 + .../SysCAMSTPortConverter.java | 112 ++ .../syscamstranslator/SysCAMSTPortDE.java | 112 ++ .../syscamstranslator/SysCAMSTPortTDF.java | 112 ++ .../java/ui/SysCAMSComponentDesignPanel.java | 178 +++ src/main/java/ui/SysCAMSPanelTranslator.java | 172 +++ src/main/java/ui/syscams/SysCAMSBlockDE.java | 67 + src/main/java/ui/syscams/SysCAMSBlockTDF.java | 76 + .../ui/syscams/SysCAMSChannelFacility.java | 180 +++ .../ui/syscams/SysCAMSChannelOutPort.java | 68 + .../SysCAMSComponentTaskDiagramPanel.java | 1261 +++++++++++++++++ .../SysCAMSComponentTaskDiagramToolBar.java | 124 ++ .../ui/syscams/SysCAMSCompositeComponent.java | 633 +++++++++ .../java/ui/syscams/SysCAMSCompositePort.java | 325 +++++ src/main/java/ui/syscams/SysCAMSFork.java | 111 ++ src/main/java/ui/syscams/SysCAMSJoin.java | 115 ++ src/main/java/ui/syscams/SysCAMSPath.java | 360 +++++ .../syscams/SysCAMSPortConnectingPoint.java | 64 + .../java/ui/syscams/SysCAMSPortConnector.java | 139 ++ .../java/ui/syscams/SysCAMSPortConverter.java | 57 + src/main/java/ui/syscams/SysCAMSPortDE.java | 62 + src/main/java/ui/syscams/SysCAMSPortTDF.java | 62 + .../ui/syscams/SysCAMSPrimitiveComponent.java | 620 ++++++++ .../java/ui/syscams/SysCAMSPrimitivePort.java | 878 ++++++++++++ .../ui/syscams/SysCAMSRecordComponent.java | 420 ++++++ .../SysCAMSReferencePortConnectingPoint.java | 122 ++ .../SysCAMSRemoteCompositeComponent.java | 596 ++++++++ .../SysCAMSRemotePortCompositeComponent.java | 138 ++ .../window/JDialogSelectSysCAMSComponent.java | 414 ++++++ .../java/ui/window/JDialogSysCAMSBlockDE.java | 184 +++ .../ui/window/JDialogSysCAMSBlockTDF.java | 226 +++ .../window/JDialogSysCAMSPortConverter.java | 280 ++++ .../java/ui/window/JDialogSysCAMSPortDE.java | 280 ++++ .../java/ui/window/JDialogSysCAMSPortTDF.java | 280 ++++ .../resources/ui/util/camsconverterportE.gif | Bin 0 -> 132 bytes .../resources/ui/util/camsconverterportN.gif | Bin 0 -> 111 bytes .../resources/ui/util/camsconverterportS.gif | Bin 0 -> 111 bytes .../resources/ui/util/camsconverterportW.gif | Bin 0 -> 132 bytes src/main/resources/ui/util/camsdeport.gif | Bin 0 -> 119 bytes src/main/resources/ui/util/camstdfport.gif | Bin 0 -> 132 bytes 46 files changed, 9308 insertions(+), 1 deletion(-) create mode 100755 doc/config.xml create mode 100644 src/main/java/syscamstranslator/SysCAMSSpecification.java create mode 100644 src/main/java/syscamstranslator/SysCAMSTBlockDE.java create mode 100644 src/main/java/syscamstranslator/SysCAMSTBlockTDF.java create mode 100644 src/main/java/syscamstranslator/SysCAMSTCluster.java create mode 100644 src/main/java/syscamstranslator/SysCAMSTComponent.java create mode 100644 src/main/java/syscamstranslator/SysCAMSTPortConverter.java create mode 100644 src/main/java/syscamstranslator/SysCAMSTPortDE.java create mode 100644 src/main/java/syscamstranslator/SysCAMSTPortTDF.java create mode 100644 src/main/java/ui/SysCAMSComponentDesignPanel.java create mode 100644 src/main/java/ui/SysCAMSPanelTranslator.java create mode 100644 src/main/java/ui/syscams/SysCAMSBlockDE.java create mode 100644 src/main/java/ui/syscams/SysCAMSBlockTDF.java create mode 100644 src/main/java/ui/syscams/SysCAMSChannelFacility.java create mode 100644 src/main/java/ui/syscams/SysCAMSChannelOutPort.java create mode 100644 src/main/java/ui/syscams/SysCAMSComponentTaskDiagramPanel.java create mode 100644 src/main/java/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java create mode 100644 src/main/java/ui/syscams/SysCAMSCompositeComponent.java create mode 100644 src/main/java/ui/syscams/SysCAMSCompositePort.java create mode 100644 src/main/java/ui/syscams/SysCAMSFork.java create mode 100644 src/main/java/ui/syscams/SysCAMSJoin.java create mode 100644 src/main/java/ui/syscams/SysCAMSPath.java create mode 100644 src/main/java/ui/syscams/SysCAMSPortConnectingPoint.java create mode 100644 src/main/java/ui/syscams/SysCAMSPortConnector.java create mode 100644 src/main/java/ui/syscams/SysCAMSPortConverter.java create mode 100644 src/main/java/ui/syscams/SysCAMSPortDE.java create mode 100644 src/main/java/ui/syscams/SysCAMSPortTDF.java create mode 100644 src/main/java/ui/syscams/SysCAMSPrimitiveComponent.java create mode 100644 src/main/java/ui/syscams/SysCAMSPrimitivePort.java create mode 100644 src/main/java/ui/syscams/SysCAMSRecordComponent.java create mode 100644 src/main/java/ui/syscams/SysCAMSReferencePortConnectingPoint.java create mode 100644 src/main/java/ui/syscams/SysCAMSRemoteCompositeComponent.java create mode 100644 src/main/java/ui/syscams/SysCAMSRemotePortCompositeComponent.java create mode 100644 src/main/java/ui/window/JDialogSelectSysCAMSComponent.java create mode 100644 src/main/java/ui/window/JDialogSysCAMSBlockDE.java create mode 100644 src/main/java/ui/window/JDialogSysCAMSBlockTDF.java create mode 100644 src/main/java/ui/window/JDialogSysCAMSPortConverter.java create mode 100644 src/main/java/ui/window/JDialogSysCAMSPortDE.java create mode 100644 src/main/java/ui/window/JDialogSysCAMSPortTDF.java create mode 100644 src/main/resources/ui/util/camsconverterportE.gif create mode 100644 src/main/resources/ui/util/camsconverterportN.gif create mode 100644 src/main/resources/ui/util/camsconverterportS.gif create mode 100644 src/main/resources/ui/util/camsconverterportW.gif create mode 100644 src/main/resources/ui/util/camsdeport.gif create mode 100644 src/main/resources/ui/util/camstdfport.gif diff --git a/.idea/misc.xml b/.idea/misc.xml index 51e5191ed4..b755d8ca46 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -38,7 +38,7 @@ <property name="caretWidth" class="java.lang.Integer" /> </properties> </component> - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK"> + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="false" project-jdk-name="1.7" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/build" /> </component> </project> \ No newline at end of file diff --git a/doc/config.xml b/doc/config.xml new file mode 100755 index 0000000000..1306d59b20 --- /dev/null +++ b/doc/config.xml @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> + +<TURTLECONFIGURATION> +<DOTTYPath data="/bin/dotty" /> +<DOTTYHost data="localhost" /> +<FILEPath data="../modeling/" /> +<DownloadedFILEPath data="../modeling/" /> +<LIBPath data="../lib" /> +<IMGPath data="../figures" /> +<IMGPath data="../doc" /> +<LOTOSPath data="../lotos/" /> +<GGraphPath data="../graphs" /> +<TGraphPath data="../graphs" /> +<TToolUpdateProxy data="false" /> +<TToolUpdateProxyPort data="8080" /> +<TToolUpdateProxyHost data="To Be Completed" /> +<JavaCodeDirectory data="../javacode" /> +<JavaCompilerPath data="/usr/bin/javac" /> +<TToolClassPath data="../javacode" /> +<JavaExecutePath data="/usr/bin/java" /> +<JavaHeader data="import java.sql.*;" /> +<SystemCCodeDirectory data="../simulators/c++2/" /> +<SystemCHost data="localhost"/> +<SystemCCodeCompileCommand data="make" /> +<SystemCCodeExecuteCommand data="../simulators/c++2/run.x -ovcd ../simulators/c++2/vcddump.vcd" /> +<SystemCCodeInteractiveExecuteCommand data="../simulators/c++2/run.x -server" /> +<TMLCodeDirectory data="../tmlcode/" /> +<GTKWavePath data="/usr/bin/gtkwave" /> +<VCDPath data="../vcd/" /> +<UPPAALCodeDirectory data="../uppaal/" /> +<UPPAALVerifierPath data="../../uppaal/bin-Linux/verifyta" /> +<UPPAALVerifierHost data="localhost" /> +<ProVerifCodeDirectory data="../proverif/" /> +<ProVerifVerifierPath data="../../proverif/proverif" /> +<ProVerifVerifierHost data="localhost" /> +<AVATARExecutableCodeDirectory data="../executablecode/" /> +<AVATARMPSoCCodeDirectory data="../MPSoC/" /> +<AVATARExecutableCodeHost data="localhost"/> +<AVATARExecutableCodeCompileCommand data="make" /> +<AVATARExecutableCodeExecuteCommand data="run.x" /> +<AVATARExecutableSoclibCodeCompileCommand data="make -C ../executablecode updategeneratedcode compilesoclib" /> +<AVATARExecutableSoclibCodeExecuteCommand data="make -C ../executablecode runsoclib" /> + + +<ExternalCommand1Host data="localhost"/> +<ExternalCommand1 data="/usr/bin/gtkwave ../simulators/c++2/vcddump.vcd"/> + + +<ExternalServer data="localhost:12345"/> + +<LastWindowAttributes x="240" y="107" width="1414" height="777" max="false" /> + + +</TURTLECONFIGURATION> diff --git a/src/main/java/syscamstranslator/SysCAMSSpecification.java b/src/main/java/syscamstranslator/SysCAMSSpecification.java new file mode 100644 index 0000000000..e188ae7d11 --- /dev/null +++ b/src/main/java/syscamstranslator/SysCAMSSpecification.java @@ -0,0 +1,150 @@ +/* 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 syscamstranslator; + +import java.util.LinkedList; +import java.util.List; + +/** + * Creation: 07/05/2018 + * @version 1.0 07/05/2018 + * @author Irina Kit Yan LEE +*/ + +public class SysCAMSSpecification{ + private List<SysCAMSTComponent> components; + private List<SysCAMSTConnector> connectors; + + public SysCAMSSpecification(List<SysCAMSTComponent> _components, List<SysCAMSTConnector> _connectors){ + components = _components ; + connectors = _connectors ; + } + + public List<SysCAMSTComponent> getComponents(){ + return components; + } + + public List<SysCAMSTConnector> getConnectors(){ + return connectors; + } + + public LinkedList<SysCAMSTBlockTDF> getAllBlockTDF(){ + LinkedList<SysCAMSTBlockTDF> blocksTDF = new LinkedList<SysCAMSTBlockTDF>(); + for (SysCAMSTComponent blockTDF : components) { + if (blockTDF instanceof SysCAMSTBlockTDF) { + blocksTDF.add((SysCAMSTBlockTDF) blockTDF); + } + } + return blocksTDF; + } + + public LinkedList<SysCAMSTBlockDE> getAllBlockDE(){ + LinkedList<SysCAMSTBlockDE> blocksDE = new LinkedList<SysCAMSTBlockDE>(); + for (SysCAMSTComponent blockDE : components) { + if (blockDE instanceof SysCAMSTBlockDE) { + blocksDE.add((SysCAMSTBlockDE) blockDE); + } + } + return blocksDE; + } + + public LinkedList<SysCAMSTCluster> getAllCluster(){ + LinkedList<SysCAMSTCluster> clusters = new LinkedList<SysCAMSTCluster>(); + for (SysCAMSTComponent cluster : components) { + if (cluster instanceof SysCAMSTCluster) { + clusters.add((SysCAMSTCluster) cluster); + } + } + return clusters; + } + + public LinkedList<SysCAMSTPortConverter> getAllPortConverter(){ + LinkedList<SysCAMSTPortConverter> portsConv = new LinkedList<SysCAMSTPortConverter>(); + for (SysCAMSTComponent portConv : components) { + if (portConv instanceof SysCAMSTPortConverter) { + portsConv.add((SysCAMSTPortConverter) portConv); + } + } + return portsConv; + } + + public LinkedList<SysCAMSTPortTDF> getAllPortTDF(){ + LinkedList<SysCAMSTPortTDF> portsTDF = new LinkedList<SysCAMSTPortTDF>(); + for (SysCAMSTComponent portTDF : components) { + if (portTDF instanceof SysCAMSTPortTDF) { + portsTDF.add((SysCAMSTPortTDF) portTDF); + } + } + return portsTDF; + } + + public LinkedList<SysCAMSTPortDE> getAllPortDE(){ + LinkedList<SysCAMSTPortDE> portsDE = new LinkedList<SysCAMSTPortDE>(); + for (SysCAMSTComponent portDE : components) { + if (portDE instanceof SysCAMSTPortDE) { + portsDE.add((SysCAMSTPortDE) portDE); + } + } + return portsDE; + } + + public int getNbBlockTDF(){ + return (getAllBlockTDF()).size(); + } + + public int getNbBlocDE(){ + return (getAllBlockDE()).size(); + } + + public int getNbCluster(){ + return (getAllCluster()).size(); + } + + public int getNbPortConverter(){ + return (getAllPortConverter()).size(); + } + + public int getNbPortTDF(){ + return (getAllPortTDF()).size(); + } + + public int getNbPortDE(){ + return (getAllPortDE()).size(); + } +} \ No newline at end of file diff --git a/src/main/java/syscamstranslator/SysCAMSTBlockDE.java b/src/main/java/syscamstranslator/SysCAMSTBlockDE.java new file mode 100644 index 0000000000..6696aa5d1f --- /dev/null +++ b/src/main/java/syscamstranslator/SysCAMSTBlockDE.java @@ -0,0 +1,72 @@ +/* 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 syscamstranslator; + +/** + * Creation: 07/05/2018 + * @version 1.0 07/05/2018 + * @author Irina Kit Yan LEE +*/ + +public class SysCAMSTBlockDE extends SysCAMSTComponent { + + private String blockDEName; + private int period; + + public SysCAMSTBlockDE(String _blockDEName, int _period) { + blockDEName = _blockDEName; + period = _period; + } + + public int getPeriod() { + return period; + } + + public void setPeriod(int _period) { + period = _period; + } + + public String getBlockDEName() { + return blockDEName; + } + + public void setBlockDEName(String _blockDEName) { + blockDEName = _blockDEName; + } +} \ No newline at end of file diff --git a/src/main/java/syscamstranslator/SysCAMSTBlockTDF.java b/src/main/java/syscamstranslator/SysCAMSTBlockTDF.java new file mode 100644 index 0000000000..d7d449fd1d --- /dev/null +++ b/src/main/java/syscamstranslator/SysCAMSTBlockTDF.java @@ -0,0 +1,82 @@ +/* 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 syscamstranslator; + +/** + * Creation: 07/05/2018 + * @version 1.0 07/05/2018 + * @author Irina Kit Yan LEE +*/ + +public class SysCAMSTBlockTDF extends SysCAMSTComponent { + + private String blockTDFName; + private int period; + private String processCode; + + public SysCAMSTBlockTDF(String _blockTDFName, int _period, String _processCode) { + blockTDFName = _blockTDFName; + period = _period; + processCode = _processCode; + } + + public int getPeriod() { + return period; + } + + public void setPeriod(int _period) { + period = _period; + } + + public String getProcessCode() { + return processCode; + } + + public void setProcessCode(String _processCode) { + processCode = _processCode; + } + + public String getBlockTDFName() { + return blockTDFName; + } + + public void setBlockTDFName(String _blockTDFName) { + blockTDFName = _blockTDFName; + } +} \ No newline at end of file diff --git a/src/main/java/syscamstranslator/SysCAMSTCluster.java b/src/main/java/syscamstranslator/SysCAMSTCluster.java new file mode 100644 index 0000000000..0d82f3673e --- /dev/null +++ b/src/main/java/syscamstranslator/SysCAMSTCluster.java @@ -0,0 +1,63 @@ +/* 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 syscamstranslator; + +/** + * Creation: 07/05/2018 + * @version 1.0 07/05/2018 + * @author Irina Kit Yan LEE +*/ + +public class SysCAMSTCluster extends SysCAMSTComponent { + + private String clusterName; + + public SysCAMSTCluster(String _clusterName) { + super(); + clusterName = _clusterName; + } + + public String getClusterName() { + return clusterName; + } + + public void setClusterName(String _clusterName) { + clusterName = _clusterName; + } +} \ No newline at end of file diff --git a/src/main/java/syscamstranslator/SysCAMSTComponent.java b/src/main/java/syscamstranslator/SysCAMSTComponent.java new file mode 100644 index 0000000000..5a4b606380 --- /dev/null +++ b/src/main/java/syscamstranslator/SysCAMSTComponent.java @@ -0,0 +1,58 @@ +/* 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 syscamstranslator; + +/** + * Creation: 07/05/2018 + * @version 1.0 07/05/2018 + * @author Irina Kit Yan LEE +*/ + +public class SysCAMSTComponent { + + public String name; + + public String getName() { + return name; + } + + public void setName(String _name) { + name = _name; + } +} \ No newline at end of file diff --git a/src/main/java/syscamstranslator/SysCAMSTPortConverter.java b/src/main/java/syscamstranslator/SysCAMSTPortConverter.java new file mode 100644 index 0000000000..a367d8cfa0 --- /dev/null +++ b/src/main/java/syscamstranslator/SysCAMSTPortConverter.java @@ -0,0 +1,112 @@ +/* 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 syscamstranslator; + +/** + * Creation: 07/05/2018 + * @version 1.0 07/05/2018 + * @author Irina Kit Yan LEE +*/ + +public class SysCAMSTPortConverter extends SysCAMSTComponent { + + private String name; + private int period; + private int rate; + private int delay; + private String origin; + private String ConvType; + + public SysCAMSTPortConverter(String _name, int _period, int _rate, int _delay, String _origin, String _ConvType) { + name = _name; + period = _period; + rate = _rate; + delay = _delay; + origin = _origin; + ConvType = _ConvType; + } + + public String getName() { + return name; + } + + public void setName(String _name) { + name = _name; + } + + public int getPeriod() { + return period; + } + + public void setPeriod(int _period) { + period = _period; + } + + public int getRate() { + return rate; + } + + public void setRate(int _rate) { + rate = _rate; + } + + public int getDelay() { + return delay; + } + + public void setDelay(int _delay) { + delay = _delay; + } + + public String getOrigin() { + return origin; + } + + public void setOrigin(String _origin) { + origin = _origin; + } + + public String getConvType() { + return ConvType; + } + + public void setConvType(String _ConvType) { + ConvType = _ConvType; + } +} \ No newline at end of file diff --git a/src/main/java/syscamstranslator/SysCAMSTPortDE.java b/src/main/java/syscamstranslator/SysCAMSTPortDE.java new file mode 100644 index 0000000000..f1ec45a4f7 --- /dev/null +++ b/src/main/java/syscamstranslator/SysCAMSTPortDE.java @@ -0,0 +1,112 @@ +/* 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 syscamstranslator; + +/** + * Creation: 07/05/2018 + * @version 1.0 07/05/2018 + * @author Irina Kit Yan LEE +*/ + +public class SysCAMSTPortDE extends SysCAMSTComponent { + + private String name; + private int period; + private int rate; + private int delay; + private String origin; + private String DEType; + + public SysCAMSTPortDE(String _name, int _period, int _rate, int _delay, String _origin, String _DEType) { + name = _name; + period = _period; + rate = _rate; + delay = _delay; + origin = _origin; + DEType = _DEType; + } + + public String getName() { + return name; + } + + public void setName(String _name) { + name = _name; + } + + public int getPeriod() { + return period; + } + + public void setPeriod(int _period) { + period = _period; + } + + public int getRate() { + return rate; + } + + public void setRate(int _rate) { + rate = _rate; + } + + public int getDelay() { + return delay; + } + + public void setDelay(int _delay) { + delay = _delay; + } + + public String getOrigin() { + return origin; + } + + public void setOrigin(String _origin) { + origin = _origin; + } + + public String getDEType() { + return DEType; + } + + public void setDEType(String _DEType) { + DEType = _DEType; + } +} \ No newline at end of file diff --git a/src/main/java/syscamstranslator/SysCAMSTPortTDF.java b/src/main/java/syscamstranslator/SysCAMSTPortTDF.java new file mode 100644 index 0000000000..03145f137b --- /dev/null +++ b/src/main/java/syscamstranslator/SysCAMSTPortTDF.java @@ -0,0 +1,112 @@ +/* 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 syscamstranslator; + +/** + * Creation: 07/05/2018 + * @version 1.0 07/05/2018 + * @author Irina Kit Yan LEE +*/ + +public class SysCAMSTPortTDF extends SysCAMSTComponent { + + private String name; + private int period; + private int rate; + private int delay; + private String origin; + private String TDFType; + + public SysCAMSTPortTDF(String _name, int _period, int _rate, int _delay, String _origin, String _TDFType) { + name = _name; + period = _period; + rate = _rate; + delay = _delay; + origin = _origin; + TDFType = _TDFType; + } + + public String getName() { + return name; + } + + public void setName(String _name) { + name = _name; + } + + public int getPeriod() { + return period; + } + + public void setPeriod(int _period) { + period = _period; + } + + public int getRate() { + return rate; + } + + public void setRate(int _rate) { + rate = _rate; + } + + public int getDelay() { + return delay; + } + + public void setDelay(int _delay) { + delay = _delay; + } + + public String getOrigin() { + return origin; + } + + public void setOrigin(String _origin) { + origin = _origin; + } + + public String getTDFType() { + return TDFType; + } + + public void setTDFType(String _TDFType) { + TDFType = _TDFType; + } +} diff --git a/src/main/java/ui/SysCAMSComponentDesignPanel.java b/src/main/java/ui/SysCAMSComponentDesignPanel.java new file mode 100644 index 0000000000..e6cbd40e7a --- /dev/null +++ b/src/main/java/ui/SysCAMSComponentDesignPanel.java @@ -0,0 +1,178 @@ +/* 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; + +import myutil.GraphicLib; +import ui.syscams.*; +import ui.util.IconManager; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.util.Vector; + +/** + * Class SysCAMSComponentDesignPanel + * Managenemt of SystemC-AMS component-based design panels + * Creation: 22/04/2018 + * @version 1.0 22/04/2018 + * @author Irina Kit Yan LEE + * @see MainGUI + */ + +public class SysCAMSComponentDesignPanel extends TURTLEPanel { + + public SysCAMSComponentTaskDiagramPanel syscamsctdp; + + public Vector<TGComponent> validated, ignored; + + public SysCAMSComponentDesignPanel(MainGUI _mgui) { + super(_mgui); + + // Issue #41 Ordering of tabbed panes + 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)); + + // Issue #41: Ordering of tabbed panes + tabbedPane.setTabLayoutPolicy( JTabbedPane.SCROLL_TAB_LAYOUT ); + } + + public void init() { + + // Toolbar + SysCAMSComponentTaskDiagramToolBar toolBarSysCAMS = new SysCAMSComponentTaskDiagramToolBar(mgui); + toolbars.add(toolBarSysCAMS); + + toolBarPanel = new JPanel(); + toolBarPanel.setLayout(new BorderLayout()); + + // Diagram + syscamsctdp = new SysCAMSComponentTaskDiagramPanel(mgui, toolBarSysCAMS); + syscamsctdp.setName("SystemC-AMS Component Diagram"); + syscamsctdp.tp = this; + tdp = syscamsctdp; + panels.add(syscamsctdp); // Always first in list + JScrollDiagramPanel jsp = new JScrollDiagramPanel(syscamsctdp); + syscamsctdp.jsp = jsp; + jsp.setWheelScrollingEnabled(true); + jsp.getVerticalScrollBar().setUnitIncrement( MainGUI.INCREMENT ); + toolBarPanel.add(toolBarSysCAMS, BorderLayout.NORTH); + toolBarPanel.add(jsp, BorderLayout.CENTER); + tabbedPane.addTab("SystemC-AMS Component Diagram", IconManager.imgic1208, toolBarPanel, "SysCAMS Component Diagram"); + tabbedPane.setSelectedIndex(0); + + mgui.changeMade(syscamsctdp, 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 Component Application diagram)"; + } + + public SysCAMSPrimitiveComponent getPrimitiveComponentByName(String _name) { + return syscamsctdp.getPrimitiveComponentByName(_name); + } +// +// public String[] getCompOutChannels(){ +// return syscamsctdp.getCompOutChannels(); +// } +// +// public String[] getCompInChannels(){ +// return syscamsctdp.getCompInChannels(); +// } +// +// public java.util.List<String> getAllSysCAMSCommunicationNames(String _name) { +// return syscamsctdp.getAllSysCAMSCommunicationNames(_name); +// } +// +// public java.util.List<String> getAllSysCAMSInputPorts( String _name ) { +// return syscamsctdp.getAllSysCAMSInputPorts( _name ); +// } + + public java.util.List<String> getAllCompositeComponent(String _name) { + return syscamsctdp.getAllCompositeComponent(_name); + } + + public Vector<String> getAllSysCAMSTasksAttributes() { + return syscamsctdp.getAllSysCAMSTasksAttributes(); + } + + public java.util.List<String> getAllSysCAMSTaskNames(String _name) { + return syscamsctdp.getAllSysCAMSTaskNames(_name); + } + + public String[] getAllOutTDF(String nameOfComponent) { + return syscamsctdp.getAllOutTDF(nameOfComponent); + } + + public String[] getAllInTDF(String nameOfComponent) { + return syscamsctdp.getAllInTDF(nameOfComponent); + } + + public String[] getAllOutDE(String nameOfComponent) { + return syscamsctdp.getAllOutDE(nameOfComponent); + } + + public String[] getAllInDE(String nameOfComponent) { + return syscamsctdp.getAllInDE(nameOfComponent); + } +} diff --git a/src/main/java/ui/SysCAMSPanelTranslator.java b/src/main/java/ui/SysCAMSPanelTranslator.java new file mode 100644 index 0000000000..c079ba37db --- /dev/null +++ b/src/main/java/ui/SysCAMSPanelTranslator.java @@ -0,0 +1,172 @@ +/* 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 syscamstranslator.*; +import ui.syscams.*; + +import java.util.*; + +/** + * Class SysCAMSPanelTranslator + * Translation of semantics of SystemC-AMS Diagrams + * Creation: 08/05/2018 + * @version 1.0 08/05/2018 + * @author Irina Kit Yan LEE +*/ + +public class SysCAMSPanelTranslator { + + private List<TGComponent> tgcComponents; + + private List<SysCAMSTComponent> syscamsComponents; + private List<SysCAMSTConnector> syscamsConnectors; + + public SysCAMSPanelTranslator(SysCAMSComponentTaskDiagramPanel _syscamsDiagramPanel) { + tgcComponents = _syscamsDiagramPanel.getComponentList(); + + syscamsComponents = new LinkedList<SysCAMSTComponent>(); + syscamsConnectors = new LinkedList<SysCAMSTConnector>(); + + MakeListOfComponent(_syscamsDiagramPanel); + } + + private void MakeListOfComponent(SysCAMSComponentTaskDiagramPanel syscamsDiagramPanel) { + + Map<TGComponent, SysCAMSTComponent> syscamsMap = new HashMap<TGComponent, SysCAMSTComponent>(); + + for (TGComponent dp : tgcComponents) { + if (dp instanceof SysCAMSBlockTDF) { + SysCAMSBlockTDF blockTDF = (SysCAMSBlockTDF) dp; + + String blockTDFName = blockTDF.getValue(); + int period = blockTDF.getPeriod(); + String processCode = blockTDF.getProcessCode(); + + SysCAMSTBlockTDF syscamsBlockTDF = new SysCAMSTBlockTDF(blockTDFName, period, processCode); + + syscamsMap.put(dp, syscamsBlockTDF); + syscamsComponents.add(syscamsBlockTDF); + + } else if (dp instanceof SysCAMSBlockDE) { + SysCAMSBlockDE blockDE = (SysCAMSBlockDE) dp; + + String blockDEName = blockDE.getValue(); + int period = blockDE.getPeriod(); + + SysCAMSTBlockDE syscamsBlockDE = new SysCAMSTBlockDE(blockDEName, period); + + syscamsMap.put(dp, syscamsBlockDE); + syscamsComponents.add(syscamsBlockDE); + } else if (dp instanceof SysCAMSCompositeComponent) { + SysCAMSCompositeComponent cluster = (SysCAMSCompositeComponent) dp; + + String clusterName = cluster.getValue(); + + SysCAMSTCluster syscamsCluster = new SysCAMSTCluster(clusterName); + + syscamsMap.put(dp, syscamsCluster); + syscamsComponents.add(syscamsCluster); + } else if (dp instanceof SysCAMSPortConverter) { + SysCAMSPortConverter portConverter = (SysCAMSPortConverter) dp; + + String portName = portConverter.getValue(); + int period = portConverter.getPeriod(); + int rate = portConverter.getRate(); + int delay = portConverter.getDelay(); + String type = portConverter.getConvType(); + String origin = portConverter.getOrigin(); + + SysCAMSTPortConverter syscamsClusterPort = new SysCAMSTPortConverter(portName, period, rate, delay, origin, type); + + syscamsMap.put(dp, syscamsClusterPort); + syscamsComponents.add(syscamsClusterPort); + } else if (dp instanceof SysCAMSPortTDF) { + SysCAMSPortTDF portTDF = (SysCAMSPortTDF) dp; + + String portName = portTDF.getValue(); + int period = portTDF.getPeriod(); + int rate = portTDF.getRate(); + int delay = portTDF.getDelay(); + String type = portTDF.getTDFType(); + String origin = portTDF.getOrigin(); + + SysCAMSTPortTDF syscamsPortTDF = new SysCAMSTPortTDF(portName, period, rate, delay, origin, type); + + syscamsMap.put(dp, syscamsPortTDF); + syscamsComponents.add(syscamsPortTDF); + } else if (dp instanceof SysCAMSPortDE) { + SysCAMSPortDE portDE = (SysCAMSPortDE) dp; + + String portName = portDE.getValue(); + int period = portDE.getPeriod(); + int rate = portDE.getRate(); + int delay = portDE.getDelay(); + String type = portDE.getDEType(); + String origin = portDE.getOrigin(); + + SysCAMSTPortDE syscamsPortDE = new SysCAMSTPortDE(portName, period, rate, delay, origin, type); + + syscamsMap.put(dp, syscamsPortDE); + syscamsComponents.add(syscamsPortDE); + } else if (dp instanceof SysCAMSPortConnector) { + SysCAMSPortConnector connector = (SysCAMSPortConnector) dp; + + TGConnectingPoint connectingPoint1 = connector.get_p1(); + TGConnectingPoint connectingPoint2 = connector.get_p2(); + + TGComponent owner_p1 = syscamsDiagramPanel.getComponentToWhichBelongs(connectingPoint1); + TGComponent owner_p2 = syscamsDiagramPanel.getComponentToWhichBelongs(connectingPoint2); + + SysCAMSTComponent avowner_p1 = syscamsMap.get(owner_p1); + SysCAMSTComponent avowner_p2 = syscamsMap.get(owner_p2); + + SysCAMSTConnectingPoint avConnectingPoint1 = new SysCAMSTConnectingPoint(avowner_p1); + SysCAMSTConnectingPoint avConnectingPoint2 = new SysCAMSTConnectingPoint(avowner_p2); + + SysCAMSTConnector avconnector = new SysCAMSTConnector(avConnectingPoint1, avConnectingPoint2); + syscamsConnectors.add(avconnector); + } + } + } + + public SysCAMSSpecification getSysCAMSSpecification() { + return new SysCAMSSpecification(syscamsComponents, syscamsConnectors); + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSBlockDE.java b/src/main/java/ui/syscams/SysCAMSBlockDE.java new file mode 100644 index 0000000000..27cb244370 --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSBlockDE.java @@ -0,0 +1,67 @@ +/* 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.syscams; + +import ui.TDiagramPanel; +import ui.TGComponent; + +/** + * Class SysCAMSBlockDE + * Primitive Component. To be used in SystemC-AMS component task diagrams + * Creation: 23/04/2018 + * @version 1.0 23/04/2018 + * @author Irina Kit Yan LEE + */ + +public class SysCAMSBlockDE extends SysCAMSPrimitiveComponent { + private int period; + + public SysCAMSBlockDE(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); + } + + public int getPeriod() { + return period; + } + + public void setPeriod(int period) { + this.period = period; + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSBlockTDF.java b/src/main/java/ui/syscams/SysCAMSBlockTDF.java new file mode 100644 index 0000000000..a354f6566f --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSBlockTDF.java @@ -0,0 +1,76 @@ +/* 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.syscams; + +import ui.TDiagramPanel; +import ui.TGComponent; + +/** + * Class SysCAMSBlockTDF + * Primitive Component. To be used in SystemC-AMS component task diagrams + * Creation: 23/04/2018 + * @version 1.0 23/04/2018 + * @author Irina Kit Yan LEE + */ + +public class SysCAMSBlockTDF extends SysCAMSPrimitiveComponent { + private int period; + private String processCode; + + public SysCAMSBlockTDF(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); + } + + public String getProcessCode() { + return processCode; + } + + public void setProcessCode(String processCode) { + this.processCode = processCode; + } + + public int getPeriod() { + return period; + } + + public void setPeriod(int period) { + this.period = period; + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSChannelFacility.java b/src/main/java/ui/syscams/SysCAMSChannelFacility.java new file mode 100644 index 0000000000..3ac59014a0 --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSChannelFacility.java @@ -0,0 +1,180 @@ +/* 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.syscams; + +import myutil.GraphicLib; +import ui.*; + +import java.awt.*; + +/** + * Class SysCAMSChannelFacility + * Channel facility. To be used in SystemC-AMS component task diagrams + * Creation: 22/04/2018 + * @version 1.0 22/04/2018 + * @author Irina Kit Yan LEE + */ + +public abstract class SysCAMSChannelFacility extends TGCScalableWithInternalComponent { + protected Color myColor, portColor; + + protected SysCAMSPrimitivePort inp, outp; + protected int inpIndex, outpIndex; + protected boolean conflict = false; + protected String conflictMessage; + + public SysCAMSChannelFacility(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); + + minWidth = 10; + minHeight = 10; + + moveable = true; + editable = false; + removable = true; + userResizable = false; + } + + public TGComponent isOnOnlyMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; + } + + public void calculatePortColor() { + if (conflict) { + myColor = Color.red; + } else { + SysCAMSPrimitivePort port = inp; + if (port == null) { + port = outp; + } + if (port == null) { + portColor = null; + if (myColor == null) { + myColor = new Color(251, 252, 155- (getMyDepth() * 10)); + } + } else { + int typep = port.getPortType(); + if (typep == 0) { + myColor = ColorManager.TML_PORT_CHANNEL; + } else if (typep == 1) { + myColor = ColorManager.TML_PORT_EVENT; + } else { + myColor = ColorManager.TML_PORT_REQUEST; + } + } + } + portColor = myColor; + } + + public void setInPort(SysCAMSPrimitivePort _inp) { + inp = _inp; + calculatePortColor(); + } + + public void setOutPort(SysCAMSPrimitivePort _outp) { + outp = _outp; + calculatePortColor(); + } + + public SysCAMSPrimitivePort getInPort() { + return inp; + } + + public SysCAMSPrimitivePort getOutPort() { + return outp; + } + + public int getInpIndex() { + return inpIndex; + } + + public int getOutpIndex() { + return outpIndex; + } + + public void setInpIndex(int _inpIndex) { + inpIndex = _inpIndex; + } + + public void setOutpIndex(int _outpIndex) { + outpIndex = _outpIndex; + } + + public boolean getConflict() { + return conflict; + } + + public void setConflict(boolean _conflict, String _msg) { + conflict = _conflict; + myColor = null; + conflictMessage = _msg; + calculatePortColor(); + } + + public int getDefaultConnector() { + return TGComponentManager.CONNECTOR_PORT_TMLC; + } + + public Color getPortColor() { + return portColor; + } + + public String getAttributes() { + if (conflict) { + return conflictMessage; + } + String s = ""; + if (inp != null) { + s = s + inp.getAttributes(); + if (outp != null) { + s = s + "\n"; + } + } + if (outp != null) { + s = s + outp.getAttributes(); + } + if (conflict) { + s += "Error in path=" + conflict; + } + return s; + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSChannelOutPort.java b/src/main/java/ui/syscams/SysCAMSChannelOutPort.java new file mode 100644 index 0000000000..ed1f34c0f9 --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSChannelOutPort.java @@ -0,0 +1,68 @@ +/* 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.syscams; + +import ui.TDiagramPanel; +import ui.TGComponent; +import ui.TGComponentManager; + +import java.awt.*; + +/** + * Class SysCAMSChannelOutPort + * Channel out port. To be used in SystemC-AMS component task diagrams + * Creation: 22/04/2018 + * @version 1.0 22/04/2018 + * @author Irina Kit Yan LEE + */ + +public class SysCAMSChannelOutPort extends SysCAMSPrimitivePort { + public SysCAMSChannelOutPort(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); + + initConnectingPoint(true, true, 1); + } + + public void drawParticularity(Graphics g) { + } + + public int getType() { + return TGComponentManager.TMLCTD_COPORT; + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramPanel.java b/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramPanel.java new file mode 100644 index 0000000000..1d834b9153 --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramPanel.java @@ -0,0 +1,1261 @@ +/* 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.syscams; + +import myutil.TraceManager; +import org.w3c.dom.Element; +import ui.*; + +import java.util.*; + +/** + * Class SysCAMSComponentTaskDiagramPanel + * Panel for drawing SystemC-AMS elements + * Creation: 27/04/2018 + * @version 1.0 27/04/2018 + * @author Irina Kit Yan LEE + */ + +@SuppressWarnings("serial") + +public class SysCAMSComponentTaskDiagramPanel extends TDiagramPanel implements TDPWithAttributes { + + public SysCAMSComponentTaskDiagramPanel(MainGUI mgui, TToolBar _ttb) { + super(mgui, _ttb); + } + + public boolean actionOnDoubleClick(TGComponent tgc) { + return false; + } + + public boolean actionOnAdd(TGComponent tgc) { + if (tgc instanceof SysCAMSPrimitiveComponent) { + return true; + } + if (tgc instanceof SysCAMSCompositePort) { + if (tgc.getFather() instanceof SysCAMSCompositeComponent) { + getMGUI().updateReferenceToSysCAMSCompositeComponent((SysCAMSCompositeComponent)(tgc.getFather())); + } + } + + return true; + } + + public boolean actionOnRemove(TGComponent tgc) { + if (tgc instanceof SysCAMSPortConnector) { + updatePorts(); + } + if (tgc instanceof SysCAMSPrimitivePort) { + updatePorts(); + } + + if (tgc instanceof SysCAMSChannelFacility) { + updatePorts(); + } + + if (tgc instanceof SysCAMSCompositePort) { + updatePorts(); + if (fatherOfRemoved instanceof SysCAMSCompositeComponent) { + getMGUI().updateReferenceToSysCAMSCompositeComponent((SysCAMSCompositeComponent)(fatherOfRemoved)); + } + } + + return true; + } + + public List<SysCAMSPrimitivePort> getPortsByName(String name){ + List<SysCAMSPrimitivePort> ports = new ArrayList<SysCAMSPrimitivePort>(); + for (TGComponent tgc : componentList){ + + if (tgc instanceof SysCAMSPrimitiveComponent){ + SysCAMSPrimitiveComponent comp = (SysCAMSPrimitiveComponent) tgc; + List<SysCAMSPrimitivePort> cps = comp.getAllTDFOriginPorts(); + for (SysCAMSPrimitivePort port : cps){ + if (port.commName.equals(name)){ + ports.add(port); + } + } + cps = comp.getAllTDFDestinationPorts(); + for (SysCAMSPrimitivePort port : cps){ + if (port.commName.equals(name)){ + ports.add(port); + } + } + } + if (tgc instanceof SysCAMSPrimitiveComponent){ + SysCAMSPrimitiveComponent comp = (SysCAMSPrimitiveComponent) tgc; + List<SysCAMSPrimitivePort> cps = comp.getAllDEOriginPorts(); + for (SysCAMSPrimitivePort port : cps){ + if (port.commName.equals(name)){ + ports.add(port); + } + } + cps = comp.getAllDEDestinationPorts(); + for (SysCAMSPrimitivePort port : cps){ + if (port.commName.equals(name)){ + ports.add(port); + } + } + } + } + return ports; + } + + public boolean actionOnValueChanged(TGComponent tgc) { + if (tgc instanceof SysCAMSPrimitiveComponent) { + SysCAMSPrimitiveComponent t = (SysCAMSPrimitiveComponent)tgc; + mgui.newSysCAMSTaskName(tp, t.oldValue, t.getValue()); + return true; + } + if (tgc instanceof SysCAMSCompositeComponent) { + SysCAMSCompositeComponent syscamscc = (SysCAMSCompositeComponent)tgc; + getMGUI().updateReferenceToSysCAMSCompositeComponent(syscamscc); + } + return true; + } + + public boolean renamePrimitiveComponent(String oldValue, String newValue) { + return mgui.newSysCAMSComponentTaskName(tp, oldValue, newValue); + } + + public boolean namePrimitiveComponentInUse(String oldValue, String newValue) { + boolean ko = mgui.nameComponentInUse(tp, oldValue, newValue); + return ko ? ko : nameAllRecordComponentInUse(oldValue, newValue); + } + + public boolean nameRecordComponentInUse(String oldValue, String newValue) { + boolean ko = mgui.nameComponentInUse(tp, oldValue, newValue); + return ko? ko : nameAllRecordComponentInUse(oldValue, newValue); + } + + public boolean isCompositeNameUsed(String newvalue) { + for (TGComponent tgc: this.componentList) { + if (tgc.getValue().equals(newvalue)) + return true; + } + return false; + } + + public boolean nameAllRecordComponentInUse(String oldValue, String newValue) { + Iterator<SysCAMSRecordComponent> iterator = getRecordComponentList().listIterator(); + SysCAMSRecordComponent record; + + while(iterator.hasNext()) { + record = iterator.next(); + if (record.getName().compareTo(newValue) == 0) { + return true; + } + } + return false; + } + + public LinkedList<SysCAMSRecordComponent> getRecordComponentList() { + LinkedList<SysCAMSRecordComponent> ll = new LinkedList<SysCAMSRecordComponent>(); + TGComponent tgc; + + Iterator<TGComponent> iterator = componentList.listIterator(); + + while(iterator.hasNext()) { + tgc = iterator.next(); + if (tgc instanceof SysCAMSRecordComponent) { + ll.add((SysCAMSRecordComponent) tgc); + } + if (tgc instanceof SysCAMSCompositeComponent) { + ll.addAll(((SysCAMSCompositeComponent)tgc).getAllRecordComponents()); + } + if (tgc instanceof SysCAMSRemoteCompositeComponent) { + ll.addAll(((SysCAMSRemoteCompositeComponent)tgc).getAllRecordComponents()); + } + } + return ll; + } + + public List<SysCAMSPrimitiveComponent> getPrimitiveComponentList() { + List<SysCAMSPrimitiveComponent> ll = new LinkedList<SysCAMSPrimitiveComponent>(); + TGComponent tgc; + + Iterator<TGComponent> iterator = componentList.listIterator(); + + while(iterator.hasNext()) { + tgc = iterator.next(); + + if (tgc instanceof SysCAMSPrimitiveComponent) { + ll.add( (SysCAMSPrimitiveComponent) tgc ); + } + if (tgc instanceof SysCAMSCompositeComponent) { + ll.addAll(((SysCAMSCompositeComponent)tgc).getAllPrimitiveComponents()); + } + if (tgc instanceof SysCAMSRemoteCompositeComponent) { + ll.addAll(((SysCAMSRemoteCompositeComponent)tgc).getAllPrimitiveComponents()); + } + } + return ll; + } + + public List<SysCAMSPrimitivePort> getPortsConnectedTo(SysCAMSPrimitivePort _port, List<? extends TGComponent> componentsToTakeIntoAccount) { + List<TGComponent> ll; + List<SysCAMSPrimitivePort> ret = new LinkedList<SysCAMSPrimitivePort>(); + Object o; + SysCAMSPrimitivePort p; + + ll = getAllPortsConnectedTo(_port); + Iterator<TGComponent> li = ll.listIterator(); + + while(li.hasNext()) { + o = li.next(); + + if (o instanceof SysCAMSPrimitivePort) { + p = (SysCAMSPrimitivePort)o; + + if (p.getFather() instanceof SysCAMSPrimitiveComponent) { + if (componentsToTakeIntoAccount.contains(p.getFather())) { + ret.add( p ); + } + } + } + } + return ret; + } + + public List<TGComponent> getAllPortsConnectedTo(SysCAMSPrimitivePort _port) { + List<TGComponent> ll = new LinkedList<TGComponent>(); + getAllPortsConnectedTo( ll, _port ); + return ll; + } + +// public List<String> getAllSysCAMSCommunicationNames(String _topname) { +// List<String> al = new ArrayList<String>(); +// +// SysCAMSPrimitiveComponent syscamsc; +// List<SysCAMSPrimitiveComponent> components = getPrimitiveComponentList(); +// Iterator<SysCAMSPrimitiveComponent> iterator = components.listIterator(); +// Iterator<SysCAMSPrimitivePort> li;//, li2; +// List<SysCAMSPrimitivePort> ports, portstome; +// String name, name1, name2; +// SysCAMSPrimitivePort port1, port2; +// +// int j; +// +// while( iterator.hasNext() ) { +// syscamsc = iterator.next(); +// ports = syscamsc.getAllChannelsOriginPorts(); +// li = ports.listIterator(); +// while( li.hasNext() ) { +// port1 = li.next(); +// portstome = getPortsConnectedTo( port1, components ); +// Iterator<SysCAMSPrimitivePort> ite = portstome.listIterator(); +// +// while( ite.hasNext()) { +// port2 = ite.next(); +// if (!port2.isOrigin()) { +// String []text1 = port1.getPortName().split( "," ); +// String []text2 = port2.getPortName().split( "," ); +// for ( j = 0; j < Math.min( text1.length, text2.length ); j++ ) { +// name1 = text1[j].trim(); +// name2 = text2[j].trim(); +// if( name1.equals( name2 ) ) { +// name = name1; +// } +// else { +// name = name1 + "__" + name2; +// } +// al.add( _topname + "::" + name ); +// } +// } +// } +// } +// } +// return al; +// } +// +// public List<String> getAllSysCAMSInputPorts( String _topname ) { //the destination ports +// //Use HashSet to avoid returning multiple identical ports due to the presence of join nodes +// Set<String> al = new HashSet<String>(); +// SysCAMSPrimitiveComponent syscamsc; +// List<SysCAMSPrimitiveComponent> components = getPrimitiveComponentList(); +// Iterator<SysCAMSPrimitiveComponent> iterator = components.listIterator(); +// Iterator<SysCAMSPrimitivePort> li;//, li2; +// List<SysCAMSPrimitivePort> ports, portstome; +// String name2; +// SysCAMSPrimitivePort port1, port2; +// int j; +// +// while( iterator.hasNext() ) { +// syscamsc = iterator.next(); +// ports = syscamsc.getAllChannelsOriginPorts(); +// li = ports.listIterator(); +// while( li.hasNext() ) { +// port1 = li.next(); +// portstome = getPortsConnectedTo( port1, components ); //this prints the ports via TraceManager +// Iterator<SysCAMSPrimitivePort> ite = portstome.listIterator(); +// while( ite.hasNext()) { +// port2 = ite.next(); +// if( !port2.isOrigin() ) { +// String []text1 = port1.getPortName().split( "," ); +// String []text2 = port2.getPortName().split( "," ); +// for( j = 0; j < Math.min( text1.length, text2.length ); j++ ) { +// name2 = text2[j].trim(); +// al.add( _topname + "::" + name2 ); +// } +// } +// } +// } +// } +// return new ArrayList<String>(al); +// } +// +// public List<String> getAllSysCAMSEventNames( String _topname ) { +// +// List<String> al = new ArrayList<String>(); +// SysCAMSPrimitiveComponent syscamsc; +// List<SysCAMSPrimitiveComponent> components = getPrimitiveComponentList(); +// Iterator<SysCAMSPrimitiveComponent> iterator = components.listIterator(); +// Iterator<SysCAMSPrimitivePort> li;//, li2; +// List<SysCAMSPrimitivePort> ports, portstome; +// String name, name1, name2; +// SysCAMSPrimitivePort port1, port2; +// int j; +// +// while( iterator.hasNext() ) { +// syscamsc = iterator.next() ; +// ports = syscamsc.getAllEventsOriginPorts(); +// li = ports.listIterator(); +// while( li.hasNext() ) { +// port1 = li.next(); +// portstome = getPortsConnectedTo( port1, components ); +// if ( portstome.size() == 1 ) { +// port2 = portstome.get(0); +// String []text1 = port1.getPortName().split( "," ); +// String []text2 = port2.getPortName().split( "," ); +// for ( j = 0; j < Math.min( text1.length, text2.length ); j++ ) { +// name1 = text1[j].trim(); +// name2 = text2[j].trim(); +// if( name1.equals( name2 ) ) { +// name = name1; +// } +// else { +// name = name1 + "__" + name2; +// } +// al.add( _topname + "::" + name ); +// } +// } +// } +// } +// return al; +// } + + public void getAllPortsConnectedTo( List<TGComponent> ll, SysCAMSPrimitivePort _port) { + List<TGComponent> components = getMGUI().getAllSysCAMSComponents(); + Iterator<TGComponent> iterator = components.listIterator(); + TGComponent tgc, tgc1, tgc2; + SysCAMSPortConnector portco; + + while(iterator.hasNext()) { + tgc = iterator.next(); + + if (tgc instanceof SysCAMSPortConnector) { + portco = (SysCAMSPortConnector)tgc; + tgc1 = getComponentToWhichBelongs(components, portco.getTGConnectingPointP1()); + tgc2 = getComponentToWhichBelongs(components, portco.getTGConnectingPointP2()); + if ((tgc1 != null) && (tgc2 != null)) { + if (tgc1 instanceof SysCAMSRemoteCompositeComponent) { + tgc1 = ((SysCAMSRemoteCompositeComponent)tgc1).getPortOf(portco.getTGConnectingPointP1()); + } + + if (tgc2 instanceof SysCAMSRemoteCompositeComponent) { + tgc2 = ((SysCAMSRemoteCompositeComponent)tgc2).getPortOf(portco.getTGConnectingPointP2()); + } + if ((!ll.contains(tgc2) && (tgc2 != _port) && ((tgc1 == _port) || (ll.contains(tgc1))))) { + ll.add(tgc2); + iterator = components.listIterator(); + } else { + if ((!ll.contains(tgc1) && (tgc1 != _port) && ((tgc2 == _port) || (ll.contains(tgc2))))) { + ll.add(tgc1); + iterator = components.listIterator(); + } + } + } + } + } + } + + public String getXMLHead() { + return "<SysCAMSComponentTaskDiagramPanel name=\"" + name + "\"" + sizeParam() + displayParam() + zoomParam() +" >"; + } + + public String getXMLTail() { + return "</SysCAMSComponentTaskDiagramPanel>"; + } + + public String getXMLSelectedHead() { + return "<SysCAMSComponentTaskDiagramPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; + } + + public String getXMLSelectedTail() { + return "</SysCAMSComponentTaskDiagramPanelCopy>"; + } + + public String getXMLCloneHead() { + return "<SysCAMSComponentTaskDiagramPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; + } + + public String getXMLCloneTail() { + return "</SysCAMSComponentTaskDiagramPanelCopy>"; + } + + 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 += " TDF=\"true\""; + } else { + s += " TDF=\"false\""; + } + if (eventsVisible) { + s += " DE=\"true\""; + } else { + s += " DE=\"false\""; + } + return s; + } + + public ArrayList<String> getAllCompositeComponent(String _name) { + ArrayList<String> list = new ArrayList<String>(); + TGComponent tgc1; + String s; + SysCAMSCompositeComponent syscamscc; + Iterator<TGComponent> iterator = componentList.listIterator(); + + while(iterator.hasNext()) { + tgc1 = iterator.next(); + + if (tgc1 instanceof SysCAMSCompositeComponent) { + syscamscc = (SysCAMSCompositeComponent)tgc1; + s = _name + "::" + syscamscc.getValue(); + list.add(s); + syscamscc.getAllCompositeComponents(list, _name); + } + } + return list; + } + + public String[] getCompOutTDF(){ + List<String> chls = new ArrayList<String>(); + TGComponent tgc; + Iterator<TGComponent> iterator = componentList.listIterator(); + + while(iterator.hasNext()) { + tgc = iterator.next(); + if (tgc instanceof SysCAMSPrimitiveComponent) { + SysCAMSPrimitiveComponent comp = (SysCAMSPrimitiveComponent) tgc; + List<SysCAMSPrimitivePort> ll = comp.getAllTDFOriginPorts(); + Iterator<SysCAMSPrimitivePort> ite = ll.listIterator(); + while(ite.hasNext()) { + SysCAMSPrimitivePort port = ite.next(); + chls.add(port.getPortName()); + } + } + } + String[] chlArray = new String[chls.size()]; + chlArray = chls.toArray(chlArray); + return chlArray; + } + + public String[] getCompInTDF(){ + List<String> chls = new ArrayList<String>(); + TGComponent tgc; + Iterator<TGComponent> iterator = componentList.listIterator(); + + while(iterator.hasNext()) { + tgc = iterator.next(); + if (tgc instanceof SysCAMSPrimitiveComponent) { + SysCAMSPrimitiveComponent comp = (SysCAMSPrimitiveComponent) tgc; + List<SysCAMSPrimitivePort> ll = comp.getAllTDFDestinationPorts(); + Iterator<SysCAMSPrimitivePort> ite = ll.listIterator(); + while(ite.hasNext()) { + SysCAMSPrimitivePort port = ite.next(); + chls.add(port.getPortName()); + } + } + } + String[] chlArray = new String[chls.size()]; + chlArray = chls.toArray(chlArray); + return chlArray; + } + + public SysCAMSPrimitiveComponent getPrimitiveComponentByName(String _name) { + TGComponent tgc; + Iterator<TGComponent> iterator = componentList.listIterator(); + SysCAMSPrimitiveComponent tmp; + + while(iterator.hasNext()) { + tgc = iterator.next(); + if (tgc instanceof SysCAMSPrimitiveComponent) { + if (tgc.getValue().equals(_name)) { + return ((SysCAMSPrimitiveComponent)tgc); + } + } + if (tgc instanceof SysCAMSCompositeComponent) { + tmp = ((SysCAMSCompositeComponent)tgc).getPrimitiveComponentByName(_name); + if (tmp != null) { + return tmp; + } + } + if (tgc instanceof SysCAMSRemoteCompositeComponent) { + tmp = ((SysCAMSRemoteCompositeComponent)tgc).getPrimitiveComponentByName(_name); + if (tmp != null) { + return tmp; + } + } + } + return null; + } + + public void updateReferenceToSysCAMSCompositeComponent(SysCAMSCompositeComponent syscamscc) { + Iterator<TGComponent> iterator = componentList.listIterator(); + TGComponent tgc; + + while(iterator.hasNext()) { + tgc = iterator.next(); + + if (tgc instanceof SysCAMSCompositeComponent) { + ((SysCAMSCompositeComponent)tgc).updateReferenceToSysCAMSCompositeComponent(syscamscc); + } + + if (tgc instanceof SysCAMSRemoteCompositeComponent) { + ((SysCAMSRemoteCompositeComponent)tgc).updateReference(syscamscc); + } + } + } + + public SysCAMSCompositeComponent getCompositeComponentByName(String _name) { + TGComponent tgc; + Iterator<TGComponent> iterator = componentList.listIterator(); + SysCAMSCompositeComponent tmp; + + while(iterator.hasNext()) { + tgc = iterator.next(); + + if (tgc instanceof SysCAMSCompositeComponent) { + tmp = (SysCAMSCompositeComponent)tgc; + if (tmp.getValue().equals(_name)) { + return tmp; + } + + if ((tmp = tmp.getCompositeComponentByName(name)) != null) { + return tmp; + } + } + } + return null; + } + + public void hideConnectors() { + Iterator<TGComponent> iterator = componentList.listIterator(); + SysCAMSPortConnector connector; + TGComponent tgc; + TGComponent tgc1; + TGComponent tgc2; + + while(iterator.hasNext()) { + tgc = iterator.next(); + + if (tgc instanceof SysCAMSPortConnector) { + connector = (SysCAMSPortConnector) tgc; + tgc1 = getComponentToWhichBelongs(connector.getTGConnectingPointP1()); + tgc2 = getComponentToWhichBelongs(connector.getTGConnectingPointP2()); + if ((tgc1 != null) && (tgc2 != null)) { + if (tgc1.hasAnHiddenAncestor()) { + tgc.setHidden(true); + } else { + if (tgc2.hasAnHiddenAncestor()) { + tgc.setHidden(true); + } else { + tgc.setHidden(false); + } + } + } + } + } + } + + public void loadExtraParameters(Element elt) { + } + + public void setConnectorsToFront() { + TGComponent tgc; + Iterator<TGComponent> iterator = componentList.listIterator(); + List<TGComponent> list = new ArrayList<TGComponent>(); + + while(iterator.hasNext()) { + tgc = iterator.next(); + if (!(tgc instanceof TGConnector)) { + list.add(tgc); + } + } + for(TGComponent tgc1: list) { + componentList.remove(tgc1); + componentList.add(tgc1); + } + } + + public void delayedLoad() { + Iterator<TGComponent> iterator; + TGComponent tgc; + + iterator = componentList.listIterator(); + + while(iterator.hasNext()) { + tgc = iterator.next(); + + if (tgc instanceof SysCAMSCompositeComponent) { + ((SysCAMSCompositeComponent)(tgc)).delayedLoad(); + } + + if (tgc instanceof SysCAMSRemoteCompositeComponent) { + try { + ((SysCAMSRemoteCompositeComponent)(tgc)).delayedLoad(); + } catch (Exception e) { + } + } + } + } + + // Returns the faulty paths + public ArrayList<SysCAMSPath> updatePorts() { + List<SysCAMSPath> paths = makePaths(); + ArrayList<SysCAMSPath> faultyPaths = new ArrayList<SysCAMSPath>(); + + // Checking rules of paths, and setting colors accordingly + for(SysCAMSPath path: paths) { + path.checkRules(); + if (path.hasError()) { + TraceManager.addDev("Path error:" + path.getErrorMessage()); + faultyPaths.add(path); + } + path.setColor(); + } + return faultyPaths; + } + + public void updatePorts_oldVersion() { + Iterator<TGComponent> iterator; + TGComponent tgc; + + // Get all SysCAMSPrimitivePort + List<SysCAMSCompositePort> ports = new ArrayList<SysCAMSCompositePort>(); + List<SysCAMSCompositePort> referencedports = new ArrayList<SysCAMSCompositePort>(); + List<SysCAMSPrimitivePort> pports = new ArrayList<SysCAMSPrimitivePort>(); + List<SysCAMSChannelFacility> facilities = new ArrayList<SysCAMSChannelFacility>(); + + iterator = componentList.listIterator(); + + while(iterator.hasNext()) { + tgc = iterator.next(); + + if (tgc instanceof SysCAMSCompositeComponent) { + ports.addAll(((SysCAMSCompositeComponent)tgc).getAllInternalCompositePorts()); + pports.addAll(((SysCAMSCompositeComponent)tgc).getAllInternalPrimitivePorts()); + referencedports.addAll(((SysCAMSCompositeComponent)tgc).getAllReferencedCompositePorts()); + } + if (tgc instanceof SysCAMSPrimitiveComponent) { + pports.addAll(((SysCAMSPrimitiveComponent)tgc).getAllInternalPrimitivePorts()); + } + if (tgc instanceof SysCAMSCompositePort) { + ports.add((SysCAMSCompositePort)tgc); + } + if (tgc instanceof SysCAMSPrimitivePort) { + pports.add((SysCAMSPrimitivePort)tgc); + } + if (tgc instanceof SysCAMSChannelFacility) { + facilities.add((SysCAMSChannelFacility)tgc); + } + } + + // Remove All Current Links To Ports + for(SysCAMSCompositePort port:ports) { + if (!referencedports.contains(port)) { + port.purge(); + } + } + + // We take each primitive ports individually and we go thru the graph + ArrayList<SysCAMSChannelFacility> mets = new ArrayList<SysCAMSChannelFacility>(); + TGConnector connector; + TGConnectingPoint tp; + String conflictMessage; + + for(SysCAMSPrimitivePort pport:pports) { + for(int i=0; i<pport.getNbConnectingPoint(); i++) { + tp = pport.getTGConnectingPointAtIndex(i); + connector = findTGConnectorUsing(tp); + if (connector != null) { + mets.clear(); + conflictMessage = propagate(pport, tp, connector, mets); + TraceManager.addDev("Conflict=" + conflictMessage); + analysePorts(pport, mets, (conflictMessage != null), conflictMessage); + } + } + } + } + + public String propagate(SysCAMSPrimitivePort pport, TGConnectingPoint tp, TGConnector connector, ArrayList<SysCAMSChannelFacility> mets) { + TGConnectingPoint tp2; + SysCAMSChannelFacility cp = null; + String conflictMessage = null; + String conflictMessageTmp; + int outindex, inindex; + + if (tp == connector.getTGConnectingPointP1()) { + tp2 = connector.getTGConnectingPointP2(); + } else { + tp2 = connector.getTGConnectingPointP1(); + } + + TGComponent tgc = (TGComponent)(tp2.getFather()); + int index = tgc.getIndexOfTGConnectingPoint(tp2); + + if (tgc instanceof SysCAMSPrimitivePort) { + return conflictMessage; + } + + // Cycle? + if (mets.contains(tgc)) { + return "Connection contains a cycle"; + } + if(tgc instanceof SysCAMSCompositePort) { + cp = (SysCAMSChannelFacility)tgc; + mets.add(cp); + + inindex = cp.getInpIndex(); + outindex = cp.getOutpIndex(); + // Already positionned port? + if (pport.isOrigin()) { + if (cp.getOutPort() != null) { + if (pport.getPortType() != 2) { + conflictMessage = "Conflicting ports types"; + } else { + if (cp.getOutPort().getPortType() != 2) { + conflictMessage = "More than two sending non-request ports "; + } else { + if ((outindex<5 && index>4) || (outindex>4 && index<5)) { + conflictMessage = "Sending ports on both side of a composite port"; + } + } + } + } else { + if (inindex > -1) { + if ((inindex<5 && index<5) || (inindex>4 && index>4)) { + conflictMessage = "Sending and receiving ports on the same side of a composite port"; + } + } + cp.setOutPort(pport); + cp.setOutpIndex(index); + } + conflictMessageTmp = explore(pport, tp2, cp, mets); + if (conflictMessageTmp != null) { + conflictMessage = conflictMessageTmp; + } + } else { + if (cp.getInPort() != null) { + conflictMessage = "More than two receiving ports "; + } else { + if (outindex > -1) { + if ((index<5 && outindex<5) || (index>4 && outindex>4)) { + conflictMessage = "Sending and receiving ports on the same side of a composite port"; + } + } + cp.setInPort(pport); + cp.setInpIndex(index); + } + conflictMessageTmp = explore(pport, tp2, cp, mets); + if (conflictMessageTmp != null) { + conflictMessage = conflictMessageTmp; + } + } + } else if(tgc instanceof SysCAMSFork) { + // Only one out, more than one in is ok + // No SysCAMSJoin + cp = (SysCAMSChannelFacility)tgc; + mets.add(cp); + + // Checks that "mets" contains no SysCAMSJoin + for(SysCAMSChannelFacility met: mets) { + if (met instanceof SysCAMSJoin) { + conflictMessage = "Join and Fork operators are mixed in the same channel"; + conflictMessageTmp = explore(pport, tp2, cp, mets); + if (conflictMessageTmp != null) { + conflictMessage = conflictMessageTmp; + } + return conflictMessage; + } + } + + if (pport.isOrigin()) { + if ((cp.getInPort() != null) && (cp.getInPort() != pport)) { + conflictMessage = "More than two sending ports in a fork architecture"; + } + cp.setInPort(pport); + conflictMessageTmp = explore(pport, tp2, cp, mets); + if (conflictMessageTmp != null) { + conflictMessage = conflictMessageTmp; + } + } else { + conflictMessage = explore(pport, tp2, cp, mets); + } + } else if(tgc instanceof SysCAMSJoin) { + // Only one out, more than one in is ok + // No SysCAMSFork + cp = (SysCAMSChannelFacility)tgc; + mets.add(cp); + + // Checks that "mets" contains no SysCAMSJoin + for(SysCAMSChannelFacility met: mets) { + if (met instanceof SysCAMSFork) { + conflictMessage = "Fork and Join operators are mixed in the same channel"; + conflictMessageTmp = explore(pport, tp2, cp, mets); + if (conflictMessageTmp != null) { + conflictMessage = conflictMessageTmp; + } + return conflictMessage; + } + } + + if (!pport.isOrigin()) { + if ((cp.getOutPort() != null) && (cp.getOutPort() != pport)) { + conflictMessage = "More than two receiving ports in a join architecture"; + } + cp.setOutPort(pport); + conflictMessageTmp = explore(pport, tp2, cp, mets); + if (conflictMessageTmp != null) { + conflictMessage = conflictMessageTmp; + } + } else { + conflictMessage = explore(pport, tp2, cp, mets); + } + } + if (cp != null) { + if ((cp.getInPort() != null) && (cp.getOutPort() != null)){ + if (cp.getInPort().getType() != cp.getOutPort().getType()) { + conflictMessage = "Ports are not compatible"; + } else { + TraceManager.addDev("ports of " + cp + " are compatible out=" + cp.getOutPort().getType() + " in=" + cp.getInPort().getType()); + } + } + } + return conflictMessage; + } + + public String explore(SysCAMSPrimitivePort pport, TGConnectingPoint _tp, SysCAMSChannelFacility cp, ArrayList<SysCAMSChannelFacility> mets) { + String conflictMessage = null; + String conflictMessageTmp; + TGConnectingPoint tp; + TGConnector connector; + + for(int i=0; i<cp.getNbConnectingPoint(); i++) { + tp = cp.getTGConnectingPointAtIndex(i); + if (tp != _tp) { + connector = findTGConnectorUsing(tp); + if (connector != null) { + conflictMessageTmp = propagate(pport, tp, connector, mets); + if (conflictMessageTmp != null) { + conflictMessage = conflictMessageTmp; + } + } + } + } + return conflictMessage; + } + + public void analysePorts(SysCAMSPrimitivePort pport, ArrayList<SysCAMSChannelFacility> mets, boolean conflict, String message) { + if (mets.size() == 0) { + return; + } + for(SysCAMSChannelFacility port: mets) { + port.setConflict(conflict, message); + } + } + + public List<String> getAllSysCAMSTaskNames(String _topname) { + TGComponent tgc; + Iterator<TGComponent> iterator = componentList.listIterator(); + List<String> list = new ArrayList<String>(); + while(iterator.hasNext()) { + tgc = iterator.next(); + + if (tgc instanceof SysCAMSPrimitiveComponent) { + list.add(_topname + "::" + tgc.getValue()); + } + } + return list; + } + + public Vector<String> getAllSysCAMSTasksAttributes() { + TGComponent tgc; + Iterator<TGComponent> iterator = componentList.listIterator(); + Vector<String> list = new Vector<String>(); + + while(iterator.hasNext()) { + tgc = iterator.next(); + if( tgc instanceof SysCAMSCompositeComponent ) { + for( SysCAMSPrimitiveComponent primComp: ((SysCAMSCompositeComponent)tgc).getAllPrimitiveComponents() ) { + for( Object o: primComp.getAttributeList() ) { + String s = o.toString(); + list.add( primComp.getValue() + "." + s.substring( 2, s.length()-1 ) ); + } + } + } + } + return list; + } + + public Vector<String> getAllRecords(SysCAMSPrimitiveComponent tgc) { + Vector<String> list = new Vector<String>(); + getAllRecords((SysCAMSCompositeComponent)(tgc.getFather()), list); + return list; + } + + public void getAllRecords(SysCAMSCompositeComponent comp, Vector<String> list) { + TGComponent tgc; + if (comp == null) { + Iterator<TGComponent> iterator = componentList.listIterator(); + while(iterator.hasNext()) { + tgc = iterator.next(); + if (tgc instanceof SysCAMSRecordComponent) { + list.add(tgc.getValue()); + } + } + return; + } + + for(int i=0; i<comp.getNbInternalTGComponent(); i++) { + tgc = comp.getInternalTGComponent(i); + if (tgc instanceof SysCAMSRecordComponent) { + list.add(tgc.getValue()); + } + } + getAllRecords((SysCAMSCompositeComponent)(comp.getFather()), list); + } + + public SysCAMSRecordComponent getRecordNamed(SysCAMSPrimitiveComponent tgc, String _nameOfRecord) { + return getRecordNamed((SysCAMSCompositeComponent)(tgc.getFather()), _nameOfRecord); + } + + public SysCAMSRecordComponent getRecordNamed(SysCAMSCompositeComponent comp, String _nameOfRecord) { + TGComponent tgc; + if (comp == null) { + Iterator<TGComponent> iterator = componentList.listIterator(); + while(iterator.hasNext()) { + tgc = iterator.next(); + if (tgc instanceof SysCAMSRecordComponent) { + if (tgc.getValue().compareTo(_nameOfRecord) == 0) { + return (SysCAMSRecordComponent)tgc; + } + } + } + return null; + } + for(int i=0; i<comp.getNbInternalTGComponent(); i++) { + tgc = comp.getInternalTGComponent(i); + if (tgc instanceof SysCAMSRecordComponent) { + if (tgc.getValue().compareTo(_nameOfRecord) == 0) { + return (SysCAMSRecordComponent)tgc; + } + } + } + return getRecordNamed((SysCAMSCompositeComponent)(comp.getFather()), _nameOfRecord); + } + + public void findAllReferencedPanels( List<SysCAMSComponentTaskDiagramPanel> panels) { + if (panels.contains(this)) { + return; + } + panels.add(this); + + Iterator<TGComponent> iterator = componentList.listIterator(); + TGComponent tgc; + + while(iterator.hasNext()) { + tgc = iterator.next(); + if (tgc instanceof SysCAMSRemoteCompositeComponent) { + SysCAMSRemoteCompositeComponent remote = (SysCAMSRemoteCompositeComponent)tgc; + TDiagramPanel panel = remote.getReferencedDiagram(); + if ((panel != null) && (panel instanceof SysCAMSComponentTaskDiagramPanel)){ + ((SysCAMSComponentTaskDiagramPanel)panel).findAllReferencedPanels(panels); + } + } + if (tgc instanceof SysCAMSCompositeComponent) { + //We must find all panels referencing this component + panels.addAll(mgui.getAllPanelsReferencingSysCAMSCompositeComponent((SysCAMSCompositeComponent)tgc)); + } + } + } + + public List<SysCAMSPath> makePaths() { + List<SysCAMSComponentTaskDiagramPanel> panels = new ArrayList<SysCAMSComponentTaskDiagramPanel>(); + + // We first find all the implicated panels + findAllReferencedPanels(panels); + + List<SysCAMSPath> paths = new ArrayList<SysCAMSPath>(); + Iterator<TGComponent> iterator; + TGComponent tgc; + + // Go through the component list of all panels, and make paths. Then, go thru connectors, + // and merge paths until nomore merging is possible + for (TDiagramPanel panel: panels) { + iterator = panel.getComponentList().listIterator(); + List<SysCAMSCompositePort> listcp; + List<SysCAMSPrimitivePort> listpp; + + while(iterator.hasNext()) { + tgc = iterator.next(); + + if (tgc instanceof SysCAMSCompositeComponent) { + listcp = ((SysCAMSCompositeComponent)tgc).getAllInternalCompositePorts(); + for(SysCAMSCompositePort cp: listcp) { + addToPaths(paths, cp); + } + listpp = ((SysCAMSCompositeComponent)tgc).getAllInternalPrimitivePorts(); + for(SysCAMSPrimitivePort pp: listpp) { + addToPaths(paths, pp); + } + } + if (tgc instanceof SysCAMSPrimitiveComponent) { + listpp = ((SysCAMSPrimitiveComponent)tgc).getAllInternalPrimitivePorts(); + for(SysCAMSPrimitivePort pp: listpp) { + addToPaths(paths, pp); + } + } + if (tgc instanceof SysCAMSPrimitivePort) { + addToPaths(paths, tgc); + } + if (tgc instanceof SysCAMSChannelFacility) { + addToPaths(paths, tgc); + } + } + } + + // Use connectors to merge paths with one another + for (TDiagramPanel panel: panels) { + iterator = panel.getComponentList().listIterator(); + SysCAMSPortConnector connector; + TGComponent tgc1, tgc2; + SysCAMSPath path1, path2; + + while(iterator.hasNext()) { + tgc = iterator.next(); + if (tgc instanceof SysCAMSPortConnector) { + connector = (SysCAMSPortConnector)tgc; + if (connector.getTGConnectingPointP1().getFather() instanceof TGComponent) { + tgc1 = (TGComponent)(connector.getTGConnectingPointP1().getFather()); + } else { + tgc1 = null; + } + if (connector.getTGConnectingPointP2().getFather() instanceof TGComponent) { + tgc2 = (TGComponent)(connector.getTGConnectingPointP2().getFather()); + } else { + tgc2 = null; + } + if (tgc1 instanceof SysCAMSRemoteCompositeComponent) { + tgc1 = ((SysCAMSRemoteCompositeComponent)tgc1).getPortOf(connector.getTGConnectingPointP1()); + } + if (tgc2 instanceof SysCAMSRemoteCompositeComponent) { + tgc2 = ((SysCAMSRemoteCompositeComponent)tgc2).getPortOf(connector.getTGConnectingPointP2()); + } + if ((tgc1 != null) && (tgc2 != null) && (tgc1 != tgc2)) { + path1 = getPathOf(paths, tgc1); + path2 = getPathOf(paths, tgc2); + if ((path1 != null) && (path2 != null)) { + // Not in the same path -> we must do a merging + // and then we remove path2 from path + if (path1 != path2) { + path1.mergeWith(path2); + paths.remove(path2); + } + } + } else { + // If there is a null component in the path, then, we must set an error in the path + if ((tgc1 == null) && (tgc2 != null)) { + path2 = getPathOf(paths, tgc2); + path2.setErrorOfConnection(true); + + } + if ((tgc2 == null) && (tgc1 != null)) { + path1 = getPathOf(paths, tgc1); + path1.setErrorOfConnection(true); + } + } + } + } + } + return paths; + } + + public SysCAMSPath getPathOf( List<SysCAMSPath> paths, TGComponent tgc) { + for(SysCAMSPath path: paths) { + if (path.contains(tgc)) { + return path; + } + } + return null; + } + + public void addToPaths( List<SysCAMSPath> paths, TGComponent tgc) { + for(SysCAMSPath path: paths) { + if (path.contains(tgc)) { + return; + } + } + // Create a new path + SysCAMSPath ph = new SysCAMSPath(); + ph.addComponent(tgc); + paths.add(ph); + } + + + public void getPanelsUsingAComponent(SysCAMSCompositeComponent syscamscc, ArrayList<SysCAMSComponentTaskDiagramPanel> panels) { + Iterator<TGComponent> iterator = componentList.listIterator(); + TGComponent tgc; + + while(iterator.hasNext()) { + tgc = iterator.next(); + if (tgc instanceof SysCAMSCompositeComponent) { + if (((SysCAMSCompositeComponent)tgc).hasReferencesTo(syscamscc)) { + panels.add(this); + return; + } + } + if (tgc instanceof SysCAMSRemoteCompositeComponent) { + if (((SysCAMSRemoteCompositeComponent)tgc).getReference() == syscamscc) { + panels.add(this); + return; + } + } + } + } + + public String[] getAllOutDE(String nameOfComponent) { + SysCAMSPrimitiveComponent comp = getPrimitiveComponentByName(nameOfComponent); + if (comp == null) { + return null; + } + List<SysCAMSPrimitivePort> ll = comp.getAllDEOriginPorts(); + String[]terms = new String[ll.size()]; + Iterator<SysCAMSPrimitivePort> ite = ll.listIterator(); + int i = 0; + + while(ite.hasNext()) { + SysCAMSPrimitivePort port = ite.next(); + terms[i] = port.getPortName(); + i ++; + } + return terms; + } + + public String[] getAllInDE(String nameOfComponent) { + SysCAMSPrimitiveComponent comp = getPrimitiveComponentByName(nameOfComponent); + if (comp == null) { + return null; + } + List<SysCAMSPrimitivePort> ll = comp.getAllDEDestinationPorts(); + String[]terms = new String[ll.size()]; + ListIterator<SysCAMSPrimitivePort> ite = ll.listIterator(); + int i = 0; + while(ite.hasNext()) { + SysCAMSPrimitivePort port = ite.next(); + terms[i] = port.getPortName(); + i ++; + } + return terms; + } + + public String[] getAllOutTDF(String nameOfComponent) { + SysCAMSPrimitiveComponent comp = getPrimitiveComponentByName(nameOfComponent); + if (comp == null) { + return null; + } + List<SysCAMSPrimitivePort> ll = comp.getAllTDFOriginPorts(); + String[]terms = new String[ll.size()]; + Iterator<SysCAMSPrimitivePort> ite = ll.listIterator(); + int i = 0; + while(ite.hasNext()) { + SysCAMSPrimitivePort port = ite.next(); + terms[i] = port.getPortName(); + i++; + } + return terms; + } + + public String[] getAllInTDF(String nameOfComponent) { + SysCAMSPrimitiveComponent comp = getPrimitiveComponentByName(nameOfComponent); + if (comp == null) { + return null; + } + + List<SysCAMSPrimitivePort> ll = comp.getAllTDFDestinationPorts(); + String[]terms = new String[ll.size()]; + Iterator<SysCAMSPrimitivePort> ite = ll.listIterator(); + int i = 0; + + while(ite.hasNext()) { + SysCAMSPrimitivePort port = ite.next(); + terms[i] = port.getPortName(); + i++; + } + return terms; + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java b/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java new file mode 100644 index 0000000000..7f20e799aa --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSComponentTaskDiagramToolBar.java @@ -0,0 +1,124 @@ +/* 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.syscams; + +import ui.MainGUI; +import ui.TGUIAction; +import ui.TToolBar; + +import javax.swing.*; + +/** + * Class SysCAMSComponentTaskDiagramToolBar Implements the toolbar to be used in + * conjunction with the panel of a SystemC-AMS diagram Creation: 22/04/2018 + * + * @version 1.0 22/04/2018 + * @author Irina Kit Yan LEE + * @see SysCAMSComponentTaskDiagramPanel + */ + +@SuppressWarnings("serial") + +public class SysCAMSComponentTaskDiagramToolBar extends TToolBar { + + public SysCAMSComponentTaskDiagramToolBar(MainGUI _mgui) { + super(_mgui); + } + + protected void setActive(boolean b) { + mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(b); + mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(b); + + mgui.actions[TGUIAction.CAMS_EDIT].setEnabled(b); + mgui.actions[TGUIAction.UML_NOTE].setEnabled(b); + mgui.actions[TGUIAction.CAMS_CONNECTOR].setEnabled(b); + mgui.actions[TGUIAction.CAMS_BLOCK_TDF].setEnabled(b); + mgui.actions[TGUIAction.CAMS_BLOCK_DE].setEnabled(b); + mgui.actions[TGUIAction.CAMS_PORT_TDF].setEnabled(b); + mgui.actions[TGUIAction.CAMS_PORT_DE].setEnabled(b); + mgui.actions[TGUIAction.CAMS_PORT_CONVERTER].setEnabled(b); + mgui.actions[TGUIAction.CAMS_CLUSTER].setEnabled(b); + + 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.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(b); + mgui.updateZoomInfo(); + } + + protected void setButtons() { + JButton button; + + button = this.add(mgui.actions[TGUIAction.CAMS_EDIT]); + button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.UML_NOTE]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.CAMS_CLUSTER]); + button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.CAMS_PORT_CONVERTER]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.CAMS_BLOCK_TDF]); + button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.CAMS_PORT_TDF]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.CAMS_BLOCK_DE]); + button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.CAMS_PORT_DE]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.CAMS_CONNECTOR]); + button.addMouseListener(mgui.mouseHandler); + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSCompositeComponent.java b/src/main/java/ui/syscams/SysCAMSCompositeComponent.java new file mode 100644 index 0000000000..fddb4ac31a --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSCompositeComponent.java @@ -0,0 +1,633 @@ +/* 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.syscams; + +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 javax.swing.*; +import java.awt.*; +import java.util.ArrayList; +import java.util.ListIterator; + +/** + * Class SysCAMSCompositeComponent + * Composite Component. To be used in SystemC-AMS diagrams + * Creation: 27/04/2018 + * + * @author Irina Kit Yan LEE + * @version 1.0 27/04/2018 + */ + +public class SysCAMSCompositeComponent extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent, HiddenInternalComponents { + private int maxFontSize = 20; + private int minFontSize = 4; + private int currentFontSize = -1; + private boolean displayText = true; + private Color myColor; + private int iconSize = 17; + + private int textX = 15; // border for ports + private double dtextX = 0.0; + + private boolean hiddeni; + + private int compositePortNb = 0; + + public SysCAMSCompositeComponent(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); + + initScaling(250, 200); + + oldScaleFactor = tdp.getZoom(); + dtextX = textX * oldScaleFactor; + textX = (int) dtextX; + dtextX = dtextX - textX; + + minWidth = 1; + minHeight = 1; + + nbConnectingPoint = 0; + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + maxWidth = 2000; + maxHeight = 2000; + + moveable = true; + editable = true; + removable = true; + userResizable = true; + + value = "Cluster"; + name = "Composite component"; + + myImageIcon = IconManager.imgic1200; + } + + public void internalDrawing(Graphics g) { + int w; + int c; + Font f = g.getFont(); + Font fold = f; + + if (myColor == null) { + if (ColorManager.TML_COMPOSITE_COMPONENT == Color.white) { + myColor = Color.white; + } else { + myColor = Color.white; + } + } + if ((rescaled) && (!tdp.isScaled())) { + if (currentFontSize == -1) { + currentFontSize = f.getSize(); + } + rescaled = false; + // Must set the font size .. + // Find the biggest font not greater than max_font size + // By Increment of 1 + // Or decrement of 1 + // If font is less than 4, no text is displayed + + int maxCurrentFontSize = Math.max(0, Math.min(height - (2 * textX), maxFontSize)); + + while (maxCurrentFontSize > (minFontSize - 1)) { + f = f.deriveFont((float) maxCurrentFontSize); + g.setFont(f); + w = g.getFontMetrics().stringWidth(value); + c = width - iconSize - (2 * textX); + if (w < c) { + break; + } + maxCurrentFontSize--; + } + currentFontSize = maxCurrentFontSize; + displayText = currentFontSize >= minFontSize; + } + // Zoom is assumed to be computed + Color col = g.getColor(); + g.drawRect(x, y, width, height); + if ((width > 2) && (height > 2)) { + g.setColor(myColor); + g.fillRect(x + 1, y + 1, width - 1, height - 1); + g.setColor(col); + } + // Font size + if (displayText) { + f = f.deriveFont((float) currentFontSize); + g.setFont(f); + w = g.getFontMetrics().stringWidth(value); + if (!(w < (width - 2 * (iconSize + textX)))) { + g.drawString(value, x + textX + 1, y + currentFontSize + textX); + } else { + g.drawString(value, x + (width - w) / 2, y + currentFontSize + textX); + } + } + g.setFont(fold); +// // Icon +// if ((width>30) && (height > (iconSize + 2*textX))) { +// g.drawImage(IconManager.imgic1200.getImage(), x + width - iconSize - textX, y + textX, null); +// } + } + + public void rescale(double scaleFactor) { + dtextX = (textX + dtextX) / oldScaleFactor * scaleFactor; + textX = (int) (dtextX); + dtextX = dtextX - textX; + super.rescale(scaleFactor); + } + + public TGComponent isOnOnlyMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; + } + + public boolean editOndoubleClick(JFrame frame) { + String s = (String) JOptionPane.showInputDialog(frame, "Name:", "Setting component name", + JOptionPane.PLAIN_MESSAGE, IconManager.imgic100, + null, + getValue()); + if ((s != null) && (s.length() > 0)) { + if (!TAttribute.isAValidId(s, false, false)) { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the component: the new name is not a valid name", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + if (((SysCAMSComponentTaskDiagramPanel) (tdp)).isCompositeNameUsed(s)) { + JOptionPane.showMessageDialog(frame, + "Error: the name is already in use", + "Name modification", + JOptionPane.ERROR_MESSAGE); + return false; + } + setValueWithChange(s); + return true; + } + return false; + } + + public int getType() { + return TGComponentManager.CAMS_CLUSTER; + } + + public void wasSwallowed() { + myColor = null; + } + + public void wasUnswallowed() { + myColor = null; + setFather(null); + TDiagramPanel tdp = getTDiagramPanel(); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); + } + + public boolean acceptSwallowedTGComponent(TGComponent tgc) { + if (tgc instanceof SysCAMSCompositeComponent) { + return true; + } + if (tgc instanceof SysCAMSRecordComponent) { + return true; + } + if (tgc instanceof SysCAMSPrimitiveComponent) { + return true; + } + if (tgc instanceof SysCAMSRemoteCompositeComponent) { + return true; + } + return tgc instanceof SysCAMSCompositePort; + } + + public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { + boolean swallowed = false; + + for (int i = 0; i < nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SwallowTGComponent) { + if (((SwallowTGComponent) tgcomponent[i]).acceptSwallowedTGComponent(tgc)) { + if (tgcomponent[i].isOnMe(x, y) != null) { + swallowed = true; + ((SwallowTGComponent) tgcomponent[i]).addSwallowedTGComponent(tgc, x, y); + break; + } + } + } + } + if (swallowed) { + return true; + } + if (!acceptSwallowedTGComponent(tgc)) { + return false; + } + // Choose its position + + // Make it an internal component + // It's one of my son + tgc.setFather(this); + tgc.setDrawingZone(true); + + //Set its coordinates + if (tgc instanceof SysCAMSCompositeComponent) { + tgc.resizeWithFather(); + } + + if (tgc instanceof SysCAMSRecordComponent) { + tgc.resizeWithFather(); + } + + if (tgc instanceof SysCAMSPrimitiveComponent) { + tgc.resizeWithFather(); + } + + if (tgc instanceof SysCAMSRemoteCompositeComponent) { + tgc.resizeWithFather(); + } + if (tgc instanceof SysCAMSCompositePort) { + tgc.resizeWithFather(); + compositePortNb++; + } + //add it + addInternalComponent(tgc, 0); + return true; + } + + public void removeSwallowedTGComponent(TGComponent tgc) { + if (tgc instanceof SysCAMSCompositePort) { + portRemoved(); + } + for (int i = 0; i < nbInternalTGComponent; i++) { + if (tgcomponent[i] == tgc) { + nbInternalTGComponent = nbInternalTGComponent - 1; + if (nbInternalTGComponent == 0) { + tgcomponent = null; + } else { + TGComponent[] tgcomponentbis = new TGComponent[nbInternalTGComponent]; + for (int j = 0; j < nbInternalTGComponent; j++) { + if (j < i) { + tgcomponentbis[j] = tgcomponent[j]; + } + if (j >= i) { + tgcomponentbis[j] = tgcomponent[j + 1]; + } + } + tgcomponent = tgcomponentbis; + } + break; + } + } + } + + public void hasBeenResized() { + rescaled = true; + for (int i = 0; i < nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSCompositeComponent) { + tgcomponent[i].resizeWithFather(); + } + if (tgcomponent[i] instanceof SysCAMSPrimitiveComponent) { + tgcomponent[i].resizeWithFather(); + } + if (tgcomponent[i] instanceof SysCAMSRecordComponent) { + tgcomponent[i].resizeWithFather(); + } + if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) { + tgcomponent[i].resizeWithFather(); + } + if (tgcomponent[i] instanceof SysCAMSCompositePort) { + tgcomponent[i].resizeWithFather(); + } + } + if (getFather() != null) { + resizeWithFather(); + } + } + + public void resizeWithFather() { + if ((father != null) && ((father instanceof SysCAMSCompositeComponent) || (father instanceof SysCAMSPrimitiveComponent))) { + // Too large to fit in the father? -> resize it! + resizeToFatherSize(); + + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); + setMoveCd(x, y); + } + } + + public java.util.List<SysCAMSPrimitiveComponent> getAllPrimitiveComponents() { + ArrayList<SysCAMSPrimitiveComponent> ll = new ArrayList<SysCAMSPrimitiveComponent>(); + for (int i = 0; i < nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSCompositeComponent) { + ll.addAll(((SysCAMSCompositeComponent) tgcomponent[i]).getAllPrimitiveComponents()); + } + if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) { + ll.addAll(((SysCAMSRemoteCompositeComponent) tgcomponent[i]).getAllPrimitiveComponents()); + } + if (tgcomponent[i] instanceof SysCAMSPrimitiveComponent) { + ll.add(((SysCAMSPrimitiveComponent) (tgcomponent[i]))); + } + } + return ll; + } + + public ArrayList<SysCAMSRecordComponent> getAllRecordComponents() { + ArrayList<SysCAMSRecordComponent> ll = new ArrayList<SysCAMSRecordComponent>(); + for (int i = 0; i < nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSCompositeComponent) { + ll.addAll(((SysCAMSCompositeComponent) tgcomponent[i]).getAllRecordComponents()); + } + if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) { + ll.addAll(((SysCAMSRemoteCompositeComponent) tgcomponent[i]).getAllRecordComponents()); + } + + if (tgcomponent[i] instanceof SysCAMSRecordComponent) { + ll.add(((SysCAMSRecordComponent) (tgcomponent[i]))); + } + } + return ll; + } + + public void getAllCompositeComponents(ArrayList<String> list, String _name) { + String s; + SysCAMSCompositeComponent syscamscc; + for (int i = 0; i < nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSCompositeComponent) { + syscamscc = (SysCAMSCompositeComponent) tgcomponent[i]; + s = _name + "::" + syscamscc.getValue(); + list.add(s); + syscamscc.getAllCompositeComponents(list, _name); + } + } + } + + public ArrayList<SysCAMSCompositePort> getAllInternalCompositePorts() { + ArrayList<SysCAMSCompositePort> list = new ArrayList<SysCAMSCompositePort>(); + for (int i = 0; i < nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSCompositeComponent) { + list.addAll(((SysCAMSCompositeComponent) tgcomponent[i]).getAllInternalCompositePorts()); + } + if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) { + list.addAll(((SysCAMSRemoteCompositeComponent) tgcomponent[i]).getAllInternalCompositePorts()); + } + if (tgcomponent[i] instanceof SysCAMSCompositePort) { + list.add((SysCAMSCompositePort) (tgcomponent[i])); + } + } + return list; + } + + public ArrayList<SysCAMSCompositePort> getAllReferencedCompositePorts() { + ArrayList<SysCAMSCompositePort> list = new ArrayList<SysCAMSCompositePort>(); + for (int i = 0; i < nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSCompositeComponent) { + list.addAll(((SysCAMSCompositeComponent) tgcomponent[i]).getAllReferencedCompositePorts()); + } + if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) { + list.addAll(((SysCAMSRemoteCompositeComponent) tgcomponent[i]).getAllInternalCompositePorts()); + } + } + return list; + } + + public ArrayList<SysCAMSCompositePort> getFirstLevelCompositePorts() { + ArrayList<SysCAMSCompositePort> list = new ArrayList<SysCAMSCompositePort>(); + for (int i = 0; i < nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSCompositePort) { + list.add((SysCAMSCompositePort) (tgcomponent[i])); + } + } + return list; + } + + public ArrayList<SysCAMSPrimitivePort> getAllInternalPrimitivePorts() { + ArrayList<SysCAMSPrimitivePort> list = new ArrayList<SysCAMSPrimitivePort>(); + for (int i = 0; i < nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSCompositeComponent) { + list.addAll(((SysCAMSCompositeComponent) tgcomponent[i]).getAllInternalPrimitivePorts()); + } + if (tgcomponent[i] instanceof SysCAMSPrimitiveComponent) { + list.addAll(((SysCAMSPrimitiveComponent) tgcomponent[i]).getAllInternalPrimitivePorts()); + } + } + return list; + } + + public SysCAMSPrimitiveComponent getPrimitiveComponentByName(String _name) { + SysCAMSPrimitiveComponent tgc; + ListIterator<SysCAMSPrimitiveComponent> li = getAllPrimitiveComponents().listIterator(); + + while (li.hasNext()) { + tgc = li.next(); + if (tgc.getValue().equals(_name)) { + return tgc; + } + } + return null; + } + + public SysCAMSCompositeComponent getCompositeComponentByName(String _name) { + TGComponent tgc; + SysCAMSCompositeComponent tmp; + + for (int i = 0; i < nbInternalTGComponent; i++) { + tgc = tgcomponent[i]; + if (tgc instanceof SysCAMSCompositeComponent) { + tmp = (SysCAMSCompositeComponent) tgc; + if (tmp.getValue().equals(_name)) { + return tmp; + } + + if ((tmp = tmp.getCompositeComponentByName(name)) != null) { + return tmp; + } + } + } + return null; + } + + public void setInternalsHidden(boolean hide) { + hiddeni = hide; + for (int i = 0; i < nbInternalTGComponent; i++) { + if (!(tgcomponent[i] instanceof SysCAMSCompositePort)) { + tgcomponent[i].setHidden(hide); + } + } + + if (tdp instanceof SysCAMSComponentTaskDiagramPanel) { + ((SysCAMSComponentTaskDiagramPanel) tdp).hideConnectors(); + } + } + + public boolean areInternalsHidden() { + return hiddeni; + } + + public void drawInternalComponentsWhenHidden(Graphics g) { + for (int i = 0; i < nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSCompositePort) { + tgcomponent[i].draw(g); + } + } + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<info hiddeni=\"" + hiddeni + "\" "); + sb.append("/>\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException { + try { + NodeList nli; + Node n1, n2; + Element elt; + + for (int i = 0; i < nl.getLength(); i++) { + n1 = nl.item(i); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for (int j = 0; j < nli.getLength(); j++) { + n2 = nli.item(j); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("info")) { + if (elt.getAttribute("hiddeni").equals("true")) { + setInternalsHidden(true); + } + } + + } + } + } + } + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + public void drawTGConnectingPoint(Graphics g, int type) { + for (int i = 0; i < nbConnectingPoint; i++) { + if (connectingPoint[i].isCompatibleWith(type)) { + connectingPoint[i].draw(g); + } + } + + for (int i = 0; i < nbInternalTGComponent; i++) { + if (hiddeni) { + if (tgcomponent[i] instanceof SysCAMSCompositePort) { + tgcomponent[i].drawTGConnectingPoint(g, type); + } + } else { + tgcomponent[i].drawTGConnectingPoint(g, type); + } + } + } + + public String getExtendedValue() { + return getValuePanel() + "::" + getValue(); + } + + public void myActionWhenRemoved() { + for (int i = 0; i < nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSCompositeComponent) { + tgcomponent[i].myActionWhenRemoved(); + } + } + tdp = null; + } + + public void updateReferenceToSysCAMSCompositeComponent(SysCAMSCompositeComponent syscamscc) { + for (int i = 0; i < nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) { + ((SysCAMSRemoteCompositeComponent) tgcomponent[i]).updateReference(syscamscc); + } + if (tgcomponent[i] instanceof SysCAMSCompositeComponent) { + ((SysCAMSCompositeComponent) tgcomponent[i]).updateReferenceToSysCAMSCompositeComponent(syscamscc); + } + } + } + + public void delayedLoad() { + for (int i = 0; i < nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) { + try { + ((SysCAMSRemoteCompositeComponent) tgcomponent[i]).delayedLoad(); + } catch (Exception e) { + } + } + if (tgcomponent[i] instanceof SysCAMSCompositeComponent) { + ((SysCAMSCompositeComponent) tgcomponent[i]).delayedLoad(); + } + } + } + + public int getCompositePortNb() { + return compositePortNb; + } + + public void portRemoved() { + compositePortNb--; + } + + public boolean hasReferencesTo(SysCAMSCompositeComponent syscamscc) { + boolean b; + + for (int i = 0; i < nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSRemoteCompositeComponent) { + b = ((SysCAMSRemoteCompositeComponent) tgcomponent[i]).getReference() == syscamscc; + if (b) { + return true; + } + } + if (tgcomponent[i] instanceof SysCAMSCompositeComponent) { + b = ((SysCAMSCompositeComponent) tgcomponent[i]).hasReferencesTo(syscamscc); + if (b) { + return true; + } + } + } + return false; + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSCompositePort.java b/src/main/java/ui/syscams/SysCAMSCompositePort.java new file mode 100644 index 0000000000..5a8ac86da5 --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSCompositePort.java @@ -0,0 +1,325 @@ +/* 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.syscams; + +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; +import ui.window.JDialogSysCAMSPortConverter; + +import java.awt.*; +import javax.swing.ImageIcon; +import javax.swing.JFrame; + +/** + * Class SysCAMSCompositePort + * Composite port. To be used in SystemC-AMS diagrams + * Creation: 29/04/2018 + * @version 1.0 29/04/2018 + * @author Irina Kit Yan LEE + */ + +public class SysCAMSCompositePort extends SysCAMSChannelFacility implements SwallowedTGComponent, WithAttributes { + private int oldx, oldy; + private int halfwidth = 13; + private int currentOrientation = GraphicLib.NORTH; + protected int decPoint = 3; + private ImageIcon portImageIconW, portImageIconE, portImageIconN, portImageIconS; + public String commName; + + // Attributes + public String portName; + public int period; + public int rate; + public int delay; + public String type; + public String origin; + + public SysCAMSCompositePort(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); + + initScaling(2*halfwidth, 2*halfwidth); + + minWidth = 10; + minHeight = 10; + + nbConnectingPoint = 10; + connectingPoint = new TGConnectingPoint[10]; + int i; + for (i=0; i<5; i++) { + connectingPoint[i] = new SysCAMSPortConnectingPoint(this, 0, 0, true, true, 0.5, 0.0); + } + for(i=5; i<10; i++) { + connectingPoint[i] = new SysCAMSPortConnectingPoint(this, 0, 0, true, true, 0.5, 1.0); + } + + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + value = ""; + name = "Composite port"; + commName = "port"; + + myImageIcon = IconManager.imgic1204; + portImageIconW = IconManager.imgic8002; + portImageIconE = IconManager.imgic8003; + portImageIconN = IconManager.imgic8004; + portImageIconS = IconManager.imgic8005; + + // Initialization of port attributes + ((SysCAMSPortConverter) this).setPeriod(0); + ((SysCAMSPortConverter) this).setDelay(0); + ((SysCAMSPortConverter) this).setRate(0); + ((SysCAMSPortConverter) this).setConvType(""); + ((SysCAMSPortConverter) this).setOrigin(""); + } + + public void internalDrawing(Graphics g) { + if ((x != oldx) | (oldy != y)) { + // Component has moved! + manageMove(); + oldx = x; + oldy = y; + } + if (rescaled) { + rescaled = false; + } + + calculatePortColor(); + + // Zoom is assumed to be computed + Color c = g.getColor(); + g.setColor(c); + + TGComponent tgc = getFather(); + + if ((tgc != null) && (tgc instanceof SysCAMSCompositeComponent)) { + if (tgc instanceof SysCAMSCompositeComponent && this instanceof SysCAMSCompositePort) { + switch(currentOrientation) { + case GraphicLib.NORTH: + g.drawRect(x-1+width/2-portImageIconN.getIconWidth()/2, y-1+height/2-portImageIconN.getIconHeight()/2, portImageIconN.getIconWidth()+2, portImageIconN.getIconHeight()+2); + g.drawImage(portImageIconN.getImage(), x+width/2-portImageIconN.getIconWidth()/2, y+height/2-portImageIconN.getIconHeight()/2, null); + break; + case GraphicLib.SOUTH: + g.drawRect(x+width/2-portImageIconS.getIconWidth()/2, y+height/2-portImageIconS.getIconHeight()/2, portImageIconS.getIconWidth(), portImageIconS.getIconHeight()); + g.drawImage(portImageIconS.getImage(), x+width/2-portImageIconS.getIconWidth()/2, y+height/2-portImageIconS.getIconHeight()/2, null); + break; + case GraphicLib.WEST: + g.drawRect(x+width/2-portImageIconW.getIconWidth()/2, y+height/2-portImageIconW.getIconHeight()/2, portImageIconW.getIconWidth(), portImageIconW.getIconHeight()); + g.drawImage(portImageIconW.getImage(), x+width/2-portImageIconW.getIconWidth()/2, y+height/2-portImageIconW.getIconHeight()/2, null); + break; + case GraphicLib.EAST: + default: + g.drawRect(x+width/2-portImageIconE.getIconWidth()/2, y+height/2-portImageIconE.getIconHeight()/2, portImageIconE.getIconWidth(), portImageIconE.getIconHeight()); + g.drawImage(portImageIconE.getImage(), x+width/2-portImageIconE.getIconWidth()/2, y+height/2-portImageIconE.getIconHeight()/2, null); + } + } + } + + int ft = 10; + if ((tgc != null) && (tgc instanceof SysCAMSPrimitiveComponent)) { + ft = ((SysCAMSPrimitiveComponent)tgc).getCurrentFontSize(); + } + int w; + Font f = g.getFont(); + Font fold = f; + + int si = Math.min(8, (int)((float)ft - 2)); + f = f.deriveFont((float)si); + g.setFont(f); + w = g.getFontMetrics().stringWidth(commName); + if (w < ((int)(width * 1.5))) { + g.drawString(commName, x, y-1); + } + + g.setFont(fold); + + // Draw arrow showing the connection if necessary + if ((!conflict) && (outp != null || inp != null)) { + int wayTo = currentOrientation; + if (inp != null) { + if (inpIndex > 4) { + wayTo = (wayTo + 2 )% 4; + } + } else { + if (outpIndex < 5) { + wayTo = (wayTo + 2 )% 4; + } + } + + int []px = new int[3]; + int []py = new int[3]; + switch(wayTo) { + case GraphicLib.NORTH: + case GraphicLib.SOUTH: + px[0] = x+width/2; + px[1] = x +width/2; + py[0] = y; + py[1] = y + height; + break; + case GraphicLib.EAST: + case GraphicLib.WEST: + default: + px[0] = x; + px[1] = x +width; + py[0] = y+height/2; + py[1] = y + height/2; + break; + } + g.drawPolygon(px, py, 2); + } + } + + public void manageMove() { + if (father != null) { + Point p = GraphicLib.putPointOnRectangle(x+(width/2), y+(height/2), father.getX(), father.getY(), father.getWidth(), father.getHeight()); + + x = p.x - width/2; + y = p.y - height/2; + + setMoveCd(x, y); + + int orientation = GraphicLib.getCloserOrientation(x+(width/2), y+(height/2), father.getX(), father.getY(), father.getWidth(), father.getHeight()); + if (orientation != currentOrientation) { + setOrientation(orientation); + } + } + } + + // TGConnecting points .. + public void setOrientation(int orientation) { + currentOrientation = orientation; + double w0, h0,w1, h1; + + switch(orientation) { + case GraphicLib.NORTH: + w0 = 0.5; + h0 = 0.0; + w1 = 0.5; + h1 = 1.0; + break; + case GraphicLib.WEST: + w0 = 0.0; + h0 = 0.5; + w1 = 1.0; + h1 = 0.5; + break; + case GraphicLib.SOUTH: + w1 = 0.5; + h1 = 0.0; + w0 = 0.5; + h0 = 1.0; + break; + case GraphicLib.EAST: + default: + w1 = 0.0; + h1 = 0.5; + w0 = 1.0; + h0 = 0.5; + } + + for (int i=0; i<5; i++) { + ((SysCAMSPortConnectingPoint)(connectingPoint[i])).setW(w0); + ((SysCAMSPortConnectingPoint)(connectingPoint[i])).setH(h0); + ((SysCAMSPortConnectingPoint)(connectingPoint[i+5])).setW(w1); + ((SysCAMSPortConnectingPoint)(connectingPoint[i+5])).setH(h1); + } + } + + public int getType() { + return TGComponentManager.TMLCTD_CPORT; + } + + public void wasSwallowed() { + myColor = null; + } + + public void wasUnswallowed() { + myColor = null; + setFather(null); + TDiagramPanel tdp = getTDiagramPanel(); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); + } + + public void resizeWithFather() { + if ((father != null) && (father instanceof SysCAMSCompositeComponent)) { + // Too large to fit in the father? -> resize it! + setCdRectangle(0-getWidth()/2, father.getWidth() - (getWidth()/2), 0-getHeight()/2, father.getHeight() - (getHeight()/2)); + setMoveCd(x, y); + oldx = -1; + oldy = -1; + } + } + + public boolean editOndoubleClick(JFrame frame) { + JDialogSysCAMSPortConverter jtdf = new JDialogSysCAMSPortConverter((SysCAMSPortConverter) this); + jtdf.setVisible(true); + + ((SysCAMSComponentTaskDiagramPanel)tdp).updatePorts(); + return true; + } + + public String getPortName() { + return commName; + } + + public void setPortName(String s) { + commName = s; + } + + public void purge() { + inp = null; + outp = null; + conflict = false; + inpIndex = -1; + outpIndex = -1; + myColor = null; + calculatePortColor(); + } + + public void myActionWhenRemoved() { + tdp = null; + TGComponent tgc = getFather(); + if (tgc instanceof SysCAMSCompositeComponent) { + ((SysCAMSCompositeComponent)(tgc)).portRemoved(); + } + father = null; + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSFork.java b/src/main/java/ui/syscams/SysCAMSFork.java new file mode 100644 index 0000000000..b3ec86bac7 --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSFork.java @@ -0,0 +1,111 @@ +/* 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.syscams; + +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; + +import java.awt.*; + +/** + * Class SysCAMSFork + * Fork operator. To be used in SystemC-AMS component task diagrams + * Creation: 22/04/2018 + * @version 1.0 22/04/2018 + * @author Irina Kit Yan LEE + */ + +public class SysCAMSFork extends SysCAMSChannelFacility implements WithAttributes { + protected int radius = 11; + protected int decPoint = 3; + + public SysCAMSFork(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); + + initScaling(2*radius, 2*radius); + + nbConnectingPoint = 7; + connectingPoint = new TGConnectingPoint[7]; + + connectingPoint[0] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.0, 0.5); + connectingPoint[1] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 1.0, 0.5); + connectingPoint[2] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 1.0, 0.5); + connectingPoint[3] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 0.75, 0.134); + connectingPoint[4] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 0.75, 0.134); + connectingPoint[5] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 0.75, 0.866); + connectingPoint[6] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 0.75, 0.866); + + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + value = "F"; + name = "Composite port"; + + myImageIcon = IconManager.imgic1204; + } + + public void internalDrawing(Graphics g) { + radius = width / 2; + + if (rescaled) { + rescaled = false; + } + calculatePortColor(); + + // Zoom is assumed to be computed + Color c = g.getColor(); + if ((width > 2) && (height > 2)) { + g.setColor(myColor); + g.fillOval(x, y, radius*2, radius*2); + g.setColor(c); + } + g.drawOval(x, y, radius*2, radius*2); + g.drawLine(x, y+radius, x+radius, y+radius); + + GraphicLib.arrowWithLine(g, 1, 1, 5, x+radius, y+radius, x+2*radius, y+radius, false); + GraphicLib.arrowWithLine(g, 1, 1, 5, x+radius, y+radius, x+3*radius/2, (int)(y+(0.134*radius)), false); + GraphicLib.arrowWithLine(g, 1, 1, 5, x+radius, y+radius, x+3*radius/2, (int)(y+2*radius-(0.134*radius)), false); + } + + public int getType() { + return TGComponentManager.TMLCTD_FORK; + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSJoin.java b/src/main/java/ui/syscams/SysCAMSJoin.java new file mode 100644 index 0000000000..7bd2da8532 --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSJoin.java @@ -0,0 +1,115 @@ +/* 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.syscams; + +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; + +import java.awt.*; + +/** + * Class SysCAMSJoin + * Join operator. To be used in SystemC-AMS component task diagrams + * Creation: 22/04/2018 + * @version 1.0 22/04/2018 + * @author Irina Kit Yan LEE + */ + +public class SysCAMSJoin extends SysCAMSChannelFacility implements WithAttributes { + protected int radius = 11; + protected int decPoint = 3; + + public SysCAMSJoin(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); + + initScaling(2*radius, 2*radius); + + nbConnectingPoint = 7; + connectingPoint = new TGConnectingPoint[7]; + + // output + connectingPoint[0] = new SysCAMSPortConnectingPoint(this, 0, 0, false, true, 1.0, 0.5); + // input + connectingPoint[1] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.0, 0.5); + connectingPoint[2] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.0, 0.5); + connectingPoint[3] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.25, 0.134); + connectingPoint[4] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.25, 0.134); + connectingPoint[5] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.25, 0.866); + connectingPoint[6] = new SysCAMSPortConnectingPoint(this, 0, 0, true, false, 0.25, 0.866); + + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + value = "J"; + name = "Composite port"; + + myImageIcon = IconManager.imgic1204; + } + + public void internalDrawing(Graphics g) { + + radius = width / 2; + + if (rescaled) { + rescaled = false; + } + + calculatePortColor(); + + // Zoom is assumed to be computed + Color c = g.getColor(); + if ((width > 2) && (height > 2)) { + g.setColor(myColor); + g.fillOval(x, y, radius*2, radius*2); + g.setColor(c); + } + g.drawOval(x, y, radius*2, radius*2); + g.drawLine(x, y+radius, x+radius, y+radius); + g.drawLine(x+radius/2, (int)(y+(0.134*radius)), x+radius, y+radius); + g.drawLine(x+radius/2, (int)(y+2*radius-(0.134*radius)), x+radius, y+radius); + + GraphicLib.arrowWithLine(g, 1, 1, 5, x+radius, y+radius, x+2*radius, y+radius, false); + } + + public int getType() { + return TGComponentManager.TMLCTD_JOIN; + } +} diff --git a/src/main/java/ui/syscams/SysCAMSPath.java b/src/main/java/ui/syscams/SysCAMSPath.java new file mode 100644 index 0000000000..9b05b7de2d --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSPath.java @@ -0,0 +1,360 @@ +/* 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.syscams; + +import ui.TGComponent; +import java.util.ArrayList; + +/** + * Class SysCAMSPath + * Notion of Path. To be used to analyze the correctness of paths in the model + * Creation: 07/05/2018 + * @version 1.0 07/05/2018 + * @author Irina Kit Yan LEE + */ + +public class SysCAMSPath { + + public ArrayList<SysCAMSPrimitivePort> producerPorts; + public ArrayList<SysCAMSPrimitivePort> consumerPorts; + + // Facilities + public ArrayList<SysCAMSCompositePort> cports; + public ArrayList<SysCAMSFork> forks; + public ArrayList<SysCAMSJoin> joins; + + private boolean errorOfConnection = false; + + private int errorNumber; + private TGComponent faultyComponent; + + + private String[] errors = {"Fork and Join operators in the same path", + "Must have at least one sender", + "Must have at least one receiver", + "More than one sender in a path with a fork", + "Senders and receivers are not of the same kind", + "One of more element of the path is badly connected", + "Events are not compatible with fork/join", + "Requests are not compatible with fork/join", + "Events/requests must all have the same parameters", + "Channels and events can have only one input and one output" + }; + + public SysCAMSPath() { + cports = new ArrayList<SysCAMSCompositePort>(); + producerPorts = new ArrayList<SysCAMSPrimitivePort>(); + consumerPorts = new ArrayList<SysCAMSPrimitivePort>(); + forks = new ArrayList<SysCAMSFork>(); + joins = new ArrayList<SysCAMSJoin>(); + } + + public void addComponent(TGComponent _tgc) { + if (_tgc instanceof SysCAMSCompositePort) { + cports.add((SysCAMSCompositePort)_tgc); + } + if (_tgc instanceof SysCAMSPrimitivePort) { + SysCAMSPrimitivePort p = (SysCAMSPrimitivePort)_tgc; + if (p.isOrigin()) { + producerPorts.add(p); + } else { + consumerPorts.add(p); + } + } + if (_tgc instanceof SysCAMSFork) { + forks.add((SysCAMSFork)_tgc); + } + if (_tgc instanceof SysCAMSJoin) { + joins.add((SysCAMSJoin)_tgc); + } + } + + public void setErrorOfConnection(boolean _err) { + errorOfConnection = _err; + } + + public boolean getErrorOfConnection() { + return errorOfConnection; + } + + public boolean contains(TGComponent tgc) { + if (cports.contains(tgc)) { + return true; + } + if (producerPorts.contains(tgc)) { + return true; + } + if (consumerPorts.contains(tgc)) { + return true; + } + if (forks.contains(tgc)) { + return true; + } + return joins.contains(tgc); + } + + public void mergeWith(SysCAMSPath _path) { + cports.addAll(_path.cports); + producerPorts.addAll(_path.producerPorts); + consumerPorts.addAll(_path.consumerPorts); + forks.addAll(_path.forks); + joins.addAll(_path.joins); + setErrorOfConnection(getErrorOfConnection() || _path.getErrorOfConnection()); + } + + public boolean hasError() { + return (errorNumber != -1); + } + + public String getErrorMessage() { + if (hasError()) { + return errors[errorNumber]; + } + return ""; + } + + public TGComponent getFaultyComponent() { + return faultyComponent; + } + + public void checkRules() { + errorNumber = -1; + + //rule0: fork or join, but not both + if ((forks.size() > 0) && (joins.size() >0)) { + faultyComponent = forks.get(0); + errorNumber = 0; + } + + //rule1: Must have at least one producer + if (producerPorts.size() == 0) { + errorNumber = 1; + if ((consumerPorts != null) && (consumerPorts.size() > 0)) { + faultyComponent = consumerPorts.get(0); + } + } + + //rule2: Must have at least one receiver + if (consumerPorts.size() == 0) { + errorNumber = 2; + if ((producerPorts != null) && (producerPorts.size() > 0)) { + faultyComponent = producerPorts.get(0); + } + } + + //rule3: If fork: must have only one producer + if ((forks.size() > 0) && (producerPorts.size() >1)) { + errorNumber = 3; + faultyComponent = forks.get(0); + } + + //rule4: producers and consumers must be of the same type + if ((consumerPorts.size()>0) && (producerPorts.size()>0)) { + int type = consumerPorts.get(0).getPortType(); + for (SysCAMSPrimitivePort porto: producerPorts) { + if (porto.getPortType() != type) { + errorNumber = 4; + faultyComponent = porto; + break; + } + } + for (SysCAMSPrimitivePort porti: consumerPorts) { + if (porti.getPortType() != type) { + errorNumber = 4; + faultyComponent = porti; + break; + } + } + } + + //rule5: Error of connection + if (errorOfConnection) { + errorNumber = 5; + } + + //rule7: requests cannot be connected through fork or join + if ((forks.size() > 0) || (joins.size() >0)) { + // Look for event, either at origin, or at destination + for (SysCAMSPrimitivePort porto: producerPorts) { + if (porto.getPortType() == 2) { + errorNumber = 7; + faultyComponent = porto; + break; + } + } + for (SysCAMSPrimitivePort porti: consumerPorts) { + if (porti.getPortType() == 2) { + errorNumber = 7; + faultyComponent = porti; + break; + } + } + } + + //rule8: all events/requests with the same parameters +// if ((forks.size() > 0) || (joins.size() >0)) { +// if (producerPorts != null && producerPorts.size() > 0) { +// SysCAMSPrimitivePort referencePort = producerPorts.get(0); +// if (referencePort != null) { +// if ((referencePort.getPortType() == 1) ||(referencePort.getPortType() == 2)) { +// // Event or request found +// // We now check that they are all compatible with the reference +// for (SysCAMSPrimitivePort porto: producerPorts) { +// if (!(porto.hasSameParametersThan(referencePort))) { +// errorNumber = 8; +// faultyComponent = porto; +// break; +// } +// } +// +// for (SysCAMSPrimitivePort porti: consumerPorts) { +// if (!(porti.hasSameParametersThan(referencePort))) { +// errorNumber = 8; +// faultyComponent = porti; +// break; +// } +// } +// } +// } +// } +// } + + // rule9: if no fork, no join, no request: one to one communication + boolean foundReq = true; + if ((forks.size() == 0) && (joins.size() == 0)) { + if (producerPorts != null && producerPorts.size() > 0) { + SysCAMSPrimitivePort referencePort = producerPorts.get(0); + if (referencePort != null) { + if (referencePort.getPortType() != 2) { + foundReq = false; + } + } + } + if (!foundReq) { + if (producerPorts.size() > 1) { + errorNumber = 9; + faultyComponent = producerPorts.get(1); + } else if (consumerPorts.size() > 1) { + errorNumber = 9; + faultyComponent = consumerPorts.get(1); + } + } + } + } + + public void setColor() { + // For each channel facility, + // set the inp and outp primitive ports if possible (otherwise, null) + // if no error: set conflict to false + // If error -> set the conflict to true + + for (SysCAMSFork fork: forks) { + if (producerPorts.size() > 0) { + fork.setOutPort(producerPorts.get(0)); + } else { + fork.setOutPort(null); + } + + if (consumerPorts.size() > 0) { + fork.setInPort(consumerPorts.get(0)); + } else { + fork.setInPort(null); + } + + if (hasError()) { + fork.setConflict(hasError(), errors[errorNumber]); + } else { + fork.setConflict(false, ""); + } + } + + for (SysCAMSJoin join: joins) { + if (producerPorts.size() > 0) { + join.setOutPort(producerPorts.get(0)); + } else { + join.setOutPort(null); + } + + if (consumerPorts.size() > 0) { + join.setInPort(consumerPorts.get(0)); + } else { + join.setInPort(null); + } + if (hasError()) { + join.setConflict(hasError(), errors[errorNumber]); + } else { + join.setConflict(false, ""); + } + } + + for (SysCAMSCompositePort port: cports) { + if (producerPorts.size() > 0) { + port.setOutPort(producerPorts.get(0)); + } else { + port.setOutPort(null); + } + + if (consumerPorts.size() > 0) { + port.setInPort(consumerPorts.get(0)); + } else { + port.setInPort(null); + } + if (hasError()) { + port.setConflict(hasError(), errors[errorNumber]); + } else { + port.setConflict(false, ""); + } + } + + for (SysCAMSPrimitivePort pport: producerPorts) { + if (hasError()) { + pport.setConflict(hasError(), errors[errorNumber]); + } else { + pport.setConflict(false, ""); + } + } + for (SysCAMSPrimitivePort cport: consumerPorts) { + if (hasError()) { + cport.setConflict(hasError(), errors[errorNumber]); + } else { + cport.setConflict(false, ""); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSPortConnectingPoint.java b/src/main/java/ui/syscams/SysCAMSPortConnectingPoint.java new file mode 100644 index 0000000000..2482024935 --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSPortConnectingPoint.java @@ -0,0 +1,64 @@ +/* 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.syscams; + +import ui.CDElement; +import ui.TGComponentManager; +import ui.TGConnectingPointWidthHeight; + +/** + * Class SysCAMSPortConnectingPoint + * Definition of connecting points on which connectors of SystemC-AMS Component Task diagrams can be connected + * Creation: 22/04/2018 + * @version 1.0 22/04/2018 + * @author Irina Kit Yan LEE + */ + +public class SysCAMSPortConnectingPoint extends TGConnectingPointWidthHeight{ + public SysCAMSPrimitivePort port; + public boolean positionned; + + public SysCAMSPortConnectingPoint(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h) { + super(_container, _x, _y, _in, _out, _w, _h); + } + + public boolean isCompatibleWith(int type) { + return type == TGComponentManager.CONNECTOR_PORT_TMLC; + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSPortConnector.java b/src/main/java/ui/syscams/SysCAMSPortConnector.java new file mode 100644 index 0000000000..6766b226e7 --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSPortConnector.java @@ -0,0 +1,139 @@ +/* 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.syscams; + +import ui.*; +import ui.util.IconManager; + +import java.awt.*; +import java.util.Vector; + +/** + * Class SysCAMSPortConnector + * Connector used in SystemC-AMS Component task diagrams + * Creation: 27/04/2018 + * @version 1.0 27/04/2018 + * @author Irina Kit Yan LEE + */ + +public class SysCAMSPortConnector extends TGConnector implements ScalableTGComponent, SpecificActionAfterAdd, SpecificActionAfterMove{ + protected double oldScaleFactor; + + public SysCAMSPortConnector(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector<Point> _listPoint) { + super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); + myImageIcon = IconManager.imgic202; + value = "Connector between ports"; + editable = false; + oldScaleFactor = tdp.getZoom(); + p1 = _p1; + p2 = _p2; + } + + public TGConnectingPoint get_p1(){ + return p1; + } + + public TGConnectingPoint get_p2(){ + return p2; + } + + protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ + try { + SysCAMSPortConnectingPoint pt1 = (SysCAMSPortConnectingPoint)p1; + SysCAMSPortConnectingPoint pt2 = (SysCAMSPortConnectingPoint)p2; + if (!pt1.positionned) { + pt1.positionned = true; + if (pt1.getFather() instanceof SysCAMSPrimitivePort) { + pt1.port = (SysCAMSPrimitivePort)(pt1.getFather()); + } + } + if (!pt2.positionned) { + pt2.positionned = true; + if (pt2.getFather() instanceof SysCAMSPrimitivePort) { + pt2.port = (SysCAMSPrimitivePort)(pt2.getFather()); + } + } + if ((pt1.port != null) && (pt2.port != null)) { + String name1 = pt1.port.getPortName(); + String name2 = pt2.port.getPortName(); + if (name1.equals(name2)) { + int w = g.getFontMetrics().stringWidth(name1); + Font fold = g.getFont(); + Font f = fold.deriveFont(Font.ITALIC, (float)(tdp.getFontSize())); + g.setFont(f); + g.drawString(name1, (x1 + x2 - w)/2, (y1 + y2)/2); + g.setFont(fold); + } + } + g.drawLine(x1, y1, x2, y2); + return; + } catch (Exception e) { + } + g.drawLine(x1, y1, x2, y2); + } + + public void rescale(double scaleFactor){ + int xx, yy; + + for(int i=0; i<nbInternalTGComponent; i++) { + xx = tgcomponent[i].getX(); + yy = tgcomponent[i].getY(); + tgcomponent[i].dx = (tgcomponent[i].dx + xx) / oldScaleFactor * scaleFactor; + tgcomponent[i].dy = (tgcomponent[i].dy + yy) / oldScaleFactor * scaleFactor; + xx = (int)(tgcomponent[i].dx); + tgcomponent[i].dx = tgcomponent[i].dx - xx; + yy = (int)(tgcomponent[i].dy); + tgcomponent[i].dy = tgcomponent[i].dy - yy; + tgcomponent[i].setCd(xx, yy); + } + oldScaleFactor = scaleFactor; + } + + public int getType() { + return TGComponentManager.CONNECTOR_PORT_TMLC; + } + + public void specificActionAfterAdd() { + ((SysCAMSComponentTaskDiagramPanel)tdp).updatePorts(); + } + + public void specificActionAfterMove() { + ((SysCAMSComponentTaskDiagramPanel)tdp).updatePorts(); + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSPortConverter.java b/src/main/java/ui/syscams/SysCAMSPortConverter.java new file mode 100644 index 0000000000..ceaf066a16 --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSPortConverter.java @@ -0,0 +1,57 @@ +package ui.syscams; + +import ui.TDiagramPanel; +import ui.TGComponent; + +public class SysCAMSPortConverter extends SysCAMSCompositePort { + private int period; + private int rate; + private int delay; + private String origin; + private String convType; + + public SysCAMSPortConverter(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); + } + + public int getPeriod() { + return period; + } + + public void setPeriod(int period) { + this.period = period; + } + + public int getRate() { + return rate; + } + + public void setRate(int rate) { + this.rate = rate; + } + + public int getDelay() { + return delay; + } + + public void setDelay(int delay) { + this.delay = delay; + } + + public String getOrigin() { + return origin; + } + + public void setOrigin(String origin) { + this.origin = origin; + } + + public String getConvType() { + return convType; + } + + public void setConvType(String convType) { + this.convType = convType; + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSPortDE.java b/src/main/java/ui/syscams/SysCAMSPortDE.java new file mode 100644 index 0000000000..5f837c6d98 --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSPortDE.java @@ -0,0 +1,62 @@ +package ui.syscams; + +import java.awt.Graphics; + +import ui.TDiagramPanel; +import ui.TGComponent; + +public class SysCAMSPortDE extends SysCAMSPrimitivePort { + private int period; + private int rate; + private int delay; + private String origin; + private String DEType; + + public SysCAMSPortDE(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); + } + + public String getDEType() { + return DEType; + } + + public void setDEType(String DEType) { + this.DEType = DEType; + } + + public String getOrigin() { + return origin; + } + + public void setOrigin(String origin) { + this.origin = origin; + } + + public int getPeriod() { + return period; + } + + public void setPeriod(int period) { + this.period = period; + } + + public int getRate() { + return rate; + } + + public void setRate(int rate) { + this.rate = rate; + } + + public int getDelay() { + return delay; + } + + public void setDelay(int delay) { + this.delay = delay; + } + + public void drawParticularity(Graphics g) { + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSPortTDF.java b/src/main/java/ui/syscams/SysCAMSPortTDF.java new file mode 100644 index 0000000000..afc054a3a0 --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSPortTDF.java @@ -0,0 +1,62 @@ +package ui.syscams; + +import java.awt.Graphics; + +import ui.TDiagramPanel; +import ui.TGComponent; + +public class SysCAMSPortTDF extends SysCAMSPrimitivePort { + private int period; + private int rate; + private int delay; + private String origin; + private String TDFType; + + public SysCAMSPortTDF(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); + } + + public String getTDFType() { + return TDFType; + } + + public void setTDFType(String tDFType) { + TDFType = tDFType; + } + + public String getOrigin() { + return origin; + } + + public void setOrigin(String origin) { + this.origin = origin; + } + + public int getPeriod() { + return period; + } + + public void setPeriod(int period) { + this.period = period; + } + + public int getRate() { + return rate; + } + + public void setRate(int rate) { + this.rate = rate; + } + + public int getDelay() { + return delay; + } + + public void setDelay(int delay) { + this.delay = delay; + } + + public void drawParticularity(Graphics g) { + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSPrimitiveComponent.java b/src/main/java/ui/syscams/SysCAMSPrimitiveComponent.java new file mode 100644 index 0000000000..152f6ea18b --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSPrimitiveComponent.java @@ -0,0 +1,620 @@ +/* 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.syscams; + +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.JDialogAttribute; +import ui.window.JDialogSysCAMSBlockDE; +import ui.window.JDialogSysCAMSBlockTDF; + +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Vector; + +/** + * Class SysCAMSPrimitiveComponent + * Primitive Component. To be used in SystemC-AMSdiagrams + * Creation: 27/04/2018 + * @version 1.0 27/04/2018 + * @author Irina Kit Yan LEE + */ + +public class SysCAMSPrimitiveComponent extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent, WithAttributes { + private int maxFontSize = 14; + private int minFontSize = 4; + private int currentFontSize = -1; + private boolean displayText = true; + private Color myColor; + + private boolean isAttacker=false; + // Icon + private int iconSize = 15; +// private boolean iconIsDrawn = false; + + // Attributes + public HashMap<String, Integer> attrMap = new HashMap<String, Integer>(); + public String mappingName; + protected LinkedList<TAttribute> myAttributes; + private int textX = 15; // border for ports + private double dtextX = 0.0; + + public String oldValue; + + public SysCAMSPrimitiveComponent(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); + + initScaling(200, 150); + + oldScaleFactor = tdp.getZoom(); + dtextX = textX * oldScaleFactor; + textX = (int)dtextX; + dtextX = dtextX - textX; + + minWidth = 1; + minHeight = 1; + + nbConnectingPoint = 0; + + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + moveable = true; + multieditable = true; + editable = true; + removable = true; + userResizable = true; + + if (this instanceof SysCAMSBlockTDF) { + value = "TDF_Block"; + } else if (this instanceof SysCAMSBlockDE) { + value = "DE_Block"; + } + +// oldValue = value; +// setName("Primitive component"); + name = "Primitive component"; + + myImageIcon = IconManager.imgic1202; + + myAttributes = new LinkedList<TAttribute> (); + + actionOnAdd(); + } + + public void internalDrawing(Graphics g) { + int w; + Font f = g.getFont(); + Font fold = f; + + if (myColor == null) { + if (ColorManager.TML_COMPOSITE_COMPONENT == Color.white) { + myColor = Color.white; + } else { + if (this instanceof SysCAMSBlockTDF) { + myColor = Color.lightGray; + } else { + myColor = Color.white; + } + } + } + if ((rescaled) && (!tdp.isScaled())) { + if (currentFontSize == -1) { + currentFontSize = f.getSize(); + } + rescaled = false; + // Must set the font size .. + // Find the biggest font not greater than max_font size + // By Increment of 1 + // Or decrement of 1 + // If font is less than 4, no text is displayed + + int maxCurrentFontSize = Math.max(0, Math.min(height-(2*textX), maxFontSize)); + f = f.deriveFont((float)maxCurrentFontSize); + g.setFont(f); + while(maxCurrentFontSize > (minFontSize-1)) { + if (g.getFontMetrics().stringWidth(value) < (width - iconSize - (2 * textX))) { + break; + } + maxCurrentFontSize --; + f = f.deriveFont((float)maxCurrentFontSize); + g.setFont(f); + } + currentFontSize = maxCurrentFontSize; + if(currentFontSize <minFontSize) { + displayText = false; + } else { + displayText = true; + f = f.deriveFont((float)currentFontSize); + g.setFont(f); + } + } + + // Zoom is assumed to be computed + Color c = g.getColor(); + g.drawRect(x, y, width, height); + if ((width > 2) && (height > 2)) { + g.setColor(myColor); + g.fillRect(x+1, y+1, width-1, height-1); + g.setColor(c); + } + + // Font size + if (displayText) { + f = f.deriveFont((float)currentFontSize); + g.setFont(f); + w = g.getFontMetrics().stringWidth(value); + if (w > (width - 2 * (iconSize + textX))) { + g.drawString(value, x + textX + 1, y + currentFontSize + textX); + + if (this instanceof SysCAMSBlockTDF) { + String s = "Tm = " + ((SysCAMSBlockTDF) this).getPeriod(); + g.drawString(s, x + textX + 1, y + height - currentFontSize - textX); + } else if (this instanceof SysCAMSBlockDE) { + String s = "Tm = " + ((SysCAMSBlockDE) this).getPeriod(); + g.drawString(s, x + textX + 1, y + height - currentFontSize - textX); + } + } else { + g.drawString(value, x + (width - w)/2, y + currentFontSize + textX); + if (this instanceof SysCAMSBlockTDF) { + String s = "Tm = " + ((SysCAMSBlockTDF) this).getPeriod(); + w = g.getFontMetrics().stringWidth(s); + g.drawString(s, x + (width - w)/2, y + height - currentFontSize - textX); + } else if (this instanceof SysCAMSBlockDE) { + String s = "Tm = " + ((SysCAMSBlockDE) this).getPeriod(); + w = g.getFontMetrics().stringWidth(s); + g.drawString(s, x + (width - w)/2, y + height - currentFontSize - textX); + } + } + } + +// // Icon +// if ((width>30) && (height > (iconSize + 2*textX))) { +// iconIsDrawn = true; +// g.drawImage(IconManager.imgic1200.getImage(), x + width - iconSize - textX, y + textX, null); +// } else { +// iconIsDrawn = false; +// } +// if (isAttacker){ +// g.drawImage(IconManager.imgic7008.getImage(), x + width - 2*iconSize - textX, y + 2*textX, null); +// } + + // Attributes + if (tdp.areAttributesVisible()) { + int index = 0; + int cpt = currentFontSize + 2 * textX; + String attr; + + TAttribute a; + + int si = Math.min(12, (int)((float)currentFontSize - 2)); + + f = g.getFont(); + f = f.deriveFont((float)si); + g.setFont(f); + int step = si + 2; + + while(index < myAttributes.size()) { + cpt += step; + if (cpt >= (height - textX)) { + break; + } + a = myAttributes.get (index); + attr = a.toString(); + w = g.getFontMetrics().stringWidth(attr); + if ((w + (2 * textX) + 1) < width) { + g.drawString(attr, x + textX, y + cpt); + drawVerification(g, x + textX, y+ cpt, a.getConfidentialityVerification()); + } else { + attr = "..."; + w = g.getFontMetrics().stringWidth(attr); + if ((w + textX + 2) < width) { + g.drawString(attr, x + textX + 1, y + cpt); + } else { + // skip attribute + cpt -= step; + } + } + index ++; + } + } + g.setFont(fold); + } + public void drawVerification(Graphics g, int x, int y, int checkConfStatus){ + Color c = g.getColor(); + Color c1; + switch(checkConfStatus) { + case TAttribute.CONFIDENTIALITY_OK: + c1 = Color.green; + break; + case TAttribute.CONFIDENTIALITY_KO: + c1 = Color.red; + break; + default: + return; + } + g.drawOval(x-10, y-10, 6, 9); + g.setColor(c1); + g.fillRect(x-12, y-5, 9, 7); + g.setColor(c); + g.drawRect(x-12, y-5, 9, 7); + } + + public void rescale(double scaleFactor){ + dtextX = (textX + dtextX) / oldScaleFactor * scaleFactor; + textX = (int)(dtextX); + dtextX = dtextX - textX; + super.rescale(scaleFactor); + } + + public TGComponent isOnOnlyMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; + } + + + public boolean isAttacker(){ + return isAttacker; + } + + public boolean editOndoubleClick(JFrame frame, int _x, int _y) { +// // On the icon? +// if (iconIsDrawn) { +// if (GraphicLib.isInRectangle(_x, _y, x + width - iconSize - textX, y + textX, iconSize, iconSize)) { +// tdp.getMouseManager().setSelection(-1, -1); +// tdp.selectTab(getValue()); +// return true; +// } +// } + // On the name ? +// if ((displayText) && (_y <= (y + currentFontSize + textX))) { +//// oldValue = value; +// String s = (String)JOptionPane.showInputDialog(frame, "Name:", "Setting component name", +// JOptionPane.PLAIN_MESSAGE, IconManager.imgic100, +// null, +// getValue()); +// if ((s != null) && (s.length() > 0)) { +// // Check whether this name is already in use, or not +// if (!TAttribute.isAValidId(s, false, false)) { +// JOptionPane.showMessageDialog(frame, +// "Could not change the name of the component: the new name is not a valid name", +// "Error", +// JOptionPane.INFORMATION_MESSAGE); +// return false; +// } +// if (oldValue.compareTo(s) != 0) { +// if (((SysCAMSComponentTaskDiagramPanel)(tdp)).namePrimitiveComponentInUse(oldValue, s)) { +// JOptionPane.showMessageDialog(frame, +// "Error: the name is already in use", +// "Name modification", +// JOptionPane.ERROR_MESSAGE); +// return false; +// } +// } +// if (((SysCAMSComponentTaskDiagramPanel)(tdp)).isCompositeNameUsed(s)) { +// JOptionPane.showMessageDialog(frame, +// "Error: the name is already in use", +// "Name modification", +// JOptionPane.ERROR_MESSAGE); +// return false; +// } +// setComponentName(s); +// setValueWithChange(s); +//// isAttacker = s.contains("Attacker"); +// rescaled = true; +// return true; +// +// } +// return false; +// } + + // And so -> attributes! +// JDialogAttribute jda = new JDialogAttribute(myAttributes, null, frame, "Setting attributes of " + value, "Attribute"); +// setJDialogOptions(jda); +// GraphicLib.centerOnParent(jda, 650, 375); + if (this instanceof SysCAMSBlockTDF) { + JDialogSysCAMSBlockTDF jtdf = new JDialogSysCAMSBlockTDF((SysCAMSBlockTDF) this); + jtdf.setVisible(true); + } else { + JDialogSysCAMSBlockDE jde = new JDialogSysCAMSBlockDE((SysCAMSBlockDE) this); + jde.setVisible(true); + } +// jda.setVisible(true); // blocked until dialog has been closed + rescaled = true; + return true; + + } + +// protected void setJDialogOptions(JDialogAttribute jda) { +// jda.addAccess(TAttribute.getStringAccess(TAttribute.PUBLIC)); +// jda.addAccess(TAttribute.getStringAccess(TAttribute.PRIVATE)); +// jda.addType(TAttribute.getStringType(TAttribute.NATURAL), true); +// jda.addType(TAttribute.getStringType(TAttribute.BOOLEAN), true); +// +// Vector<String> records = ((SysCAMSComponentTaskDiagramPanel)(tdp)).getAllRecords(this); +// for(String s: records) { +// jda.addType(s, false); +// } +// jda.enableInitialValue(true); +// jda.enableRTLOTOSKeyword(true); +// jda.enableJavaKeyword(false); +// jda.enableTMLKeyword(false); +// } + + public Vector<String> getAllRecords() { + return ((SysCAMSComponentTaskDiagramPanel)(tdp)).getAllRecords(this); + } + + public SysCAMSRecordComponent getRecordNamed(String _nameOfRecord) { + return ((SysCAMSComponentTaskDiagramPanel)(tdp)).getRecordNamed(this, _nameOfRecord); + } + + public int getType() { + return TGComponentManager.TMLCTD_PCOMPONENT; + } + + public void wasSwallowed() { + myColor = null; + } + + public void wasUnswallowed() { + myColor = null; + setFather(null); + TDiagramPanel tdp = getTDiagramPanel(); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); + } + + public boolean acceptSwallowedTGComponent(TGComponent tgc) { + return tgc instanceof SysCAMSPrimitivePort; + } + + public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { + //TraceManager.addDev("Add swallow component"); + // Choose its position + // Make it an internal component + // It's one of my son + //Set its coordinates + if (tgc instanceof SysCAMSPrimitivePort) { + tgc.setFather(this); + tgc.setDrawingZone(true); + tgc.resizeWithFather(); + addInternalComponent(tgc, 0); + return true; + } + return false; + } + + public void removeSwallowedTGComponent(TGComponent tgc) { + removeInternalComponent(tgc); + } + + public void hasBeenResized() { + rescaled = true; + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSPrimitivePort) { + tgcomponent[i].resizeWithFather(); + } + } + if (getFather() != null) { + resizeWithFather(); + } + } + + public void resizeWithFather() { + if ((father != null) && (father instanceof SysCAMSCompositeComponent)) { + // Too large to fit in the father? -> resize it! + resizeToFatherSize(); + + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); + setMoveCd(x, y); + } + } + + public int getChildCount() { + return myAttributes.size() + nbInternalTGComponent + 1; + } + + public Object getChild(int index) { + if (index == 0) { + return value; + } else { + if (index <= myAttributes.size()) { + return myAttributes.get (index-1); + } else { + return tgcomponent[index-1-myAttributes.size()]; + } + } + } + + public int getIndexOfChild(Object child) { + if (child instanceof String) { + return 0; + } else { + if (myAttributes.indexOf(child) > -1) { + return myAttributes.indexOf(child) + 1; + } else { + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] == child) { + return myAttributes.size() + 1 + i; + } + } + } + } + return -1; + } + + protected String translateExtraParam() { + TAttribute a; + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<Data isAttacker=\""); + sb.append(isAttacker() ? "Yes": "No"); + sb.append("\" />\n"); + for(int i=0; i<myAttributes.size(); i++) { + a = myAttributes.get (i); + sb.append("<Attribute access=\""); + sb.append(a.getAccess()); + sb.append("\" id=\""); + sb.append(a.getId()); + sb.append("\" value=\""); + sb.append(a.getInitialValue()); + sb.append("\" type=\""); + sb.append(a.getType()); + sb.append("\" typeOther=\""); + sb.append(a.getTypeOther()); + sb.append("\" />\n"); + } + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + try { + NodeList nli; + Node n1, n2; + Element elt; + int access, type; + String typeOther; + String id, valueAtt; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; j<nli.getLength(); j++) { + n2 = nli.item(j); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("Data")) { + isAttacker = elt.getAttribute("isAttacker").equals("Yes"); + } + if (elt.getTagName().equals("Attribute")) { + access = Integer.decode(elt.getAttribute("access")).intValue(); + type = Integer.decode(elt.getAttribute("type")).intValue(); + try { + typeOther = elt.getAttribute("typeOther"); + } catch (Exception e) { + typeOther = ""; + } + id = elt.getAttribute("id"); + valueAtt = elt.getAttribute("value"); + + if (valueAtt.equals("null")) { + valueAtt = ""; + } + if ((TAttribute.isAValidId(id, false, false)) && (TAttribute.isAValidInitialValue(type, valueAtt))) { + TAttribute ta = new TAttribute(access, id, valueAtt, type, typeOther); + myAttributes.add (ta); + } + } + } + } + } + } + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + public int getCurrentFontSize() { + return currentFontSize; + } + + public java.util.List<TAttribute> getAttributeList() { + return myAttributes; + } + + public java.util.List<SysCAMSPrimitivePort> getAllTDFOriginPorts() { + return getAllPorts(0, true); + } + + public java.util.List<SysCAMSPrimitivePort> getAllTDFDestinationPorts() { + return getAllPorts(0, false); + } + + public java.util.List<SysCAMSPrimitivePort> getAllDEOriginPorts() { + return getAllPorts(1, true); + } + + public java.util.List<SysCAMSPrimitivePort> getAllDEDestinationPorts() { + return getAllPorts(1, false); + } + + public java.util.List<SysCAMSPrimitivePort> getAllPorts(int _type, boolean _isOrigin) { + java.util.List<SysCAMSPrimitivePort> ret = new LinkedList<SysCAMSPrimitivePort>(); + SysCAMSPrimitivePort port; + + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSPrimitivePort) { + port = (SysCAMSPrimitivePort)tgcomponent[i]; + if ((port.getPortType() == _type) && (port.isOrigin() == _isOrigin)) { + ret.add(port); + } + } + } + return ret; + } + + public java.util.List<SysCAMSPrimitivePort> getAllInternalPrimitivePorts() { + java.util.List<SysCAMSPrimitivePort> list = new ArrayList<SysCAMSPrimitivePort>(); + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSPrimitivePort) { + list.add((SysCAMSPrimitivePort)(tgcomponent[i])); + } + } + return list; + } + + public String getAttributes() { + String attr = ""; + for (TAttribute a: myAttributes) { + attr += a.toAvatarString() + "\n"; + } + return attr; + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSPrimitivePort.java b/src/main/java/ui/syscams/SysCAMSPrimitivePort.java new file mode 100644 index 0000000000..2e79885b2f --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSPrimitivePort.java @@ -0,0 +1,878 @@ +/* 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.syscams; + +import myutil.GraphicLib; + +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import ui.*; +import ui.tmlad.TMLADNotifiedEvent; +import ui.tmlad.TMLADReadChannel; +import ui.tmlad.TMLADSendEvent; +import ui.tmlad.TMLADSendRequest; +import ui.tmlad.TMLADWaitEvent; +import ui.tmlad.TMLADWriteChannel; +import ui.tmldd.TMLArchiCPNode; +import ui.tmldd.TMLArchiPortArtifact; +import ui.util.IconManager; +import ui.window.JDialogSysCAMSPortDE; +import ui.window.JDialogSysCAMSPortTDF; + +import javax.swing.*; +import java.awt.*; + +/** + * Class SysCAMSPrimitivePort + * Primitive port. To be used in SystemC-AMS diagrams + * Creation: 27/04/2018 + * @version 1.0 27/04/2018 + * @author Irina Kit Yan LEE + */ + +public abstract class SysCAMSPrimitivePort extends TGCScalableWithInternalComponent implements SwallowedTGComponent, LinkedReference, WithAttributes { + protected Color myColor; + protected int orientation; + protected int oldx, oldy; + protected int halfwidth = 13; + protected int currentOrientation = GraphicLib.NORTH; + + protected int nbMaxAttribute = 5; + protected TType list[]; + protected int maxSamples = 8; + protected int widthSamples = 4; + protected boolean isFinite = false; + protected boolean isBlocking = false; + public boolean isOrigin = true; + public int typep = 0; + protected int oldTypep = typep; + public String commName; + + protected boolean isLossy; + protected boolean isPostex = false; + protected boolean isPrex = false; + protected int lossPercentage; + protected int maxNbOfLoss; //-1 means no max + + //Security Verification + public int checkConfStatus; + + public int checkSecConfStatus; + public String secName=""; + + public int checkWeakAuthStatus; + public int checkStrongAuthStatus; + public boolean checkConf; + public boolean checkAuth; + public static int NOCHECK= 0; + public static int TOCHECK = 1; + public static int CHECKED_CONF = 2; + public static int CHECKED_UNCONF = 3; + + public String mappingName="???"; + protected int decPoint = 3; + + protected boolean conflict = false; + protected String conflictMessage; + protected String dataFlowType = "VOID"; + protected String associatedEvent = "VOID"; + + public int verification; + + private ImageIcon portImageIconTDF, portImageIconDE; + + public SysCAMSPrimitivePort(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); + + initScaling(2*halfwidth, 2*halfwidth); + + minWidth = 1; + minHeight = 1; + + nbConnectingPoint = 1; + connectingPoint = new TGConnectingPoint[1]; + for (int i=0; i<1; i++) { + connectingPoint[i] = new SysCAMSPortConnectingPoint(this, 0, 0, true, true, 0.5, 0.0); + } + + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + moveable = true; + editable = true; + removable = true; + userResizable = false; + checkConf=false; + commName = "comm"; + makeValue(); + setName("Primitive port"); + checkConfStatus= NOCHECK; + list = new TType[nbMaxAttribute]; + for(int i=0; i<nbMaxAttribute; i++) { + list[i] = new TType(); + } + myImageIcon = IconManager.imgic1206; + portImageIconTDF = IconManager.imgic8000; + portImageIconDE = IconManager.imgic8001; + + // Initialization of port attributes + if (this instanceof SysCAMSPortTDF) { + ((SysCAMSPortTDF) this).setTDFType(""); + } else if (this instanceof SysCAMSPortDE) { + ((SysCAMSPortDE) this).setDEType(""); + } + } + + public void initConnectingPoint(boolean in, boolean out, int nb) { + nbConnectingPoint = nb; + connectingPoint = new TGConnectingPoint[nb]; + int i; + for (i=0; i<nbConnectingPoint; i++) { + connectingPoint[i] = new SysCAMSPortConnectingPoint(this, 0, 0, in, out, 0.5, 0.0); + } + } + + public Color getMyColor() { + return myColor; + } + + public void internalDrawing(Graphics g) { + if ((x != oldx) | (oldy != y)) { + // Component has moved! + manageMove(); + oldx = x; + oldy = y; + } + calculatePortColor(); + + if (rescaled) { + rescaled = false; + } + + // Zoom is assumed to be computed + Color c = g.getColor(); + g.setColor(c); + + TGComponent tgc = getFather(); + if ((tgc != null) && (tgc instanceof SysCAMSPrimitiveComponent)) { + if (tgc instanceof SysCAMSBlockTDF && this instanceof SysCAMSPortTDF) { + g.drawRect(x+width/2-portImageIconTDF.getIconWidth()/2, y+height/2-portImageIconTDF.getIconHeight()/2, portImageIconTDF.getIconWidth(), portImageIconTDF.getIconHeight()); + g.drawImage(portImageIconTDF.getImage(), x+width/2-portImageIconTDF.getIconWidth()/2, y+height/2-portImageIconTDF.getIconHeight()/2, null); + } else if (tgc instanceof SysCAMSBlockDE && this instanceof SysCAMSPortDE) { + g.drawRect(x+width/2-portImageIconDE.getIconWidth()/2, y+height/2-portImageIconDE.getIconHeight()/2, portImageIconDE.getIconWidth(), portImageIconDE.getIconHeight()); + g.drawImage(portImageIconDE.getImage(), x+width/2-portImageIconDE.getIconWidth()/2, y+height/2-portImageIconDE.getIconHeight()/2, null); + } + } + + int ft = 10; + if ((tgc != null) && (tgc instanceof SysCAMSPrimitiveComponent)) { + ft = ((SysCAMSPrimitiveComponent)tgc).getCurrentFontSize(); + } + int w; + Font f = g.getFont(); + Font fold = f; + + int si = Math.min(8, (int)((float)ft - 2)); + f = f.deriveFont((float)si); + g.setFont(f); + w = g.getFontMetrics().stringWidth(commName); + if (w < ((int)(width * 1.5))) { + g.drawString(commName, x, y-1); + } + + if (checkConf && isOrigin){ + drawConfVerification(g); + } + if (checkAuth && !isOrigin){ + drawAuthVerification(g); + } + g.setFont(fold); + + drawParticularity(g); + } + + public abstract void drawParticularity(Graphics g); + + public void drawAuthVerification(Graphics g){ + int lockwidth=(int) (16*tdp.getZoom()); + int lockheight=(int) (16*tdp.getZoom()); + + int xc=(int) (18*tdp.getZoom()); + int yc= (int) (12*tdp.getZoom()); + + int xoffset= (int) (20*tdp.getZoom()); + int yoffset= (int) (18*tdp.getZoom()); + + int ovalwidth=(int) (10*tdp.getZoom()); + int ovalheight=(int) (15*tdp.getZoom()); + g.drawString(secName, x-xc*2/3, y+yc*2/3); + Color c = g.getColor(); + Color c1; + Color c2; + switch(checkStrongAuthStatus) { + case 2: + c1 = Color.green; + break; + case 3: + c1 = Color.red; + break; + default: + c1 = Color.gray; + } + switch(checkWeakAuthStatus) { + case 2: + c2 = Color.green; + break; + case 3: + c2 = Color.red; + break; + default: + c2= c1; + } + g.drawOval(x-xc, y+yc, ovalwidth, ovalheight); + g.setColor(c1); + int[] xps = new int[]{x-xoffset, x-xoffset, x-xoffset+lockwidth}; + int[] yps = new int[]{y+yoffset, y+yoffset+lockheight, y+yoffset+lockheight}; + int[] xpw = new int[]{x-xoffset+lockwidth, x-xoffset+lockwidth, x-xoffset}; + int[] ypw = new int[]{y+yoffset+lockheight, y+yoffset, y+yoffset}; + g.fillPolygon(xps, yps,3); + + g.setColor(c2); + g.fillPolygon(xpw, ypw, 3); + g.setColor(c); + g.drawPolygon(xps, yps,3); + g.drawPolygon(xpw, ypw, 3); + g.drawString("S", x-xoffset+1, y+yc+yoffset); + g.drawString("W", x-xoffset+lockwidth/2, y+yc+ovalheight); + if (checkStrongAuthStatus ==3){ + g.drawLine(x-xoffset, y+yoffset*3/2, x-xoffset/2, y+yoffset+yc); + g.drawLine(x-xoffset, y+yoffset+yc, x-xoffset/2, y+yoffset*3/2); + } + if (checkWeakAuthStatus==3 || checkStrongAuthStatus==3 && checkWeakAuthStatus <2){ + g.drawLine(x-xc*2/3, y+yoffset, x-xc/3, y+yc+lockheight); + g.drawLine(x-xc*2/3, y+yc+lockheight, x-xc/3, y+yoffset); + } + } + + public void drawConfVerification(Graphics g){ + int lockwidth=(int) (9*tdp.getZoom()); + int lockheight=(int) (7*tdp.getZoom()); + int yoffset = 3*lockheight; + + int ovalwidth=(int) (6*tdp.getZoom()); + int ovalheight=(int) (9*tdp.getZoom()); + + Color c = g.getColor(); + Color c1; + switch(checkConfStatus) { + case 1: + c1 = Color.gray; + break; + case 2: + c1 = Color.green; + break; + case 3: + c1 = Color.red; + break; + default: + return; + } + g.drawString(mappingName, x-lockwidth*2, y-lockheight); + g.drawOval(x-ovalwidth*2, y, ovalwidth, ovalheight); + g.setColor(c1); + g.fillRect(x-lockwidth*3/2, y+lockheight/2, lockwidth, lockheight); + g.setColor(c); + g.drawRect(x-lockwidth*3/2, y+lockheight/2, lockwidth, lockheight); + if (checkConfStatus==3){ + g.drawLine(x-lockwidth*2, y, x, y+lockheight*2); + g.drawLine(x-lockwidth*2, y+lockheight*2, x, y); + } + if (!secName.equals("")){ + switch(checkSecConfStatus) { + case 1: + c1 = Color.gray; + break; + case 2: + c1 = Color.green; + break; + case 3: + c1 = Color.red; + break; + default: + return; + } + g.drawString(secName, x-lockwidth*2, y+lockheight*3); + g.drawOval(x-ovalwidth*2, y+yoffset, ovalwidth, ovalheight); + g.setColor(c1); + g.fillRect(x-lockwidth*3/2, y+lockheight/2+yoffset, lockwidth, lockheight); + g.setColor(c); + g.drawRect(x-lockwidth*3/2, y+lockheight/2+yoffset, lockwidth, lockheight); + } + } + + public void manageMove() { + if (father != null) { + Point p = GraphicLib.putPointOnRectangle(x+(width/2), y+(height/2), father.getX(), father.getY(), father.getWidth(), father.getHeight()); + + x = p.x - width/2; + y = p.y - height/2; + + setMoveCd(x, y); + + int orientation = GraphicLib.getCloserOrientation(x+(width/2), y+(height/2), father.getX(), father.getY(), father.getWidth(), father.getHeight()); + if (orientation != currentOrientation) { + setOrientation(orientation); + } + } + } + + // TGConnecting points .. + public void setOrientation(int orientation) { + currentOrientation = orientation; + double w0, h0; + + switch(orientation) { + case GraphicLib.NORTH: + w0 = 0.5; + h0 = 0.0; + break; + case GraphicLib.WEST: + w0 = 0.0; + h0 = 0.5; + break; + case GraphicLib.SOUTH: + w0 = 0.5; + h0 = 1.0; + break; + case GraphicLib.EAST: + default: + w0 = 1.0; + h0 = 0.5; + } + + for (int i=0; i<nbConnectingPoint; i++) { + ((SysCAMSPortConnectingPoint) connectingPoint[i]).setW(w0); + ((SysCAMSPortConnectingPoint) connectingPoint[i]).setH(h0); + } + } + + public TGComponent isOnOnlyMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; + } + + public void wasSwallowed() { + myColor = null; + } + + public void wasUnswallowed() { + myColor = null; + setFather(null); + TDiagramPanel tdp = getTDiagramPanel(); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); + } + + public void resizeWithFather() { + if ((father != null) && (father instanceof SysCAMSPrimitiveComponent)) { + // Too large to fit in the father? -> resize it! + //resizeToFatherSize(); + setCdRectangle(0-getWidth()/2, father.getWidth() - (getWidth()/2), 0-getHeight()/2, father.getHeight() - (getHeight()/2)); + setMoveCd(x, y); + oldx = -1; + oldy = -1; + } + } + + public boolean editOndoubleClick(JFrame frame) { +// int oldSample = maxSamples; +// +// Vector<String> otherTypes; +// +// if (getFather() == null) { +// otherTypes = new Vector<String>(); +// } else { +// SysCAMSPrimitiveComponent tgc = (SysCAMSPrimitiveComponent)(getFather()); +// otherTypes = tgc.getAllRecords(); +// } +// Vector<TGComponent> refs = new Vector<TGComponent>(); +// for (TGComponent req: tdp.getMGUI().getAllRequirements()){ +// if (req instanceof AvatarRDRequirement){ +// refs.add(req); +// } +// } + +// JDialogTMLCompositePort jda = new JDialogTMLCompositePort(commName, typep, list[0], list[1], list[2], list[3], list[4], isOrigin, isFinite, isBlocking, ""+maxSamples, ""+widthSamples, isLossy, lossPercentage, maxNbOfLoss, frame, "Port properties", otherTypes, dataFlowType, associatedEvent, isPrex, isPostex, checkConf, checkAuth, reference, refs); +// GraphicLib.centerOnParent(jda, 350, 700 ); +// jda.setVisible( true ); +// dataFlowType = jda.getDataFlowType(); +// associatedEvent = jda.getAssociatedEvent(); +// isPrex = jda.isChannelPrex(); +// isPostex = jda.isChannelPostex(); + +// TraceManager.addDev( "The Data flow type is: " + dataFlowType ); +// TraceManager.addDev( "The Associated event is: " + associatedEvent ); + +// if (jda.hasNewData()) { +// try { +// maxSamples = Integer.decode(jda.getMaxSamples()).intValue(); +// widthSamples = Integer.decode(jda.getWidthSamples()).intValue(); +// if (maxSamples < 1) { +// maxSamples = oldSample; +// JOptionPane.showMessageDialog(frame, "Non valid value: " + maxSamples + ": Should be at least 1", "Error", JOptionPane.INFORMATION_MESSAGE); +// return false; +// } +// isOrigin = jda.isOrigin(); +// isFinite = jda.isFinite(); +// isBlocking = jda.isBlocking(); +// setPortName(jda.getParamName()); +// commName = jda.getParamName(); +// isLossy = jda.isLossy(); +// lossPercentage = jda.getLossPercentage(); +// maxNbOfLoss = jda.getMaxNbOfLoss(); +// oldTypep = typep; +// typep = jda.getPortType(); +// checkConf = jda.checkConf; +// reference = jda.getReference(); +// if (checkConf){ +// if (checkConfStatus == NOCHECK){ +// checkConfStatus = TOCHECK; +// } +// } +// else { +// if (checkConfStatus != NOCHECK){ +// checkConfStatus = NOCHECK; +// } +// } +// checkAuth = jda.checkAuth; +// if (checkStrongAuthStatus < 2){ +// checkStrongAuthStatus = 1; +// checkWeakAuthStatus = 1; +// } +// for(int i=0; i<nbMaxAttribute; i++) { +// list[i].setType(jda.getStringType(i)); +// } +// } catch (Exception e) { +// JOptionPane.showMessageDialog(frame, "Non valid value: " + e.getMessage(), "Error", JOptionPane.INFORMATION_MESSAGE); +// return false; +// } +// } + + if (this instanceof SysCAMSPortTDF) { + JDialogSysCAMSPortTDF jtdf = new JDialogSysCAMSPortTDF((SysCAMSPortTDF) this); + jtdf.setVisible(true); + } else { + JDialogSysCAMSPortDE jde = new JDialogSysCAMSPortDE((SysCAMSPortDE) this); + jde.setVisible(true); + } + + ((SysCAMSComponentTaskDiagramPanel)tdp).updatePorts(); + return true; + } + + protected String translateExtraParam() { + TType a; + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<Prop commName=\""); + sb.append(commName); + sb.append("\" commType=\"" + typep); + sb.append("\" origin=\""); + if (isOrigin) { + sb.append("true"); + } else { + sb.append("false"); + } + sb.append("\" finite=\""); + if (isFinite) { + sb.append("true"); + } else { + sb.append("false"); + } + sb.append("\" blocking=\""); + if (isBlocking) { + sb.append("true"); + } else { + sb.append("false"); + } + sb.append("\" maxSamples=\"" + maxSamples); + sb.append("\" widthSamples=\"" + widthSamples); + sb.append("\" isLossy=\"" + isLossy); + sb.append("\" isPrex=\"" + isPrex); + sb.append("\" isPostex=\"" + isPostex); + sb.append("\" lossPercentage=\"" + lossPercentage); + sb.append("\" maxNbOfLoss=\"" + maxNbOfLoss); + sb.append("\" dataFlowType=\"" + dataFlowType); + sb.append("\" associatedEvent=\"" + associatedEvent); + sb.append("\" checkConf=\"" + checkConf); + sb.append("\" checkConfStatus=\"" + checkConfStatus); + sb.append("\" checkAuth=\"" + checkAuth); + sb.append("\" checkWeakAuthStatus=\"" + checkWeakAuthStatus); + sb.append("\" checkStrongAuthStatus=\"" + checkStrongAuthStatus); + sb.append("\" />\n"); + for(int i=0; i<nbMaxAttribute; i++) { + a = list[i]; + sb.append("<Type"); + sb.append(" type=\""); + sb.append(a.getType()); + sb.append("\" typeOther=\""); + sb.append(a.getTypeOther()); + sb.append("\" />\n"); + } + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + try { + NodeList nli; + Node n1, n2; + Element elt; + int typeAtt; + String typeOther; + int nbAttribute = 0; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; j<nli.getLength(); j++) { + n2 = nli.item(j); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if ((elt.getTagName().equals("Type")) && (nbAttribute < nbMaxAttribute)) { + typeAtt = Integer.decode(elt.getAttribute("type")).intValue(); + try { + typeOther = elt.getAttribute("typeOther"); + } catch (Exception e) { + typeOther = ""; + } + TType ta = new TType(typeAtt, typeOther); + list[nbAttribute] = ta; + nbAttribute ++; + } + if (elt.getTagName().equals("Prop")) { + commName = elt.getAttribute("commName"); + try { + typep = Integer.decode(elt.getAttribute("commType")).intValue(); + maxSamples = Integer.decode(elt.getAttribute("maxSamples")).intValue(); + widthSamples = Integer.decode(elt.getAttribute("widthSamples")).intValue(); + } catch (Exception e) { + } + try { + lossPercentage = Integer.decode(elt.getAttribute("lossPercentage")).intValue(); + maxNbOfLoss = Integer.decode(elt.getAttribute("maxNbOfLoss")).intValue(); + dataFlowType = elt.getAttribute("dataFlowType"); + associatedEvent = elt.getAttribute("associatedEvent"); + checkConf = (elt.getAttribute("checkConf").compareTo("true")==0); + if (checkConf){ + checkConfStatus=TOCHECK; + } + checkAuth = (elt.getAttribute("checkAuth").compareTo("true")==0); + isLossy = (elt.getAttribute("isLossy").compareTo("true") ==0); + isPrex = (elt.getAttribute("isPrex").compareTo("true") ==0); + isPostex = (elt.getAttribute("isPostex").compareTo("true") ==0); + } catch (Exception e) { + lossPercentage = 0; + maxNbOfLoss = -1; + isLossy = false; + } + try { + isBlocking = (elt.getAttribute("blocking").compareTo("true") ==0); + isOrigin = (elt.getAttribute("origin").compareTo("true") ==0); + isFinite = (elt.getAttribute("finite").compareTo("true") ==0); + + } catch (Exception e) {} + } + makeValue(); + } + } + } + } + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + public void makeValue() { + value = getPortTypeName() + " " + getPortName(); + } + + public String getPortName() { + return commName; + } + + public int getPortType() { + return typep; + } + + public String getPortTypeName() { + switch(typep) { + case 0: + return "Channel"; + case 1: + return "Event"; + case 2: + default: + return "Request"; + } + } + + public boolean isBlocking() { + return isBlocking; + } + + public boolean isFinite() { + return isFinite; + } + + public int getMax() { + return maxSamples; + } + + public int getSize() { + return widthSamples; + } + + public boolean isOrigin() { + return isOrigin; + } + + public int getNbMaxAttribute() { + return nbMaxAttribute; + } + + public TType getParamAt(int index) { + return list[index]; + } + public void setParam(int index, TType t){ + list[index] = t; + } + + public int getDefaultConnector() { + return TGComponentManager.CONNECTOR_PORT_TMLC; + } + + public String getAttributes() { + String attr = ""; + if (isOrigin()) { + attr += "out "; + } else { + attr += "in "; + } + attr += getPortTypeName() + ": "; + attr += getPortName() + "\n"; + // Channel + if (typep == 0) { + if (!isBlocking()) { + attr += "N"; + } + attr += "B"; + if (isOrigin()) { + attr += "W\n"; + attr += "Width (in B): " + getSize() + "\n"; + if (isFinite()) { + attr += "Max samples: " + getNbMaxAttribute() + "\n"; + } else { + attr += "Infinite\n"; + } + } else { + attr += "R\n"; + } + // Event and Request + } else { + attr += "("; + for(int i=0; i<nbMaxAttribute; i++) { + if (i!=0) { + attr += ","; + } + attr += TType.getStringType(list[i].getType()); + } + attr += ")\n"; + if (typep == 1) { + if (isOrigin()) { + if (!isFinite()) { + attr += "Infinite FIFO\n"; + } else { + if (isBlocking()) { + attr += "Blocking "; + } else { + attr += "Non-blocking "; + } + attr += "finite FIFO: " + getMax() + "\n"; + } + } + } + } + if (conflict) { + attr += "Error in path=" + conflictMessage; + } + return attr; + } + + public boolean isLossy() { + return isLossy && isOrigin; + } + + public int getLossPercentage() { + return lossPercentage; + } + + public int getMaxNbOfLoss() { + return maxNbOfLoss; + } + + public boolean getConflict() { + return conflict; + } + + public void setConflict(boolean _conflict, String _msg) { + conflict = _conflict; + myColor = null; + conflictMessage = _msg; + calculatePortColor(); + } + + public void calculatePortColor() { + if (conflict) { + myColor = Color.red; + } else { +// if (typep == 0) { +// myColor = ColorManager.TML_PORT_CHANNEL; +// } else if (typep == 1) { +// myColor = ColorManager.TML_PORT_EVENT; +// } else { +// myColor = ColorManager.TML_PORT_REQUEST; +// } + if (this instanceof SysCAMSPortTDF) { + myColor = Color.lightGray; + } else { + myColor = Color.white; + } + } + } + + public String getDataFlowType() { + return dataFlowType; + } + + public boolean isPrex() { + return isPrex; + } + + public boolean isPostex() { + return isPostex; + } + + public String getAssociatedEvent() { + return associatedEvent; + } + + public boolean hasSameParametersThan(SysCAMSPrimitivePort _p) { + for(int i=0; i<5; i++) { + if (!(getParamAt(i).equals(_p.getParamAt(i)))) { + return false; + } + } + return true; + } + + public void setPortName(String s) { + for (TURTLEPanel tp : tdp.getMainGUI().tabs) { + for (TDiagramPanel t : tp.getPanels()) { + for (TGComponent t2 : t.getComponentList()) { + if (t2 instanceof TMLArchiCPNode) { + TMLArchiCPNode tacn = (TMLArchiCPNode) t2; + for (TGComponent tgc : tacn.getRecursiveAllInternalComponent()) { + if (tgc instanceof TMLArchiPortArtifact) { + TMLArchiPortArtifact tapi = (TMLArchiPortArtifact) tgc; + String tmp = tapi.getValue().replaceAll("(?i)" + commName + "$", s); + tapi.setValue(tmp); + } + } + } + } + } + } + + if ( (father != null) && (father instanceof SysCAMSPrimitiveComponent)) { + String name = father.getValue(); + TURTLEPanel tp = tdp.getMainGUI().getCurrentTURTLEPanel(); + for (TDiagramPanel t : tp.getPanels()) { + if (t.getName().compareTo(name) == 0) { + for (TGComponent t2 : t.getComponentList()) { + if (t2 instanceof TMLADWriteChannel) { + TMLADWriteChannel twc = (TMLADWriteChannel) t2; + if (twc.getChannelName().equals(commName)) + twc.setChannelName(s); + } + if (t2 instanceof TMLADReadChannel) { + TMLADReadChannel trc = (TMLADReadChannel) t2; + if (trc.getChannelName().equals(commName)) + trc.setChannelName(s); + } + if (t2 instanceof TMLADSendEvent) { + TMLADSendEvent tse = (TMLADSendEvent) t2; + if (tse.getEventName().equals(commName)) + tse.setEventName(s); + } + if (t2 instanceof TMLADSendRequest) { + TMLADSendRequest tsr = (TMLADSendRequest) t2; + if (tsr.getRequestName().equals(commName)) + tsr.setRequestName(s); + } + if (t2 instanceof TMLADWaitEvent) { + TMLADWaitEvent twe = (TMLADWaitEvent) t2; + if (twe.getEventName().equals(commName)) + twe.setEventName(s); + } + if (t2 instanceof TMLADNotifiedEvent) { + TMLADNotifiedEvent tne = (TMLADNotifiedEvent) t2; + if (tne.getEventName().equals(commName)) + tne.setEventName(s); + } + } + t.repaint(); + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSRecordComponent.java b/src/main/java/ui/syscams/SysCAMSRecordComponent.java new file mode 100644 index 0000000000..b74e5adab7 --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSRecordComponent.java @@ -0,0 +1,420 @@ +/* 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.syscams; + +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.JDialogAttribute; + +import javax.swing.*; +import java.awt.*; +import java.util.LinkedList; + +/** + * Class SysCAMSRecordComponent + * Record Component. To be used in SystemC-AMS component task diagrams + * Creation: 22/04/2018 + * @version 1.0 22/04/2018 + * @author Irina Kit Yan LEE + */ + +public class SysCAMSRecordComponent extends TGCScalableWithInternalComponent implements SwallowedTGComponent { + private int maxFontSize = 14; + private int minFontSize = 4; + private int currentFontSize = -1; + private boolean displayText = true; + private Color myColor; + + // Icon + private int iconSize = 15; + + // Attributes + protected LinkedList<TAttribute> myAttributes; + private int textX = 15; // border for ports + private double dtextX = 0.0; + + public String oldValue; + + public SysCAMSRecordComponent(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); + + initScaling(200, 150); + + oldScaleFactor = tdp.getZoom(); + dtextX = textX * oldScaleFactor; + textX = (int)dtextX; + dtextX = dtextX - textX; + + minWidth = 1; + minHeight = 1; + + nbConnectingPoint = 0; + + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + moveable = true; + multieditable = true; + editable = true; + removable = true; + userResizable = true; + + value = tdp.findTMLRecordComponentName("Record_"); + oldValue = value; + setName("Record component"); + + myImageIcon = IconManager.imgic1202; + + myAttributes = new LinkedList<TAttribute> (); + + actionOnAdd(); + } + + public void internalDrawing(Graphics g) { + int w; + Font f = g.getFont(); + Font fold = f; + + if (myColor == null) { + myColor = new Color(193, 218, 241- (getMyDepth() * 10), 200); + } + + if ((rescaled) && (!tdp.isScaled())) { + + if (currentFontSize == -1) { + currentFontSize = f.getSize(); + } + rescaled = false; + // Must set the font size .. + // Find the biggest font not greater than max_font size + // By Increment of 1 + // Or decrement of 1 + // If font is less than 4, no text is displayed + + int maxCurrentFontSize = Math.max(0, Math.min(height-(2*textX), maxFontSize)); + + f = f.deriveFont((float)maxCurrentFontSize); + g.setFont(f); + while(maxCurrentFontSize > (minFontSize-1)) { + if (g.getFontMetrics().stringWidth(value) < (width - iconSize - (2 * textX))) { + break; + } + maxCurrentFontSize --; + f = f.deriveFont((float)maxCurrentFontSize); + g.setFont(f); + } + + currentFontSize = maxCurrentFontSize; + + if(currentFontSize <minFontSize) { + displayText = false; + } else { + displayText = true; + f = f.deriveFont((float)currentFontSize); + g.setFont(f); + } + } + + // Zoom is assumed to be computed + Color c = g.getColor(); + g.drawRect(x, y, width, height); + if ((width > 2) && (height > 2)) { + g.setColor(myColor); + g.fillRect(x+1, y+1, width-1, height-1); + g.setColor(c); + } + + // Font size + if (displayText) { + f = f.deriveFont((float)currentFontSize); + g.setFont(f); + w = g.getFontMetrics().stringWidth(value); + if (w > (width - 2 * (iconSize + textX))) { + g.drawString(value, x + textX + 1, y + currentFontSize + textX); + } else { + g.drawString(value, x + (width - w)/2, y + currentFontSize + textX); + } + } + + // Icon + if ((width>30) && (height > (iconSize + 2*textX))) { + g.drawImage(IconManager.imgic1200.getImage(), x + width - iconSize - textX, y + textX, null); + } + + // Attributes + if (tdp.areAttributesVisible()) { + int index = 0; + int cpt = currentFontSize + 2 * textX; + String attr; + + TAttribute a; + + int si = Math.min(12, (int)((float)currentFontSize - 2)); + + f = g.getFont(); + f = f.deriveFont((float)si); + g.setFont(f); + int step = si + 2; + + while(index < myAttributes.size()) { + cpt += step; + if (cpt >= (height - textX)) { + break; + } + a = myAttributes.get (index); + attr = a.toString(); + w = g.getFontMetrics().stringWidth(attr); + if ((w + (2 * textX) + 1) < width) { + g.drawString(attr, x + textX, y + cpt); + } else { + attr = "..."; + w = g.getFontMetrics().stringWidth(attr); + if ((w + textX + 2) < width) { + g.drawString(attr, x + textX + 1, y + cpt); + } else { + // skip attribute + cpt -= step; + } + } + index ++; + } + } + g.setFont(fold); + } + + public void rescale(double scaleFactor){ + dtextX = (textX + dtextX) / oldScaleFactor * scaleFactor; + textX = (int)(dtextX); + dtextX = dtextX - textX; + + super.rescale(scaleFactor); + } + + public TGComponent isOnOnlyMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; + } + + public boolean editOndoubleClick(JFrame frame, int _x, int _y) { + // On the name ? + if ((displayText) && (_y <= (y + currentFontSize + textX))) { + oldValue = value; + String s = (String)JOptionPane.showInputDialog(frame, "Name:", "Setting component name", + JOptionPane.PLAIN_MESSAGE, IconManager.imgic100, + null, + getValue()); + if ((s != null) && (s.length() > 0)) { + // Check whether this name is already in use, or not + + if (!TAttribute.isAValidId(s, false, false)) { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the component: the new name is not a valid name", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + + if (((SysCAMSComponentTaskDiagramPanel)(tdp)).nameRecordComponentInUse(oldValue, s)) { + JOptionPane.showMessageDialog(frame, + "Error: the name is already in use", + "Name modification", + JOptionPane.ERROR_MESSAGE); + return false; + } else { + setValueWithChange(s); + rescaled = true; + return true; + } + } + return false; + } + + // And so -> attributes! + JDialogAttribute jda = new JDialogAttribute(myAttributes, null, frame, "Setting fields of " + value, "Field"); + setJDialogOptions(jda); + GraphicLib.centerOnParent(jda, 650, 375); + jda.setVisible(true); // blocked until dialog has been closed + rescaled = true; + return true; + } + + protected void setJDialogOptions(JDialogAttribute jda) { + jda.addAccess(TAttribute.getStringAccess(TAttribute.PUBLIC)); + jda.addAccess(TAttribute.getStringAccess(TAttribute.PRIVATE)); + jda.addType(TAttribute.getStringType(TAttribute.NATURAL), true); + jda.addType(TAttribute.getStringType(TAttribute.BOOLEAN), true); + jda.enableInitialValue(true); + jda.enableRTLOTOSKeyword(true); + jda.enableJavaKeyword(false); + } + + public int getType() { + return TGComponentManager.TMLCTD_RCOMPONENT; + } + + public void wasSwallowed() { + myColor = null; + } + + public void wasUnswallowed() { + myColor = null; + setFather(null); + TDiagramPanel tdp = getTDiagramPanel(); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); + } + + public void hasBeenResized() { + rescaled = true; + + if (getFather() != null) { + resizeWithFather(); + } + } + + public void resizeWithFather() { + if ((father != null) && (father instanceof SysCAMSCompositeComponent)) { + // Too large to fit in the father? -> resize it! + resizeToFatherSize(); + + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); + setMoveCd(x, y); + } + } + + public int getChildCount() { + return myAttributes.size(); + } + + public Object getChild(int index) { + if (index == 0) { + return value; + } else { + return myAttributes.get (index-1); + } + } + + public int getIndexOfChild(Object child) { + if (child instanceof String) { + return 0; + } else { + return myAttributes.indexOf(child) + 1; + } + } + + protected String translateExtraParam() { + TAttribute a; + StringBuffer sb = new StringBuffer("<extraparam>\n"); + for(int i=0; i<myAttributes.size(); i++) { + a = myAttributes.get (i); + sb.append("<Attribute access=\""); + sb.append(a.getAccess()); + sb.append("\" id=\""); + sb.append(a.getId()); + sb.append("\" value=\""); + sb.append(a.getInitialValue()); + sb.append("\" type=\""); + sb.append(a.getType()); + sb.append("\" typeOther=\""); + sb.append(a.getTypeOther()); + sb.append("\" />\n"); + } + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + try { + NodeList nli; + Node n1, n2; + Element elt; + int access, type; + String typeOther; + String id, valueAtt; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; j<nli.getLength(); j++) { + n2 = nli.item(j); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("Attribute")) { + access = Integer.decode(elt.getAttribute("access")).intValue(); + type = Integer.decode(elt.getAttribute("type")).intValue(); + try { + typeOther = elt.getAttribute("typeOther"); + } catch (Exception e) { + typeOther = ""; + } + id = elt.getAttribute("id"); + valueAtt = elt.getAttribute("value"); + + if (valueAtt.equals("null")) { + valueAtt = ""; + } + if ((TAttribute.isAValidId(id, false, false)) && (TAttribute.isAValidInitialValue(type, valueAtt))) { + TAttribute ta = new TAttribute(access, id, valueAtt, type, typeOther); + myAttributes.add (ta); + } + } + } + } + } + } + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + public int getCurrentFontSize() { + return currentFontSize; + } + + public LinkedList<TAttribute> getAttributes() { + return myAttributes; + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSReferencePortConnectingPoint.java b/src/main/java/ui/syscams/SysCAMSReferencePortConnectingPoint.java new file mode 100644 index 0000000000..88945a228f --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSReferencePortConnectingPoint.java @@ -0,0 +1,122 @@ +/* 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.syscams; + +import ui.CDElement; +import ui.TGComponent; + +/** + * Class SysCAMSReferencePortConnectingPoint + * Definition of referenced connecting points on which connectors of SystemC-AMS Component Task diagrams can be connected + * Creation: 27/04/2018 + * @version 1.0 27/04/2018 + * @author Irina Kit Yan LEE + */ + +public class SysCAMSReferencePortConnectingPoint extends SysCAMSPortConnectingPoint{ + + private SysCAMSCompositePort port; + + public SysCAMSReferencePortConnectingPoint(SysCAMSCompositePort _port, CDElement _container, double _w, double _h) { + super(_container, 0, 0, true, true, _w, _h); + port = _port; + } + + public void setPort(SysCAMSCompositePort _port) { + port = _port; + } + + public SysCAMSCompositePort getPort() { + return port; + } + + public static double getDecX(SysCAMSCompositePort _port) { + if (_port != null) { + TGComponent tgc = _port.getFather(); + if (tgc != null) { + int x1 = _port.getX() + _port.getWidth()/2; + int x2 = tgc.getX(); + int w1 = tgc.getWidth(); + return ((double)x1 - x2) / w1; + } + } + return 0; + } + + public double getDecX() { + if (port != null) { + return getDecX(port); + } + return 0; + } + + public static double getDecY(SysCAMSCompositePort _port) { + if (_port != null) { + TGComponent tgc = _port.getFather(); + if (tgc != null) { + int y1 = _port.getY() + _port.getHeight()/2; + int y2 = tgc.getY(); + int h1 = tgc.getHeight(); + return ((double)y1 - y2) / h1; + } + } + return 0; + } + + public double getDecY() { + if (port != null) { + return getDecY(port); + } + return 0; + } + + public int getX() { + if (container != null) { + return x + container.getX() + (int)(container.getWidth() * getDecX()); + } + return x; + } + + public int getY() { + if (container != null) { + return y + container.getY() + (int)(container.getHeight() * getDecY()); + } + return y; + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSRemoteCompositeComponent.java b/src/main/java/ui/syscams/SysCAMSRemoteCompositeComponent.java new file mode 100644 index 0000000000..b85c1ea3c7 --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSRemoteCompositeComponent.java @@ -0,0 +1,596 @@ +/* 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.syscams; + +import myutil.GraphicLib; +import myutil.TraceManager; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import ui.*; +import ui.util.IconManager; +//import ui.window.JDialogTMLRemoteCompositeComponent; + +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; + +/** +* Class SysCAMSRemoteCompositeComponent +* Composite Component. To be used in SystemC-AMS diagrams + * Creation: 27/04/2018 + * @version 1.0 27/04/2018 + * @author Irina Kit Yan LEE + */ + +public class SysCAMSRemoteCompositeComponent extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent { + private int maxFontSize = 20; + private int minFontSize = 4; + private int currentFontSize = -1; + private boolean displayText = true; + private Color myColor; + private int iconSize = 17; + private boolean iconIsDrawn = false; + + private int textX = 15; // border for ports + private double dtextX = 0.0; + + private int defaultDiag = 10; + private double ddefaultDiag = 0.0; + + private SysCAMSCompositeComponent syscamscc; + private ArrayList<SysCAMSCompositePort> ports; + + private NodeList nl; + + public SysCAMSRemoteCompositeComponent(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); + + initScaling(250, 200); + + oldScaleFactor = tdp.getZoom(); + dtextX = textX * oldScaleFactor; + textX = (int)dtextX; + dtextX = dtextX - textX; + + minWidth = 1; + minHeight = 1; + + nbConnectingPoint = 0; + nbInternalTGComponent = 0; + + moveable = true; + editable = true; + removable = true; + userResizable = true; + multieditable = true; + + value = "No reference"; + name = "Remote composite component"; + + ports = new ArrayList<SysCAMSCompositePort>(); + + myImageIcon = IconManager.imgic1200; + } + + public void updateReference(SysCAMSCompositeComponent syscamsccc) { + if (syscamscc == syscamsccc) { + updateReference(); + } + } + + public void updateReference() { + if (syscamscc != null) { + if (syscamscc.getTDiagramPanel() == null) { + syscamscc = null; + value = "No reference"; + } else { + // Update + value = syscamscc.getExtendedValue(); + updatePorts(); + } + } + } + + public void internalDrawing(Graphics g) { + int w; + int c; + Font f = g.getFont(); + Font fold = f; + + if (syscamscc == null) { + // Use value to find the component + syscamscc = tdp.getMGUI().getSysCAMSCompositeComponent(value); + if (syscamscc == null) { + value = "No reference"; + } + } else { + if (syscamscc.getTDiagramPanel() == null) { + syscamscc = null; + value = "No reference"; + } else { + if (ports.size() != syscamscc.getCompositePortNb()) { + updateReference(); + } + } + } + if (myColor == null) { + myColor = new Color(251, 252, 200- (getMyDepth() * 10), 200); + } + + if ((rescaled) && (!tdp.isScaled())) { + if (currentFontSize == -1) { + currentFontSize = f.getSize(); + } + rescaled = false; + // Must set the font size .. + // Find the biggest font not greater than max_font size + // By Increment of 1 + // Or decrement of 1 + // If font is less than 4, no text is displayed + int maxCurrentFontSize = Math.max(0, Math.min(height-(2*textX), maxFontSize)); + while(maxCurrentFontSize > (minFontSize-1)) { + f = f.deriveFont((float)maxCurrentFontSize); + g.setFont(f); + w = g.getFontMetrics().stringWidth(value); + c = width - iconSize - (2 * textX); + if (w < c) { + break; + } + maxCurrentFontSize --; + } + currentFontSize = maxCurrentFontSize; + displayText = currentFontSize >= minFontSize; + } + + // Zoom is assumed to be computed + Color col = g.getColor(); + g.drawRect(x, y, width, height); + if ((width > 2) && (height > 2)) { + g.setColor(myColor); + g.fillRect(x+1, y+1, width-1, height-1); + g.setColor(col); + } + + // Font size + if (displayText) { + f = f.deriveFont((float)currentFontSize); + g.setFont(f); + w = g.getFontMetrics().stringWidth(value); + if (!(w < (width - 2 * (iconSize + textX)))) { + g.drawString(value, x + textX + 1, y + currentFontSize + textX); + } else { + g.drawString(value, x + (width - w)/2, y + currentFontSize + textX); + } + } + g.setFont(fold); + + // Icon + if ((width>30) && (height > (iconSize + 2*textX))) { + g.drawImage(IconManager.imgic1200.getImage(), x + width - iconSize - textX, y + textX, null); + iconIsDrawn = true; + } else { + iconIsDrawn = false; + } + } + + public void rescale(double scaleFactor){ + dtextX = (textX + dtextX) / oldScaleFactor * scaleFactor; + textX = (int)(dtextX); + dtextX = dtextX - textX; + + ddefaultDiag = (defaultDiag + ddefaultDiag) / oldScaleFactor * scaleFactor; + defaultDiag = (int)(ddefaultDiag); + ddefaultDiag = ddefaultDiag - defaultDiag; + + super.rescale(scaleFactor); + } + + public TGComponent isOnOnlyMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; + } + + public boolean editOndoubleClick(JFrame frame, int _x, int _y) { + // On the icon? + if (iconIsDrawn && (syscamscc != null)) { + if (GraphicLib.isInRectangle(_x, _y, x + width - iconSize - textX, y + textX, iconSize, iconSize)) { + boolean b = tdp.getMGUI().selectHighLevelTab(syscamscc.getValuePanel()); + if (b) { + return false; + } + } + } + +// JDialogTMLRemoteCompositeComponent dialog = new JDialogTMLRemoteCompositeComponent(frame, "Setting referenced component", this); +// GraphicLib.centerOnParent(dialog, 400, 350); +// dialog.setVisible( true ); // blocked until dialog has been closed +// +// if (!dialog.isRegularClose()) { +// return false; +// } +// +// if (dialog.getReferenceComponentName() == null) { +// return false; +// } +// +// if (dialog.getReferenceComponentName().length() != 0) { +// tmlcc = getTDiagramPanel().getMGUI().getCompositeComponent(dialog.getReferenceComponentName()); +// if (tmlcc != null ){ +// updateReference(); +// rescaled = true; +// } +// tdp.repaint(); +// } + return false; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<info ref=\"" + value + "\" "); + sb.append("/>\n"); + + for (SysCAMSCompositePort port: ports) { + sb.append("<port id=\"" + port.getId() + "\" />\n"); + } + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList _nl, int decX, int decY, int decId) throws MalformedModelingException{ + nl = _nl; + } + + public void delayedLoad() throws MalformedModelingException { + try { + NodeList nli; + Node n1, n2; + Element elt; + int j, k; + int index; + int cptk = 0; + SysCAMSRemotePortCompositeComponent pcc; + TGConnectingPoint[] old = null; + ArrayList<SysCAMSCompositePort> tmp = null; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(j=0; j<nli.getLength(); j++) { + n2 = nli.item(j); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("info")) { + value = elt.getAttribute("ref"); + syscamscc = getTDiagramPanel().getMGUI().getSysCAMSCompositeComponent(value); + if (syscamscc != null ){ + updateReference(); + rescaled = true; + tmp = ports; + ports = new ArrayList<SysCAMSCompositePort>(); + for (SysCAMSCompositePort port: tmp) { + ports.add(port); + } + } + } + + if (elt.getTagName().equals("port")) { + if (old == null) { + old = connectingPoint; + connectingPoint = new TGConnectingPoint[nbConnectingPoint]; + } + try { + int portid = Integer.decode(elt.getAttribute("id")).intValue(); + + for (SysCAMSCompositePort port: tmp) { + if (port.getId() == portid) { + index = tmp.indexOf(port); + for (k=index*5; k<(index+1)*5; k++) { + // Must update position of connecting point + connectingPoint[k] = old[cptk]; + + if ((k % 5) == 0) { + if (nbInternalTGComponent > (k/5)) { + pcc = (SysCAMSRemotePortCompositeComponent)(tgcomponent[k/5]); + if (pcc != null) { + pcc.setElements(port, (SysCAMSReferencePortConnectingPoint)(connectingPoint[k])); + } + } + } + ((SysCAMSReferencePortConnectingPoint)(connectingPoint[k])).setPort(port); + if (connectingPoint[k] == null) { + TraceManager.addDev("null cp"); + } + cptk ++; + } + break; + } + } + } catch (Exception e) { + } + } + + } + } + } + } + // Make paths + ((SysCAMSComponentTaskDiagramPanel)getTDiagramPanel()).makePaths(); + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + public int getType() { + return TGComponentManager.TMLCTD_CREMOTECOMPONENT; + } + + public void wasSwallowed() { + myColor = null; + } + + public void wasUnswallowed() { + myColor = null; + setFather(null); + TDiagramPanel tdp = getTDiagramPanel(); + setCdRectangle(tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY()); + } + + public void hasBeenResized() { + rescaled = true; + if (getFather() != null) { + resizeWithFather(); + } + } + + public void resizeWithFather() { + if ((father != null) && ((father instanceof SysCAMSCompositeComponent) ||(father instanceof SysCAMSPrimitiveComponent))) { + // Too large to fit in the father? -> resize it! + resizeToFatherSize(); + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); + setMoveCd(x, y); + } + } + + public java.util.List<SysCAMSPrimitiveComponent> getAllPrimitiveComponents() { + if (syscamscc == null) { + return new ArrayList<SysCAMSPrimitiveComponent>(); + } + return syscamscc.getAllPrimitiveComponents(); + } + + public java.util.List<SysCAMSRecordComponent> getAllRecordComponents() { + if (syscamscc == null) { + return new ArrayList<SysCAMSRecordComponent>(); + } + return syscamscc.getAllRecordComponents(); + } + + public java.util.List<SysCAMSCompositePort> getAllInternalCompositePorts() { + java.util.List<SysCAMSCompositePort> list = new ArrayList<SysCAMSCompositePort>(); + if (syscamscc == null) { + return list; + } + return syscamscc.getAllInternalCompositePorts(); + } + + public ArrayList<SysCAMSPrimitivePort> getAllInternalPrimitivePorts() { + ArrayList<SysCAMSPrimitivePort> list = new ArrayList<SysCAMSPrimitivePort>(); + if (syscamscc == null) { + return list; + } + return syscamscc.getAllInternalPrimitivePorts(); + } + + public SysCAMSPrimitiveComponent getPrimitiveComponentByName(String _name) { + if (syscamscc == null) { + return null; + } + return syscamscc.getPrimitiveComponentByName(_name); + } + + public void drawTGConnectingPoint(Graphics g, int type) { + for (int i=0; i<nbConnectingPoint; i++) { + if (connectingPoint[i].isCompatibleWith(type)) { + connectingPoint[i].draw(g); + } + } + } + + // 5 tgconnecting per port: we show only them toward the exterior of the component + // Add to ports the new port and remove to ports the removed ports + // Update tgconnecting points accordingly. Those points should point to their original ones so as to be sure to be drawn at the right place + // to a list of those points, keep that list, and then, generate a array of those points. + public void updatePorts() { + ArrayList<SysCAMSCompositePort> list = syscamscc.getFirstLevelCompositePorts(); + int cpt=0; + + int i, j; + SysCAMSCompositePort tmp; + SysCAMSReferencePortConnectingPoint point; + + // Close attention to the list + boolean change = true; + if (list.size() != ports.size()) { + change = true; + } else { + for (SysCAMSCompositePort port: ports) { + if (!list.contains(port)) { + change = true; + break; + } + } + } + + if (change) { + TraceManager.addDev("change on ports!"); + // Delete unused ports and + ArrayList<SysCAMSReferencePortConnectingPoint> points = new ArrayList<SysCAMSReferencePortConnectingPoint>(); + cpt=0; + + for(i=0; i<ports.size(); i++) { + tmp = ports.get(i); + if (list.contains(tmp)) { + for (j=cpt; j<cpt+5; j++) { + points.add((SysCAMSReferencePortConnectingPoint)(connectingPoint[cpt])); + } + } else { + ports.remove(tmp); + for (j=cpt; j<cpt+5; j++) { + tdp.removeOneConnector(connectingPoint[cpt]); + // Shall we remove the connecting points? + } + i --; + } + cpt = cpt + 5; + } + // Add new ports + for (SysCAMSCompositePort port1: list) { + if (!ports.contains(port1)) { + ports.add(port1); + for(j=0; j<5; j++) { + point = new SysCAMSReferencePortConnectingPoint(port1, this, 0.5, 0.5); + points.add(point); + } + } + } + + if (nbConnectingPoint == points.size()) { + } else { + nbConnectingPoint = points.size(); + SysCAMSRemotePortCompositeComponent tgp; + connectingPoint = new TGConnectingPoint[nbConnectingPoint]; + nbInternalTGComponent = nbConnectingPoint/5; + tgcomponent = new TGComponent[nbInternalTGComponent]; + cpt = 0; + int cpttg = 0; + + for(SysCAMSPortConnectingPoint pt: points) { + connectingPoint[cpt] = pt; + if ((cpt % 5) == 0) { + tgp = new SysCAMSRemotePortCompositeComponent(getX(), getY(), 0, 0, 10, 10, false, this, tdp); + tgp.setElements(ports.get(cpttg), (SysCAMSReferencePortConnectingPoint)pt); + tgcomponent[cpttg] = tgp; + cpttg ++; + } + cpt ++; + } + } + } + } + + public TGComponent getPortOf(TGConnectingPoint tp) { + if (ports == null) { + return null; + } + for (int i=0; i<nbConnectingPoint; i++) { + if (connectingPoint[i] == tp) { + if (i/5 < ports.size()) { + return ports.get(i/5); + } + } + } + return null; + } + + public boolean setIdTGConnectingPoint(int num, int id) { + int i; + try { + if (connectingPoint == null) { + nbConnectingPoint = num + 1; + connectingPoint = new TGConnectingPoint[nbConnectingPoint]; + for(i=0; i<nbConnectingPoint; i++) { + connectingPoint[i] = new SysCAMSReferencePortConnectingPoint(null, this, 0.5, 0.5); + } + } else { + if (num >= nbConnectingPoint) { + nbConnectingPoint = num + 1; + TGConnectingPoint[] old = connectingPoint; + connectingPoint = new TGConnectingPoint[nbConnectingPoint]; + for(i=0; i<old.length; i++) { + connectingPoint[i] = old[i]; + } + for(i=old.length; i<nbConnectingPoint; i++) { + connectingPoint[i] = new SysCAMSReferencePortConnectingPoint(null, this, 0.5, 0.5); + } + } + } + connectingPoint[num].forceId(id); + return true; + } catch (Exception e) { + TraceManager.addDev("Exception remote 1:" + e.getMessage()); + return false; + } + } + + public boolean acceptSwallowedTGComponent(TGComponent tgc) { + return tgc instanceof SysCAMSRemotePortCompositeComponent; + } + + public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { + if (!acceptSwallowedTGComponent(tgc)) { + return false; + } + tgc.setFather(this); + tgc.setDrawingZone(true); + addInternalComponent(tgc, 0); + return true; + } + + public void removeSwallowedTGComponent(TGComponent tgc) { + } + + public String getAttributes() { + return ""; + } + + public TDiagramPanel getReferencedDiagram() { + if (syscamscc == null) { + return null; + } + return syscamscc.getTDiagramPanel(); + } + + public SysCAMSCompositeComponent getReference() { + return syscamscc; + } +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSRemotePortCompositeComponent.java b/src/main/java/ui/syscams/SysCAMSRemotePortCompositeComponent.java new file mode 100644 index 0000000000..6d43d81325 --- /dev/null +++ b/src/main/java/ui/syscams/SysCAMSRemotePortCompositeComponent.java @@ -0,0 +1,138 @@ +/* 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.syscams; + +import myutil.GraphicLib; +import ui.*; +import ui.util.IconManager; + +import java.awt.*; + +/** + * Class SysCAMSRemotePortCompositeComponent + * Port referencing the port of a composite component + * Creation: 22/04/2018 + * @version 1.0 22/04/2018 + * @author Irina Kit Yan LEE + */ + +public class SysCAMSRemotePortCompositeComponent extends TGCWithInternalComponent implements SwallowedTGComponent, WithAttributes { + private SysCAMSCompositePort port; + SysCAMSReferencePortConnectingPoint point; + private int defaultDiag = 10; + private Color myColor = new Color(251, 252, 200); + + public SysCAMSRemotePortCompositeComponent(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); + + nbConnectingPoint = 0; + nbInternalTGComponent = 0; + + moveable = false; + editable = false; + removable = false; + userResizable = false; + multieditable = false; + + value = "Reference Port"; + name = "Reference Port"; + + myImageIcon = IconManager.imgic1200; + } + + public void internalDrawing(Graphics g) { + int xp, yp; + Color pc = myColor; + Color col = g.getColor(); + + if (port != null) { + pc = port.getPortColor(); + if (pc == null) { + pc = myColor; + } + } + + if (point != null) { + xp = point.getX() - (defaultDiag / 2); + yp = point.getY() - (defaultDiag / 2); + x = point.getX(); + y = point.getY() ; + forceSize(0, 0); + g.setColor(pc); + g.fillOval(xp, yp, defaultDiag+1, defaultDiag+1); + g.setColor(col); + g.drawOval(xp, yp, defaultDiag, defaultDiag); + } + } + + public void setElements(SysCAMSCompositePort _port, SysCAMSReferencePortConnectingPoint _point) { + port = _port; + point = _point; + } + + public SysCAMSCompositePort getPort() { + return port; + } + + public String getAttributes() { + if (port != null) { + return port.getAttributes(); + } + return ""; + } + + public TGComponent isOnOnlyMe(int x1, int y1) { + if (point == null) { + return null; + } + + int xp, yp; + xp = point.getX() - (defaultDiag / 2); + yp = point.getY() - (defaultDiag / 2); + + if (GraphicLib.isInRectangle(x1, y1, xp, yp, defaultDiag, defaultDiag)) { + return this; + } + return null; + } + + public int getType() { + return TGComponentManager.TMLCTD_CREMOTEPORTCOMPONENT; + } +} \ No newline at end of file diff --git a/src/main/java/ui/window/JDialogSelectSysCAMSComponent.java b/src/main/java/ui/window/JDialogSelectSysCAMSComponent.java new file mode 100644 index 0000000000..eada7f27cb --- /dev/null +++ b/src/main/java/ui/window/JDialogSelectSysCAMSComponent.java @@ -0,0 +1,414 @@ +/* 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.TGComponent; +import ui.syscams.SysCAMSCompositeComponent; +import ui.syscams.SysCAMSPrimitiveComponent; +import ui.syscams.SysCAMSRemoteCompositeComponent; + +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.LinkedList; +import java.util.List; +import java.util.Vector; + +/** + * Class JDialogSelectSysCAMSComponent + * Dialog for managing primitive components to be validated + * Creation: 27/04/2018 + * @version 1.0 27/04/2018 + * @author Irina Kit Yan LEE + */ + +@SuppressWarnings("serial") + +public class JDialogSelectSysCAMSComponent extends JDialogBase implements ActionListener, ListSelectionListener { + public static Vector<TGComponent> validated, ignored; + private static boolean optimized = true; + + private Vector<TGComponent> val; + private Vector<TGComponent> ign, back; + + //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; + + /** Creates new form */ + public JDialogSelectSysCAMSComponent(Frame f, Vector<TGComponent> _back, List<TGComponent> componentList, String title) { + super(f, title, true); + + back = _back; + + List<TGComponent> pcl = new LinkedList<TGComponent>(); + makeComponentList(pcl, componentList); + + if ((validated == null) || (ignored == null)) { + val = makeNewVal(pcl); + ign = new Vector<TGComponent>(); + } else { + val = validated; + ign = ignored; + checkTask(val, pcl); + checkTask(ign, pcl); + addNewTask(val, pcl, ign); + } + + initComponents(); + myInitComponents(); + pack(); + } + + private void makeComponentList(List<TGComponent> cs, List<TGComponent> lcs) { + TGComponent tgc; + SysCAMSCompositeComponent ccomp; + + for(int i=0; i<lcs.size(); i++) { + tgc = lcs.get(i); + if (tgc instanceof SysCAMSCompositeComponent) { + ccomp = (SysCAMSCompositeComponent)tgc; + cs.addAll(ccomp.getAllPrimitiveComponents()); + } + if (tgc instanceof SysCAMSPrimitiveComponent) { + cs.add(tgc); + } + + if (tgc instanceof SysCAMSRemoteCompositeComponent) { + cs.addAll(((SysCAMSRemoteCompositeComponent)tgc).getAllPrimitiveComponents()); + } + } + } + + 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 SysCAMSPrimitiveComponent) { + v.addElement(tgc); + } + } + return v; + } + + private void checkTask(Vector<? extends TGComponent> tobeChecked, List<TGComponent> source) { + TGComponent t; + + for(int i=0; i<tobeChecked.size(); i++) { + t = tobeChecked.elementAt(i); + + if (!source.contains(t)) { + tobeChecked.removeElementAt(i); + i--; + } + } + } + + public void addNewTask(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 SysCAMSPrimitiveComponent) && (!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(gridbag2); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + 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("Ignored components")); + 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("Used components")); + 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(); + panel5.setLayout(new FlowLayout()); + + optimize = new JCheckBox("Optimize TML specification"); + optimize.setSelected(optimized); + panel5.add(optimize); + + 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; + optimized = optimize.isSelected(); + 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; + } +} diff --git a/src/main/java/ui/window/JDialogSysCAMSBlockDE.java b/src/main/java/ui/window/JDialogSysCAMSBlockDE.java new file mode 100644 index 0000000000..3fd9d549ad --- /dev/null +++ b/src/main/java/ui/window/JDialogSysCAMSBlockDE.java @@ -0,0 +1,184 @@ +/* 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.syscams.*; +import ui.util.IconManager; + +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; + +/** + * Class JDialogSystemCAMSBlockDE + * Dialog for managing of SystemC-AMS DE Block + * Creation: 26/04/2018 + * @version 1.0 26/04/2018 + * @author Irina Kit Yan LEE +*/ + +@SuppressWarnings("serial") + +public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener { + + /** Access to ActionPerformed **/ + private JTextField nameTextField; + private JTextField periodTextField; + + /** Parameters **/ + private SysCAMSBlockDE block; + + /** Constructor **/ + public JDialogSysCAMSBlockDE(SysCAMSBlockDE block) { + /** Set JDialog **/ + this.setTitle("Setting TDF Block Attributes"); + this.setSize(500, 168); + this.setLocationRelativeTo(null); + this.setVisible(true); + this.setAlwaysOnTop(true); + this.setResizable(false); + + /** Parameters **/ + this.block = block; + + dialog(); + } + + public void dialog() { + /** JPanel **/ + JPanel mainPanel = new JPanel(new BorderLayout()); + this.add(mainPanel); + + /** JTabbedPane **/ + JPanel attributesMainPanel = new JPanel(); + mainPanel.add(attributesMainPanel, BorderLayout.NORTH); // add tab to main panel + + // --- Attributes GridLayout ---// + attributesMainPanel.setLayout(new BorderLayout()); + + // Box for Attributes + Box attributesBox = Box.createVerticalBox(); + attributesBox.setBorder(BorderFactory.createTitledBorder("Setting DE block attributes")); + + // BorderLayout for Adding Attributes + JPanel attributesBoxPanel = new JPanel(new GridLayout(2, 2, 0, 10)); + + // GridLayout for name + JLabel nameLabel = new JLabel("Name : "); + attributesBoxPanel.add(nameLabel); + if (block.getValue().toString().equals("")) { // name empty + nameTextField = new JTextField(10); + } else { + nameTextField = new JTextField(block.getValue().toString(), 10); // name not empty + } + attributesBoxPanel.add(nameTextField); + + // GridLayout for period + JLabel periodLabel = new JLabel("Period Tm : "); + attributesBoxPanel.add(periodLabel); + if (block.getPeriod() == -1) { + periodTextField = new JTextField(10); + } else { + periodTextField = new JTextField(Integer.toString(block.getPeriod()), 10); + } + attributesBoxPanel.add(periodTextField); + attributesBox.add(attributesBoxPanel); // add border to box + + attributesMainPanel.add(attributesBox, BorderLayout.NORTH); // add box to grid + + // Down Side + JPanel downPanel = new JPanel(new GridLayout(1, 2)); + + JButton saveCloseButton = new JButton("Save and close"); + saveCloseButton.setIcon(IconManager.imgic25); + saveCloseButton.setActionCommand("Save_Close"); + saveCloseButton.addActionListener(this); + downPanel.add(saveCloseButton); + + JButton cancelButton = new JButton("Cancel"); + cancelButton.setIcon(IconManager.imgic27); + cancelButton.setActionCommand("Cancel"); + cancelButton.addActionListener(this); + downPanel.add(cancelButton); + + mainPanel.add(downPanel, BorderLayout.CENTER); + } + + public void actionPerformed(ActionEvent e) { + if ("Save_Close".equals(e.getActionCommand())) { + /** Save the name of the block into listNameTDF **/ + block.setValue(new String(nameTextField.getText())); + + /** Save the period of the block into listPeriodTmTDF **/ + if (!(periodTextField.getText().isEmpty())) { + Boolean periodValueInteger = false; + try { + Integer.parseInt(periodTextField.getText()); + } catch (NumberFormatException e1) { + JDialog msg = new JDialog(this); + msg.setLocationRelativeTo(null); + JOptionPane.showMessageDialog(msg, "Period Tm is not a Integer", "Warning !", + JOptionPane.WARNING_MESSAGE); + periodValueInteger = true; + } + if (periodValueInteger == false) { + block.setPeriod(Integer.parseInt(periodTextField.getText())); + } + } else { + block.setPeriod(-1); + } + + this.dispose(); + } + + if ("Cancel".equals(e.getActionCommand())) { + this.dispose(); + } + } +} \ No newline at end of file diff --git a/src/main/java/ui/window/JDialogSysCAMSBlockTDF.java b/src/main/java/ui/window/JDialogSysCAMSBlockTDF.java new file mode 100644 index 0000000000..91f8817476 --- /dev/null +++ b/src/main/java/ui/window/JDialogSysCAMSBlockTDF.java @@ -0,0 +1,226 @@ +/* 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.syscams.*; +import ui.util.IconManager; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; + +/** + * Class JDialogSystemCAMSBlockTDF + * Dialog for managing of SystemC-AMS TDF Block + * Creation: 26/04/2018 + * @version 1.0 26/04/2018 + * @author Irina Kit Yan LEE +*/ + +@SuppressWarnings("serial") + +public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener { + + /** Access to ActionPerformed **/ + private JTextField nameTextField; + private JTextField periodTextField; + private JTextArea processCodeTextArea; + + /** Parameters **/ + private SysCAMSBlockTDF block; + + /** Constructor **/ + public JDialogSysCAMSBlockTDF(SysCAMSBlockTDF block) { + /** Set JDialog **/ + this.setTitle("Setting TDF Block Attributes"); + this.setSize(500, 310); + this.setLocationRelativeTo(null); + this.setVisible(true); + this.setAlwaysOnTop(true); + this.setResizable(false); + + /** Parameters **/ + this.block = block; + + dialog(); + } + + public void dialog() { + /** JPanel **/ + JPanel mainPanel = new JPanel(new BorderLayout()); + this.add(mainPanel); + + /** JTabbedPane **/ + JTabbedPane tabbedPane = new JTabbedPane(); + JPanel attributesMainPanel = new JPanel(); + JPanel processMainPanel = new JPanel(); + tabbedPane.add("Attributes", attributesMainPanel); + tabbedPane.add("Process Code", processMainPanel); + + mainPanel.add(tabbedPane, BorderLayout.NORTH); // add tab to main panel + + // --- Attributes GridLayout ---// + attributesMainPanel.setLayout(new BorderLayout()); + + // Box for Attributes + Box attributesBox = Box.createVerticalBox(); + attributesBox.setBorder(BorderFactory.createTitledBorder("Setting TDF block attributes")); + + // BorderLayout for Adding Attributes + JPanel attributesBoxPanel = new JPanel(new GridLayout(2, 2, 0, 10)); + + // GridLayout for name + JLabel nameLabel = new JLabel("Name : "); + attributesBoxPanel.add(nameLabel); + if (block.getValue().toString().equals("")) { // name empty + nameTextField = new JTextField(10); + } else { + nameTextField = new JTextField(block.getValue().toString(), 10); // name not empty + } + attributesBoxPanel.add(nameTextField); + + // GridLayout for period + JLabel periodLabel = new JLabel("Period Tm : "); + attributesBoxPanel.add(periodLabel); + if (block.getPeriod() == -1) { + periodTextField = new JTextField(10); + } else { + periodTextField = new JTextField(Integer.toString(block.getPeriod()), 10); + } + attributesBoxPanel.add(periodTextField); + attributesBox.add(attributesBoxPanel); // add border to box + + attributesMainPanel.add(attributesBox, BorderLayout.NORTH); // add box to grid + + // Down Side + JPanel downPanel = new JPanel(new GridLayout(1, 2)); + + JButton saveCloseButton = new JButton("Save and close"); + saveCloseButton.setIcon(IconManager.imgic25); + saveCloseButton.setActionCommand("Save_Close"); + saveCloseButton.addActionListener(this); + downPanel.add(saveCloseButton); + + JButton cancelButton = new JButton("Cancel"); + cancelButton.setIcon(IconManager.imgic27); + cancelButton.setActionCommand("Cancel"); + cancelButton.addActionListener(this); + downPanel.add(cancelButton); + + mainPanel.add(downPanel, BorderLayout.CENTER); + + // --- ProcessCode BorderLayout ---// + processMainPanel.setLayout(new BorderLayout()); + + Box codeBox = Box.createVerticalBox(); + codeBox.setBorder(BorderFactory.createTitledBorder("Generating code")); + + JPanel codeBoxPanel = new JPanel(new BorderLayout()); + + codeBoxPanel.add(new JLabel("Behavior function of TDF block : "), BorderLayout.NORTH); + + processCodeTextArea = new JTextArea(block.getProcessCode()); + processCodeTextArea.setSize(100, 100); + processCodeTextArea.setTabSize(2); + + processCodeTextArea.setFont(new Font("Arial", Font.PLAIN, 16)); + processCodeTextArea.setLineWrap(true); + processCodeTextArea.setWrapStyleWord(true); + + JScrollPane processScrollPane = new JScrollPane(processCodeTextArea); + processScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + processScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + processScrollPane.setPreferredSize(new Dimension(200, 150)); + + codeBoxPanel.add(processScrollPane, BorderLayout.SOUTH); + + codeBox.add(codeBoxPanel); + processMainPanel.add(codeBox, BorderLayout.PAGE_START); + } + + public void actionPerformed(ActionEvent e) { + if ("Save_Close".equals(e.getActionCommand())) { + /** Save the name of the block into listNameTDF **/ + block.setValue(new String(nameTextField.getText())); + + /** Save the period of the block into listPeriodTmTDF **/ + if (!(periodTextField.getText().isEmpty())) { + Boolean periodValueInteger = false; + try { + Integer.parseInt(periodTextField.getText()); + } catch (NumberFormatException e1) { + JDialog msg = new JDialog(this); + msg.setLocationRelativeTo(null); + JOptionPane.showMessageDialog(msg, "Period Tm is not a Integer", "Warning !", + JOptionPane.WARNING_MESSAGE); + periodValueInteger = true; + } + if (periodValueInteger == false) { + block.setPeriod(Integer.parseInt(periodTextField.getText())); + } + } else { + block.setPeriod(-1); + } + + /** Save the process code into listProcessCodeTDF **/ + block.setProcessCode(processCodeTextArea.getText()); + + this.dispose(); + } + + if ("Cancel".equals(e.getActionCommand())) { + this.dispose(); + } + } +} \ No newline at end of file diff --git a/src/main/java/ui/window/JDialogSysCAMSPortConverter.java b/src/main/java/ui/window/JDialogSysCAMSPortConverter.java new file mode 100644 index 0000000000..9b2ff29199 --- /dev/null +++ b/src/main/java/ui/window/JDialogSysCAMSPortConverter.java @@ -0,0 +1,280 @@ +/* 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.syscams.*; +import ui.util.IconManager; + +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; + +/** + * Class JDialogSystemCAMSPortConverterIn + * Dialog for managing of SystemC-AMS Converter Input Port + * Creation: 07/05/2018 + * @version 1.0 07/05/2018 + * @author Irina Kit Yan LEE +*/ + +@SuppressWarnings("serial") + +public class JDialogSysCAMSPortConverter extends JDialog implements ActionListener { + + /** Access to ActionPerformed **/ + private JTextField nameTextField; + private JTextField periodTextField; + private JTextField rateTextField; + private JTextField delayTextField; + private String listTypeString[]; + private JComboBox<String> typeComboBoxString; + private String listOriginString[]; + private JComboBox<String> originComboBoxString; + + /** Parameters **/ + private SysCAMSPortConverter port; + + /** Constructor **/ + public JDialogSysCAMSPortConverter(SysCAMSPortConverter port) { + /** Set JDialog **/ + this.setTitle("Setting Converter Input Ports"); + this.setSize(500, 318); + this.setLocationRelativeTo(null); + this.setVisible(true); + this.setAlwaysOnTop(true); + this.setResizable(false); + + /** Parameters **/ + this.port = port; + this.dialog(); + } + + public void dialog() { + /** JPanel **/ + JPanel mainPanel = new JPanel(new BorderLayout()); + this.add(mainPanel); + + JPanel attributesMainPanel = new JPanel(new GridLayout()); + mainPanel.add(attributesMainPanel, BorderLayout.NORTH); + + // Left Side + Box box = Box.createVerticalBox(); + box.setBorder(BorderFactory.createTitledBorder("Setting converter input port attributes")); + + JPanel boxPanel = new JPanel(new GridLayout(6, 2, 0, 10)); + + JLabel labelName = new JLabel("Name : "); + boxPanel.add(labelName); + + if (port.getPortName().toString().equals("")) { // name empty + nameTextField = new JTextField(10); + } else { + nameTextField = new JTextField(port.getPortName().toString(), 10); // name not empty + } + + boxPanel.add(nameTextField); + + // Period + JLabel periodLabel = new JLabel("Period Tp : "); + boxPanel.add(periodLabel); // add label to box + if (port.getPeriod() == -1) { // name empty // port.getName().toString().equals("") || + periodTextField = new JTextField(10); + } else { + periodTextField = new JTextField("" + port.getPeriod(), 10); // name not empty + } + boxPanel.add(periodTextField); // add text to box + + // Rate + JLabel rateLabel = new JLabel("Rate : "); + boxPanel.add(rateLabel); // add label to box + + if (port.getRate() == -1) { // name empty // port.getName().toString().equals("") || + rateTextField = new JTextField(10); + } else { + rateTextField = new JTextField("" + port.getRate(), 10); // name not empty + } + boxPanel.add(rateTextField); // add text to box + + // Delay + JLabel delayLabel = new JLabel("Delay : "); + boxPanel.add(delayLabel); // add label to box + if (port.getDelay() == -1) { // name empty // port.getName().toString().equals("") || + delayTextField = new JTextField(10); + } else { + delayTextField = new JTextField("" + port.getDelay(), 10); // name not empty + } + boxPanel.add(delayTextField); // add text to box + + // Type + JLabel typeLabel = new JLabel("Type : "); + boxPanel.add(typeLabel); // add label to box + listTypeString = new String[3]; + listTypeString[0] = "Integer"; + listTypeString[1] = "Boolean"; + listTypeString[2] = "Float"; + typeComboBoxString = new JComboBox<String>(listTypeString); + if (port.getConvType().equals("") || port.getConvType().equals("Integer")) { + typeComboBoxString.setSelectedIndex(0); + } + if (port.getConvType().equals("Boolean")) { + typeComboBoxString.setSelectedIndex(1); + } + if (port.getConvType().equals("Float")) { + typeComboBoxString.setSelectedIndex(2); + } + typeComboBoxString.setActionCommand("type"); + typeComboBoxString.addActionListener(this); + boxPanel.add(typeComboBoxString); // add combo to box + + // Origin + JLabel orginLabel = new JLabel("Origin : "); + boxPanel.add(orginLabel); // add label to box + listOriginString = new String[2]; + listOriginString[0] = "Input"; + listOriginString[1] = "Output"; + originComboBoxString = new JComboBox<String>(listOriginString); + if (port.getOrigin().equals("") || port.getOrigin().equals("Input")) { + originComboBoxString.setSelectedIndex(0); + } + if (port.getOrigin().equals("Output")) { + originComboBoxString.setSelectedIndex(1); + } + originComboBoxString.setActionCommand("origin"); + originComboBoxString.addActionListener(this); + boxPanel.add(originComboBoxString); // add combo to box + + box.add(boxPanel); // add border to box + attributesMainPanel.add(box); // add grid to grid + + // Down Side + JPanel downPanel = new JPanel(new GridLayout(1, 2)); + + JButton saveCloseButton = new JButton("Save and close"); + saveCloseButton.setIcon(IconManager.imgic25); + saveCloseButton.setActionCommand("Save_Close"); + saveCloseButton.addActionListener(this); + downPanel.add(saveCloseButton); + + JButton cancelButton = new JButton("Cancel"); + cancelButton.setIcon(IconManager.imgic27); + cancelButton.setActionCommand("Cancel"); + cancelButton.addActionListener(this); + downPanel.add(cancelButton); + + mainPanel.add(downPanel, BorderLayout.CENTER); + } + + public void actionPerformed(ActionEvent e) { + if ("Save_Close".equals(e.getActionCommand())) { + port.setPortName(new String(nameTextField.getText())); + + if (!(periodTextField.getText().isEmpty())) { + Boolean periodValueInteger = false; + try { + Integer.parseInt(periodTextField.getText()); + } catch (NumberFormatException e1) { + JDialog msg = new JDialog(this); + msg.setLocationRelativeTo(null); + JOptionPane.showMessageDialog(msg, "Period is not a Integer", "Warning !", + JOptionPane.WARNING_MESSAGE); + periodValueInteger = true; + } + if (periodValueInteger == false) { + port.setPeriod(Integer.parseInt(periodTextField.getText())); + } + } else { + port.setPeriod(-1); + } + if (!(rateTextField.getText().isEmpty())) { + Boolean rateValueInteger = false; + try { + Integer.parseInt(rateTextField.getText()); + } catch (NumberFormatException e1) { + JDialog msg = new JDialog(this); + msg.setLocationRelativeTo(null); + JOptionPane.showMessageDialog(msg, "Rate is not a Integer", "Warning !", + JOptionPane.WARNING_MESSAGE); + rateValueInteger = true; + } + if (rateValueInteger == false) { + port.setRate(Integer.parseInt(rateTextField.getText())); + } + } else { + port.setRate(-1); + } + + if (!(delayTextField.getText().isEmpty())) { + Boolean delayValueInteger = false; + try { + Integer.parseInt(delayTextField.getText()); + } catch (NumberFormatException e1) { + JDialog msg = new JDialog(this); + msg.setLocationRelativeTo(null); + JOptionPane.showMessageDialog(msg, "Delay is not a Integer", "Warning !", + JOptionPane.WARNING_MESSAGE); + delayValueInteger = true; + } + if (delayValueInteger == false) { + port.setDelay(Integer.parseInt(delayTextField.getText())); + } + } else { + port.setDelay(-1); + } + port.setConvType((String) typeComboBoxString.getSelectedItem()); + port.setOrigin((String) originComboBoxString.getSelectedItem()); + + this.dispose(); + } + + if ("Cancel".equals(e.getActionCommand())) { + this.dispose(); + } + } +} \ No newline at end of file diff --git a/src/main/java/ui/window/JDialogSysCAMSPortDE.java b/src/main/java/ui/window/JDialogSysCAMSPortDE.java new file mode 100644 index 0000000000..a3b0e7aa3e --- /dev/null +++ b/src/main/java/ui/window/JDialogSysCAMSPortDE.java @@ -0,0 +1,280 @@ +/* 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.syscams.*; +import ui.util.IconManager; + +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; + +/** + * Class JDialogSystemCAMSPortDE + * Dialog for managing of SystemC-AMS DE Port + * Creation: 07/05/2018 + * @version 1.0 07/05/2018 + * @author Irina Kit Yan LEE +*/ + +@SuppressWarnings("serial") + +public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { + + /** Access to ActionPerformed **/ + private JTextField nameTextField; + private JTextField periodTextField; + private JTextField rateTextField; + private JTextField delayTextField; + private String listTypeString[]; + private JComboBox<String> typeComboBoxString; + private String listOriginString[]; + private JComboBox<String> originComboBoxString; + + /** Parameters **/ + private SysCAMSPortDE port; + + /** Constructor **/ + public JDialogSysCAMSPortDE(SysCAMSPortDE port) { + /** Set JDialog **/ + this.setTitle("Setting DE Ports"); + this.setSize(500, 318); + this.setLocationRelativeTo(null); + this.setVisible(true); + this.setAlwaysOnTop(true); + this.setResizable(false); + + /** Parameters **/ + this.port = port; + this.dialog(); + } + + public void dialog() { + /** JPanel **/ + JPanel mainPanel = new JPanel(new BorderLayout()); + this.add(mainPanel); + + JPanel attributesMainPanel = new JPanel(new GridLayout()); + mainPanel.add(attributesMainPanel, BorderLayout.NORTH); + + // Left Side + Box box = Box.createVerticalBox(); + box.setBorder(BorderFactory.createTitledBorder("Setting DE port attributes")); + + JPanel boxPanel = new JPanel(new GridLayout(6, 2, 0, 10)); + + JLabel labelName = new JLabel("Name : "); + boxPanel.add(labelName); + + if (port.getPortName().toString().equals("")) { // name empty + nameTextField = new JTextField(10); + } else { + nameTextField = new JTextField(port.getPortName().toString(), 10); // name not empty + } + + boxPanel.add(nameTextField); + + // Period + JLabel periodLabel = new JLabel("Period Tp : "); + boxPanel.add(periodLabel); // add label to box + if (port.getPeriod() == -1) { // name empty // port.getName().toString().equals("") || + periodTextField = new JTextField(10); + } else { + periodTextField = new JTextField("" + port.getPeriod(), 10); // name not empty + } + boxPanel.add(periodTextField); // add text to box + + // Rate + JLabel rateLabel = new JLabel("Rate : "); + boxPanel.add(rateLabel); // add label to box + + if (port.getRate() == -1) { // name empty // port.getName().toString().equals("") || + rateTextField = new JTextField(10); + } else { + rateTextField = new JTextField("" + port.getRate(), 10); // name not empty + } + boxPanel.add(rateTextField); // add text to box + + // Delay + JLabel delayLabel = new JLabel("Delay : "); + boxPanel.add(delayLabel); // add label to box + if (port.getDelay() == -1) { // name empty // port.getName().toString().equals("") || + delayTextField = new JTextField(10); + } else { + delayTextField = new JTextField("" + port.getDelay(), 10); // name not empty + } + boxPanel.add(delayTextField); // add text to box + + // Type + JLabel typeLabel = new JLabel("Type : "); + boxPanel.add(typeLabel); // add label to box + listTypeString = new String[3]; + listTypeString[0] = "Integer"; + listTypeString[1] = "Boolean"; + listTypeString[2] = "Float"; + typeComboBoxString = new JComboBox<String>(listTypeString); + if (port.getDEType().equals("") || port.getDEType().equals("Integer")) { + typeComboBoxString.setSelectedIndex(0); + } + if (port.getDEType().equals("Boolean")) { + typeComboBoxString.setSelectedIndex(1); + } + if (port.getDEType().equals("Float")) { + typeComboBoxString.setSelectedIndex(2); + } + typeComboBoxString.setActionCommand("type"); + typeComboBoxString.addActionListener(this); + boxPanel.add(typeComboBoxString); // add combo to box + + // Origin + JLabel orginLabel = new JLabel("Origin : "); + boxPanel.add(orginLabel); // add label to box + listOriginString = new String[2]; + listOriginString[0] = "Input"; + listOriginString[1] = "Output"; + originComboBoxString = new JComboBox<String>(listOriginString); + if (port.getOrigin().equals("") || port.getOrigin().equals("Input")) { + originComboBoxString.setSelectedIndex(0); + } + if (port.getOrigin().equals("Output")) { + originComboBoxString.setSelectedIndex(1); + } + originComboBoxString.setActionCommand("origin"); + originComboBoxString.addActionListener(this); + boxPanel.add(originComboBoxString); // add combo to box + + box.add(boxPanel); // add border to box + attributesMainPanel.add(box); // add grid to grid + + // Down Side + JPanel downPanel = new JPanel(new GridLayout(1, 2)); + + JButton saveCloseButton = new JButton("Save and close"); + saveCloseButton.setIcon(IconManager.imgic25); + saveCloseButton.setActionCommand("Save_Close"); + saveCloseButton.addActionListener(this); + downPanel.add(saveCloseButton); + + JButton cancelButton = new JButton("Cancel"); + cancelButton.setIcon(IconManager.imgic27); + cancelButton.setActionCommand("Cancel"); + cancelButton.addActionListener(this); + downPanel.add(cancelButton); + + mainPanel.add(downPanel, BorderLayout.CENTER); + } + + public void actionPerformed(ActionEvent e) { + if ("Save_Close".equals(e.getActionCommand())) { + port.setPortName(new String(nameTextField.getText())); + + if (!(periodTextField.getText().isEmpty())) { + Boolean periodValueInteger = false; + try { + Integer.parseInt(periodTextField.getText()); + } catch (NumberFormatException e1) { + JDialog msg = new JDialog(this); + msg.setLocationRelativeTo(null); + JOptionPane.showMessageDialog(msg, "Period is not a Integer", "Warning !", + JOptionPane.WARNING_MESSAGE); + periodValueInteger = true; + } + if (periodValueInteger == false) { + port.setPeriod(Integer.parseInt(periodTextField.getText())); + } + } else { + port.setPeriod(-1); + } + if (!(rateTextField.getText().isEmpty())) { + Boolean rateValueInteger = false; + try { + Integer.parseInt(rateTextField.getText()); + } catch (NumberFormatException e1) { + JDialog msg = new JDialog(this); + msg.setLocationRelativeTo(null); + JOptionPane.showMessageDialog(msg, "Rate is not a Integer", "Warning !", + JOptionPane.WARNING_MESSAGE); + rateValueInteger = true; + } + if (rateValueInteger == false) { + port.setRate(Integer.parseInt(rateTextField.getText())); + } + } else { + port.setRate(-1); + } + + if (!(delayTextField.getText().isEmpty())) { + Boolean delayValueInteger = false; + try { + Integer.parseInt(delayTextField.getText()); + } catch (NumberFormatException e1) { + JDialog msg = new JDialog(this); + msg.setLocationRelativeTo(null); + JOptionPane.showMessageDialog(msg, "Delay is not a Integer", "Warning !", + JOptionPane.WARNING_MESSAGE); + delayValueInteger = true; + } + if (delayValueInteger == false) { + port.setDelay(Integer.parseInt(delayTextField.getText())); + } + } else { + port.setDelay(-1); + } + port.setDEType((String) typeComboBoxString.getSelectedItem()); + port.setOrigin((String) originComboBoxString.getSelectedItem()); + + this.dispose(); + } + + if ("Cancel".equals(e.getActionCommand())) { + this.dispose(); + } + } +} \ No newline at end of file diff --git a/src/main/java/ui/window/JDialogSysCAMSPortTDF.java b/src/main/java/ui/window/JDialogSysCAMSPortTDF.java new file mode 100644 index 0000000000..556d0c54b0 --- /dev/null +++ b/src/main/java/ui/window/JDialogSysCAMSPortTDF.java @@ -0,0 +1,280 @@ +/* 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.syscams.*; +import ui.util.IconManager; + +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; + +/** + * Class JDialogSystemCAMSPortTDF + * Dialog for managing of SystemC-AMS TDF Port + * Creation: 26/04/2018 + * @version 1.0 26/04/2018 + * @author Irina Kit Yan LEE +*/ + +@SuppressWarnings("serial") + +public class JDialogSysCAMSPortTDF extends JDialog implements ActionListener { + + /** Access to ActionPerformed **/ + private JTextField nameTextField; + private JTextField periodTextField; + private JTextField rateTextField; + private JTextField delayTextField; + private String listTypeString[]; + private JComboBox<String> typeComboBoxString; + private String listOriginString[]; + private JComboBox<String> originComboBoxString; + + /** Parameters **/ + private SysCAMSPortTDF port; + + /** Constructor **/ + public JDialogSysCAMSPortTDF(SysCAMSPortTDF port) { + /** Set JDialog **/ + this.setTitle("Setting TDF Ports"); + this.setSize(500, 318); + this.setLocationRelativeTo(null); + this.setVisible(true); + this.setAlwaysOnTop(true); + this.setResizable(false); + + /** Parameters **/ + this.port = port; + this.dialog(); + } + + public void dialog() { + /** JPanel **/ + JPanel mainPanel = new JPanel(new BorderLayout()); + this.add(mainPanel); + + JPanel attributesMainPanel = new JPanel(new GridLayout()); + mainPanel.add(attributesMainPanel, BorderLayout.NORTH); + + // Left Side + Box box = Box.createVerticalBox(); + box.setBorder(BorderFactory.createTitledBorder("Setting TDF port attributes")); + + JPanel boxPanel = new JPanel(new GridLayout(6, 2, 0, 10)); + + JLabel labelName = new JLabel("Name : "); + boxPanel.add(labelName); + + if (port.getPortName().toString().equals("")) { // name empty + nameTextField = new JTextField(10); + } else { + nameTextField = new JTextField(port.getPortName().toString(), 10); // name not empty + } + + boxPanel.add(nameTextField); + + // Period + JLabel periodLabel = new JLabel("Period Tp : "); + boxPanel.add(periodLabel); // add label to box + if (port.getPeriod() == -1) { // name empty // port.getName().toString().equals("") || + periodTextField = new JTextField(10); + } else { + periodTextField = new JTextField("" + port.getPeriod(), 10); // name not empty + } + boxPanel.add(periodTextField); // add text to box + + // Rate + JLabel rateLabel = new JLabel("Rate : "); + boxPanel.add(rateLabel); // add label to box + + if (port.getRate() == -1) { // name empty // port.getName().toString().equals("") || + rateTextField = new JTextField(10); + } else { + rateTextField = new JTextField("" + port.getRate(), 10); // name not empty + } + boxPanel.add(rateTextField); // add text to box + + // Delay + JLabel delayLabel = new JLabel("Delay : "); + boxPanel.add(delayLabel); // add label to box + if (port.getDelay() == -1) { // name empty // port.getName().toString().equals("") || + delayTextField = new JTextField(10); + } else { + delayTextField = new JTextField("" + port.getDelay(), 10); // name not empty + } + boxPanel.add(delayTextField); // add text to box + + // Type + JLabel typeLabel = new JLabel("Type : "); + boxPanel.add(typeLabel); // add label to box + listTypeString = new String[3]; + listTypeString[0] = "Integer"; + listTypeString[1] = "Boolean"; + listTypeString[2] = "Float"; + typeComboBoxString = new JComboBox<String>(listTypeString); + if (port.getTDFType().equals("") || port.getTDFType().equals("Integer")) { + typeComboBoxString.setSelectedIndex(0); + } + if (port.getTDFType().equals("Boolean")) { + typeComboBoxString.setSelectedIndex(1); + } + if (port.getTDFType().equals("Float")) { + typeComboBoxString.setSelectedIndex(2); + } + typeComboBoxString.setActionCommand("type"); + typeComboBoxString.addActionListener(this); + boxPanel.add(typeComboBoxString); // add combo to box + + // Origin + JLabel orginLabel = new JLabel("Origin : "); + boxPanel.add(orginLabel); // add label to box + listOriginString = new String[3]; + listOriginString[0] = "Input"; + listOriginString[1] = "Output"; + originComboBoxString = new JComboBox<String>(listOriginString); + if (port.getOrigin().equals("") || port.getOrigin().equals("Input")) { + originComboBoxString.setSelectedIndex(0); + } + if (port.getOrigin().equals("Output")) { + originComboBoxString.setSelectedIndex(1); + } + originComboBoxString.setActionCommand("origin"); + originComboBoxString.addActionListener(this); + boxPanel.add(originComboBoxString); // add combo to box + + box.add(boxPanel); // add border to box + attributesMainPanel.add(box); // add grid to grid + + // Down Side + JPanel downPanel = new JPanel(new GridLayout(1, 2)); + + JButton saveCloseButton = new JButton("Save and close"); + saveCloseButton.setIcon(IconManager.imgic25); + saveCloseButton.setActionCommand("Save_Close"); + saveCloseButton.addActionListener(this); + downPanel.add(saveCloseButton); + + JButton cancelButton = new JButton("Cancel"); + cancelButton.setIcon(IconManager.imgic27); + cancelButton.setActionCommand("Cancel"); + cancelButton.addActionListener(this); + downPanel.add(cancelButton); + + mainPanel.add(downPanel, BorderLayout.CENTER); + } + + public void actionPerformed(ActionEvent e) { + if ("Save_Close".equals(e.getActionCommand())) { + port.setPortName(new String(nameTextField.getText())); + + if (!(periodTextField.getText().isEmpty())) { + Boolean periodValueInteger = false; + try { + Integer.parseInt(periodTextField.getText()); + } catch (NumberFormatException e1) { + JDialog msg = new JDialog(this); + msg.setLocationRelativeTo(null); + JOptionPane.showMessageDialog(msg, "Period is not a Integer", "Warning !", + JOptionPane.WARNING_MESSAGE); + periodValueInteger = true; + } + if (periodValueInteger == false) { + port.setPeriod(Integer.parseInt(periodTextField.getText())); + } + } else { + port.setPeriod(-1); + } + if (!(rateTextField.getText().isEmpty())) { + Boolean rateValueInteger = false; + try { + Integer.parseInt(rateTextField.getText()); + } catch (NumberFormatException e1) { + JDialog msg = new JDialog(this); + msg.setLocationRelativeTo(null); + JOptionPane.showMessageDialog(msg, "Rate is not a Integer", "Warning !", + JOptionPane.WARNING_MESSAGE); + rateValueInteger = true; + } + if (rateValueInteger == false) { + port.setRate(Integer.parseInt(rateTextField.getText())); + } + } else { + port.setRate(-1); + } + + if (!(delayTextField.getText().isEmpty())) { + Boolean delayValueInteger = false; + try { + Integer.parseInt(delayTextField.getText()); + } catch (NumberFormatException e1) { + JDialog msg = new JDialog(this); + msg.setLocationRelativeTo(null); + JOptionPane.showMessageDialog(msg, "Delay is not a Integer", "Warning !", + JOptionPane.WARNING_MESSAGE); + delayValueInteger = true; + } + if (delayValueInteger == false) { + port.setDelay(Integer.parseInt(delayTextField.getText())); + } + } else { + port.setDelay(-1); + } + port.setTDFType((String) typeComboBoxString.getSelectedItem()); + port.setOrigin((String) originComboBoxString.getSelectedItem()); + + this.dispose(); + } + + if ("Cancel".equals(e.getActionCommand())) { + this.dispose(); + } + } +} \ No newline at end of file diff --git a/src/main/resources/ui/util/camsconverterportE.gif b/src/main/resources/ui/util/camsconverterportE.gif new file mode 100644 index 0000000000000000000000000000000000000000..a0b9f06cb96c24c74b40065d8985c6abaa6025e7 GIT binary patch literal 132 zcmZ?wbhEHb6krfw_{abP*4Ebl|NjRv6#sMkxrPKgI|jHK=@~FHLWDeX6Vp?D6Vo%3 zv-#2!b8{1I4fIS*L6AZ5CkulJ!+!=HkTD<w8JJY2^shX<mT_^-0w$3aM|XV^iMT$o Y@lpHS6mzN6U27M(SbytPXJxPk09)!Pb^rhX literal 0 HcmV?d00001 diff --git a/src/main/resources/ui/util/camsconverterportN.gif b/src/main/resources/ui/util/camsconverterportN.gif new file mode 100644 index 0000000000000000000000000000000000000000..72165975e4f0239b3f58dc7a26ea0e7e4c3bccb3 GIT binary patch literal 111 zcmZ?wbhEHb6krfw_{hWn1lHEp|Ns97G8BKZfcOlG|G7PL6Vp?D6Vo%3vw71Kb8{1I z4fIS*O-xN0bU-RVni-gsr}VEpy_Rutjn0MC;C&gd*;|rcNFKD9cBpew0{4nbYplN2 IiZfUP0HiV_7ytkO literal 0 HcmV?d00001 diff --git a/src/main/resources/ui/util/camsconverterportS.gif b/src/main/resources/ui/util/camsconverterportS.gif new file mode 100644 index 0000000000000000000000000000000000000000..e2ce184b7136bfa6f1763032dc78fb93442a7d7e GIT binary patch literal 111 zcmZ?wbhEHb6krfw_{hWn1lHEp|Ns97G8BKZfcOlG|G7PL6Vp?D6Vo%3vw71Kb8{1I z4fIS*O-xN0bU-RVni-gsr}VEpy_Rut&4OD}FSc5?p3O{XpK$N+jJB!`Z+>}fa=u;` H1T-B0%XB2` literal 0 HcmV?d00001 diff --git a/src/main/resources/ui/util/camsconverterportW.gif b/src/main/resources/ui/util/camsconverterportW.gif new file mode 100644 index 0000000000000000000000000000000000000000..fd2af4f477d57323015b6249ba4d5b70ff66265e GIT binary patch literal 132 zcmZ?wbhEHb6krfw_{abP*4Ebl|NjRv6#sMkxrPKgI|jHK=@~FHLWDeX6Vp?D6Vo%3 zv-#2!b8{1I4fIS*L6AZ5CkulJ!+!=HkTD<w8JJY2^shX<mT_?nM})wOoe|RWR3Dc2 XwsTfFX@xC4rF1FB>RT^2D}yxvGZ`k4 literal 0 HcmV?d00001 diff --git a/src/main/resources/ui/util/camsdeport.gif b/src/main/resources/ui/util/camsdeport.gif new file mode 100644 index 0000000000000000000000000000000000000000..0d8c64d4df64153abf70d51fd6dbfb8d3a98f2e0 GIT binary patch literal 119 zcmZ?wbhEHb6krfw_`twmZEgMk|9{2*+<vYh!Oo5Wu10zW%!~{S3_u~z+{E-$-^BFH z<ZQn5#N6COTLV24QxIfO{K>)~!tkF#2dENgkN^V%lWb4_%F}BZ7T54xNDbbXk^QfA T!NbzWfozv%S-tx$#$XKqE$Jp{ literal 0 HcmV?d00001 diff --git a/src/main/resources/ui/util/camstdfport.gif b/src/main/resources/ui/util/camstdfport.gif new file mode 100644 index 0000000000000000000000000000000000000000..105d5cbc715f18610dba65e9cb98f654ba602aa0 GIT binary patch literal 132 zcmZ?wbhEHb6krfw_{abP*4Ebl|NjRv6#sMkxrPKgI|jHK=@~FHLWDeX6Vp?D6Vo%3 zv-#2!b8{1I4fIS*L6AZ5CkulJ!+!=HkTD<w8JJY2^shX<mT_^-f?HBAwpzBH%}i*o XQE-rZrjfUD<F0-e>u<g4tPIuwUH>Rh literal 0 HcmV?d00001 -- GitLab