Skip to content
Snippets Groups Projects
Commit 340d03ef authored by apvrille's avatar apvrille
Browse files

Enhancing dialog window for channels

parent ceafcd74
No related branches found
No related tags found
No related merge requests found
...@@ -47,6 +47,8 @@ import ui.*; ...@@ -47,6 +47,8 @@ import ui.*;
import ui.util.IconManager; import ui.util.IconManager;
import ui.window.JDialogMultiString; import ui.window.JDialogMultiString;
import myutil.*; import myutil.*;
import ui.window.JDialogMultiStringAndTabs;
import ui.window.TabInfo;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
...@@ -261,60 +263,61 @@ public class TMLADReadChannel extends TGCWithoutInternalComponent implements Che ...@@ -261,60 +263,61 @@ public class TMLADReadChannel extends TGCWithoutInternalComponent implements Che
} }
public boolean editOndoubleClick(JFrame frame) { public boolean editOndoubleClick(JFrame frame) {
TabInfo tab1 = new TabInfo("Name and samples");
String[] labels = new String[4]; String[] labels = new String[2];
String[] values = new String[4]; String[] values = new String[2];
labels[0] = "Channel name"; labels[0] = "Channel name";
values[0] = channelName; values[0] = channelName;
labels[1] = "Nb of samples"; labels[1] = "Nb of samples";
values[1] = nbOfSamples; values[1] = nbOfSamples;
labels[2] = "Security Pattern"; tab1.labels=labels;
values[2] = securityContext; tab1.values = values;
labels[3] = "Attacker?";
values[3] = isAttacker ? "Yes" : "No";
ArrayList<String[]> help = new ArrayList<String[]>(); ArrayList<String[]> help = new ArrayList<String[]>();
String[] allInChannels = tdp.getMGUI().getAllInChannels(); String[] allInChannels = tdp.getMGUI().getAllInChannels();
TraceManager.addDev("isAttacker " + isAttacker);
if (isAttacker) { if (isAttacker) {
allInChannels = tdp.getMGUI().getAllCompInChannels(); allInChannels = tdp.getMGUI().getAllCompInChannels();
} }
help.add(allInChannels); help.add(allInChannels);
help.add(null); help.add(null);
help.add(tdp.getMGUI().getCurrentCryptoConfig()); tab1.help = help;
TabInfo tab2 = new TabInfo("Security");
labels = new String[2];
values = new String[2];
labels[0] = "Security Pattern";
values[0] = securityContext;
labels[1] = "Attacker?";
values[1] = isAttacker ? "Yes" : "No";
help = new ArrayList<String[]>();
String[] choice = new String[]{"Yes", "No"}; String[] choice = new String[]{"Yes", "No"};
help.add(tdp.getMGUI().getCurrentCryptoConfig());
help.add(choice); help.add(choice);
// JDialogTwoString jdts = new JDialogTwoString(frame, "Setting channel's properties", "Channel name", channelName, "Nb of samples", nbOfSamples); tab2.labels=labels;
tab2.values = values;
tab2.help = help;
ArrayList<TabInfo> tabs = new ArrayList<>();
tabs.add(tab1);
tabs.add(tab2);
JDialogMultiString jdms = new JDialogMultiString(frame, "Setting channel's properties", 4, labels, values, help); //JDialogTwoString jdts = new JDialogTwoString(frame, "Setting channel's properties", "Channel name", channelName, "Nb of samples", nbOfSamples);
JDialogMultiStringAndTabs jdmsat = new JDialogMultiStringAndTabs(frame, "Write in channel", tabs);
//jdms.setSize(600, 300); //jdms.setSize(600, 300);
GraphicLib.centerOnParent(jdms, 600, 300); GraphicLib.centerOnParent(jdmsat, 600, 300);
jdms.setVisible(true); // blocked until dialog has been closed jdmsat.setVisible(true); // blocked until dialog has been closed
if (jdms.hasBeenSet() && (jdms.hasValidString(0))) { if (jdmsat.hasBeenSet() && (jdmsat.hasValidString(0))) {
channelName = jdms.getString(0); channelName = jdmsat.getString(0, 0);
nbOfSamples = jdms.getString(1); nbOfSamples = jdmsat.getString(0, 1);
securityContext = jdms.getString(2); securityContext = jdmsat.getString(1, 0);
isAttacker = jdms.getString(3).equals("Yes"); isAttacker = jdmsat.getString(1, 1).equals("Yes");
makeValue(); makeValue();
return true; return true;
} }
/*jdts.setSize(350, 300);
GraphicLib.centerOnParent(jdts);
jdts.show(); // blocked until dialog has been closed
if (jdts.hasBeenSet() && (jdts.hasValidString())) {
channelName = jdts.getString1();
nbOfSamples = jdts.getString2();
makeValue();
return true;
}*/
return false; return false;
} }
public void setSamples(String sp) { public void setSamples(String sp) {
......
...@@ -37,8 +37,6 @@ ...@@ -37,8 +37,6 @@
*/ */
package ui.tmlad; package ui.tmlad;
import myutil.Conversion; import myutil.Conversion;
...@@ -49,52 +47,53 @@ import org.w3c.dom.NodeList; ...@@ -49,52 +47,53 @@ import org.w3c.dom.NodeList;
import ui.*; import ui.*;
import ui.util.IconManager; import ui.util.IconManager;
import ui.window.JDialogMultiString; import ui.window.JDialogMultiString;
import ui.window.JDialogMultiStringAndTabs;
import ui.window.TabInfo;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.geom.Line2D; import java.awt.geom.Line2D;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
/** /**
* Class TMLADWriteChannel * Class TMLADWriteChannel
* Action of writting data in channel * Action of writting data in channel
* Creation: 17/11/2005 * Creation: 17/11/2005
* @version 1.0 17/11/2005 *
* @author Ludovic APVRILLE * @author Ludovic APVRILLE
* @version 1.0 17/11/2005
*/ */
public class TMLADWriteChannel extends TGCWithoutInternalComponent implements CheckableAccessibility, LinkedReference, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight { public class TMLADWriteChannel extends TGCWithoutInternalComponent implements CheckableAccessibility, LinkedReference, CheckableLatency, EmbeddedComment, AllowedBreakpoint, BasicErrorHighlight {
protected int lineLength = 5; protected int lineLength = 5;
protected int textX = 5; protected int textX = 5;
protected int textY = 15; protected int textY = 15;
protected int arc = 5; protected int arc = 5;
protected int linebreak = 10; protected int linebreak = 10;
private ConcurrentHashMap<String, String> latencyVals; private ConcurrentHashMap<String, String> latencyVals;
protected int latencyX=30; protected int latencyX = 30;
protected int latencyY=25; protected int latencyY = 25;
protected int textWidth=10; protected int textWidth = 10;
protected int textHeight=20; protected int textHeight = 20;
protected String channelName = "ch"; protected String channelName = "ch";
protected String nbOfSamples= "1"; protected String nbOfSamples = "1";
protected String securityContext = ""; protected String securityContext = "";
protected boolean isAttacker = false; protected boolean isAttacker = false;
protected int stateOfError = 0; // Not yet checked protected int stateOfError = 0; // Not yet checked
public final static int NOT_VERIFIED = 0; public final static int NOT_VERIFIED = 0;
public final static int REACHABLE = 1; public final static int REACHABLE = 1;
public final static int NOT_REACHABLE = 2; public final static int NOT_REACHABLE = 2;
public int reachabilityInformation; public int reachabilityInformation;
public TMLADWriteChannel(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { public TMLADWriteChannel(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); super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
width = 30; width = 30;
...@@ -102,7 +101,6 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch ...@@ -102,7 +101,6 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch
minWidth = 30; minWidth = 30;
nbConnectingPoint = 2; nbConnectingPoint = 2;
connectingPoint = new TGConnectingPoint[2]; connectingPoint = new TGConnectingPoint[2];
connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0); connectingPoint[0] = new TGConnectingPointTMLAD(this, 0, -lineLength, true, false, 0.5, 0.0);
...@@ -116,41 +114,41 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch ...@@ -116,41 +114,41 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch
name = "write channel"; name = "write channel";
myImageIcon = IconManager.imgic900; myImageIcon = IconManager.imgic900;
latencyVals = new ConcurrentHashMap<String, String>(); latencyVals = new ConcurrentHashMap<String, String>();
} }
public ConcurrentHashMap<String, String> getLatencyMap(){ public ConcurrentHashMap<String, String> getLatencyMap() {
return latencyVals; return latencyVals;
} }
public void internalDrawing(Graphics g) { public void internalDrawing(Graphics g) {
int w = g.getFontMetrics().stringWidth(value); int w = g.getFontMetrics().stringWidth(value);
int w1 = Math.max(minWidth, w + 2 * textX); int w1 = Math.max(minWidth, w + 2 * textX);
if ((w1 != width) & (!tdp.isScaled())) { if ((w1 != width) & (!tdp.isScaled())) {
setCd(x + width/2 - w1/2, y); setCd(x + width / 2 - w1 / 2, y);
width = w1; width = w1;
//updateConnectingPoints(); //updateConnectingPoints();
} }
//g.drawRoundRect(x, y, width, height, arc, arc); //g.drawRoundRect(x, y, width, height, arc, arc);
if (stateOfError > 0) { if (stateOfError > 0) {
Color c = g.getColor(); Color c = g.getColor();
switch(stateOfError) { switch (stateOfError) {
case ErrorHighlight.OK: case ErrorHighlight.OK:
g.setColor(ColorManager.TML_PORT_CHANNEL); g.setColor(ColorManager.TML_PORT_CHANNEL);
break; break;
default: default:
g.setColor(ColorManager.UNKNOWN_BOX_ACTION); g.setColor(ColorManager.UNKNOWN_BOX_ACTION);
} }
// Making the polygon // Making the polygon
int [] px1 = {x, x+width-linebreak, x+width, x+width-linebreak, x}; int[] px1 = {x, x + width - linebreak, x + width, x + width - linebreak, x};
int [] py1 = {y, y, y+(height/2), y+height, y+height}; int[] py1 = {y, y, y + (height / 2), y + height, y + height};
g.fillPolygon(px1, py1, 5); g.fillPolygon(px1, py1, 5);
g.setColor(c); g.setColor(c);
} }
g.drawLine(x+(width/2), y, x+(width/2), y - lineLength); g.drawLine(x + (width / 2), y, x + (width / 2), y - lineLength);
g.drawLine(x+(width/2), y+height, x+(width/2), y + lineLength + height); g.drawLine(x + (width / 2), y + height, x + (width / 2), y + lineLength + height);
int x1 = x + 1; int x1 = x + 1;
int y1 = y + 1; int y1 = y + 1;
...@@ -158,91 +156,91 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch ...@@ -158,91 +156,91 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch
int width1 = width; int width1 = width;
Color c = g.getColor(); Color c = g.getColor();
g.setColor(ColorManager.TML_PORT_CHANNEL); g.setColor(ColorManager.TML_PORT_CHANNEL);
g.drawLine(x1, y1, x1+width1-linebreak, y1); g.drawLine(x1, y1, x1 + width1 - linebreak, y1);
g.drawLine(x1, y1+height1, x1+width1-linebreak, y1+height1); g.drawLine(x1, y1 + height1, x1 + width1 - linebreak, y1 + height1);
g.drawLine(x1, y1, x1, y1+height1); g.drawLine(x1, y1, x1, y1 + height1);
g.drawLine(x1+width1-linebreak, y1, x1+width1, y1+height1/2); g.drawLine(x1 + width1 - linebreak, y1, x1 + width1, y1 + height1 / 2);
g.drawLine(x1+width1-linebreak, y1+height1, x1+width1, y1+height1/2); g.drawLine(x1 + width1 - linebreak, y1 + height1, x1 + width1, y1 + height1 / 2);
g.setColor(c); g.setColor(c);
g.drawLine(x, y, x+width-linebreak, y); g.drawLine(x, y, x + width - linebreak, y);
g.drawLine(x, y+height, x+width-linebreak, y+height); g.drawLine(x, y + height, x + width - linebreak, y + height);
g.drawLine(x, y, x, y+height); g.drawLine(x, y, x, y + height);
g.drawLine(x+width-linebreak, y, x+width, y+height/2); g.drawLine(x + width - linebreak, y, x + width, y + height / 2);
g.drawLine(x+width-linebreak, y+height, x+width, y+height/2); g.drawLine(x + width - linebreak, y + height, x + width, y + height / 2);
if (isAttacker){ if (isAttacker) {
g.drawString("attack", x+(width-w) / 2, y); g.drawString("attack", x + (width - w) / 2, y);
} } else {
else { g.drawString("chl", x + (width - w) / 2, y);
g.drawString("chl", x+(width-w) / 2, y); }
} g.drawString(value, x + (width - w) / 2, y + textY);
g.drawString(value, x + (width - w) / 2 , y + textY); if (!securityContext.equals("")) {
if (!securityContext.equals("")){ g.drawString("sec:" + securityContext, x + 3 * width / 4, y + height + textY);
g.drawString("sec:"+securityContext, x+3*width/4, y+height+textY); }
}
if (getCheckLatency()) {
if (getCheckLatency()){ ConcurrentHashMap<String, String> latency = tdp.getMGUI().getLatencyVals(getDIPLOID());
ConcurrentHashMap<String, String> latency =tdp.getMGUI().getLatencyVals(getDIPLOID()); //
// if (latency != null) {
if (latency!=null){ latencyVals = latency;
latencyVals=latency; drawLatencyInformation(g);
drawLatencyInformation(g); }
} }
} drawReachabilityInformation(g);
drawReachabilityInformation(g);
} }
public void drawLatencyInformation(Graphics g){ public void drawLatencyInformation(Graphics g) {
int index=1; int index = 1;
for (String s:latencyVals.keySet()){ for (String s : latencyVals.keySet()) {
int w = g.getFontMetrics().stringWidth(s); int w = g.getFontMetrics().stringWidth(s);
g.drawString(s, x-latencyX-w+1, y-latencyY*index-2); g.drawString(s, x - latencyX - w + 1, y - latencyY * index - 2);
g.drawRect(x-latencyX-w, y-latencyY*index-textHeight, w+4, textHeight); g.drawRect(x - latencyX - w, y - latencyY * index - textHeight, w + 4, textHeight);
g.drawLine(x,y,x-latencyX, y-latencyY*index); g.drawLine(x, y, x - latencyX, y - latencyY * index);
g.drawString(latencyVals.get(s), x-latencyX/2, y-latencyY*index/2); g.drawString(latencyVals.get(s), x - latencyX / 2, y - latencyY * index / 2);
index++; index++;
} }
} }
public void addLatency(String name, String num){ public void addLatency(String name, String num) {
latencyVals.put(name,num); latencyVals.put(name, num);
} }
public void drawReachabilityInformation(Graphics g) { public void drawReachabilityInformation(Graphics g) {
if (reachabilityInformation > 0) { if (reachabilityInformation > 0) {
Color c = g.getColor(); Color c = g.getColor();
Color c1; Color c1;
switch(reachabilityInformation) { switch (reachabilityInformation) {
case REACHABLE: case REACHABLE:
c1 = Color.green; c1 = Color.green;
break; break;
case NOT_REACHABLE: case NOT_REACHABLE:
c1 = Color.red; c1 = Color.red;
break; break;
default: default:
return; return;
} }
GraphicLib.arrowWithLine(g, 1, 0, 10, x-30, y-3, x-15, y-3, true); GraphicLib.arrowWithLine(g, 1, 0, 10, x - 30, y - 3, x - 15, y - 3, true);
g.drawOval(x-11, y-10, 7, 9); g.drawOval(x - 11, y - 10, 7, 9);
g.setColor(c1); g.setColor(c1);
g.fillRect(x-12, y-7, 9, 7); g.fillRect(x - 12, y - 7, 9, 7);
g.setColor(c); g.setColor(c);
g.drawRect(x-12, y-7, 9, 7); g.drawRect(x - 12, y - 7, 9, 7);
if (reachabilityInformation==NOT_REACHABLE){ if (reachabilityInformation == NOT_REACHABLE) {
g.drawLine(x-14, y-9, x-1, y+3); g.drawLine(x - 14, y - 9, x - 1, y + 3);
g.drawLine(x-14, y+3, x-1, y-9); g.drawLine(x - 14, y + 3, x - 1, y - 9);
} }
} }
} }
public TGComponent isOnMe(int _x, int _y) { public TGComponent isOnMe(int _x, int _y) {
if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) { if (GraphicLib.isInRectangle(_x, _y, x, y, width, height)) {
return this; return this;
} }
if ((int)(Line2D.ptSegDistSq(x+(width/2), y-lineLength, x+(width/2), y + lineLength + height, _x, _y)) < distanceSelected) { if ((int) (Line2D.ptSegDistSq(x + (width / 2), y - lineLength, x + (width / 2), y + lineLength + height, _x, _y)) < distanceSelected) {
return this; return this;
} }
...@@ -265,7 +263,7 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch ...@@ -265,7 +263,7 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch
} }
public String getChannelName(int _index) { public String getChannelName(int _index) {
return getChannelsByName()[_index]; return getChannelsByName()[_index];
} }
public String getSamplesValue() { public String getSamplesValue() {
...@@ -277,39 +275,54 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch ...@@ -277,39 +275,54 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch
} }
public boolean editOndoubleClick(JFrame frame) { public boolean editOndoubleClick(JFrame frame) {
String [] labels = new String[4]; TabInfo tab1 = new TabInfo("Name and samples");
String [] values = new String[4]; String[] labels = new String[2];
String[] values = new String[2];
labels[0] = "Channel name"; labels[0] = "Channel name";
values[0] = channelName; values[0] = channelName;
labels[1] = "Nb of samples"; labels[1] = "Nb of samples";
values[1] = nbOfSamples; values[1] = nbOfSamples;
labels[2] = "Security Pattern"; tab1.labels=labels;
values[2] = securityContext; tab1.values = values;
labels[3] = "Attacker?"; ArrayList<String[]> help = new ArrayList<String[]>();
values[3] = isAttacker ? "Yes" : "No"; String[] allOutChannels = tdp.getMGUI().getAllOutChannels();
ArrayList<String []> help = new ArrayList<String []>(); if (isAttacker) {
String[] allOutChannels = tdp.getMGUI().getAllOutChannels(); allOutChannels = tdp.getMGUI().getAllCompOutChannels();
}
if (isAttacker){ help.add(allOutChannels);
allOutChannels =tdp.getMGUI().getAllCompOutChannels(); help.add(null);
} tab1.help = help;
String[] choice = new String[]{"Yes", "No"};
help.add(allOutChannels); TabInfo tab2 = new TabInfo("Security");
help.add(null); labels = new String[2];
help.add(tdp.getMGUI().getCurrentCryptoConfig()); values = new String[2];
help.add(choice); labels[0] = "Security Pattern";
values[0] = securityContext;
labels[1] = "Attacker?";
values[1] = isAttacker ? "Yes" : "No";
help = new ArrayList<String[]>();
String[] choice = new String[]{"Yes", "No"};
help.add(tdp.getMGUI().getCurrentCryptoConfig());
help.add(choice);
tab2.labels=labels;
tab2.values = values;
tab2.help = help;
ArrayList<TabInfo> tabs = new ArrayList<>();
tabs.add(tab1);
tabs.add(tab2);
//JDialogTwoString jdts = new JDialogTwoString(frame, "Setting channel's properties", "Channel name", channelName, "Nb of samples", nbOfSamples); //JDialogTwoString jdts = new JDialogTwoString(frame, "Setting channel's properties", "Channel name", channelName, "Nb of samples", nbOfSamples);
JDialogMultiString jdms = new JDialogMultiString(frame, "Setting channel's properties", 4, labels, values, help); JDialogMultiStringAndTabs jdmsat = new JDialogMultiStringAndTabs(frame, "Write in channel", tabs);
//jdms.setSize(600, 300); //jdms.setSize(600, 300);
GraphicLib.centerOnParent(jdms, 600, 300); GraphicLib.centerOnParent(jdmsat, 600, 300);
jdms.setVisible( true ); // blocked until dialog has been closed jdmsat.setVisible(true); // blocked until dialog has been closed
if (jdms.hasBeenSet() && (jdms.hasValidString(0))) { if (jdmsat.hasBeenSet() && (jdmsat.hasValidString(0))) {
channelName = jdms.getString(0); channelName = jdmsat.getString(0, 0);
nbOfSamples = jdms.getString(1); nbOfSamples = jdmsat.getString(0, 1);
securityContext = jdms.getString(2); securityContext = jdmsat.getString(1, 0);
isAttacker=jdms.getString(3).equals("Yes"); isAttacker = jdmsat.getString(1, 1).equals("Yes");
makeValue(); makeValue();
return true; return true;
} }
...@@ -326,15 +339,15 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch ...@@ -326,15 +339,15 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch
sb.append(getSamplesValue()); sb.append(getSamplesValue());
sb.append("\" secPattern=\""); sb.append("\" secPattern=\"");
sb.append(securityContext); sb.append(securityContext);
sb.append("\" isAttacker=\""); sb.append("\" isAttacker=\"");
sb.append(isAttacker ? "Yes": "No"); sb.append(isAttacker ? "Yes" : "No");
sb.append("\" />\n"); sb.append("\" />\n");
sb.append("</extraparam>\n"); sb.append("</extraparam>\n");
return new String(sb); return new String(sb);
} }
@Override @Override
public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException{ public void loadExtraParam(NodeList nl, int decX, int decY, int decId) throws MalformedModelingException {
// //
try { try {
...@@ -345,12 +358,12 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch ...@@ -345,12 +358,12 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch
// //
// //
for(int i=0; i<nl.getLength(); i++) { for (int i = 0; i < nl.getLength(); i++) {
n1 = nl.item(i); n1 = nl.item(i);
// //
if (n1.getNodeType() == Node.ELEMENT_NODE) { if (n1.getNodeType() == Node.ELEMENT_NODE) {
nli = n1.getChildNodes(); nli = n1.getChildNodes();
for(int j=0; j<nli.getLength(); j++) { for (int j = 0; j < nli.getLength(); j++) {
n2 = nli.item(j); n2 = nli.item(j);
// //
if (n2.getNodeType() == Node.ELEMENT_NODE) { if (n2.getNodeType() == Node.ELEMENT_NODE) {
...@@ -359,7 +372,7 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch ...@@ -359,7 +372,7 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch
channelName = elt.getAttribute("channelName"); channelName = elt.getAttribute("channelName");
nbOfSamples = elt.getAttribute("nbOfSamples"); nbOfSamples = elt.getAttribute("nbOfSamples");
securityContext = elt.getAttribute("secPattern"); securityContext = elt.getAttribute("secPattern");
isAttacker = elt.getAttribute("isAttacker").equals("Yes"); isAttacker = elt.getAttribute("isAttacker").equals("Yes");
} }
} }
} }
...@@ -380,30 +393,33 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch ...@@ -380,30 +393,33 @@ public class TMLADWriteChannel extends TGCWithoutInternalComponent implements Ch
public int getDefaultConnector() { public int getDefaultConnector() {
return TGComponentManager.CONNECTOR_TMLAD; return TGComponentManager.CONNECTOR_TMLAD;
} }
public String getChannelName(){
return channelName; public String getChannelName() {
return channelName;
}
public void setChannelName(String s) {
channelName = s;
makeValue();
} }
public void setChannelName(String s){
channelName=s; public void setSamples(String sp) {
makeValue(); nbOfSamples = sp;
} makeValue();
public void setSamples(String sp){
nbOfSamples=sp;
makeValue();
} }
public String getSecurityContext(){ public String getSecurityContext() {
return securityContext; return securityContext;
} }
public void setSecurityContext(String sc){ public void setSecurityContext(String sc) {
securityContext=sc; securityContext = sc;
} }
public boolean isAttacker(){ public boolean isAttacker() {
return isAttacker; return isAttacker;
} }
public void setStateAction(int _stateAction) { public void setStateAction(int _stateAction) {
stateOfError = _stateAction; stateOfError = _stateAction;
......
/* 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.
*/
package ui.window;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Class JDialogMultiStringAndTabs
* Dialog for managing several string components
* Creation: 22/06/2018
*
* @author Ludovic APVRILLE
* @version 1.0 22/06/2018
*/
public class JDialogMultiStringAndTabs extends JDialogBase implements ActionListener {
private ArrayList<TabInfo> tabs;
private int totalNbOfStrings;
private boolean set = false;
// Panel1
private JTextField[] texts;
private JButton inserts[];
private HashMap<Integer, JComboBox<String>> helps;
private ArrayList<String[]> possibleValues = null;
/**
* Creates new form
*/
// arrayDelay: [0] -> minDelay ; [1] -> maxDelay
public JDialogMultiStringAndTabs(Frame f, String title, ArrayList<TabInfo> _tabs) {
super(f, title, true);
tabs = _tabs;
totalNbOfStrings = 0;
for(TabInfo tab: tabs) {
totalNbOfStrings += tab.labels.length;
}
texts = new JTextField[totalNbOfStrings];
initComponents();
myInitComponents();
pack();
}
private void myInitComponents() {
}
private void initComponents() {
inserts = new JButton[totalNbOfStrings];
helps = new HashMap<>();
Container c = getContentPane();
GridBagLayout gridbag0 = new GridBagLayout();
GridBagConstraints c0 = new GridBagConstraints();
setFont(new Font("Helvetica", Font.PLAIN, 14));
c.setLayout(gridbag0);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
int totalIndex = 0;
JTabbedPane pane = new JTabbedPane();
// Iterate on tab panes
for(TabInfo tab: tabs) {
JPanel panel1 = new JPanel();
GridBagLayout gridbag1 = new GridBagLayout();
GridBagConstraints c1 = new GridBagConstraints();
panel1.setLayout(gridbag1);
// first line panel1
c1.weighty = 1.0;
c1.weightx = 1.0;
c1.gridwidth = GridBagConstraints.REMAINDER; //end row
c1.fill = GridBagConstraints.BOTH;
c1.gridheight = 1;
panel1.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;
// Strings
for (int i = 0; i < tab.getSize(); i++) {
c1.gridwidth = 1;
panel1.add(new JLabel(tab.labels[i] + " = "), c1);
if (tab.help != null) {
if (i < tab.help.size()) {
String[] tmp = tab.help.get(i);
if (tmp != null) {
helps.put(totalIndex, new JComboBox<>(tmp));
panel1.add(helps.get(totalIndex), c1);
c1.gridwidth = GridBagConstraints.REMAINDER; //end row
inserts[totalIndex] = new JButton("Use");
inserts[totalIndex].addActionListener(this);
panel1.add(inserts[totalIndex], c1);
}
}
}
c1.gridwidth = GridBagConstraints.REMAINDER; //end row
texts[totalIndex] = new JTextField(tab.values[i], 15);
panel1.add(texts[totalIndex], c1);
totalIndex ++;
}
pane.addTab(tab.identifier, panel1);
}
//panel1.setBorder(new javax.swing.border.TitledBorder("Properties"));
//panel1.setPreferredSize(new Dimension(600, 300));
// main panel;
c0.gridwidth = 1;
c0.gridheight = 10;
c0.weighty = 1.0;
c0.weightx = 1.0;
c0.gridwidth = GridBagConstraints.REMAINDER; //end row
c0.fill = GridBagConstraints.BOTH;
c.add(pane, c0);
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 != null) {
for (int i = 0; i < inserts.length; i++) {
if (evt.getSource() == inserts[i]) {
texts[i].setText(helps.get(i).getSelectedItem().toString());
}
}
}
}
public void closeDialog() {
set = true;
dispose();
}
public int getIndex(int tabIndex, int indexInTab) {
int index = 0;
for(int i=0; i<tabs.size(); i++) {
if (tabIndex == i) {
return index + indexInTab;
} else {
index += tabs.get(i).getSize();
}
}
return -1;
}
public String getString(int tabIndex, int indexInTab) {
// Compute index of box
int index = getIndex(tabIndex, indexInTab);
return texts[index].getText();
}
public boolean hasValidString(int i) {
return texts[i].getText().length() > 0;
}
public boolean hasBeenSet() {
return set;
}
public void cancelDialog() {
dispose();
}
}
/* 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.
*/
package ui.window;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Class TabInfo
* Specification of a tab for dialog windows
* Creation: 22/06/2018
*
* @author Ludovic APVRILLE
* @version 1.0 22/06/2018
*/
public class TabInfo {
public String identifier;
public String[] labels;
public String[] values;
public ArrayList<String[]> help;
public TabInfo(String _identifier) {
identifier = _identifier;
}
public int getSize() {
if (labels == null) {
return 0;
}
return labels.length;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment