Commit 05e3c131 authored by apvrille's avatar apvrille

First countermeasure working. Still need to make the icons and the right shape

parent e047af54
......@@ -894,12 +894,16 @@ public class ActionPerformer {
mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ATD_BLOCK);
} else if (command.equals(mgui.actions[TGUIAction.ATD_ATTACK].getActionCommand())) {
mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ATD_ATTACK);
} else if (command.equals(mgui.actions[TGUIAction.ATD_COUNTERMEASURE].getActionCommand())) {
mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ATD_COUNTERMEASURE);
} else if (command.equals(mgui.actions[TGUIAction.ATD_CONSTRAINT].getActionCommand())) {
mgui.actionOnButton(TGComponentManager.COMPONENT, TGComponentManager.ATD_CONSTRAINT);
} else if (command.equals(mgui.actions[TGUIAction.ATD_COMPOSITION_CONNECTOR].getActionCommand())) {
mgui.actionOnButton(TGComponentManager.CONNECTOR, TGComponentManager.ATD_COMPOSITION_CONNECTOR);
} else if (command.equals(mgui.actions[TGUIAction.ATD_ATTACK_CONNECTOR].getActionCommand())) {
mgui.actionOnButton(TGComponentManager.CONNECTOR, TGComponentManager.ATD_ATTACK_CONNECTOR);
} else if (command.equals(mgui.actions[TGUIAction.ATD_COUNTERMEASURE_CONNECTOR].getActionCommand())) {
mgui.actionOnButton(TGComponentManager.CONNECTOR, TGComponentManager.ATD_COUNTERMEASURE_CONNECTOR);
// TURTLE-OS
} else if (command.equals(mgui.actions[TGUIAction.TOS_TCLASS].getActionCommand())) {
......
......@@ -149,6 +149,7 @@ public class TGComponentManager {
public static final int ATD_COMPOSITION_CONNECTOR = 132;
public static final int ATD_ATTACK_CONNECTOR = 133;
public static final int ATD_COUNTERMEASURE_CONNECTOR = 137;
public static final int CONNECTOR_MESSAGE_ASYNC_SDZV = 134;
public static final int CONNECTOR_MESSAGE_SYNC_SDZV = 135;
......@@ -296,6 +297,7 @@ public class TGComponentManager {
public static final int ATD_BLOCK = 1400;
public static final int ATD_ATTACK = 1401;
public static final int ATD_CONSTRAINT = 1402;
public static final int ATD_COUNTERMEASURE = 1403;
// TML Communication patterns and TMLSD
public static final int TMLCP_CHOICE = 1500;
......@@ -998,6 +1000,9 @@ public class TGComponentManager {
case ATD_CONSTRAINT:
tgc = new ATDConstraint(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);
break;
case ATD_COUNTERMEASURE:
tgc = new ATDCountermeasure(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);
break;
case DIPLODODUSMETHODOLOGY_REF_APPLICATION:
tgc = new DiplodocusMethodologyDiagramReferenceToApplication(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp);
break;
......@@ -1745,12 +1750,16 @@ public class TGComponentManager {
return ATD_BLOCK;
} else if (tgc instanceof ATDAttack) {
return ATD_ATTACK;
} else if (tgc instanceof ATDCountermeasure) {
return ATD_COUNTERMEASURE;
} else if (tgc instanceof ATDConstraint) {
return ATD_CONSTRAINT;
} else if (tgc instanceof ATDCompositionConnector) {
return ATD_COMPOSITION_CONNECTOR;
} else if (tgc instanceof ATDAttackConnector) {
return ATD_ATTACK_CONNECTOR;
} else if (tgc instanceof ATDCountermeasureConnector) {
return ATD_COUNTERMEASURE_CONNECTOR;
} else if (tgc instanceof DiplodocusMethodologyDiagramReferenceToApplication) {
return DIPLODODUSMETHODOLOGY_REF_APPLICATION;
} else if (tgc instanceof DiplodocusMethodologyDiagramReferenceToCP) {
......@@ -2205,6 +2214,10 @@ public class TGComponentManager {
case ATD_ATTACK_CONNECTOR:
tgc = new ATDAttackConnector(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp, p1, p2, listPoint);
break;
case ATD_COUNTERMEASURE_CONNECTOR:
tgc = new ATDCountermeasureConnector(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp, p1, p2, listPoint);
break;
case DIPLODOCUSMETHODOLOGY_CONNECTOR:
tgc = new DiplodocusMethodologyConnector(x, y, tdp.getMinX(), tdp.getMaxX(), tdp.getMinY(), tdp.getMaxY(), false, null, tdp, p1, p2, listPoint);
......
......@@ -348,6 +348,8 @@ public class TGUIAction extends AbstractAction {
public static final int ATD_ATTACK_CONNECTOR = 286;
public static final int ATD_COMPOSITION_CONNECTOR = 288;
public static final int ATD_CONSTRAINT = 287;
public static final int ATD_COUNTERMEASURE = 456;
public static final int ATD_COUNTERMEASURE_CONNECTOR = 457;
// AVATAR Block Diagram
public static final int ABD_BLOCK = 289;
......@@ -600,7 +602,7 @@ public class TGUIAction extends AbstractAction {
public static final int ACT_INTERNAL_SEARCH = 415;
//--
public static final int NB_ACTION = 456;
public static final int NB_ACTION = 458;
private static final TAction [] actions = new TAction[NB_ACTION];
......@@ -1069,10 +1071,12 @@ public class TGUIAction extends AbstractAction {
// Attack Tree Diagrams
actions[ATD_BLOCK] = new TAction("atd-block", "Add a block", IconManager.imgic1070, IconManager.imgic1070, "Block", "Add a SysML Block to the currently opened attack tree diagram", 0);
actions[ATD_ATTACK] = new TAction("atd-attack", "Add an attack", IconManager.imgic1072, IconManager.imgic1072, " Attack", "Add an attack (i.e. a SysML value type) to the currently opened attack tree diagram", 0);
actions[ATD_ATTACK] = new TAction("atd-attack", "Add an attack", IconManager.imgic1072, IconManager.imgic1072, "Attack", "Add an attack (i.e. a SysML value type) to the currently opened attack tree diagram", 0);
actions[ATD_ATTACK_CONNECTOR] = new TAction("atd-attack-connector", "Add a connector between attacks /constraints", IconManager.imgic1080, IconManager.imgic1080, "Connector", "Add a connector between attacks / constraints of the currently opened attack tree diagram", 0);
actions[ATD_COMPOSITION_CONNECTOR] = new TAction("atd-composition-connector", "Add a composition connector between blocks", IconManager.imgic1076, IconManager.imgic1076, "Composition connector", "Add a composition between blocks of the currently opened attack tree diagram", 0);
actions[ATD_CONSTRAINT] = new TAction("atd-constraint", "Add an constraint", IconManager.imgic1078, IconManager.imgic1078, "Constraint", "Add a constraint to the currently opened attack tree diagram", 0);
actions[ATD_COUNTERMEASURE] = new TAction("atd-countermeasure", "Add a countermeasure", IconManager.imgic1072, IconManager.imgic1072, "Countermeasure", "Add a countermeasure to the currently opened attack tree diagram", 0);
actions[ATD_COUNTERMEASURE_CONNECTOR] = new TAction("atd-countermeasure-connector", "Add a connector between attacks / countermeasures", IconManager.imgic1080, IconManager.imgic1080, "Connector", "Add a connector between attacks / countermeasures of the currently opened attack tree diagram", 0);
// TURTLE-OS
actions[TOS_TCLASS] = new TAction("add-tclass-os", "Add Tclass", IconManager.imgic104, IconManager.imgic104, "Tclass", "Add a TClass to the currently opened class diagram", 0);
......
......@@ -83,8 +83,8 @@ public class ATDAttack extends TGCScalableWithInternalComponent implements Swall
height = (int)(40 * tdp.getZoom());
minWidth = 100;
nbConnectingPoint = 12;
connectingPoint = new TGConnectingPoint[12];
nbConnectingPoint = 24;
connectingPoint = new TGConnectingPoint[24];
connectingPoint[0] = new ATDAttackConnectingPoint(this, 0, 0, true, true, 0.5, 0.0);
connectingPoint[1] = new ATDAttackConnectingPoint(this, 0, 0, true, true, 0.0, 0.5);
......@@ -98,6 +98,18 @@ public class ATDAttack extends TGCScalableWithInternalComponent implements Swall
connectingPoint[9] = new ATDAttackConnectingPoint(this, 0, 0, true, true, 1.0, 0.75);
connectingPoint[10] = new ATDAttackConnectingPoint(this, 0, 0, true, true, 0.25, 1.0);
connectingPoint[11] = new ATDAttackConnectingPoint(this, 0, 0, true, true, 0.75, 1.0);
connectingPoint[12] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 0.5, 0.0);
connectingPoint[13] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 0.0, 0.5);
connectingPoint[14] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 1.0, 0.5);
connectingPoint[15] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 0.5, 1.0);
connectingPoint[16] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 0.25, 0.0);
connectingPoint[17] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 0.75, 0.0);
connectingPoint[18] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 0.0, 0.25);
connectingPoint[19] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 1.0, 0.25);
connectingPoint[20] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 0.0, 0.75);
connectingPoint[21] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 1.0, 0.75);
connectingPoint[22] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 0.25, 1.0);
connectingPoint[23] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 0.75, 1.0);
//addTGConnectingPointsComment();
moveable = true;
......
......@@ -51,7 +51,7 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ui.*;
import ui.window.JDialogAttack;
import ui.window.JDialogCountermeasure;
import javax.swing.*;
import java.awt.*;
......@@ -84,17 +84,17 @@ public class ATDCountermeasure extends TGCScalableWithInternalComponent implemen
connectingPoint = new TGConnectingPoint[12];
connectingPoint[0] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 0.5, 0.0);
connectingPoint[1] = new ATDCountermeasureAttackConnectingPoint(this, 0, 0, true, true, 0.0, 0.5);
connectingPoint[2] = new ATDCountermeasureAttackConnectingPoint(this, 0, 0, true, true, 1.0, 0.5);
connectingPoint[3] = new ATDCountermeasureAttackConnectingPoint(this, 0, 0, true, true, 0.5, 1.0);
connectingPoint[4] = new ATDCountermeasureAttackConnectingPoint(this, 0, 0, true, true, 0.25, 0.0);
connectingPoint[5] = new ATDCountermeasureAttackConnectingPoint(this, 0, 0, true, true, 0.75, 0.0);
connectingPoint[6] = new ATDCountermeasureAttackConnectingPoint(this, 0, 0, true, true, 0.0, 0.25);
connectingPoint[7] = new ATDCountermeasureAttackConnectingPoint(this, 0, 0, true, true, 1.0, 0.25);
connectingPoint[8] = new ATDCountermeasureAttackConnectingPoint(this, 0, 0, true, true, 0.0, 0.75);
connectingPoint[9] = new ATDCountermeasureAttackConnectingPoint(this, 0, 0, true, true, 1.0, 0.75);
connectingPoint[10] = new ATDCountermeasureAttackConnectingPoint(this, 0, 0, true, true, 0.25, 1.0);
connectingPoint[11] = new ATDCountermeasureAttackConnectingPoint(this, 0, 0, true, true, 0.75, 1.0);
connectingPoint[1] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 0.0, 0.5);
connectingPoint[2] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 1.0, 0.5);
connectingPoint[3] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 0.5, 1.0);
connectingPoint[4] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 0.25, 0.0);
connectingPoint[5] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 0.75, 0.0);
connectingPoint[6] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 0.0, 0.25);
connectingPoint[7] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 1.0, 0.25);
connectingPoint[8] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 0.0, 0.75);
connectingPoint[9] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 1.0, 0.75);
connectingPoint[10] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 0.25, 1.0);
connectingPoint[11] = new ATDCountermeasureConnectingPoint(this, 0, 0, true, true, 0.75, 1.0);
//addTGConnectingPointsComment();
moveable = true;
......@@ -244,7 +244,7 @@ public class ATDCountermeasure extends TGCScalableWithInternalComponent implemen
String tmp;
boolean error = false;
JDialogAttack dialog = new JDialogAttack(frame, "Setting attack attributes", this);
JDialogCountermeasure dialog = new JDialogCountermeasure(frame, "Setting countermeasure attributes", this);
// dialog.setSize(450, 350);
GraphicLib.centerOnParent(dialog, 450, 350);
dialog.setVisible( true ); // blocked until dialog has been closed
......@@ -271,8 +271,6 @@ public class ATDCountermeasure extends TGCScalableWithInternalComponent implemen
description = dialog.getDescription();
}
isRootAttack = dialog.isRootAttack();
if (error) {
JOptionPane.showMessageDialog(frame,
"Name is non-valid",
......
......@@ -82,6 +82,9 @@ public class AttackTreeDiagramToolbar extends TToolBar {
mgui.actions[TGUIAction.ATD_CONSTRAINT].setEnabled(b);
mgui.actions[TGUIAction.ATD_COUNTERMEASURE].setEnabled(b);
mgui.actions[TGUIAction.ATD_COUNTERMEASURE_CONNECTOR].setEnabled(b);
mgui.actions[TGUIAction.ACT_TOGGLE_ATTR].setEnabled(b);
mgui.actions[TGUIAction.ACT_MODEL_CHECKING].setEnabled(b);
......@@ -124,6 +127,12 @@ public class AttackTreeDiagramToolbar extends TToolBar {
button = this.add(mgui.actions[TGUIAction.ATD_ATTACK_CONNECTOR]);
button.addMouseListener(mgui.mouseHandler);
this.addSeparator();
button = this.add(mgui.actions[TGUIAction.ATD_COUNTERMEASURE]);
button.addMouseListener(mgui.mouseHandler);
button = this.add(mgui.actions[TGUIAction.ATD_COUNTERMEASURE_CONNECTOR]);
button.addMouseListener(mgui.mouseHandler);
this.addSeparator();
this.addSeparator();
......
/**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 JDialogAttack
* Dialog for managing atatck attributes
* Creation: 07/06/2017
* @version 1.0 07/06/2017
* @author Ludovic APVRILLE
* @see
*/
package ui.window;
import ui.IconManager;
import ui.atd.ATDCountermeasure;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
//import javax.swing.event.*;
public class JDialogCountermeasure extends javax.swing.JDialog implements ActionListener {
private boolean regularClose;
private JPanel panel2;
private Frame frame;
//protected JTextField taskName;
protected JTextField name, description;
// Main Panel
private JButton closeButton;
private JButton cancelButton;
private ATDCountermeasure countermeasure;
/** Creates new form */
public JDialogCountermeasure(Frame _frame, String _title, ATDCountermeasure _countermeasure) {
super(_frame, _title, true);
frame = _frame;
countermeasure = _countermeasure;
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("Attack attributes"));
panel2.setPreferredSize(new Dimension(350, 250));
c1.gridwidth = 1;
c1.gridheight = 1;
c1.weighty = 1.0;
c1.weightx = 1.0;
c1.gridwidth = 1;
c1.fill = GridBagConstraints.HORIZONTAL;
panel2.add(new JLabel("Name:"), c2);
c1.gridwidth = GridBagConstraints.REMAINDER; //end row
name = new JTextField(countermeasure.getCountermeasureName());
panel2.add(name, c1);
c1.gridwidth = 1;
c1.fill = GridBagConstraints.HORIZONTAL;
panel2.add(new JLabel("Description:"), c2);
c1.gridwidth = GridBagConstraints.REMAINDER; //end row
description = new JTextField(countermeasure.getDescription());
panel2.add(description, c1);
// 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) {
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 getDescription() {
return description.getText();
}
public String getName() {
return name.getText();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment