Browse Source

Changed the simulators table mechanism substantially. It is now easier to hide variables (and in future configure more options). It is now the PathTableModel who is responsible for this, making it a lot easier to add variables back to the view. Also added a couple of extra menu options to the pop-up menu.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@135 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Mark Kattenbelt 20 years ago
parent
commit
3b0cc0e571
  1. 2
      prism/src/prism/PrismSettings.java
  2. 159
      prism/src/userinterface/simulator/GUIInitialStatePicker.form
  3. 184
      prism/src/userinterface/simulator/GUIInitialStatePicker.java
  4. 63
      prism/src/userinterface/simulator/GUISimulator.form
  5. 358
      prism/src/userinterface/simulator/GUISimulator.java
  6. 2
      prism/src/userinterface/simulator/GUISimulatorPathTable.java

2
prism/src/prism/PrismSettings.java

@ -119,6 +119,7 @@ public class PrismSettings implements Observer
public static final String SIMULATOR_SIMULTANEOUS = "simulator.simultaneous";
public static final String SIMULATOR_FIELD_CHOICE = "simulator.fieldChoice";
public static final String SIMULATOR_NEW_PATH_ASK_INITIAL = "simulator.newPathAskDefault";
public static final String SIMULATOR_NEW_PATH_ASK_VIEW = "simulator.newPathAskView";
public static final String SIMULATOR_RENDER_ALL_VALUES = "simulator.renderAllValues";
public static final String SIMULATOR_NETWORK_FILE = "simulator.networkFile";
@ -207,6 +208,7 @@ public class PrismSettings implements Observer
{ BOOLEAN_TYPE, SIMULATOR_SIMULTANEOUS, "check properties simultaneously?", "3.0", new Boolean(true), "", "When set to true, all relevant properties are checked over the same execution paths, meaning only one set of sample paths need be generated. This feature is only supported by the PRISM simulator." },
{ CHOICE_TYPE, SIMULATOR_FIELD_CHOICE, "values used in dialog", "3.0", "Last used values", "Last used values,Always use defaults", "This setting allows the choice between whether the values used in the simulation dialog are taken from the defaults every time, or from the last used values." },
{ BOOLEAN_TYPE, SIMULATOR_NEW_PATH_ASK_INITIAL, "ask for initial state?", "3.0", new Boolean(true), "", "When set to true, creating a new path in the simulator user interface prompts for an initial state rather than using default values for the model." },
{ BOOLEAN_TYPE, SIMULATOR_NEW_PATH_ASK_VIEW, "ask for view configuration?", "3.0", new Boolean(false), "", "When set to true, creating a new path in the simulator user interface prompts for an initial state rather than using default values for the model." },
{ CHOICE_TYPE, SIMULATOR_RENDER_ALL_VALUES, "path render style", "3.0", "Render changes", "Render changes,Render all values", "How the execution path in the simulator user interface should display the different states. The \'render changes\' option displays a value only if it has changed." },
{ FILE_TYPE, SIMULATOR_NETWORK_FILE, "network profile", "3.0", new File(""), "", "This file is used to specify the network profile which should be used by the distributed PRISM simulator." }
},

159
prism/src/userinterface/simulator/GUIInitialStatePicker.form

@ -1,48 +1,30 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Form version="1.2" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="formSizePolicy" type="int" value="2"/>
</SyntheticProperties>
<Events>
<EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
</Events>
<AuxValues>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-5,0,0,1,-92"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,46,0,0,2,38"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel6">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="South"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
<Property name="alignment" type="int" value="2"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="okayButton">
<Properties>
<Property name="text" type="java.lang.String" value="Okay"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okayButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="cancelButton">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel7">
<Container class="javax.swing.JPanel" name="allPanel">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder bottom="5" left="5" right="5" top="5"/>
</Border>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
@ -51,66 +33,89 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel1">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Initial State"/>
</Border>
</Property>
</Properties>
<Container class="javax.swing.JPanel" name="bottomPanel">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
<BorderConstraints direction="South"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel2">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
</Container>
<Container class="javax.swing.JPanel" name="jPanel3">
<Container class="javax.swing.JPanel" name="buttonPanel">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="2" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="East"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
<Property name="alignment" type="int" value="2"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="okayButton">
<Properties>
<Property name="text" type="java.lang.String" value="Okay"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okayButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="cancelButton">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel4">
<Component class="javax.swing.JCheckBox" name="optionCheckBox">
<Properties>
<Property name="label" type="java.lang.String" value="Always prompt for initial state on path creation"/>
</Properties>
<AccessibilityProperties>
<Property name="AccessibleContext.accessibleName" type="java.lang.String" value="optionCheckBox"/>
</AccessibilityProperties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="optionCheckBoxActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
</Container>
<Container class="javax.swing.JPanel" name="jPanel5">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="4" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="West"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="topPanel">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Initial state"/>
</Border>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
</Container>
<Container class="javax.swing.JPanel" name="topPanel">
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="innerPanel">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder bottom="5" left="5" right="5" top="5"/>
</Border>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="1" gridY="3" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>

