diff --git a/src/ui/AttackTreePanel.java b/src/ui/AttackTreePanel.java new file mode 100755 index 0000000000000000000000000000000000000000..489175e59ea9c79ca81e693befcc3eb9fcdab361 --- /dev/null +++ b/src/ui/AttackTreePanel.java @@ -0,0 +1,146 @@ +/**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 AttackTreePanel + * Management of attack trees + * Creation: 03/11/2009 + * @version 1.0 03/11/2009 + * @author Ludovic APVRILLE + * @see MainGUI + */ + +package ui; + +import java.awt.*; +import javax.swing.*; +import javax.swing.event.*; +import ui.atd.*; + +import java.util.*; + +public class AttackTreePanel extends TURTLEPanel { + public AttackTreeDiagramPanel atdp; + + public RequirementPanel(MainGUI _mgui) { + super(_mgui); + + tabbedPane = new JTabbedPane(); + UIManager.put("TabbedPane.tabAreaBackground", _mgui.BACK_COLOR); + UIManager.put("TabbedPane.selected", _mgui.BACK_COLOR); + SwingUtilities.updateComponentTreeUI(tabbedPane); + //tabbedPane.setOpaque(true); + + cl = new ChangeListener() { + public void stateChanged(ChangeEvent e){ + mgui.paneRequirementAction(e); + } + }; + tabbedPane.addChangeListener(cl); + tabbedPane.addMouseListener(new TURTLEPanelPopupListener(this, mgui)); + + } + + public void init() { + + // Requirement Diagram toolbar + //addRequirementDiagram("Requirement Diagram"); + + //jsp.setVisible(true); + } + + public boolean addAttackTreeDiagram(String s) { + AttackTreeDiagramToolBar toolBarAt = new AttackTreeDiagramToolBar(mgui); + toolbars.add(toolBarAt); + + toolBarPanel = new JPanel(); + //toolBarPanel.setBackground(Color.red); + toolBarPanel.setLayout(new BorderLayout()); + //toolBarPanel.setBackground(ColorManager.MainTabbedPaneSelect); + + //The diagram + atdp = new AttackTreeDiagramPanel(mgui, toolBarReq); + atdp.setName(s); + atdp.tp = this; + tdp = atdp; + panels.add(atdp); + JScrollDiagramPanel jsp = new JScrollDiagramPanel(atdp); + atdp.jsp = jsp; + jsp.setWheelScrollingEnabled(true); + jsp.getVerticalScrollBar().setUnitIncrement(mgui.INCREMENT); + toolBarPanel.add(toolBarAt, BorderLayout.NORTH); + toolBarPanel.add(jsp, BorderLayout.CENTER); + tabbedPane.addTab(s, IconManager.imgic1000, toolBarPanel, "Opens Attack Tree Diagram"); + tabbedPane.setSelectedIndex(0); + JPanel toolBarPanel = new JPanel(); + toolBarPanel.setLayout(new BorderLayout()); + + return true; + } + + + public String saveHeaderInXml() { + return "<Modeling type=\"AttackTree\" nameTab=\"" + mgui.getTabName(this) + "\" >\n"; + } + + public String saveTailInXml() { + return "</Modeling>\n\n\n"; + } + + public String toString() { + return mgui.getTitleAt(this) + " (SysML Parametric Diagram)"; + } + + public boolean removeEnabled(int index) { + if (panels.size() > 1) { + return true; + } + return false; + } + + public boolean renameEnabled(int index) { + if (panels.size() == 0) { + return false; + } + if ((panels.elementAt(index) instanceof AttackTreeDiagramPanel)){ + return true; + } + + return false; + } + +} diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index 37bcce5c85622f0d19a27b2ae406841f8da73c2e..17fcfe0b867f88733f42f40b311cb48ffcd7c871 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -764,6 +764,20 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { //System.out.println("Main analysis added"); return index; } + + private int addAttackTreePanel(String name, int index) { + if (index == -1) { + index = tabs.size(); + } + AttackTreePanel atp = new AttackTreePanel(this); + tabs.add(index, atp); // should look for the first + mainTabbedPane.add(atp.tabbedPane, index); + mainTabbedPane.setToolTipTextAt(index, "Open requirement diagrams"); + mainTabbedPane.setTitleAt(index, name); + mainTabbedPane.setIconAt(index, IconManager.imgic1000); + atp.init(); + return index; + } private int addRequirementPanel(String name, int index) { if (index == -1) { @@ -1303,6 +1317,15 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { //paneAction(null); //frame.repaint();*/ } + + public void newAttackTree() { + //System.out.println("NEW ANALYSIS"); + addAttackTreePanel("Attack Trees", 0); + //((TURTLEPanel)tabs.elementAt(0)).tabbedPane.setSelectedIndex(0); + mainTabbedPane.setSelectedIndex(0); + //paneAction(null); + //frame.repaint(); + } public void newRequirement() { //System.out.println("NEW ANALYSIS"); @@ -5863,7 +5886,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { private MainGUI mgui; private JPopupMenu menu; - private JMenuItem rename, remove, moveRight, moveLeft, newDesign, newAnalysis, newDeployment, newRequirement, newTMLDesign, newTMLComponentDesign, newTMLArchi, newProactiveDesign, newTURTLEOSDesign, newNCDesign, sort, clone; + private JMenuItem rename, remove, moveRight, moveLeft, newDesign, newAnalysis, newDeployment, newRequirement, newTMLDesign, newTMLComponentDesign, newTMLArchi, newProactiveDesign, newTURTLEOSDesign, newNCDesign, sort, clone, newAttackTree; public PopupListener(MainGUI _mgui) { mgui = _mgui; @@ -5899,6 +5922,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { newAnalysis = createMenuItem("New TURTLE Analysis"); newDesign = createMenuItem("New TURTLE Design"); newDeployment = createMenuItem("New TURTLE Deployment"); + newAttackTree = createMenuItem("New Attack Tree (SysML Parametric Diagram)"); newRequirement = createMenuItem("New SysML Requirement Diagram"); newTMLDesign = createMenuItem("New DIPLODOCUS Design"); newTMLComponentDesign = createMenuItem("New Component-based DIPLODOCUS Design"); @@ -5926,6 +5950,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { menu.addSeparator(); + menu.add(newAttackTree); menu.add(newRequirement); menu.addSeparator(); @@ -6023,6 +6048,8 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { mgui.newDesign(); } else if (ac.equals("New TURTLE Deployment")) { mgui.newDeployment(); + } else if (ac.equals("New Attack Tree (SysML Parametric Diagram)")) { + mgui.newAttackTree(); } else if (ac.equals("New SysML Requirement Diagram")) { mgui.newRequirement(); } else if (ac.equals("New DIPLODOCUS Design")) { @@ -6066,7 +6093,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { public void mouseEntered(MouseEvent evt) { if (evt.getSource() instanceof AbstractButton) { AbstractButton button = (AbstractButton)evt.getSource(); - Action action = button.getAction(); // getAction is new in JDK 1.3 + Action action = button.getAction(); if (action != null) { String message = (String)action.getValue(Action.LONG_DESCRIPTION); label.setText(message); diff --git a/src/ui/atd/AttackTreeDiagramPanel.java b/src/ui/atd/AttackTreeDiagramPanel.java index ab49f777b825737b87505f55e5bd9f840f998d26..cb4f897fe5402eb25e4282000cc0071225cf6aa0 100644 --- a/src/ui/atd/AttackTreeDiagramPanel.java +++ b/src/ui/atd/AttackTreeDiagramPanel.java @@ -55,9 +55,9 @@ import java.util.*; import ui.*; -public class AttackTreePanel extends TDiagramPanel { +public class AttackTreeDiagramPanel extends TDiagramPanel { - public AttackTreePanel(MainGUI mgui, TToolBar _ttb) { + public AttackTreeDiagramPanel(MainGUI mgui, TToolBar _ttb) { super(mgui, _ttb); //addComponent(400, 50, TGComponentManager.EBRDD_START_STATE, false); TDiagramMouseManager tdmm = new TDiagramMouseManager(this); diff --git a/src/ui/atd/AttackTreePanel.java b/src/ui/atd/AttackTreePanel.java deleted file mode 100644 index ab49f777b825737b87505f55e5bd9f840f998d26..0000000000000000000000000000000000000000 --- a/src/ui/atd/AttackTreePanel.java +++ /dev/null @@ -1,145 +0,0 @@ -/**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 AttackTreePanel - * Panel used for drawing attack trees - * Creation: 03/11/2009 - * @version 1.0 03/11/2009 - * @author Ludovic APVRILLE - * @see - */ - -package ui.atd; - -//import java.awt.*; -import java.util.*; - -//import org.w3c.dom.*; -//import org.xml.sax.*; -//import javax.xml.parsers.*; - -import ui.*; - -public class AttackTreePanel extends TDiagramPanel { - - public AttackTreePanel(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 "<AttckTreePanel name=\"" + name + "\"" + sizeParam() + " >"; - } - - public String getXMLTail() { - return "</AttackTreePanel>"; - } - - public String getXMLSelectedHead() { - return "<AttackTreePanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; - } - - public String getXMLSelectedTail() { - return "</AttackTreePanelCopy>"; - } - - public String getXMLCloneHead() { - return "<AttackTreePanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; - } - - public String getXMLCloneTail() { - return "</AttackTreePanelCopy>"; - } - - public void makeGraphicalOptimizations() { - // Segments of connector that mask components - - // Components over others - - // Position correctly guards of choice - } - - - - 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); - } - } - -}