From c9f11a2bfa31c63bf4cd701a92f95a1481714f7e Mon Sep 17 00:00:00 2001
From: Fabien Tessier <fabien.tessier@telecom-paristech.fr>
Date: Thu, 7 Dec 2017 14:24:31 +0100
Subject: [PATCH] Update Performance Pragma Dialog for project manager merge

---
 .../java/tmltranslator/SecurityPattern.java   |   1 +
 .../tmltranslator/toavatar/TML2Avatar.java    |  26 +-
 src/main/java/ui/GTURTLEModeling.java         |   2 +-
 src/main/java/ui/tmlad/TMLADEncrypt.java      |  20 +-
 .../ui/tmlad/TMLActivityDiagramPanel.java     |  10 +-
 .../JDialogCryptographicConfiguration.java    | 843 ++++++++++--------
 .../ui/window/JDialogPerformancePragma.java   | 338 +++----
 7 files changed, 690 insertions(+), 550 deletions(-)

diff --git a/src/main/java/tmltranslator/SecurityPattern.java b/src/main/java/tmltranslator/SecurityPattern.java
index e49d7afbc2..a9018cb0e2 100644
--- a/src/main/java/tmltranslator/SecurityPattern.java
+++ b/src/main/java/tmltranslator/SecurityPattern.java
@@ -56,6 +56,7 @@ public class SecurityPattern {
     public String nonce;
     public String formula;
     public String key;
+    public String algorithm="";
     
     public SecurityPattern(String _name, String _type, String _overhead, String _size, String _enctime, String _dectime, String _nonce, String _formula, String _key){
         this.name=_name;
diff --git a/src/main/java/tmltranslator/toavatar/TML2Avatar.java b/src/main/java/tmltranslator/toavatar/TML2Avatar.java
index b337ace686..d336ddaaa2 100644
--- a/src/main/java/tmltranslator/toavatar/TML2Avatar.java
+++ b/src/main/java/tmltranslator/toavatar/TML2Avatar.java
@@ -738,6 +738,8 @@ outerloop:
 								//Add aencrypt method
 								AvatarMethod aencrypt = new AvatarMethod("aencrypt", ae);
 								block.addAttribute(new AvatarAttribute("encryptedKey_"+ae.securityPattern.key, AvatarType.INTEGER, block,null));
+								block.addAttribute(new AvatarAttribute("key_"+ae.securityPattern.key, AvatarType.INTEGER, block,null));
+								block.addAttribute(new AvatarAttribute("pubKey_"+ae.securityPattern.name, AvatarType.INTEGER, block,null));
 								aencrypt.addParameter(block.getAvatarAttributeWithName("key_"+ae.securityPattern.key));
 								aencrypt.addParameter(block.getAvatarAttributeWithName("pubKey_"+ae.securityPattern.name));
 								aencrypt.addReturnParameter(block.getAvatarAttributeWithName("encryptedKey_"+ae.securityPattern.key));
@@ -767,8 +769,11 @@ outerloop:
 							ae.securityPattern.state1=as;
 						}
 						else if (ae.securityPattern.type.equals("Nonce")){
+							//Do nothing except occupy time to forge nonce
+							
+							
 							//Create a nonce by a random function
-							AvatarRandom arandom = new AvatarRandom("randomnonce",ae.getReferenceObject());
+							/*AvatarRandom arandom = new AvatarRandom("randomnonce",ae.getReferenceObject());
 							arandom.setVariable(ae.securityPattern.name);
 							arandom.setValues("0","10");
 							elementList.add(arandom);
@@ -776,7 +781,7 @@ outerloop:
 							tran = new AvatarTransition(block, "__afterrandom_"+ae.getName(), ae.getReferenceObject());
 							arandom.addNext(tran);
 							elementList.add(tran);
-							block.addAttribute(new AvatarAttribute(ae.securityPattern.name, AvatarType.INTEGER, block, null));
+							block.addAttribute(new AvatarAttribute(ae.securityPattern.name, AvatarType.INTEGER, block, null));*/
 						}
 						else if (ae.securityPattern.type.equals("Hash")){
 							AvatarMethod hash = new AvatarMethod("hash", ae);
@@ -1513,12 +1518,12 @@ outerloop:
 			distributeKeys();
 
 			System.out.println("ALL KEYS " +accessKeys);
-			for (TMLTask t: accessKeys.keySet()){
+			/*for (TMLTask t: accessKeys.keySet()){
 				System.out.println("TASK " +t.getName());
 				for (SecurityPattern sp: accessKeys.get(t)){
 					System.out.println(sp.name);
 				}
-			}
+			}*/
 
 			for (TMLTask task:tasks){
 
@@ -2042,16 +2047,16 @@ outerloop:
 					for (AvatarAttribute key: symKeys.get(sp)){
 						keys= keys+" "+key.getBlock().getName() + "."+key.getName();
 					}
-					avspec.addPragma(new AvatarPragmaInitialKnowledge("#InitialSessionKnowledge"+ keys, null, symKeys.get(sp), true));
+					avspec.addPragma(new AvatarPragmaInitialKnowledge("#InitialSessionKnowledge "+ keys, null, symKeys.get(sp), true));
 				}
 			}
 			for (SecurityPattern sp:pubKeys.keySet()){
 				if (pubKeys.get(sp).size()!=0){
 					String keys = "";
-					for (AvatarAttribute key: symKeys.get(sp)){
+					for (AvatarAttribute key: pubKeys.get(sp)){
 						keys= keys+" "+key.getBlock().getName() + "."+key.getName();
 					}
-					avspec.addPragma(new AvatarPragmaInitialKnowledge("#InitialSessionKnowledge "+sp.name, null, pubKeys.get(sp),true));
+					avspec.addPragma(new AvatarPragmaInitialKnowledge("#InitialSessionKnowledge "+keys, null, pubKeys.get(sp),true));
 				}
 			}
 			tmlmap.getTMLModeling().secChannelMap = secChannelMap;
@@ -2119,9 +2124,10 @@ outerloop:
 					else if (sp.type.equals("Asymmetric Encryption")){
 						AvatarAttribute pubkey = new AvatarAttribute("pubKey_"+sp.name, AvatarType.INTEGER, b, null);
 						b.addAttribute(pubkey);
+						
 						AvatarAttribute privkey = new AvatarAttribute("privKey_"+sp.name, AvatarType.INTEGER, b, null);
 						b.addAttribute(privkey);
-						avspec.addPragma(new AvatarPragmaPrivatePublicKey("PrivatePublicKey "+sp.name, null, privkey, pubkey));
+						avspec.addPragma(new AvatarPragmaPrivatePublicKey("#PrivatePublicKeys " +  b.getName() + " " + privkey.getName() + " " + pubkey.getName(), null, privkey, pubkey));
 						if (pubKeys.containsKey(sp)){
 							pubKeys.get(sp).add(pubkey);
 						}
@@ -2135,10 +2141,14 @@ outerloop:
 							AvatarBlock b2 = taskBlockMap.get(task2);
 							pubkey = new AvatarAttribute("pubKey_"+sp.name, AvatarType.INTEGER, b2, null);
 							b2.addAttribute(pubkey);
+							if (pubKeys.containsKey(sp)){
+								pubKeys.get(sp).add(pubkey);
+							}
 						}		
 					}
 				}
 			}