184
prism/src/userinterface/simulator/GUIInitialStatePicker.java

@ -23,6 +23,7 @@
package userinterface.simulator;
import parser.*;
import prism.*;
import javax.swing.*;
import java.awt.*;
import javax.swing.border.*;
@ -32,19 +33,15 @@ import java.awt.event.*;
import userinterface.*;
public class GUIInitialStatePicker extends javax.swing.JDialog implements KeyListener
{
//STATICS
{
//STATICS
public static final int NO_VALUES = 0;
public static final int VALUES_DONE = 1;
public static final int CANCELLED = 2;
//ATTRIBUTES
//ATTRIBUTES
private boolean cancelled = true;
private boolean askOption;
private JTable initValuesTable;
private DefineValuesTable initValuesModel;
@ -52,25 +49,21 @@ public class GUIInitialStatePicker extends javax.swing.JDialog implements KeyLis
private Action okAction;
private Action cancelAction;
Values initialState;
Values initialState;
private GUIPrism gui;
private ModulesFile mf;
// Variables declaration - do not modify//GEN-BEGIN:variables
javax.swing.JButton cancelButton;
javax.swing.JPanel jPanel1;
javax.swing.JPanel jPanel2;
javax.swing.JPanel jPanel3;
javax.swing.JPanel jPanel4;
javax.swing.JPanel jPanel5;
javax.swing.JPanel jPanel6;
javax.swing.JPanel jPanel7;
javax.swing.JButton okayButton;
javax.swing.JPanel topPanel;
private javax.swing.JPanel allPanel;
private javax.swing.JPanel bottomPanel;
private javax.swing.JPanel buttonPanel;
private javax.swing.JButton cancelButton;
private javax.swing.JPanel innerPanel;
private javax.swing.JButton okayButton;
private javax.swing.JCheckBox optionCheckBox;
private javax.swing.JPanel topPanel;
// End of variables declaration//GEN-END:variables
/** Creates new form GUIConstantsPicker */
@ -83,30 +76,26 @@ public class GUIInitialStatePicker extends javax.swing.JDialog implements KeyLis
//setup tables
initValuesModel = new DefineValuesTable();
initValuesTable = new JTable();
initValuesTable = new JTable();
initValuesTable.setModel(initValuesModel);
initValuesTable.setSelectionMode(DefaultListSelectionModel.SINGLE_INTERVAL_SELECTION);
initValuesTable.setCellSelectionEnabled(true);
initValuesTable.setModel(initValuesModel);
initValuesTable.setSelectionMode(DefaultListSelectionModel.SINGLE_INTERVAL_SELECTION);
initValuesTable.setCellSelectionEnabled(true);
this.initialState = defaultInitial;
this.initialState = defaultInitial;
//initialise
initComponents();
this.getRootPane().setDefaultButton(okayButton);
initTable();
initValues();
setResizable(false);
pack();
initValues();
super.setBounds(new Rectangle(550, 300));
setResizable(true);
setLocationRelativeTo(getParent()); // centre
this.askOption = gui.getPrism().getSettings().getBoolean(PrismSettings.SIMULATOR_NEW_PATH_ASK_INITIAL);
optionCheckBox.setSelected(this.askOption);
}
/** This method is called from within the constructor to
@ -114,94 +103,80 @@ public class GUIInitialStatePicker extends javax.swing.JDialog implements KeyLis
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents()//GEN-BEGIN:initComponents
{
java.awt.GridBagConstraints gridBagConstraints;
jPanel6 = new javax.swing.JPanel();
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
allPanel = new javax.swing.JPanel();
bottomPanel = new javax.swing.JPanel();
buttonPanel = new javax.swing.JPanel();
okayButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
jPanel7 = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
jPanel3 = new javax.swing.JPanel();
jPanel4 = new javax.swing.JPanel();
jPanel5 = new javax.swing.JPanel();
optionCheckBox = new javax.swing.JCheckBox();
topPanel = new javax.swing.JPanel();
innerPanel = new javax.swing.JPanel();
addWindowListener(new java.awt.event.WindowAdapter()
{
public void windowClosing(java.awt.event.WindowEvent evt)
{
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
}
});
jPanel6.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
allPanel.setLayout(new java.awt.BorderLayout());
allPanel.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(5, 5, 5, 5)));
bottomPanel.setLayout(new java.awt.BorderLayout());
buttonPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
okayButton.setText("Okay");
okayButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
okayButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okayButtonActionPerformed(evt);
}
});
jPanel6.add(okayButton);
buttonPanel.add(okayButton);
cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
jPanel6.add(cancelButton);
buttonPanel.add(cancelButton);
getContentPane().add(jPanel6, java.awt.BorderLayout.SOUTH);
bottomPanel.add(buttonPanel, java.awt.BorderLayout.EAST);
jPanel7.setLayout(new java.awt.BorderLayout());
optionCheckBox.setLabel("Always prompt for initial state on path creation");
optionCheckBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
optionCheckBoxActionPerformed(evt);
}
});
jPanel1.setLayout(new java.awt.GridBagLayout());
bottomPanel.add(optionCheckBox, java.awt.BorderLayout.WEST);
optionCheckBox.getAccessibleContext().setAccessibleName("optionCheckBox");
jPanel1.setBorder(new javax.swing.border.TitledBorder("Initial State"));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
jPanel1.add(jPanel2, gridBagConstraints);
allPanel.add(bottomPanel, java.awt.BorderLayout.SOUTH);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 0;
jPanel1.add(jPanel3, gridBagConstraints);
topPanel.setLayout(new java.awt.BorderLayout());
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
jPanel1.add(jPanel4, gridBagConstraints);
topPanel.setBorder(new javax.swing.border.TitledBorder("Initial state"));
innerPanel.setLayout(new java.awt.BorderLayout());
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 4;
jPanel1.add(jPanel5, gridBagConstraints);
innerPanel.setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(5, 5, 5, 5)));
topPanel.add(innerPanel, java.awt.BorderLayout.CENTER);
topPanel.setLayout(new java.awt.BorderLayout());
allPanel.add(topPanel, java.awt.BorderLayout.CENTER);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 3;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
jPanel1.add(topPanel, gridBagConstraints);
getContentPane().add(allPanel, java.awt.BorderLayout.CENTER);
jPanel7.add(jPanel1, java.awt.BorderLayout.CENTER);
}
// </editor-fold>//GEN-END:initComponents
getContentPane().add(jPanel7, java.awt.BorderLayout.CENTER);
pack();
}//GEN-END:initComponents
private void optionCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_optionCheckBoxActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_optionCheckBoxActionPerformed
@ -215,9 +190,9 @@ public class GUIInitialStatePicker extends javax.swing.JDialog implements KeyLis
JScrollPane sp = new JScrollPane();
sp.setViewportView(initValuesTable);
topPanel.add(sp);
innerPanel.add(sp);
topPanel.setPreferredSize(new Dimension(300,300));
innerPanel.setPreferredSize(new Dimension(300,300));
}
private void initValues()
@ -296,7 +271,18 @@ public class GUIInitialStatePicker extends javax.swing.JDialog implements KeyLis
int i, n;
Value c;
if (optionCheckBox.isSelected() != this.askOption)
{
this.askOption = !this.askOption;
try
{
gui.getPrism().getSettings().set(PrismSettings.SIMULATOR_NEW_PATH_ASK_INITIAL, this.askOption);
}
catch (PrismException e)
{
}
}
if(initValuesTable.getCellEditor() != null)initValuesTable.getCellEditor().stopCellEditing();

63
prism/src/userinterface/simulator/GUISimulator.form

@ -6,6 +6,10 @@
</Component>
</NonVisualComponents>
<AuxValues>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,3,7,0,0,3,102"/>
</AuxValues>
@ -107,9 +111,6 @@
</Container>
<Component class="javax.swing.JButton" name="manualUpdateField">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.openide.explorer.propertysheet.editors.IconEditor">
<Image iconType="3" name="/images/smallManualUpdate.gif"/>
</Property>
<Property name="text" type="java.lang.String" value="Do Update"/>
<Property name="toolTipText" type="java.lang.String" value="Perform the selected update"/>
<Property name="horizontalAlignment" type="int" value="10"/>
@ -124,8 +125,8 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="manualUpdateFieldActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
@ -160,8 +161,8 @@
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
@ -180,8 +181,8 @@
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
@ -212,8 +213,8 @@
<Property name="toolTipText" type="java.lang.String" value="Automatically sample time from a negative exponential distribution"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
@ -266,8 +267,8 @@
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value="currentUpdatesTable = new GUISimulatorUpdatesTable(updateTableModel, this);"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
</SubComponents>
@ -278,8 +279,8 @@
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value="Font f = jLabel5.getFont();&#xa;&#xa;jLabel5.setFont(new Font(f.getName(), Font.BOLD, f.getSize()));"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
@ -312,9 +313,6 @@
</Container>
<Component class="javax.swing.JButton" name="autoUpdateButton">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.openide.explorer.propertysheet.editors.IconEditor">
<Image iconType="3" name="/images/smallAutomaticUpdate.gif"/>
</Property>
<Property name="text" type="java.lang.String" value="Auto Update"/>
<Property name="toolTipText" type="java.lang.String" value="Make a number of automatic updates"/>
<Property name="horizontalAlignment" type="int" value="10"/>
@ -323,8 +321,8 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="autoUpdateButtonActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
@ -354,8 +352,8 @@
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
@ -384,8 +382,8 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="autoUpdateFieldActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
@ -449,9 +447,6 @@
</Container>
<Component class="javax.swing.JButton" name="backtrackButton">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.openide.explorer.propertysheet.editors.IconEditor">
<Image iconType="3" name="/images/smallBacktrack.gif"/>
</Property>
<Property name="text" type="java.lang.String" value="Backtrack"/>
<Property name="toolTipText" type="java.lang.String" value="Backtrack to the given step."/>
<Property name="horizontalAlignment" type="int" value="10"/>
@ -460,8 +455,8 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="backtrackButtonActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
@ -477,8 +472,8 @@
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
@ -514,9 +509,6 @@
</Container>
<Component class="javax.swing.JButton" name="removePrecedingButton">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.openide.explorer.propertysheet.editors.IconEditor">
<Image iconType="3" name="/images/smallRemovePreceding.gif"/>
</Property>
<Property name="text" type="java.lang.String" value="Remove"/>
<Property name="toolTipText" type="java.lang.String" value="Remove all before the given step"/>
<Property name="horizontalAlignment" type="int" value="10"/>
@ -525,8 +517,8 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="removePrecedingButtonActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
@ -542,8 +534,8 @@
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
@ -560,8 +552,8 @@
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
@ -578,8 +570,8 @@
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
@ -699,8 +691,8 @@
<Component class="javax.swing.JList" name="pathFormulaeList">
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value="pathFormulaeList = new GUISimPathFormulaeList(this);"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
</SubComponents>
@ -805,9 +797,6 @@
<SubComponents>
<Component class="javax.swing.JButton" name="newPathButton">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.openide.explorer.propertysheet.editors.IconEditor">
<Image iconType="3" name="/images/smallNewPath.gif"/>
</Property>
<Property name="text" type="java.lang.String" value="New Path"/>
<Property name="toolTipText" type="java.lang.String" value="New Path"/>
<Property name="horizontalAlignment" type="int" value="10"/>
@ -819,8 +808,8 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="newPathButtonActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
@ -830,9 +819,6 @@
</Component>
<Component class="javax.swing.JButton" name="resetPathButton">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.openide.explorer.propertysheet.editors.IconEditor">
<Image iconType="3" name="/images/smallResetPath.gif"/>
</Property>
<Property name="text" type="java.lang.String" value="Reset Path"/>
<Property name="toolTipText" type="java.lang.String" value="Reset Path"/>
<Property name="horizontalAlignment" type="int" value="10"/>
@ -844,8 +830,8 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="resetPathButtonActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
@ -855,9 +841,6 @@
</Component>
<Component class="javax.swing.JButton" name="exportPathButton">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.openide.explorer.propertysheet.editors.IconEditor">
<Image iconType="3" name="/images/smallExport.gif"/>
</Property>
<Property name="text" type="java.lang.String" value="Export Path"/>
<Property name="toolTipText" type="java.lang.String" value="Export Path"/>
<Property name="horizontalAlignment" type="int" value="10"/>
@ -869,8 +852,8 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exportPathButtonActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">

358
prism/src/userinterface/simulator/GUISimulator.java

@ -61,39 +61,21 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect
private GUISimulator.UpdateTableModel updateTableModel;
private Values lastConstants, lastPropertyConstants, lastInitialState;
private ArrayList hiddenColumns;
//private int maxPathLength;
//External state
private boolean computing;
//Options
//private boolean verifyAllPropertiesAtOnce;
//private GUISimulatorOptions options;
private boolean displayStyleFast;
//private boolean askForInitialState;
private boolean displayPathLoops;
//Actions
private Action backtrackToHere, removeToHere;
private JMenu showColumnMenu;
private Action backtrackToHere, removeToHere, newPath, resetPath, exportPath, configureView;
/** Creates a new instance of GUISimulator */
public GUISimulator(GUIPrism gui)
{
super(gui, true);
pathTableModel = new PathTableModel();
pathTableModel = new PathTableModel(this);
updateTableModel = new UpdateTableModel();
hiddenColumns = new ArrayList();
this.gui = gui;
this.engine = gui.getPrism().getSimulator();
initComponents();
@ -105,28 +87,17 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect
pathTable.getTableHeader().addMouseListener(this);
pathTable.getParent().addMouseListener(this);
pathTable.getTableHeader().setReorderingAllowed(false);
pathTable.getTableHeader().setReorderingAllowed(true);
pathTable.addComponentListener(new ComponentListener()
{
public void componentHidden(ComponentEvent e)
{
}
public void componentMoved(ComponentEvent e)
{
}
public void componentResized(ComponentEvent e)
{
public void componentHidden(ComponentEvent e){}
public void componentMoved(ComponentEvent e){}
public void componentResized(ComponentEvent e) {
sortOutColumnSizes();
}
public void componentShown(ComponentEvent e)
{
}
public void componentShown(ComponentEvent e){}
});
@ -386,6 +357,7 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect
lastInitialState = defaultInitialState;
}
}
initialState = GUIInitialStatePicker.defineInitalValuesWithDialog(getGUI(), lastInitialState, mf);
// if user clicked cancel from dialog...
if (initialState == null) {
@ -421,10 +393,16 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect
repopulateFormulae();
stateLabelList.repaint();
pathFormulaeList.repaint();
//pathTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
// store inital state for next time
lastInitialState = initialState;
if (getPrism().getSettings().getBoolean(PrismSettings.SIMULATOR_NEW_PATH_ASK_VIEW))
{
new GUIViewDialog(gui, pathTableModel, mf);
}
}
catch(PrismException e)
{
@ -684,6 +662,11 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect
}
}
public void a_configureView()
{
new GUIViewDialog(gui, pathTableModel, mf);
}
public void repopulateFormulae()
{
((GUISimPathFormulaeList)pathFormulaeList).clearList();
@ -1893,7 +1876,46 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect
}//GEN-END:initComponents
private void initPopups()
{
{
newPath = new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
a_newPath();
}
};
newPath.putValue(Action.LONG_DESCRIPTION, "Creates a new path.");
newPath.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_N));
newPath.putValue(Action.NAME, "New Path");
newPath.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallNewPath.gif"));
resetPath = new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
a_restartPath();
}
};
resetPath.putValue(Action.LONG_DESCRIPTION, "Resets the path.");
resetPath.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_R));
resetPath.putValue(Action.NAME, "Reset Path");
resetPath.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallResetPath.gif"));
exportPath = new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
a_exportPath();
}
};
exportPath.putValue(Action.LONG_DESCRIPTION, "Exports the path.");
exportPath.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_X));
exportPath.putValue(Action.NAME, "Export Path");
exportPath.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallExport.gif"));
backtrackToHere = new AbstractAction()
{
public void actionPerformed(ActionEvent e)
@ -1933,19 +1955,27 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect
removeToHere.putValue(Action.NAME, "Remove preceding steps");
removeToHere.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallRemovePreceding.gif"));
//item to dynamically add checkboxes for each column
showColumnMenu = new JMenu("Show Column");
configureView = new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
a_configureView();
}
};
configureView.putValue(Action.LONG_DESCRIPTION, "Configures the view.");
configureView.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_C));
configureView.putValue(Action.NAME, "Configure View");
configureView.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFind.gif"));
pathPopup = new JPopupMenu();
pathPopup.add(showColumnMenu);
pathPopup.add(newPath);
pathPopup.add(resetPath);
pathPopup.add(exportPath);
pathPopup.addSeparator();
pathPopup.add(backtrackToHere);
pathPopup.add(removeToHere);
pathPopup.addSeparator();
pathPopup.add(configureView);
}
@ -2059,9 +2089,16 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect
backtrackToHere.setEnabled(!(e.getSource() == pathTable.getTableHeader() || e.getSource() == pathTable.getParent()));
removeToHere.setEnabled(!(e.getSource() == pathTable.getTableHeader() || e.getSource() == pathTable.getParent()));
newPath.setEnabled(newPathButton.isEnabled());
resetPath.setEnabled(resetPathButton.isEnabled());
exportPath.setEnabled(exportPathButton.isEnabled());
configureView.setEnabled(pathActive);
int index = pathTable.rowAtPoint(e.getPoint());
pathTable.getSelectionModel().setSelectionInterval(index, index);
/*
showColumnMenu.removeAll();
//Now populate showColumnMenu with all columns
@ -2106,6 +2143,9 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect
showColumnMenu.add(showColumn);
}
*/
/*
showColumnMenu.addSeparator();
JMenuItem showAll = new JMenuItem("Show all columns");
@ -2125,7 +2165,7 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect
}
});
showColumnMenu.add(showAll);
*/
pathPopup.show(e.getComponent(), e.getX(), e.getY());
@ -2389,32 +2429,120 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect
private javax.swing.JLabel transitionTotalRewardsLabel;
// End of variables declaration//GEN-END:variables
class PathTableModel extends AbstractTableModel
/**
* @author mxk
* Represents a in the model.
*/
public class Variable
{
private int index;
private String name;
private int type;
public int getColumnCount()
public Variable(int index, String name, int type)
{
int colCount;
if(pathActive)
colCount = 1+engine.getNumVariables();
else colCount = 0;
if(mf == null) return colCount;
if(mf.getType() == ModulesFile.STOCHASTIC)
colCount +=1;
colCount += (2*mf.getNumRewardStructs());
return colCount;
this.index = index;
this.name = name;
this.type = type;
}
public int getRowCount()
public int getIndex()
{
return index;
}
public String getName()
{
return name;
}
public int getType()
{
return type;
}
public String toString()
{
return name;
}
public boolean equals(Object o)
{
return (o instanceof Variable && ((Variable)o).getIndex() == index);
}
}
class PathTableModel extends AbstractTableModel
{
private boolean SHOW_STEP = true;
ArrayList visibleVariables;
ArrayList hiddenVariables;
GUISimulator simulator;
public PathTableModel(GUISimulator simulator)
{
this.simulator = simulator;
}
public SimulatorEngine getEngine()
{
return engine;
}
public ArrayList getVisibleVariables()
{
return visibleVariables;
}
public ArrayList getHiddenVariables()
{
return hiddenVariables;
}
public void setVisibility(ArrayList visibleVariables, ArrayList hiddenVariables)
{
this.visibleVariables = visibleVariables;
this.hiddenVariables = hiddenVariables;
if(pathActive)
return engine.getPathSize();
else return 0;
if (pathActive)
{ fireTableStructureChanged(); }
}
/**
* Returns the number of columns.
* @see javax.swing.table.TableModel#getColumnCount()
*/
public int getColumnCount()
{
if (!pathActive)
{ return 0; }
else
{
// At least we have the step count and s.
int colCount = 1 + visibleVariables.size();
// Add state and transitions rewards for each reward structure.
colCount += (2*mf.getNumRewardStructs());
// Add a column for time if CTMC.
if (mf.getType() == ModulesFile.STOCHASTIC)
{ colCount += 1; }
return colCount;
}
}
/**
* Returns the number of rows.
* @see javax.swing.table.TableModel#getRowCount()
*/
public int getRowCount()
{
// Return current path size if there is an active path.
return (pathActive ? SimulatorEngine.getPathSize() : 0);
}
public boolean shouldColourRow(int row)
@ -2444,41 +2572,57 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect
{
if(pathActive)
{
if (columnIndex == 0) return ""+rowIndex;
int stepStart = 0;
int varStart = (SHOW_STEP) ? stepStart + 1 : stepStart;
int timeStart = varStart + visibleVariables.size();
// The step column
if (stepStart <= columnIndex && columnIndex < varStart)
{
return "" + rowIndex;
}
// A variable column
else if (varStart <= columnIndex && columnIndex < timeStart)
{
int varIndex = ((Variable)visibleVariables.get(columnIndex - varStart)).getIndex();
int type = engine.getVariableType(varIndex);
int result = SimulatorEngine.getPathData(varIndex, rowIndex);
if(type == Expression.BOOLEAN)
{ return new Boolean(result != 0); }
else if (type == Expression.INT)
{ return new Integer(result); }
}
// todo: tidy rest up.
if (mf == null) return null;
if(mf.getType() == ModulesFile.STOCHASTIC)
{
int n = engine.getNumVariables();
int n = visibleVariables.size();
if(columnIndex == n+1) //where time should be
{
return new Double(engine.getTimeSpentInPathState(rowIndex));
return new Double(SimulatorEngine.getTimeSpentInPathState(rowIndex));
}
else if(columnIndex > n+1) //rewards
{
int i = columnIndex-(n+2);
if (i%2 == 0) return new Double(engine.getStateRewardOfPathState(rowIndex,i/2));
else return new Double(engine.getTransitionRewardOfPathState(rowIndex,i/2));
if (i%2 == 0) return new Double(SimulatorEngine.getStateRewardOfPathState(rowIndex,i/2));
else return new Double(SimulatorEngine.getTransitionRewardOfPathState(rowIndex,i/2));
}
}
else
{
int n = engine.getNumVariables();
int n = visibleVariables.size();
if(columnIndex > n)
{
int i = columnIndex-(n+1);
if (i%2 == 0) return new Double(engine.getStateRewardOfPathState(rowIndex,i/2));
else return new Double(engine.getTransitionRewardOfPathState(rowIndex,i/2));
if (i%2 == 0) return new Double(SimulatorEngine.getStateRewardOfPathState(rowIndex,i/2));
else return new Double(SimulatorEngine.getTransitionRewardOfPathState(rowIndex,i/2));
}
}
int type = engine.getVariableType(columnIndex-1);
int result = engine.getPathData(columnIndex-1, rowIndex);
if(type == Expression.BOOLEAN)
{
if(result == 0) return new Boolean(false);
else return new Boolean(true);
}
else
return new Integer(result);
return null;
}
else return null;
}
@ -2495,11 +2639,26 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect
{
if(pathActive)
{
if (column == 0) return "Step";
int stepStart = 0;
int varStart = (SHOW_STEP) ? stepStart + 1 : stepStart;
int timeStart = varStart + visibleVariables.size();
// The step column
if (column == stepStart && SHOW_STEP)
{
return "#";
}
// A variable column
else if (varStart <= column && column < timeStart)
{
return ((Variable)visibleVariables.get(column - varStart)).getName();
}
if (mf == null) return null;
if (mf.getType() == ModulesFile.STOCHASTIC)
{
int n = engine.getNumVariables();
int n = visibleVariables.size();
if(column == n+1) //where time should be
{
return "Time";
@ -2512,7 +2671,7 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect
}
else
{
int n = engine.getNumVariables();
int n = visibleVariables.size();
if(column > n) //rewards
{
int i = column-(n+1);
@ -2529,13 +2688,35 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect
}
}
/**
* Method is called when a new path is created.
* The structure of the path may be for a different model etc.
*/
public void restartPathTable()
{
{
visibleVariables = new ArrayList();
hiddenVariables = new ArrayList();
if (pathActive)
{
try
{
for (int i = 0; i < engine.getNumVariables(); i++)
{
visibleVariables.add(new Variable(i, engine.getVariableName(i), engine.getVariableType(i))); }
}
catch (SimulatorException e) {}
}
fireTableStructureChanged();
//Sort out the minimum widths for each column
sortOutColumnSizes();
}
/**
* Method is called whenever a path is modified.
*/
public void updatePathTable()
{
fireTableDataChanged();
@ -2560,7 +2741,6 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect
{
return displayPathLoops;
}
}
public void sortOutColumnSizes()

2
prism/src/userinterface/simulator/GUISimulatorPathTable.java

@ -364,7 +364,7 @@ public class GUISimulatorPathTable extends JTable
column = table.convertColumnIndexToModel(column);
bg = Color.white;
if(column == 0 || column > engine.getNumVariables())
if(column == 0 || column > ptm.getVisibleVariables().size())
{
if(value instanceof Double)
{

Loading…
Cancel
Save