diff --git a/src/ui/AvatarMADsPanel.java b/src/ui/AvatarMADsPanel.java new file mode 100644 index 0000000000000000000000000000000000000000..4cd8eb12829ebfc0e86dc75add954f4447c55c07 --- /dev/null +++ b/src/ui/AvatarMADsPanel.java @@ -0,0 +1,149 @@ +/**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 AvatarMADsPanel + * Management of Avatar modeling hypothesis panels + * Creation: 27/08/2013 + * @version 1.0 27/08/2013 + * @author Ludovic APVRILLE + * @see MainGUI + */ + +package ui; + +import java.awt.*; +import javax.swing.*; +import javax.swing.event.*; +import java.util.*; +import ui.avatarmad.*; + +import myutil.*; + +public class AvatarMADsPanel extends TURTLEPanel { + + public AvatarMADsPanel(MainGUI _mgui) { + super(_mgui); + tabbedPane = new JTabbedPane(); + cl = new ChangeListener() { + public void stateChanged(ChangeEvent e){ + mgui.paneMADAction(e); + } + }; + tabbedPane.addChangeListener(cl); + tabbedPane.addMouseListener(new TURTLEPanelPopupListener(this, mgui)); + } + + + public AvatarMADPanel getMADPanel(String name) { + AvatarMADPanel amadp; + for(int i=1; i<panels.size(); i++) { + amadp = (AvatarMADPanel)(panels.elementAt(i)); + if (amadp.getName().compareTo(name) ==0) { + return asmdp; + } + } + return null; + } + + public void addAvatarStateMachineDiagramPanel(String s) { + JPanel toolBarPanel = new JPanel(); + toolBarPanel.setLayout(new BorderLayout()); + + AvatarSMDToolBar toolBarActivity = new AvatarSMDToolBar(mgui); + toolbars.add(toolBarActivity); + + AvatarSMDPanel asmdp = new AvatarSMDPanel(mgui, toolBarActivity); + asmdp.tp = this; + asmdp.setName(s); + JScrollDiagramPanel jsp = new JScrollDiagramPanel(asmdp); + asmdp.jsp = jsp; + jsp.setWheelScrollingEnabled(true); + jsp.getVerticalScrollBar().setUnitIncrement(mgui.INCREMENT); + toolBarPanel.add(toolBarActivity, BorderLayout.NORTH); + toolBarPanel.add(jsp, BorderLayout.CENTER); + panels.add(asmdp); + tabbedPane.addTab(s, IconManager.imgic63, toolBarPanel, "Opens the state machine of " + s); + //tabbedPane.setMnemonicAt(tabbedPane.getTabCount()-1, '^'); + return; + } + + public void init() { + + // Class Diagram toolbar + AvatarMADToolBar toolBarAvatarMAD = new AvatarMADToolBar(mgui); + toolbars.add(toolBarAvatarMAD); + + toolBarPanel = new JPanel(); + toolBarPanel.setLayout(new BorderLayout()); + + //Class diagram + AvatarMADPanel amadp = new AvatarMADPanel(mgui, toolBarAvatarMAD); + amadp.setName("Model Assumption Diagram"); + amadp.tp = this; + tdp = amadp; + panels.add(amadp); // Always first in list + JScrollDiagramPanel jsp = new JScrollDiagramPanel(amadp); + amadp.jsp = jsp; + jsp.setWheelScrollingEnabled(true); + jsp.getVerticalScrollBar().setUnitIncrement(mgui.INCREMENT); + toolBarPanel.add(toolBarAvatarMAD, BorderLayout.NORTH); + toolBarPanel.add(jsp, BorderLayout.CENTER); + tabbedPane.addTab("Model Assumption Diagram", IconManager.imgic80, toolBarPanel, "Opens the MAD"); + tabbedPane.setSelectedIndex(0); + //tabbedPane.setMnemonicAt(tabbedPane.getTabCount()-1, '^'); + + //jsp.setVisible(true); + + } + + + public String saveHeaderInXml() { + return "<Modeling type=\"AVATAR MAD\" nameTab=\"" + mgui.getTabName(this) + "\" >\n"; + } + + public String saveTailInXml() { + return "</Modeling>\n\n\n"; + } + + public String toString() { + return mgui.getTitleAt(this) + " (AVATAR MAD)"; + } + + + +} \ No newline at end of file diff --git a/src/ui/GTURTLEModeling.java b/src/ui/GTURTLEModeling.java index a5be47f49ac6eb93c86c3d1a1351fc5ab036251a..3278a2f0a1a45c1bafaec925af5b7ea196080f14 100755 --- a/src/ui/GTURTLEModeling.java +++ b/src/ui/GTURTLEModeling.java @@ -78,6 +78,7 @@ import ui.window.*; import ui.avatarbd.*; import ui.avatarsmd.*; import ui.avatarrd.*; +import ui.avatarmad.*; import ui.avatarpd.*; import ui.avatarcd.*; import ui.avatarad.*; @@ -3243,6 +3244,42 @@ public class GTURTLEModeling { makePostLoading(ardp, beginIndex); } } + + } else if (tdp instanceof AvatarMADPanel) { + nl = doc.getElementsByTagName("AvatarMADPanelCopy"); + + if (nl == null) { + return; + } + + AvatarMADPanel amadp = (AvatarMADPanel)tdp; + + for(i=0; i<nl.getLength(); i++) { + adn = nl.item(i); + if (adn.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) adn; + + if (amadp == 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"), amadp); + makeXMLConnectors(elt.getElementsByTagName("CONNECTOR"), amadp); + makeXMLComponents(elt.getElementsByTagName("SUBCOMPONENT"), amadp); + connectConnectorsToRealPoints(amadp); + amadp.structureChanged(); + makePostLoading(amadp, beginIndex); + } + } + } else if (tdp instanceof AvatarPDPanel) { nl = doc.getElementsByTagName("AvatarPDPanelCopy"); @@ -3487,6 +3524,8 @@ public class GTURTLEModeling { loadAvatarDesign(node); } else if (type.compareTo("Avatar Requirement") == 0) { loadAvatarRequirement(node); + } else if (type.compareTo("Avatar MAD") == 0) { + loadAvatarMADs(node); // TURTLE @@ -3577,6 +3616,33 @@ public class GTURTLEModeling { } } } + + public void loadAvatarMADs(Node node) throws MalformedModelingException, SAXException { + Element elt = (Element) node; + String nameTab; + NodeList diagramNl; + int indexReq; + int cpt_req = 0; + + + nameTab = elt.getAttribute("nameTab"); + + indexReq = mgui.createAvatarMADs(nameTab); + + diagramNl = node.getChildNodes(); + + for(int j=0; j<diagramNl.getLength(); j++) { + //TraceManager.addDev("Deployment nodes: " + j); + node = diagramNl.item(j); + if (node.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element)node; + if (elt.getTagName().compareTo("AvatarMADPanel") == 0) { + loadAvatarMAD(elt, indexReq, cpt_req); + cpt_req ++; + } + } + } + } public void loadDesign(Node node) throws MalformedModelingException, SAXException { Element elt = (Element) node; @@ -4076,6 +4142,23 @@ public class GTURTLEModeling { loadDiagram(elt, tdp); } + public void loadAvatarMAD(Element elt, int indexAnalysis, int indexTab) throws MalformedModelingException, SAXException { + String name; + + name = elt.getAttribute("name"); + mgui.createAvatarMAD(indexAnalysis, name); + + + TDiagramPanel tdp = mgui.getAvatarMADPanel(indexAnalysis, indexTab, name); + + if (tdp == null) { + throw new MalformedModelingException(); + } + tdp.removeAll(); + + loadDiagram(elt, tdp); + } + public void loadAvatarPD(Element elt, int indexAnalysis, int indexTab) throws MalformedModelingException, SAXException { String name; diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index 0b807e200a370360845b28d6b28ad592cfdeeaf7..749ae2815c0c16baa7ebec4495f4a70786361c3c 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -89,6 +89,7 @@ import ui.prosmd.*; import ui.avatarbd.*; import ui.avatarsmd.*; import ui.avatarrd.*; +import ui.avatarmad.*; import ui.avatarpd.*; import ui.avatarcd.*; import ui.avatarad.*; @@ -5133,6 +5134,20 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { setPanelMode(); return true; } + + public boolean createAvatarMAD(int index, String s) { + return createAvatarMAD((TURTLEPanel)(tabs.elementAt(index)), s); + } + + public boolean createAvatarMAD(TURTLEPanel tp, String s) { + if (!(tp instanceof AvatarMADsPanel)) { + return false; + } + + ((AvatarMADsPanel)tp).addAvatarMADPanel(s); + setPanelMode(); + return true; + } public boolean createAvatarPD(int index, String s) { return createAvatarPD((TURTLEPanel)(tabs.elementAt(index)), s); @@ -5431,6 +5446,33 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { } + public void paneMADAction(ChangeEvent e) { + //TraceManager.addDev("Pane design action size=" + tabs.size()); + try { + + TDiagramPanel tdp1 = (TDiagramPanel)(getCurrentTURTLEPanel().panels.elementAt(getCurrentJTabbedPane().getSelectedIndex())); + //TraceManager.addDev("Pane design action 1"); + if (activetdp != null) { + activetdp.activateActions(false); + unactivateDrawing(); + activetdp.stopAddingConnector(); + } + //TraceManager.addDev("Pane design action 1 on "+ tdp1.getName()); + tdp1.activateActions(true); + activetdp = tdp1; + + setEditMode(); + setPanelMode(); + //TraceManager.addDev("Pane design action 3"); + + // activate the drawing of the right pane + basicActivateDrawing(); + + } catch (Exception ex) { + //TraceManager.addDev("Exception pane design action"); + } + } + public void paneDesignAction(ChangeEvent e) { //TraceManager.addDev("Pane design action size=" + tabs.size()); try { diff --git a/src/ui/avatarmad/AvatarMADAssumption.java b/src/ui/avatarmad/AvatarMADAssumption.java new file mode 100644 index 0000000000000000000000000000000000000000..b0831c16a476aff496a112374d2f821a82d1b625 --- /dev/null +++ b/src/ui/avatarmad/AvatarMADAssumption.java @@ -0,0 +1,844 @@ +/**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 AvatarRDRequirement +* Avatar requirement: to be used in requirement diagram of AVATAR +* Creation: 20/04/2010 +* @version 1.0 20/04/2010 +* @author Ludovic APVRILLE +* @see +*/ + +package ui.avatarrd; + + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +public class AvatarRDRequirement extends TGCScalableWithInternalComponent implements WithAttributes, TGAutoAdjust { + public String oldValue; + protected int textX = 5; + protected int textY = 22; + protected int lineHeight = 30; + private double dlineHeight = 0.0; + //protected int reqType = 0; + // 0: normal, 1: formal, 2: security + //protected int startFontSize = 10; + protected Graphics graphics; + //protected int iconSize = 30; + + private Font myFont, myFontB; + private int maxFontSize = 30; + private int minFontSize = 4; + private int currentFontSize = -1; + private boolean displayText = true; + + protected final static String[] REQ_TYPE_STR = {"<<Requirement>>", "<<Safety Requirement>>", "<<Security Requirement>>"}; + protected final static int NB_REQ_TYPE = 3; + + protected final static int REGULAR_REQ = 0; + protected final static int SAFETY_REQ = 1; + protected final static int SECURITY_REQ = 2; + + public final static int HIGH = 0; + public final static int MEDIUM = 1; + public final static int LOW = 2; + + protected String text; + protected String []texts; + protected String kind = ""; + protected String criticality = ""; + protected int reqType = 0; + protected String violatedAction = ""; + protected String attackTreeNode = ""; + protected String referenceElements = ""; + protected String id = ""; + + protected boolean satisfied = false; + protected boolean verified = false; + + private JMenuItem isRegular = null; + private JMenuItem isSafety = null; + private JMenuItem isSecurity = null; + private JMenuItem menuNonSatisfied = null; + private JMenuItem menuSatisfied = null; + private JMenuItem menuNonVerified = null; + private JMenuItem menuVerified = null; + JMenuItem editAttributes = null; + + + // Icon + private int iconSize = 18; + private boolean iconIsDrawn = false; + + public AvatarRDRequirement(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + initScaling(200, 120); + oldScaleFactor = tdp.getZoom(); + dlineHeight = lineHeight * oldScaleFactor; + lineHeight = (int)dlineHeight; + dlineHeight = dlineHeight - lineHeight; + + minWidth = 1; + minHeight = lineHeight; + + nbConnectingPoint = 28; + connectingPoint = new TGConnectingPoint[nbConnectingPoint]; + connectingPoint[0] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.0, 0.25, TGConnectingPoint.WEST); + connectingPoint[1] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.0, 0.5, TGConnectingPoint.WEST); + connectingPoint[2] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.0, 0.75, TGConnectingPoint.WEST); + connectingPoint[3] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 1.0, 0.25, TGConnectingPoint.EAST); + connectingPoint[4] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 1.0, 0.5, TGConnectingPoint.EAST); + connectingPoint[5] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 1.0, 0.75, TGConnectingPoint.EAST); + connectingPoint[6] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.25, 0.0, TGConnectingPoint.NORTH); + connectingPoint[7] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.5, 0.0, TGConnectingPoint.NORTH); + connectingPoint[8] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.75, 0.0, TGConnectingPoint.NORTH); + connectingPoint[9] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.25, 1.0, TGConnectingPoint.SOUTH); + connectingPoint[10] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.5, 1.0, TGConnectingPoint.SOUTH); + connectingPoint[11] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.75, 1.0, TGConnectingPoint.SOUTH); + connectingPoint[12] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 0.0, 0.25, TGConnectingPoint.WEST); + connectingPoint[13] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 0.0, 0.5, TGConnectingPoint.WEST); + connectingPoint[14] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 0.0, 0.75, TGConnectingPoint.WEST); + connectingPoint[15] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 1.0, 0.25, TGConnectingPoint.EAST); + connectingPoint[16] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 1.0, 0.5, TGConnectingPoint.EAST); + connectingPoint[17] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 1.0, 0.75, TGConnectingPoint.EAST); + connectingPoint[18] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 0.25, 0.0, TGConnectingPoint.NORTH); + connectingPoint[19] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 0.5, 0.0, TGConnectingPoint.NORTH); + connectingPoint[20] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 0.75, 0.0, TGConnectingPoint.NORTH); + connectingPoint[21] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 0.25, 1.0, TGConnectingPoint.SOUTH); + connectingPoint[22] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 0.5, 1.0, TGConnectingPoint.SOUTH); + connectingPoint[23] = new AvatarRDConnectingPointVerify(this, 0, 0, true, false, 0.75, 1.0, TGConnectingPoint.SOUTH); + connectingPoint[24] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.5, 1.0, TGConnectingPoint.SOUTH); + connectingPoint[25] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.5, 1.0, TGConnectingPoint.SOUTH); + connectingPoint[26] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.5, 1.0, TGConnectingPoint.SOUTH); + connectingPoint[27] = new AvatarRDConnectingPointDerive(this, 0, 0, true, true, 0.5, 1.0, TGConnectingPoint.SOUTH); + + + addTGConnectingPointsCommentTop(); + + nbInternalTGComponent = 0; + //tgcomponent = new TGComponent[nbInternalTGComponent]; + + int h = 1; + //TAttributeRequirement tgc0; + //tgc0 = new TAttributeRequirement(x, y+height+h, 0, 0, height + h, height+h, true, this, _tdp); + //tgcomponent[0] = tgc0; + + moveable = true; + editable = true; + removable = true; + userResizable = true; + multieditable = true; + + //reqType = 0; + + id = "0"; + + // Name of the requirement + name = "Requirement"; + id = tdp.findAvatarRequirementID(id); + try { + value = tdp.findAvatarRequirementName("Requirement_", Integer.decode(id).intValue()); + } catch (Exception e) { + value = tdp.findAvatarRequirementName("Requirement_", 0); + } + oldValue = value; + + myImageIcon = IconManager.imgic5100; + + text = "Requirement description:\nDouble-click to edit"; + + actionOnAdd(); + } + + public void makeValue() { + texts = Conversion.wrapText(text); + } + + public void internalDrawing(Graphics g) { + Font f = g.getFont(); + Font fold = f; + int w, c; + int size; + + if (texts == null) { + makeValue(); + } + + if (!tdp.isScaled()) { + graphics = g; + } + + if (((rescaled) && (!tdp.isScaled())) || myFont == null) { + currentFontSize = tdp.getFontSize(); + //System.out.println("Rescaled, font size = " + currentFontSize + " height=" + height); + myFont = f.deriveFont((float)currentFontSize); + myFontB = myFont.deriveFont(Font.BOLD); + + if (rescaled) { + rescaled = false; + } + } + + if(currentFontSize <minFontSize) { + displayText = false; + } else { + displayText = true; + } + + int h = g.getFontMetrics().getHeight(); + + g.drawRect(x, y, width, height); + + g.drawLine(x, y+lineHeight, x+width, y+lineHeight); + g.setColor(ColorManager.AVATAR_REQUIREMENT_TOP); + g.fillRect(x+1, y+1, width-1, lineHeight-1); + g.setColor(ColorManager.AVATAR_REQUIREMENT_ATTRIBUTES); + g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); + ColorManager.setColor(g, getState(), 0); + if ((lineHeight > 23) && (width > 23)){ + g.drawImage(IconManager.img5100, x + width - iconSize + 1, y + 3, Color.yellow, null); + } + + if (displayText) { + size = currentFontSize - 2; + g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2))); + + drawLimitedString(g, REQ_TYPE_STR[reqType], x, y + size, width, 1); + + size += currentFontSize; + g.setFont(myFontB); + w = g.getFontMetrics().stringWidth(value); + drawLimitedString(g, value, x, y + size, width, 1); + + } + + if (verified) { + if (satisfied) { + Color tmp = g.getColor(); + GraphicLib.setMediumStroke(g); + g.setColor(Color.green); + g.drawLine(x+width-2, y-6+lineHeight, x+width-6, y-2+lineHeight); + g.drawLine(x+width-6, y-3+lineHeight, x+width-8, y-6+lineHeight); + g.setColor(tmp); + GraphicLib.setNormalStroke(g); + } else { + //g.drawString("acc", x + width - 10, y+height-10); + Color tmp = g.getColor(); + GraphicLib.setMediumStroke(g); + g.setColor(Color.red); + g.drawLine(x+width-2, y-2+lineHeight, x+width-8, y-8+lineHeight); + g.drawLine(x+width-8, y-2+lineHeight, x+width-2, y-8+lineHeight); + g.setColor(tmp); + GraphicLib.setNormalStroke(g); + } + } + + g.setFont(myFont); + String texti = "Text"; + String s ; + int i; + size = lineHeight + currentFontSize; + + //ID + if (size < (height - 2)) { + drawLimitedString(g, "ID=" + id, x + textX, y + size, width, 0); + } + size += currentFontSize; + + //text + for(i=0; i<texts.length; i++) { + if (size < (height - 2)) { + s = texts[i]; + if (i == 0) { + s = texti + "=\"" + s; + } + if (i == (texts.length - 1)) { + s = s + "\""; + } + drawLimitedString(g, s, x + textX, y + size, width, 0); + } + size += currentFontSize; + + } + // Type and risk + if (size < (height - 2)) { + drawLimitedString(g, "Kind=\"" + kind + "\"", x + textX, y + size, width, 0); + size += currentFontSize; + if (size < (height - 2)) { + drawLimitedString(g, "Risk=\"" + criticality + "\"", x + textX, y + size, width, 0); + size += currentFontSize; + if (size < (height - 2)) { + + drawLimitedString(g, "Reference elements=\"" + referenceElements + "\"", x + textX, y + size, width, 0); + + size += currentFontSize; + if (size < (height - 2)) { + + if (reqType == SECURITY_REQ) { + drawLimitedString(g, "Targeted attacks=\"" + attackTreeNode + "\"", x + textX, y + size, width, 0); + } + + if (reqType == SAFETY_REQ) { + drawLimitedString(g, "Violated action=\"" + violatedAction + "\"", x + textX, y + size, width, 0); + } + } + } + } + } + + + g.setFont(f); + } + + public boolean editOndoubleClick(JFrame frame, int _x, int _y) { + // On the name ? + oldValue = value; + + if ((displayText) && (_y <= (y + lineHeight))) { + String text = getName() + ": "; + if (hasFather()) { + text = getTopLevelName() + " / " + text; + } + String s = (String)JOptionPane.showInputDialog(frame, text, + "setting value", JOptionPane.PLAIN_MESSAGE, IconManager.imgic101, + null, + getValue()); + + if ((s != null) && (s.length() > 0) && (!s.equals(oldValue))) { + //boolean b; + if (!TAttribute.isAValidId(s, false, false)) { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the Requirement: the new name is not a valid name", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + + if (!tdp.isRequirementNameUnique(s)) { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the Requirement: the new name is already in use", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + + + int size = graphics.getFontMetrics().stringWidth(s) + iconSize + 5; + minDesiredWidth = Math.max(size, minWidth); + if (minDesiredWidth != width) { + newSizeForSon(null); + } + setValue(s); + + if (tdp.actionOnDoubleClick(this)) { + return true; + } else { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the Requirement: this name is already in use", + "Error", + JOptionPane.INFORMATION_MESSAGE); + setValue(oldValue); + } + } + return false; + } + + return editAttributes(); + + } + + public boolean editAttributes() { + //String oldValue = value; + String atn = null; + String va = null; + + if (reqType == SECURITY_REQ) { + atn = attackTreeNode; + } + + + if (reqType == SAFETY_REQ) { + va = violatedAction; + } + + JDialogRequirement jdr = new JDialogRequirement(tdp.getGUI().getFrame(), "Setting attributes of Requirement " + getRequirementName(), id, text, kind, criticality, va, reqType, atn, referenceElements); + jdr.setSize(750, 400); + GraphicLib.centerOnParent(jdr); + jdr.show(); + + if (!jdr.isRegularClose()) { + return false; + } + + + if (reqType == SAFETY_REQ) { + violatedAction = jdr.getViolatedAction(); + } + if (reqType == SECURITY_REQ) { + attackTreeNode = jdr.getAttackTreeNode(); + } + referenceElements = jdr.getReferenceElements(); + id = jdr.getId(); + text = jdr.getText(); + kind = jdr.getKind(); + criticality = jdr.getCriticality(); + + makeValue(); + return true; + } + + public void rescale(double scaleFactor){ + dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; + lineHeight = (int)(dlineHeight); + dlineHeight = dlineHeight - lineHeight; + + minHeight = lineHeight; + + super.rescale(scaleFactor); + } + + + public TGComponent isOnOnlyMe(int x1, int y1) { + if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { + return this; + } + return null; + } + + public String getRequirementName() { + return value; + } + + public boolean isSafety() { + return (reqType == 1); + } + + public void setRequirementType(int _type) { + reqType = _type; + } + + public int getRequirementType() { + return reqType; + } + + public boolean isSatisfied() { + return satisfied; + } + + public boolean isVerified() { + return verified; + } + + public int getType() { + return TGComponentManager.AVATARRD_REQUIREMENT; + } + + public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { + + componentMenu.addSeparator(); + + isRegular = new JMenuItem("Set as regular requirement"); + isSafety = new JMenuItem("Set as safety requirement"); + isSecurity = new JMenuItem("Set as security requirement"); + menuNonSatisfied = new JMenuItem("Set as non satisfied"); + menuSatisfied = new JMenuItem("Set as satisfied"); + menuNonVerified = new JMenuItem("Set as non verified"); + menuVerified = new JMenuItem("Set as verified"); + + + isRegular.addActionListener(menuAL); + isSafety.addActionListener(menuAL); + isSecurity.addActionListener(menuAL); + menuNonSatisfied.addActionListener(menuAL); + menuSatisfied.addActionListener(menuAL); + menuNonVerified.addActionListener(menuAL); + menuVerified.addActionListener(menuAL); + + editAttributes = new JMenuItem("Edit attributes"); + editAttributes.addActionListener(menuAL); + + isRegular.setEnabled(reqType != REGULAR_REQ); + isSafety.setEnabled(reqType != SAFETY_REQ); + isSecurity.setEnabled(reqType != SECURITY_REQ); + + menuNonSatisfied.setEnabled(satisfied); + menuSatisfied.setEnabled(!satisfied); + + menuNonVerified.setEnabled(verified); + menuVerified.setEnabled(!verified); + + componentMenu.add(isRegular); + componentMenu.add(isSafety); + componentMenu.add(isSecurity); + componentMenu.addSeparator(); + componentMenu.add(menuNonSatisfied); + componentMenu.add(menuSatisfied); + componentMenu.add(menuNonVerified); + componentMenu.add(menuVerified); + componentMenu.add(editAttributes); + } + + public boolean eventOnPopup(ActionEvent e) { + String s = e.getActionCommand(); + + if (e.getSource() == menuNonSatisfied) { + satisfied = false; + } else if (e.getSource() == menuSatisfied) { + satisfied = true; + } else if (e.getSource() == menuNonVerified) { + verified = false; + } else if (e.getSource() == menuVerified) { + verified = true; + } else if (e.getSource() == isRegular) { + reqType = REGULAR_REQ; + } else if (e.getSource() == isSafety) { + reqType = SAFETY_REQ; + } else if (e.getSource() == isSecurity) { + reqType = SECURITY_REQ; + } else { + return editAttributes(); + } + + + return true; + } + + public String toString() { + String ret = getValue(); + + ret += "ID=" + id; + + ret += " " + text; + ret += " criticality=" + criticality; + + return ret; + } + + protected String translateExtraParam() { + StringBuffer sb = new StringBuffer("<extraparam>\n"); + + if (texts != null) { + for(int i=0; i<texts.length; i++) { + //value = value + texts[i] + "\n"; + sb.append("<textline data=\""); + sb.append(GTURTLEModeling.transformString(texts[i])); + sb.append("\" />\n"); + } + } + sb.append("<kind data=\""); + sb.append(kind); + sb.append("\" />\n"); + sb.append("<criticality data=\""); + sb.append(criticality); + sb.append("\" />\n"); + sb.append("<reqType data=\""); + sb.append(reqType); + sb.append("\" />\n"); + sb.append("<id data=\""); + sb.append(id); + sb.append("\" />\n"); + sb.append("<satisfied data=\""); + sb.append(satisfied); + sb.append("\" />\n"); + sb.append("<verified data=\""); + sb.append(verified); + sb.append("\" />\n"); + sb.append("<attackTreeNode data=\""); + sb.append(attackTreeNode); + sb.append("\" />\n"); + sb.append("<violatedAction data=\""); + sb.append(violatedAction); + sb.append("\" />\n"); + sb.append("<referenceElements data=\""); + sb.append(referenceElements); + sb.append("\" />\n"); + sb.append("</extraparam>\n"); + return new String(sb); + } + + + public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ + try { + NodeList nli; + Node n1, n2; + Element elt; + String oldtext = text; + text = ""; + String s; + + //System.out.println("Loading tclass " + getValue()); + //System.out.println(nl.toString()); + + for(int i=0; i<nl.getLength(); i++) { + n1 = nl.item(i); + if (n1.getNodeType() == Node.ELEMENT_NODE) { + nli = n1.getChildNodes(); + for(int j=0; j<nli.getLength(); j++) { + n2 = nli.item(j); + if (n2.getNodeType() == Node.ELEMENT_NODE) { + elt = (Element) n2; + if (elt.getTagName().equals("textline")) { + //System.out.println("Analyzing line0"); + s = elt.getAttribute("data"); + if (s.equals("null")) { + s = ""; + } + text += GTURTLEModeling.decodeString(s) + "\n"; + } else if (elt.getTagName().equals("kind")) { + //System.out.println("Analyzing line1"); + kind = elt.getAttribute("data"); + if (kind.equals("null")) { + kind = ""; + } + } else if (elt.getTagName().equals("criticality")) { + //System.out.println("Analyzing line2"); + criticality = elt.getAttribute("data"); + if (criticality.equals("null")) { + criticality = ""; + } + } else if (elt.getTagName().equals("violatedAction")) { + //System.out.println("Analyzing line2"); + violatedAction = elt.getAttribute("data"); + if (violatedAction.equals("null")) { + violatedAction = ""; + } + } else if (elt.getTagName().equals("attackTreeNode")) { + //System.out.println("Analyzing line2"); + attackTreeNode = elt.getAttribute("data"); + if (attackTreeNode.equals("null")) { + attackTreeNode = ""; + } + } else if (elt.getTagName().equals("referenceElements")) { + //System.out.println("Analyzing line2"); + referenceElements = elt.getAttribute("data"); + if (referenceElements.equals("null")) { + referenceElements = ""; + } + } else if (elt.getTagName().equals("reqType")) { + //System.out.println("Analyzing line2"); + s = elt.getAttribute("data"); + if (s.equals("null")) { + reqType = REGULAR_REQ; + } else { + try { + reqType = Integer.decode(s).intValue(); + } catch (Exception e) { + reqType = REGULAR_REQ; + } + } + if (reqType > (NB_REQ_TYPE-1)) { + reqType = REGULAR_REQ; + } + + } else if (elt.getTagName().equals("id")) { + //System.out.println("Analyzing line3"); + id = elt.getAttribute("data"); + if (id.equals("null")) { + id = ""; + } + //System.out.println("Analyzing line4"); + } else if (elt.getTagName().equals("satisfied")) { + //System.out.println("Analyzing line3"); + s = elt.getAttribute("data"); + if (s.equals("null")) { + satisfied = false; + } else { + if (s.equals("true")) { + satisfied = true; + } else { + satisfied = false; + } + } + //System.out.println("Analyzing line4"); + } else if (elt.getTagName().equals("verified")) { + //System.out.println("Analyzing line3"); + s = elt.getAttribute("data"); + if (s.equals("null")) { + verified = false; + } else { + if (s.equals("true")) { + verified = true; + } else { + verified = false; + } + } + } + //System.out.println("Analyzing line4"); + } + } + } + } + if (text.length() == 0) { + text = oldtext; + } + } catch (Exception e) { + TraceManager.addError("Failed when loading requirement extra parameters (AVATARRD)"); + throw new MalformedModelingException(); + } + + makeValue(); + } + + + public String getText() { + return text; + } + + public String getID() { + return id; + } + + public String getKind() { + return kind; + } + + public String getViolatedAction() { + return violatedAction; + } + + public String getAttackTreeNode() { + return attackTreeNode; + } + + public String getReferenceElements() { + return referenceElements; + } + + public int getCriticality() { + //System.out.println("Criticality=" + criticality); + if (criticality.compareTo("High") == 0) { + return AvatarRDRequirement.HIGH; + } else if (criticality.compareTo("Medium") == 0) { + return AvatarRDRequirement.MEDIUM; + } else { + return AvatarRDRequirement.LOW; + } + } + + public String getAttributes() { + String attr = "ID=" + id + "\n"; + attr += "Text= " + text + "\n"; + attr += "Kind= " + kind + "\n"; + attr += "Risk= " + criticality + "\n"; + attr += "References= " + referenceElements + "\n"; + if (reqType == SAFETY_REQ) { + attr += "Violated action= " + violatedAction + "\n"; + } + if (reqType == SECURITY_REQ) { + attr += "Attack tree node(s)= " + attackTreeNode + "\n"; + } + return attr; + } + + public void autoAdjust(int mode) { + //System.out.println("Auto adjust in mode = " + mode); + + if (graphics == null) { + return; + } + + Font f = graphics.getFont(); + Font f0 = f.deriveFont((float)currentFontSize); + Font f1 = f0.deriveFont(Font.BOLD); + Font f2 = f.deriveFont((float)(currentFontSize - 2)); + + // Must find for both modes which width is desirable + String s0, s1; + s0 = REQ_TYPE_STR[reqType]; + s1 = "Text="; + + graphics.setFont(f2); + int w0 = graphics.getFontMetrics().stringWidth(s0); + graphics.setFont(f1); + int w1 = graphics.getFontMetrics().stringWidth(value); + int w2 = Math.max(w0, w1) + (2 * iconSize); + + graphics.setFont(f0); + int w3, w4 = w2; + int i; + + if(texts.length == 1) { + w3 = graphics.getFontMetrics().stringWidth(s1 + "=\"" + texts[0] + "\""); + w4 = Math.max(w4, w3); + } else { + for(i=0; i<texts.length; i++) { + if (i == 0) { + w3 = graphics.getFontMetrics().stringWidth(s1 + "=\"" + texts[i]); + } else if (i == (texts.length - 1)) { + w3 = graphics.getFontMetrics().stringWidth(texts[i] + "\""); + } else { + w3 = graphics.getFontMetrics().stringWidth(texts[i]); + } + + w4 = Math.max(w4, w3+2); + } + } + w3 = graphics.getFontMetrics().stringWidth("Kind=\"" + kind + "\"") + 2; + w4 = Math.max(w4, w3); + w3 = graphics.getFontMetrics().stringWidth("Risk=\"" + criticality + "\"") + 2; + w4 = Math.max(w4, w3); + w3 = graphics.getFontMetrics().stringWidth("ID=\"" + id + "\"") + 2; + w4 = Math.max(w4, w3); + + if (mode == 1) { + resize(w4, lineHeight); + return; + } + + int h; + if (mode == 2) { + h = ((texts.length + 4) * currentFontSize) + lineHeight; + } else { + h = ((texts.length + 5) * currentFontSize) + lineHeight; + } + + + resize(w4, h); + + } + +} diff --git a/src/ui/avatarmad/AvatarMADAssumptionConnectingPoint.java b/src/ui/avatarmad/AvatarMADAssumptionConnectingPoint.java new file mode 100644 index 0000000000000000000000000000000000000000..6bd62afcb40785372cac42e44a586a39d6b09b2e --- /dev/null +++ b/src/ui/avatarmad/AvatarMADAssumptionConnectingPoint.java @@ -0,0 +1,87 @@ +/**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 AvatarRDConnectingPointDerive + * Definition of connecting points on which connectors between requirements may be connected + * Creation: 20/04/2010 + * @version 1.0 20/04/2010 + * @author Ludovic APVRILLE + * @see + */ + +package ui.avatarrd; + +//import java.awt.*; + +import ui.*; + +public class AvatarRDConnectingPointDerive extends TGConnectingPointWidthHeight { + + public AvatarRDConnectingPointDerive(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h, int _orientation) { + super(_container, _x, _y, _in, _out, _w, _h); + orientation = _orientation; + } + + public boolean isCompatibleWith(int type) { + //System.out.println("is compatible with " + type); + if (type == TGComponentManager.AVATARRD_DERIVE_CONNECTOR) { + //System.out.println("is compatible with:true"); + return true; + } + + if (type == TGComponentManager.AVATARRD_COMPOSITION_CONNECTOR) { + //System.out.println("is compatible with:true"); + return true; + } + + if (type == TGComponentManager.AVATARRD_COPY_CONNECTOR) { + //System.out.println("is compatible with:true"); + return true; + } + + if (type == TGComponentManager.AVATARRD_REFINE_CONNECTOR) { + //System.out.println("is compatible with:true"); + return true; + } + //System.out.pr + //System.out.println("is compatible with:false"); + return false; + } + + +} \ No newline at end of file diff --git a/src/ui/avatarmad/AvatarMADCompositionConnector.java b/src/ui/avatarmad/AvatarMADCompositionConnector.java new file mode 100644 index 0000000000000000000000000000000000000000..d984762576125e4f62b1c016942449fbb34c2d02 --- /dev/null +++ b/src/ui/avatarmad/AvatarMADCompositionConnector.java @@ -0,0 +1,132 @@ +/**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 AvatarRDCompositionConnector + * Connector to be used in Avatar RD. Connects two requirements +* Creation: 20/04/2010 +* @version 1.0 20/04/2010 + * @author Ludovic APVRILLE + * @see + */ + +package ui.avatarrd; + +import java.awt.*; +//import java.awt.geom.*; +import java.util.*; + +import myutil.*; + +import ui.*; + +public class AvatarRDCompositionConnector extends TGConnectorWithCommentConnectionPoints { + int w, h; + private int radius = 5; + + public AvatarRDCompositionConnector(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); + value = "<<composition>>"; + + myImageIcon = IconManager.imgic1012; + } + + + protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ + + //g.drawLine(x1, y1, x2, y2); + //GraphicLib.dashedArrowWithLine(g, 1, 1, 0, x1, y1, x2, y2, false); + g.drawLine(x1, y1, x2, y2); + + int orientation = p2.getOrientation(); + + switch(orientation) { + case TGConnectingPoint.NORTH: + y2 = y2 - radius; + break; + case TGConnectingPoint.EAST: + x2 = x2 + radius; + break; + case TGConnectingPoint.SOUTH: + y2 = y2 + radius; + break; + case TGConnectingPoint.WEST: + x2 = x2 - radius; + break; + } + //g.drawLine(x1, y1, x2, y2 + radius); + Color c = g.getColor(); + g.setColor(Color.WHITE); + g.fillOval(x2-radius+1, y2-radius+1, (2*radius), (2*radius)); + g.setColor(c); + g.drawOval(x2-radius, y2-radius, 2*radius, 2*radius); + g.drawLine(x2, y2-radius, x2, y2+radius); + g.drawLine(x2-radius, y2, x2+radius, y2); + + // Indicate semantics + /*Font f = g.getFont(); + Font old = f; + if (f.getSize() != tdp.getFontSize()) { + f = f.deriveFont((float)tdp.getFontSize()); + g.setFont(f); + } + + w = g.getFontMetrics().stringWidth(value); + h = g.getFontMetrics().getHeight(); + g.drawString(value, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2); + g.setFont(old);*/ + } + + /*public TGComponent extraIsOnOnlyMe(int x1, int y1) { + if (GraphicLib.isInRectangle(x1, y1, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2 - h, w, h)) { + return this; + } + return null; + }*/ + + public int getType() { + return TGComponentManager.AVATARRD_COMPOSITION_CONNECTOR; + } + +} + + + + + + + diff --git a/src/ui/avatarmad/AvatarMADDiagramReference.java b/src/ui/avatarmad/AvatarMADDiagramReference.java new file mode 100644 index 0000000000000000000000000000000000000000..742629afa75980c057355062266cfbc22322cebe --- /dev/null +++ b/src/ui/avatarmad/AvatarMADDiagramReference.java @@ -0,0 +1,377 @@ +/**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 AvatarRDProperty +* Avatar property: to be used in avatar requirement diagrams +* Creation: 20/04/2010 +* @version 1.0 20/04/2010 +* @author Ludovic APVRILLE +* @see +*/ + +package ui.avatarrd; + + + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +public class AvatarRDProperty extends TGCScalableWithInternalComponent implements TGAutoAdjust { + public String oldValue; + protected int textX = 5; + protected int textY = 22; + protected int lineHeight = 30; + private double dlineHeight = 0.0; + //protected int startFontSize = 10; + protected Graphics graphics; + //protected int iconSize = 30; + + private Font myFont, myFontB; + private int maxFontSize = 30; + private int minFontSize = 4; + private int currentFontSize = -1; + private boolean displayText = true; + + protected final static String PROPERTY = "<<Property>>"; + + protected String diagramText; + protected String violatedAction = "noAction"; + + private int iconSize = 18; + private boolean iconIsDrawn = false; + + public AvatarRDProperty(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + initScaling(150, lineHeight); + oldScaleFactor = tdp.getZoom(); + dlineHeight = lineHeight * oldScaleFactor; + lineHeight = (int)dlineHeight; + dlineHeight = dlineHeight - lineHeight; + + minWidth = 10; + minHeight = lineHeight; + + nbConnectingPoint = 12; + connectingPoint = new TGConnectingPoint[nbConnectingPoint]; + connectingPoint[0] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.0, 0.25); + connectingPoint[1] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.0, 0.5); + connectingPoint[2] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.0, 0.75); + connectingPoint[3] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 1.0, 0.25); + connectingPoint[4] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 1.0, 0.5); + connectingPoint[5] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 1.0, 0.75); + connectingPoint[6] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.25, 0.0); + connectingPoint[7] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.5, 0.0); + connectingPoint[8] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.75, 0.0); + connectingPoint[9] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.25, 1.0); + connectingPoint[10] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.5, 1.0); + connectingPoint[11] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.75, 1.0); + + addTGConnectingPointsCommentTop(); + + nbInternalTGComponent = 0; + //tgcomponent = new TGComponent[nbInternalTGComponent]; + + int h = 1; + //TAttributeRequirement tgc0; + //tgc0 = new TAttributeRequirement(x, y+height+h, 0, 0, height + h, height+h, true, this, _tdp); + //tgcomponent[0] = tgc0; + + moveable = true; + editable = true; + removable = true; + userResizable = true; + multieditable = true; + + + // Name of the observer + name = "AvatarProperty"; + value = "AvatarProperty"; + //value = tdp.findRequirementName("Requirement_"); + oldValue = value; + + myImageIcon = IconManager.imgic5100; + + diagramText = "no diagram"; + + actionOnAdd(); + } + + + public void internalDrawing(Graphics g) { + Font f = g.getFont(); + Font fold = f; + int w, c; + int size; + + if (!tdp.isScaled()) { + graphics = g; + } + + if (((rescaled) && (!tdp.isScaled())) || myFont == null) { + currentFontSize = tdp.getFontSize(); + //System.out.println("Rescaled, font size = " + currentFontSize + " height=" + height); + myFont = f.deriveFont((float)currentFontSize); + myFontB = myFont.deriveFont(Font.BOLD); + + if (rescaled) { + rescaled = false; + } + } + + if(currentFontSize <minFontSize) { + displayText = false; + } else { + displayText = true; + } + + int h = g.getFontMetrics().getHeight(); + + g.drawRect(x, y, width, height); + + g.drawLine(x, y+lineHeight, x+width, y+lineHeight); + g.setColor(ColorManager.AVATAR_REQUIREMENT_TOP); + g.fillRect(x+1, y+1, width-1, lineHeight-1); + g.setColor(ColorManager.AVATAR_REQUIREMENT_ATTRIBUTES); + g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); + ColorManager.setColor(g, getState(), 0); + if ((lineHeight > 23) && (width > 23)){ + g.drawImage(IconManager.img5100, x + width - iconSize + 1, y + 3, Color.yellow, null); + } + + if (displayText) { + size = currentFontSize - 2; + g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2))); + drawLimitedString(g, PROPERTY, x, y + size, width, 1); + size += currentFontSize; + g.setFont(myFontB); + w = g.getFontMetrics().stringWidth(value); + drawLimitedString(g, value, x, y + size, width, 1); + + } + + /*g.setFont(myFont); + + size = lineHeight + currentFontSize; + if (size < (height - 2)) { + drawLimitedString(g, "Diagram=\"" + diagramText + "\"", x + textX, y + size, width, 0); + size += currentFontSize; + // Violated action + if (size < (height - 2)) { + drawLimitedString(g, "Violated_Action=\"" + violatedAction + "\"", x + textX, y + size, width, 0); + } + }*/ + g.setFont(f); + } + + public boolean editOndoubleClick(JFrame frame, int _x, int _y) { + oldValue = value; + + if ((displayText) && (_y <= (y + lineHeight))) { + String texti = getName() + ": "; + if (hasFather()) { + texti = getTopLevelName() + " / " + diagramText; + } + String s = (String)JOptionPane.showInputDialog(frame, texti, + "setting value", JOptionPane.PLAIN_MESSAGE, IconManager.imgic101, + null, + getValue()); + + if ((s != null) && (s.length() > 0) && (!s.equals(oldValue))) { + //boolean b; + if (!TAttribute.isAValidId(s, false, false)) { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the Property: the new name is not a valid name", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + + if (!tdp.isRequirementNameUnique(s)) { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the Property: the new name is already in use", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + + + int size = graphics.getFontMetrics().stringWidth(s) + iconSize + 5; + minDesiredWidth = Math.max(size, minWidth); + if (minDesiredWidth != width) { + newSizeForSon(null); + } + setValue(s); + + if (tdp.actionOnDoubleClick(this)) { + return true; + } else { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the Property: this name is already in use", + "Error", + JOptionPane.INFORMATION_MESSAGE); + setValue(oldValue); + } + } + return false; + } else { + //return editAttributes(); + return false; + } + + } + + /*public boolean editAttributes() { + JDialogObserver jdo = new JDialogObserver(tdp.getGUI().getFrame(), "Setting diagrams of Observer " + getRequirementObserverName(), diagramText, violatedAction); + jdo.setSize(750, 400); + GraphicLib.centerOnParent(jdo); + jdo.show(); + + if (!jdo.isRegularClose()) { + return false; + } + + diagramText = jdo.getText(); + violatedAction = jdo.getViolatedAction(); + + return true; + }*/ + + public void rescale(double scaleFactor){ + dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; + lineHeight = (int)(dlineHeight); + dlineHeight = dlineHeight - lineHeight; + minHeight = lineHeight; + + super.rescale(scaleFactor); + } + + + public TGComponent isOnOnlyMe(int x1, int y1) { + if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { + return this; + } + return null; + } + + public String getRequirementObserverName() { + return value; + } + + + public int getType() { + return TGComponentManager.AVATARRD_PROPERTY; + } + + /* public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { + componentMenu.addSeparator(); + JMenuItem generate = null; + // Should verify first whether it is connected to a formal requirement with a verify relation, or not + generate = new JMenuItem("Generate on diagrams"); + + generate.addActionListener(menuAL); + componentMenu.add(generate); + + JMenuItem editAttributes = new JMenuItem("Edit attributes"); + editAttributes.addActionListener(menuAL); + componentMenu.add(editAttributes); + } + + public boolean eventOnPopup(ActionEvent e) { + String s = e.getActionCommand(); + if (s.indexOf("diagrams") > -1) { + // To be implemented! + } else { + return editAttributes(); + } + return true; + }*/ + + public String toString() { + String ret = getValue() + PROPERTY; + return ret; + } + + public void autoAdjust(int mode) { + //System.out.println("Auto adjust in mode = " + mode); + + if (graphics == null) { + return; + } + + Font f = graphics.getFont(); + Font f0 = f.deriveFont((float)currentFontSize); + Font f1 = f0.deriveFont(Font.BOLD); + Font f2 = f.deriveFont((float)(currentFontSize - 2)); + + // Must find for both modes which width is desirable + String s0, s1; + + s0 = PROPERTY; + + graphics.setFont(f2); + int w0 = graphics.getFontMetrics().stringWidth(s0); + graphics.setFont(f1); + int w1 = graphics.getFontMetrics().stringWidth(value); + int w2 = Math.max(w0, w1) + (2 * iconSize); + graphics.setFont(f0); + /*int w3 = graphics.getFontMetrics().stringWidth("Diagram=\"" + diagramText + "\"") + textX; + int w4 = graphics.getFontMetrics().stringWidth("Violated_Action=\"" + violatedAction + "\"") + textX; + graphics.setFont(f); + + w2 = Math.max(w2, w3); + w2 = Math.max(w2, w4);*/ + if (mode == 1) { + resize(w2, lineHeight); + return; + } + + int h = (3 * currentFontSize) + lineHeight; + + resize(w2, h); + + } + +} \ No newline at end of file diff --git a/src/ui/avatarmad/AvatarMADElementReference.java b/src/ui/avatarmad/AvatarMADElementReference.java new file mode 100644 index 0000000000000000000000000000000000000000..742629afa75980c057355062266cfbc22322cebe --- /dev/null +++ b/src/ui/avatarmad/AvatarMADElementReference.java @@ -0,0 +1,377 @@ +/**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 AvatarRDProperty +* Avatar property: to be used in avatar requirement diagrams +* Creation: 20/04/2010 +* @version 1.0 20/04/2010 +* @author Ludovic APVRILLE +* @see +*/ + +package ui.avatarrd; + + + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +import org.w3c.dom.*; + +import myutil.*; +import ui.*; +import ui.window.*; + +public class AvatarRDProperty extends TGCScalableWithInternalComponent implements TGAutoAdjust { + public String oldValue; + protected int textX = 5; + protected int textY = 22; + protected int lineHeight = 30; + private double dlineHeight = 0.0; + //protected int startFontSize = 10; + protected Graphics graphics; + //protected int iconSize = 30; + + private Font myFont, myFontB; + private int maxFontSize = 30; + private int minFontSize = 4; + private int currentFontSize = -1; + private boolean displayText = true; + + protected final static String PROPERTY = "<<Property>>"; + + protected String diagramText; + protected String violatedAction = "noAction"; + + private int iconSize = 18; + private boolean iconIsDrawn = false; + + public AvatarRDProperty(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { + super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); + + initScaling(150, lineHeight); + oldScaleFactor = tdp.getZoom(); + dlineHeight = lineHeight * oldScaleFactor; + lineHeight = (int)dlineHeight; + dlineHeight = dlineHeight - lineHeight; + + minWidth = 10; + minHeight = lineHeight; + + nbConnectingPoint = 12; + connectingPoint = new TGConnectingPoint[nbConnectingPoint]; + connectingPoint[0] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.0, 0.25); + connectingPoint[1] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.0, 0.5); + connectingPoint[2] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.0, 0.75); + connectingPoint[3] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 1.0, 0.25); + connectingPoint[4] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 1.0, 0.5); + connectingPoint[5] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 1.0, 0.75); + connectingPoint[6] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.25, 0.0); + connectingPoint[7] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.5, 0.0); + connectingPoint[8] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.75, 0.0); + connectingPoint[9] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.25, 1.0); + connectingPoint[10] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.5, 1.0); + connectingPoint[11] = new AvatarRDConnectingPointVerify(this, 0, 0, false, true, 0.75, 1.0); + + addTGConnectingPointsCommentTop(); + + nbInternalTGComponent = 0; + //tgcomponent = new TGComponent[nbInternalTGComponent]; + + int h = 1; + //TAttributeRequirement tgc0; + //tgc0 = new TAttributeRequirement(x, y+height+h, 0, 0, height + h, height+h, true, this, _tdp); + //tgcomponent[0] = tgc0; + + moveable = true; + editable = true; + removable = true; + userResizable = true; + multieditable = true; + + + // Name of the observer + name = "AvatarProperty"; + value = "AvatarProperty"; + //value = tdp.findRequirementName("Requirement_"); + oldValue = value; + + myImageIcon = IconManager.imgic5100; + + diagramText = "no diagram"; + + actionOnAdd(); + } + + + public void internalDrawing(Graphics g) { + Font f = g.getFont(); + Font fold = f; + int w, c; + int size; + + if (!tdp.isScaled()) { + graphics = g; + } + + if (((rescaled) && (!tdp.isScaled())) || myFont == null) { + currentFontSize = tdp.getFontSize(); + //System.out.println("Rescaled, font size = " + currentFontSize + " height=" + height); + myFont = f.deriveFont((float)currentFontSize); + myFontB = myFont.deriveFont(Font.BOLD); + + if (rescaled) { + rescaled = false; + } + } + + if(currentFontSize <minFontSize) { + displayText = false; + } else { + displayText = true; + } + + int h = g.getFontMetrics().getHeight(); + + g.drawRect(x, y, width, height); + + g.drawLine(x, y+lineHeight, x+width, y+lineHeight); + g.setColor(ColorManager.AVATAR_REQUIREMENT_TOP); + g.fillRect(x+1, y+1, width-1, lineHeight-1); + g.setColor(ColorManager.AVATAR_REQUIREMENT_ATTRIBUTES); + g.fillRect(x+1, y+1+lineHeight, width-1, height-1-lineHeight); + ColorManager.setColor(g, getState(), 0); + if ((lineHeight > 23) && (width > 23)){ + g.drawImage(IconManager.img5100, x + width - iconSize + 1, y + 3, Color.yellow, null); + } + + if (displayText) { + size = currentFontSize - 2; + g.setFont(myFont.deriveFont((float)(myFont.getSize() - 2))); + drawLimitedString(g, PROPERTY, x, y + size, width, 1); + size += currentFontSize; + g.setFont(myFontB); + w = g.getFontMetrics().stringWidth(value); + drawLimitedString(g, value, x, y + size, width, 1); + + } + + /*g.setFont(myFont); + + size = lineHeight + currentFontSize; + if (size < (height - 2)) { + drawLimitedString(g, "Diagram=\"" + diagramText + "\"", x + textX, y + size, width, 0); + size += currentFontSize; + // Violated action + if (size < (height - 2)) { + drawLimitedString(g, "Violated_Action=\"" + violatedAction + "\"", x + textX, y + size, width, 0); + } + }*/ + g.setFont(f); + } + + public boolean editOndoubleClick(JFrame frame, int _x, int _y) { + oldValue = value; + + if ((displayText) && (_y <= (y + lineHeight))) { + String texti = getName() + ": "; + if (hasFather()) { + texti = getTopLevelName() + " / " + diagramText; + } + String s = (String)JOptionPane.showInputDialog(frame, texti, + "setting value", JOptionPane.PLAIN_MESSAGE, IconManager.imgic101, + null, + getValue()); + + if ((s != null) && (s.length() > 0) && (!s.equals(oldValue))) { + //boolean b; + if (!TAttribute.isAValidId(s, false, false)) { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the Property: the new name is not a valid name", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + + if (!tdp.isRequirementNameUnique(s)) { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the Property: the new name is already in use", + "Error", + JOptionPane.INFORMATION_MESSAGE); + return false; + } + + + int size = graphics.getFontMetrics().stringWidth(s) + iconSize + 5; + minDesiredWidth = Math.max(size, minWidth); + if (minDesiredWidth != width) { + newSizeForSon(null); + } + setValue(s); + + if (tdp.actionOnDoubleClick(this)) { + return true; + } else { + JOptionPane.showMessageDialog(frame, + "Could not change the name of the Property: this name is already in use", + "Error", + JOptionPane.INFORMATION_MESSAGE); + setValue(oldValue); + } + } + return false; + } else { + //return editAttributes(); + return false; + } + + } + + /*public boolean editAttributes() { + JDialogObserver jdo = new JDialogObserver(tdp.getGUI().getFrame(), "Setting diagrams of Observer " + getRequirementObserverName(), diagramText, violatedAction); + jdo.setSize(750, 400); + GraphicLib.centerOnParent(jdo); + jdo.show(); + + if (!jdo.isRegularClose()) { + return false; + } + + diagramText = jdo.getText(); + violatedAction = jdo.getViolatedAction(); + + return true; + }*/ + + public void rescale(double scaleFactor){ + dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; + lineHeight = (int)(dlineHeight); + dlineHeight = dlineHeight - lineHeight; + minHeight = lineHeight; + + super.rescale(scaleFactor); + } + + + public TGComponent isOnOnlyMe(int x1, int y1) { + if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { + return this; + } + return null; + } + + public String getRequirementObserverName() { + return value; + } + + + public int getType() { + return TGComponentManager.AVATARRD_PROPERTY; + } + + /* public void addActionToPopupMenu(JPopupMenu componentMenu, ActionListener menuAL, int x, int y) { + componentMenu.addSeparator(); + JMenuItem generate = null; + // Should verify first whether it is connected to a formal requirement with a verify relation, or not + generate = new JMenuItem("Generate on diagrams"); + + generate.addActionListener(menuAL); + componentMenu.add(generate); + + JMenuItem editAttributes = new JMenuItem("Edit attributes"); + editAttributes.addActionListener(menuAL); + componentMenu.add(editAttributes); + } + + public boolean eventOnPopup(ActionEvent e) { + String s = e.getActionCommand(); + if (s.indexOf("diagrams") > -1) { + // To be implemented! + } else { + return editAttributes(); + } + return true; + }*/ + + public String toString() { + String ret = getValue() + PROPERTY; + return ret; + } + + public void autoAdjust(int mode) { + //System.out.println("Auto adjust in mode = " + mode); + + if (graphics == null) { + return; + } + + Font f = graphics.getFont(); + Font f0 = f.deriveFont((float)currentFontSize); + Font f1 = f0.deriveFont(Font.BOLD); + Font f2 = f.deriveFont((float)(currentFontSize - 2)); + + // Must find for both modes which width is desirable + String s0, s1; + + s0 = PROPERTY; + + graphics.setFont(f2); + int w0 = graphics.getFontMetrics().stringWidth(s0); + graphics.setFont(f1); + int w1 = graphics.getFontMetrics().stringWidth(value); + int w2 = Math.max(w0, w1) + (2 * iconSize); + graphics.setFont(f0); + /*int w3 = graphics.getFontMetrics().stringWidth("Diagram=\"" + diagramText + "\"") + textX; + int w4 = graphics.getFontMetrics().stringWidth("Violated_Action=\"" + violatedAction + "\"") + textX; + graphics.setFont(f); + + w2 = Math.max(w2, w3); + w2 = Math.max(w2, w4);*/ + if (mode == 1) { + resize(w2, lineHeight); + return; + } + + int h = (3 * currentFontSize) + lineHeight; + + resize(w2, h); + + } + +} \ No newline at end of file diff --git a/src/ui/avatarmad/AvatarMADImpactConnector.java b/src/ui/avatarmad/AvatarMADImpactConnector.java new file mode 100644 index 0000000000000000000000000000000000000000..01307813543cdcb3a15596156d5efa0c82393378 --- /dev/null +++ b/src/ui/avatarmad/AvatarMADImpactConnector.java @@ -0,0 +1,106 @@ +/**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 AvatarRDDeriveConnector + * Connector to be used in Avatar RD. Connects two requirements + * Creation: 20/04/2010 + * @version 1.0 20/04/2010 + * @author Ludovic APVRILLE + * @see + */ + +package ui.avatarrd; + +import java.awt.*; +//import java.awt.geom.*; +import java.util.*; + +import myutil.*; + +import ui.*; + +public class AvatarRDRefineConnector extends TGConnectorWithCommentConnectionPoints { + int w, h; + + public AvatarRDRefineConnector(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); + value = "<<refine>>"; + + myImageIcon = IconManager.imgic1008; + } + + + protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ + + //g.drawLine(x1, y1, x2, y2); + GraphicLib.dashedArrowWithLine(g, 1, 1, 0, x1, y1, x2, y2, false); + + // Indicate semantics + + Font f = g.getFont(); + Font old = f; + if (f.getSize() != tdp.getFontSize()) { + f = f.deriveFont((float)tdp.getFontSize()); + g.setFont(f); + } + + w = g.getFontMetrics().stringWidth(value); + h = g.getFontMetrics().getHeight(); + g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2)/2); + g.setFont(old); + } + + public TGComponent extraIsOnOnlyMe(int x1, int y1) { + if (GraphicLib.isInRectangle(x1, y1, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2 - h, w, h)) { + return this; + } + return null; + } + + public int getType() { + return TGComponentManager.AVATARRD_REFINE_CONNECTOR; + } + +} + + + + + + + diff --git a/src/ui/avatarmad/AvatarMADPanel.java b/src/ui/avatarmad/AvatarMADPanel.java new file mode 100644 index 0000000000000000000000000000000000000000..a5160e03703989016ddf76c0bbfd069df5321c53 --- /dev/null +++ b/src/ui/avatarmad/AvatarMADPanel.java @@ -0,0 +1,134 @@ +/**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 AvatarMADPanel + * Panel for drawing Avatar Model Assumption Panels +* Creation: 20/04/2010 +* @version 1.0 20/04/2010 + * @author Ludovic APVRILLE + * @see + */ + +package ui.avatarmad; + +//import java.awt.*; +import java.util.*; + +import ui.*; + +public class AvatarMADPanel extends TDiagramPanel implements TDPWithAttributes { + + + public AvatarMADPanel(MainGUI mgui, TToolBar _ttb) { + super(mgui, _ttb); + /*TDiagramMouseManager tdmm = new TDiagramMouseManager(this); + addMouseListener(tdmm); + addMouseMotionListener(tdmm);*/ + } + + public boolean actionOnDoubleClick(TGComponent tgc) { + return true; + } + + public boolean actionOnAdd(TGComponent tgc) { + /*if (tgc instanceof TCDTClass) { + TCDTClass tgcc = (TCDTClass)(tgc); + mgui.addTClass(tgcc.getClassName()); + return true; + }*/ + return false; + } + + public boolean actionOnRemove(TGComponent tgc) { + /*if (tgc instanceof TCDTClass) { + TCDTClass tgcc = (TCDTClass)(tgc); + mgui.removeTClass(tgcc.getClassName()); + resetAllInstancesOf(tgcc); + return true; + }*/ + return false; + } + + public boolean actionOnValueChanged(TGComponent tgc) { + /*if (tgc instanceof TCDTClass) { + return actionOnDoubleClick(tgc); + }*/ + return false; + } + + public String getXMLHead() { + return "<AvatarMADPanel name=\"" + name + "\"" + sizeParam() + zoomParam() + " >"; + } + + public String getXMLTail() { + return "</AvatarMADPanel>"; + } + + public String getXMLSelectedHead() { + return "<AvatarMADPanelCopy name=\"" + name + "\" xSel=\"" + xSel + "\" ySel=\"" + ySel + "\" widthSel=\"" + widthSel + "\" heightSel=\"" + heightSel + "\" >"; + } + + public String getXMLSelectedTail() { + return "</AvatarMADPanelCopy>"; + } + + public String getXMLCloneHead() { + return "<AvatarMADPanelCopy name=\"" + name + "\" xSel=\"" + 0 + "\" ySel=\"" + 0 + "\" widthSel=\"" + 0 + "\" heightSel=\"" + 0 + "\" >"; + } + + public String getXMLCloneTail() { + return "</AvatarMADPanelCopy>"; + } + + + public void makePostLoadingProcessing() throws MalformedModelingException { + + } + + public void enhance() { + autoAdjust(); + } + +} + + + + + + + diff --git a/src/ui/avatarmad/AvatarMADToOthersConnectingPoint.java b/src/ui/avatarmad/AvatarMADToOthersConnectingPoint.java new file mode 100644 index 0000000000000000000000000000000000000000..6bd62afcb40785372cac42e44a586a39d6b09b2e --- /dev/null +++ b/src/ui/avatarmad/AvatarMADToOthersConnectingPoint.java @@ -0,0 +1,87 @@ +/**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 AvatarRDConnectingPointDerive + * Definition of connecting points on which connectors between requirements may be connected + * Creation: 20/04/2010 + * @version 1.0 20/04/2010 + * @author Ludovic APVRILLE + * @see + */ + +package ui.avatarrd; + +//import java.awt.*; + +import ui.*; + +public class AvatarRDConnectingPointDerive extends TGConnectingPointWidthHeight { + + public AvatarRDConnectingPointDerive(CDElement _container, int _x, int _y, boolean _in, boolean _out, double _w, double _h, int _orientation) { + super(_container, _x, _y, _in, _out, _w, _h); + orientation = _orientation; + } + + public boolean isCompatibleWith(int type) { + //System.out.println("is compatible with " + type); + if (type == TGComponentManager.AVATARRD_DERIVE_CONNECTOR) { + //System.out.println("is compatible with:true"); + return true; + } + + if (type == TGComponentManager.AVATARRD_COMPOSITION_CONNECTOR) { + //System.out.println("is compatible with:true"); + return true; + } + + if (type == TGComponentManager.AVATARRD_COPY_CONNECTOR) { + //System.out.println("is compatible with:true"); + return true; + } + + if (type == TGComponentManager.AVATARRD_REFINE_CONNECTOR) { + //System.out.println("is compatible with:true"); + return true; + } + //System.out.pr + //System.out.println("is compatible with:false"); + return false; + } + + +} \ No newline at end of file diff --git a/src/ui/avatarmad/AvatarMADToolBar.java b/src/ui/avatarmad/AvatarMADToolBar.java new file mode 100644 index 0000000000000000000000000000000000000000..ffa78ac938f862b4516ef74e971aa073d359f7a0 --- /dev/null +++ b/src/ui/avatarmad/AvatarMADToolBar.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 AvatarRDToolBar + * Implements the toolbar to be used in conjunction with the Avatar Requirement Diagram +* Creation: 20/04/2010 +* @version 1.0 20/04/2010 + * @author Ludovic APVRILLE + * @see + */ + +package ui.avatarrd; + +import javax.swing.*; +//import java.awt.*; +//import java.awt.event.*; + +import ui.*; + +public class AvatarRDToolBar extends TToolBar { + + public AvatarRDToolBar(MainGUI _mgui) { + super(_mgui); + + } + + protected void setActive(boolean b) { + mgui.actions[TGUIAction.ACT_ZOOM_MORE].setEnabled(b); + mgui.actions[TGUIAction.ACT_ZOOM_LESS].setEnabled(b); + + mgui.actions[TGUIAction.ACT_SHOW_ZOOM].setEnabled(b); + mgui.updateZoomInfo(); + + mgui.actions[TGUIAction.ARD_EDIT].setEnabled(b); + mgui.actions[TGUIAction.UML_NOTE].setEnabled(b); + mgui.actions[TGUIAction.CONNECTOR_COMMENT].setEnabled(b); + mgui.actions[TGUIAction.ARD_REQUIREMENT].setEnabled(b); + mgui.actions[TGUIAction.ARD_PROPERTY].setEnabled(b); + mgui.actions[TGUIAction.ARD_VERIFY_CONNECTOR].setEnabled(b); + mgui.actions[TGUIAction.ARD_DERIVE_CONNECTOR].setEnabled(b); + mgui.actions[TGUIAction.ARD_REFINE_CONNECTOR].setEnabled(b); + mgui.actions[TGUIAction.ARD_COPY_CONNECTOR].setEnabled(b); + mgui.actions[TGUIAction.ARD_COMPOSITION_CONNECTOR].setEnabled(b); + + mgui.actions[TGUIAction.ACT_TOGGLE_ATTR].setEnabled(b); + + mgui.actions[TGUIAction.ACT_ENHANCE].setEnabled(b); + + } + + protected void setButtons() { + JButton button; + + button = this.add(mgui.actions[TGUIAction.ARD_EDIT]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.UML_NOTE]); + button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.CONNECTOR_COMMENT]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.ARD_REQUIREMENT]); + button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.ARD_PROPERTY]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.ARD_COMPOSITION_CONNECTOR]); + button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.ARD_DERIVE_CONNECTOR]); + button.addMouseListener(mgui.mouseHandler); + + button = this.add(mgui.actions[TGUIAction.ARD_COPY_CONNECTOR]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.ARD_REFINE_CONNECTOR]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.ARD_VERIFY_CONNECTOR]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_ATTR]); + button.addMouseListener(mgui.mouseHandler); + + this.addSeparator(); + + button = this.add(mgui.actions[TGUIAction.ACT_ENHANCE]); + button.addMouseListener(mgui.mouseHandler); + + } + +} // Class + + + + + diff --git a/src/ui/avatarmad/AvatarMADVersioningConnector.java b/src/ui/avatarmad/AvatarMADVersioningConnector.java new file mode 100644 index 0000000000000000000000000000000000000000..01307813543cdcb3a15596156d5efa0c82393378 --- /dev/null +++ b/src/ui/avatarmad/AvatarMADVersioningConnector.java @@ -0,0 +1,106 @@ +/**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 AvatarRDDeriveConnector + * Connector to be used in Avatar RD. Connects two requirements + * Creation: 20/04/2010 + * @version 1.0 20/04/2010 + * @author Ludovic APVRILLE + * @see + */ + +package ui.avatarrd; + +import java.awt.*; +//import java.awt.geom.*; +import java.util.*; + +import myutil.*; + +import ui.*; + +public class AvatarRDRefineConnector extends TGConnectorWithCommentConnectionPoints { + int w, h; + + public AvatarRDRefineConnector(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); + value = "<<refine>>"; + + myImageIcon = IconManager.imgic1008; + } + + + protected void drawLastSegment(Graphics g, int x1, int y1, int x2, int y2){ + + //g.drawLine(x1, y1, x2, y2); + GraphicLib.dashedArrowWithLine(g, 1, 1, 0, x1, y1, x2, y2, false); + + // Indicate semantics + + Font f = g.getFont(); + Font old = f; + if (f.getSize() != tdp.getFontSize()) { + f = f.deriveFont((float)tdp.getFontSize()); + g.setFont(f); + } + + w = g.getFontMetrics().stringWidth(value); + h = g.getFontMetrics().getHeight(); + g.drawString(value, (x1 + x2 - w) / 2, (y1 + y2)/2); + g.setFont(old); + } + + public TGComponent extraIsOnOnlyMe(int x1, int y1) { + if (GraphicLib.isInRectangle(x1, y1, (p1.getX() + p2.getX() - w) / 2, (p1.getY() + p2.getY())/2 - h, w, h)) { + return this; + } + return null; + } + + public int getType() { + return TGComponentManager.AVATARRD_REFINE_CONNECTOR; + } + +} + + + + + + +