diff --git a/src/ui/Pragma.java b/src/ui/Pragma.java deleted file mode 100755 index c728b7843d941dae529da6415a808bdfb6f9e714..0000000000000000000000000000000000000000 --- a/src/ui/Pragma.java +++ /dev/null @@ -1,305 +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 Pragma - * Like a Note but with Pragma - * Creation: 06/12/2003 - * @version 1.0 06/12/2003 - * @author Ludovic APVRILLE - * @see - */ - -package ui; - -import java.awt.*; -import javax.swing.*; - - -import org.w3c.dom.*; - -import myutil.*; -import ui.window.*; - -public class Pragma extends TGCScalableWithoutInternalComponent { - - protected String[] values; - protected int textX = 1; - protected int textY = 2; - protected int marginY = 20; - protected int marginX = 20; - protected int limit = 15; - protected Graphics myg; - - protected Color myColor; - - private Font myFont, myFontB; - private int maxFontSize = 30; - private int minFontSize = 4; - private int currentFontSize = -1; - - protected Graphics graphics; - - public Pragma(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { - super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - - width = 150; - height = 30; - minWidth = 20; - minHeight = 10; - - oldScaleFactor = tdp.getZoom(); - - nbConnectingPoint = 0; - //addTGConnectingPointsComment(); - int len = makeTGConnectingPointsComment(16); - int decw = 0; - int dech = 0; - for(int i=0; i<2; i++) { - connectingPoint[len] = new TGConnectingPointComment(this, 0, 0, true, true, 0.0 + decw, 0.0 + dech); - connectingPoint[len + 1 ] = new TGConnectingPointComment(this, 0, 0, true, true, 0.5 + decw, 0.0 + dech); - connectingPoint[len + 2 ] = new TGConnectingPointComment(this, 0, 0, true, true, 1.0 + decw, 0.0 + dech); - connectingPoint[len + 3 ] = new TGConnectingPointComment(this, 0, 0, true, true, 0.0 + decw, 0.5 + dech); - connectingPoint[len + 4 ] = new TGConnectingPointComment(this, 0, 0, true, true, 1.0 + decw, 0.5 + dech); - connectingPoint[len + 5 ] = new TGConnectingPointComment(this, 0, 0, true, true, 0.0 + decw, 1.0 + dech); - connectingPoint[len + 6 ] = new TGConnectingPointComment(this, 0, 0, true, true, 0.5 + decw, 1.0 + dech); - connectingPoint[len + 7 ] = new TGConnectingPointComment(this, 0, 0, true, true, 0.9 + decw, 1.0 + dech); - len += 8; - } - - moveable = true; - editable = true; - removable = true; - - name = "Proverif Pragma"; - value = "Proverif List of Pragma"; - - myImageIcon = IconManager.imgic6000; - } - - public String[] getValues() { - return values; - } - - - public void internalDrawing(Graphics g) { - Font f = g.getFont(); - Font fold = f; - - /*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 (values == null) { - makeValue(); - } - - int h = g.getFontMetrics().getHeight(); - Color c = g.getColor(); - - int desiredWidth = minWidth; - for(int i=0; i< values.length; i++) { - desiredWidth = Math.max(desiredWidth, g.getFontMetrics().stringWidth(values[i]) + marginX); - } - - int desiredHeight = (values.length * currentFontSize) + textY + 1; - - //TraceManager.addDev("resize: " + desiredWidth + "," + desiredHeight); - - if ((desiredWidth != width) || (desiredHeight != height)) { - resize(desiredWidth, desiredHeight); - } - - g.drawLine(x, y, x+width, y); - g.drawLine(x, y, x, y+height); - g.drawLine(x, y+height, x+width-limit, y+height); - g.drawLine(x+width, y, x+width, y+height - limit); - - g.setColor(ColorManager.PRAGMA_BG); - int [] px1 = {x+1, x+width, x + width, x + width-limit, x+1}; - int [] py1 = {y+1, y+1, y+height-limit, y+height, y+height}; - g.fillPolygon(px1, py1, 5); - g.setColor(c); - - int [] px = {x+width, x + width - 4, x+width-10, x + width-limit}; - int [] py = {y+height-limit, y + height - limit + 3, y + height - limit + 2, y +height}; - g.drawPolygon(px, py, 4); - - if (g.getColor() == ColorManager.NORMAL_0) { - g.setColor(ColorManager.PRAGMA); - } - g.fillPolygon(px, py, 4); - - g.setColor(Color.black); - for (int i = 0; i<values.length; i++) { - //TraceManager.addDev("x+texX=" + (x + textX) + " y+textY=" + y + textY + i* h + ": " + values[i]); - g.drawString(values[i], x + textX, y + textY + (i+1)* currentFontSize); - } - g.setColor(c); - - } - - public void makeValue() { - values = Conversion.wrapText(value); - //checkMySize(); - } - - /*public void checkMySize() { - if (myg == null) { - return; - } - int desiredWidth = minWidth; - for(int i=0; i< values.length; i++) { - desiredWidth = Math.max(desiredWidth, myg.getFontMetrics().stringWidth(values[i]) + marginX); - } - - int desiredHeight = values.length * myg.getFontMetrics().getHeight() + marginY; - - if ((desiredWidth != width) || (desiredHeight != height)) { - resize(desiredWidth, desiredHeight); - } - }*/ - - public boolean editOndoubleClick(JFrame frame) { - String oldValue = value; - - JDialogNote jdn = new JDialogNote(frame, "Setting the note", value); - //jdn.setLocation(200, 150); - GraphicLib.centerOnParent(jdn); - jdn.show(); // blocked until dialog has been closed - - String s = jdn.getText(); - if ((s != null) && (s.length() > 0) && (!s.equals(oldValue))) { - String tmp = s; - /*s = GTURTLEModeling.removeForbiddenCharactersFromInput(s); - s = Conversion.replaceAllChar(s, '&', " "); - s = Conversion.replaceAllChar(s, '"', " "); - - if(s.compareTo(tmp) != 0) { - JOptionPane.showMessageDialog(frame, "Forbidden characters have been removed from the note", "Error", JOptionPane.INFORMATION_MESSAGE); - }*/ - setValue(s); - makeValue(); - return true; - } - return false; - } - - public TGComponent isOnMe(int x1, int y1) { - if (GraphicLib.isInRectangle(x1, y1, x, y, width, height)) { - return this; - } - return null; - } - - public void rescale(double scaleFactor){ - /*dlineHeight = (lineHeight + dlineHeight) / oldScaleFactor * scaleFactor; - lineHeight = (int)(dlineHeight); - dlineHeight = dlineHeight - lineHeight; - minHeight = lineHeight;*/ - - values = null; - - super.rescale(scaleFactor); - } - - public int getType() { - return TGComponentManager.PRAGMA; - } - - protected String translateExtraParam() { - if (values == null) { - makeValue(); - } - StringBuffer sb = new StringBuffer("<extraparam>\n"); - for(int i=0; i<values.length; i++) { - sb.append("<Line value=\""); - sb.append(GTURTLEModeling.transformString(values[i])); - sb.append("\" />\n"); - } - sb.append("</extraparam>\n"); - return new String(sb); - } - - public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ - value = ""; - values = null; - try { - NodeList nli; - Node n1, n2; - Element elt; - String s; - - for(int i=0; i<nl.getLength(); i++) { - n1 = nl.item(i); - //System.out.println(n1); - if (n1.getNodeType() == Node.ELEMENT_NODE) { - nli = n1.getChildNodes(); - for(int j=0; j<nli.getLength(); j++) { - n2 = nli.item(j); - //System.out.println(n2); - if (n2.getNodeType() == Node.ELEMENT_NODE) { - elt = (Element) n2; - if (elt.getTagName().equals("Line")) { - //System.out.println("Analyzing line"); - s = elt.getAttribute("value"); - if (s.equals("null")) { - s = ""; - } - value += GTURTLEModeling.decodeString(s) + "\n"; - } - } - } - } - } - - } catch (Exception e) { - throw new MalformedModelingException(); - } - } -} diff --git a/src/ui/avatarbd/AvatarBDPragma.java b/src/ui/avatarbd/AvatarBDPragma.java index ec2f435742e186046dffce4d866b82fc78fbd51f..1996345be8145ed34e11da037619f10e3924a577 100755 --- a/src/ui/avatarbd/AvatarBDPragma.java +++ b/src/ui/avatarbd/AvatarBDPragma.java @@ -90,9 +90,9 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { public AvatarBDPragma(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); - width = 150; + width = 200; height = 30; - minWidth = 20; + minWidth = 80; minHeight = 10; models = new LinkedList<String>(); properties = new LinkedList<String>(); @@ -160,7 +160,7 @@ public class AvatarBDPragma extends TGCScalableWithoutInternalComponent { Color c = g.getColor(); int desiredWidth = minWidth; - desiredWidth = Math.max(desiredWidth, g.getFontMetrics().stringWidth("Property Pragma") + marginX); + desiredWidth = Math.max(desiredWidth, 2*g.getFontMetrics().stringWidth("Property Pragma") + marginX); for(int i=0; i< values.length; i++) { desiredWidth = Math.max(desiredWidth, g.getFontMetrics().stringWidth(values[i]) + marginX); diff --git a/src/ui/window/JDialogPragma.java b/src/ui/window/JDialogPragma.java index d454f0159f15dd4d932e95587aa6848e95cba943..4f1ae6d5fce823ccb49f7ec531a658b33c1b8a54 100755 --- a/src/ui/window/JDialogPragma.java +++ b/src/ui/window/JDialogPragma.java @@ -62,7 +62,10 @@ public class JDialogPragma extends javax.swing.JDialog implements ActionListener protected JTextArea textarea; protected JButton close; protected JButton cancel; - + protected JMenuBar menuBar; + protected JButton help; + protected JPopupMenu helpPopup; + /** Creates new form */ public JDialogPragma(Frame f, String title, String _text) { super(f, title, true); @@ -74,7 +77,7 @@ public class JDialogPragma extends javax.swing.JDialog implements ActionListener //Suggestion Panel code from: http://stackoverflow.com/questions/10873748/how-to-show-autocomplete-as-i-type-in-jtextarea public class SuggestionPanel { - private final String[] pragma = {"#Constant", "#InitialSystemKnowledge", "#InitialSessionKnowledge", "#PrivatePublicKeys", "#Public", "#Confidentiality", "#Secret", "#SecrecyAssumption", "#Authenticity"}; + private final String[] pragma = {"#Authenticity", "#Confidentiality", "#Constant", "#InitialSessionKnowledge", "#InitialSystemKnowledge", "#PrivatePublicKeys", "#Public", "#SecrecyAssumption", "#Secret"}; private JList list; private JPopupMenu popupMenu; private String subWord; @@ -226,16 +229,23 @@ public class JDialogPragma extends javax.swing.JDialog implements ActionListener Font f = new Font("Helvetica", Font.PLAIN, 14); setFont(f); c.setLayout(new BorderLayout()); - //setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - + //setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + helpPopup = new JPopupMenu(); + JTextArea jft = new JTextArea("Pragma Guidelines: #Authenticity: Compare two Attributes at a given state \n #Confidentiality: Query whether the attacker knows the value of this attribute. \n #Constant: Take a guess \n #InitialSessionKnowledge: Knowledge at the start of each session\n #InitialSystemKnowledge: Knowledge at the start of the system \n #PrivatePublicKeys: The attribute Private Key followed by the attribute Public Key \n #Public: Self-explanatory \n #SecrecyAssumption: Like Secret, but with a fancier name \n #Secret: See #Confidentiality"); + helpPopup.add(jft); textarea = new JTextArea(); + textarea.setEditable(true); textarea.setMargin(new Insets(10, 10, 10, 10)); textarea.setTabSize(3); textarea.append(text); textarea.setFont(new Font("times", Font.PLAIN, 12)); + JMenuBar menuBar = new JMenuBar(); + menuBar.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); + help = new JButton("?"); + menuBar.add(help); + setJMenuBar(menuBar); textarea.addKeyListener(new KeyListener() { - @Override public void keyTyped(KeyEvent e) { if (e.getKeyChar() == KeyEvent.VK_ENTER || e.getKeyChar() == KeyEvent.VK_TAB) { @@ -282,24 +292,36 @@ public class JDialogPragma extends javax.swing.JDialog implements ActionListener } }); + + JScrollPane jsp = new JScrollPane(textarea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); jsp.setPreferredSize(new Dimension(300, 300)); c.add(jsp, BorderLayout.CENTER); + + close = new JButton("Ok", IconManager.imgic25); cancel = new JButton("Cancel", IconManager.imgic27); + help.setPreferredSize(new Dimension(30,30)); + close.setPreferredSize(new Dimension(150, 30)); cancel.setPreferredSize(new Dimension(150, 30)); close.addActionListener(this); cancel.addActionListener(this); - + help.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + help(); + } + }); JPanel jp = new JPanel(); jp.add(close); jp.add(cancel); c.add(jp, BorderLayout.SOUTH); + } public void actionPerformed(ActionEvent evt) { @@ -311,6 +333,7 @@ public class JDialogPragma extends javax.swing.JDialog implements ActionListener } else if (command.equals("Ok")) { close(); } + } public void cancel() { @@ -321,7 +344,9 @@ public class JDialogPragma extends javax.swing.JDialog implements ActionListener text = textarea.getText(); dispose(); } - + public void help(){ + helpPopup.show(help, 20, 20); + } public String getText() { return text; } diff --git a/src/ui/window/JDialogProVerifGeneration.java b/src/ui/window/JDialogProVerifGeneration.java index 73b8b41d25adb1d22e36d912bcb7e93612b06a1c..2c74937456dac84e14d24dbd95a487cc9e62973a 100644 --- a/src/ui/window/JDialogProVerifGeneration.java +++ b/src/ui/window/JDialogProVerifGeneration.java @@ -216,7 +216,7 @@ public class JDialogProVerifGeneration extends javax.swing.JDialog implements Ac c03.gridheight = 1; exegroup = new ButtonGroup(); - exe = new JRadioButton(textC2, false); + exe = new JRadioButton(textC2, true); exe.addActionListener(this); exegroup.add(exe); //exeJava.addActionListener(this);