From 1fccc5ac63ebafc27340defedd4a7b420ecf5254 Mon Sep 17 00:00:00 2001 From: Ludovic Apvrille <ludovic.apvrille@telecom-paristech.fr> Date: Thu, 10 Sep 2009 14:53:29 +0000 Subject: [PATCH] New EBRDD: modeling --- src/ui/GTURTLEModeling.java | 60 ++++ src/ui/IconManager.java | 35 ++- src/ui/MainGUI.java | 68 ++++- src/ui/RequirementPanel.java | 38 ++- src/ui/TGComponentManager.java | 66 +++++ src/ui/TGConnector.java | 27 +- src/ui/TGUIAction.java | 27 +- src/ui/TURTLEPanelPopupListener.java | 8 +- src/ui/ebrdd/EBRDDActionState.java | 169 ++++++++++++ src/ui/ebrdd/EBRDDChoice.java | 186 +++++++++++++ src/ui/ebrdd/EBRDDERB.java | 290 ++++++++++++++++++++ src/ui/ebrdd/EBRDDERC.java | 232 ++++++++++++++++ src/ui/ebrdd/EBRDDESO.java | 290 ++++++++++++++++++++ src/ui/ebrdd/EBRDDForLoop.java | 257 +++++++++++++++++ src/ui/ebrdd/EBRDDPanel.java | 197 +++++++++++++ src/ui/ebrdd/EBRDDSequence.java | 117 ++++++++ src/ui/ebrdd/EBRDDStartState.java | 104 +++++++ src/ui/ebrdd/EBRDDStopState.java | 109 ++++++++ src/ui/ebrdd/EBRDDToolBar.java | 147 ++++++++++ src/ui/ebrdd/TGConnectingPointEBRDD.java | 72 +++++ src/ui/ebrdd/TGConnectingPointEBRDDERC.java | 72 +++++ src/ui/ebrdd/TGConnectorEBRDD.java | 82 ++++++ src/ui/ebrdd/TGConnectorEBRDDERC.java | 148 ++++++++++ src/ui/images/ebrdderb.gif | Bin 0 -> 136 bytes src/ui/images/ebrdderc.gif | Bin 0 -> 99 bytes src/ui/images/ebrddeso.gif | Bin 0 -> 127 bytes src/ui/images/ercconnector.gif | Bin 0 -> 136 bytes src/ui/tmldd/TMLArchiMemoryNode.java | 2 +- src/ui/window/JDialogERB.java | 200 ++++++++++++++ src/ui/window/JDialogESO.java | 243 ++++++++++++++++ 30 files changed, 3231 insertions(+), 15 deletions(-) create mode 100755 src/ui/ebrdd/EBRDDActionState.java create mode 100755 src/ui/ebrdd/EBRDDChoice.java create mode 100644 src/ui/ebrdd/EBRDDERB.java create mode 100644 src/ui/ebrdd/EBRDDERC.java create mode 100644 src/ui/ebrdd/EBRDDESO.java create mode 100755 src/ui/ebrdd/EBRDDForLoop.java create mode 100644 src/ui/ebrdd/EBRDDPanel.java create mode 100644 src/ui/ebrdd/EBRDDSequence.java create mode 100755 src/ui/ebrdd/EBRDDStartState.java create mode 100755 src/ui/ebrdd/EBRDDStopState.java create mode 100755 src/ui/ebrdd/EBRDDToolBar.java create mode 100755 src/ui/ebrdd/TGConnectingPointEBRDD.java create mode 100755 src/ui/ebrdd/TGConnectingPointEBRDDERC.java create mode 100755 src/ui/ebrdd/TGConnectorEBRDD.java create mode 100755 src/ui/ebrdd/TGConnectorEBRDDERC.java create mode 100755 src/ui/images/ebrdderb.gif create mode 100755 src/ui/images/ebrdderc.gif create mode 100755 src/ui/images/ebrddeso.gif create mode 100755 src/ui/images/ercconnector.gif create mode 100644 src/ui/window/JDialogERB.java create mode 100644 src/ui/window/JDialogESO.java diff --git a/src/ui/GTURTLEModeling.java b/src/ui/GTURTLEModeling.java index 4c9567f893..7f38fd8711 100755 --- a/src/ui/GTURTLEModeling.java +++ b/src/ui/GTURTLEModeling.java @@ -66,6 +66,7 @@ import ui.ad.*; import ui.cd.*; import ui.dd.*; import ui.iod.*; +import ui.ebrdd.*; import ui.req.*; import ui.sd.*; import ui.ucd.*; @@ -2171,6 +2172,40 @@ public class GTURTLEModeling { makePostLoading(rdp, beginIndex); } } + } else if (tdp instanceof EBRDDPanel) { + nl = doc.getElementsByTagName("EBRDDPanelCopy"); + + if (nl == null) { + return; + } + + EBRDDPanel ebrddp = (EBRDDPanel)tdp; + + for(i=0; i<nl.getLength(); i++) { + adn = nl.item(i); + if (adn.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) adn; + + if (ebrddp == null) { + throw new MalformedModelingException(); + } + + //int xSel = Integer.decode(elt.getAttribute("xSel")).intValue(); + //int ySel = Integer.decode(elt.getAttribute("ySel")).intValue(); + //int widthSel = Integer.decode(elt.getAttribute("widthSel")).intValue(); + //int heightSel = Integer.decode(elt.getAttribute("heightSel")).intValue(); + + decX = _decX; + decY = _decY; + + makeXMLComponents(elt.getElementsByTagName("COMPONENT"), ebrddp); + makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), ebrddp); + makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), ebrddp); + connectConnectorsToRealPoints(ebrddp); + ebrddp.structureChanged(); + makePostLoading(ebrddp, beginIndex); + } + } } else if (tdp instanceof TMLTaskDiagramPanel) { nl = doc.getElementsByTagName("TMLTaskDiagramPanelCopy"); docCopy = doc; @@ -2896,6 +2931,9 @@ public class GTURTLEModeling { if (elt.getTagName().compareTo("TRequirementDiagramPanel") == 0) { loadRequirementDiagram(elt, indexReq, cpt_req); cpt_req ++; + } else if (elt.getTagName().compareTo("EBRDDPanel") == 0) { + loadEBRDD(elt, indexReq, cpt_req); + cpt_req ++; } } } @@ -3129,6 +3167,11 @@ public class GTURTLEModeling { //System.out.println("Connectors..."); ((TMLComponentTaskDiagramPanel)tdp).setConnectorsToFront(); } + + if (tdp instanceof EBRDDPanel) { + //System.out.println("Connectors..."); + ((EBRDDPanel)tdp).setConnectorsToFront(); + } } @@ -3332,6 +3375,23 @@ public class GTURTLEModeling { loadDiagram(elt, tdp); } + + public void loadEBRDD(Element elt, int indexAnalysis, int indexTab) throws MalformedModelingException, SAXException { + String name; + + name = elt.getAttribute("name"); + mgui.createEBRDD(indexAnalysis, name); + + + TDiagramPanel tdp = mgui.getEBRDDPanel(indexAnalysis, indexTab, name); + + if (tdp == null) { + throw new MalformedModelingException(); + } + tdp.removeAll(); + + loadDiagram(elt, tdp); + } public void loadSequenceDiagram(Element elt, int indexAnalysis) throws MalformedModelingException, SAXException { String name; diff --git a/src/ui/IconManager.java b/src/ui/IconManager.java index f84aa03410..fabe002cd2 100755 --- a/src/ui/IconManager.java +++ b/src/ui/IconManager.java @@ -107,6 +107,7 @@ public class IconManager { public static ImageIcon imgic900, imgic902, imgic904, imgic906, imgic908, imgic910, imgic912, imgic914, imgic916, imgic918, imgic920, imgic922, imgic924, imgic926; // Requirement diagrams public static ImageIcon imgic1000, imgic1002, imgic1004,imgic1006,imgic1008, imgic1010, imgic1012, imgic1014; + public static ImageIcon imgic1050, imgic1052, imgic1054,imgic1056; // TMLDD public static ImageIcon imgic1100, imgic1102, imgic1104, imgic1106, imgic1108; @@ -360,15 +361,7 @@ public class IconManager { private static String icon700 = "images/ddnode.gif"; private static String icon702 = "images/ddartifact.gif"; - // Requirement diagrams - private static String icon1000 = "images/reqdiag.gif"; - private static String icon1002 = "images/reqreq.gif"; - private static String icon1004 = "images/reqobs.gif"; - private static String icon1006 = "images/reqver.gif"; - private static String icon1008 = "images/reqder.gif"; - private static String icon1010 = "images/reqcopy.gif"; - private static String icon1012 = "images/reqcomp.gif"; - private static String icon1014 = "images/ebrddobs.gif"; + // TML private static String icon800 = "images/tmlcdevt.gif"; @@ -394,6 +387,25 @@ public class IconManager { private static String icon924 = "images/tmladrandom.gif"; private static String icon926 = "images/tmladforeverloop.gif"; + // Requirement diagrams + private static String icon1000 = "images/reqdiag.gif"; + private static String icon1002 = "images/reqreq.gif"; + private static String icon1004 = "images/reqobs.gif"; + private static String icon1006 = "images/reqver.gif"; + private static String icon1008 = "images/reqder.gif"; + private static String icon1010 = "images/reqcopy.gif"; + private static String icon1012 = "images/reqcomp.gif"; + private static String icon1014 = "images/ebrddobs.gif"; + + + // EBRDD + private static String icon1050 = "images/ebrdderc.gif"; + private static String icon1052 = "images/ercconnector.gif"; + private static String icon1054 = "images/ebrddeso.gif"; + private static String icon1056 = "images/ebrdderb.gif"; + + + // DIPLODOCUS architecture private static String icon1100 = "images/tmlcpunode.gif"; private static String icon1102 = "images/tmlbusnode.gif"; private static String icon1104 = "images/tmlbridgenode.gif"; @@ -690,6 +702,11 @@ public class IconManager { imgic1012 = getIcon(icon1012); imgic1014 = getIcon(icon1014); + imgic1050 = getIcon(icon1050); + imgic1052 = getIcon(icon1052); + imgic1054 = getIcon(icon1054); + imgic1056 = getIcon(icon1056); + imgic1100 = getIcon(icon1100); imgic1102 = getIcon(icon1102); imgic1104 = getIcon(icon1104); diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index ce54bce715..7af1b0cbe2 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -67,6 +67,7 @@ import ui.file.*; import ui.interactivesimulation.*; import ui.iod.*; import ui.req.*; +import ui.ebrdd.*; import ui.sd.*; import ui.ucd.*; import ui.tree.*; @@ -2551,7 +2552,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { } else if (tp instanceof RequirementPanel) { TDiagramPanel tdp = getCurrentTDiagramPanel(); if (!(tdp instanceof RequirementDiagramPanel)) { - System.out.println("Internal error: Requirement panels"); + System.out.println("No syntax checking for EBRDD: not yet implemented"); return ret; } RequirementDiagramPanel rdp= (RequirementDiagramPanel)tdp; @@ -4269,6 +4270,20 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { setPanelMode(); return true; } + + public boolean createEBRDD(int index, String s) { + return createEBRDD((TURTLEPanel)(tabs.elementAt(index)), s); + } + + public boolean createEBRDD(TURTLEPanel tp, String s) { + if (!(tp instanceof RequirementPanel)) { + return false; + } + + ((RequirementPanel)tp).addEBRDD(s); + setPanelMode(); + return true; + } public RequirementDiagramPanel getRequirementDiagramPanel(int index, String s) { //System.out.println("Searching for " + s); @@ -4298,6 +4313,35 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { } return null; } + + public EBRDDPanel getEBRDDPanel(int index, String s) { + //System.out.println("Searching for " + s); + TURTLEPanel tp = (TURTLEPanel)(tabs.elementAt(index)); + return getEBRDDPanel(tp, s); + } + + public EBRDDPanel getEBRDDPanel(TURTLEPanel tp, String s) { + for(int i=0; i<tp.tabbedPane.getTabCount(); i++) { + if (tp.tabbedPane.getTitleAt(i).equals(s)) { + if (tp.panelAt(i) instanceof EBRDDPanel) + return (EBRDDPanel)(tp.panelAt(i)); + } + } + return null; + } + + public EBRDDPanel getEBRDDPanel(int index, int indexTab, String s) { + TURTLEPanel tp = (TURTLEPanel)(tabs.elementAt(index)); + return getEBRDDPanel(tp, indexTab, s); + } + + + public EBRDDPanel getEBRDDPanel(TURTLEPanel tp, int indexTab, String s) { + if(tp.tabbedPane.getTitleAt(indexTab).equals(s)) { + return (EBRDDPanel)(tp.panelAt(indexTab)); + } + return null; + } public void alignInstances() { @@ -5570,6 +5614,28 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.NCDD_ROUTE_ARTIFACT); } else if (command.equals(actions[TGUIAction.TMLTD_TASK].getActionCommand())) { actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLTD_TASK); + } else if (command.equals(actions[TGUIAction.EBRDD_START].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.EBRDD_START_STATE); + } else if (command.equals(actions[TGUIAction.EBRDD_STOP].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.EBRDD_STOP_STATE); + } else if (command.equals(actions[TGUIAction.EBRDD_CONNECTOR].getActionCommand())) { + actionOnButton(TGComponentManager.CONNECTOR, TGComponentManager.CONNECTOR_EBRDD); + } else if (command.equals(actions[TGUIAction.EBRDD_CONNECTOR_ERC].getActionCommand())) { + actionOnButton(TGComponentManager.CONNECTOR, TGComponentManager.CONNECTOR_EBRDD_ERC); + } else if (command.equals(actions[TGUIAction.EBRDD_CHOICE].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.EBRDD_CHOICE); + } else if (command.equals(actions[TGUIAction.EBRDD_ERC].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.EBRDD_ERC); + } else if (command.equals(actions[TGUIAction.EBRDD_ESO].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.EBRDD_ESO); + } else if (command.equals(actions[TGUIAction.EBRDD_ERB].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.EBRDD_ERB); + } else if (command.equals(actions[TGUIAction.EBRDD_SEQUENCE].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.EBRDD_SEQUENCE); + } else if (command.equals(actions[TGUIAction.EBRDD_ACTION].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.EBRDD_ACTION); + } else if (command.equals(actions[TGUIAction.EBRDD_FOR_LOOP].getActionCommand())) { + actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.EBRDD_FOR_LOOP); } else if (command.equals(actions[TGUIAction.TMLAD_START].getActionCommand())) { actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.TMLAD_START_STATE); } else if (command.equals(actions[TGUIAction.TMLAD_STOP].getActionCommand())) { diff --git a/src/ui/RequirementPanel.java b/src/ui/RequirementPanel.java index f3cd8d6444..cbe07d1294 100755 --- a/src/ui/RequirementPanel.java +++ b/src/ui/RequirementPanel.java @@ -39,7 +39,7 @@ knowledge of the CeCILL license and that you accept its terms. * Class RequirementPanel * Managenemt of requirement panels * Creation: 15/05/2006 - * @version 1.0 15/05/2006 + * @version 1.1 08/09/2009 * @author Ludovic APVRILLE * @see MainGUI */ @@ -50,9 +50,11 @@ import java.awt.*; import javax.swing.*; import javax.swing.event.*; import ui.req.*; +import ui.ebrdd.*; public class RequirementPanel extends TURTLEPanel { public RequirementDiagramPanel rdp; + public EBRDDPanel ebrdd; public RequirementPanel(MainGUI _mgui) { super(_mgui); @@ -109,6 +111,35 @@ public class RequirementPanel extends TURTLEPanel { return true; } + + public boolean addEBRDD(String s) { + EBRDDToolBar toolBarEBRDD = new EBRDDToolBar(mgui); + toolbars.add(toolBarEBRDD); + + toolBarPanel = new JPanel(); + //toolBarPanel.setBackground(Color.red); + toolBarPanel.setLayout(new BorderLayout()); + //toolBarPanel.setBackground(ColorManager.MainTabbedPaneSelect); + + // diagram + ebrdd = new EBRDDPanel(mgui, toolBarEBRDD); + ebrdd.setName(s); + ebrdd.tp = this; + //tdp = rdp; + panels.add(ebrdd); + JScrollDiagramPanel jsp = new JScrollDiagramPanel(ebrdd); + ebrdd.jsp = jsp; + jsp.setWheelScrollingEnabled(true); + jsp.getVerticalScrollBar().setUnitIncrement(mgui.INCREMENT); + toolBarPanel.add(toolBarEBRDD, BorderLayout.NORTH); + toolBarPanel.add(jsp, BorderLayout.CENTER); + tabbedPane.addTab(s, IconManager.imgic1000, toolBarPanel, "Opens EBRDD"); + tabbedPane.setSelectedIndex(0); + JPanel toolBarPanel = new JPanel(); + toolBarPanel.setLayout(new BorderLayout()); + + return true; + } public String saveHeaderInXml() { @@ -137,6 +168,11 @@ public class RequirementPanel extends TURTLEPanel { if ((panels.elementAt(index) instanceof RequirementDiagramPanel)){ return true; } + + if ((panels.elementAt(index) instanceof EBRDDPanel)){ + return true; + } + return false; } diff --git a/src/ui/TGComponentManager.java b/src/ui/TGComponentManager.java index fb596da2a8..6d0941e787 100755 --- a/src/ui/TGComponentManager.java +++ b/src/ui/TGComponentManager.java @@ -55,7 +55,9 @@ import ui.dd.*; import ui.iod.*; import ui.sd.*; import ui.ucd.*; + import ui.req.*; +import ui.ebrdd.*; import ui.tmlad.*; import ui.tmlcd.*; @@ -126,6 +128,9 @@ public class TGComponentManager { public static final int CONNECTOR_PORT_TMLC = 126; public static final int CONNECTOR_NODE_NC = 127; + + public static final int CONNECTOR_EBRDD = 130; + public static final int CONNECTOR_EBRDD_ERC = 131; public static final int TCD_TCLASS = 201; public static final int TCD_PARALLEL_OPERATOR = 202; @@ -207,6 +212,16 @@ public class TGComponentManager { public static final int TMLCTD_PCOMPONENT = 1202; public static final int TMLCTD_COPORT = 1203; public static final int TMLCTD_CREMOTECOMPONENT = 1204; + + public static final int EBRDD_START_STATE = 1300; + public static final int EBRDD_STOP_STATE = 1301; + public static final int EBRDD_CHOICE = 1302; + public static final int EBRDD_ERC = 1303; + public static final int EBRDD_ACTION = 1304; + public static final int EBRDD_FOR_LOOP = 1305; + public static final int EBRDD_SEQUENCE = 1306; + public static final int EBRDD_ESO = 1307; + public static final int EBRDD_ERB = 1308; public static final int TREQ_REQUIREMENT = 900; public static final int TREQ_OBSERVER = 901; @@ -412,6 +427,33 @@ public class TGComponentManager { break; case TDD_ARTIFACT: tgc = new TDDArtifact(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case EBRDD_START_STATE: + tgc = new EBRDDStartState(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case EBRDD_STOP_STATE: + tgc = new EBRDDStopState(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case EBRDD_CHOICE: + tgc = new EBRDDChoice(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case EBRDD_ERC: + tgc = new EBRDDERC(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case EBRDD_ACTION: + tgc = new EBRDDERC(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case EBRDD_FOR_LOOP: + tgc = new EBRDDForLoop(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case EBRDD_SEQUENCE: + tgc = new EBRDDSequence(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case EBRDD_ESO: + tgc = new EBRDDESO(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); + break; + case EBRDD_ERB: + tgc = new EBRDDERB(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); break; case TMLAD_START_STATE: tgc = new TMLADStartState(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp); @@ -760,6 +802,24 @@ public class TGComponentManager { return NCDD_TRAFFIC_ARTIFACT; } else if (tgc instanceof NCRouteArtifact) { return NCDD_ROUTE_ARTIFACT; + } else if (tgc instanceof EBRDDStartState) { + return EBRDD_START_STATE; + } else if (tgc instanceof EBRDDStopState) { + return EBRDD_STOP_STATE; + } else if (tgc instanceof EBRDDChoice) { + return EBRDD_CHOICE; + } else if (tgc instanceof EBRDDERC) { + return EBRDD_ERC; + } else if (tgc instanceof EBRDDActionState) { + return EBRDD_ACTION; + } else if (tgc instanceof EBRDDForLoop) { + return EBRDD_FOR_LOOP; + } else if (tgc instanceof EBRDDSequence) { + return EBRDD_SEQUENCE; + } else if (tgc instanceof EBRDDESO) { + return EBRDD_ESO; + } else if (tgc instanceof EBRDDERB) { + return EBRDD_ERB; } else if (tgc instanceof TMLADStartState) { return TMLAD_START_STATE; } else if (tgc instanceof TMLADStopState) { @@ -998,6 +1058,12 @@ public class TGComponentManager { break; case TOSAD_CONNECTOR: tgc = new TOSADConnector(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp, p1, p2, listPoint); + break; + case CONNECTOR_EBRDD: + tgc = new TGConnectorEBRDD(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp, p1, p2, listPoint); + break; + case CONNECTOR_EBRDD_ERC: + tgc = new TGConnectorEBRDDERC(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp, p1, p2, listPoint); break; case CONNECTOR_TMLAD: tgc = new TGConnectorTMLAD(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp, p1, p2, listPoint); diff --git a/src/ui/TGConnector.java b/src/ui/TGConnector.java index c6a9ed7837..b9f8b1dca5 100755 --- a/src/ui/TGConnector.java +++ b/src/ui/TGConnector.java @@ -606,8 +606,20 @@ public abstract class TGConnector extends TGCWithInternalComponent { } else { automatic = new JMenuItem("Activate automatic drawing"); } + automatic.addActionListener(menuAL); componentMenu.add(automatic); + + JMenuItem negation; + if (canBeNegated()) { + if (getNegation()) { + negation = new JMenuItem("Negation (to off)"); + } else { + negation = new JMenuItem("Negation (to on)"); + } + negation.addActionListener(menuAL); + componentMenu.add(negation); + } } public boolean eventOnPopup(ActionEvent e) { @@ -621,7 +633,9 @@ public abstract class TGConnector extends TGCWithInternalComponent { } else if (e.getActionCommand().equals("Activate automatic drawing")) { automaticDrawing = true; return true; - } + } else if (e.getActionCommand().startsWith("Negation ")) { + reverseNegation(); + } return false; } @@ -665,5 +679,16 @@ public abstract class TGConnector extends TGCWithInternalComponent { GraphicLib.dashedRect(g, x1+s2+s3, y1+s3, w+15, h-12); } + + public void reverseNegation() { + } + + public boolean canBeNegated() { + return false; + } + + public boolean getNegation() { + return false; + } } diff --git a/src/ui/TGUIAction.java b/src/ui/TGUIAction.java index 4ab91c8de7..e491a6c4dd 100755 --- a/src/ui/TGUIAction.java +++ b/src/ui/TGUIAction.java @@ -207,6 +207,18 @@ public class TGUIAction extends AbstractAction { public static final int TMLARCHI_MEMORYNODE = 224; public static final int TMLARCHI_BRIDGENODE = 225; + public static final int EBRDD_EDIT = 271; + public static final int EBRDD_CONNECTOR = 272; + public static final int EBRDD_START = 273; + public static final int EBRDD_STOP = 274; + public static final int EBRDD_CHOICE = 275; + public static final int EBRDD_ERC = 276; + public static final int EBRDD_ACTION = 277; + public static final int EBRDD_FOR_LOOP = 278; + public static final int EBRDD_SEQUENCE = 279; + public static final int EBRDD_ESO = 280; + public static final int EBRDD_ERB = 281; + public static final int EBRDD_CONNECTOR_ERC = 282; // TURTLE-OS public static final int TOS_TCLASS = 189; @@ -381,7 +393,7 @@ public class TGUIAction extends AbstractAction { //Action for the help button created by Solange public static final int PRUEBA_1 = 205; - public static final int NB_ACTION = 271; + public static final int NB_ACTION = 283; private static final TAction [] actions = new TAction[NB_ACTION]; @@ -669,6 +681,19 @@ public class TGUIAction extends AbstractAction { actions[TMLAD_SELECT_EVT] = new TAction("add-tmlad-select-evt", "Add select event", IconManager.imgic916, IconManager.imgic916, "Select event", "Add a selection between events to the currently opened TML Task activity diagram", 0); actions[TMLAD_RANDOM] = new TAction("add-tmlad-random", "Add random", IconManager.imgic924, IconManager.imgic924, "Select random", "Add a random operator to the currently opened TML Task activity diagram", 0); + actions[EBRDD_EDIT] = new TAction("edit-ebrdd-diagram", "Edit EBRDD", IconManager.imgic100, IconManager.imgic101, "Edit EBRDD", "Make it possible to edit the currently opened Event-Based Requirement Description Diagram", 0); + actions[EBRDD_CONNECTOR] = new TAction("add-ebrdd-connector", "Connect two operators together", IconManager.imgic202, IconManager.imgic202, "Connect two operators together", "Connect two operators of the currently opened Event-Based Requirement Description Diagram", 0); + actions[EBRDD_START] = new TAction("add-ebrdd-start", "Add Start state", IconManager.imgic222, IconManager.imgic222, "Start", "Add a start state to the currently opened Event-Based Requirement Description Diagram", 0); + actions[EBRDD_STOP] = new TAction("add-ebrdd-stop", "Add Stop", IconManager.imgic210, IconManager.imgic210, "Stop", "Add a termination state to the currently opened Event-Based Requirement Description Diagram", 0); + actions[EBRDD_CHOICE] = new TAction("add-ebrdd-choice", "Add Choice", IconManager.imgic222, IconManager.imgic222, "Choice", "Add a deterministic choice to the currently opened Event-Based Requirement Description Diagram", 0); + actions[EBRDD_ERC] = new TAction("add-ebrdd-erc", "Add ERC", IconManager.imgic1050, IconManager.imgic1050, "Event Reception Container", "Add an Event Reception Container to the currently opened Event-Based Requirement Description Diagram", 0); + actions[EBRDD_ACTION] = new TAction("add-ebrdd-action", "Add Action", IconManager.imgic204, IconManager.imgic204, "Action", "Add an Action to the currently opened Event-Based Requirement Description Diagram", 0); + actions[EBRDD_FOR_LOOP] = new TAction("add-ebrdd-for-loop", "Loop (for)", IconManager.imgic912, IconManager.imgic912, "Loop (for)", "Add a for loop to the currently opened Event-Based Requirement Description Diagram", 0); + actions[EBRDD_SEQUENCE] = new TAction("add-ebrdd-sequence", "Sequence", IconManager.imgic226, IconManager.imgic226, "Sequence", "Add a sequence to the currently opened Event-Based Requirement Description Diagram", 0); + actions[EBRDD_CONNECTOR_ERC] = new TAction("add-ebrdd-erc-connector", "Connect two ESO / ERB operators together", IconManager.imgic1052, IconManager.imgic1052, "Connect two ESO / ERB operators together", "Connect two ESO / ERB operators of the currently opened Event-Based Requirement Description Diagram", 0); + actions[EBRDD_ESO] = new TAction("add-ebrdd-eso", "Add ESO", IconManager.imgic1054, IconManager.imgic1054, "Event Sequencing Operator", "Add an Event Sequencing Operator to the currently opened Event-Based Requirement Description Diagram", 0); + actions[EBRDD_ERB] = new TAction("add-ebrdd-erb", "Add ERB", IconManager.imgic1056, IconManager.imgic1056, "Event Reaction Block", "Add an Event Reaction Block to the currently opened Event-Based Requirement Description Diagram", 0); + actions[TMLARCHI_EDIT] = new TAction("edit-tmlarchi-diagram", "Edit DIPLODOCUS architecture diagram", IconManager.imgic100, IconManager.imgic101, "Edit DIPLODOCUS architecture diagram", "Make it possible to edit the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_LINK] = new TAction("add-tmlarchi-link", "Add a link", IconManager.imgic202, IconManager.imgic202, "Link", "Add a link between two nodes of the currently opened DIPLODOCUS architecture diagram", 0); actions[TMLARCHI_CPUNODE] = new TAction("add-tmlarchi-cpunode", "Add a CPU node", IconManager.imgic1100, IconManager.imgic1100, "CPU node", "Add a cpu node to the currently opened DIPLODOCUS architecture diagram", 0); diff --git a/src/ui/TURTLEPanelPopupListener.java b/src/ui/TURTLEPanelPopupListener.java index 546461096b..35e255c6f6 100755 --- a/src/ui/TURTLEPanelPopupListener.java +++ b/src/ui/TURTLEPanelPopupListener.java @@ -59,7 +59,7 @@ public class TURTLEPanelPopupListener extends MouseAdapter /* popup menus onto t private JPopupMenu menu; protected MainGUI mgui; - private JMenuItem rename, remove, moveRight, moveLeft, sort, newucd, newreq, newprosmd; + private JMenuItem rename, remove, moveRight, moveLeft, sort, newucd, newreq, newebrdd, newprosmd; public TURTLEPanelPopupListener(TURTLEPanel _tp, MainGUI _mgui) { tp = _tp; @@ -93,6 +93,7 @@ public class TURTLEPanelPopupListener extends MouseAdapter /* popup menus onto t sort = createMenuItem("Sort"); newucd = createMenuItem("New use case diagram"); newreq = createMenuItem("New requirement diagram"); + newebrdd = createMenuItem("New Event-Based Requirement Description Diagram"); newprosmd = createMenuItem("New ProActive state machine diagram"); menu = new JPopupMenu("TURTLE panel"); @@ -107,6 +108,7 @@ public class TURTLEPanelPopupListener extends MouseAdapter /* popup menus onto t menu.add(newucd); menu.addSeparator(); menu.add(newreq); + menu.add(newebrdd); menu.addSeparator(); menu.add(newprosmd); } @@ -145,6 +147,7 @@ public class TURTLEPanelPopupListener extends MouseAdapter /* popup menus onto t newucd.setEnabled(tp.isUCDEnabled()); newreq.setEnabled(tp.isReqEnabled()); + newebrdd.setEnabled(tp.isReqEnabled()); newprosmd.setEnabled(tp.isProSMDEnabled()); } @@ -171,6 +174,9 @@ public class TURTLEPanelPopupListener extends MouseAdapter /* popup menus onto t } else if (ac.equals("New requirement diagram")) { mgui.createRequirementDiagram(tp, "Requirement diagram"); mgui.changeMade(null, -1); + } else if (ac.equals("New Event-Based Requirement Description Diagram")) { + mgui.createEBRDD(tp, "EBRDD"); + mgui.changeMade(null, -1); } else if (ac.equals("New ProActive state machine diagram")) { mgui.createProActiveSMD(tp, "ProActive SMD"); mgui.changeMade(null, -1); diff --git a/src/ui/ebrdd/EBRDDActionState.java b/src/ui/ebrdd/EBRDDActionState.java new file mode 100755 index 0000000000..6604d6985c --- /dev/null +++ b/src/ui/ebrdd/EBRDDActionState.java @@ -0,0 +1,169 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** + * Class EBRDDActionState + * Action state of an EBRDD + * Creation: 09/09/2009 + * @version 1.0 09/09/2009 + * @author Ludovic APVRILLE + * @see + */ + +package ui.ebrdd; + +import java.awt.*; +import java.awt.geom.*; + +import myutil.*; +import ui.*; + +public class EBRDDActionState extends TGCOneLineText implements PreJavaCode, PostJavaCode, CheckableAccessibility, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { + protected int lineLength = 5; + protected int textX = 5; + protected int textY = 15; + protected int arc = 5; + + protected int stateOfError = 0; // Not yet checked + + public EBRDDActionState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + width = 30; + height = 20; + minWidth = 30; + + nbConnectingPoint = 2; + connectingPoint = new TGConnectingPoint[2]; + connectingPoint[0] = new TGConnectingPointEBRDD(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = new TGConnectingPointEBRDD(this, 0, lineLength, false, true, 0.5, 1.0); + + moveable = true; + editable = true; + removable = true; + + value = "action"; + name = "action state"; + + myImageIcon = IconManager.imgic204; + } + + public void internalDrawing(Graphics g) { + int w = g.getFontMetrics().stringWidth(value); + int w1 = Math.max(minWidth, w + 2 * textX); + if ((w1 != width) & (!tdp.isScaled())) { + setCd(x + width/2 - w1/2, y); + width = w1; + //updateConnectingPoints(); + } + + if (stateOfError > 0) { + Color c = g.getColor(); + switch(stateOfError) { + case ErrorHighlight.OK: + g.setColor(ColorManager.ATTRIBUTE_BOX_ACTION); + break; + default: + g.setColor(ColorManager.UNKNOWN_BOX_ACTION); + } + g.fillRoundRect(x, y, width, height, arc, arc); + g.setColor(c); + } + + g.drawRoundRect(x, y, width, height, arc, arc); + g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); + g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); + + g.drawString(value, x + (width - w) / 2 , y + textY); + + } + + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x +width/2, y- lineLength, x+width/2, y + lineLength + height, _x, _y)) < distanceSelected) { + return this; + } + + return null; + } + + public String getAction() { + return value; + } + + public String getAction(int cpt) { + if (cpt <0) { + return value; + } + + String ret; + + try { + ret = value; + while(cpt >0) { + ret = ret.substring(ret.indexOf(';') + 1, ret.length()); + cpt --; + } + + int index = ret.indexOf(';'); + + if (index > 0) { + ret = ret.substring(0, index+1); + } + } catch (Exception e) { + return value; + } + return ret; + } + + public int getType() { + return TGComponentManager.EBRDD_ACTION; + } + + public int getDefaultConnector() { + return TGComponentManager.CONNECTOR_EBRDD; + } + + public void setStateAction(int _stateAction) { + stateOfError = _stateAction; + } + + +} diff --git a/src/ui/ebrdd/EBRDDChoice.java b/src/ui/ebrdd/EBRDDChoice.java new file mode 100755 index 0000000000..3d72d03537 --- /dev/null +++ b/src/ui/ebrdd/EBRDDChoice.java @@ -0,0 +1,186 @@ +/** + Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** + * Class EBRDDChoice + * Choice with guards. To be used in EBRDDs + * Creation: 09/09/2009 + * @version 1.0 09/09/2009 + * @author Ludovic APVRILLE + * @see + */ + +package ui.ebrdd; + +import java.awt.*; +import java.awt.geom.*; + +import myutil.*; +import ui.*; + +public class EBRDDChoice extends TGCWithInternalComponent implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { + private int lineLength = 10; + private int lineOutLength = 25; + private int textX1, textY1, textX2, textY2, textX3, textY3; + + protected int stateOfError = 0; // Not yet checked + + public EBRDDChoice(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + width = 30; + height = 30; + textX1 = -lineOutLength; + textY1 = height/2 - 5; + textX2 = width + 5; + textY2 = height/2 - 5; + textX3 = width /2 + 5; + textY3 = height + 15; + + nbConnectingPoint = 4; + connectingPoint = new TGConnectingPoint[nbConnectingPoint]; + connectingPoint[0] = new TGConnectingPointEBRDD(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = new TGConnectingPointEBRDD(this, -lineOutLength, 0, false, true, 0.0, 0.5); + connectingPoint[2] = new TGConnectingPointEBRDD(this, lineOutLength, 0, false, true, 1.0, 0.5); + connectingPoint[3] = new TGConnectingPointEBRDD(this, 0, lineOutLength, false, true, 0.5, 1.0); + + nbInternalTGComponent = 3; + tgcomponent = new TGComponent[nbInternalTGComponent]; + + TGCOneLineText tgc = new TGCOneLineText(x+textX1, y+textY1, textX1-50, textX1+5, textY1, textY1 + 25, true, this, _tdp); + tgc.setValue("[ ]"); + tgc.setName("guard 1"); + tgcomponent[0] = tgc; + + tgc = new TGCOneLineText(x+textX2, y+textY2, textX2, textX2+20, textY2, textY2+25, true, this, _tdp); + tgc.setValue("[ ]"); + tgc.setName("guard 2"); + tgcomponent[1] = tgc; + + tgc = new TGCOneLineText(x+textX3, y+textY3, textX3, textX3+20, textY3, textY3+25, true, this, _tdp); + tgc.setValue("[ ]"); + tgc.setName("guard 3"); + tgcomponent[2] = tgc; + + moveable = true; + editable = false; + removable = true; + + name = "choice"; + + myImageIcon = IconManager.imgic208; + } + + public void internalDrawing(Graphics g) { + if (stateOfError > 0) { + Color c = g.getColor(); + switch(stateOfError) { + case ErrorHighlight.OK: + g.setColor(ColorManager.CHOICE); + break; + default: + g.setColor(ColorManager.UNKNOWN_BOX_ACTION); + } + // Making the polygon + int [] px1 = {x+(width/2), x+width+2, x + (width/2), x}; + int [] py1 = {y, y + height/2, y+height+2, y+height/2}; + g.fillPolygon(px1, py1, 4); + g.setColor(c); + } + + g.drawLine(x+(width/2), y, x+width, y + height/2); + g.drawLine(x, y + height / 2, x+width/2, y + height); + g.drawLine(x + width/2, y, x, y + height/2); + g.drawLine(x + width, y + height/2, x + width/2, y + height); + + g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); + g.drawLine(x, y + height/2, x-lineOutLength, y + height/2); + g.drawLine(x + width, y + height/2, x+ width + lineOutLength, y + height/2); + g.drawLine(x+(width/2), y + height, x+(width/2), y + height + lineOutLength); + } + + public TGComponent isOnOnlyMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x+(width/2), y + height, x+(width/2), y + height + lineOutLength, _x, _y)) < distanceSelected) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x + width, y + height/2, x+ width + lineOutLength, y + height/2, _x, _y)) < distanceSelected) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x, y + height/2, x-lineOutLength, y + height/2, _x, _y)) < distanceSelected) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x+(width/2), y, x+(width/2), y - lineLength, _x, _y)) < distanceSelected) { + return this; + } + + return null; + } + + public String getGuard(int i) { + if ((i>=0) && (i<nbInternalTGComponent)) { + return tgcomponent[i].getValue(); + } + return ""; + } + + public void setGuard(String guard, int i) { + if ((i>=0) && (i<nbInternalTGComponent)) { + tgcomponent[i].setValue(guard); + } + } + + public int getType() { + return TGComponentManager.EBRDD_CHOICE; + } + + public int getDefaultConnector() { + return TGComponentManager.CONNECTOR_EBRDD; + } + + public void setStateAction(int _stateAction) { + stateOfError = _stateAction; + } + +} diff --git a/src/ui/ebrdd/EBRDDERB.java b/src/ui/ebrdd/EBRDDERB.java new file mode 100644 index 0000000000..b6b44fcf35 --- /dev/null +++ b/src/ui/ebrdd/EBRDDERB.java @@ -0,0 +1,290 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** + * Class EBRDDERB + * Event Reaction Block an EBRDD + * Creation: 09/09/2009 + * @version 1.0 09/09/2009 + * @author Ludovic APVRILLE + * @see + */ + +package ui.ebrdd; + +import java.awt.*; +import java.awt.geom.*; + +import javax.swing.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +import org.w3c.dom.*; + +public class EBRDDERB extends TGCOneLineText implements SwallowedTGComponent { + protected int lineLength = 5; + protected int textX = 5; + protected int textY = 15; + protected int diffY = 20; + + protected int wid; + + protected int stateOfError = 0; // Not yet checked + + protected String evt = "evt1", condition = "x==0", action = "x=x+1"; + + public EBRDDERB(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + width = 60; + height = 60; + minWidth = 30; + + nbConnectingPoint = 1; + connectingPoint = new TGConnectingPoint[1]; + connectingPoint[0] = new TGConnectingPointEBRDDERC(this, 0, -lineLength, true, false, 0.5, 0.0); + + moveable = true; + editable = true; + removable = true; + + value = "action / condition"; + name = "Event Reaction Block"; + + myImageIcon = IconManager.imgic204; + } + + public void internalDrawing(Graphics g) { + if (wid != width) { + resizeWithFather(); + } + + String val1 = "evt: " + evt; + String val2 = "cond: " + condition; + String val3 = "action: " + action; + + int w11 = g.getFontMetrics().stringWidth(val1); + int w22 = g.getFontMetrics().stringWidth(val2); + int w33 = g.getFontMetrics().stringWidth(val3); + + int w1 = Math.max(w11, w22); + w1 = Math.max(w1, w33); + int w = Math.max(minWidth, w1 + (2 * textX)); + if ((w != width) & (!tdp.isScaled())) { + setCd(x + width/2 - w/2, y); + width = w; + //updateConnectingPoints(); + } + + if (stateOfError > 0) { + Color c = g.getColor(); + switch(stateOfError) { + case ErrorHighlight.OK: + g.setColor(ColorManager.ATTRIBUTE_BOX_ACTION); + break; + default: + g.setColor(ColorManager.UNKNOWN_BOX_ACTION); + } + g.fillRect(x, y, width, height); + g.setColor(c); + } + + g.drawRect(x, y, width, height); + g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); + //g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); + + g.drawString(val1, x + textX - 2, y + textY); + g.drawLine(x, y + textY + 2, x + width, y + textY + 2); + g.drawString(val2, x + textX - 2, y + textY + diffY); + g.drawString(val3, x + textX - 2, y + textY + (2 * diffY)); + + } + + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x +width/2, y- lineLength, x+width/2, y, _x, _y)) < distanceSelected) { + return this; + } + + return null; + } + + public boolean editOndoubleClick(JFrame frame) { + boolean error = false; + String errors = ""; + String val; + + JDialogERB dialog = new JDialogERB(frame, this); + dialog.setSize(500, 450); + GraphicLib.centerOnParent(dialog); + dialog.show(); // blocked until dialog has been closed + + if (!dialog.isRegularClose()) { + return false; + } + + val = dialog.getEvent().trim(); + if (val.length() == 0) { + error = true; + errors += "event "; + } + + val = dialog.getCondition().trim(); + if (val.length() == 0) { + error = true; + errors += "condition "; + } + + val = dialog.getAction().trim(); + if (val.length() == 0) { + error = true; + errors += "action "; + } + + + if (error) { + JOptionPane.showMessageDialog(frame, + "Invalid value for the following attributes: " + errors, + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + + evt = dialog.getEvent().trim(); + condition = dialog.getCondition().trim(); + action = dialog.getAction().trim(); + + return true; + } + + public int getType() { + return TGComponentManager.EBRDD_ERB; + } + + public int getDefaultConnector() { + return TGComponentManager.CONNECTOR_EBRDD_ERC; + } + + public void setStateAction(int _stateAction) { + stateOfError = _stateAction; + } + + public void resizeWithFather() { + if ((father != null) && (father instanceof EBRDDERC)) { + //System.out.println("cdRect comp"); + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); + //setCd(Math.min(x, father.getWidth() - getWidth()), Math.min(y, father.getHeight() - getHeight())); + setMoveCd(x, y); + } + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<elements evt=\"" + evt + "\" "); + sb.append("cond=\"" + condition + "\" "); + sb.append("action=\"" + action + "\" "); + sb.append("/>\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro ***"); + try { + + NodeList nli; + Node n1, n2; + Element elt; + + String val = null; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + //System.out.println(n1); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; i<nli.getLength(); i++) { + n2 = nli.item(i); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("elements")) { + val = elt.getAttribute("evt"); + //System.out.println("val=" + val); + if (val != null) { + evt = val; + } + val = elt.getAttribute("cond"); + //System.out.println("val=" + val); + if (val != null) { + condition = val; + } + val = elt.getAttribute("action"); + //System.out.println("val=" + val); + if (val != null) { + action = val; + } + } + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + public String getEvent() { + return evt; + } + + public String getCondition() { + return condition; + } + + public String getAction() { + return action; + } + + +} diff --git a/src/ui/ebrdd/EBRDDERC.java b/src/ui/ebrdd/EBRDDERC.java new file mode 100644 index 0000000000..cf39dc3688 --- /dev/null +++ b/src/ui/ebrdd/EBRDDERC.java @@ -0,0 +1,232 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** + * Class EBRDDERC + * Event reception Container. To be used in EBRDDs + * Creation: 02/05/2005 + * @version 1.1 21/05/2008 + * @author Ludovic APVRILLE + * @see + */ + +package ui.ebrdd; + +import java.awt.*; +import java.awt.geom.*; +import java.util.*; +import javax.swing.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +import tmltranslator.*; + +public class EBRDDERC extends TGCWithInternalComponent implements SwallowTGComponent { + /*private int textY1 = 15; + private int textY2 = 30; + private int derivationx = 2; + private int derivationy = 3; + private String stereotype = "CPU";*/ + + protected int lineLength = 5; + + + public EBRDDERC(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + width = 250; + height = 200; + minWidth = 150; + minHeight = 100; + + nbConnectingPoint = 2; + connectingPoint = new TGConnectingPoint[2]; + connectingPoint[0] = new TGConnectingPointEBRDD(this, 0, - lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = new TGConnectingPointEBRDD(this, 0, lineLength, false, true, 0.5, 1.0); + + addTGConnectingPointsComment(); + + nbInternalTGComponent = 0; + + moveable = true; + editable = true; + removable = true; + userResizable = true; + + name = tdp.findNodeName("ERC"); + value = "name"; + + //myImageIcon = IconManager.imgic700; + } + + public void internalDrawing(Graphics g) { + Color c = g.getColor(); + g.draw3DRect(x, y, width, height, true); + + + // Top lines + /*g.drawLine(x, y, x + derivationx, y - derivationy); + g.drawLine(x + width, y, x + width + derivationx, y - derivationy); + g.drawLine(x + derivationx, y - derivationy, x + width + derivationx, y - derivationy); + + // Right lines + g.drawLine(x + width, y + height, x + width + derivationx, y - derivationy + height); + g.drawLine(x + derivationx + width, y - derivationy, x + width + derivationx, y - derivationy + height);*/ + + // Filling color + g.setColor(ColorManager.CPU_BOX_1); + g.fill3DRect(x+1, y+1, width-1, height-1, true); + g.setColor(c); + + // Connecting lines + g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); + g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); + + + // String + int w = g.getFontMetrics().stringWidth(name); + g.drawString(value, x + (width - w)/2, y+15); + + // Icon + //g.drawImage(IconManager.imgic1100.getImage(), x + 4, y + 4, null); + //g.drawImage(IconManager.img9, x + width - 20, y + 4, null); + } + + public TGComponent isOnOnlyMe(int x1, int y1) { + if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x +width/2, y- lineLength, x+width/2, y + lineLength + height, x1, y1)) < distanceSelected) { + return this; + } + + return null; + } + + + public boolean editOndoubleClick(JFrame frame) { + //System.out.println("Double click"); + String text = getName() + ": "; + if (hasFather()) { + text = getTopLevelName() + " / " + text; + } + String s = (String)JOptionPane.showInputDialog(frame, text, + "setting value", JOptionPane.PLAIN_MESSAGE, IconManager.imgic100, + null, + getValue()); + if ((s != null) && (s.length() > 0)) { + setValue(s); + return true; + } + return false; + } + + + public void addSwallowedTGComponent(TGComponent tgc, int x, int y) { + //System.out.println("Add swallow component"); + // 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 EBRDDESO) { + //tgc.setCdRectangle((width/2) - tgc.getWidth(), (width/2), spacePt, height-spacePt); + //System.out.println("cdRect comp swallow"); + ((EBRDDESO)tgc).resizeWithFather(); + //tgc.setCdRectangle(0, width - tgc.getWidth(), 0, height - tgc.getHeight()); + //tgc.setCd(x, y); + } + + if (tgc instanceof EBRDDERB) { + //tgc.setCdRectangle((width/2) - tgc.getWidth(), (width/2), spacePt, height-spacePt); + //System.out.println("cdRect comp swallow"); + ((EBRDDERB)tgc).resizeWithFather(); + //tgc.setCdRectangle(0, width - tgc.getWidth(), 0, height - tgc.getHeight()); + //tgc.setCd(x, y); + } + + // else unknown*/ + + //add it + addInternalComponent(tgc, 0); + } + + public void removeSwallowedTGComponent(TGComponent tgc) { + removeInternalComponent(tgc); + } + + + public Vector getElementList() { + Vector v = new Vector(); + for(int i=0; i<nbInternalTGComponent; i++) { + if ((tgcomponent[i] instanceof EBRDDESO) || (tgcomponent[i] instanceof EBRDDERB)){ + v.add(tgcomponent[i]); + } + } + return v; + } + + public void hasBeenResized() { + for(int i=0; i<nbInternalTGComponent; i++) { + if (tgcomponent[i] instanceof EBRDDESO) { + ((EBRDDESO)tgcomponent[i]).resizeWithFather(); + } + if (tgcomponent[i] instanceof EBRDDERB) { + ((EBRDDERB)tgcomponent[i]).resizeWithFather(); + } + } + + } + + public int getType() { + return TGComponentManager.EBRDD_ERC; + } + + public int getDefaultConnector() { + return TGComponentManager.CONNECTOR_EBRDD; + } + + +} diff --git a/src/ui/ebrdd/EBRDDESO.java b/src/ui/ebrdd/EBRDDESO.java new file mode 100644 index 0000000000..757295bfbc --- /dev/null +++ b/src/ui/ebrdd/EBRDDESO.java @@ -0,0 +1,290 @@ +/** +Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** +* Class EBRDDESO +* Event Sequencing operator. To be used in EBRDDs +* Creation: 09/09/2009 +* @version 1.0 09/09/2009 +* @author Ludovic APVRILLE +* @see +*/ + +package ui.ebrdd; + +import java.awt.*; +import javax.swing.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +import org.w3c.dom.*; + +public class EBRDDESO extends TGCWithoutInternalComponent implements SwallowedTGComponent { + private int lineLength = 0; + private int textX, textY; + + // Type + public final static String [] ESOS = {"Conjunction", "Disjunction", "Sequence", "Strict sequence", "Simultaneous", "At least/At most"}; + + protected int id; + protected int timeout; + protected boolean oncePerEvent; + protected int n, m; + + + public EBRDDESO(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + + width = 150; + height = 5; + + textX = width - 6; + textY = height + 2; + + nbConnectingPoint = 6; + connectingPoint = new TGConnectingPoint[6]; + connectingPoint[0] = new TGConnectingPointEBRDDERC(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = new TGConnectingPointEBRDDERC(this, 0, lineLength, false, true, 0.167, 1.0); + connectingPoint[2] = new TGConnectingPointEBRDDERC(this, 0, lineLength, false, true, 0.333, 1.0); + connectingPoint[3] = new TGConnectingPointEBRDDERC(this, 0, lineLength, false, true, 0.5, 1.0); + connectingPoint[4] = new TGConnectingPointEBRDDERC(this, 0, lineLength, false, true, 0.667, 1.0); + connectingPoint[5] = new TGConnectingPointEBRDDERC(this, 0, lineLength, false, true, 0.833, 1.0); + + nbInternalTGComponent = 0; + + moveable = true; + editable = true; + removable = true; + + setValue("Conjunction"); + name = "ESO"; + id = 0; + + myImageIcon = IconManager.imgic206; + } + + public void internalDrawing(Graphics g) { + g.drawRect(x, y, width, height); + g.fillRect(x, y, width, height); + Font f = g.getFont(); + int w = g.getFontMetrics().stringWidth(ESOS[id]); + g.drawString(ESOS[id], x+width-w, y-2); + } + + public TGComponent isOnMe(int x1, int y1) { + if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { + return this; + } + return null; + } + public boolean editOndoubleClick(JFrame frame) { + boolean error = false; + String errors = ""; + int tmp; + String tmpName; + + JDialogESO dialog = new JDialogESO(frame, this); + dialog.setSize(500, 450); + GraphicLib.centerOnParent(dialog); + dialog.show(); // blocked until dialog has been closed + + if (!dialog.isRegularClose()) { + return false; + } + + int _n = 0, _m = 0, _timeout = 0; + String val; + + try { + val = dialog.getTimeout(); + _timeout = Integer.decode(val).intValue(); + } catch (Exception e) { + error = true; + errors += "timeout "; + } + + try { + val = dialog.getN(); + _n = Integer.decode(val).intValue(); + } catch (Exception e) { + error = true; + errors += "n "; + } + + try { + val = dialog.getM(); + _m = Integer.decode(val).intValue(); + } catch (Exception e) { + error = true; + errors += "m "; + } + + if (error) { + JOptionPane.showMessageDialog(frame, + "Invalid value for the following attributes: " + errors, + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + + id = dialog.getID(); + timeout = _timeout; + oncePerEvent = dialog.getOncePerEvent(); + n = _n; + m = _m; + + return true; + } + + public int getType() { + return TGComponentManager.EBRDD_ESO; + } + + public int getDefaultConnector() { + return TGComponentManager.CONNECTOR_EBRDD_ERC; + } + + public void resizeWithFather() { + if ((father != null) && (father instanceof EBRDDERC)) { + //System.out.println("cdRect comp"); + setCdRectangle(0, father.getWidth() - getWidth(), 0, father.getHeight() - getHeight()); + //setCd(Math.min(x, father.getWidth() - getWidth()), Math.min(y, father.getHeight() - getHeight())); + setMoveCd(x, y); + } + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<attributes id=\"" + id + "\" "); + sb.append(" timeout=\"" + timeout + "\" "); + sb.append(" oncePerEvent=\"" + oncePerEvent + "\" "); + sb.append(" n=\"" + n + "\" "); + sb.append(" m=\"" + m + "\""); + sb.append("/>\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro ***"); + try { + + NodeList nli; + Node n1, n2; + Element elt; + int t1id; + String sstereotype = null, snodeName = null; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + //System.out.println(n1); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; i<nli.getLength(); i++) { + n2 = nli.item(i); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + + if (elt.getTagName().equals("attributes")) { + id = Integer.decode(elt.getAttribute("id")).intValue(); + timeout = Integer.decode(elt.getAttribute("timeout")).intValue(); + n = Integer.decode(elt.getAttribute("n")).intValue(); + m = Integer.decode(elt.getAttribute("m")).intValue(); + oncePerEvent = elt.getAttribute("m").equals("true"); + } + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + } + + public static boolean hasTimeout(int _id) { + return true; + } + + public static boolean hasOncePerEvent(int _id) { + switch(_id) { + case 0: + return true; + case 1: + return false; + case 2: + return true; + case 3: + return false; + case 4: + return false; + case 5: + return true; + } + return false; + } + + public static boolean hasNM(int _id) { + return (_id == 5); + } + + public int getID() { + return id; + } + + public int getTimeout() { + return timeout; + } + + public boolean getOncePerEvent() { + return oncePerEvent; + } + + public int getN() { + return n; + } + + public int getM() { + return m; + } + +} diff --git a/src/ui/ebrdd/EBRDDForLoop.java b/src/ui/ebrdd/EBRDDForLoop.java new file mode 100755 index 0000000000..c395deb763 --- /dev/null +++ b/src/ui/ebrdd/EBRDDForLoop.java @@ -0,0 +1,257 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + * + * /** + * Class EBRDDForLoop + * For loop of an EBRDD + * Creation: 09/09/2009 + * @version 1.0 09/09/2009 + * @author Ludovic APVRILLE + * @see + */ + +package ui.ebrdd; + +import java.awt.*; +import java.awt.geom.*; +import javax.swing.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +public class EBRDDForLoop extends TGCWithoutInternalComponent implements EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { + protected int lineLength = 5; + protected int textX = 5; + protected int textY = 15; + protected int arc = 5; + + protected String init = "i=0"; + protected String condition = "i<5"; + protected String increment = "i = i+1"; + + protected int stateOfError = 0; // Not yet checked + + public EBRDDForLoop(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + width = 30; + height = 20; + minWidth = 30; + + nbConnectingPoint = 3; + connectingPoint = new TGConnectingPoint[3]; + connectingPoint[0] = new TGConnectingPointEBRDD(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = new TGConnectingPointEBRDD(this, 0, lineLength, false, true, 1.0, 0.45); // loop + connectingPoint[2] = new TGConnectingPointEBRDD(this, 0, lineLength, false, true, 0.5, 1.0); // after lopp + + moveable = true; + editable = true; + removable = true; + + makeValue(); + + name = "for loop"; + + myImageIcon = IconManager.imgic912; + } + + public void internalDrawing(Graphics g) { + int w = g.getFontMetrics().stringWidth(value); + int w1 = Math.max(minWidth, w + 2 * textX); + if ((w1 != width) & (!tdp.isScaled())) { + setCd(x + width/2 - w1/2, y); + width = w1; + //updateConnectingPoints(); + } + + if (stateOfError > 0) { + Color c = g.getColor(); + switch(stateOfError) { + case ErrorHighlight.OK: + g.setColor(ColorManager.FOR); + break; + default: + g.setColor(ColorManager.UNKNOWN_BOX_ACTION); + } + g.fillRoundRect(x, y, width, height, arc, arc); + g.setColor(c); + } + + g.drawRoundRect(x, y, width, height, arc, arc); + g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); + g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); + g.drawLine(x+width, y+height/2, x+width +lineLength, y+height/2); + + g.drawString(value, x + (width - w) / 2 , y + textY); + } + + public boolean editOndoubleClick(JFrame frame) { + String [] labels = new String[3]; + String [] values = new String[3]; + labels[0] = "Initialisation of variables"; + values[0] = init; + labels[1] = "Condition to stay in loop"; + values[1] = condition; + labels[2] = "Increment at each loop"; + values[2] = increment; + + + JDialogMultiString jdms = new JDialogMultiString(frame, "Setting loop's properties", 3, labels, values); + jdms.setSize(350, 300); + GraphicLib.centerOnParent(jdms); + jdms.show(); // blocked until dialog has been closed + + if (jdms.hasBeenSet()) { + init = jdms.getString(0); + condition = jdms.getString(1); + increment = jdms.getString(2); + + makeValue(); + return true; + } + + return false; + + } + + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x+(width/2), y-lineLength, x+(width/2), y + lineLength + height, _x, _y)) < distanceSelected) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x+width, y+height/2, x+width +lineLength, y+height/2, _x, _y)) < distanceSelected) { + return this; + } + + return null; + } + + public void makeValue() { + value = "for(" + init + ";" + condition + ";" + increment + ")"; + } + + public String getAction() { + return value; + } + + public String getInit() { + return init; + } + + public String getCondition() { + return condition; + } + + public String getIncrement() { + return increment; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<Data init=\""); + sb.append(getInit()); + sb.append("\" condition=\""); + sb.append(GTURTLEModeling.transformString(getCondition())); + sb.append("\" increment=\""); + sb.append(getIncrement()); + sb.append("\" />\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro *** " + getId()); + try { + + NodeList nli; + Node n1, n2; + Element elt; + int k; + String s; + + //System.out.println("Loading Synchronization gates"); + //System.out.println(nl.toString()); + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + //System.out.println(n1); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; i<nli.getLength(); i++) { + n2 = nli.item(i); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("Data")) { + init = elt.getAttribute("init"); + condition = elt.getAttribute("condition"); + increment = elt.getAttribute("increment"); + } + + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + makeValue(); + } + + + public int getType() { + return TGComponentManager.EBRDD_FOR_LOOP; + } + + public int getDefaultConnector() { + return TGComponentManager.CONNECTOR_EBRDD; + } + + public void setStateAction(int _stateAction) { + stateOfError = _stateAction; + } + + +} diff --git a/src/ui/ebrdd/EBRDDPanel.java b/src/ui/ebrdd/EBRDDPanel.java new file mode 100644 index 0000000000..bde7b984c9 --- /dev/null +++ b/src/ui/ebrdd/EBRDDPanel.java @@ -0,0 +1,197 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + * + * /** + * Class EBRDDPanel + * Panel used for drawing EBRDDs + * Creation: 08/09/2009 + * @version 1.0 08/09/2009 + * @author Ludovic APVRILLE + * @see + */ + +package ui.ebrdd; + +//import java.awt.*; +import java.util.*; + +//import org.w3c.dom.*; +//import org.xml.sax.*; +//import javax.xml.parsers.*; + +import ui.*; + +public class EBRDDPanel extends TDiagramPanel { + + public EBRDDPanel(MainGUI mgui, TToolBar _ttb) { + super(mgui, _ttb); + addComponent(400, 50, TGComponentManager.EBRDD_START_STATE, false); + TDiagramMouseManager tdmm = new TDiagramMouseManager(this); + addMouseListener(tdmm); + addMouseMotionListener(tdmm); + } + + public boolean actionOnDoubleClick(TGComponent tgc) { + return false; + } + + public boolean actionOnAdd(TGComponent tgc) { + return false; + } + public boolean actionOnValueChanged(TGComponent tgc) { + return false; + } + + public boolean actionOnRemove(TGComponent tgc) { + return false; + } + + public String getXMLHead() { + return "<EBRDDPanel name=\"" + name + "\"" + sizeParam() + " >"; + } + + public String getXMLTail() { + return "</EBRDDPanel>"; + } + + public String getXMLSelectedHead() { + return "<EBRDDPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; + } + + public String getXMLSelectedTail() { + return "</EBRDDPanelCopy>"; + } + + public String getXMLCloneHead() { + return "<EBRDDPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; + } + + public String getXMLCloneTail() { + return "</EBRDDPanelCopy>"; + } + + public void makeGraphicalOptimizations() { + // Segments of connector that mask components + + // Components over others + + // Position correctly guards of choice + } + + public void enhance() { + //System.out.println("enhance"); + Vector v = new Vector(); + Object o; + Iterator iterator = componentList.listIterator(); + + while(iterator.hasNext()) { + o = iterator.next(); + if (o instanceof EBRDDStartState){ + enhance(v, (EBRDDStartState)o); + } + } + + mgui.changeMade(this, MOVE_CONNECTOR); + repaint(); + } + + public void enhance(Vector v, TGComponent tgc) { + TGComponent tgc1; + TGConnector tgcon; + int i; + + //System.out.println("Enhancing: " + tgc); + + if (tgc == null) { + return; + } + + if (v.contains(tgc)) { + return; + } + + v.add(tgc); + + //System.out.println("Nb of nexts: " + tgc.getNbNext()); + if (!(tgc instanceof EBRDDStartState)) { + for(i=0; i<tgc.getNbNext(); i++) { + tgc1 = getNextTGComponent(tgc, i); + tgcon = getNextTGConnector(tgc, i); + if (tgcon.getAutomaticDrawing()) { + if ((tgc1 != null) && (tgcon != null)) { + tgcon.alignOrMakeSquareTGComponents(); + } + } + } + } + + // Explore next elements + for(i=0; i<tgc.getNbNext(); i++) { + tgc1 = getNextTGComponent(tgc, i); + enhance(v, tgc1); + } + } + + public boolean hasAutoConnect() { + return true; + } + + public void setConnectorsToFront() { + TGComponent tgc; + + //System.out.println("list size=" + componentList.size()); + + Iterator iterator = componentList.listIterator(); + + ArrayList<TGComponent> list = new ArrayList<TGComponent>(); + + while(iterator.hasNext()) { + tgc = (TGComponent)(iterator.next()); + if (!(tgc instanceof TGConnector)) { + list.add(tgc); + } + } + + //System.out.println("Putting to back ..."); + for(TGComponent tgc1: list) { + //System.out.println("Putting to back: " + tgc1); + componentList.remove(tgc1); + componentList.add(tgc1); + } + } + +} diff --git a/src/ui/ebrdd/EBRDDSequence.java b/src/ui/ebrdd/EBRDDSequence.java new file mode 100644 index 0000000000..3c180c6f26 --- /dev/null +++ b/src/ui/ebrdd/EBRDDSequence.java @@ -0,0 +1,117 @@ +/** +Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** +* Class EBRDDSequence +* Sequence. To be used in EBRDDs +* Creation: 09/09/2009 +* @version 1.0 09/09/2009 +* @author Ludovic APVRILLE +* @see +*/ + +package ui.ebrdd; + +import java.awt.*; + +import myutil.*; +import ui.*; + +public class EBRDDSequence extends TGCWithInternalComponent implements EmbeddedComment, AllowedBreakpoint { + private int lineLength = 0; + private int textX, textY; + + public EBRDDSequence(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + + width = 150; + height = 5; + + textX = width - 6; + textY = height + 2; + + nbConnectingPoint = 6; + connectingPoint = new TGConnectingPoint[6]; + connectingPoint[0] = new TGConnectingPointEBRDD(this, 0, -lineLength, true, false, 0.5, 0.0); + connectingPoint[1] = new TGConnectingPointEBRDD(this, 0, lineLength, false, true, 0.167, 1.0); + connectingPoint[2] = new TGConnectingPointEBRDD(this, 0, lineLength, false, true, 0.333, 1.0); + connectingPoint[3] = new TGConnectingPointEBRDD(this, 0, lineLength, false, true, 0.5, 1.0); + connectingPoint[4] = new TGConnectingPointEBRDD(this, 0, lineLength, false, true, 0.667, 1.0); + connectingPoint[5] = new TGConnectingPointEBRDD(this, 0, lineLength, false, true, 0.833, 1.0); + + nbInternalTGComponent = 1; + tgcomponent = new TGComponent[nbInternalTGComponent]; + + TGCOneLineText tgc = new TGCOneLineText(x+textX + 10, y+textY, textX +10 , textX + 10 , textY, textY, true, this, _tdp); + tgc.setValue(">>"); + tgc.setName("Sequence"); + tgc.setEditable(false); + + tgcomponent[0] = tgc; + + moveable = true; + editable = false; + removable = true; + + name = "sequence"; + + myImageIcon = IconManager.imgic206; + } + + public void internalDrawing(Graphics g) { + g.drawRect(x, y, width, height); + g.fillRect(x, y, width, height); + } + + public TGComponent isOnOnlyMe(int x1, int y1) { + if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { + return this; + } + return null; + } + + public int getType() { + return TGComponentManager.EBRDD_SEQUENCE; + } + + public int getDefaultConnector() { + return TGComponentManager.CONNECTOR_EBRDD; + } + +} diff --git a/src/ui/ebrdd/EBRDDStartState.java b/src/ui/ebrdd/EBRDDStartState.java new file mode 100755 index 0000000000..c1ed1bfc01 --- /dev/null +++ b/src/ui/ebrdd/EBRDDStartState.java @@ -0,0 +1,104 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + * + * /** + * Class EBRDDStartState + * Used to start a new activity of an EBRDD + * Creation: 08/09/2009 + * @version 1.0 08/09/2009 + * @author Ludovic APVRILLE + * @see + */ + +package ui.ebrdd; + +import java.awt.*; +import java.awt.geom.*; + +import myutil.*; +import ui.*; + +public class EBRDDStartState extends TGCWithoutInternalComponent implements EmbeddedComment{ + private int lineLength = 5; + + public EBRDDStartState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + width = 15; + height = 15; + + nbConnectingPoint = 1; + connectingPoint = new TGConnectingPoint[1]; + connectingPoint[0] = new TGConnectingPointEBRDD(this, 0, lineLength, false, true, 0.5, 1.0); + + nbInternalTGComponent = 0; + + moveable = true; + editable = false; + removable = true; + + name = "start state"; + + myImageIcon = IconManager.imgic222; + } + + public void internalDrawing(Graphics g) { + g.fillOval(x, y, width, height); + g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); + } + + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + + if ((int)(Line2D.ptSegDistSq(x+(width/2), y+height, x+(width/2), y + lineLength + height, _x, _y)) < distanceSelected) { + return this; + } + + return null; + } + + public int getType() { + return TGComponentManager.EBRDD_START_STATE; + } + + public int getDefaultConnector() { + return TGComponentManager.CONNECTOR_EBRDD; + } + +} diff --git a/src/ui/ebrdd/EBRDDStopState.java b/src/ui/ebrdd/EBRDDStopState.java new file mode 100755 index 0000000000..7b66c4718d --- /dev/null +++ b/src/ui/ebrdd/EBRDDStopState.java @@ -0,0 +1,109 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + * + * /** + * Class EBRDDStopState + * Used to terminate an activity of an EBRDD. + * Creation: 08/09/2009 + * @version 1.0 08/09/2009 + * @author Ludovic APVRILLE + * @see + */ + +package ui.ebrdd; + +import java.awt.*; + +import myutil.*; +import ui.*; + +public class EBRDDStopState extends TGCWithoutInternalComponent implements EmbeddedComment, AllowedBreakpoint { + private int internalCircleSize = 16; + private int lineLength = 5; + + public EBRDDStopState(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + width = 20; + height = 20; + + nbConnectingPoint = 1; + connectingPoint = new TGConnectingPoint[1]; + connectingPoint[0] = new TGConnectingPointEBRDD(this, 0, - lineLength, true, false, 0.5, 0.0); + + nbInternalTGComponent = 0; + + moveable = true; + editable = false; + removable = true; + + name = "stop state"; + + myImageIcon = IconManager.imgic210; + } + + public void internalDrawing(Graphics g) { + ColorManager.setColor(g, state, 0); + g.fillOval(x + (width - internalCircleSize)/2, y + (height - internalCircleSize)/2, internalCircleSize, internalCircleSize); + g.drawOval(x, y, width, height); + g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); + } + + + public TGComponent isOnMe(int _x, int _y) { + if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { + return this; + } + return null; + } + + public int getType() { + return TGComponentManager.EBRDD_STOP_STATE; + } + + public int getDefaultConnector() { + return TGComponentManager.CONNECTOR_EBRDD; + } + +} + + + + + + + diff --git a/src/ui/ebrdd/EBRDDToolBar.java b/src/ui/ebrdd/EBRDDToolBar.java new file mode 100755 index 0000000000..1d1e233800 --- /dev/null +++ b/src/ui/ebrdd/EBRDDToolBar.java @@ -0,0 +1,147 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** + * Class EBRDDToolBar + * Toolbar associated with EBRDD + * Creation: 08/09/2009 + * @version 1.0 08/09/2009 + * @author Ludovic APVRILLE + * @see + */ + +package ui.ebrdd; + +import javax.swing.*; +//import java.awt.*; +//import java.awt.event.*; + +import ui.*; + +public class EBRDDToolBar extends TToolBar { + + + public EBRDDToolBar(MainGUI _mgui) { + super(_mgui); + } + + protected void setActive(boolean b) { + mgui.actions[TGUIAction.EBRDD_EDIT].setEnabled(b); + mgui.actions[TGUIAction.UML_NOTE].setEnabled(b); + mgui.actions[TGUIAction.EBRDD_CONNECTOR].setEnabled(b); + mgui.actions[TGUIAction.EBRDD_START].setEnabled(b); + mgui.actions[TGUIAction.EBRDD_STOP].setEnabled(b); + mgui.actions[TGUIAction.EBRDD_ACTION].setEnabled(b); + mgui.actions[TGUIAction.EBRDD_CHOICE].setEnabled(b); + mgui.actions[TGUIAction.EBRDD_FOR_LOOP].setEnabled(b); + mgui.actions[TGUIAction.EBRDD_SEQUENCE].setEnabled(b); + mgui.actions[TGUIAction.EBRDD_ERC].setEnabled(b); + mgui.actions[TGUIAction.EBRDD_CONNECTOR_ERC].setEnabled(b); + mgui.actions[TGUIAction.EBRDD_ESO].setEnabled(b); + mgui.actions[TGUIAction.EBRDD_ERB].setEnabled(b); + + mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(false); + mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(false); + mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(false); + mgui.updateZoomInfo(); + } + + protected void setButtons() { + JButton button; + + button = this.add(mgui.actions[TGUIAction.EBRDD_EDIT]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.UML_NOTE]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.EBRDD_CONNECTOR]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.EBRDD_START]); + button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.EBRDD_STOP]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.EBRDD_ACTION]); + button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.EBRDD_CHOICE]); + button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.EBRDD_FOR_LOOP]); + button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.EBRDD_SEQUENCE]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.EBRDD_ERC]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.EBRDD_CONNECTOR_ERC]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.EBRDD_ESO]); + button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.EBRDD_ERB]); + button.addMouseListener(mgui.mouseHandler); + + } +} // Class + + + + + diff --git a/src/ui/ebrdd/TGConnectingPointEBRDD.java b/src/ui/ebrdd/TGConnectingPointEBRDD.java new file mode 100755 index 0000000000..294e6670ac --- /dev/null +++ b/src/ui/ebrdd/TGConnectingPointEBRDD.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. + +/** + * Class TGConnectingPointEBRDD + * Definition of connecting points on which connectors of EBRDD can be connected + * Creation: 08/09/2009 + * @version 1.0 08/09/2009 + * @author Ludovic APVRILLE + * @see + */ + +package ui.ebrdd; + +//import java.awt.*; +import ui.*; + +public class TGConnectingPointEBRDD extends TGConnectingPointWidthHeight{ + + public TGConnectingPointEBRDD(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) { + if (type == TGComponentManager.CONNECTOR_EBRDD) { + return true; + } + return false; + } + +} + + + + + + + diff --git a/src/ui/ebrdd/TGConnectingPointEBRDDERC.java b/src/ui/ebrdd/TGConnectingPointEBRDDERC.java new file mode 100755 index 0000000000..a53245f6e3 --- /dev/null +++ b/src/ui/ebrdd/TGConnectingPointEBRDDERC.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. + +/** + * Class TGConnectingPointEBRDDERC + * Definition of connecting points on which connectors of EBRDD can be connected + * Creation: 09/09/2009 + * @version 1.0 09/09/2009 + * @author Ludovic APVRILLE + * @see + */ + +package ui.ebrdd; + +//import java.awt.*; +import ui.*; + +public class TGConnectingPointEBRDDERC extends TGConnectingPointWidthHeight{ + + public TGConnectingPointEBRDDERC(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) { + if (type == TGComponentManager.CONNECTOR_EBRDD_ERC) { + return true; + } + return false; + } + +} + + + + + + + diff --git a/src/ui/ebrdd/TGConnectorEBRDD.java b/src/ui/ebrdd/TGConnectorEBRDD.java new file mode 100755 index 0000000000..0abf8dba0f --- /dev/null +++ b/src/ui/ebrdd/TGConnectorEBRDD.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. + +/** + * Class TGConnectorEBRDD + * Basic connector with a full arrow at the end. Used in EBRDDs. + * Creation: 08/09/2009 + * @version 1.0 08/09/2009 + * @author Ludovic APVRILLE + * @see + */ + +package ui.ebrdd; + +import java.awt.*; +import java.awt.geom.*; +import java.util.*; + +import myutil.*; +import ui.*; + +public class TGConnectorEBRDD extends TGConnector { + protected int arrowLength = 10; + + public TGConnectorEBRDD(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector _listPoint) { + super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); + myImageIcon = IconManager.imgic202; + } + + protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ + if (Point2D.distance(x1, y1, x2, y2) < GraphicLib.longueur * 1.5) { + g.drawLine(x1, y1, x2, y2); + } else { + GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, x2, y2, true); + } + } + + public int getType() { + return TGComponentManager.CONNECTOR_EBRDD; + } +} + + + + + + + diff --git a/src/ui/ebrdd/TGConnectorEBRDDERC.java b/src/ui/ebrdd/TGConnectorEBRDDERC.java new file mode 100755 index 0000000000..8944fee475 --- /dev/null +++ b/src/ui/ebrdd/TGConnectorEBRDDERC.java @@ -0,0 +1,148 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + +ludovic.apvrille AT enst.fr + +This software is a computer program whose purpose is to allow the +edition of TURTLE analysis, design and deployment diagrams, to +allow the generation of RT-LOTOS or Java code from this diagram, +and at last to allow the analysis of formal validation traces +obtained from external tools, e.g. RTL from LAAS-CNRS and CADP +from INRIA Rhone-Alpes. + +This software is governed by the CeCILL license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +/** + * Class TGConnectorEBRDDERC + * Basic connector with a full arrow at the end. Used in EBRDDs. + * Creation: 09/09/2009 + * @version 1.0 09/09/2009 + * @author Ludovic APVRILLE + * @see + */ + +package ui.ebrdd; + +import java.awt.*; +import java.awt.geom.*; +import java.util.*; + +import myutil.*; +import ui.*; + +import org.w3c.dom.*; + +public class TGConnectorEBRDDERC extends TGConnector { + protected int arrowLength = 10; + protected boolean negation = false; + protected static int negateSize = 10; + + public TGConnectorEBRDDERC(int _x, int _y, int _minX, int _minY, int _maxX, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp, TGConnectingPoint _p1, TGConnectingPoint _p2, Vector _listPoint) { + super(_x, _y, _minX, _minY, _maxX, _maxY, _pos, _father, _tdp, _p1, _p2, _listPoint); + myImageIcon = IconManager.imgic202; + } + + protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ + if (Point2D.distance(x1, y1, x2, y2) < GraphicLib.longueur * 1.5) { + g.drawLine(x1, y1, x2, y2); + } else { + GraphicLib.arrowWithLine(g, 1, 0, 10, x1, y1, x2, y2, true); + } + if (negation) { + g.drawOval((x1+x2-negateSize)/2, (y1+y2-negateSize)/2, negateSize, negateSize); + } + } + + public int getType() { + return TGComponentManager.CONNECTOR_EBRDD_ERC; + } + + public void reverseNegation() { + negation = !negation; + } + + public boolean canBeNegated() { + return true; + } + + public boolean getNegation() { + return negation; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<negation value=\"" + negation); + sb.append("\" />\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + //System.out.println("*** load extra synchro ***"); + try { + + NodeList nli; + Node n1, n2; + Element elt; + + String val = null; + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + //System.out.println(n1); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; i<nli.getLength(); i++) { + n2 = nli.item(i); + //System.out.println(n2); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("negation")) { + val = elt.getAttribute("value").trim(); + //System.out.println("val=" + val); + if (val.equals("false")) { + negation = false; + } else { + negation = true; + } + } + } + } + } + } + + } catch (Exception e) { + throw new MalformedModelingException(); + } + } +} + + + + + + + diff --git a/src/ui/images/ebrdderb.gif b/src/ui/images/ebrdderb.gif new file mode 100755 index 0000000000000000000000000000000000000000..3108d143827efe67ca88a18084f51c9e81f96746 GIT binary patch literal 136 zcmZ?wbhEHb<Yy3Ic+AKE1poj4KX?BZ1E&asuqK0$8iRlm1HS?Tw>VH76Da;<0czrB z&;jWLnZdwf`r)MK>e>f!3T8hNet6DFn5WUsIn!cQR{OjSugjj!d8G4fox@DNYnvI9 T`DMA&g-a)$n)ytKk--`O1l~Fe literal 0 HcmV?d00001 diff --git a/src/ui/images/ebrdderc.gif b/src/ui/images/ebrdderc.gif new file mode 100755 index 0000000000000000000000000000000000000000..312043e048243750f7cdec59f955b6bf6bfdafb7 GIT binary patch literal 99 zcmZ?wbhEHb<Yy3ISjfl#1poj4KX?BZkW~E10u*3o&;f~p<QbSu=Jc;*-mM@qW6LeI xP4_B|{A+nvIHp;eEn<*NF)6*MZj|$uch<SZenp&Z7CMi3D*i}LYGY!s1^{$JB6t7* literal 0 HcmV?d00001 diff --git a/src/ui/images/ebrddeso.gif b/src/ui/images/ebrddeso.gif new file mode 100755 index 0000000000000000000000000000000000000000..3606c41c88efb01689d22be883f94ffc398c2719 GIT binary patch literal 127 zcmZ?wbhEHb<Yy3Ic+AKE1poj4KX?BZ1E&asuqK0$8iRlm1HS?Tw>SfbAW#YoDE?#t zYT{?m0qF#p!N8*P;iTv4y%w*}?q(HIXcAZOaH^7XDcsZE*zq}qt9)JC@}EEKPQ5hL Msp>nC!opw;0MraJp#T5? literal 0 HcmV?d00001 diff --git a/src/ui/images/ercconnector.gif b/src/ui/images/ercconnector.gif new file mode 100755 index 0000000000000000000000000000000000000000..2aec14220ee50fa3325d4841b94d6eeaa016b69e GIT binary patch literal 136 zcmZ?wbhEHb<Yy3Ic+AKE1poj4KX?BZ1E&asuqK0$8iRlm1HS?Tw>SfbAW#YoDE?#t zYT{?m0qF#p!N6kr;iTv4y%w)|4%E$iP}r}~tIRrM`Ay#gjw0^05+3a<ob<mnFs^1b VR&Co5oLO0^Xt=jOM2eBY8UU{DG%x@F literal 0 HcmV?d00001 diff --git a/src/ui/tmldd/TMLArchiMemoryNode.java b/src/ui/tmldd/TMLArchiMemoryNode.java index 4f6e16c45c..45576948f2 100755 --- a/src/ui/tmldd/TMLArchiMemoryNode.java +++ b/src/ui/tmldd/TMLArchiMemoryNode.java @@ -73,7 +73,7 @@ public class TMLArchiMemoryNode extends TMLArchiCommunicationNode implements Swa width = 200; height = 200; minWidth = 100; - minHeight = 100; + minHeight = 50; nbConnectingPoint = 16; connectingPoint = new TGConnectingPoint[16]; diff --git a/src/ui/window/JDialogERB.java b/src/ui/window/JDialogERB.java new file mode 100644 index 0000000000..7e15c9a201 --- /dev/null +++ b/src/ui/window/JDialogERB.java @@ -0,0 +1,200 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + * + * /** + * Class JDialogERB + * Dialog for managing attributes of Event Reaction Blocks (ERC) + * Creation: 10/09/2009 + * @version 1.0 10/09/2009 + * @author Ludovic APVRILLE + * @see + */ + +package ui.window; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +//import javax.swing.event.*; +//import java.util.*; + +import ui.*; +import ui.ebrdd.*; + +import ui.tmldd.*; + + +public class JDialogERB extends javax.swing.JDialog implements ActionListener { + + private boolean regularClose; + + private JPanel panel2; + private Frame frame; + private EBRDDERB erb; + + // Panel + protected JTextField evt, condition, action; + + // Main Panel + private JButton closeButton; + private JButton cancelButton; + + + /** Creates new form */ + public JDialogERB(Frame _frame, EBRDDERB _erb) { + super(_frame, "Event Reaction Block", true); + frame = _frame; + erb = _erb; + + initComponents(); + myInitComponents(); + pack(); + } + + private void myInitComponents() { + } + + private void initComponents() { + Container c = getContentPane(); + GridBagLayout gridbag0 = new GridBagLayout(); + GridBagLayout gridbag1 = new GridBagLayout(); + GridBagLayout gridbag2 = new GridBagLayout(); + GridBagConstraints c0 = new GridBagConstraints(); + //GridBagConstraints c1 = new GridBagConstraints(); + GridBagConstraints c2 = new GridBagConstraints(); + + setFont(new Font("Helvetica", Font.PLAIN, 14)); + c.setLayout(gridbag0); + + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + + panel2 = new JPanel(); + panel2.setLayout(gridbag2); + panel2.setBorder(new javax.swing.border.TitledBorder("ERB attributes")); + panel2.setPreferredSize(new Dimension(400, 300)); + + c2.gridwidth = 1; + c2.gridheight = 1; + c2.weighty = 1.0; + c2.weightx = 1.0; + c2.fill = GridBagConstraints.HORIZONTAL; + + c2.gridwidth = 1; + panel2.add(new JLabel("Event:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + evt = new JTextField(""+erb.getEvent(), 30); + panel2.add(evt, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Condititon:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + condition = new JTextField(""+erb.getCondition(), 30); + panel2.add(condition, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Action:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + action = new JTextField(""+erb.getAction(), 30); + panel2.add(action, c2); + + // main panel; + c0.gridheight = 10; + c0.weighty = 1.0; + c0.weightx = 1.0; + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + c.add(panel2, c0); + + c0.gridwidth = 1; + c0.gridheight = 1; + c0.fill = GridBagConstraints.HORIZONTAL; + closeButton = new JButton("Save and Close", IconManager.imgic25); + //closeButton.setPreferredSize(new Dimension(600, 50)); + closeButton.addActionListener(this); + c.add(closeButton, c0); + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + cancelButton = new JButton("Cancel", IconManager.imgic27); + cancelButton.addActionListener(this); + c.add(cancelButton, c0); + } + + + public void actionPerformed(ActionEvent evt) { + /* if (evt.getSource() == typeBox) { + boolean b = ((Boolean)(initValues.elementAt(typeBox.getSelectedIndex()))).booleanValue(); + initialValue.setEnabled(b); + return; + }*/ + + + String command = evt.getActionCommand(); + + // Compare the action command to the known actions. + if (command.equals("Save and Close")) { + closeDialog(); + } else if (command.equals("Cancel")) { + cancelDialog(); + } + } + + public void closeDialog() { + regularClose = true; + dispose(); + } + + public void cancelDialog() { + dispose(); + } + + public boolean isRegularClose() { + return regularClose; + } + + public String getEvent() { + return evt.getText(); + } + + public String getCondition() { + return condition.getText(); + } + + public String getAction() { + return action.getText(); + } + + +} diff --git a/src/ui/window/JDialogESO.java b/src/ui/window/JDialogESO.java new file mode 100644 index 0000000000..aca4dbe202 --- /dev/null +++ b/src/ui/window/JDialogESO.java @@ -0,0 +1,243 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + * + * /** + * Class JDialogESO + * Dialog for managing attributes of Event Sequence Operators (ESO) + * Creation: 10/09/2009 + * @version 1.0 10/09/2009 + * @author Ludovic APVRILLE + * @see + */ + +package ui.window; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +//import javax.swing.event.*; +//import java.util.*; + +import ui.*; +import ui.ebrdd.*; + +import ui.tmldd.*; + + +public class JDialogESO extends javax.swing.JDialog implements ActionListener { + + private boolean regularClose; + + private JPanel panel2; + private Frame frame; + private EBRDDESO eso; + + // Panel + protected JTextField timeout, n ,m; + protected JComboBox ids, oncePerEvent; + + // Main Panel + private JButton closeButton; + private JButton cancelButton; + + + /** Creates new form */ + public JDialogESO(Frame _frame, EBRDDESO _eso) { + super(_frame, "Event Sequence Operator", true); + frame = _frame; + eso = _eso; + + initComponents(); + myInitComponents(); + pack(); + } + + private void myInitComponents() { + checkMode(); + } + + private void initComponents() { + Container c = getContentPane(); + GridBagLayout gridbag0 = new GridBagLayout(); + GridBagLayout gridbag1 = new GridBagLayout(); + GridBagLayout gridbag2 = new GridBagLayout(); + GridBagConstraints c0 = new GridBagConstraints(); + //GridBagConstraints c1 = new GridBagConstraints(); + GridBagConstraints c2 = new GridBagConstraints(); + + setFont(new Font("Helvetica", Font.PLAIN, 14)); + c.setLayout(gridbag0); + + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + + panel2 = new JPanel(); + panel2.setLayout(gridbag2); + panel2.setBorder(new javax.swing.border.TitledBorder("ESO attributes")); + panel2.setPreferredSize(new Dimension(400, 300)); + + c2.gridwidth = 1; + c2.gridheight = 1; + c2.weighty = 1.0; + c2.weightx = 1.0; + c2.fill = GridBagConstraints.HORIZONTAL; + panel2.add(new JLabel("Operator:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + ids = new JComboBox(EBRDDESO.ESOS); + /*for(int i=0; i<EBRDDESO.ESOS.length; i++) { + ids.addItem(EBRDDESO.ESOS[i]); + }*/ + ids.addActionListener(this); + ids.setSelectedIndex(eso.getID()); + panel2.add(ids, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Timeout:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + timeout = new JTextField(""+eso.getTimeout(), 15); + panel2.add(timeout, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("Once Per Event:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + oncePerEvent = new JComboBox(); + oncePerEvent.addItem("false"); + oncePerEvent.addItem("true"); + if (eso.getOncePerEvent()) { + oncePerEvent.setSelectedIndex(1); + } else { + oncePerEvent.setSelectedIndex(0); + } + panel2.add(oncePerEvent, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("At least:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + n = new JTextField(""+eso.getN(), 15); + panel2.add(n, c2); + + c2.gridwidth = 1; + panel2.add(new JLabel("At most:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + m = new JTextField(""+eso.getM(), 15); + panel2.add(m, c2); + + + // main panel; + c0.gridheight = 10; + c0.weighty = 1.0; + c0.weightx = 1.0; + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + c.add(panel2, c0); + + c0.gridwidth = 1; + c0.gridheight = 1; + c0.fill = GridBagConstraints.HORIZONTAL; + closeButton = new JButton("Save and Close", IconManager.imgic25); + //closeButton.setPreferredSize(new Dimension(600, 50)); + closeButton.addActionListener(this); + c.add(closeButton, c0); + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + cancelButton = new JButton("Cancel", IconManager.imgic27); + cancelButton.addActionListener(this); + c.add(cancelButton, c0); + } + + private void checkMode() { + if (timeout != null) { + int index = ids.getSelectedIndex(); + oncePerEvent.setEnabled(eso.hasOncePerEvent(index)); + timeout.setEnabled(eso.hasTimeout(index)); + n.setEnabled(eso.hasNM(index)); + m.setEnabled(eso.hasNM(index)); + } + } + + + public void actionPerformed(ActionEvent evt) { + /* if (evt.getSource() == typeBox) { + boolean b = ((Boolean)(initValues.elementAt(typeBox.getSelectedIndex()))).booleanValue(); + initialValue.setEnabled(b); + return; + }*/ + + checkMode(); + + String command = evt.getActionCommand(); + + // Compare the action command to the known actions. + if (command.equals("Save and Close")) { + closeDialog(); + } else if (command.equals("Cancel")) { + cancelDialog(); + } + } + + public void closeDialog() { + regularClose = true; + dispose(); + } + + public void cancelDialog() { + dispose(); + } + + public boolean isRegularClose() { + return regularClose; + } + + public int getID() { + return ids.getSelectedIndex(); + } + + public String getTimeout() { + return timeout.getText(); + } + + public boolean getOncePerEvent() { + return (oncePerEvent.getSelectedIndex() == 1); + } + + public String getN() { + return n.getText(); + } + + public String getM() { + return m.getText(); + } + +} -- GitLab