diff --git a/src/main/java/elntranslator/ELNTModule.java b/src/main/java/elntranslator/ELNTModule.java index 2f78341883e7e6a21d0f6581dd00c60e54053f93..b345c68ef8d0c9ab5049c8607568a51a356baa2a 100644 --- a/src/main/java/elntranslator/ELNTModule.java +++ b/src/main/java/elntranslator/ELNTModule.java @@ -40,8 +40,6 @@ package elntranslator; import java.util.LinkedList; -import syscamstranslator.SysCAMSTBlockTDF; - /** * Class ELNTModule * Parameters of a ELN component : module @@ -67,7 +65,7 @@ public class ELNTModule extends ELNTComponent { private LinkedList<ELNTComponentCurrentSourceTDF> TDF_isource; private LinkedList<ELNTComponentVoltageSinkTDF> TDF_vsink; private LinkedList<ELNTComponentVoltageSourceTDF> TDF_vsource; - private LinkedList<ELNTComponentModuleTerminal> moduleTerminal; + private LinkedList<ELNTModuleTerminal> moduleTerminal; public ELNTModule(String _name) { name = _name; @@ -85,7 +83,7 @@ public class ELNTModule extends ELNTComponent { TDF_isource = new LinkedList<ELNTComponentCurrentSourceTDF>(); TDF_vsink = new LinkedList<ELNTComponentVoltageSinkTDF>(); TDF_vsource = new LinkedList<ELNTComponentVoltageSourceTDF>(); - moduleTerminal = new LinkedList<ELNTComponentModuleTerminal>(); + moduleTerminal = new LinkedList<ELNTModuleTerminal>(); } public String getName() { diff --git a/src/main/java/syscamstranslator/SysCAMSSpecification.java b/src/main/java/syscamstranslator/SysCAMSSpecification.java index 64d88bed1f17a004a63d988f30585ca97abb4175..7349f34aea5ade84becaed193536851659fd2fea 100644 --- a/src/main/java/syscamstranslator/SysCAMSSpecification.java +++ b/src/main/java/syscamstranslator/SysCAMSSpecification.java @@ -143,7 +143,7 @@ public class SysCAMSSpecification{ cons.add(con); } else if (con.get_p1().getComponent() instanceof SysCAMSTPortConverter && con.get_p2().getComponent() instanceof SysCAMSTPortDE) { if (((SysCAMSTPortDE) con.get_p2().getComponent()).getBlockDE() != null) { - if ((((SysCAMSTPortDE) con.get_p2().getComponent()).getBlockDE()).getCluster() != null ) { + if ((((SysCAMSTPortDE) con.get_p2().getComponent()).getBlockDE()).getCluster() != null) { cons.add(con); } } else if (((SysCAMSTPortDE) con.get_p2().getComponent()).getBlockGPIO2VCI() != null) { @@ -152,14 +152,20 @@ public class SysCAMSSpecification{ } } else if (con.get_p2().getComponent() instanceof SysCAMSTPortConverter && con.get_p1().getComponent() instanceof SysCAMSTPortDE) { if (((SysCAMSTPortDE) con.get_p1().getComponent()).getBlockDE() != null) { - if ((((SysCAMSTPortDE) con.get_p1().getComponent()).getBlockDE()).getCluster() != null ) { + if ((((SysCAMSTPortDE) con.get_p1().getComponent()).getBlockDE()).getCluster() != null) { cons.add(con); } } else if (((SysCAMSTPortDE) con.get_p1().getComponent()).getBlockGPIO2VCI() != null) { System.out.println("Spec: IF p1 belongs to GPIO"); cons.add(con); } - } + } else if (con.get_p1().getComponent() instanceof SysCAMSTPortDE && con.get_p2().getComponent() instanceof SysCAMSTPortDE) { + if (((SysCAMSTPortDE) con.get_p1().getComponent()).getBlockDE() != null && ((SysCAMSTPortDE) con.get_p2().getComponent()).getBlockDE() != null) { + if ((((SysCAMSTPortDE) con.get_p1().getComponent()).getBlockDE()).getCluster() != null && (((SysCAMSTPortDE) con.get_p2().getComponent()).getBlockDE()).getCluster() != null) { + cons.add(con); + } + } + } } } return cons; diff --git a/src/main/java/syscamstranslator/SysCAMSTConnector.java b/src/main/java/syscamstranslator/SysCAMSTConnector.java index d28d43884d6867e931fa34b40c6195ab5abd649c..19963497f860d7b21ea50d03578ca75bf51d6605 100644 --- a/src/main/java/syscamstranslator/SysCAMSTConnector.java +++ b/src/main/java/syscamstranslator/SysCAMSTConnector.java @@ -47,13 +47,15 @@ package syscamstranslator; */ public class SysCAMSTConnector{ - private SysCAMSTConnectingPoint connectingPoint1; private SysCAMSTConnectingPoint connectingPoint2; + + private String name; - public SysCAMSTConnector(SysCAMSTConnectingPoint _connectingPoint1, SysCAMSTConnectingPoint _connectingPoint2) { + public SysCAMSTConnector(SysCAMSTConnectingPoint _connectingPoint1, SysCAMSTConnectingPoint _connectingPoint2, String _name) { connectingPoint1 = _connectingPoint1; connectingPoint2 = _connectingPoint2; + name = _name; } public SysCAMSTConnectingPoint get_p1() { @@ -63,4 +65,8 @@ public class SysCAMSTConnector{ public SysCAMSTConnectingPoint get_p2() { return connectingPoint2; } + + public String getName() { + return name; + } } diff --git a/src/main/java/syscamstranslator/toSysCAMS/ClusterCode.java b/src/main/java/syscamstranslator/toSysCAMS/ClusterCode.java index 1e32f520c86fd5bde2ea7f63541c885c00edd8e5..9eee38a252b01ca8c7f48d9e8666377fe80c5677 100644 --- a/src/main/java/syscamstranslator/toSysCAMS/ClusterCode.java +++ b/src/main/java/syscamstranslator/toSysCAMS/ClusterCode.java @@ -55,7 +55,7 @@ import syscamstranslator.*; * Creation: 14/05/2018 * @version 1.0 14/05/2018 * @author Irina Kit Yan LEE -*/ + */ public class ClusterCode { static private String corpsCluster; @@ -67,66 +67,101 @@ public class ClusterCode { public static String getClusterCode(SysCAMSTCluster cluster, LinkedList<SysCAMSTConnector> connectors) { int nb_con = 1; int nb_block = 1; - + + LinkedList<String> names = new LinkedList<String>(); + if (cluster != null) { LinkedList<SysCAMSTBlockTDF> tdf = cluster.getBlockTDF(); LinkedList<SysCAMSTBlockDE> de = cluster.getBlockDE(); - + corpsCluster = "// Simulation entry point." + CR + "int sc_main(int argc, char *argv[]) {" + CR2 + "\tusing namespace sc_core;" + CR + "\tusing namespace sca_util;" + CR2; - + corpsCluster = corpsCluster + "\t// Declare signal to interconnect." + CR; - + for (SysCAMSTConnector c : connectors) { - if (c.get_p1().getComponent() instanceof SysCAMSTPortTDF) { - corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortTDF) c.get_p1().getComponent()).getTDFType() + "> " - + "sig_" + nb_con + "(\"" - + "sig_" + nb_con + "\");" + CR; - nb_con++; - } else if (c.get_p1().getComponent() instanceof SysCAMSTPortConverter) { - corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortConverter) c.get_p1().getComponent()).getConvType() + "> " - + "sig_" + nb_con + "(\"" - + "sig_" + nb_con + "\");" + CR; - nb_con++; - } else if (c.get_p1().getComponent() instanceof SysCAMSTPortDE) { - corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortDE) c.get_p1().getComponent()).getDEType() + "> " - + "sig_" + nb_con + "(\"" - + "sig_" + nb_con + "\");" + CR; - nb_con++; + if ((c.get_p1().getComponent() instanceof SysCAMSTPortTDF && c.get_p2().getComponent() instanceof SysCAMSTPortTDF) + || (c.get_p1().getComponent() instanceof SysCAMSTPortTDF && c.get_p2().getComponent() instanceof SysCAMSTPortTDF)) { + if (c.getName().equals("")) { + corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortTDF) c.get_p1().getComponent()).getTDFType() + "> " + + "sig_" + nb_con + ";" + CR; + names.add("sig_" + nb_con); + nb_con++; + } else { + corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortTDF) c.get_p1().getComponent()).getTDFType() + "> " + + c.getName() + ";" + CR; + names.add(c.getName()); + } + } else if ((c.get_p1().getComponent() instanceof SysCAMSTPortConverter && c.get_p2().getComponent() instanceof SysCAMSTPortDE)) { + if (c.getName().equals("")) { + corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortConverter) c.get_p1().getComponent()).getConvType() + "> " + + "sig_" + nb_con + ";" + CR; + names.add("sig_" + nb_con); + nb_con++; + } else { + corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortConverter) c.get_p1().getComponent()).getConvType() + "> " + + c.getName() + ";" + CR; + names.add(c.getName()); + } + } else if ((c.get_p2().getComponent() instanceof SysCAMSTPortConverter && c.get_p1().getComponent() instanceof SysCAMSTPortDE)) { + if (c.getName().equals("")) { + corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortConverter) c.get_p2().getComponent()).getConvType() + "> " + + "sig_" + nb_con + ";" + CR; + names.add("sig_" + nb_con); + nb_con++; + } else { + corpsCluster = corpsCluster + "\tsca_tdf::sca_signal<" + ((SysCAMSTPortConverter) c.get_p2().getComponent()).getConvType() + "> " + + c.getName() + ";" + CR; + names.add(c.getName()); + } + } else if ((c.get_p1().getComponent() instanceof SysCAMSTPortDE && c.get_p2().getComponent() instanceof SysCAMSTPortDE) + || (c.get_p2().getComponent() instanceof SysCAMSTPortDE && c.get_p1 ().getComponent() instanceof SysCAMSTPortDE)) { + if (c.getName().equals("")) { + corpsCluster = corpsCluster + "\tsc_core::sc_signal<" + ((SysCAMSTPortDE) c.get_p1().getComponent()).getDEType() + "> " + + "sig_" + nb_con + ";" + CR; + names.add("sig_" + nb_con); + nb_con++; + } else { + corpsCluster = corpsCluster + "\tsc_core::sc_signal<" + ((SysCAMSTPortDE) c.get_p1().getComponent()).getDEType() + "> " + + c.getName() + ";" + CR; + names.add(c.getName()); + } } } corpsCluster = corpsCluster + CR + "\t// Instantiate headers files as well as bind their ports to the signal." + CR; - + for (SysCAMSTBlockTDF t : tdf) { corpsCluster = corpsCluster + "\t" + t.getName() + " " + t.getName() + "_" + nb_block + "(\"" + t.getName() + "_" + nb_block + "\");" + CR; - + LinkedList<SysCAMSTPortTDF> portTDF = t.getPortTDF(); LinkedList<SysCAMSTPortConverter> portConv = t.getPortConverter(); - + for (SysCAMSTPortTDF p : portTDF) { for (int i = 0; i < connectors.size(); i++) { - nb_con = i+1; - if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortTDF) { + if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortTDF && connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortTDF) { if (((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortTDF) connectors.get(i).get_p1().getComponent()).getBlockTDF().getName().equals(t.getName())) { - corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + "sig_" + nb_con + ");" + CR; + corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; } else if (((SysCAMSTPortTDF) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortTDF) connectors.get(i).get_p2().getComponent()).getBlockTDF().getName().equals(t.getName())) { - corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + "sig_" + nb_con + ");" + CR; + corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; } } } } - + for (SysCAMSTPortConverter p : portConv) { for (int i = 0; i < connectors.size(); i++) { - nb_con = i+1; - if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortConverter) { + if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortConverter && connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortDE) { if (((SysCAMSTPortConverter) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortConverter) connectors.get(i).get_p1().getComponent()).getBlockTDF().getName().equals(t.getName())) { - corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + "sig_" + nb_con + ");" + CR; + corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; + } else if (((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getBlockDE().getName().equals(t.getName())) { + corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; } - } else if (connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortConverter) { + } else if (connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortConverter && connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortDE) { if (((SysCAMSTPortConverter) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortConverter) connectors.get(i).get_p2().getComponent()).getBlockTDF().getName().equals(t.getName())) { - corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + "sig_" + nb_con + ");" + CR; + corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; + } else if (((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getBlockDE().getName().equals(t.getName())) { + corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; } } } @@ -134,22 +169,31 @@ public class ClusterCode { corpsCluster = corpsCluster + CR; nb_block++; } - + for (SysCAMSTBlockDE t : de) { corpsCluster = corpsCluster + "\t" + t.getName() + " " + t.getName() + "_" + nb_block + "(\"" + t.getName() + "_" + nb_block + "\");" + CR; - + LinkedList<SysCAMSTPortDE> portDE = t.getPortDE(); - + for (SysCAMSTPortDE p : portDE) { for (int i = 0; i < connectors.size(); i++) { - nb_con = i+1; - if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortDE) { + if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortDE && connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortDE) { if (((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getBlockDE().getName().equals(t.getName())) { - corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + "sig_" + nb_con + ");" + CR; - } - } else if (connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortDE) { - if (((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getBlockDE().getName().equals(t.getName())) { - corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + "sig_" + nb_con + ");" + CR; + corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; + } else if (((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getBlockDE().getName().equals(t.getName())) { + corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; + } + } else if (connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortConverter && connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortDE) { + if (((SysCAMSTPortConverter) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortConverter) connectors.get(i).get_p1().getComponent()).getBlockTDF().getName().equals(t.getName())) { + corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; + } else if (((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortDE) connectors.get(i).get_p2().getComponent()).getBlockDE().getName().equals(t.getName())) { + corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; + } + } else if (connectors.get(i).get_p2().getComponent() instanceof SysCAMSTPortConverter && connectors.get(i).get_p1().getComponent() instanceof SysCAMSTPortDE) { + if (((SysCAMSTPortConverter) connectors.get(i).get_p2().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortConverter) connectors.get(i).get_p2().getComponent()).getBlockTDF().getName().equals(t.getName())) { + corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; + } else if (((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getName().equals(p.getName()) && ((SysCAMSTPortDE) connectors.get(i).get_p1().getComponent()).getBlockDE().getName().equals(t.getName())) { + corpsCluster = corpsCluster + "\t" + t.getName() + "_" + nb_block + "." + p.getName() + "(" + names.get(i) + ");" + CR; } } } @@ -157,14 +201,12 @@ public class ClusterCode { corpsCluster = corpsCluster + CR; nb_block++; } - + corpsCluster = corpsCluster + "\t// Configure signal tracing." + CR + "\tsca_trace_file* tfp = sca_create_tabular_trace_file(\"" + cluster.getClusterName() + "_tb\");" + CR; - - nb_con = 1; + for (int i = 0; i < connectors.size(); i++) { - corpsCluster = corpsCluster + "\tsca_trace(tfp, "+ "sig_" + nb_con + ", \"" + "sig_" + nb_con + "\");" + CR; - nb_con++; + corpsCluster = corpsCluster + "\tsca_trace(tfp, "+ names.get(i) + ", \"" + names.get(i) + "\");" + CR; } corpsCluster = corpsCluster + CR + "\t// Start simulation." + CR + "\tsc_start(100.0, SC_MS);" + CR2 + "\t// Close trace file and stop simulation to enable clean-up by" + CR diff --git a/src/main/java/ui/ActionPerformer.java b/src/main/java/ui/ActionPerformer.java index 2d63316ac47cc763cd7af2ac7dfe51d3a8fe3cb1..824db9d610d07990df7f5ee2423baaf1a8efadc6 100644 --- a/src/main/java/ui/ActionPerformer.java +++ b/src/main/java/ui/ActionPerformer.java @@ -973,6 +973,8 @@ public class ActionPerformer { mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ELN_TDF_VOLTAGE_SOURCE); } else if (command.equals(mgui.actions[TGUIAction.ELN_TDF_CURRENT_SOURCE].getActionCommand())){ mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ELN_TDF_CURRENT_SOURCE); + } else if (command.equals(mgui.actions[TGUIAction.ELN_CLUSTER].getActionCommand())){ + mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ELN_CLUSTER); // Attack Tree Diagrams } else if (command.equals(mgui.actions[TGUIAction.ATD_BLOCK].getActionCommand())) { diff --git a/src/main/java/ui/ELNPanelTranslator.java b/src/main/java/ui/ELNPanelTranslator.java index d8c810b192032c7bab7e51bc46e9f5ab922f6253..451f67658ab263b6bf75bfdf88c0104437042d1b 100644 --- a/src/main/java/ui/ELNPanelTranslator.java +++ b/src/main/java/ui/ELNPanelTranslator.java @@ -42,6 +42,7 @@ import ui.eln.*; import ui.eln.sca_eln.*; import ui.eln.sca_eln_sca_tdf.*; import java.util.*; +import elntranslator.*; /** * Class ELNPanelTranslator @@ -92,9 +93,9 @@ public class ELNPanelTranslator { if (dp instanceof ELNModule) { ELNModule module = (ELNModule) dp; - String name = module.getValue(); + String moduleName = module.getValue(); - ELNTModule elnModule = new ELNTModule(name); + ELNTModule elnModule = new ELNTModule(moduleName); List<ELNComponentCapacitor> capacitors = module.getAllComponentCapacitor(); for (int i = 0; i < capacitors.size(); i++) { @@ -105,12 +106,12 @@ public class ELNPanelTranslator { double q0 = capacitor.getQ0(); String unit0 = capacitor.getUnit0(); String unit1 = capacitor.getUnit1(); - ELNConnectingPoint[] cp = (ELNConnectingPoint) capacitor.connectingPoint; + ELNConnectingPoint[] cp = (ELNConnectingPoint[]) capacitor.connectingPoint; ELNTComponentCapacitor elnCapacitor = new ELNTComponentCapacitor(name, val, q0, unit0, unit1, cp, elnModule); elnMap.put(capacitor, elnCapacitor); - elnModule.addComponentCapacitor(elnCapacitor); + elnModule.addCapacitor(elnCapacitor); elnComponents.add(elnCapacitor); } List<ELNComponentCurrentSinkTDF> TDF_isinks = module.getAllComponentCurrentSinkTDF(); @@ -119,12 +120,12 @@ public class ELNPanelTranslator { String name = TDF_isink.getValue(); double scale = TDF_isink.getScale(); - ELNConnectingPoint[] cp = (ELNConnectingPoint) TDF_isink.connectingPoint; + ELNConnectingPoint[] cp = (ELNConnectingPoint[]) TDF_isink.connectingPoint; ELNTComponentCurrentSinkTDF elnTDF_isink = new ELNTComponentCurrentSinkTDF(name, scale, cp, elnModule); elnMap.put(TDF_isink, elnTDF_isink); - elnModule.addComponentCurrentSinkTDF(elnTDF_isink); + elnModule.addTDF_isink(elnTDF_isink); elnComponents.add(elnTDF_isink); } List<ELNComponentCurrentSourceTDF> TDF_isources = module.getAllComponentCurrentSourceTDF(); @@ -133,12 +134,12 @@ public class ELNPanelTranslator { String name = TDF_isource.getValue(); double scale = TDF_isource.getScale(); - ELNConnectingPoint[] cp = (ELNConnectingPoint) TDF_isource.connectingPoint; + ELNConnectingPoint[] cp = (ELNConnectingPoint[]) TDF_isource.connectingPoint; ELNTComponentCurrentSourceTDF elnTDF_isource = new ELNTComponentCurrentSourceTDF(name, scale, cp, elnModule); elnMap.put(TDF_isource, elnTDF_isource); - elnModule.addComponentCurrentSourceTDF(elnTDF_isource); + elnModule.addTDF_isource(elnTDF_isource); elnComponents.add(elnTDF_isource); } List<ELNComponentIdealTransformer> idealTransformers = module.getAllComponentIdealTransformer(); @@ -147,12 +148,12 @@ public class ELNPanelTranslator { String name = idealTransformer.getValue(); double ratio = idealTransformer.getRatio(); - ELNConnectingPoint[] cp = (ELNConnectingPoint) idealTransformer.connectingPoint; + ELNConnectingPoint[] cp = (ELNConnectingPoint[]) idealTransformer.connectingPoint; ELNTComponentIdealTransformer elnIdealTransformer = new ELNTComponentIdealTransformer(name, ratio, cp, elnModule); elnMap.put(idealTransformer, elnIdealTransformer); - elnModule.addComponentIdealTransformer(elnIdealTransformer); + elnModule.addIdealTransformer(elnIdealTransformer); elnComponents.add(elnIdealTransformer); } List<ELNComponentIndependentCurrentSource> isources = module.getAllComponentIndependentCurrentSource(); @@ -170,12 +171,12 @@ public class ELNPanelTranslator { double acNoiseAmpliture = isource.getAcNoiseAmplitude(); String delay = isource.getDelay(); String unit0 = isource.getUnit0(); - ELNConnectingPoint[] cp = (ELNConnectingPoint) isource.connectingPoint; + ELNConnectingPoint[] cp = (ELNConnectingPoint[]) isource.connectingPoint; ELNTComponentIndependentCurrentSource elnISource = new ELNTComponentIndependentCurrentSource(name, initValue, offset, amplitude, frequency, phase, acAmplitude, acPhase, acNoiseAmpliture, delay, unit0, cp, elnModule); elnMap.put(isource, elnISource); - elnModule.addComponentIndependentCurrentSource(elnISource); + elnModule.addIsource(elnISource); elnComponents.add(elnISource); } List<ELNComponentIndependentVoltageSource> vsources = module.getAllComponentIndependentVoltageSource(); @@ -193,12 +194,12 @@ public class ELNPanelTranslator { double acNoiseAmpliture = vsource.getAcNoiseAmplitude(); String delay = vsource.getDelay(); String unit0 = vsource.getUnit0(); - ELNConnectingPoint[] cp = (ELNConnectingPoint) vsource.connectingPoint; + ELNConnectingPoint[] cp = (ELNConnectingPoint[]) vsource.connectingPoint; ELNTComponentIndependentVoltageSource elnVSource = new ELNTComponentIndependentVoltageSource(name, initValue, offset, amplitude, frequency, phase, acAmplitude, acPhase, acNoiseAmpliture, delay, unit0, cp, elnModule); elnMap.put(vsource, elnVSource); - elnModule.addComponentIndependentVoltageSource(elnVSource); + elnModule.addVsource(elnVSource); elnComponents.add(elnVSource); } List<ELNComponentInductor> inductors = module.getAllComponentInductor(); @@ -210,12 +211,12 @@ public class ELNPanelTranslator { double phi0 = inductor.getPhi0(); String unit0 = inductor.getUnit0(); String unit1 = inductor.getUnit1(); - ELNConnectingPoint[] cp = (ELNConnectingPoint) inductor.connectingPoint; + ELNConnectingPoint[] cp = (ELNConnectingPoint[]) inductor.connectingPoint; - ELNTComponentInductor elnInductor = new ELNTComponentInductor(name, val, q0, unit0, unit1, cp, elnModule); + ELNTComponentInductor elnInductor = new ELNTComponentInductor(name, val, phi0, unit0, unit1, cp, elnModule); elnMap.put(inductor, elnInductor); - elnModule.addComponentInductor(elnInductor); + elnModule.addInductor(elnInductor); elnComponents.add(elnInductor); } List<ELNComponentNodeRef> nodeRefs = module.getAllComponentNodeRef(); @@ -227,7 +228,7 @@ public class ELNPanelTranslator { ELNTComponentNodeRef elnNodeRef = new ELNTComponentNodeRef(name, elnModule); elnMap.put(nodeRef, elnNodeRef); - elnModule.addComponentNodeRef(elnNodeRef); + elnModule.addNodeRef(elnNodeRef); elnComponents.add(elnNodeRef); } List<ELNComponentResistor> resistors = module.getAllComponentResistor(); @@ -237,12 +238,12 @@ public class ELNPanelTranslator { String name = resistor.getValue(); double val = resistor.getVal(); String unit = resistor.getUnit(); - ELNConnectingPoint[] cp = (ELNConnectingPoint) resistor.connectingPoint; + ELNConnectingPoint[] cp = (ELNConnectingPoint[]) resistor.connectingPoint; ELNTComponentResistor elnResistor = new ELNTComponentResistor(name, val, unit, cp, elnModule); elnMap.put(resistor, elnResistor); - elnModule.addComponentResistor(elnResistor); + elnModule.addResistor(elnResistor); elnComponents.add(elnResistor); } List<ELNComponentTransmissionLine> transmissionLines = module.getAllComponentTransmissionLine(); @@ -255,12 +256,12 @@ public class ELNPanelTranslator { String delay = transmissionLine.getDelay(); String unit0 = transmissionLine.getUnit0(); String unit2 = transmissionLine.getUnit2(); - ELNConnectingPoint[] cp = (ELNConnectingPoint) transmissionLine.connectingPoint; + ELNConnectingPoint[] cp = (ELNConnectingPoint[]) transmissionLine.connectingPoint; ELNTComponentTransmissionLine elnTransmissionLine = new ELNTComponentTransmissionLine(name, z0, delta0, delay, unit0, unit2, cp, elnModule); elnMap.put(transmissionLine, elnTransmissionLine); - elnModule.addComponentTransmissionLine(elnTransmissionLine); + elnModule.addTransmissionLine(elnTransmissionLine); elnComponents.add(elnTransmissionLine); } List<ELNComponentVoltageControlledCurrentSource> vccss = module.getAllComponentVoltageControlledCurrentSource(); @@ -270,12 +271,12 @@ public class ELNPanelTranslator { String name = vccs.getValue(); double val = vccs.getVal(); String unit = vccs.getUnit(); - ELNConnectingPoint[] cp = (ELNConnectingPoint) vccs.connectingPoint; + ELNConnectingPoint[] cp = (ELNConnectingPoint[]) vccs.connectingPoint; ELNTComponentVoltageControlledCurrentSource elnVCCS = new ELNTComponentVoltageControlledCurrentSource(name, val, unit, cp, elnModule); elnMap.put(vccs, elnVCCS); - elnModule.addComponentVoltageControlledCurrentSource(elnVCCS); + elnModule.addVccs(elnVCCS); elnComponents.add(elnVCCS); } List<ELNComponentVoltageControlledVoltageSource> vcvss = module.getAllComponentVoltageControlledVoltageSource(); @@ -284,12 +285,12 @@ public class ELNPanelTranslator { String name = vcvs.getValue(); double val = vcvs.getVal(); - ELNConnectingPoint[] cp = (ELNConnectingPoint) vcvs.connectingPoint; + ELNConnectingPoint[] cp = (ELNConnectingPoint[]) vcvs.connectingPoint; ELNTComponentVoltageControlledVoltageSource elnVCVS = new ELNTComponentVoltageControlledVoltageSource(name, val, cp, elnModule); elnMap.put(vcvs, elnVCVS); - elnModule.addComponentVoltageControlledVoltageSource(elnVCVS); + elnModule.addVcvs(elnVCVS); elnComponents.add(elnVCVS); } List<ELNComponentVoltageSinkTDF> TDF_vsinks = module.getAllComponentVoltageSinkTDF(); @@ -298,12 +299,12 @@ public class ELNPanelTranslator { String name = TDF_vsink.getValue(); double scale = TDF_vsink.getScale(); - ELNConnectingPoint[] cp = (ELNConnectingPoint) TDF_vsink.connectingPoint; + ELNConnectingPoint[] cp = (ELNConnectingPoint[]) TDF_vsink.connectingPoint; ELNTComponentVoltageSinkTDF elnTDF_vsink = new ELNTComponentVoltageSinkTDF(name, scale, cp, elnModule); elnMap.put(TDF_vsink, elnTDF_vsink); - elnModule.addComponentVoltageSinkTDF(elnTDF_vsink); + elnModule.addTDF_vsink(elnTDF_vsink); elnComponents.add(elnTDF_vsink); } List<ELNComponentVoltageSourceTDF> TDF_vsources = module.getAllComponentVoltageSourceTDF(); @@ -312,12 +313,12 @@ public class ELNPanelTranslator { String name = TDF_vsource.getValue(); double scale = TDF_vsource.getScale(); - ELNConnectingPoint[] cp = (ELNConnectingPoint) TDF_vsource.connectingPoint; + ELNConnectingPoint[] cp = (ELNConnectingPoint[]) TDF_vsource.connectingPoint; ELNTComponentVoltageSourceTDF elnTDF_vsource = new ELNTComponentVoltageSourceTDF(name, scale, cp, elnModule); elnMap.put(TDF_vsource, elnTDF_vsource); - elnModule.addComponentVoltageSourceTDF(elnTDF_vsource); + elnModule.addTDF_vsource(elnTDF_vsource); elnComponents.add(elnTDF_vsource); } List<ELNModuleTerminal> moduleTerminals = module.getAllModuleTerminal(); @@ -337,19 +338,22 @@ public class ELNPanelTranslator { } else if (dp instanceof ELNConnector) { ELNConnector connector = (ELNConnector) dp; - TGConnectingPoint connectingPoint1 = connector.get_p1(); - TGConnectingPoint connectingPoint2 = connector.get_p2(); - String name = connector.getValue(); - + + ELNConnectingPoint connectingPoint1 = (ELNConnectingPoint) connector.get_p1(); + ELNConnectingPoint connectingPoint2 = (ELNConnectingPoint) connector.get_p2(); + + String p1Name = connectingPoint1.getName(); + String p2Name = connectingPoint2.getName(); + TGComponent owner_p1 = elnDiagramPanel.getComponentToWhichBelongs(connectingPoint1); TGComponent owner_p2 = elnDiagramPanel.getComponentToWhichBelongs(connectingPoint2); ELNTComponent avowner_p1 = elnMap.get(owner_p1); ELNTComponent avowner_p2 = elnMap.get(owner_p2); - ELNTConnectingPoint avConnectingPoint1 = new ELNTConnectingPoint(avowner_p1); - ELNTConnectingPoint avConnectingPoint2 = new ELNTConnectingPoint(avowner_p2); + ELNTConnectingPoint avConnectingPoint1 = new ELNTConnectingPoint(avowner_p1, p1Name); + ELNTConnectingPoint avConnectingPoint2 = new ELNTConnectingPoint(avowner_p2, p2Name); ELNTConnector avconnector = new ELNTConnector(avConnectingPoint1, avConnectingPoint2, name); diff --git a/src/main/java/ui/SysCAMSPanelTranslator.java b/src/main/java/ui/SysCAMSPanelTranslator.java index ef4ea91df3a183c75a680488199c495aa9658187..348cff831757158fb81457092c4c1c4d4d86d744 100644 --- a/src/main/java/ui/SysCAMSPanelTranslator.java +++ b/src/main/java/ui/SysCAMSPanelTranslator.java @@ -261,6 +261,8 @@ public class SysCAMSPanelTranslator { TGConnectingPoint connectingPoint1 = connector.get_p1(); TGConnectingPoint connectingPoint2 = connector.get_p2(); + + String name = connector.getValue(); TGComponent owner_p1 = syscamsDiagramPanel.getComponentToWhichBelongs(connectingPoint1); TGComponent owner_p2 = syscamsDiagramPanel.getComponentToWhichBelongs(connectingPoint2); @@ -271,7 +273,7 @@ public class SysCAMSPanelTranslator { SysCAMSTConnectingPoint avConnectingPoint1 = new SysCAMSTConnectingPoint(avowner_p1); SysCAMSTConnectingPoint avConnectingPoint2 = new SysCAMSTConnectingPoint(avowner_p2); - SysCAMSTConnector avconnector = new SysCAMSTConnector(avConnectingPoint1, avConnectingPoint2); + SysCAMSTConnector avconnector = new SysCAMSTConnector(avConnectingPoint1, avConnectingPoint2, name); syscamsConnectors.add(avconnector); } } diff --git a/src/main/java/ui/TDiagramPanel.java b/src/main/java/ui/TDiagramPanel.java index f21ffc3db29a4d5ceabf6cb47438c7c966771273..e7dcebff6a8877decd4601b6e6d80bc438abdc7e 100755 --- a/src/main/java/ui/TDiagramPanel.java +++ b/src/main/java/ui/TDiagramPanel.java @@ -2632,6 +2632,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { || (o instanceof SysCAMSBlockTDF && this.checkSysCAMSBlockTDFComponent((SysCAMSBlockTDF) o, name)) || (o instanceof SysCAMSBlockDE && this.checkSysCAMSBlockDEComponent((SysCAMSBlockDE) o, name)) || (o instanceof SysCAMSCompositeComponent && this.checkSysCAMSCompositeComponent((SysCAMSCompositeComponent) o, name)) + || (o instanceof ELNCluster && this.checkELNCluster((ELNCluster) o, name)) || (o instanceof ELNModule && this.checkELNModule((ELNModule) o, name)) || (o instanceof ELNComponentNodeRef && this.checkELNComponentNodeRef((ELNComponentNodeRef) o, name)) || (o instanceof ELNComponentResistor && this.checkELNComponentResistor((ELNComponentResistor) o, name)) @@ -2710,6 +2711,10 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { return false; } + public boolean checkELNCluster(ELNCluster o, String name) { + return false; + } + public boolean checkELNModule(ELNModule o, String name) { return false; } @@ -2921,9 +2926,6 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { public String findELNComponentName(String name) { return this.findGoodName(name, new NameChecker() { - public boolean checkELNModule(ELNModule o, String name) { - return o.getValue().equals(name); - } public boolean checkELNComponentNodeRef(ELNComponentNodeRef o, String name) { return o.getValue().equals(name); } @@ -2966,6 +2968,22 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { public boolean checkELNComponentVoltageSourceTDF(ELNComponentVoltageSourceTDF o, String name) { return o.getValue().equals(name); } + public boolean checkELNModule(ELNModule o, String name) { + if (o.getValue().equals(name)) + return true; + for (int i = 0; i < o.getNbInternalTGComponent(); i++) + if (this.isNameAlreadyTaken(o.getInternalTGComponent(i), name)) + return true; + return false; + } + public boolean checkELNCluster(ELNCluster o, String name) { + if (o.getValue().equals(name)) + return true; + for (int i = 0; i < o.getNbInternalTGComponent(); i++) + if (this.isNameAlreadyTaken(o.getInternalTGComponent(i), name)) + return true; + return false; + } }); } diff --git a/src/main/java/ui/TGComponentManager.java b/src/main/java/ui/TGComponentManager.java index 8d2d1a50c33e829c81af0e0ac3b356c27f423745..d16ae06888ef96ffb9e6abf300b694d801bf8539 100644 --- a/src/main/java/ui/TGComponentManager.java +++ b/src/main/java/ui/TGComponentManager.java @@ -364,6 +364,7 @@ public class TGComponentManager { public static final int ELN_MODULE_TERMINAL = 1624; public static final int ELN_TDF_VOLTAGE_SOURCE = 1625; public static final int ELN_TDF_CURRENT_SOURCE = 1626; + public static final int ELN_CLUSTER = 1627; // SMD diagram public static final int PROSMD_START_STATE = 2000; @@ -1339,6 +1340,9 @@ public class TGComponentManager { case ELN_TDF_CURRENT_SOURCE: tgc = new ELNComponentCurrentSourceTDF(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; + case ELN_CLUSTER: + tgc = new ELNCluster(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; // Communication patterns + SD case TMLCP_CHOICE: tgc = new TMLCPChoice(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); @@ -1775,6 +1779,8 @@ public class TGComponentManager { return ELN_TDF_VOLTAGE_SOURCE; } else if (tgc instanceof ELNComponentCurrentSourceTDF) { return ELN_TDF_CURRENT_SOURCE; + } else if (tgc instanceof ELNCluster) { + return ELN_CLUSTER; // Others } else if (tgc instanceof TADDeterministicDelay) { diff --git a/src/main/java/ui/TGUIAction.java b/src/main/java/ui/TGUIAction.java index f554a7f5aa4bd64301a1ec03447c15cb1cf482cd..6ec0575134c1dc742a55375fdb720c41b76f2fa2 100644 --- a/src/main/java/ui/TGUIAction.java +++ b/src/main/java/ui/TGUIAction.java @@ -306,6 +306,7 @@ public class TGUIAction extends AbstractAction { public static final int ELN_TOGGLE_ATTR = 501; public static final int ELN_TDF_VOLTAGE_SOURCE = 502; public static final int ELN_TDF_CURRENT_SOURCE = 503; + public static final int ELN_CLUSTER = 504; public static final int EBRDD_EDIT = 271; public static final int EBRDD_CONNECTOR = 272; @@ -661,7 +662,7 @@ public class TGUIAction extends AbstractAction { public static final int MOVE_ENABLED = 463; public static final int FIRST_DIAGRAM = 464; - public static final int NB_ACTION = 504; + public static final int NB_ACTION = 505; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -1187,7 +1188,8 @@ public class TGUIAction extends AbstractAction { actions[ELN_TOGGLE_ATTR] = new TAction("eln-toggle-attr-command", "Show / hide attributes in ELN", IconManager.imgic138, IconManager.imgic138, "Show / hide element attributes in ELN", "Show / hide attributes to the currently opened ELN Diagram", 0); actions[ELN_TDF_VOLTAGE_SOURCE] = new TAction("eln-tdf-vsource", "Add a voltage source driven by a TDF input signal", IconManager.imgic8033, IconManager.imgic8033, "Voltage source driven by a TDF input signal", "Add a voltage source driven by a TDF input signal to the currently opened ELN Diagram", 0); actions[ELN_TDF_CURRENT_SOURCE] = new TAction("eln-tdf-isource", "Add a current source driven by a TDF input signal", IconManager.imgic8034, IconManager.imgic8034, "Current source driven by a TDF input signal", "Add a current source driven by a TDF input signal to the currently opened ELN Diagram", 0); - + actions[ELN_CLUSTER] = new TAction("eln-cluster", "Add a cluster", IconManager.imgic8006, IconManager.imgic8006, "Cluster", "Add a cluster to the currently opened ELN Diagram", 0); + //ProActive State Machine Diagram actions[PROSMD_EDIT] = new TAction("edit-prosmd-diagram", "Edit ProActive state machine diagram", IconManager.imgic100, IconManager.imgic101, "Edit ProActive state machine diagram", "Make it possible to edit the currently opened ProActive state machine diagram", 0); actions[PROSMD_START] = new TAction("add-prosmd-start", "Add Start state", IconManager.imgic222, IconManager.imgic222, "Start", "Add a start state to the currently opened ProActive state machine diagram", 0); diff --git a/src/main/java/ui/avatardd/ADDClusterNode.java b/src/main/java/ui/avatardd/ADDClusterNode.java index d0f3a64b4fc5bfdb49591763c4e05d3f79624f7d..f73bc4b2b7581fbb095792c977d061c470c72fcf 100644 --- a/src/main/java/ui/avatardd/ADDClusterNode.java +++ b/src/main/java/ui/avatardd/ADDClusterNode.java @@ -43,6 +43,7 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import ui.*; import ui.syscams.SysCAMSComponentTaskDiagramPanel; +import ui.syscams.SysCAMSCompositeComponent; import ui.util.IconManager; import javax.swing.*; @@ -63,8 +64,8 @@ public class ADDClusterNode extends ADDNode implements WithAttributes { private int derivationx = 2; private int derivationy = 3; private String stereotype = "SystemC-AMS Cluster"; - private int currentFontSize = -1; - private int textX = 15; // border for ports + + private SysCAMSCompositeComponent cluster; private int index = 0; @@ -201,6 +202,7 @@ public class ADDClusterNode extends ADDNode implements WithAttributes { SysCAMSComponentTaskDiagramPanel tdp = mgui.getListSysCAMSPanel().get(i); if (tdp.getCompositeComponent().getValue().equals(getName())) { mgui.selectTab(tdp); + setCluster(tdp.getCompositeComponent()); return true; } } @@ -273,4 +275,12 @@ public class ADDClusterNode extends ADDNode implements WithAttributes { attr += "index = " + index + "\n"; return attr; } + + public SysCAMSCompositeComponent getCluster() { + return cluster; + } + + public void setCluster(SysCAMSCompositeComponent cluster) { + this.cluster = cluster; + } } diff --git a/src/main/java/ui/eln/ELNCluster.java b/src/main/java/ui/eln/ELNCluster.java new file mode 100644 index 0000000000000000000000000000000000000000..89294a742349cc508ff2cf252e355c421c328135 --- /dev/null +++ b/src/main/java/ui/eln/ELNCluster.java @@ -0,0 +1,318 @@ +/* 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.eln; + +import myutil.GraphicLib; +import ui.*; +import ui.syscams.*; +import ui.util.IconManager; +import java.awt.*; +import java.util.*; +import javax.swing.*; + +/** + * Class ELNCluster + * Cluster to be used in ELN diagrams + * Creation: 28/07/2018 + * @version 1.0 28/07/2018 + * @author Irina Kit Yan LEE + */ + +public class ELNCluster extends TGCScalableWithInternalComponent implements SwallowTGComponent { + private int maxFontSize = 14; + private int minFontSize = 4; + private int currentFontSize = -1; + protected int orientation; + private Color myColor; + + private int textX = 15; + private double dtextX = 0.0; + protected int decPoint = 3; + + public String oldValue; + + public ELNCluster(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(400, 400); + + oldScaleFactor = tdp.getZoom(); + dtextX = textX * oldScaleFactor; + textX = (int)dtextX; + dtextX = dtextX - textX; + + minWidth = 1; + minHeight = 1; + + addTGConnectingPointsComment(); + + moveable = true; + multieditable = true; + editable = false; + removable = true; + userResizable = true; + + value = tdp.findELNComponentName("Cluster"); + } + + public void internalDrawing(Graphics g) { + int w; + Font f = g.getFont(); + Font fold = f; + MainGUI mgui = getTDiagramPanel().getMainGUI(); + + if (myColor == null) { + myColor = Color.white; + } + + if (this.rescaled && !this.tdp.isScaled()) { + this.rescaled = false; + int maxCurrentFontSize = Math.max(0, Math.min(this.height, (int) (this.maxFontSize * this.tdp.getZoom()))); + f = f.deriveFont((float) maxCurrentFontSize); + + while (maxCurrentFontSize > (this.minFontSize * this.tdp.getZoom() - 1)) { + if (g.getFontMetrics().stringWidth(value) < (width - (2 * textX))) { + break; + } + maxCurrentFontSize--; + f = f.deriveFont((float) maxCurrentFontSize); + } + + if (this.currentFontSize < this.minFontSize * this.tdp.getZoom()) { + maxCurrentFontSize++; + f = f.deriveFont((float) maxCurrentFontSize); + } + g.setFont(f); + this.currentFontSize = maxCurrentFontSize; + } else { + f = f.deriveFont(this.currentFontSize); + } + + 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); + } + + int attributeFontSize = this.currentFontSize * 5 / 6; + g.setFont(f.deriveFont((float) attributeFontSize)); + g.setFont(f); + w = g.getFontMetrics().stringWidth(value); + if (w > (width - 2 * textX)) { + g.setFont(f.deriveFont(Font.BOLD)); + if (mgui.getHidden() == false) { + g.drawString(value, x + textX + 1, y + currentFontSize + textX); + } + } else { + g.setFont(f.deriveFont(Font.BOLD)); + if (mgui.getHidden() == false) { + g.drawString(value, x + (width - w)/2, y + currentFontSize + textX); + } + } + + 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 (_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)) { + 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; + } + setComponentName(s); + setValueWithChange(s); + setValue(s); + rescaled = true; + return true; + + } + return false; + } + return false; + } + + public int getType() { + return TGComponentManager.ELN_CLUSTER; + } + + public boolean acceptSwallowedTGComponent(TGComponent tgc) { + if (tgc instanceof ELNModule) { + return true; + } else if (tgc instanceof SysCAMSPortDE) { + return true; + } else if (tgc instanceof SysCAMSPortTDF) { + return true; + } + return false; + } + + 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; + } + tgc.setFather(this); + tgc.setDrawingZone(true); + + if (tgc instanceof ELNModule) { + tgc.resizeWithFather(); + } + if (tgc instanceof SysCAMSPortDE) { + tgc.resizeWithFather(); + } + if (tgc instanceof SysCAMSPortTDF) { + tgc.resizeWithFather(); + } + addInternalComponent(tgc, 0); + return true; + } + + public void removeSwallowedTGComponent(TGComponent tgc) { + 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 ELNModule) { + tgcomponent[i].resizeWithFather(); + } + if (tgcomponent[i] instanceof SysCAMSPortDE) { + tgcomponent[i].resizeWithFather(); + } + if (tgcomponent[i] instanceof SysCAMSPortTDF) { + tgcomponent[i].resizeWithFather(); + } + } + } + + public int getCurrentFontSize() { + return currentFontSize; + } + + public java.util.List<ELNModule> getAllModule() { + java.util.List<ELNModule> list = new ArrayList<ELNModule>(); + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof ELNModule) { + list.add((ELNModule)(tgcomponent[i])); + } + } + return list; + } + + public java.util.List<SysCAMSPortDE> getAllPortDE() { + java.util.List<SysCAMSPortDE> list = new ArrayList<SysCAMSPortDE>(); + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSPortDE) { + list.add((SysCAMSPortDE)(tgcomponent[i])); + } + } + return list; + } + + public java.util.List<SysCAMSPortTDF> getAllPortTDF() { + java.util.List<SysCAMSPortTDF> list = new ArrayList<SysCAMSPortTDF>(); + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof SysCAMSPortTDF) { + list.add((SysCAMSPortTDF)(tgcomponent[i])); + } + } + return list; + } +} \ No newline at end of file diff --git a/src/main/java/ui/eln/ELNDiagramToolBar.java b/src/main/java/ui/eln/ELNDiagramToolBar.java index 6494124d74dbaaa15c8c9555d389d441963e9f15..466a7147ff2d8d2add97df817b504fd15b1dcf0c 100644 --- a/src/main/java/ui/eln/ELNDiagramToolBar.java +++ b/src/main/java/ui/eln/ELNDiagramToolBar.java @@ -85,6 +85,9 @@ public class ELNDiagramToolBar extends TToolBar { mgui.actions[TGUIAction.ELN_TDF_VOLTAGE_SOURCE].setEnabled(b); mgui.actions[TGUIAction.ELN_TDF_CURRENT_SOURCE].setEnabled(b); mgui.actions[TGUIAction.ELN_CONNECTOR].setEnabled(b); + mgui.actions[TGUIAction.ELN_CLUSTER].setEnabled(b); + mgui.actions[TGUIAction.CAMS_PORT_DE].setEnabled(b); + mgui.actions[TGUIAction.CAMS_PORT_TDF].setEnabled(b); mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b); mgui.actions[TGUIAction.ACT_ONECLICK_LOTOS_RG].setEnabled(b); @@ -110,6 +113,17 @@ public class ELNDiagramToolBar extends TToolBar { this.addSeparator(); + button = this.add(mgui.actions[TGUIAction.ELN_CLUSTER]); + button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.CAMS_PORT_DE]); + 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.ELN_MODULE]); button.addMouseListener(mgui.mouseHandler); diff --git a/src/main/java/ui/eln/ELNModule.java b/src/main/java/ui/eln/ELNModule.java index 08f9c1895b3fb8a35a72170ce042fc5dd0491c15..dc7c22550daa59261b0b144714f3f2b761ed969b 100644 --- a/src/main/java/ui/eln/ELNModule.java +++ b/src/main/java/ui/eln/ELNModule.java @@ -42,6 +42,7 @@ import myutil.GraphicLib; import ui.*; import ui.eln.sca_eln.*; import ui.eln.sca_eln_sca_tdf.*; +import ui.syscams.*; import ui.util.IconManager; import ui.window.*; import java.awt.*; @@ -56,7 +57,7 @@ import javax.swing.*; * @author Irina Kit Yan LEE */ -public class ELNModule extends TGCScalableWithInternalComponent implements SwallowTGComponent { +public class ELNModule extends TGCScalableWithInternalComponent implements SwallowTGComponent, SwallowedTGComponent { private int maxFontSize = 14; private int minFontSize = 4; private int currentFontSize = -1; @@ -72,7 +73,7 @@ public class ELNModule extends TGCScalableWithInternalComponent implements Swall public ELNModule(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); + initScaling(300, 300); oldScaleFactor = tdp.getZoom(); dtextX = textX * oldScaleFactor; @@ -90,7 +91,7 @@ public class ELNModule extends TGCScalableWithInternalComponent implements Swall removable = true; userResizable = true; - value = tdp.findELNComponentName("Module_"); + value = tdp.findELNComponentName("Module"); } public void internalDrawing(Graphics g) { @@ -100,7 +101,7 @@ public class ELNModule extends TGCScalableWithInternalComponent implements Swall MainGUI mgui = getTDiagramPanel().getMainGUI(); if (myColor == null) { - myColor = Color.white; + myColor = Color.lightGray; } if (this.rescaled && !this.tdp.isScaled()) { @@ -204,7 +205,43 @@ public class ELNModule extends TGCScalableWithInternalComponent implements Swall } public boolean acceptSwallowedTGComponent(TGComponent tgc) { - if (tgc instanceof ELNComponent) { + if (tgc instanceof ELNComponentCapacitor) { + return true; + } + if (tgc instanceof ELNComponentIdealTransformer) { + return true; + } + if (tgc instanceof ELNComponentIndependentCurrentSource) { + return true; + } + if (tgc instanceof ELNComponentIndependentVoltageSource) { + return true; + } + if (tgc instanceof ELNComponentInductor) { + return true; + } + if (tgc instanceof ELNComponentResistor) { + return true; + } + if (tgc instanceof ELNComponentTransmissionLine) { + return true; + } + if (tgc instanceof ELNComponentVoltageControlledCurrentSource) { + return true; + } + if (tgc instanceof ELNComponentVoltageControlledVoltageSource) { + return true; + } + if (tgc instanceof ELNComponentCurrentSinkTDF) { + return true; + } + if (tgc instanceof ELNComponentCurrentSourceTDF) { + return true; + } + if (tgc instanceof ELNComponentVoltageSinkTDF) { + return true; + } + if (tgc instanceof ELNComponentVoltageSourceTDF) { return true; } if (tgc instanceof ELNComponentNodeRef) { @@ -213,11 +250,101 @@ public class ELNModule extends TGCScalableWithInternalComponent implements Swall if (tgc instanceof ELNModuleTerminal) { return true; } + if (tgc instanceof SysCAMSPortDE) { + return true; + } + if (tgc instanceof SysCAMSPortTDF) { + return true; + } return false; } public boolean addSwallowedTGComponent(TGComponent tgc, int x, int y) { - if (tgc instanceof ELNComponent) { + if (tgc instanceof ELNComponentCapacitor) { + tgc.setFather(this); + tgc.setDrawingZone(true); + tgc.resizeWithFather(); + addInternalComponent(tgc, 0); + return true; + } + if (tgc instanceof ELNComponentIdealTransformer) { + tgc.setFather(this); + tgc.setDrawingZone(true); + tgc.resizeWithFather(); + addInternalComponent(tgc, 0); + return true; + } + if (tgc instanceof ELNComponentIndependentCurrentSource) { + tgc.setFather(this); + tgc.setDrawingZone(true); + tgc.resizeWithFather(); + addInternalComponent(tgc, 0); + return true; + } + if (tgc instanceof ELNComponentIndependentVoltageSource) { + tgc.setFather(this); + tgc.setDrawingZone(true); + tgc.resizeWithFather(); + addInternalComponent(tgc, 0); + return true; + } + if (tgc instanceof ELNComponentInductor) { + tgc.setFather(this); + tgc.setDrawingZone(true); + tgc.resizeWithFather(); + addInternalComponent(tgc, 0); + return true; + } + if (tgc instanceof ELNComponentResistor) { + tgc.setFather(this); + tgc.setDrawingZone(true); + tgc.resizeWithFather(); + addInternalComponent(tgc, 0); + return true; + } + if (tgc instanceof ELNComponentTransmissionLine) { + tgc.setFather(this); + tgc.setDrawingZone(true); + tgc.resizeWithFather(); + addInternalComponent(tgc, 0); + return true; + } + if (tgc instanceof ELNComponentVoltageControlledCurrentSource) { + tgc.setFather(this); + tgc.setDrawingZone(true); + tgc.resizeWithFather(); + addInternalComponent(tgc, 0); + return true; + } + if (tgc instanceof ELNComponentVoltageControlledVoltageSource) { + tgc.setFather(this); + tgc.setDrawingZone(true); + tgc.resizeWithFather(); + addInternalComponent(tgc, 0); + return true; + } + if (tgc instanceof ELNComponentCurrentSinkTDF) { + tgc.setFather(this); + tgc.setDrawingZone(true); + tgc.resizeWithFather(); + addInternalComponent(tgc, 0); + return true; + } + if (tgc instanceof ELNComponentCurrentSourceTDF) { + tgc.setFather(this); + tgc.setDrawingZone(true); + tgc.resizeWithFather(); + addInternalComponent(tgc, 0); + return true; + } + if (tgc instanceof ELNComponentVoltageSinkTDF) { + tgc.setFather(this); + tgc.setDrawingZone(true); + tgc.resizeWithFather(); + addInternalComponent(tgc, 0); + return true; + } + if (tgc instanceof ELNComponentVoltageSourceTDF) { tgc.setFather(this); tgc.setDrawingZone(true); tgc.resizeWithFather(); @@ -238,6 +365,20 @@ public class ELNModule extends TGCScalableWithInternalComponent implements Swall addInternalComponent(tgc, 0); return true; } + if (tgc instanceof SysCAMSPortDE) { + tgc.setFather(this); + tgc.setDrawingZone(true); + tgc.resizeWithFather(); + addInternalComponent(tgc, 0); + return true; + } + if (tgc instanceof SysCAMSPortTDF) { + tgc.setFather(this); + tgc.setDrawingZone(true); + tgc.resizeWithFather(); + addInternalComponent(tgc, 0); + return true; + } return false; } @@ -248,7 +389,43 @@ public class ELNModule extends TGCScalableWithInternalComponent implements Swall public void hasBeenResized() { rescaled = true; for(int i=0; i<nbInternalTGComponent; i++) { - if (tgcomponent[i] instanceof ELNComponent) { + if (tgcomponent[i] instanceof ELNComponentCapacitor) { + tgcomponent[i].resizeWithFather(); + } + if (tgcomponent[i] instanceof ELNComponentIdealTransformer) { + tgcomponent[i].resizeWithFather(); + } + if (tgcomponent[i] instanceof ELNComponentIndependentCurrentSource) { + tgcomponent[i].resizeWithFather(); + } + if (tgcomponent[i] instanceof ELNComponentIndependentVoltageSource) { + tgcomponent[i].resizeWithFather(); + } + if (tgcomponent[i] instanceof ELNComponentInductor) { + tgcomponent[i].resizeWithFather(); + } + if (tgcomponent[i] instanceof ELNComponentResistor) { + tgcomponent[i].resizeWithFather(); + } + if (tgcomponent[i] instanceof ELNComponentTransmissionLine) { + tgcomponent[i].resizeWithFather(); + } + if (tgcomponent[i] instanceof ELNComponentVoltageControlledCurrentSource) { + tgcomponent[i].resizeWithFather(); + } + if (tgcomponent[i] instanceof ELNComponentVoltageControlledVoltageSource) { + tgcomponent[i].resizeWithFather(); + } + if (tgcomponent[i] instanceof ELNComponentCurrentSinkTDF) { + tgcomponent[i].resizeWithFather(); + } + if (tgcomponent[i] instanceof ELNComponentCurrentSourceTDF) { + tgcomponent[i].resizeWithFather(); + } + if (tgcomponent[i] instanceof ELNComponentVoltageSinkTDF) { + tgcomponent[i].resizeWithFather(); + } + if (tgcomponent[i] instanceof ELNComponentVoltageSourceTDF) { tgcomponent[i].resizeWithFather(); } if (tgcomponent[i] instanceof ELNComponentNodeRef) { @@ -257,6 +434,35 @@ public class ELNModule extends TGCScalableWithInternalComponent implements Swall if (tgcomponent[i] instanceof ELNModuleTerminal) { tgcomponent[i].resizeWithFather(); } + if (tgcomponent[i] instanceof SysCAMSPortDE) { + tgcomponent[i].resizeWithFather(); + } + if (tgcomponent[i] instanceof SysCAMSPortTDF) { + tgcomponent[i].resizeWithFather(); + } + } + if (getFather() != null) { + resizeWithFather(); + } + } + + 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 ELNCluster)) { + resizeToFatherSize(); + + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); + setMoveCd(x, y); } } diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentCapacitor.java b/src/main/java/ui/eln/sca_eln/ELNComponentCapacitor.java index 641b3b0a09720a8d8209e910366b269aa1163d75..9429e0f1b8dfc0fba2cad937282ee5721747e52b 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentCapacitor.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentCapacitor.java @@ -156,6 +156,7 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl old = width; width = height; height = old; + resizeWithFather(); } rotateTopBottom(g); @@ -238,6 +239,7 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl old = width; width = height; height = old; + resizeWithFather(); } rotateRightLeft(g); @@ -314,6 +316,7 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl old = width; width = height; height = old; + resizeWithFather(); } rotateTopBottom(g); @@ -396,6 +399,7 @@ public class ELNComponentCapacitor extends TGCScalableWithInternalComponent impl old = width; width = height; height = old; + resizeWithFather(); } rotateRightLeft(g); diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentIdealTransformer.java b/src/main/java/ui/eln/sca_eln/ELNComponentIdealTransformer.java index f33d289222175de0e731c0c22798716ca27a21f3..2934a908c2b62b84af273784f150068a4ba235ec 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentIdealTransformer.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentIdealTransformer.java @@ -155,6 +155,7 @@ public class ELNComponentIdealTransformer extends TGCScalableWithInternalCompone old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -267,6 +268,7 @@ public class ELNComponentIdealTransformer extends TGCScalableWithInternalCompone old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -379,6 +381,7 @@ public class ELNComponentIdealTransformer extends TGCScalableWithInternalCompone old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -491,6 +494,7 @@ public class ELNComponentIdealTransformer extends TGCScalableWithInternalCompone old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentIndependentCurrentSource.java b/src/main/java/ui/eln/sca_eln/ELNComponentIndependentCurrentSource.java index 59965eb0b56291f5a04bf7d9e3702c381126b361..76c95f747b8a0026c526c47055f6fa46c67aa5ad 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentIndependentCurrentSource.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentIndependentCurrentSource.java @@ -163,6 +163,7 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -241,6 +242,7 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -325,6 +327,7 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -403,6 +406,7 @@ public class ELNComponentIndependentCurrentSource extends TGCScalableWithInterna old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentIndependentVoltageSource.java b/src/main/java/ui/eln/sca_eln/ELNComponentIndependentVoltageSource.java index bf75e2fb38688d2e261219166edccf5b0b45ab9f..f211f3ee04619e3be7afa1938f6109cd251ed02e 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentIndependentVoltageSource.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentIndependentVoltageSource.java @@ -163,6 +163,7 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -241,6 +242,7 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -325,6 +327,7 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -403,6 +406,7 @@ public class ELNComponentIndependentVoltageSource extends TGCScalableWithInterna old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentInductor.java b/src/main/java/ui/eln/sca_eln/ELNComponentInductor.java index 1b45f4c8bf1fff7fce5b9b6346674a7be8f81fc9..ad95dcbd85f4f717343ecd2d04c79e0afffee07d 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentInductor.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentInductor.java @@ -157,6 +157,7 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -241,6 +242,7 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -319,6 +321,7 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -403,6 +406,7 @@ public class ELNComponentInductor extends TGCScalableWithInternalComponent imple old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentNodeRef.java b/src/main/java/ui/eln/sca_eln/ELNComponentNodeRef.java index 95d0b86b798ef2e746dc8eb085dd07680e8d5e0e..64ecee13b321917c6e3032ca2ed6345de329d97e 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentNodeRef.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentNodeRef.java @@ -148,6 +148,7 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -195,6 +196,7 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -243,6 +245,7 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -291,6 +294,7 @@ public class ELNComponentNodeRef extends TGCScalableWithInternalComponent implem old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentResistor.java b/src/main/java/ui/eln/sca_eln/ELNComponentResistor.java index 8efcb5bf946c2f2db10ead5ce58e94525a5be887..6ea92b14d86cc27a1ef78256c89c116b1be471bc 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentResistor.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentResistor.java @@ -154,6 +154,7 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple old = width; width = height; height = old; + resizeWithFather(); } rotateTopBottom(g); @@ -236,6 +237,7 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple old = width; width = height; height = old; + resizeWithFather(); } rotateRightLeft(g); @@ -313,6 +315,7 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple old = width; width = height; height = old; + resizeWithFather(); } rotateTopBottom(g); @@ -395,6 +398,7 @@ public class ELNComponentResistor extends TGCScalableWithInternalComponent imple old = width; width = height; height = old; + resizeWithFather(); } rotateRightLeft(g); diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentTransmissionLine.java b/src/main/java/ui/eln/sca_eln/ELNComponentTransmissionLine.java index 133d724f9e51984dfd853efd2dc0eb7d3d0802fd..a079fe145eb5b1529c612e80bd4172d8c8ad8305 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentTransmissionLine.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentTransmissionLine.java @@ -161,6 +161,7 @@ public class ELNComponentTransmissionLine extends TGCScalableWithInternalCompone old = width; width = height; height = old; + resizeWithFather(); } rotateTopBottom(g); @@ -271,6 +272,7 @@ public class ELNComponentTransmissionLine extends TGCScalableWithInternalCompone old = width; width = height; height = old; + resizeWithFather(); } rotateRightLeft(g); @@ -381,6 +383,7 @@ public class ELNComponentTransmissionLine extends TGCScalableWithInternalCompone old = width; width = height; height = old; + resizeWithFather(); } rotateTopBottom(g); @@ -491,6 +494,7 @@ public class ELNComponentTransmissionLine extends TGCScalableWithInternalCompone old = width; width = height; height = old; + resizeWithFather(); } rotateRightLeft(g); diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledCurrentSource.java b/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledCurrentSource.java index 41c26fc60596f890b07d1f026c7e5974944fd62e..499e97ba6ac4ac2e376fa049bcf6b8fbc0a7c091 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledCurrentSource.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledCurrentSource.java @@ -157,6 +157,7 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -269,6 +270,7 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -381,6 +383,7 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -493,6 +496,7 @@ public class ELNComponentVoltageControlledCurrentSource extends TGCScalableWithI old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; diff --git a/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledVoltageSource.java b/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledVoltageSource.java index faf41fe67e315f5df08f42af010db7d6c98f5269..7204be924b0f9dec740f00f9cefa0c6dcdb0ad5a 100644 --- a/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledVoltageSource.java +++ b/src/main/java/ui/eln/sca_eln/ELNComponentVoltageControlledVoltageSource.java @@ -155,6 +155,7 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -267,6 +268,7 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -379,6 +381,7 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -491,6 +494,7 @@ public class ELNComponentVoltageControlledVoltageSource extends TGCScalableWithI old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; diff --git a/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentCurrentSinkTDF.java b/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentCurrentSinkTDF.java index e566d185ece415eed6d127b69155ff66a5cc59db..65b6ae4b57331bb0be97d3adc1726f9da3c36585 100644 --- a/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentCurrentSinkTDF.java +++ b/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentCurrentSinkTDF.java @@ -154,6 +154,7 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -252,6 +253,7 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -347,6 +349,7 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -445,6 +448,7 @@ public class ELNComponentCurrentSinkTDF extends TGCScalableWithInternalComponent old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; diff --git a/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentCurrentSourceTDF.java b/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentCurrentSourceTDF.java index 8e17ecc461f16aaa6b62b41e7c3668ffbec24125..8279eeefc90925b8a536ad6b22a8ca922d012847 100644 --- a/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentCurrentSourceTDF.java +++ b/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentCurrentSourceTDF.java @@ -155,6 +155,7 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -253,6 +254,7 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -348,6 +350,7 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -446,6 +449,7 @@ public class ELNComponentCurrentSourceTDF extends TGCScalableWithInternalCompone old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; diff --git a/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentVoltageSinkTDF.java b/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentVoltageSinkTDF.java index a44f8b982b0ead4d196a17f82e639b1e6f78b5cb..5868c2fab8269ba89fce0f8767c5d0dba4be3289 100644 --- a/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentVoltageSinkTDF.java +++ b/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentVoltageSinkTDF.java @@ -155,6 +155,7 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -253,6 +254,7 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -348,6 +350,7 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -446,6 +449,7 @@ public class ELNComponentVoltageSinkTDF extends TGCScalableWithInternalComponent old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; diff --git a/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentVoltageSourceTDF.java b/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentVoltageSourceTDF.java index 080c27f897dea9df94fc7aa7cd050ff20406356a..9a8fa2733bc0861affe318b4cf57e1406169fa65 100644 --- a/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentVoltageSourceTDF.java +++ b/src/main/java/ui/eln/sca_eln_sca_tdf/ELNComponentVoltageSourceTDF.java @@ -155,6 +155,7 @@ public class ELNComponentVoltageSourceTDF extends TGCScalableWithInternalCompone old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -253,6 +254,7 @@ public class ELNComponentVoltageSourceTDF extends TGCScalableWithInternalCompone old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -348,6 +350,7 @@ public class ELNComponentVoltageSourceTDF extends TGCScalableWithInternalCompone old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; @@ -446,6 +449,7 @@ public class ELNComponentVoltageSourceTDF extends TGCScalableWithInternalCompone old = width; width = height; height = old; + resizeWithFather(); } int attributeFontSize = this.currentFontSize * 5 / 6; diff --git a/src/main/java/ui/syscams/SysCAMSCompositeComponent.java b/src/main/java/ui/syscams/SysCAMSCompositeComponent.java index a260d627c7bf013983e10f9c6271115af79f2d31..b4715c23be17b14934c853c5863e53c085eb266d 100644 --- a/src/main/java/ui/syscams/SysCAMSCompositeComponent.java +++ b/src/main/java/ui/syscams/SysCAMSCompositeComponent.java @@ -197,17 +197,6 @@ public class SysCAMSCompositeComponent extends TGCScalableWithInternalComponent 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 addSwallowedTGComponent(TGComponent tgc, int x, int y) { boolean swallowed = false; @@ -418,11 +407,10 @@ public class SysCAMSCompositeComponent extends TGCScalableWithInternalComponent public boolean acceptSwallowedTGComponent(TGComponent tgc) { if (tgc instanceof SysCAMSBlockTDF) { - return tgc instanceof SysCAMSBlockTDF; + return true; } else if (tgc instanceof SysCAMSBlockDE) { - return tgc instanceof SysCAMSBlockDE; - } else { return true; } + return false; } } \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSPortConnector.java b/src/main/java/ui/syscams/SysCAMSPortConnector.java index b57a640757e437934c0dbf88b1f1b78c11f701d7..4749eda5da4460fdb2371cad12ea80661a8af7b1 100644 --- a/src/main/java/ui/syscams/SysCAMSPortConnector.java +++ b/src/main/java/ui/syscams/SysCAMSPortConnector.java @@ -40,13 +40,13 @@ package ui.syscams; import ui.*; import ui.util.IconManager; +import ui.window.JDialogELNConnector; +import ui.window.JDialogSysCAMSConnector; import java.awt.*; -import java.awt.geom.Point2D; import java.util.Vector; -import javax.swing.JDialog; -import javax.swing.JOptionPane; +import javax.swing.JFrame; import myutil.GraphicLib; @@ -65,8 +65,8 @@ public class SysCAMSPortConnector extends TGConnector implements ScalableTGCompo super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); myImageIcon = IconManager.imgic202; - value = "Connector between ports"; - editable = false; + value = ""; + editable = true; oldScaleFactor = tdp.getZoom(); p1 = _p1; @@ -81,8 +81,21 @@ public class SysCAMSPortConnector extends TGConnector implements ScalableTGCompo return p2; } + public boolean editOndoubleClick(JFrame frame) { + JDialogSysCAMSConnector jde = new JDialogSysCAMSConnector(this); + jde.setVisible(true); + return true; + } + protected void drawLastSegment(Graphics gr, int x1, int y1, int x2, int y2) { Graphics2D g = (Graphics2D) gr; + + int w = g.getFontMetrics().stringWidth(value); + Font fold = g.getFont(); + Font f = fold.deriveFont(Font.ITALIC, (float) (tdp.getFontSize())); + g.setFont(f); + g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2) / 2); + g.setFont(fold); try { SysCAMSPortConnectingPoint pt1 = (SysCAMSPortConnectingPoint) p1; @@ -116,6 +129,16 @@ public class SysCAMSPortConnector extends TGConnector implements ScalableTGCompo g.setStroke(dashed); GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, x2, y2, true); } + } else if ((pt1.port instanceof SysCAMSPortDE) && (pt2.port instanceof SysCAMSPortDE) + || (pt2.port instanceof SysCAMSPortDE) && (pt1.port instanceof SysCAMSPortDE)) { + if (pt1.port.getFather().getFather() instanceof SysCAMSCompositeComponent + && pt2.port.getFather().getFather() instanceof SysCAMSCompositeComponent) { + GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, x2, y2, true); + } else { + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 9 }, 0); + g.setStroke(dashed); + GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, x2, y2, true); + } } else if ((pt1.port instanceof SysCAMSPortTDF) && (pt2.port instanceof SysCAMSPortTDF) || (pt2.port instanceof SysCAMSPortTDF) && (pt1.port instanceof SysCAMSPortTDF)) { GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, x2, y2, true); diff --git a/src/main/java/ui/syscams/SysCAMSPrimitivePort.java b/src/main/java/ui/syscams/SysCAMSPrimitivePort.java index 9b5b5bffb497041d88b350ca3d5e3eb950ca7277..2bbf4d0ce3c5491af59c029bffa5aeca624470b4 100644 --- a/src/main/java/ui/syscams/SysCAMSPrimitivePort.java +++ b/src/main/java/ui/syscams/SysCAMSPrimitivePort.java @@ -44,11 +44,9 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import ui.*; +import ui.eln.*; import ui.util.IconManager; -import ui.window.JDialogSysCAMSPortConverter; -import ui.window.JDialogSysCAMSPortDE; -import ui.window.JDialogSysCAMSPortTDF; - +import ui.window.*; import javax.swing.*; import java.awt.*; @@ -362,6 +360,18 @@ public class SysCAMSPrimitivePort extends TGCScalableWithInternalComponent imple oldx = -1; oldy = -1; } + if ((father != null) && (father instanceof ELNCluster)) { + setCdRectangle(0-getWidth()/2, father.getWidth() - (getWidth()/2), 0-getHeight()/2, father.getHeight() - (getHeight()/2)); + setMoveCd(x, y); + oldx = -1; + oldy = -1; + } + if ((father != null) && (father instanceof ELNModule)) { + 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) { diff --git a/src/main/java/ui/window/JDialogSysCAMSConnector.java b/src/main/java/ui/window/JDialogSysCAMSConnector.java new file mode 100644 index 0000000000000000000000000000000000000000..d02e61a4d37e755fed1f0f99520149e98ada9ad3 --- /dev/null +++ b/src/main/java/ui/window/JDialogSysCAMSConnector.java @@ -0,0 +1,151 @@ +/* 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.SysCAMSPortConnector; +import ui.util.*; +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +/** + * Class JDialogSysCAMSConnector + * Dialog for managing of SystemC-AMS connector + * Creation: 27/07/2018 + * @version 1.0 27/07/2018 + * @author Irina Kit Yan LEE + */ + +@SuppressWarnings("serial") + +public class JDialogSysCAMSConnector extends JDialog implements ActionListener { + + private JTextField nameTextField; + + private SysCAMSPortConnector con; + + public JDialogSysCAMSConnector(SysCAMSPortConnector con) { + this.setTitle("Setting Connector Attributes"); + this.setLocationRelativeTo(null); + this.setVisible(true); + this.setAlwaysOnTop(true); + this.setResizable(false); + + this.con = con; + + getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close"); + getRootPane().getActionMap().put("close", new AbstractAction() { + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + + dialog(); + } + + public void dialog() { + JPanel mainPanel = new JPanel(new BorderLayout()); + this.add(mainPanel); + + JPanel attributesMainPanel = new JPanel(); + mainPanel.add(attributesMainPanel, BorderLayout.NORTH); + + attributesMainPanel.setLayout(new BorderLayout()); + + Box attributesBox = Box.createVerticalBox(); + attributesBox.setBorder(BorderFactory.createTitledBorder("Setting connector attributes")); + + GridBagLayout gridBag = new GridBagLayout(); + GridBagConstraints constraints = new GridBagConstraints(); + JPanel attributesBoxPanel = new JPanel(); + attributesBoxPanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); + attributesBoxPanel.setLayout(gridBag); + + JLabel labelName = new JLabel("Name : "); + constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, + new Insets(15, 10, 5, 10), 0, 0); + gridBag.setConstraints(labelName, constraints); + attributesBoxPanel.add(labelName); + + if (con.getValue().toString().equals("")) { + nameTextField = new JTextField(10); + } else { + nameTextField = new JTextField(con.getValue().toString(), 10); + } + constraints = new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, + new Insets(15, 10, 5, 10), 0, 0); + gridBag.setConstraints(nameTextField, constraints); + attributesBoxPanel.add(nameTextField); + + attributesBox.add(attributesBoxPanel); + + attributesMainPanel.add(attributesBox, BorderLayout.NORTH); + + JPanel downPanel = new JPanel(new FlowLayout()); + + JButton saveCloseButton = new JButton("Save and close"); + saveCloseButton.setIcon(IconManager.imgic25); + saveCloseButton.setActionCommand("Save_Close"); + saveCloseButton.addActionListener(this); + saveCloseButton.setPreferredSize(new Dimension(200, 30)); + downPanel.add(saveCloseButton); + + JButton cancelButton = new JButton("Cancel"); + cancelButton.setIcon(IconManager.imgic27); + cancelButton.setActionCommand("Cancel"); + cancelButton.addActionListener(this); + cancelButton.setPreferredSize(new Dimension(200, 30)); + downPanel.add(cancelButton); + + mainPanel.add(downPanel, BorderLayout.CENTER); + pack(); + this.getRootPane().setDefaultButton(saveCloseButton); + } + + public void actionPerformed(ActionEvent e) { + if ("Save_Close".equals(e.getActionCommand())) { + con.setValue(new String(nameTextField.getText())); + this.dispose(); + } + + if ("Cancel".equals(e.getActionCommand())) { + this.dispose(); + } + } +} \ No newline at end of file