diff --git a/src/main/java/ui/MainGUI.java b/src/main/java/ui/MainGUI.java index 9b643b1e865395be170150ad46b452ae3c901462..cedd1e84bc52373245347b5171461c4ae616b248 100644 --- a/src/main/java/ui/MainGUI.java +++ b/src/main/java/ui/MainGUI.java @@ -2073,7 +2073,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per public void newMethodology() { // TraceManager.addDev("NEW DESIGN"); - addSysmlsecMethodologyPanel("Methodology", -1, true); + addSysmlsecMethodologyPanel("Methodology", -1, false); tabs.elementAt(tabs.size() - 1).tabbedPane.setSelectedIndex(0); mainTabbedPane.setSelectedIndex(tabs.size() - 1); // paneAction(null); diff --git a/src/main/java/ui/SysmlsecMethodologyPanel.java b/src/main/java/ui/SysmlsecMethodologyPanel.java index ea018e126462c6e31fb2625b957dcb25239b3894..63e7aab95ee78fe142feed2fa4ec49b8328e90d9 100644 --- a/src/main/java/ui/SysmlsecMethodologyPanel.java +++ b/src/main/java/ui/SysmlsecMethodologyPanel.java @@ -139,16 +139,13 @@ public class SysmlsecMethodologyPanel extends TURTLEPanel { p1 = tgc1.getTGConnectingPointAtIndex(0); p2 = tgc2.getTGConnectingPointAtIndex(0); Vector<Point> listPoint = new Vector<Point>(); - Point p = new Point(210, 235); - listPoint.add(p); - TGConnector tgco = TGComponentManager.addConnector(p1.getX(), p1.getY(), TGComponentManager.SYSMLSEC_METHODOLOGY_CONNECTOR, dmd, p1, p2, listPoint); - p1.setFree(false); - p2.setFree(false); - //dmd.getComponentList().add(0, tgco); + TGConnector tgco; + Point p; + // Reqs -> Attacks - p1 = tgc2.getTGConnectingPointAtIndex(1); - p2 = tgc10.getTGConnectingPointAtIndex(0); + p1 = tgc2.getTGConnectingPointAtIndex(9); + p2 = tgc10.getTGConnectingPointAtIndex(6); listPoint = new Vector<Point>(); //p = new Point(375, 370); //listPoint.add(p); @@ -158,8 +155,8 @@ public class SysmlsecMethodologyPanel extends TURTLEPanel { dmd.getComponentList().add(0, tgco); // Reqs -> Faults - p1 = tgc2.getTGConnectingPointAtIndex(4); - p2 = tgc12.getTGConnectingPointAtIndex(0); + p1 = tgc2.getTGConnectingPointAtIndex(6); + p2 = tgc12.getTGConnectingPointAtIndex(9); listPoint = new Vector<Point>(); tgco = TGComponentManager.addConnector(p1.getX(), p1.getY(), TGComponentManager.SYSMLSEC_METHODOLOGY_CONNECTOR, dmd, p1, p2, listPoint); p1.setFree(false); @@ -167,8 +164,8 @@ public class SysmlsecMethodologyPanel extends TURTLEPanel { dmd.getComponentList().add(0, tgco); // Faults -> Reqs - p1 = tgc12.getTGConnectingPointAtIndex(1); - p2 = tgc2.getTGConnectingPointAtIndex(3); + p1 = tgc12.getTGConnectingPointAtIndex(11); + p2 = tgc2.getTGConnectingPointAtIndex(8); listPoint = new Vector<Point>(); //p = new Point(375, 370); //listPoint.add(p); @@ -178,8 +175,8 @@ public class SysmlsecMethodologyPanel extends TURTLEPanel { dmd.getComponentList().add(0, tgco); // Attacks -> Reqs - p1 = tgc10.getTGConnectingPointAtIndex(1); - p2 = tgc2.getTGConnectingPointAtIndex(2); + p1 = tgc10.getTGConnectingPointAtIndex(8); + p2 = tgc2.getTGConnectingPointAtIndex(11); listPoint = new Vector<Point>(); //p = new Point(375, 370); //listPoint.add(p); @@ -189,7 +186,7 @@ public class SysmlsecMethodologyPanel extends TURTLEPanel { dmd.getComponentList().add(0, tgco); // Analysis -> Design - p1 = tgc3.getTGConnectingPointAtIndex(1); + p1 = tgc3.getTGConnectingPointAtIndex(9); p2 = tgc4.getTGConnectingPointAtIndex(0); listPoint = new Vector<Point>(); p = new Point(xa + 60, ya + 125); @@ -200,7 +197,7 @@ public class SysmlsecMethodologyPanel extends TURTLEPanel { dmd.getComponentList().add(0, tgco); // Design -> Prototyping - p1 = tgc4.getTGConnectingPointAtIndex(1); + p1 = tgc4.getTGConnectingPointAtIndex(9); p2 = tgc5.getTGConnectingPointAtIndex(0); listPoint = new Vector<Point>(); p = new Point(xa + 160, ya + 225); @@ -211,7 +208,7 @@ public class SysmlsecMethodologyPanel extends TURTLEPanel { dmd.getComponentList().add(0, tgco); // Reqs -> Prop - p1 = tgc2.getTGConnectingPointAtIndex(0); + p1 = tgc2.getTGConnectingPointAtIndex(4); p2 = tgc6.getTGConnectingPointAtIndex(0); listPoint = new Vector<Point>(); p = new Point(xa - 305, 385); @@ -225,7 +222,7 @@ public class SysmlsecMethodologyPanel extends TURTLEPanel { // Partitioning // App -> mapping - p1 = tgc7.getTGConnectingPointAtIndex(0); + p1 = tgc7.getTGConnectingPointAtIndex(10); p2 = tgc9.getTGConnectingPointAtIndex(0); listPoint = new Vector<Point>(); tgco = TGComponentManager.addConnector(p1.getX(), p1.getY(), TGComponentManager.DIPLODOCUSMETHODOLOGY_CONNECTOR, dmd, p1, p2, listPoint); @@ -234,8 +231,8 @@ public class SysmlsecMethodologyPanel extends TURTLEPanel { dmd.getComponentList().add(0, tgco); // cp -> mapping - p1 = tgc11.getTGConnectingPointAtIndex(0); - p2 = tgc9.getTGConnectingPointAtIndex(2); + p1 = tgc11.getTGConnectingPointAtIndex(10); + p2 = tgc9.getTGConnectingPointAtIndex(7); listPoint = new Vector<Point>(); tgco = TGComponentManager.addConnector(p1.getX(), p1.getY(), TGComponentManager.DIPLODOCUSMETHODOLOGY_CONNECTOR, dmd, p1, p2, listPoint); p1.setFree(false); @@ -243,8 +240,8 @@ public class SysmlsecMethodologyPanel extends TURTLEPanel { dmd.getComponentList().add(0, tgco); // Archi -> mapping - p1 = tgc8.getTGConnectingPointAtIndex(0); - p2 = tgc9.getTGConnectingPointAtIndex(1); + p1 = tgc8.getTGConnectingPointAtIndex(10); + p2 = tgc9.getTGConnectingPointAtIndex(3); listPoint = new Vector<Point>(); tgco = TGComponentManager.addConnector(p1.getX(), p1.getY(), TGComponentManager.DIPLODOCUSMETHODOLOGY_CONNECTOR, dmd, p1, p2, listPoint); p1.setFree(false); diff --git a/src/main/java/ui/TGCPanelInfo.java b/src/main/java/ui/TGCPanelInfo.java index 66035a367d2cb8c53fd7d3743b3362f64aba7c2d..e5c03eb7805f69717a5c2581c92269a00178440d 100644 --- a/src/main/java/ui/TGCPanelInfo.java +++ b/src/main/java/ui/TGCPanelInfo.java @@ -42,6 +42,7 @@ import java.awt.Color; import java.awt.Font; import java.awt.Graphics; +import myutil.Conversion; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -52,6 +53,10 @@ import ui.atd.ATDConstraint; import ui.atd.ATDCountermeasure; import ui.sysmlsecmethodology.SysmlsecMethodologyDiagramReference; import ui.util.IconManager; +import ui.window.JDialogInfoPanel; +import ui.window.JDialogManageListOfString; + +import javax.swing.*; /** * Class TGCPanelInfo @@ -71,6 +76,10 @@ public class TGCPanelInfo extends TGCScalableWithInternalComponent implements Sw public final static int LOWER_LEFT = 7; public final static int LOWER_MIDDLE = 8; public final static int LOWER_RIGHT = 9; + + + public final String[] TEXT_POSITIONS = {"Upper left", "Upper middle", "Upper right", "Middle left", "Middle", + "Middle right", "Lower left", "Lower middle", "Lower right"}; // Issue #31 private static final int MARGIN_X = 5; @@ -123,8 +132,8 @@ public class TGCPanelInfo extends TGCScalableWithInternalComponent implements Sw } moveable = true; - editable = false; - removable = false; + editable = true; + removable = true; userResizable = true; name = "Info"; @@ -212,6 +221,27 @@ public class TGCPanelInfo extends TGCScalableWithInternalComponent implements Sw return null; } + @Override + public boolean editOnDoubleClick(JFrame frame) { + String oldValue = value; + + JDialogInfoPanel jdip = new JDialogInfoPanel(frame, "Attributes", value, TEXT_POSITIONS, stringPos-1); + GraphicLib.centerOnParent(jdip, 550, 350); + jdip.setVisible( true ); + + if (jdip.isRegularClose()) { + value = jdip.getValue().trim(); + if (value.length() == 0) { + value = oldValue; + } + stringPos = jdip.getSelectedIndex() + 1; + return true; + } + + return false; + } + + public boolean acceptSwallowedTGComponent(TGComponent tgc) { return tgc instanceof SysmlsecMethodologyDiagramReference; @@ -269,6 +299,7 @@ public class TGCPanelInfo extends TGCScalableWithInternalComponent implements Sw // //value = ""; StringBuffer sb = new StringBuffer("<extraparam>\n"); + sb.append("<TextPos value=\"" + stringPos + "\" />\n"); sb.append("<TextColor value=\"" + textColor.getRGB() + "\" />\n"); sb.append("</extraparam>\n"); @@ -298,6 +329,12 @@ public class TGCPanelInfo extends TGCScalableWithInternalComponent implements Sw s = elt.getAttribute("value"); textColor = new Color(Integer.decode(s).intValue()); } + + if (elt.getTagName().equals("TextPos")) { + s = elt.getAttribute("value"); + stringPos = Integer.decode(s); + } + } } } diff --git a/src/main/java/ui/TGUIAction.java b/src/main/java/ui/TGUIAction.java index a307687c2e642df4611ffbb9c1108b5e4feae67a..b9b014ee8f4d1e9165dadac50a40665ab3253944 100644 --- a/src/main/java/ui/TGUIAction.java +++ b/src/main/java/ui/TGUIAction.java @@ -1521,9 +1521,9 @@ public class TGUIAction extends AbstractAction { actions[M_REF_MAPPING] = new TAction("add-ref-mapping", "Add reference to a mapping", IconManager.imgic426, IconManager.imgic426, "Reference to a mapping", "Add a reference to a mapping", 0); - actions[M_PANEL_INFO] = new TAction("add-diag-name", "Add a diagram name", IconManager.imgic426, + actions[M_PANEL_INFO] = new TAction("add-info-comp", "Add an information component", IconManager.imgic426, IconManager.imgic426, - "diagram name", "Add a diagram name", 0); + "Information", "Add a information component", 0); } diff --git a/src/main/java/ui/window/JDialogInfoPanel.java b/src/main/java/ui/window/JDialogInfoPanel.java new file mode 100644 index 0000000000000000000000000000000000000000..914c13584b06cbcb5fccbd975ed42043b6eef81f --- /dev/null +++ b/src/main/java/ui/window/JDialogInfoPanel.java @@ -0,0 +1,185 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package ui.window; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + + + + +/** + * Class JDialogInfoPanel + * Dialog for managing attributes of info panels (e.g. methods) + * Creation: 22/06/2021 + * @version 1.0 22/06/2021 + * @author Ludovic APVRILLE + */ +public class JDialogInfoPanel extends JDialogBase implements ActionListener { + + private boolean regularClose; + + private JPanel panel2; + private Frame frame; + private String variable, minValue, maxValue, extraAttribute1, extraAttribute2; + + private int functionId; + + + // Panel2 + private JTextField valueField; + private JComboBox<String> positionBox; + + private String value; + private String[] possiblePositions; + private int selectedPosition; + + /* Creates new form */ + public JDialogInfoPanel(Frame _frame, String _title, String _value, + String[] _possiblePositions, int _selectedPosition) { + super(_frame, _title, true); + frame = _frame; + + value = _value; + possiblePositions = _possiblePositions; + selectedPosition = _selectedPosition; + + 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("RANDOM Attributes")); + panel2.setPreferredSize(new Dimension(250, 200)); + + c2.gridwidth = 1; + c2.gridheight = 1; + c2.weighty = 1.0; + c2.weightx = 1.0; + c2.fill = GridBagConstraints.HORIZONTAL; + panel2.add(new JLabel("Identifier:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + valueField = new JTextField(value, 30); + valueField.setEditable(true); + valueField.setFont(new Font("times", Font.PLAIN, 12)); + panel2.add(valueField, c2); + + + c2.gridwidth = 1; + panel2.add(new JLabel("Text position:"), c2); + c2.gridwidth = GridBagConstraints.REMAINDER; //end row + positionBox = new JComboBox<>(possiblePositions); + positionBox.setSelectedIndex(selectedPosition); + panel2.add(positionBox, c2); + + + + // main panel; + c0.gridheight = 10; + c0.weighty = 1.0; + c0.weightx = 1.0; + c0.gridwidth = GridBagConstraints.REMAINDER; //end row + c0.fill = GridBagConstraints.BOTH; + c.add(panel2, c0); + + c0.gridwidth = 1; + c0.gridheight = 1; + c0.fill = GridBagConstraints.HORIZONTAL; + + initButtons(c0, c, this); + } + + public void actionPerformed(ActionEvent evt) { + + + // Compare the action command to the known actions. + if (evt.getSource() == closeButton) { + closeDialog(); + } else if (evt.getSource() == cancelButton) { + cancelDialog(); + } + } + + public void closeDialog() { + regularClose = true; + dispose(); + } + + public void cancelDialog() { + dispose(); + } + + public boolean isRegularClose() { + return regularClose; + } + + public String getValue() { + return valueField.getText(); + } + + public int getSelectedIndex() { + return positionBox.getSelectedIndex(); + } + + + +}