+			
 		}
 		public AvatarBlock createFifo(String name){
 			AvatarBlock fifo = new AvatarBlock("FIFO__FIFO"+name, avspec, null);
diff --git a/src/main/java/ui/GTURTLEModeling.java b/src/main/java/ui/GTURTLEModeling.java
index 90e56a2d53..5e3cfd7e18 100755
--- a/src/main/java/ui/GTURTLEModeling.java
+++ b/src/main/java/ui/GTURTLEModeling.java
@@ -9485,7 +9485,7 @@ public class GTURTLEModeling {
             else {
                 bl.addAttribute(new TAttribute(0, attr.getName(), attr.getType().getDefaultInitialValue(), type));
             }
-            if (attr.getName().contains("key_")){
+            if (attr.getName().contains("key_") || attr.getName().contains("privKey_")){
                 hasCrypto=true;
                 bl.addCryptoElements();
             }
diff --git a/src/main/java/ui/tmlad/TMLADEncrypt.java b/src/main/java/ui/tmlad/TMLADEncrypt.java
index f786c53c01..35081f5282 100755
--- a/src/main/java/ui/tmlad/TMLADEncrypt.java
+++ b/src/main/java/ui/tmlad/TMLADEncrypt.java
@@ -76,6 +76,7 @@ public class TMLADEncrypt extends TGCWithoutInternalComponent implements Embedde
     public String key ="";
     public String nonce="";
     public String formula="";
+    public String algorithm="";
     protected int stateOfError = 0; // Not yet checked
     
     public TMLADEncrypt(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp)  {
@@ -190,7 +191,7 @@ public class TMLADEncrypt extends TGCWithoutInternalComponent implements Embedde
     public boolean editOndoubleClick(JFrame frame) {
 
         //JDialogTwoString jdts = new JDialogTwoString(frame, "Setting channel's properties", "Channel name", channelName, "Nb of samples", nbOfSamples);]
-		String[] values=new String[]{securityContext, type, message_overhead, encTime, size, nonce, formula, decTime, key};
+		String[] values=new String[]{securityContext, type, message_overhead, encTime, size, nonce, formula, decTime, key,algorithm};
 		String[] nonces=tdp.getMGUI().getAllNonce();
 		String[] keys = tdp.getMGUI().getAllKeys().toArray(new String[0]);
 		JDialogCryptographicConfiguration jdms = new JDialogCryptographicConfiguration(frame, "Setting Cryptographic Configuration properties", values, nonces, keys);
@@ -200,7 +201,7 @@ public class TMLADEncrypt extends TGCWithoutInternalComponent implements Embedde
 
 	    if (jdms.hasBeenSet() && (jdms.hasValidString(0))) {
 		    securityContext = jdms.getString(0);
-		    type=jdms.getString(1);
+	 		type=jdms.getString(1);
 		    message_overhead=jdms.getString(2);
 		    encTime=jdms.getString(3);
 		    size=jdms.getString(4);
@@ -208,7 +209,7 @@ public class TMLADEncrypt extends TGCWithoutInternalComponent implements Embedde
 		    formula = jdms.getString(6);
 		    decTime = jdms.getString(7);
 		    key = jdms.getString(8);
-
+		 	algorithm=jdms.getString(9);
 		    return true;
 	    }
 
@@ -239,16 +240,18 @@ public class TMLADEncrypt extends TGCWithoutInternalComponent implements Embedde
         sb.append(type);
         sb.append("\" overhead=\"");
         sb.append(message_overhead);
-	sb.append("\" size=\"");
+		sb.append("\" size=\"");
         sb.append(size);
-	sb.append("\" encTime=\"");
+		sb.append("\" encTime=\"");
         sb.append(encTime);
-	sb.append("\" decTime=\"");
+		sb.append("\" decTime=\"");
         sb.append(decTime);
-	sb.append("\" nonce=\"");
+		sb.append("\" nonce=\"");
         sb.append(nonce);
-	sb.append("\" key=\"");
+		sb.append("\" key=\"");
         sb.append(key);
+        sb.append("\" algorithm=\"");
+        sb.append(algorithm);
         sb.append("\" />\n");
         sb.append("</extraparam>\n");
         return new String(sb);
@@ -287,6 +290,7 @@ public class TMLADEncrypt extends TGCWithoutInternalComponent implements Embedde
 								decTime = elt.getAttribute("decTime");
 								nonce = elt.getAttribute("nonce");
 								key = elt.getAttribute("key");
+								algorithm = elt.getAttribute("algorithm");
                                 //System.out.println("eventName=" +eventName + " variable=" + result);
                             }
                         }
diff --git a/src/main/java/ui/tmlad/TMLActivityDiagramPanel.java b/src/main/java/ui/tmlad/TMLActivityDiagramPanel.java
index 33877457fd..eb6be9ed1f 100755
--- a/src/main/java/ui/tmlad/TMLActivityDiagramPanel.java
+++ b/src/main/java/ui/tmlad/TMLActivityDiagramPanel.java
@@ -216,8 +216,14 @@ public class TMLActivityDiagramPanel extends TDiagramPanel {
     	for (TGComponent c: comps){
     		if (c instanceof TMLADEncrypt){
     			TMLADEncrypt en= (TMLADEncrypt) c;
-    			if (!en.securityContext.isEmpty() && (en.type.equals("Symmetric Encryption") || en.type.equals("Asymmetric Encryption") ||  en.type.equals("MAC"))){
-    				ns.add(en.securityContext);
+    			if (!en.securityContext.isEmpty()){
+    				if ((en.type.equals("Symmetric Encryption") || en.type.equals("MAC"))){
+	    				ns.add(en.securityContext);
+	    			}
+	    			else if (en.type.equals("Asymmetric Encryption")) {
+	    				ns.add(en.securityContext);
+	    				//ns.add("pubKey" + en.securityContext);
+	    			}
     			}
     		}
     	}
diff --git a/src/main/java/ui/window/JDialogCryptographicConfiguration.java b/src/main/java/ui/window/JDialogCryptographicConfiguration.java
index 200124d849..f9d5e7ebb3 100644
--- a/src/main/java/ui/window/JDialogCryptographicConfiguration.java
+++ b/src/main/java/ui/window/JDialogCryptographicConfiguration.java
@@ -48,6 +48,9 @@ import java.awt.*;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.util.HashMap;
+import java.util.Vector;
+import java.util.List;
+import java.util.ArrayList;
 
 
 /**
@@ -59,420 +62,502 @@ import java.util.HashMap;
  */
 public class JDialogCryptographicConfiguration extends JDialogBase implements ActionListener  {
 
-    private String [] values;
+	private String [] values;
 
-    private int nbString;
+	private int nbString;
 
-    private boolean set = false;
+	private boolean set = false;
 
-    private JPanel panel1;
+	private JPanel panel1;
 
-    // Panel1
-    private JTextField [] texts;
-    private JButton inserts[];
-    private HashMap<Integer, JComboBox<String>> helps;
+	private List<securityAlgorithm> secAlgs;
+	private Vector<String> algNames;
+	// Panel1
+	private JTextField [] texts;
+	private JButton inserts[];
+	private HashMap<Integer, JComboBox<String>> helps;
 
-    // Main Panel
-    private String[] nonces;
-    private String[] keys;
+	// Main Panel
+	private String[] nonces;
+	private String[] keys;
 
-    GridBagConstraints c0 = new GridBagConstraints();
-    Container c;
-    /** Creates new form  */
-    // arrayDelay: [0] -> minDelay ; [1] -> maxDelay
-    public JDialogCryptographicConfiguration(Frame f, String title, String[] _values, String[] _nonces, String[] _keys) {
+	GridBagConstraints c0 = new GridBagConstraints();
+	Container c;
+	/** Creates new form  */
+	// arrayDelay: [0] -> minDelay ; [1] -> maxDelay
+	public JDialogCryptographicConfiguration(Frame f, String title, String[] _values, String[] _nonces, String[] _keys) {
 
-        super(f, title, true);
+		super(f, title, true);
 
-        nbString = 9;
+		nbString = 10;
 
-	values=_values;
-	nonces=_nonces;
-	keys=_keys;
-        texts = new JTextField[nbString];
+		values=_values;
+		nonces=_nonces;
+		keys=_keys;
+		texts = new JTextField[nbString];
+		secAlgs= new ArrayList<securityAlgorithm>();
+		algNames=new Vector<String>();
+		initComponents();
+		myInitComponents();
+		pack();
+	}
 
-        initComponents();
-        myInitComponents();
-        pack();
-    }
 
+	private void myInitComponents() {
+	}
 
-    private void myInitComponents() {
-    }
+	private void initComponents() {
 
-    private void initComponents() {
-	inserts = new JButton[nbString];
-	helps = new HashMap<>();
+		//Add list of sample security algorithms
+		secAlgs.add(new securityAlgorithm("AES", "0","100","10","128","Symmetric Encryption"));  
+		secAlgs.add(new securityAlgorithm("Triple-DES", "0","200","200","128","Symmetric Encryption"));
+		
+		secAlgs.add(new securityAlgorithm("RSA", "0","100","100","128","Asymmetric Encryption"));    
+		secAlgs.add(new securityAlgorithm("ECC", "0","10","100","128","Asymmetric Encryption"));    
+		
+		secAlgs.add(new securityAlgorithm("SHA-256", "0","100","100","128","Hash"));    
+		secAlgs.add(new securityAlgorithm("Whirlpool", "0","100","100","128","Hash"));  
+		
+		secAlgs.add(new securityAlgorithm("Poly-1305", "0","100","100","128","MAC"));    
+		secAlgs.add(new securityAlgorithm("HMAC", "0","100","100","128","MAC")); 
+		
+		for (securityAlgorithm secAlg: secAlgs){
+			algNames.add(secAlg.name);
+		}
+		inserts = new JButton[nbString];
+		helps = new HashMap<>();
 
-        c = getContentPane();
-        GridBagLayout gridbag0 = new GridBagLayout();
+		c = getContentPane();
+		GridBagLayout gridbag0 = new GridBagLayout();
 
 
 
-        setFont(new Font("Helvetica", Font.PLAIN, 14));
-        c.setLayout(gridbag0);
+		setFont(new Font("Helvetica", Font.PLAIN, 14));
+		c.setLayout(gridbag0);
 
-        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 
-  	if (values[1].contains("Encryption") || values[1].equals("MAC") || values[1].isEmpty()){
-	    panel1= new EncryptPanel(this);
-	}
-	else {
-	    panel1=new funcPanel(this);
-	}
-	c0.gridwidth = 1;
-        c0.gridheight = 10;
-        c0.weighty = 1.0;
-        c0.weightx = 1.0;
-        c0.gridwidth = GridBagConstraints.REMAINDER; //end row
-        c.add(panel1, c0);
-
-
-
-
-        // main panel;
-        c0.gridwidth = 1;
-        c0.gridheight = 1;
-        c0.fill = GridBagConstraints.HORIZONTAL;
-        
-        initButtons(c0, c, this);
-    }
-
-    public void actionPerformed(ActionEvent evt)  {
-        String command = evt.getActionCommand();
-
-        // Compare the action command to the known actions.
-        if (command.equals("Save and Close"))  {
-            closeDialog();
-        } else if (command.equals("Cancel")) {
-            cancelDialog();
-        } else if (inserts[0] != null) {
-	    if (evt.getSource() == inserts[0]) {
-		texts[1].setText(helps.get(1).getSelectedItem().toString());
-		boolean repanel = false;
-		if (helps.get(1).getSelectedIndex()==5 && !(panel1 instanceof advPanel)){
-		    values[1]=helps.get(1).getSelectedItem().toString();
-		    values[0]=texts[0].getText();
-		    values[3]=texts[3].getText();
-		    values[2]=texts[3].getText();
-		    values[5]="";
-		    values[4]="";
-		    repanel=true;
-		    c.removeAll();
-		    panel1= new advPanel(this);
+		if (values[1].contains("Encryption") || values[1].equals("MAC") || values[1].isEmpty()){
+			panel1= new EncryptPanel(this);
 		}
-		else if ((helps.get(1).getSelectedIndex() >2) && !(panel1 instanceof funcPanel)){
-		    values[1]=helps.get(1).getSelectedItem().toString();
-		    values[0]=texts[0].getText();
-		    values[3]=texts[3].getText();
-		    values[2]="";
-		    values[5]="";
-		    values[6]="";
-		    repanel=true;
-		    c.removeAll();
-		    panel1= new funcPanel(this);
+		else {
+			panel1=new funcPanel(this);
 		}
-		else if ((helps.get(1).getSelectedIndex() <3) && !(panel1 instanceof EncryptPanel)){
-		    values[1]=helps.get(1).getSelectedItem().toString();
-		    values[0]=texts[0].getText();
-		    values[3]=texts[3].getText();
-		    values[4]="";
-		    values[6]="";
-		    c.removeAll();
-		    repanel=true;
-		    panel1= new EncryptPanel(this);
+		c0.gridwidth = 1;
+		c0.gridheight = 10;
+		c0.weighty = 1.0;
+		c0.weightx = 1.0;
+		c0.gridwidth = GridBagConstraints.REMAINDER; //end row
+		c.add(panel1, c0);
+
+		// main panel;
+		c0.gridwidth = 1;
+		c0.gridheight = 1;
+		c0.fill = GridBagConstraints.HORIZONTAL;
+		initButtons(c0, c, this);
+	}
 
+	public void actionPerformed(ActionEvent evt)  {
+		String command = evt.getActionCommand();
+
+		// Compare the action command to the known actions.
+		if (command.equals("Save and Close"))  {
+			closeDialog();
+		} else if (command.equals("Cancel")) {
+			cancelDialog();
+		} else if (inserts[0] != null) {
+			if (evt.getSource() == inserts[0]) {
+				texts[1].setText(helps.get(1).getSelectedItem().toString());
+				boolean repanel = false;
+				if (helps.get(1).getSelectedIndex()==5 && !(panel1 instanceof advPanel)){
+					values[1]=helps.get(1).getSelectedItem().toString();
+					values[0]=texts[0].getText();
+					values[3]=texts[3].getText();
+					values[2]=texts[3].getText();
+					values[5]="";
+					values[4]="";
+					values[9]=texts[9].getText();
+					repanel=true;
+					c.removeAll();
+					panel1= new advPanel(this);
+				}
+				else if ((helps.get(1).getSelectedIndex() >2) && !(panel1 instanceof funcPanel)){
+					values[1]=helps.get(1).getSelectedItem().toString();
+					values[0]=texts[0].getText();
+					values[3]=texts[3].getText();
+					values[2]="";
+					values[5]="";
+					values[6]="";
+					values[9]=texts[9].getText();
+					repanel=true;
+					c.removeAll();
+					panel1= new funcPanel(this);
+				}
+				else if ((helps.get(1).getSelectedIndex() <3) && !(panel1 instanceof EncryptPanel)){
+					values[1]=helps.get(1).getSelectedItem().toString();
+					values[0]=texts[0].getText();
+					values[3]=texts[3].getText();
+					values[4]="";
+					values[6]="";
+					values[9]="";
+					c.removeAll();
+					repanel=true;
+					panel1= new EncryptPanel(this);
+
+				}
+
+				if (repanel){
+					c0.gridwidth = 1;
+					c0.gridheight = 10;
+					c0.weighty = 1.0;
+					c0.weightx = 1.0;
+					c0.gridwidth = GridBagConstraints.REMAINDER; //end row
+
+					c.add(panel1,c0);
+					// main panel;
+					c0.gridwidth = 1;
+					c0.gridheight = 1;
+					c0.fill = GridBagConstraints.HORIZONTAL;
+					closeButton = new JButton("Save and Close", IconManager.imgic25);
+					//closeButton.setPreferredSize(new Dimension(600, 50));
+					closeButton.addActionListener(this);
+					c.add(closeButton, c0);
+					c0.gridwidth = GridBagConstraints.REMAINDER; //end row
+					cancelButton = new JButton("Cancel", IconManager.imgic27);
+					cancelButton.addActionListener(this);
+					c.add(cancelButton, c0);
+					this.invalidate();	   
+					this.validate();
+					this.repaint();
+				}
+			}
+			if (evt.getSource() == inserts[5]) {
+				if (helps.get(5).getSelectedItem()!=null){
+					texts[5].setText(helps.get(5).getSelectedItem().toString());
+				}
+			}
+			if (evt.getSource() == inserts[8]) {
+				if (helps.get(8).getSelectedItem()!=null){
+					texts[8].setText(helps.get(8).getSelectedItem().toString());
+				}
+			}
+			//Using preset algorithm
+			if (evt.getSource() == inserts[9]) {
+				if (helps.get(9).getSelectedItem()!=null){
+					texts[9].setText(helps.get(9).getSelectedItem().toString());
+					for (securityAlgorithm secAlg: secAlgs){
+						if (secAlg.name.equals(texts[9].getText())){
+							//Set algorithm times + overhead
+							texts[1].setText(secAlg.type);
+							texts[2].setText(secAlg.overhead);
+							texts[3].setText(secAlg.encryptCC);
+							texts[7].setText(secAlg.decryptCC);
+						}	
+					}
+				}
+			}
 		}
-		
-		if (repanel){
-		    c0.gridwidth = 1;
-        	    c0.gridheight = 10;
-        	    c0.weighty = 1.0;
-    		    c0.weightx = 1.0;
-    		    c0.gridwidth = GridBagConstraints.REMAINDER; //end row
-
-		    c.add(panel1,c0);
-		    // main panel;
-  		    c0.gridwidth = 1;
-  		    c0.gridheight = 1;
-  		    c0.fill = GridBagConstraints.HORIZONTAL;
- 		    closeButton = new JButton("Save and Close", IconManager.imgic25);
- 		    //closeButton.setPreferredSize(new Dimension(600, 50));
-        	    closeButton.addActionListener(this);
-        	    c.add(closeButton, c0);
-        	    c0.gridwidth = GridBagConstraints.REMAINDER; //end row
-        	    cancelButton = new JButton("Cancel", IconManager.imgic27);
-    		    cancelButton.addActionListener(this);
-   		    c.add(cancelButton, c0);
-		    this.invalidate();	   
-		    this.validate();
-		    this.repaint();
+	}
+
+
+
+	public class EncryptPanel extends JPanel {
+		EncryptPanel(JDialogCryptographicConfiguration j){
+			GridBagConstraints c1 = new GridBagConstraints();
+			GridBagLayout gridbag1 = new GridBagLayout();
+
+			this.setLayout(gridbag1);
+
+			this.setBorder(new javax.swing.border.TitledBorder("Properties"));
+
+			this.setPreferredSize(new Dimension(600, 200));
+
+			c1.weighty = 1.0;
+			c1.weightx = 1.0;
+			c1.gridwidth = GridBagConstraints.REMAINDER; //end row
+			c1.fill = GridBagConstraints.BOTH;
+			c1.gridheight = 1;
+			add(new JLabel(" "), c1);
+
+			c1.gridwidth = 1;
+			c1.gridheight = 1;
+			c1.weighty = 1.0;
+			c1.weightx = 1.0;
+			c1.anchor = GridBagConstraints.CENTER;
+			c1.fill = GridBagConstraints.HORIZONTAL;
+			c1.anchor = GridBagConstraints.CENTER;
+			String[] vals = new String[]{"Symmetric Encryption", "Asymmetric Encryption","MAC", "Hash", "Nonce", "Advanced"}; 
+			// String1
+			c1.gridwidth = 1;
+			add(new JLabel("Cryptographic Configuration Name"),c1);
+			texts[0]=new JTextField(values[0],15);
+			c1.gridwidth = GridBagConstraints.REMAINDER; //end row
+			add(texts[0],c1);
+
+			c1.gridwidth=1;
+			add(new JLabel("Security Pattern"), c1);
+			helps.put(1, new JComboBox<>(vals));
+			helps.get(1).setSelectedItem(values[1]);
+			add(helps.get(1),c1);
+			c1.gridwidth=GridBagConstraints.REMAINDER;
+			inserts[0] = new JButton("Use");
+			inserts[0].addActionListener(j);
+			add(inserts[0], c1);
+			texts[1]=new JTextField(values[1], 15);
+			add(texts[1], c1);
+
+			c1.gridwidth = 1;
+			add(new JLabel("Overhead"),c1);
+			texts[2]=new JTextField(values[2],15);
+			c1.gridwidth = GridBagConstraints.REMAINDER; //end row
+			add(texts[2],c1);
+
+			c1.gridwidth = 1;
+			add(new JLabel("Encryption Computational Complexity"),c1);
+			texts[3]=new JTextField(values[3],15);
+			c1.gridwidth = GridBagConstraints.REMAINDER; //end row
+			add(texts[3],c1);
+
+			c1.gridwidth = 1;
+			add(new JLabel("Decryption Computational Complexity"),c1);
+			texts[7]=new JTextField(values[7],15);
+			c1.gridwidth = GridBagConstraints.REMAINDER; //end row
+			add(texts[7],c1);
+
+			c1.gridwidth = 1;
+			add(new JLabel("Nonce"),c1);
+			helps.put(5, new JComboBox<>(nonces));
+			if (helps.get(5).getItemCount() > 0){
+				helps.get(5).setSelectedItem(values[5]);
+			}
+			add(helps.get(5),c1);
+			c1.gridwidth=GridBagConstraints.REMAINDER;
+			inserts[5] = new JButton("Use");
+			inserts[5].addActionListener(j);
+			add(inserts[5], c1);
+			texts[5]=new JTextField(values[5], 15);
+			add(texts[5], c1);
+
+			c1.gridwidth = 1;
+			add(new JLabel("Encrypted Key"),c1);
+			helps.put(8, new JComboBox<>(keys));
+			if (helps.get(8).getItemCount() > 0){
+				helps.get(8).setSelectedItem(values[8]);
+			}
+			add(helps.get(8),c1);
+			c1.gridwidth=GridBagConstraints.REMAINDER;
+			inserts[8] = new JButton("Use");
+			inserts[8].addActionListener(j);
+			add(inserts[8], c1);
+			texts[8]=new JTextField(values[8], 15);
+			add(texts[8], c1);
+
+			c1.gridwidth = 1;
+			add(new JLabel("Algorithm"),c1);
+			helps.put(9, new JComboBox<>(algNames));
+			helps.get(9).setSelectedItem(values[9]);
+			add(helps.get(9),c1);
+			c1.gridwidth=GridBagConstraints.REMAINDER;
+			inserts[9] = new JButton("Use");
+			inserts[9].addActionListener(j);
+			add(inserts[9], c1);
+			texts[9]=new JTextField(values[9],15);
+			c1.gridwidth = GridBagConstraints.REMAINDER; //end row
+			add(texts[9],c1);
+
 		}
-	    }
-	    if (evt.getSource() == inserts[5]) {
-		if (helps.get(5).getSelectedItem()!=null){
-		    texts[5].setText(helps.get(5).getSelectedItem().toString());
+
+
+
+	}
+
+	public class funcPanel extends JPanel {
+		funcPanel(JDialogCryptographicConfiguration j){
+			GridBagConstraints c1 = new GridBagConstraints();
+			GridBagLayout gridbag1 = new GridBagLayout();
+
+			setLayout(gridbag1);
+
+			setBorder(new javax.swing.border.TitledBorder("Properties"));
+
+			setPreferredSize(new Dimension(600, 200));
+
+			c1.weighty = 1.0;
+			c1.weightx = 1.0;
+			c1.gridwidth = GridBagConstraints.REMAINDER; //end row
+			c1.fill = GridBagConstraints.BOTH;
+			c1.gridheight = 1;
+			add(new JLabel(" "), c1);
+
+			// second line panel1
+			c1.gridwidth = 1;
+			c1.gridheight = 1;
+			c1.weighty = 1.0;
+			c1.weightx = 1.0;
+			c1.anchor = GridBagConstraints.CENTER;
+			c1.fill = GridBagConstraints.HORIZONTAL;
+			c1.anchor = GridBagConstraints.CENTER;
+			String[] vals = new String[]{"Symmetric Encryption", "Asymmetric Encryption","MAC", "Hash", "Nonce", "Advanced"}; 
+			// String1
+			c1.gridwidth = 1;
+			add(new JLabel("Cryptographic Configuration Name"),c1);
+			texts[0]=new JTextField(values[0],15);
+			c1.gridwidth = GridBagConstraints.REMAINDER; //end row
+			add(texts[0],c1);
+
+			c1.gridwidth=1;
+			add(new JLabel("Security Pattern"), c1);
+			helps.put(1, new JComboBox<>(vals));
+			helps.get(1).setSelectedItem(values[1]);
+			add(helps.get(1),c1);
+
+			c1.gridwidth=GridBagConstraints.REMAINDER;
+			inserts[0] = new JButton("Use");
+			inserts[0].addActionListener(j);
+			add(inserts[0], c1);
+			texts[1]=new JTextField(values[1], 15);
+			add(texts[1], c1);
+
+			c1.gridwidth = 1;
+			add(new JLabel("Computational Complexity"),c1);
+			texts[3]=new JTextField(values[3],15);
+			c1.gridwidth = GridBagConstraints.REMAINDER; //end row
+			add(texts[3],c1);
+
+			c1.gridwidth = 1;
+			add(new JLabel("Size"),c1);
+			texts[4]=new JTextField(values[4],15);
+			c1.gridwidth = GridBagConstraints.REMAINDER; //end row
+			add(texts[4],c1);
+
+			c1.gridwidth = 1;
+			add(new JLabel("Algorithm"),c1);
+			helps.put(9, new JComboBox<>(algNames));
+			helps.get(9).setSelectedItem(values[9]);
+			add(helps.get(9),c1);
+			c1.gridwidth=GridBagConstraints.REMAINDER;
+			inserts[9] = new JButton("Use");
+			inserts[9].addActionListener(j);
+			add(inserts[9], c1);
+			texts[9]=new JTextField(values[9],15);
+			c1.gridwidth = GridBagConstraints.REMAINDER; //end row
+			add(texts[9],c1);
 		}
-	    }
-	    if (evt.getSource() == inserts[8]) {
-		if (helps.get(8).getSelectedItem()!=null){
-		    texts[8].setText(helps.get(8).getSelectedItem().toString());
+	}
+
+
+	public class advPanel extends JPanel {
+		advPanel(JDialogCryptographicConfiguration j){
+			GridBagConstraints c1 = new GridBagConstraints();
+			GridBagLayout gridbag1 = new GridBagLayout();
+
+			setLayout(gridbag1);
+
+			setBorder(new javax.swing.border.TitledBorder("Properties"));
+
+			setPreferredSize(new Dimension(600, 200));
+
+			c1.weighty = 1.0;
+			c1.weightx = 1.0;
+			c1.gridwidth = GridBagConstraints.REMAINDER; //end row
+			c1.fill = GridBagConstraints.BOTH;
+			c1.gridheight = 1;
+			add(new JLabel(" "), c1);
+
+			// second line panel1
+			c1.gridwidth = 1;
+			c1.gridheight = 1;
+			c1.weighty = 1.0;
+			c1.weightx = 1.0;
+			c1.anchor = GridBagConstraints.CENTER;
+			c1.fill = GridBagConstraints.HORIZONTAL;
+			c1.anchor = GridBagConstraints.CENTER;
+			String[] vals = new String[]{"Symmetric Encryption", "Asymmetric Encryption","MAC", "Hash", "Nonce", "Advanced"}; 
+
+			// String1
+			c1.gridwidth = 1;
+			add(new JLabel("Cryptographic Configuration Name"),c1);
+			texts[0]=new JTextField(values[0],15);
+			c1.gridwidth = GridBagConstraints.REMAINDER; //end row
+			add(texts[0],c1);
+
+			c1.gridwidth=1;
+			add(new JLabel("Security Pattern"), c1);
+			helps.put(1, new JComboBox<>(vals));
+			helps.get(1).setSelectedItem(values[1]);
+			add(helps.get(1),c1);
+			c1.gridwidth=GridBagConstraints.REMAINDER;
+			inserts[0] = new JButton("Use");
+			inserts[0].addActionListener(j);
+			add(inserts[0], c1);
+			texts[1]=new JTextField(values[1], 15);
+			add(texts[1], c1);
+
+			c1.gridwidth = 1;
+			add(new JLabel("Overhead"),c1);
+			texts[2]=new JTextField(values[2],15);
+			c1.gridwidth = GridBagConstraints.REMAINDER; //end row
+			add(texts[2],c1);
+
+
+			c1.gridwidth = 1;
+			add(new JLabel("Computational Complexity"),c1);
+			texts[3]=new JTextField(values[3],15);
+			c1.gridwidth = GridBagConstraints.REMAINDER; //end row
+			add(texts[3],c1);
+
+
+
+			c1.gridwidth=1;
+			add(new JLabel("Custom Security Formula"), c1);
+			c1.gridwidth = GridBagConstraints.REMAINDER; //end row
+			texts[6] = new JTextField(values[6], 15);
+			add(texts[6],c1);        
+			
 		}
-	    }
 	}
-    }
-
-
-
-    public class EncryptPanel extends JPanel {
-	EncryptPanel(JDialogCryptographicConfiguration j){
-        GridBagConstraints c1 = new GridBagConstraints();
-        GridBagLayout gridbag1 = new GridBagLayout();
-
-        this.setLayout(gridbag1);
-
-        this.setBorder(new javax.swing.border.TitledBorder("Properties"));
-
-        this.setPreferredSize(new Dimension(600, 200));
-
-        c1.weighty = 1.0;
-        c1.weightx = 1.0;
-        c1.gridwidth = GridBagConstraints.REMAINDER; //end row
-        c1.fill = GridBagConstraints.BOTH;
-        c1.gridheight = 1;
-        add(new JLabel(" "), c1);
-
-        c1.gridwidth = 1;
-        c1.gridheight = 1;
-        c1.weighty = 1.0;
-        c1.weightx = 1.0;
-        c1.anchor = GridBagConstraints.CENTER;
-        c1.fill = GridBagConstraints.HORIZONTAL;
-        c1.anchor = GridBagConstraints.CENTER;
-	String[] vals = new String[]{"Symmetric Encryption", "Asymmetric Encryption","MAC", "Hash", "Nonce", "Advanced"}; 
-        // String1
-      	c1.gridwidth = 1;
-	add(new JLabel("Cryptographic Configuration Name"),c1);
-	texts[0]=new JTextField(values[0],15);
-	c1.gridwidth = GridBagConstraints.REMAINDER; //end row
-	add(texts[0],c1);
-
-	c1.gridwidth=1;
-	add(new JLabel("Security Pattern"), c1);
-	helps.put(1, new JComboBox<>(vals));
-	helps.get(1).setSelectedItem(values[1]);
-	add(helps.get(1),c1);
-	c1.gridwidth=GridBagConstraints.REMAINDER;
-	inserts[0] = new JButton("Use");
-	inserts[0].addActionListener(j);
-	add(inserts[0], c1);
-	texts[1]=new JTextField(values[1], 15);
-        add(texts[1], c1);
-
-      	c1.gridwidth = 1;
-	add(new JLabel("Overhead"),c1);
-	texts[2]=new JTextField(values[2],15);
-	c1.gridwidth = GridBagConstraints.REMAINDER; //end row
-	add(texts[2],c1);
-
-      	c1.gridwidth = 1;
-	add(new JLabel("Encryption Computational Complexity"),c1);
-	texts[3]=new JTextField(values[3],15);
-	c1.gridwidth = GridBagConstraints.REMAINDER; //end row
-	add(texts[3],c1);
-
-      	c1.gridwidth = 1;
-	add(new JLabel("Decryption Computational Complexity"),c1);
-	texts[7]=new JTextField(values[7],15);
-	c1.gridwidth = GridBagConstraints.REMAINDER; //end row
-	add(texts[7],c1);
-
-      	c1.gridwidth = 1;
-	add(new JLabel("Nonce"),c1);
-	helps.put(5, new JComboBox<>(nonces));
-	if (helps.get(5).getItemCount() > 0){
-	    helps.get(5).setSelectedItem(values[5]);
+
+	public void closeDialog() {
+		set = true;
+		dispose();
 	}
-	add(helps.get(5),c1);
-	c1.gridwidth=GridBagConstraints.REMAINDER;
-	inserts[5] = new JButton("Use");
-	inserts[5].addActionListener(j);
-	add(inserts[5], c1);
-	texts[5]=new JTextField(values[5], 15);
-        add(texts[5], c1);
-
-      	c1.gridwidth = 1;
-	add(new JLabel("Encrypted Key"),c1);
-	helps.put(8, new JComboBox<>(keys));
-	if (helps.get(8).getItemCount() > 0){
-	    helps.get(8).setSelectedItem(values[8]);
+
+	public String getString(int i) {
+		if (texts[i]!=null){
+			return texts[i].getText();
+		}
+		return "";
 	}
-	add(helps.get(8),c1);
-	c1.gridwidth=GridBagConstraints.REMAINDER;
-	inserts[8] = new JButton("Use");
-	inserts[8].addActionListener(j);
-	add(inserts[8], c1);
-	texts[8]=new JTextField(values[8], 15);
-        add(texts[8], c1);
 
+	public boolean hasValidString(int i) {
+		return texts[i] != null && texts[i].getText().length() > 0;
 	}
-    }
-
-    public class funcPanel extends JPanel {
-      funcPanel(JDialogCryptographicConfiguration j){
-        GridBagConstraints c1 = new GridBagConstraints();
-        GridBagLayout gridbag1 = new GridBagLayout();
-
-        setLayout(gridbag1);
-
-        setBorder(new javax.swing.border.TitledBorder("Properties"));
-
-        setPreferredSize(new Dimension(600, 200));
-
-        c1.weighty = 1.0;
-        c1.weightx = 1.0;
-        c1.gridwidth = GridBagConstraints.REMAINDER; //end row
-        c1.fill = GridBagConstraints.BOTH;
-        c1.gridheight = 1;
-        add(new JLabel(" "), c1);
-
-        // second line panel1
-        c1.gridwidth = 1;
-        c1.gridheight = 1;
-        c1.weighty = 1.0;
-        c1.weightx = 1.0;
-        c1.anchor = GridBagConstraints.CENTER;
-        c1.fill = GridBagConstraints.HORIZONTAL;
-        c1.anchor = GridBagConstraints.CENTER;
-	String[] vals = new String[]{"Symmetric Encryption", "Asymmetric Encryption","MAC", "Hash", "Nonce", "Advanced"}; 
-        // String1
-      	c1.gridwidth = 1;
-	add(new JLabel("Cryptographic Configuration Name"),c1);
-	texts[0]=new JTextField(values[0],15);
-	c1.gridwidth = GridBagConstraints.REMAINDER; //end row
-	add(texts[0],c1);
-
-	c1.gridwidth=1;
-	add(new JLabel("Security Pattern"), c1);
-	helps.put(1, new JComboBox<>(vals));
-	helps.get(1).setSelectedItem(values[1]);
-	add(helps.get(1),c1);
-
-	c1.gridwidth=GridBagConstraints.REMAINDER;
-	inserts[0] = new JButton("Use");
-	inserts[0].addActionListener(j);
-	add(inserts[0], c1);
-	texts[1]=new JTextField(values[1], 15);
-        add(texts[1], c1);
-
-      	c1.gridwidth = 1;
-	add(new JLabel("Computational Complexity"),c1);
-	texts[3]=new JTextField(values[3],15);
-	c1.gridwidth = GridBagConstraints.REMAINDER; //end row
-	add(texts[3],c1);
-
-      	c1.gridwidth = 1;
-	add(new JLabel("Size"),c1);
-	texts[4]=new JTextField(values[4],15);
-	c1.gridwidth = GridBagConstraints.REMAINDER; //end row
-	add(texts[4],c1);
-        
-       }
-    }
-
-
-public class advPanel extends JPanel {
-      advPanel(JDialogCryptographicConfiguration j){
-        GridBagConstraints c1 = new GridBagConstraints();
-        GridBagLayout gridbag1 = new GridBagLayout();
-
-        setLayout(gridbag1);
-
-        setBorder(new javax.swing.border.TitledBorder("Properties"));
-
-        setPreferredSize(new Dimension(600, 200));
-
-        c1.weighty = 1.0;
-        c1.weightx = 1.0;
-        c1.gridwidth = GridBagConstraints.REMAINDER; //end row
-        c1.fill = GridBagConstraints.BOTH;
-        c1.gridheight = 1;
-        add(new JLabel(" "), c1);
-
-        // second line panel1
-        c1.gridwidth = 1;
-        c1.gridheight = 1;
-        c1.weighty = 1.0;
-        c1.weightx = 1.0;
-        c1.anchor = GridBagConstraints.CENTER;
-        c1.fill = GridBagConstraints.HORIZONTAL;
-        c1.anchor = GridBagConstraints.CENTER;
-	String[] vals = new String[]{"Symmetric Encryption", "Asymmetric Encryption","MAC", "Hash", "Nonce", "Advanced"}; 
-
-        // String1
-      	c1.gridwidth = 1;
-	add(new JLabel("Cryptographic Configuration Name"),c1);
-	texts[0]=new JTextField(values[0],15);
-	c1.gridwidth = GridBagConstraints.REMAINDER; //end row
-	add(texts[0],c1);
-
-	c1.gridwidth=1;
-	add(new JLabel("Security Pattern"), c1);
-	helps.put(1, new JComboBox<>(vals));
-	helps.get(1).setSelectedItem(values[1]);
-	add(helps.get(1),c1);
-	c1.gridwidth=GridBagConstraints.REMAINDER;
-	inserts[0] = new JButton("Use");
-	inserts[0].addActionListener(j);
-	add(inserts[0], c1);
-	texts[1]=new JTextField(values[1], 15);
-        add(texts[1], c1);
-
-      	c1.gridwidth = 1;
-	add(new JLabel("Overhead"),c1);
-	texts[2]=new JTextField(values[2],15);
-	c1.gridwidth = GridBagConstraints.REMAINDER; //end row
-	add(texts[2],c1);
-
-
-	c1.gridwidth = 1;
-	add(new JLabel("Computational Complexity"),c1);
-	texts[3]=new JTextField(values[3],15);
-	c1.gridwidth = GridBagConstraints.REMAINDER; //end row
-	add(texts[3],c1);
-
-
-
-	c1.gridwidth=1;
-	add(new JLabel("Custom Security Formula"), c1);
-	c1.gridwidth = GridBagConstraints.REMAINDER; //end row
-	texts[6] = new JTextField(values[6], 15);
-	add(texts[6],c1);        
-       }
-    }
-
-    public void closeDialog() {
-        set = true;
-        dispose();
-    }
-
-    public String getString(int i) {
-	if (texts[i]!=null){
-            return texts[i].getText();
+
+
+	public boolean hasBeenSet() {
+		return set;
 	}
-	return "";
-    }
 
-    public boolean hasValidString(int i) {
-		return texts[i] != null && texts[i].getText().length() > 0;
+	public void cancelDialog() {
+		dispose();
 	}
 
+	public class securityAlgorithm {
+		String name;
+		String overhead;
+		String encryptCC;
+		String decryptCC;
+		String keysize;
+		String type;
+		public securityAlgorithm(String name, String overhead, String encryptCC, String decryptCC, String keysize, String type){
+			this.name=name;
+			this.overhead=overhead;
+			this.encryptCC = encryptCC;
+			this.decryptCC= decryptCC;
+			this.keysize= keysize;
+			this.type=type;
+		}
+	}
 
-    public boolean hasBeenSet() {
-        return set;
-    }
 
-    public void cancelDialog() {
-        dispose();
-    }
 }
diff --git a/src/main/java/ui/window/JDialogPerformancePragma.java b/src/main/java/ui/window/JDialogPerformancePragma.java
index ae54ce24a9..1ae0fd6bd1 100644
--- a/src/main/java/ui/window/JDialogPerformancePragma.java
+++ b/src/main/java/ui/window/JDialogPerformancePragma.java
@@ -1,26 +1,26 @@
 /* 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,
@@ -31,7 +31,7 @@
  * 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.
  */
@@ -58,9 +58,9 @@ import java.util.HashMap;
  * @author Ludovic APVRILLE, Letitia LI
  */
 public class JDialogPerformancePragma extends JDialogBase implements ActionListener {
-
+    
     protected String text;
-
+    
     //components
     protected JTextArea textarea;
     protected JButton close;
@@ -68,21 +68,21 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe
     protected JMenuBar menuBar;
     protected JMenu help;
     protected JPopupMenu helpPopup;
-    public HashMap<String, java.util.List<String>> blockAttributeMap = new HashMap<String, java.util.List<String>>();
+	public HashMap<String, java.util.List<String>> blockAttributeMap = new HashMap<String, java.util.List<String>>();
     /** Creates new form  */
     public JDialogPerformancePragma(Frame f, String title, String _text) {
         super(f, title, true);
         text = _text;
-
+        
         initComponents();
         pack();
     }
-    //Suggestion Panel code from: http://stackoverflow.com/questions/10873748/how-to-show-autocomplete-as-i-type-in-jtextarea
+//Suggestion Panel code from: http://stackoverflow.com/questions/10873748/how-to-show-autocomplete-as-i-type-in-jtextarea
 
     public class SuggestionPanel {
-        //Form list of all blocks
-        //For each block, create a list of all states and signals
-
+	//Form list of all blocks
+	//For each block, create a list of all states and signals
+	
         private JList list;
         private JPopupMenu popupMenu;
         private String subWord;
@@ -95,12 +95,12 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe
             popupMenu.removeAll();
             popupMenu.setOpaque(false);
             popupMenu.setBorder(null);
-
+			
             popupMenu.add(list = createSuggestionList(linePosition ,position, subWord), BorderLayout.CENTER);
-            //Show popupMenu only if there are matching suggestions
-            if (list.getModel().getSize() >0){
+	    //Show popupMenu only if there are matching suggestions
+	    	if (list.getModel().getSize() >0){
                 popupMenu.show(textarea, location.x, textarea.getBaseline(0, 0) + location.y);
-            }
+	    	}
         }
 
         public void hide() {
@@ -110,53 +110,53 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe
             }
         }
 
-        private JList createSuggestionList(int linePosition, final int position, final String subWord) {
-            ArrayList<String> matches = new ArrayList<String>();
-            if (linePosition<6){
-                matches.add("Latency(");
-            }
-
-            else if (!subWord.contains(".")){
-                for (String block: blockAttributeMap.keySet()){
-                    if (block.startsWith(subWord)){
-                        matches.add(block);
-                    }
-                }
-            }
-            else {
-                String block = subWord.split("\\.")[0];
-                if (blockAttributeMap.containsKey(block)){
-                    for (String attr: blockAttributeMap.get(block)){
-                        if (attr.startsWith(subWord.split("\\.")[1])){
-                            matches.add(block+"."+attr);
-                        }
-                    }
-                }
-            }
-            String[] data = new String[matches.size()];
+	private JList createSuggestionList(int linePosition, final int position, final String subWord) {
+	    ArrayList<String> matches = new ArrayList<String>();
+	    if (linePosition<6){
+	        matches.add("Latency(");
+	    }
+		
+		else if (!subWord.contains(".")){
+			for (String block: blockAttributeMap.keySet()){
+				if (block.startsWith(subWord)){
+					matches.add(block);
+				}
+			}
+		}
+		else {
+			String block = subWord.split("\\.")[0];
+			if (blockAttributeMap.containsKey(block)){
+				for (String attr: blockAttributeMap.get(block)){
+					if (attr.startsWith(subWord.split("\\.")[1])){
+						matches.add(block+"."+attr);
+					}
+				}
+			}
+		}
+	    String[] data = new String[matches.size()];
             data = matches.toArray(data);
             JList<String> list = new JList<>(data);
             list.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
             list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
             list.setSelectedIndex(0);
             list.addMouseListener(new MouseAdapter() {
-                    @Override
-                    public void mouseClicked(MouseEvent e) {
-                        if (e.getClickCount() == 2) {
-                            insertSelection();
-                        }
+                @Override
+                public void mouseClicked(MouseEvent e) {
+                    if (e.getClickCount() == 2) {
+                        insertSelection();
                     }
-                });
-
+                }
+            });
+	    
             return list;
         }
 
-
+	
         public boolean insertSelection() {
-            //Note that it will not add if the selection will not fit on the current line
-            if (!popupMenu.isVisible()){
-                return false;
-            }
+		//Note that it will not add if the selection will not fit on the current line
+	    if (!popupMenu.isVisible()){
+		return false;
+	    }
             if (list.getSelectedValue() != null) {
                 try {
                     final String selectedSuggestion = ((String) list.getSelectedValue()).substring(subWord.length());
@@ -184,22 +184,22 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe
             final int position = textarea.getCaretPosition();
             list.setSelectedIndex(index);
             SwingUtilities.invokeLater(new Runnable() {
-                    @Override
-                    public void run() {
-                        textarea.setCaretPosition(position);
-                    }
-                });
-        }
-    }
-    private SuggestionPanel suggestion;
-    protected void showSuggestionLater() {
-        SwingUtilities.invokeLater(new Runnable() {
                 @Override
                 public void run() {
-                    showSuggestion();
+                    textarea.setCaretPosition(position);
                 }
-
             });
+        }
+    }
+     private SuggestionPanel suggestion;
+     protected void showSuggestionLater() {
+        SwingUtilities.invokeLater(new Runnable() {
+            @Override
+            public void run() {
+                showSuggestion();
+            }
+
+        });
     }
 
     protected void showSuggestion() {
@@ -231,23 +231,23 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe
         if (subWord.length() < 1) {
             return;
         }
-        start=Math.max(0,position-1);
-        while (start>0){
-            //Find previous new line position
-            if (!String.valueOf(text.charAt(start)).matches(".")){
-                break;
-            }
-            else {
-                start--;
-            }
-        }
+		start=Math.max(0,position-1);
+		while (start>0){
+			//Find previous new line position
+			if (!String.valueOf(text.charAt(start)).matches(".")){
+				break;
+			}
+			else {
+				start--;
+			}
+		}
         suggestion = new SuggestionPanel(textarea, position, subWord, location, position-start-1);
         SwingUtilities.invokeLater(new Runnable() {
-                @Override
-                public void run() {
-                    textarea.requestFocusInWindow();
-                }
-            });
+            @Override
+            public void run() {
+                textarea.requestFocusInWindow();
+            }
+        });
     }
 
     private void hideSuggestion() {
@@ -257,12 +257,47 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe
     }
 
     protected void initComponents() {
-
+        
         Container c = getContentPane();
         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("UPPAAL pragmas");
+		//helpPopup.add(jft);
+		JLabel t = new JLabel("");
+		JLabel header= new JLabel(" 	Performance Pragma");
+		Font headerFont=new Font(t.getFont().getName(),Font.BOLD,t.getFont().getSize()+2);
+		header.setFont(headerFont);
+		helpPopup.add(header);
+		//Text
+		helpPopup.add(new JLabel(" Performance Pragma allow us to query and record "));
+		helpPopup.add(new JLabel(" the latency (in cycles) between two events after simulation"));
+		helpPopup.add(new JLabel(" Depending on the format of the pragma, results can be the"));
+		helpPopup.add(new JLabel(" numeric average latency value or a verified true/false result"));		
+		
+		JLabel example =new JLabel(" Examples:");
+		example.setFont(headerFont);
+		helpPopup.add(example);
+		
+		Font exFont=new Font(t.getFont().getName(),Font.ITALIC,t.getFont().getSize());
+		JLabel t1 = new JLabel(" Latency(block1.state1, block2.s)<10:");
+		t1.setFont(exFont);
+		helpPopup.add(t1);
+		helpPopup.add(new JLabel(" Will be marked with a green check mark or "));
+		helpPopup.add(new JLabel(" red cross depending on simulation results"));		
+	
+		JLabel t2 = new JLabel(" Latency(block1.state1, block2.s)?:");
+		t2.setFont(exFont);
+		helpPopup.add(t2);
+		
+		helpPopup.add(new JLabel(" Will be marked with the average latency"));
+		helpPopup.add(new JLabel(" time after simulation"));	
+		helpPopup.setPreferredSize(new Dimension(600,250));
+        
+        
         textarea = new JTextArea();
 
         textarea.setEditable(true);
@@ -270,74 +305,74 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe
         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 JMenu("?");
-        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) {
-                        if (suggestion != null) {
-                            if (suggestion.insertSelection()) {
-                                e.consume();
-                                final int position = textarea.getCaretPosition();
-                                SwingUtilities.invokeLater(new Runnable() {
-                                        @Override
-                                        public void run() {
-                                            try {
-                                                textarea.getDocument().remove(position - 1, 1);
-                                            } catch (BadLocationException e) {
-                                                e.printStackTrace();
-                                            }
-                                        }
-                                    });
-                            }
+		JMenuBar menuBar = new JMenuBar();
+		menuBar.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
+		help = new JMenu("?");
+		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) {
+                    if (suggestion != null) {
+                        if (suggestion.insertSelection()) {
+                            e.consume();
+                            final int position = textarea.getCaretPosition();
+                            SwingUtilities.invokeLater(new Runnable() {
+                                @Override
+                                public void run() {
+                                    try {
+                                        textarea.getDocument().remove(position - 1, 1);
+                                    } catch (BadLocationException e) {
+                                        e.printStackTrace();
+                                    }
+                                }
+                            });
                         }
                     }
                 }
+            }
 
-                @Override
-                public void keyReleased(KeyEvent e) {
-                    if (e.getKeyCode() == KeyEvent.VK_DOWN && suggestion != null) {
-                        suggestion.moveDown();
-                    } else if (e.getKeyCode() == KeyEvent.VK_UP && suggestion != null) {
-                        suggestion.moveUp();
-                    } else if (Character.isWhitespace(e.getKeyChar())) {
-                        hideSuggestion();
-                    }
-                    else if (Character.isLetter(e.getKeyChar())){
-                        showSuggestionLater();
-                    }
+            @Override
+            public void keyReleased(KeyEvent e) {
+                if (e.getKeyCode() == KeyEvent.VK_DOWN && suggestion != null) {
+                    suggestion.moveDown();
+                } else if (e.getKeyCode() == KeyEvent.VK_UP && suggestion != null) {
+                    suggestion.moveUp();
+                } else if (Character.isWhitespace(e.getKeyChar())) {
+                    hideSuggestion();
                 }
-
-                @Override
-                public void keyPressed(KeyEvent e) {
-                    if (e.getKeyCode() == KeyEvent.VK_DOWN && suggestion != null) {
-                        e.consume();
-                    } else if (e.getKeyCode() == KeyEvent.VK_UP && suggestion != null) {
-                        e.consume();
-                    }
+		else if (Character.isLetter(e.getKeyChar())){
+                    showSuggestionLater();
                 }
-            });
+            }
 
+            @Override
+            public void keyPressed(KeyEvent e) {
+		if (e.getKeyCode() == KeyEvent.VK_DOWN && suggestion != null) {
+                   e.consume();
+                } else if (e.getKeyCode() == KeyEvent.VK_UP && suggestion != null) {
+                    e.consume();
+                } 
+            }
+        });
 
 
+	
         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));
+        
+	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() {
@@ -349,43 +384,42 @@ public class JDialogPerformancePragma extends JDialogBase implements ActionListe
         JPanel jp = new JPanel();
         jp.add(close);
         jp.add(cancel);
-
+        
         c.add(jp, BorderLayout.SOUTH);
-
+	
     }
-
-    public void actionPerformed(ActionEvent evt)  {
-        //String command = evt.getActionCommand();
-
+    
+    public void	actionPerformed(ActionEvent evt)  {
+        String command = evt.getActionCommand();
+        
         // Compare the action command to the known actions.
-        if (evt.getSource() == cancel)  {
+        if (command.equals("Cancel"))  {
             cancel();
-        } else if (evt.getSource() == close) {
+        } else if (command.equals("Ok")) {
             close();
         }
-
+	
     }
-
+    
     public void cancel() {
         dispose();
     }
-
+    
     public void close() {
         text = textarea.getText();
         dispose();
     }
     public void help(){
-        if (!helpPopup.isVisible()){
-            helpPopup.show(help, 20, 20);
-        }
-        else {
-            helpPopup.setVisible(false);
-        }
+	if (!helpPopup.isVisible()){
+	    helpPopup.show(help, 20, 20);
+	}
+	else {
+	    helpPopup.setVisible(false);
+	}
     }
-
     public String getText() {
         return text;
     }
-
-
+    
+    
 }
-- 
GitLab