Commit 9e65d835 authored by apvrille's avatar apvrille

Update on network models: management of properties

parent 9b2e48ea
......@@ -57,10 +57,7 @@ import javax.swing.event.EventListenerList;
public class TGUIAction extends AbstractAction {
/**
*
*/
private static final long serialVersionUID = -4942930048930203001L;
private static final long serialVersionUID = -4942930048930203001L;
// Actions
public static final int ACT_NEW = 0;
......@@ -652,7 +649,7 @@ public class TGUIAction extends AbstractAction {
actions[ACT_NEW_DESIGN] = new TAction("new-command-design", "New design", IconManager.imgic14, IconManager.imgic14, "New design", "New TURTLE design", 0);
actions[ACT_NEW_ANALYSIS] = new TAction("new-command-analysis", "New analysis", IconManager.imgic17, IconManager.imgic17, "New analysis", "New TURTLE analysis", 0);
actions[ACT_OPEN] = new TAction("open-command","Open", IconManager.imgic22, IconManager.imgic23, "Open", "Open an existing TTooll model",'O', true);
actions[ACT_OPEN_FROM_NETWORK] = new TAction("open-command-from-network","Open from network", IconManager.imgic22, IconManager.imgic23, "Open from network", "Open an existing TTool model from the TTool website",'O', true);
actions[ACT_OPEN_FROM_NETWORK] = new TAction("open-command-from-network","Open from TTool repository", IconManager.imgic22, IconManager.imgic23, "Open from TTool repository", "Open an existing TTool model from the TTool repository (TTool website)",'O', true);
actions[ACT_OPEN_LAST] = new TAction("openlast-command","Open file: " + ConfigurationTTool.LastOpenFile, IconManager.imgic22, IconManager.imgic23, "Open: " + ConfigurationTTool.LastOpenFile, "Open the lastly saved TTool model", 0);
actions[ACT_MERGE] = new TAction("merge-command","Merge", IconManager.imgic22, IconManager.imgic23, "Merge", "Merge the current TTool modeling with another one saved in a file ", 0);
actions[ACT_SAVE] = new TAction("save-command", "Save",IconManager.imgic24, IconManager.imgic25, "Save", "Save an opened or a new TTool modeling", 'S', true);
......
......@@ -60,9 +60,9 @@ import myutil.*;
public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements ActionListener, Runnable, LoaderFacilityInterface, CallbackLoaderInterface {
public final static String [] FEATURES = {"All", "Requirements", "Attacktrees", "Properties", "Partitioning", "Analysis", "Design", "Prototyping", "Security protocol"};
public final static String [] FEATURES = {"all", "requirements", "attacktrees", "properties", "partitioning", "analysis", "design", "prototyping", "security protocol"};
public final static String [] PROPS = {"All", "Safety", "Security", "Performance"};
public final static String [] PROPS = {"safety", "security", "performance"};
private ArrayList<NetworkModel> listOfModels;
......@@ -80,7 +80,8 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac
private JTextAreaWriter textAreaWriter;
protected JButton start;
protected JButton stop;
protected JList<String> featureList;
protected JComboBox<String> featureList;
protected JCheckBox [] props;
protected JScrollPane jsp;
......@@ -147,8 +148,18 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac
jsp.setPreferredSize(new Dimension(400, 200));
JPanel options = new JPanel();
featureList = new JList<String>(FEATURES);
featureList = new JComboBox<String>(FEATURES);
featureList.addActionListener(this);
options.add(featureList);
props = new JCheckBox[PROPS.length];
for (int i=0; i<props.length; i++) {
props[i] = new JCheckBox(PROPS[i]);
props[i].addActionListener(this);
props[i].setSelected(true);
options.add(props[i]);
}
lowPart.add(options, BorderLayout.NORTH);
......@@ -182,16 +193,24 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac
//String command = evt.getActionCommand();
// Compare the action command to the known actions.
if (evt.getSource() == start) {
loadFile();
} else if (evt.getSource() == stop) {
if (evt.getSource() == stop) {
cancel();
}
}
return ;
} else if (evt.getSource() == featureList) {
featureSelectionMade();
return;
}
for (int i = 0; i<props.length; i++) {
if (evt.getSource() == props[i]) {
panel.setProperty(i, props[i].isSelected());
return;
}
}
}
public void loadFile() {
// Run the retreiver + analyzer
public void featureSelectionMade() {
panel.setFeatureSelectedIndex(featureList.getSelectedIndex());
}
public void cancel() {
......@@ -229,7 +248,7 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac
if (inputLine.startsWith("-FEATURES")) {
if (nm != null) {
String tmp = inputLine.substring(9, inputLine.length()).trim();
String tmp = inputLine.substring(9, inputLine.length()).trim().toLowerCase();
for (int i=1; i<FEATURES.length; i++) {
nm.features[i] = tmp.indexOf(FEATURES[i]) != -1;
}
......@@ -239,8 +258,8 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac
if (inputLine.startsWith("-PROPS")) {
if (nm != null) {
String tmp = inputLine.substring(6, inputLine.length()).trim();
for (int i=1; i<PROPS.length; i++) {
String tmp = inputLine.substring(6, inputLine.length()).trim().toLowerCase();
for (int i=0; i<PROPS.length; i++) {
nm.props[i] = tmp.indexOf(PROPS[i]) != -1;
}
//nm.type = NetworkModel.stringToNetworkModelType(inputLine.substring(5, inputLine.length()).trim());
......@@ -307,6 +326,8 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac
}
}
// LoaderFacilityInterface
public void load(int index) {
String fileName = listOfModels.get(index).fileName;
jta.append("Loading model: " + fileName);
......@@ -320,6 +341,7 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac
}
}
// CallbackLoaderInterface
public void loadDone() {
jta.append("Model transfered, opening it in TTool\n");
this.dispose();
......@@ -331,7 +353,8 @@ public class JDialogLoadingNetworkModel extends javax.swing.JFrame implements Ac
panel.reactivateSelection();
}
// JTA manipulation by external objects
public void appendOut(String s) {
jta.append(s);
}
......
......@@ -70,15 +70,13 @@ public class NetworkModel {
features = new boolean[JDialogLoadingNetworkModel.FEATURES.length];
features[0] = true;
props = new boolean[JDialogLoadingNetworkModel.PROPS.length];
props[0] = true;
}
public void update() {
}
public static NetworkModelType stringToNetworkModelType(String type) {
/*public static NetworkModelType stringToNetworkModelType(String type) {
type = type.toLowerCase();
if (type.compareTo("software design") == 0) {
return NetworkModelType.SOFTWARE_DESIGN;
......@@ -97,6 +95,6 @@ public class NetworkModel {
}
return NetworkModelType.SOFTWARE_DESIGN;
}
}*/
}
......@@ -142,15 +142,15 @@ public class TMLArchiDiagramToolBar extends TToolBar implements ActionListener
button = this.add(mgui.actions[TGUIAction.TMLARCHI_EVENT_ARTIFACT]);
button.addMouseListener(mgui.mouseHandler);
}
button = this.add(mgui.actions[TGUIAction.TMLARCHI_COMMUNICATION_ARTIFACT]);
button = this.add(mgui.actions[TGUIAction.TMLARCHI_COMMUNICATION_ARTIFACT]);
button.addMouseListener(mgui.mouseHandler);
button = this.add(mgui.actions[TGUIAction.TMLARCHI_PORT_ARTIFACT]);
button = this.add(mgui.actions[TGUIAction.TMLARCHI_PORT_ARTIFACT]);
button.addMouseListener(mgui.mouseHandler);
button = this.add(mgui.actions[TGUIAction.TMLARCHI_KEY]);
button = this.add(mgui.actions[TGUIAction.TMLARCHI_KEY]);
button.addMouseListener(mgui.mouseHandler);
this.addSeparator();
button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_ATTR]);
this.addSeparator();
button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_ATTR]);
button = this.add(mgui.actions[TGUIAction.TMLARCHI_COMMUNICATION_ARTIFACT]);
button.addMouseListener(mgui.mouseHandler);
button = this.add(mgui.actions[TGUIAction.TMLARCHI_PORT_ARTIFACT]);
......@@ -166,32 +166,32 @@ public class TMLArchiDiagramToolBar extends TToolBar implements ActionListener
button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_DIPLO_ID]);
button.addMouseListener(mgui.mouseHandler);
this.addSeparator();
button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_DIPLO_ID]);
this.addSeparator();
button = this.add(mgui.actions[TGUIAction.ACT_TOGGLE_DIPLO_ID]);
button.addMouseListener(mgui.mouseHandler);
this.addSeparator();
if (viewInfos == null) {
TraceManager.addDev("null viewInfos");
}
box = new JComboBox(viewInfos);
this.add(box);
box.addActionListener(this);
this.addSeparator();
if (viewInfos == null) {
TraceManager.addDev("null viewInfos");
}
box = new JComboBox(viewInfos);
this.add(box);
box.addActionListener(this);
}
public void setPanel(TMLArchiDiagramPanel _panel) {
panel = _panel;
panel = _panel;
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == box) {
if (panel != null) {
panel.setCurrentView(box.getSelectedIndex());
}
}
if (e.getSource() == box) {
if (panel != null) {
panel.setCurrentView(box.getSelectedIndex());
}
}
}
} // Class
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment