From fca4ce844e93ac122a993e6b4e0efc5b011262b9 Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Tue, 27 Jul 2010 09:15:18 +0000 Subject: [PATCH] Code tidy (GUI). git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@2007 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- .../properties/GUIMultiProperties.java | 1206 +++++++---------- .../properties/GUIPropertiesList.java | 369 ++--- .../userinterface/properties/GUIProperty.java | 249 ++-- .../computation/ModelCheckThread.java | 8 +- 4 files changed, 849 insertions(+), 983 deletions(-) diff --git a/prism/src/userinterface/properties/GUIMultiProperties.java b/prism/src/userinterface/properties/GUIMultiProperties.java index d4aa9f5a..866362e0 100644 --- a/prism/src/userinterface/properties/GUIMultiProperties.java +++ b/prism/src/userinterface/properties/GUIMultiProperties.java @@ -56,32 +56,30 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List { //CONSTANTS public static final int CONTINUE = 0; - public static final int CANCEL = 1; - + public static final int CANCEL = 1; + public static final int WARN_INVALID_PROPS = 1; public static final int NEVER_INVALID_PROPS = 2; - + //ATTRIBUTES - + // current model (gets updated only by event listening to GUIModel) private ModulesFile parsedModel; private Model builtModel; private Values lastBuildValues; - + //state private boolean modified; private boolean modifiedSinceBuild; private boolean computing; - private boolean verifyAfterReceiveParseNotification, - verifyAfterReceiveBuildNotification, - experimentAfterReceiveParseNotification, - simulateAfterReceiveParseNotification; + private boolean verifyAfterReceiveParseNotification, verifyAfterReceiveBuildNotification, experimentAfterReceiveParseNotification, + simulateAfterReceiveParseNotification; private PropertiesFile parsedProperties; - private ArrayList propertiesToBeVerified; + private ArrayList propertiesToBeVerified; private File activeFile; private Values lastPFConstants; private Values lastSimulateValues; - + //gui private GUIPrismFileFilter propsFilter[]; private GUIPrismFileFilter textFilter[]; @@ -92,24 +90,21 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List private JScrollPane expScroller; private JLabel fileLabel; private Vector clipboardVector; - - private Action newProps, openProps, saveProps, savePropsAs, insertProps, - verifySelected, - newProperty, editProperty, newConstant, - removeConstant, newLabel, removeLabel, newExperiment, deleteExperiment, stopExperiment, - viewResults, plotResults, exportResults, simulate, details; - + + private Action newProps, openProps, saveProps, savePropsAs, insertProps, verifySelected, newProperty, editProperty, newConstant, removeConstant, newLabel, + removeLabel, newExperiment, deleteExperiment, stopExperiment, viewResults, plotResults, exportResults, simulate, details; + //current properties private GUIPropertiesList propList; private GUIPropConstantList consTable; private GUIPropLabelList labTable; - + // Cached copies of settings private Font displayFontFast; private Color backgroundFast, warningFast; - + //CONSTRUCTORS - + /** Creates a new instance of GUIMultiProperties */ public GUIMultiProperties(GUIPrism pr, GUISimulator simulator) { @@ -121,7 +116,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List setParsedModel(null); //options = new GUIPropertiesOptions(this); } - + public void takeCLArgs(String args[]) { // disabled for now - need to sort out so this doesn't happen until model is fully parsed @@ -131,151 +126,148 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List // t.start(); // } } - + //ACCESS METHODS - + public ModulesFile getParsedModel() { return parsedModel; } - + public String getConstantsString() { return consTable.getValidConstantsString(); } - + public String getLabelsString() { return labTable.getValidLabelsString(); } - + public int getNumConstants() { return consTable.getRowCount(); } - + public int getNumLabels() { return labTable.getRowCount(); } - + public Font getListFont() { return displayFontFast; } - + public Color getWarningColor() { return warningFast; } - + public Color getSelectionColor() { return backgroundFast; } - + public int getInvalidPropertyStrategy() { - return getPrism().getSettings().getInteger(PrismSettings.PROPERTIES_ADDITION_STRATEGY)+1; //note the correction + return getPrism().getSettings().getInteger(PrismSettings.PROPERTIES_ADDITION_STRATEGY) + 1; //note the correction } - + /* UPDATE METHODS */ - + public void repaintList() { propList.repaint(); } - + protected void verifyAfterBuild() { verifyAfterReceiveBuildNotification = false; + + // Re-enable GUI elements propList.setEnabled(true); consTable.setEnabled(true); labTable.setEnabled(true); - if(builtModel != null && parsedProperties != null && propertiesToBeVerified != null) - { + // Start model check process + if (builtModel != null && parsedProperties != null && propertiesToBeVerified != null) { Thread t = new ModelCheckThread(this, builtModel, parsedProperties, propertiesToBeVerified, lastBuildValues, lastPFConstants); t.setPriority(Thread.NORM_PRIORITY); t.start(); } } - + protected void verifyAfterParse() { - verifyAfterReceiveParseNotification = false; - ArrayList validGUIProperties; + ArrayList validGUIProperties; Values buildValues; UndefinedConstants uCon; - try - { - parsedProperties = getPrism().parsePropertiesString(parsedModel, getLabelsString()+"\n"+getConstantsString()+"\n"+propList.getValidSelectedString()); + + verifyAfterReceiveParseNotification = false; + + // Get valid/selected properties + try { + String propertiesString = getLabelsString() + "\n" + getConstantsString() + "\n" + propList.getValidSelectedString(); + // Get PropertiesFile for valid/selected properties + parsedProperties = getPrism().parsePropertiesString(parsedModel, propertiesString); + // And get list of corresponding GUIProperty objects validGUIProperties = propList.getValidSelectedProperties(); - } - catch(PrismException e) - { + } catch (PrismException e) { error(e.getMessage()); return; } - - //find out any undefined constants - try - { + + // Query user for undefined constant values (if required) + try { uCon = new UndefinedConstants(parsedModel, parsedProperties); - if(uCon.getMFNumUndefined() + uCon.getPFNumUndefined() > 0) - { + if (uCon.getMFNumUndefined() + uCon.getPFNumUndefined() > 0) { int result = GUIConstantsPicker.defineConstantsWithDialog(this.getGUI(), uCon, lastBuildValues, lastPFConstants); - if(result != GUIConstantsPicker.VALUES_DONE) + if (result != GUIConstantsPicker.VALUES_DONE) return; } buildValues = uCon.getMFConstantValues(); lastPFConstants = uCon.getPFConstantValues(); parsedProperties.setUndefinedConstants(lastPFConstants); - } - catch(PrismException e) - { + } catch (PrismException e) { error(e.getMessage()); return; } - verifyAfterReceiveBuildNotification = true; - propertiesToBeVerified = validGUIProperties; + // Disable GUI elements in Properties tab propList.setEnabled(false); consTable.setEnabled(false); + // Trigger build then verify + verifyAfterReceiveBuildNotification = true; + propertiesToBeVerified = validGUIProperties; notifyEventListeners(new GUIPropertiesEvent(GUIPropertiesEvent.REQUEST_MODEL_BUILD, buildValues)); } - + public void simulateAfterParse() { simulateAfterReceiveParseNotification = false; - ArrayList validGUIProperties, simulatableGUIProperties; + ArrayList validGUIProperties, simulatableGUIProperties; UndefinedConstants uCon; - try - { - parsedProperties = getPrism().parsePropertiesString(parsedModel, getLabelsString()+"\n"+getConstantsString()+"\n"+propList.getValidSelectedString()); + try { + parsedProperties = getPrism().parsePropertiesString(parsedModel, + getLabelsString() + "\n" + getConstantsString() + "\n" + propList.getValidSelectedString()); validGUIProperties = propList.getValidSelectedProperties(); if (validGUIProperties.size() == 0) { error("None of the selected properties are suitable for simulation"); return; } - } - catch(PrismException e) - { + } catch (PrismException e) { error(e.getMessage()); return; } - + // See which of the selected properties are ok for simulation - simulatableGUIProperties = new ArrayList(); - for(int i = 0; i < validGUIProperties.size(); i++) - { - GUIProperty guiP = (GUIProperty)validGUIProperties.get(i); - try - { + simulatableGUIProperties = new ArrayList(); + for (int i = 0; i < validGUIProperties.size(); i++) { + GUIProperty guiP = validGUIProperties.get(i); + try { getPrism().checkPropertyForSimulation(guiP.getProperty()); simulatableGUIProperties.add(guiP); - } - catch(PrismException e) - { + } catch (PrismException e) { // do nothing } } @@ -285,145 +277,128 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List } if (simulatableGUIProperties.size() < validGUIProperties.size()) { int q = questionYesNo("Warning", "Warning: Some of the selected properties are not suitable for simulation. Continue?"); - if (q != 0) return; + if (q != 0) + return; } - + //find out any undefined constants - try - { + try { uCon = new UndefinedConstants(parsedModel, parsedProperties); - if(uCon.getMFNumUndefined() + uCon.getPFNumUndefined() > 0) - { + if (uCon.getMFNumUndefined() + uCon.getPFNumUndefined() > 0) { int result = GUIConstantsPicker.defineConstantsWithDialog(this.getGUI(), uCon, lastSimulateValues, lastPFConstants); - if(result != GUIConstantsPicker.VALUES_DONE) + if (result != GUIConstantsPicker.VALUES_DONE) return; } - + lastSimulateValues = uCon.getMFConstantValues(); lastPFConstants = uCon.getPFConstantValues(); parsedModel.setUndefinedConstants(lastSimulateValues); parsedProperties.setUndefinedConstants(lastPFConstants); - + SimulationInformation info = GUISimulationPicker.defineSimulationWithDialog(this.getGUI(), parsedModel.getInitialValues(), parsedModel); - if(info == null) return; + if (info == null) + return; Values initialState = info.getInitialState(); - + int noIterations = info.getNoIterations(); int maxPathLength = info.getMaxPathLength(); - - if(parsedModel != null && parsedProperties != null && validGUIProperties != null) - { - if(info.isDistributed()) - { - new GUISimulatorDistributionDialog(getGUI(), getPrism().getSimulator(), true).show(this, parsedModel, parsedProperties, validGUIProperties, info); - } - else - { - Thread t = new SimulateModelCheckThread(this, parsedModel, parsedProperties, validGUIProperties, lastSimulateValues, lastPFConstants, initialState, noIterations, maxPathLength, info); + + if (parsedModel != null && parsedProperties != null && validGUIProperties != null) { + if (info.isDistributed()) { + new GUISimulatorDistributionDialog(getGUI(), getPrism().getSimulator(), true).show(this, parsedModel, parsedProperties, validGUIProperties, + info); + } else { + Thread t = new SimulateModelCheckThread(this, parsedModel, parsedProperties, validGUIProperties, lastSimulateValues, lastPFConstants, + initialState, noIterations, maxPathLength, info); t.setPriority(Thread.NORM_PRIORITY); t.start(); } } - } - catch(PrismException e) - { + } catch (PrismException e) { error(e.getMessage()); return; } } - + public void experimentAfterParse() { experimentAfterReceiveParseNotification = false; GUIProperty gp = propList.getProperty(propList.getSelectedIndex()); Type type; - - try - { + + try { // parse property to be used for experiment - parsedProperties = getPrism().parsePropertiesString(parsedModel, getLabelsString()+"\n"+getConstantsString()+"\n"+gp.getPropString()); - if (parsedProperties.getNumProperties() <= 0) - { + parsedProperties = getPrism().parsePropertiesString(parsedModel, getLabelsString() + "\n" + getConstantsString() + "\n" + gp.getPropString()); + if (parsedProperties.getNumProperties() <= 0) { error("There are no properties selected"); return; } - if (parsedProperties.getNumProperties() > 1) - { + if (parsedProperties.getNumProperties() > 1) { error("Experiments can only be created for a single property"); return; } - + // check the type of the property type = parsedProperties.getProperty(0).getType(); - } - catch(PrismException e) - { + } catch (PrismException e) { error(e.getMessage()); return; } - + // sort out undefined constants UndefinedConstants uCon = new UndefinedConstants(parsedModel, parsedProperties); boolean showGraphDialog = false; boolean useSimulation = false; - if(uCon.getMFNumUndefined()+uCon.getPFNumUndefined() == 0) - { + if (uCon.getMFNumUndefined() + uCon.getPFNumUndefined() == 0) { error("Cannot create an experiment because there are no constants with undefined values"); return; } - int result = GUIExperimentPicker.defineConstantsWithDialog(this.getGUI(), uCon, type instanceof TypeInt || type instanceof TypeDouble, gp.isValidForSimulation()); - if(result == GUIExperimentPicker.VALUES_DONE_SHOW_GRAPH || result == GUIExperimentPicker.VALUES_DONE_SHOW_GRAPH_AND_SIMULATE) - { + int result = GUIExperimentPicker.defineConstantsWithDialog(this.getGUI(), uCon, type instanceof TypeInt || type instanceof TypeDouble, gp + .isValidForSimulation()); + if (result == GUIExperimentPicker.VALUES_DONE_SHOW_GRAPH || result == GUIExperimentPicker.VALUES_DONE_SHOW_GRAPH_AND_SIMULATE) { showGraphDialog = true; - } - else if(result == GUIExperimentPicker.CANCELLED) return; - if(result == GUIExperimentPicker.VALUES_DONE_SIMULATE || result == GUIExperimentPicker.VALUES_DONE_SHOW_GRAPH_AND_SIMULATE) - { + } else if (result == GUIExperimentPicker.CANCELLED) + return; + if (result == GUIExperimentPicker.VALUES_DONE_SIMULATE || result == GUIExperimentPicker.VALUES_DONE_SHOW_GRAPH_AND_SIMULATE) { useSimulation = true; } - + //if we are using simulation, make sure the property is ok - if(useSimulation) - { - try - { + if (useSimulation) { + try { getPrism().checkPropertyForSimulation(gp.getProperty()); - } - catch(PrismException e) - { + } catch (PrismException e) { error("Property is not suitable for simulation: " + e.getMessage()); return; } } - + // make sure we can actually create a graph, i.e. that there is >1 result - if (showGraphDialog) if (uCon.getRangingConstants().size() == 0) - { - message("Cannot create a graph since there is only a single result."); - showGraphDialog = false; - } - + if (showGraphDialog) + if (uCon.getRangingConstants().size() == 0) { + message("Cannot create a graph since there is only a single result."); + showGraphDialog = false; + } + // Use these values to create a new experiment int i = experiments.newExperiment(parsedProperties, uCon, parsedModel, useSimulation); boolean notCancelled = true; // start the experiment, via the graph dialog if appropriate - if(showGraphDialog) - { + if (showGraphDialog) { GUIGraphPicker ggp = new GUIGraphPicker(getGUI(), this, experiments.getExperiment(i), graphHandler, false); - - if (ggp.isGraphCancelled()) - { + + if (ggp.isGraphCancelled()) { if (questionYesNo("Do you want to cancel the experiment completely?", 0) == 0) notCancelled = false; } - } - + } + if (notCancelled) experiments.startExperiment(i); //else // experiments.removeExperiment(i); } - + public void propertyLoadSuccessful(PropertiesFile pf, File f) { // note: add constants/labels first to stop property parse errors @@ -438,7 +413,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List setActiveFile(f); notifyEventListeners(new GUIPropertiesEvent(GUIPropertiesEvent.PROPERTIES_LIST_CHANGED)); } - + public void propertyInsertSuccessful(PropertiesFile pf) { propList.addPropertiesFile(pf); @@ -447,30 +422,25 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List tabToFront(); setModified(true); } - + public void propertySaveSuccessful(File f) { setActiveFile(f); setModified(false); } - + public void changeProperty(String pctl, String comment, String id) { int index = propList.getIndexOf(id); - if(index < 0) - { - if(pctl!=null) - { + if (index < 0) { + if (pctl != null) { propList.addProperty(pctl, comment); setModified(true); } - } - else - { + } else { GUIProperty gp = propList.getProperty(index); gp.setBeingEdited(false); - if(pctl != null) - { + if (pctl != null) { gp.setPropString(pctl, parsedModel, getConstantsString(), getLabelsString()); gp.setComment(comment); setModified(true); @@ -481,36 +451,35 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List selectionChangeHandler.notifyListeners(new GUIEvent(1)); updateCommentLabel(); } - + public void cancelProperty(String id) { int index = propList.getIndexOf(id); - if(index >= 0) - { + if (index >= 0) { GUIProperty gp = propList.getProperty(index); gp.setBeingEdited(false); // Force repaint because we modified the GUIProperty directly repaintList(); } } - + /** Called by the constant list to let us know something changed there */ - + public void constantListChanged() { labTable.validateLabels(); propList.validateProperties(); setModified(true); } - + /** Called by the label list to let us know something changed there */ - + public void labelListChanged() { propList.validateProperties(); setModified(true); } - + protected void setModified(boolean mod) { modified = mod; @@ -520,25 +489,25 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List notifyEventListeners(new GUIPropertiesEvent(GUIPropertiesEvent.PROPERTIES_LIST_CHANGED)); } } - + protected void setComputing(boolean com) { computing = com; doEnables(); selectionChangeHandler.notifyListeners(new GUIEvent(1)); } - + protected void setActiveFile(File f) { activeFile = f; setActiveFileLabel(); } - + protected void setActiveFileLabel() { - fileLabel.setText("Properties list: " + ((activeFile == null)?"":activeFile.getPath()) + (modified?"*":"")); + fileLabel.setText("Properties list: " + ((activeFile == null) ? "" : activeFile.getPath()) + (modified ? "*" : "")); } - + protected void setParsedModel(ModulesFile m) { parsedModel = m; @@ -546,36 +515,36 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List propList.validateProperties(); doEnables(); } - + protected void setBuiltModel(Model m) { builtModel = m; doEnables(); } - + protected void doEnables() { // properties panel setEnabled(true); setTabEnabled(true); // properties menu - newProps.setEnabled (!computing); - openProps.setEnabled (!computing); - insertProps.setEnabled (!computing); - saveProps.setEnabled (!computing); - savePropsAs.setEnabled (!computing); - simulate.setEnabled (!computing && parsedModel != null && propList.getValidSimulatableSelectedProperties().size() > 0); - verifySelected.setEnabled (!computing && parsedModel != null && propList.getValidSelectedProperties().size() > 0); - details.setEnabled (!computing && parsedModel != null && propList.getValidSelectedProperties().size() > 0); + newProps.setEnabled(!computing); + openProps.setEnabled(!computing); + insertProps.setEnabled(!computing); + saveProps.setEnabled(!computing); + savePropsAs.setEnabled(!computing); + simulate.setEnabled(!computing && parsedModel != null && propList.existsValidSimulatableSelectedProperties()); + verifySelected.setEnabled(!computing && parsedModel != null && propList.existsValidSelectedProperties()); + details.setEnabled(!computing && parsedModel != null && propList.existsValidSelectedProperties()); // properties list - propList.setEnabled (!computing); - newProperty.setEnabled (!computing); - editProperty.setEnabled (!computing && propList.getSelectedProperties().size() > 0); + propList.setEnabled(!computing); + newProperty.setEnabled(!computing); + editProperty.setEnabled(!computing && propList.getSelectedProperties().size() > 0); // constants list removeConstant.setEnabled(consTable.getSelectedRowCount() > 0); // label list removeLabel.setEnabled(labTable.getSelectedRowCount() > 0); - + // newExperiment: enabled if there is exactly one prop selected and it is valid newExperiment.setEnabled(propList.getNumSelectedProperties() == 1 && propList.getValidSelectedProperties().size() == 1); // deleteExperiments: enabled if one or more experiments selected @@ -583,77 +552,75 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List // viewResults: enabled if at least one experiment is selected viewResults.setEnabled(experiments.getSelectedRowCount() > 0); // plotResults: enabled if exactly one experiment is selected and its type is int/double - if (experiments.getSelectedRowCount() == 1) - { + if (experiments.getSelectedRowCount() == 1) { GUIExperiment exp = experiments.getExperiment(experiments.getSelectedRow()); Type type = exp.getPropertyType(); plotResults.setEnabled(type instanceof TypeInt || type instanceof TypeDouble); - } - else - { + } else { plotResults.setEnabled(false); } // exportResults: enabled if at least one experiment is selected exportResults.setEnabled(experiments.getSelectedRowCount() > 0); } - + public int doModificationCheck() { - if(modified) - { - if(activeFile == null) - { - String[] selection = - {"Yes", "No", "Cancel"}; + if (modified) { + if (activeFile == null) { + String[] selection = { "Yes", "No", "Cancel" }; int selectionNo = -1; - selectionNo = optionPane("Properties list has been modified.\nDo you wish to save it?", "Question", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, selection, selection[0]); - switch(selectionNo) - { - case 0: return a_save(); - case 1: return CONTINUE; - case 2: return CANCEL; - default: return CANCEL; + selectionNo = optionPane("Properties list has been modified.\nDo you wish to save it?", "Question", JOptionPane.OK_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE, selection, selection[0]); + switch (selectionNo) { + case 0: + return a_save(); + case 1: + return CONTINUE; + case 2: + return CANCEL; + default: + return CANCEL; } - } - else - { - String[] selection = - {"Yes", "No", "Save As...", "Cancel"}; + } else { + String[] selection = { "Yes", "No", "Save As...", "Cancel" }; int selectionNo = -1; - selectionNo = optionPane("Properties list has been modified.\nDo you wish to save it?", "Question", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, selection, selection[0]); - switch(selectionNo) - { - case 0: return a_save(); - case 1: return CONTINUE; - case 2: return a_saveAs(); - case 3: return CANCEL; - default: return CANCEL; + selectionNo = optionPane("Properties list has been modified.\nDo you wish to save it?", "Question", JOptionPane.OK_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE, selection, selection[0]); + switch (selectionNo) { + case 0: + return a_save(); + case 1: + return CONTINUE; + case 2: + return a_saveAs(); + case 3: + return CANCEL; + default: + return CANCEL; } } } return CONTINUE; } - + private void updateCommentLabel() { ArrayList selectedProps = propList.getSelectedProperties(); - if(selectedProps.size() == 1) - { - GUIProperty p = (GUIProperty)selectedProps.get(0); + if (selectedProps.size() == 1) { + GUIProperty p = (GUIProperty) selectedProps.get(0); comLabel.setText(p.getComment()); - } - else - { + } else { comLabel.setText(""); } } - + //ACTION METHODS - + public void a_newList() { - if (doModificationCheck() != CONTINUE) return; - + if (doModificationCheck() != CONTINUE) + return; + propList.deleteAll(); consTable.newList(); labTable.newList(); @@ -663,16 +630,15 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List doEnables(); notifyEventListeners(new GUIPropertiesEvent(GUIPropertiesEvent.PROPERTIES_LIST_CHANGED)); } - + public void a_open() { - if (doModificationCheck() != CONTINUE) return; - - if (showOpenFileDialog(propsFilter, propsFilter[0]) == JFileChooser.APPROVE_OPTION) - { + if (doModificationCheck() != CONTINUE) + return; + + if (showOpenFileDialog(propsFilter, propsFilter[0]) == JFileChooser.APPROVE_OPTION) { File file = getChooserFile(); - if (file == null) - { + if (file == null) { error("No file selected"); return; } @@ -681,39 +647,30 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List t.start(); } } - + // Save properties // NB: This used to be in a thread but I have taken it out because: // (a) We sometimes need to know whether save was successful before continuing // (b) When saving before clearing, clear can occur too early - + public int a_save() { - if(activeFile == null) - { + if (activeFile == null) { return a_saveAs(); - } - else - { + } else { // only allow save if all props valid (can't reopen file otherwise) - if (propList.getNumProperties() != propList.getNumValidProperties()) - { + if (!propList.allPropertiesAreValid()) { message("Cannot save properties list: some properties are invalid"); return CANCEL; - } - else - { + } else { // do save - try - { + try { setTaskBarText("Saving properties..."); PrintWriter out = new PrintWriter(new FileWriter(activeFile)); out.print(propList.toFileString(activeFile, consTable, labTable)); out.flush(); out.close(); - } - catch(IOException e) - { + } catch (IOException e) { setTaskBarText("Saving properties... error."); error("Could not save to file \"" + activeFile + "\""); return CANCEL; @@ -724,39 +681,33 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List } } } - + // Save properties as // NB: This used to be in a thread but I have taken it out because: // (a) We sometimes need to know whether save was successful before continuing // (b) When saving before clearing, clear can occur too early - + public int a_saveAs() { // only allow save if all props valid (can't reopen file otherwise) - if (propList.getNumProperties() != propList.getNumValidProperties()) - { + if (!propList.allPropertiesAreValid()) { message("Cannot save properties list: some properties are invalid"); return CANCEL; } - if (!consTable.isConstantListValid()) - { + if (!consTable.isConstantListValid()) { message("Cannot save properties list: some constants are invalid"); return CANCEL; } - if (showSaveFileDialog(propsFilter, propsFilter[0]) == JFileChooser.APPROVE_OPTION) - { + if (showSaveFileDialog(propsFilter, propsFilter[0]) == JFileChooser.APPROVE_OPTION) { File file = getChooserFile(); // do save - try - { + try { setTaskBarText("Saving properties..."); PrintWriter out = new PrintWriter(new FileWriter(file)); out.print(propList.toFileString(file, consTable, labTable)); out.flush(); out.close(); - } - catch(IOException e) - { + } catch (IOException e) { setTaskBarText("Saving properties... error."); error("Could not save to file \"" + file + "\""); return CANCEL; @@ -767,36 +718,30 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List } return CANCEL; } - + public void a_insert() { - if (showOpenFileDialog(propsFilter, propsFilter[0]) == JFileChooser.APPROVE_OPTION) - { + if (showOpenFileDialog(propsFilter, propsFilter[0]) == JFileChooser.APPROVE_OPTION) { File file = getChooserFile(); - if (file == null) - { + if (file == null) { error("No file selected"); return; } Thread t = new LoadPropertiesThread(this, parsedModel, file, true); t.setPriority(Thread.NORM_PRIORITY); t.start(); - } - else - { + } else { return; } } - + public void a_simulateSelected() { consTable.correctEditors(); labTable.correctEditors(); // Bail out if there are no valid properties to simulate - // (probably never occurs- action is disabled in this case) - ArrayList guiPropsTmp = propList.getValidSimulatableSelectedProperties(); - if(guiPropsTmp.size() == 0) - { + // (probably never occurs - action is disabled in this case) + if (!propList.existsValidSimulatableSelectedProperties()) { error("None of the selected properties are suitable for simulation"); return; } @@ -804,17 +749,14 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List simulateAfterReceiveParseNotification = true; notifyEventListeners(new GUIPropertiesEvent(GUIPropertiesEvent.REQUEST_MODEL_PARSE)); } - - + public void a_detailSelected() { int[] selected = propList.getSelectedIndices(); - - for(int i = 0; i < selected.length; i++) - { + + for (int i = 0; i < selected.length; i++) { GUIProperty gp = propList.getProperty(selected[i]); - if(!gp.isBeingEdited()) - { + if (!gp.isBeingEdited()) { gp.setBeingEdited(true); // Force repaint because we modified the GUIProperty directly repaintList(); @@ -822,16 +764,14 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List } } } - + public void a_verifySelected() { consTable.correctEditors(); labTable.correctEditors(); // Bail out if there are no valid properties to verify - // (probably never occurs- action is disabled in this case) - ArrayList guiPropsTmp = propList.getValidSelectedProperties(); - if(guiPropsTmp.size() == 0) - { + // (probably never occurs - action is disabled in this case) + if (!propList.existsValidSelectedProperties()) { error("None of the selected properties are suitable for verification. The model was not built"); return; } @@ -839,7 +779,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List verifyAfterReceiveParseNotification = true; notifyEventListeners(new GUIPropertiesEvent(GUIPropertiesEvent.REQUEST_MODEL_PARSE)); } - + public void a_cut() { java.awt.datatransfer.Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); @@ -848,79 +788,70 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List clipboard.setContents(new GUIClipboardProperties(propList.getSelectedProperties()), null); a_delete(); } - + public void a_copy() { java.awt.datatransfer.Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); //java.awt.datatransfer.StringSelection selection = new java.awt.datatransfer.StringSelection(propList.getClipboardString()); //clipboard.setContents(selection, null); - clipboard.setContents(new GUIClipboardProperties(propList.getSelectedProperties()), null); + clipboard.setContents(new GUIClipboardProperties(propList.getSelectedProperties()), null); } - + public void a_paste() { Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable contents = clipboard.getContents(null); - - if(contents !=null) - { - if (contents.isDataFlavorSupported(getGUIClipboardPropertiesDataFlavor())) - { - try - { - GUIClipboardProperties gcp = (GUIClipboardProperties)contents.getTransferData(getGUIClipboardPropertiesDataFlavor()); + + if (contents != null) { + if (contents.isDataFlavorSupported(getGUIClipboardPropertiesDataFlavor())) { + try { + GUIClipboardProperties gcp = (GUIClipboardProperties) contents.getTransferData(getGUIClipboardPropertiesDataFlavor()); ArrayList listOfProperties = gcp.getProperties(); - for (int i = 0; i < listOfProperties.size(); i++) - { + for (int i = 0; i < listOfProperties.size(); i++) { GUIProperty property = (GUIProperty) listOfProperties.get(i); propList.addProperty(property.getPropString(), property.getComment()); setModified(true); } + } catch (UnsupportedFlavorException e) { + } catch (IOException e) { } - catch(UnsupportedFlavorException e) {} - catch(IOException e) {} - } - else - { - try - { - String text = (String)contents.getTransferData(java.awt.datatransfer.DataFlavor.stringFlavor); + } else { + try { + String text = (String) contents.getTransferData(java.awt.datatransfer.DataFlavor.stringFlavor); propList.pastePropertiesString(text); setModified(true); + } catch (UnsupportedFlavorException e) { + } catch (IOException e) { } - catch(UnsupportedFlavorException e) {} - catch(IOException e) {} } } } - + public void a_delete() { propList.deleteSelected(); setModified(true); } - + public void a_deleteAll() { propList.deleteAll(); setModified(true); } - + public void a_newProperty() { GUIPropertyEditor ed = new GUIPropertyEditor(this, parsedModel, getInvalidPropertyStrategy()); ed.show(); } - + public void a_editProperty() { int[] selected = propList.getSelectedIndices(); - - for(int i = 0; i < selected.length; i++) - { + + for (int i = 0; i < selected.length; i++) { GUIProperty gp = propList.getProperty(selected[i]); - if(!gp.isBeingEdited()) - { + if (!gp.isBeingEdited()) { gp.setBeingEdited(true); // Force repaint because we modified the GUIProperty directly repaintList(); @@ -928,279 +859,244 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List ed.show(); } } - - selectionChangeHandler.notifyListeners(new GUIEvent(1)); + + selectionChangeHandler.notifyListeners(new GUIEvent(1)); } - + public void a_selectAll() { propList.selectAll(); } - + public void a_addConstant() { consTable.addNewConstant(); } - + public void a_removeSelectedConstants() { // Note: Unlike for prop list, this is safe because constants can always be deleted // (not the case properties - e.g. if they are being edited) - while(consTable.getSelectedRowCount() > 0) - { + while (consTable.getSelectedRowCount() > 0) { consTable.removeConstant(consTable.getSelectedRow());//for now } } - + public void a_addLabel() { labTable.addNewLabel(); } - + public void a_removeSelectedLabels() { // Note: Unlike for prop list, this is safe because constants can always be deleted // (not the case properties - e.g. if they are being edited) - while(labTable.getSelectedRowCount() > 0) - { + while (labTable.getSelectedRowCount() > 0) { labTable.removeLabel(labTable.getSelectedRow()); } } - + public void a_newExperiment() { experimentAfterReceiveParseNotification = true; notifyEventListeners(new GUIPropertiesEvent(GUIPropertiesEvent.REQUEST_MODEL_PARSE)); } - + public void a_stopExperiment() { experiments.stop(); } - + public void a_deleteExperiment() { experiments.deleteSelected(); } - + public void a_viewResults() { GUIExperiment exp; int i, n, inds[]; - + // get selected experiments n = experiments.getSelectedRowCount(); - if (n < 1) return; + if (n < 1) + return; inds = experiments.getSelectedRows(); // show results dialog for reach one - for (i = 0 ; i < n; i++) { + for (i = 0; i < n; i++) { exp = experiments.getExperiment(inds[i]); new GUIResultsTable(this.getGUI(), this, exp).show(); } } - + public void a_plotResults() { GUIExperiment exp; Type type; - + // get experiment - if (experiments.getSelectedRowCount() != 1) return; + if (experiments.getSelectedRowCount() != 1) + return; exp = experiments.getExperiment(experiments.getSelectedRow()); // check its type type = exp.getPropertyType(); - if (!(type instanceof TypeInt || type instanceof TypeDouble)) - { + if (!(type instanceof TypeInt || type instanceof TypeDouble)) { message("Can only plot results if the property is of type int or double"); return; } // make sure we can actually create a graph, i.e. that there is >1 result - if (exp.getRangingConstants().size() == 0) - { + if (exp.getRangingConstants().size() == 0) { message("Cannot create a graph since there is only a single result."); return; } - + // launch dialog, plot series (modal) - GUIGraphPicker ggp = new GUIGraphPicker(getGUI(), this, exp, graphHandler, true); - - + GUIGraphPicker ggp = new GUIGraphPicker(getGUI(), this, exp, graphHandler, true); + } - + public void a_exportResults() { GUIExperiment exps[]; int i, n, inds[]; - + // get selected experiments n = experiments.getSelectedRowCount(); - if (n < 1) return; + if (n < 1) + return; exps = new GUIExperiment[n]; inds = experiments.getSelectedRows(); - for (i = 0 ; i < n; i++) exps[i] = experiments.getExperiment(inds[i]); + for (i = 0; i < n; i++) + exps[i] = experiments.getExperiment(inds[i]); // get filename to save - if (showSaveFileDialog(textFilter, textFilter[0]) == JFileChooser.APPROVE_OPTION) - { + if (showSaveFileDialog(textFilter, textFilter[0]) == JFileChooser.APPROVE_OPTION) { File file = getChooserFile(); Thread t = new ExportResultsThread(this, exps, file); t.setPriority(Thread.NORM_PRIORITY); t.start(); } } - + //METHODS TO IMPLEMENT GUIPlugin INTERFACE - + public boolean displaysTab() { return true; } - + public JMenu getMenu() { return propMenu; } - + public OptionsPanel getOptions() { return null; } - + public String getTabText() { return "Properties"; } - + public JToolBar getToolBar() { return null; } - + public String getXMLIDTag() { return ""; } - + public Object getXMLSaveTree() { return null; } - + public void loadXML(Object c) { } - + // if return value is true, event should not be passed on to any more listeners - + public boolean processGUIEvent(GUIEvent e) { - if(e instanceof GUIModelEvent) - { - GUIModelEvent me = (GUIModelEvent)e; - if(me.getID() == me.NEW_MODEL) - { + if (e instanceof GUIModelEvent) { + GUIModelEvent me = (GUIModelEvent) e; + if (me.getID() == me.NEW_MODEL) { //New Model setBuiltModel(null); setParsedModel(null); //newList(); - } - else if(me.getID() == GUIModelEvent.MODEL_BUILT) - { + } else if (me.getID() == GUIModelEvent.MODEL_BUILT) { setBuiltModel(me.getModel()); - if(me.getBuildValues() != null)lastBuildValues = me.getBuildValues(); + if (me.getBuildValues() != null) + lastBuildValues = me.getBuildValues(); modifiedSinceBuild = false; - if(verifyAfterReceiveBuildNotification)verifyAfterBuild(); - } - else if(me.getID() == GUIModelEvent.MODEL_PARSED) - { + if (verifyAfterReceiveBuildNotification) + verifyAfterBuild(); + } else if (me.getID() == GUIModelEvent.MODEL_PARSED) { setParsedModel(me.getModulesFile()); - if(verifyAfterReceiveParseNotification)verifyAfterParse(); - if(experimentAfterReceiveParseNotification)experimentAfterParse(); - if(simulateAfterReceiveParseNotification)simulateAfterParse(); - } - else if(me.getID() == GUIModelEvent.MODEL_PARSE_FAILED) - { + if (verifyAfterReceiveParseNotification) + verifyAfterParse(); + if (experimentAfterReceiveParseNotification) + experimentAfterParse(); + if (simulateAfterReceiveParseNotification) + simulateAfterParse(); + } else if (me.getID() == GUIModelEvent.MODEL_PARSE_FAILED) { verifyAfterReceiveParseNotification = false; experimentAfterReceiveParseNotification = false; simulateAfterReceiveParseNotification = false; - } - else if(me.getID() == GUIModelEvent.MODEL_BUILD_FAILED) - { + } else if (me.getID() == GUIModelEvent.MODEL_BUILD_FAILED) { verifyAfterReceiveBuildNotification = false; - } - else if(me.getID() == GUIModelEvent.MODIFIED_SINCE_SAVE) - { + } else if (me.getID() == GUIModelEvent.MODIFIED_SINCE_SAVE) { //setBuiltModel(null); modifiedSinceBuild = true; - } - else if(me.getID() == GUIModelEvent.NEW_LOAD_NOT_RELOAD_MODEL) - { - if (getPrism().getSettings().getBoolean(PrismSettings.PROPERTIES_CLEAR_LIST_ON_LOAD)) - { + } else if (me.getID() == GUIModelEvent.NEW_LOAD_NOT_RELOAD_MODEL) { + if (getPrism().getSettings().getBoolean(PrismSettings.PROPERTIES_CLEAR_LIST_ON_LOAD)) { a_newList(); } } - } - else if(e instanceof GUIComputationEvent) - { - if(e.getID() == GUIComputationEvent.COMPUTATION_START) - { + } else if (e instanceof GUIComputationEvent) { + if (e.getID() == GUIComputationEvent.COMPUTATION_START) { setComputing(true); - } - else if(e.getID() == GUIComputationEvent.COMPUTATION_DONE) - { + } else if (e.getID() == GUIComputationEvent.COMPUTATION_DONE) { setComputing(false); - } - else if(e.getID() == GUIComputationEvent.COMPUTATION_ERROR) - { + } else if (e.getID() == GUIComputationEvent.COMPUTATION_ERROR) { setComputing(false); } - } - else if(e instanceof GUIClipboardEvent && super.getGUI().getFocussedPlugin() == this) - { - GUIClipboardEvent ce = (GUIClipboardEvent)e; - - if(ce.getComponent() == this || ce.getComponent() == propList) - { - if(!computing) - { - if(ce.getID() == ce.CUT) - {a_cut();} - else if(ce.getID() == ce.COPY) - {a_copy();} - else if(ce.getID() == ce.PASTE) - {a_paste();} - else if(ce.getID() == ce.DELETE) - {a_delete();} - else if(ce.getID() == ce.SELECT_ALL) - {a_selectAll();} + } else if (e instanceof GUIClipboardEvent && super.getGUI().getFocussedPlugin() == this) { + GUIClipboardEvent ce = (GUIClipboardEvent) e; + + if (ce.getComponent() == this || ce.getComponent() == propList) { + if (!computing) { + if (ce.getID() == ce.CUT) { + a_cut(); + } else if (ce.getID() == ce.COPY) { + a_copy(); + } else if (ce.getID() == ce.PASTE) { + a_paste(); + } else if (ce.getID() == ce.DELETE) { + a_delete(); + } else if (ce.getID() == ce.SELECT_ALL) { + a_selectAll(); + } } + } else { } - else - { - } - } - else if(e instanceof GUIPropertiesEvent) - { - GUIPropertiesEvent pr = (GUIPropertiesEvent)e; - if(pr.getID() == GUIPropertiesEvent.EXPERIMENT_START) - { + } else if (e instanceof GUIPropertiesEvent) { + GUIPropertiesEvent pr = (GUIPropertiesEvent) e; + if (pr.getID() == GUIPropertiesEvent.EXPERIMENT_START) { stopExperiment.setEnabled(true); - } - else if(pr.getID() == GUIPropertiesEvent.EXPERIMENT_END) - { + } else if (pr.getID() == GUIPropertiesEvent.EXPERIMENT_END) { stopExperiment.setEnabled(false); - } - else if(pr.getID() == GUIPropertiesEvent.VERIFY_END) - { + } else if (pr.getID() == GUIPropertiesEvent.VERIFY_END) { a_detailSelected(); } - } - else if (e instanceof GUIExitEvent) - { - if(e.getID() == GUIExitEvent.REQUEST_EXIT) - { - if (doModificationCheck() != CONTINUE) - { + } else if (e instanceof GUIExitEvent) { + if (e.getID() == GUIExitEvent.REQUEST_EXIT) { + if (doModificationCheck() != CONTINUE) { notifyEventListeners(new GUIExitEvent(GUIExitEvent.CANCEL_EXIT)); return true; } @@ -1208,23 +1104,19 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List } return false; } - + //METHODS TO IMPLEMENT MouseListner INTERFACE - + public void mouseClicked(MouseEvent e) { removeConstant.setEnabled(consTable.getSelectedRowCount() > 0); removeLabel.setEnabled(labTable.getSelectedRowCount() > 0); - if(!computing) - { - if(e.getClickCount() >= 2) - { - if(e.getSource() == propList) - { + if (!computing) { + if (e.getClickCount() >= 2) { + if (e.getSource() == propList) { int index = propList.locationToIndex(e.getPoint()); - - if(index != -1) - { + + if (index != -1) { propList.setSelectedIndex(index); } a_editProperty(); @@ -1232,139 +1124,112 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List } } } - + public void mouseEntered(MouseEvent e) { removeConstant.setEnabled(consTable.getSelectedRowCount() > 0); removeLabel.setEnabled(labTable.getSelectedRowCount() > 0); } - + public void mouseExited(MouseEvent e) { removeConstant.setEnabled(consTable.getSelectedRowCount() > 0); removeLabel.setEnabled(labTable.getSelectedRowCount() > 0); } - + public void mousePressed(MouseEvent e) { removeConstant.setEnabled(consTable.getSelectedRowCount() > 0); removeLabel.setEnabled(labTable.getSelectedRowCount() > 0); - if(!computing) - { - if(e.isPopupTrigger() && e.getSource() == propList) - { + if (!computing) { + if (e.isPopupTrigger() && e.getSource() == propList) { int index = propList.locationToIndex(e.getPoint()); // if there are no properties selected, select the one under the popup - if(propList.isSelectionEmpty()) - { - if(index != -1) - { + if (propList.isSelectionEmpty()) { + if (index != -1) { propList.setSelectedIndex(index); } - } - else - { + } else { // if the property under the popup is not already selected, select just that one int[] sel = propList.getSelectedIndices(); boolean valid = false; - for(int i = 0; i < sel.length; i++) - { - if(sel[i] == index) - { + for (int i = 0; i < sel.length; i++) { + if (sel[i] == index) { valid = true; break; } } - if(!valid) - { + if (!valid) { propList.setSelectedIndex(index); } } - + // disable certain actions if any of the selected propeties are currently being edited int[] sel = propList.getSelectedIndices(); boolean showDeleters = true; - for(int i = 0; i < sel.length; i++) - { - if(propList.getProperty(sel[i]).isBeingEdited()) - { + for (int i = 0; i < sel.length; i++) { + if (propList.getProperty(sel[i]).isBeingEdited()) { showDeleters = false; break; } - } - - verifySelected.setEnabled(propList.getValidSelectedProperties().size() > 0); - simulate.setEnabled(propList.getValidSimulatableSelectedProperties().size() > 0); - details.setEnabled(propList.getValidSelectedProperties().size() > 0); + } + + verifySelected.setEnabled(propList.existsValidSelectedProperties()); + simulate.setEnabled(propList.existsValidSimulatableSelectedProperties()); + details.setEnabled(propList.existsValidSelectedProperties()); editProperty.setEnabled(propList.getSelectedProperties().size() > 0); - + newExperiment.setEnabled(propList.getNumSelectedProperties() == 1 && propList.getValidSelectedProperties().size() == 1); - - if(showDeleters == false) - { + + if (showDeleters == false) { simulate.setEnabled(false); verifySelected.setEnabled(false); details.setEnabled(false); editProperty.setEnabled(false); newExperiment.setEnabled(false); } - + propertiesPopup.show(e.getComponent(), e.getX(), e.getY()); - } - else if(e.isPopupTrigger() && (e.getSource() == consTable || e.getSource() == constantsScroll)) - { - constantsPopup.show(e.getComponent(), e.getX(), e.getY()); - } - else if(e.isPopupTrigger() && ( e.getSource() == labTable || e.getSource() == labelsScroll)) - { + } else if (e.isPopupTrigger() && (e.getSource() == consTable || e.getSource() == constantsScroll)) { + constantsPopup.show(e.getComponent(), e.getX(), e.getY()); + } else if (e.isPopupTrigger() && (e.getSource() == labTable || e.getSource() == labelsScroll)) { labelsPopup.show(e.getComponent(), e.getX(), e.getY()); - } - else if(e.isPopupTrigger() && ( e.getSource() == experiments || e.getSource() == expScroller)) - { + } else if (e.isPopupTrigger() && (e.getSource() == experiments || e.getSource() == expScroller)) { doEnables(); this.experimentPopup.show(e.getComponent(), e.getX(), e.getY()); } - } + } } - + @Override - public boolean canDoClipBoardAction(Action action) + public boolean canDoClipBoardAction(Action action) { if (computing) return false; - + // disable certain actions if any of the selected propeties are currently being edited int[] sel = propList.getSelectedIndices(); boolean showDeleters = true; - for(int i = 0; i < sel.length; i++) - { - if(propList.getProperty(sel[i]).isBeingEdited()) - { + for (int i = 0; i < sel.length; i++) { + if (propList.getProperty(sel[i]).isBeingEdited()) { showDeleters = false; break; } - } - - if (action == GUIPrism.getClipboardPlugin().getPasteAction()) - { + } + + if (action == GUIPrism.getClipboardPlugin().getPasteAction()) { Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); return (clipboard.getContents(null) != null); - } - else if (action == GUIPrism.getClipboardPlugin().getCutAction() || - action == GUIPrism.getClipboardPlugin().getDeleteAction()) - { - if (!showDeleters) return false; + } else if (action == GUIPrism.getClipboardPlugin().getCutAction() || action == GUIPrism.getClipboardPlugin().getDeleteAction()) { + if (!showDeleters) + return false; return (propList.getSelectedProperties().size() > 0); - } - else if (action == GUIPrism.getClipboardPlugin().getCopyAction()) - { + } else if (action == GUIPrism.getClipboardPlugin().getCopyAction()) { return (propList.getSelectedProperties().size() > 0); - } - else if (action == GUIPrism.getClipboardPlugin().getSelectAllAction()) - { + } else if (action == GUIPrism.getClipboardPlugin().getSelectAllAction()) { return true; } - + return false; } @@ -1372,136 +1237,117 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List { removeConstant.setEnabled(consTable.getSelectedRowCount() > 0); removeLabel.setEnabled(labTable.getSelectedRowCount() > 0); - if(!computing) - { - if(e.isPopupTrigger() && e.getSource() == propList) - { + if (!computing) { + if (e.isPopupTrigger() && e.getSource() == propList) { int index = propList.locationToIndex(e.getPoint()); // if there are no properties selected, select the one under the popup - if(propList.isSelectionEmpty()) - { - if(index != -1) - { + if (propList.isSelectionEmpty()) { + if (index != -1) { propList.setSelectedIndex(index); } - } - else - { + } else { // if the property under the popup is not already selected, select just that one int[] sel = propList.getSelectedIndices(); boolean valid = false; - for(int i = 0; i < sel.length; i++) - { - if(sel[i] == index) - { + for (int i = 0; i < sel.length; i++) { + if (sel[i] == index) { valid = true; break; } } - if(!valid) - { + if (!valid) { propList.setSelectedIndex(index); } } // disable certain actions if any of the selected propeties are currently being edited int[] sel = propList.getSelectedIndices(); boolean showDeleters = true; - for(int i = 0; i < sel.length; i++) - { - if(propList.getProperty(sel[i]).isBeingEdited()) - { + for (int i = 0; i < sel.length; i++) { + if (propList.getProperty(sel[i]).isBeingEdited()) { showDeleters = false; break; } } - verifySelected.setEnabled(propList.getValidSelectedProperties().size() > 0); - simulate.setEnabled(propList.getValidSimulatableSelectedProperties().size() > 0); - details.setEnabled(propList.getValidSelectedProperties().size() > 0); + verifySelected.setEnabled(propList.existsValidSelectedProperties()); + simulate.setEnabled(propList.existsValidSimulatableSelectedProperties()); + details.setEnabled(propList.existsValidSelectedProperties()); editProperty.setEnabled(propList.getSelectedProperties().size() > 0); newExperiment.setEnabled(propList.getNumSelectedProperties() == 1 && propList.getValidSelectedProperties().size() == 1); - - if(showDeleters == false) - { + + if (showDeleters == false) { simulate.setEnabled(false); verifySelected.setEnabled(false); details.setEnabled(false); editProperty.setEnabled(false); newExperiment.setEnabled(false); } - + propertiesPopup.show(e.getComponent(), e.getX(), e.getY()); - } - else if(e.isPopupTrigger() && (e.getSource() == consTable || e.getSource() == constantsScroll)) - { + } else if (e.isPopupTrigger() && (e.getSource() == consTable || e.getSource() == constantsScroll)) { constantsPopup.show(e.getComponent(), e.getX(), e.getY()); - - } - else if(e.isPopupTrigger() && ( e.getSource() == labTable || e.getSource() == labelsScroll)) - { + + } else if (e.isPopupTrigger() && (e.getSource() == labTable || e.getSource() == labelsScroll)) { labelsPopup.show(e.getComponent(), e.getX(), e.getY()); - } - else if(e.isPopupTrigger() && ( e.getSource() == experiments || e.getSource() == expScroller)) - { + } else if (e.isPopupTrigger() && (e.getSource() == experiments || e.getSource() == expScroller)) { doEnables(); this.experimentPopup.show(e.getComponent(), e.getX(), e.getY()); } } } - - public void componentAdded(ContainerEvent e) + + public void componentAdded(ContainerEvent e) { // notify GUIClipboard - selectionChangeHandler.notifyListeners(new GUIEvent(1)); + selectionChangeHandler.notifyListeners(new GUIEvent(1)); } - public void componentRemoved(ContainerEvent e) { + public void componentRemoved(ContainerEvent e) + { // notify GUIClipboard - selectionChangeHandler.notifyListeners(new GUIEvent(1)); + selectionChangeHandler.notifyListeners(new GUIEvent(1)); } //METHODS TO IMPLEMENT ListSelectionListener INTERFACE public void valueChanged(ListSelectionEvent e) { - ArrayList selectedProps = propList.getSelectedProperties(); - - // disable certain actions if any of the selected propeties are currently being edited + ArrayList selectedProps = propList.getSelectedProperties(); + + // disable certain actions if any of the selected properties are currently being edited boolean showDeleters = true; - for(int i = 0; i < selectedProps.size(); i++) - { - if(((GUIProperty)selectedProps.get(i)).isBeingEdited()) - { + for (int i = 0; i < selectedProps.size(); i++) { + if (((GUIProperty) selectedProps.get(i)).isBeingEdited()) { showDeleters = false; break; } } - - verifySelected.setEnabled(propList.getValidSelectedProperties().size() > 0); - simulate.setEnabled(propList.getValidSimulatableSelectedProperties().size() > 0); - details.setEnabled(propList.getValidSelectedProperties().size() > 0); + + verifySelected.setEnabled(propList.existsValidSelectedProperties()); + simulate.setEnabled(propList.existsValidSimulatableSelectedProperties()); + details.setEnabled(propList.existsValidSelectedProperties()); editProperty.setEnabled(propList.getSelectedProperties().size() > 0); - - if(showDeleters == false) - { + + if (showDeleters == false) { simulate.setEnabled(false); verifySelected.setEnabled(false); details.setEnabled(false); editProperty.setEnabled(false); } - + updateCommentLabel(); - + //Now do the one for the constants table - + removeConstant.setEnabled(consTable.getSelectedRowCount() > 0); removeLabel.setEnabled(labTable.getSelectedRowCount() > 0); - + // notify GUIClipboard selectionChangeHandler.notifyListeners(new GUIEvent(1)); } - + //CONSTRUCTOR HELPER METHODS JScrollPane constantsScroll, labelsScroll; JTextArea comLabel; + private void initComponents() { setupActions(); @@ -1510,7 +1356,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List { JPanel left = new JPanel(); { - left.setMinimumSize(new java.awt.Dimension(10,10)); + left.setMinimumSize(new java.awt.Dimension(10, 10)); JSplitPane leftSc = new JSplitPane(); { JPanel topLeft = new JPanel(); @@ -1569,7 +1415,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List leftSc.setDividerLocation(0.5); leftSc.setDividerSize(5); leftSc.setResizeWeight(0.5); - + } left.setLayout(new BorderLayout()); left.add(leftSc, BorderLayout.CENTER); @@ -1585,7 +1431,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List JButton b = new JButton(stopExperiment); b.setToolTipText("Stop Current Experiment"); stopTool.add(b); - + stopTool.setFloatable(false); } expScroller = new JScrollPane(); @@ -1599,12 +1445,12 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List topRight.add(stopTool, BorderLayout.NORTH); topRight.add(expScroller, BorderLayout.CENTER); } - JPanel bottomRight = new JPanel(new GridLayout(1,1)); + JPanel bottomRight = new JPanel(new GridLayout(1, 1)); { graphHandler = new GUIGraphHandler(this.getGUI(), this, true); bottomRight.add(graphHandler); - - bottomRight.setPreferredSize(new Dimension(300,300)); + + bottomRight.setPreferredSize(new Dimension(300, 300)); //graphHandler.addGraph(); //graphHandler.addGraph(); } @@ -1615,19 +1461,19 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List rightSplit.setDividerSize(5); rightSplit.setResizeWeight(0.5); } - + right.setLayout(new BorderLayout()); right.setBorder(new TitledBorder("Experiments")); right.add(rightSplit, BorderLayout.CENTER); } - + mainSplit.setLeftComponent(left); mainSplit.setRightComponent(right); mainSplit.setDividerLocation(0.5); mainSplit.setOneTouchExpandable(true); mainSplit.setResizeWeight(0.5); } - + JPanel topPanel = new JPanel(); { fileLabel = new JLabel(); @@ -1636,11 +1482,11 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List fileLabel.setBorder(new javax.swing.border.EtchedBorder()); fileLabel.setMinimumSize(new java.awt.Dimension(40, 25)); } - + //progress = new JProgressBar(0, 100); topPanel.setLayout(new BorderLayout()); //topPanel.add(progress, BorderLayout.WEST); - topPanel.add(fileLabel,BorderLayout.CENTER); + topPanel.add(fileLabel, BorderLayout.CENTER); } setLayout(new BorderLayout()); add(mainSplit, BorderLayout.CENTER); @@ -1672,12 +1518,12 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List textFilter[0] = new GUIPrismFileFilter("Plain text files (*.txt)"); textFilter[0].addExtension("txt"); } - + private void createPopups() { propertiesPopup = new JPopupMenu(); - - propertiesPopup.add(editProperty); + + propertiesPopup.add(editProperty); propertiesPopup.add(newProperty); propertiesPopup.add(new JSeparator()); propertiesPopup.add(verifySelected); @@ -1692,33 +1538,33 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List propertiesPopup.add(GUIPrism.getClipboardPlugin().getDeleteAction()); propertiesPopup.add(new JSeparator()); propertiesPopup.add(GUIPrism.getClipboardPlugin().getSelectAllAction()); - + constantsPopup = new JPopupMenu(); - + constantsPopup.add(newConstant); constantsPopup.add(removeConstant); - + labelsPopup = new JPopupMenu(); labelsPopup.add(newLabel); labelsPopup.add(removeLabel); - + consTable.addMouseListener(this); propList.addMouseListener(this); - + experimentPopup = new JPopupMenu(); - + experimentPopup.add(newExperiment); experimentPopup.add(deleteExperiment); experimentPopup.add(new JSeparator()); experimentPopup.add(viewResults); experimentPopup.add(plotResults); experimentPopup.add(exportResults); - + } - + private void setupActions() { - + newProps = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1732,7 +1578,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List newProps.putValue(Action.NAME, "New properties list"); newProps.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallNew.png")); newProps.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK)); - + openProps = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1746,7 +1592,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List openProps.putValue(Action.NAME, "Open properties list..."); openProps.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallOpen.png")); openProps.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK)); - + saveProps = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1754,13 +1600,14 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List a_save(); } }; - saveProps.putValue(Action.LONG_DESCRIPTION, "Saves all properties to the current active properties list, if non exists the user is prompted with a dialog."); + saveProps.putValue(Action.LONG_DESCRIPTION, + "Saves all properties to the current active properties list, if non exists the user is prompted with a dialog."); // saveProps.putValue(Action.SHORT_DESCRIPTION, "Save properties list"); saveProps.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_S)); saveProps.putValue(Action.NAME, "Save properties list"); saveProps.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallSave.png")); saveProps.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK)); - + savePropsAs = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1773,7 +1620,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List savePropsAs.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_A)); savePropsAs.putValue(Action.NAME, "Save properties list as..."); savePropsAs.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallSaveAs.png")); - + insertProps = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1781,12 +1628,13 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List a_insert(); } }; - insertProps.putValue(Action.LONG_DESCRIPTION, "Inserts properties from user selected file into the properties list. The active property file remains the same however."); + insertProps.putValue(Action.LONG_DESCRIPTION, + "Inserts properties from user selected file into the properties list. The active property file remains the same however."); //insertProps.putValue(Action.SHORT_DESCRIPTION, "Insert properties list"); insertProps.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_I)); insertProps.putValue(Action.NAME, "Insert properties list..."); insertProps.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallAdd.png")); - + simulate = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1799,7 +1647,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List simulate.putValue(Action.NAME, "Simulate"); simulate.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallSimulate.png")); simulate.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0)); - + details = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1811,7 +1659,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List details.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D)); details.putValue(Action.NAME, "Show details"); details.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallDetails.png")); - + verifySelected = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1819,13 +1667,16 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List a_verifySelected(); } }; - verifySelected.putValue(Action.LONG_DESCRIPTION, "Model checks the selected properties against the model that is built. If there is no built model, the parsed model is automatically built. If the parsed model has changed since the last build, the user is prompted as to whether they wish to re-build the model. If the model text has been modified since the last build, the user is asked whether they want to re-parse and re-build."); + verifySelected + .putValue( + Action.LONG_DESCRIPTION, + "Model checks the selected properties against the model that is built. If there is no built model, the parsed model is automatically built. If the parsed model has changed since the last build, the user is prompted as to whether they wish to re-build the model. If the model text has been modified since the last build, the user is asked whether they want to re-parse and re-build."); //verifySelected.putValue(Action.SHORT_DESCRIPTION, "Verify Selected Properties"); verifySelected.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_V)); verifySelected.putValue(Action.NAME, "Verify"); verifySelected.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallTick.png")); verifySelected.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)); - + newProperty = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1837,7 +1688,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List newProperty.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D)); newProperty.putValue(Action.NAME, "Add"); newProperty.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallAdd.png")); - + editProperty = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1849,7 +1700,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List editProperty.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_E)); editProperty.putValue(Action.NAME, "Edit"); editProperty.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallEdit.png")); - + newConstant = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1861,7 +1712,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List newConstant.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D)); newConstant.putValue(Action.NAME, "Add constant"); newConstant.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallAdd.png")); - + removeConstant = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1873,8 +1724,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List removeConstant.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D)); removeConstant.putValue(Action.NAME, "Delete constant"); removeConstant.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallDelete.png")); - - + newLabel = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1886,7 +1736,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List newLabel.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D)); newLabel.putValue(Action.NAME, "Add label"); newLabel.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallAdd.png")); - + removeLabel = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1898,8 +1748,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List removeLabel.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D)); removeLabel.putValue(Action.NAME, "Delete label"); removeLabel.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallDelete.png")); - - + newExperiment = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1912,7 +1761,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List newExperiment.putValue(Action.NAME, "New experiment"); newExperiment.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallExperiment.png")); newExperiment.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0)); - + deleteExperiment = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1924,7 +1773,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List deleteExperiment.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D)); deleteExperiment.putValue(Action.NAME, "Delete experiment"); deleteExperiment.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallDelete.png")); - + viewResults = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1936,7 +1785,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List viewResults.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_V)); viewResults.putValue(Action.NAME, "View results"); viewResults.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallView.png")); - + plotResults = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1948,7 +1797,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List plotResults.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P)); plotResults.putValue(Action.NAME, "Plot results"); plotResults.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileGraph.png")); - + exportResults = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1960,7 +1809,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List exportResults.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_E)); exportResults.putValue(Action.NAME, "Export results"); exportResults.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallExport.png")); - + stopExperiment = new AbstractAction() { public void actionPerformed(ActionEvent e) @@ -1971,9 +1820,9 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List stopExperiment.putValue(Action.LONG_DESCRIPTION, "Stops the Experiment that is currently running"); stopExperiment.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallStop.png")); stopExperiment.setEnabled(false); - + } - + /** * Getter for property propList. * @return Value of property propList. @@ -1982,9 +1831,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List { return propList; } - - - + /** * Getter for property consTable. * @return Value of property consTable. @@ -1993,9 +1840,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List { return consTable; } - - - + /** * Getter for property labTable. * @return Value of property labTable. @@ -2004,7 +1849,7 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List { return labTable; } - + public void notifySettings(PrismSettings settings) { displayFontFast = settings.getFontColorPair(PrismSettings.PROPERTIES_FONT).f; @@ -2013,12 +1858,12 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List warningFast = settings.getColor(PrismSettings.PROPERTIES_WARNING_COLOUR); repaint(); } - + public static DataFlavor getGUIClipboardPropertiesDataFlavor() { return new DataFlavor(GUIClipboardProperties.class, "PRISM Property List"); } - + /** * A class that allows sets of properties to be put on the clipboard. */ @@ -2026,54 +1871,55 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List { private ArrayList listOfProperties; private StringSelection stringRepresentation; - + public GUIClipboardProperties(ArrayList listOfProperties) { this.listOfProperties = listOfProperties; String tmpString = ""; - for(int i = 0 ; i < listOfProperties.size(); i++) - { - GUIProperty gp = (GUIProperty)listOfProperties.get(i); - if (gp.getComment().trim().length() > 0) - { + for (int i = 0; i < listOfProperties.size(); i++) { + GUIProperty gp = (GUIProperty) listOfProperties.get(i); + if (gp.getComment().trim().length() > 0) { tmpString += "//" + gp.getComment() + "\n"; } tmpString += gp.getPropString(); - if(i != listOfProperties.size() -1 ) tmpString += "\n"; - } - + if (i != listOfProperties.size() - 1) + tmpString += "\n"; + } + stringRepresentation = new StringSelection(tmpString); - } - + } + public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { - if (flavor.getRepresentationClass() == this.getClass()) - { return this; } - else - { return this.stringRepresentation.getTransferData(flavor); } + if (flavor.getRepresentationClass() == this.getClass()) { + return this; + } else { + return this.stringRepresentation.getTransferData(flavor); + } } - + public DataFlavor[] getTransferDataFlavors() - { + { DataFlavor[] stringFlavors = stringRepresentation.getTransferDataFlavors(); - + DataFlavor[] allFlavors = new DataFlavor[stringFlavors.length + 1]; allFlavors[0] = GUIMultiProperties.getGUIClipboardPropertiesDataFlavor(); - - for (int i = 0; i < stringFlavors.length; i++) - { allFlavors[i+1] = stringFlavors[i]; } - + + for (int i = 0; i < stringFlavors.length; i++) { + allFlavors[i + 1] = stringFlavors[i]; + } + return allFlavors; } - - public boolean isDataFlavorSupported(DataFlavor flavor) + + public boolean isDataFlavorSupported(DataFlavor flavor) { - return (stringRepresentation.isDataFlavorSupported(flavor) || flavor.equals(GUIMultiProperties.getGUIClipboardPropertiesDataFlavor())); - } - + return (stringRepresentation.isDataFlavorSupported(flavor) || flavor.equals(GUIMultiProperties.getGUIClipboardPropertiesDataFlavor())); + } + public ArrayList getProperties() { return listOfProperties; - } + } } } diff --git a/prism/src/userinterface/properties/GUIPropertiesList.java b/prism/src/userinterface/properties/GUIPropertiesList.java index 00bbdd49..d0220896 100644 --- a/prism/src/userinterface/properties/GUIPropertiesList.java +++ b/prism/src/userinterface/properties/GUIPropertiesList.java @@ -44,224 +44,264 @@ import prism.*; public class GUIPropertiesList extends JList implements KeyListener { //STATICS - + private static int counter = 0; - + //ATTRIBUTES - + private Prism prism; private GUIMultiProperties parent; - + private DefaultListModel listModel; - + private PictureCellRenderer rend; - + //CONSTRUCTORS - + /** Creates a new instance of GUIPropertiesList */ public GUIPropertiesList(Prism prism, GUIMultiProperties parent) { this.prism = prism; this.parent = parent; - + listModel = new DefaultListModel(); setModel(listModel); - + rend = new PictureCellRenderer(); setCellRenderer(rend); - + addKeyListener(this); setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - + getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK), "none"); } - + /** Override set font to update row heights at same time */ public void setFont(Font font) { super.setFont(font); // Note: minimum of 20 since icons are 16x16 - if (font != null) setFixedCellHeight(Math.max(20, getFontMetrics(font).getHeight() + 4)); + if (font != null) + setFixedCellHeight(Math.max(20, getFontMetrics(font).getHeight() + 4)); } //ACCESS METHODS - + public int getNumProperties() { return listModel.size(); } - - public GUIProperty getProperty(int index) + + /** + * Get the ith property in the list. + */ + public GUIProperty getProperty(int i) { - return (GUIProperty)listModel.getElementAt(index); + return (GUIProperty) listModel.getElementAt(i); } - - public int getNumValidProperties() + + /** + * Check that all properties in the list are valid. + */ + public boolean allPropertiesAreValid() { - int total = 0; - for(int i = 0; i < getNumProperties(); i++) - { - GUIProperty gp = getProperty(i); - if(gp.isValid()) total++; + for (int i = 0; i < getNumProperties(); i++) { + if (!getProperty(i).isValid()) + return false; } - return total; + return true; } - + + /** + * Get the number of properties currently selected in the list. + */ public int getNumSelectedProperties() { return getSelectedIndices().length; } - - public ArrayList getSelectedProperties() + + /** + * Get a list of the properties currently selected in the list. + */ + public ArrayList getSelectedProperties() { + ArrayList gps = new ArrayList(); int[] ind = getSelectedIndices(); - ArrayList ps = new ArrayList(); - for(int i = 0; i < ind.length; i++) - ps.add(getProperty(ind[i])); - return ps; + for (int i = 0; i < ind.length; i++) { + gps.add(getProperty(ind[i])); + } + return gps; } - - public ArrayList getValidSelectedProperties() + + /** + * Check if there are any valid properties currently selected in the list. + */ + public boolean existsValidSelectedProperties() { - ArrayList gps = new ArrayList(); - ArrayList prs = getSelectedProperties(); - for(int i = 0; i < prs.size(); i++) - { - GUIProperty gp = (GUIProperty)prs.get(i); - if(gp.isValid()) - { - gps.add(gp); + if (parent.getParsedModel() == null) + return false; + int[] ind = getSelectedIndices(); + for (int i = 0; i < ind.length; i++) { + if (getProperty(ind[i]).isValid()) { + return true; } } - return gps; + return false; } - - public ArrayList getValidSimulatableSelectedProperties() + + /** + * Get a list of the valid properties currently selected in the list. + */ + public ArrayList getValidSelectedProperties() { - ArrayList gps = new ArrayList(); - if(parent.getParsedModel() == null) return gps; - ArrayList prs = getSelectedProperties(); - for(int i = 0; i < prs.size(); i++) - { - GUIProperty gp = (GUIProperty)prs.get(i); - if(gp.isValidForSimulation()) - { + ArrayList gps = new ArrayList(); + if (parent.getParsedModel() == null) + return gps; + int[] ind = getSelectedIndices(); + for (int i = 0; i < ind.length; i++) { + GUIProperty gp = getProperty(ind[i]); + if (gp.isValid()) { gps.add(gp); } - } - + } return gps; } - + + /** + * Get a string comprising concatenation of all valid properties currently selected in the list. + */ public String getValidSelectedString() { String str = ""; - ArrayList prs = getValidSelectedProperties(); - for(int i = 0; i < prs.size(); i++) - { - str += ((GUIProperty)prs.get(i)).getPropString()+"\n"; + ArrayList gps = getValidSelectedProperties(); + for (GUIProperty gp : gps) { + str += gp.getPropString() + "\n"; } return str; } - + + /** + * Check if there are any valid and simulate-able properties currently selected in the list. + */ + public boolean existsValidSimulatableSelectedProperties() + { + if (parent.getParsedModel() == null) + return false; + int[] ind = getSelectedIndices(); + for (int i = 0; i < ind.length; i++) { + if (getProperty(ind[i]).isValidForSimulation()) { + return true; + } + } + return false; + } + + /** + * Get a list of the valid and simulate-able properties currently selected in the list. + */ + public ArrayList getValidSimulatableSelectedProperties() + { + ArrayList gps = new ArrayList(); + if (parent.getParsedModel() == null) + return gps; + int[] ind = getSelectedIndices(); + for (int i = 0; i < ind.length; i++) { + GUIProperty gp = getProperty(ind[i]); + if (gp.isValidForSimulation()) { + gps.add(gp); + } + } + return gps; + } + public int getIndexOf(String id) { int index = -1; - for(int i = 0; i < getNumProperties(); i++) - { + for (int i = 0; i < getNumProperties(); i++) { String str = getProperty(i).getID(); - if(id.equals(str)) - { + if (id.equals(str)) { index = i; break; } } return index; } - + //Used for cut and copy public String getClipboardString() { - int[]ind = getSelectedIndices(); + int[] ind = getSelectedIndices(); String str = ""; - for(int i = 0 ; i < ind.length; i++) - { + for (int i = 0; i < ind.length; i++) { GUIProperty gp = getProperty(i); - str+=gp.getPropString(); - if(i != ind.length-1) str+="\n"; + str += gp.getPropString(); + if (i != ind.length - 1) + str += "\n"; } return str; } - + /* UPDATE METHODS */ - + public void addProperty(String propString, String comment) { counter++; - GUIProperty gp = new GUIProperty(prism, "PROPERTY"+counter, propString, comment); + GUIProperty gp = new GUIProperty(prism, "PROPERTY" + counter, propString, comment); gp.parse(parent.getParsedModel(), parent.getConstantsString(), parent.getLabelsString()); listModel.addElement(gp); } - - + public void setProperty(int index, String propString, String comment) { counter++; - GUIProperty gp = new GUIProperty(prism, "PROPERTY"+counter, propString, comment); + GUIProperty gp = new GUIProperty(prism, "PROPERTY" + counter, propString, comment); gp.parse(parent.getParsedModel(), parent.getConstantsString(), parent.getLabelsString()); listModel.setElementAt(gp, index); } - + /** Used for pasting */ public void pastePropertiesString(String str) { StringTokenizer sto = new StringTokenizer(str, "\n"); - while(sto.hasMoreTokens()) - { + while (sto.hasMoreTokens()) { String token = sto.nextToken(); - + // Make sure it isn't comment we are pasting if (token.indexOf("//") != 0) addProperty(token, ""); } } - + public void addPropertiesFile(PropertiesFile pf) { - for(int i = 0; i < pf.getNumProperties(); i++) - { + for (int i = 0; i < pf.getNumProperties(); i++) { String str = pf.getProperty(i).toString(); String com = pf.getPropertyComment(i); addProperty(str, com); } } - + public boolean deleteProperty(int index) { GUIProperty gp = getProperty(index); - if(!gp.isBeingEdited()) - { + if (!gp.isBeingEdited()) { listModel.removeElementAt(index); return true; - } - else return false; + } else + return false; } - + public void deleteSelected() { - while(!isSelectionEmpty()) - { + while (!isSelectionEmpty()) { boolean deleted = deleteProperty(getSelectedIndex()); - if(!deleted) - { + if (!deleted) { //if not deleted, unselect, so the rest can!! - int[]ind = getSelectedIndices(); - int[]newInd = new int[ind.length-1]; + int[] ind = getSelectedIndices(); + int[] newInd = new int[ind.length - 1]; int c = 0; - for(int i = 0; i < ind.length; i++) - { - if(ind[i] != getSelectedIndex()) - { + for (int i = 0; i < ind.length; i++) { + if (ind[i] != getSelectedIndex()) { newInd[c] = ind[i]; c++; } @@ -270,43 +310,41 @@ public class GUIPropertiesList extends JList implements KeyListener } } } - + public void deleteAll() { selectAll(); deleteSelected(); } - + public void selectAll() { - if(getNumProperties() > 0) - { - setSelectionInterval(0, getNumProperties()-1); + if (getNumProperties() > 0) { + setSelectionInterval(0, getNumProperties() - 1); } } - + /** Validate all the properties in the list NB: Don't call it "validate()" to avoid overwriting Swing methods */ - + public void validateProperties() { - for(int i = 0; i < getNumProperties(); i++) - { + for (int i = 0; i < getNumProperties(); i++) { GUIProperty p = getProperty(i); p.parse(parent.getParsedModel(), parent.getConstantsString(), parent.getLabelsString()); } // Force repaint because we modified a GUIProperty directly repaint(); } - + // convert to string which can be written to a file - + public String toFileString(File f, GUIPropConstantList consList, GUIPropLabelList labList) { int numProp; - String s, s2[]; - int i, j; - + String s; + int i; + s = ""; if (consList.getNumConstants() > 0) { s += consList.getConstantsString() + "\n"; @@ -315,135 +353,116 @@ public class GUIPropertiesList extends JList implements KeyListener s += labList.getLabelsString() + "\n"; } numProp = getNumProperties(); - for(i = 0; i < numProp; i++) - { + for (i = 0; i < numProp; i++) { GUIProperty gp = getProperty(i); - if (gp.getComment().length()>0) + if (gp.getComment().length() > 0) s += PrismParser.slashCommentBlock(gp.getComment()); s += gp.getPropString() + "\n\n"; } - + return s; } - + //REQUIRED TO IMPLEMENT KEYLISTENER - + public void keyPressed(KeyEvent e) { - if(e.getModifiers() == KeyEvent.CTRL_MASK) - { - if(e.getKeyCode() == KeyEvent.VK_C) - { - parent.a_copy(); - } - else if(e.getKeyCode() == KeyEvent.VK_V) - { - parent.a_paste(); - } - else if(e.getKeyCode() == KeyEvent.VK_X) - { - parent.a_cut(); - } - else if(e.getKeyCode() == KeyEvent.VK_D) - { - parent.a_delete(); - } - else if(e.getKeyCode() == KeyEvent.VK_A) - { + if (e.getModifiers() == KeyEvent.CTRL_MASK) { + if (e.getKeyCode() == KeyEvent.VK_C) { + parent.a_copy(); + } else if (e.getKeyCode() == KeyEvent.VK_V) { + parent.a_paste(); + } else if (e.getKeyCode() == KeyEvent.VK_X) { + parent.a_cut(); + } else if (e.getKeyCode() == KeyEvent.VK_D) { + parent.a_delete(); + } else if (e.getKeyCode() == KeyEvent.VK_A) { parent.a_selectAll(); - } + } } - if(e.getKeyCode() == KeyEvent.VK_DELETE) - { - parent.a_delete(); + if (e.getKeyCode() == KeyEvent.VK_DELETE) { + parent.a_delete(); } } - + public void keyReleased(KeyEvent e) { } - + public void keyTyped(KeyEvent e) { } - + //RENDERERS - + class PictureCellRenderer extends JLabel implements ListCellRenderer { String toolTip; - + public PictureCellRenderer() { toolTip = ""; setOpaque(true); } - + public String getToolTipText() { return toolTip; } - + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { setBorder(new BottomBorder()); GUIProperty p = getProperty(index); - + // tooltip toolTip = p.getToolTipText(); - + // text setText(p.getPropString()); - + // icon setIcon(p.getImage()); - + // foreground/background colours - if(isSelected) - { + if (isSelected) { setBackground(parent.getSelectionColor()); setForeground(p.isValid() ? Color.black : Color.red); - } - else - { - if(!p.isValid()) - { + } else { + if (!p.isValid()) { setBackground(parent.getWarningColor()); setForeground(Color.red); - } - else - { + } else { setBackground(Color.white); setForeground(Color.black); } } - - if(p.isBeingEdited()) - { + + if (p.isBeingEdited()) { setBackground(Color.lightGray); } - + return this; } } - + class BottomBorder implements javax.swing.border.Border { public Insets getBorderInsets(Component c) { - return new Insets(0,0,0,0); + return new Insets(0, 0, 0, 0); } - + public boolean isBorderOpaque() { return true; } - + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { g.setColor(Color.lightGray); - g.drawLine(x,(y+height-1), (x+width), (y+height-1)); - + g.drawLine(x, (y + height - 1), (x + width), (y + height - 1)); + } } } diff --git a/prism/src/userinterface/properties/GUIProperty.java b/prism/src/userinterface/properties/GUIProperty.java index ec31b18f..04f71380 100644 --- a/prism/src/userinterface/properties/GUIProperty.java +++ b/prism/src/userinterface/properties/GUIProperty.java @@ -27,20 +27,21 @@ //============================================================================== package userinterface.properties; + +import javax.swing.*; + import userinterface.GUIPrism; import parser.*; import parser.ast.*; import prism.*; -import javax.swing.*; /** - * - * @author ug60axh + * Encapsulates a property in the list in the GUI "Properties" tab. */ public class GUIProperty { //Constants - + /** A property state constant image */ public static final ImageIcon IMAGE_NOT_DONE = GUIPrism.getIconFromImage("smallFilePrism.png"); /** A property state constant image */ @@ -55,7 +56,7 @@ public class GUIProperty public static final ImageIcon IMAGE_INVALID = GUIPrism.getIconFromImage("smallWarning.png"); /** A property state constant image */ public static final ImageIcon IMAGE_NUMBER = GUIPrism.getIconFromImage("smallCompute.png"); - + /** Property status */ public static final int STATUS_NOT_DONE = 0; /** Property status */ @@ -70,284 +71,284 @@ public class GUIProperty public static final int STATUS_RESULT_FALSE = 5; /** Property status */ public static final int STATUS_RESULT_NUMBER = 6; - - + //ATTRIBUTES - - private Prism prism; // Required for parsing - - private String id; // Unique ID - private int status; // Status - see constants above - private ImageIcon doingImage; // Image when in DOING state - can be modified externally for animations - private boolean beingEdited; // Is this property currently being edited? - - private String propString; // String representing the property - private Expression expr; // The parsed property - private String comment; // The property's comment - - private Result result; // Result of model checking etc. (if done, null if not) - private String parseError; // Parse error (if property is invalid) - - private String method; // Method used (verification, simulation) - private String constantsString; // Constant values used - + + private Prism prism; // Required for parsing + + private String id; // Unique ID + private int status; // Status - see constants above + private ImageIcon doingImage; // Image when in DOING state - can be modified externally for animations + private boolean beingEdited; // Is this property currently being edited? + + private String propString; // String representing the property + private Expression expr; // The parsed property (null if invalid) + private String comment; // The property's comment + + private Result result; // Result of model checking etc. (if done, null if not) + private String parseError; // Parse error (if property is invalid) + + private String method; // Method used (verification, simulation) + private String constantsString; // Constant values used + /** Creates a new instance of GUIProperty */ public GUIProperty(Prism prism, String id, String propString, String comment) { this.prism = prism; - + this.id = id; status = STATUS_NOT_DONE; doingImage = IMAGE_DOING; beingEdited = false; - + this.propString = propString; expr = null; this.comment = comment; - + result = null; parseError = ""; method = ""; constantsString = ""; } - + //ACCESS METHODS - + public String getID() { return id; } - + public int getStatus() { return status; } - + public ImageIcon getImage() { switch (status) { - case STATUS_NOT_DONE: return IMAGE_NOT_DONE; - case STATUS_DOING: return doingImage; - case STATUS_PARSE_ERROR: return IMAGE_INVALID; - case STATUS_RESULT_ERROR: return IMAGE_ERROR; - case STATUS_RESULT_TRUE: return IMAGE_TICK; - case STATUS_RESULT_FALSE: return IMAGE_CROSS; - case STATUS_RESULT_NUMBER: return IMAGE_NUMBER; - default: return IMAGE_NOT_DONE; + case STATUS_NOT_DONE: + return IMAGE_NOT_DONE; + case STATUS_DOING: + return doingImage; + case STATUS_PARSE_ERROR: + return IMAGE_INVALID; + case STATUS_RESULT_ERROR: + return IMAGE_ERROR; + case STATUS_RESULT_TRUE: + return IMAGE_TICK; + case STATUS_RESULT_FALSE: + return IMAGE_CROSS; + case STATUS_RESULT_NUMBER: + return IMAGE_NUMBER; + default: + return IMAGE_NOT_DONE; } } - + public boolean isBeingEdited() { return beingEdited; } - + public String getPropString() { return propString; } - + public Expression getProperty() { return expr; } - + public String getComment() { return comment; } - + + /** + * Is this property valid? i.e. Did it parse OK last time it was parsed? + */ public boolean isValid() { return expr != null; } - + // just a basic check - see if it's a P=? or R=? property - + + /** + * Is this property both valid (i.e. parsed OK last time it was checked) + * and suitable approximate verification through simulation? + */ public boolean isValidForSimulation() { boolean b = isValid() && (expr instanceof ExpressionProb || expr instanceof ExpressionReward); - if(b) - { - if(expr instanceof ExpressionProb) - { - if ((((ExpressionProb)expr).getProb() != null)) - { + if (b) { + if (expr instanceof ExpressionProb) { + if ((((ExpressionProb) expr).getProb() != null)) { return false; } - } - else if(expr instanceof ExpressionReward) - { - if ((((ExpressionReward)expr).getReward() != null)) - { + } else if (expr instanceof ExpressionReward) { + if ((((ExpressionReward) expr).getReward() != null)) { return false; } } return true; - } - else return false; + } else + return false; } - + public Result getResult() { return result; } - + public String getResultString() { return result == null ? "Unknown" : result.getResultString(); } - + public String getToolTipText() { switch (status) { - case STATUS_DOING: return "In progress..."; - case STATUS_PARSE_ERROR: return "Invalid property: " + parseError; - case STATUS_RESULT_ERROR: return getResultString(); - default: return "Result: " + getResultString(); + case STATUS_DOING: + return "In progress..."; + case STATUS_PARSE_ERROR: + return "Invalid property: " + parseError; + case STATUS_RESULT_ERROR: + return getResultString(); + default: + return "Result: " + getResultString(); } } - + public String getConstantsString() { return constantsString; } - + public String getMethodString() { return method; } - + public String toString() { return propString; } - + //UPDATE METHODS - + public void setStatus(int status) { this.status = status; } - + public void setDoingImage(ImageIcon image) { doingImage = image; } - + public void setPropString(String propString, ModulesFile m, String constantsString, String labelString) { this.propString = propString; setStatus(STATUS_NOT_DONE); parse(m, constantsString, labelString); } - + public void setComment(String comment) { this.comment = comment; } - + public void setBeingEdited(boolean beingEdited) { this.beingEdited = beingEdited; } - + public void setResult(Result res) { result = res; - if (result.getResult() instanceof Boolean) - { - if (((Boolean)result.getResult()).booleanValue()) { + if (result.getResult() instanceof Boolean) { + if (((Boolean) result.getResult()).booleanValue()) { setStatus(STATUS_RESULT_TRUE); } else { setStatus(STATUS_RESULT_FALSE); } - } - else if (result.getResult() instanceof Double) - { + } else if (result.getResult() instanceof Double) { setStatus(STATUS_RESULT_NUMBER); - } - else if (result.getResult() instanceof Exception) - { + } else if (result.getResult() instanceof Exception) { setStatus(STATUS_RESULT_ERROR); - } - else - { + } else { setStatus(STATUS_NOT_DONE); result = null; } } - + public void setMethodString(String method) { this.method = (method == null) ? "" : method; } - + public void setConstants(Values mfConstants, Values pfConstants) { if (mfConstants != null && mfConstants.getNumValues() > 0) { constantsString = mfConstants.toString(); if (pfConstants != null && pfConstants.getNumValues() > 0) constantsString += ", " + pfConstants.toString(); - } - else if (pfConstants != null && pfConstants.getNumValues() > 0) { + } else if (pfConstants != null && pfConstants.getNumValues() > 0) { constantsString = pfConstants.toString(); - } - else { + } else { constantsString = ""; } } - + public void parse(ModulesFile m, String constantsString, String labelString) { - if(propString == null || constantsString == null || labelString == null) - { + if (propString == null || constantsString == null || labelString == null) { expr = null; setStatus(STATUS_PARSE_ERROR); parseError = "(Unexpected) Properties, constants or labels are null"; return; } - try - { + try { //Parse constants and labels boolean couldBeNoConstantsOrLabels = false; PropertiesFile fConLab = null; - try - { - fConLab = prism.parsePropertiesString(m, constantsString+"\n"+labelString); - } - catch(PrismException e) - { + try { + fConLab = prism.parsePropertiesString(m, constantsString + "\n" + labelString); + } catch (PrismException e) { couldBeNoConstantsOrLabels = true; } //Parse all together - String withConsLabs = constantsString+"\n"+labelString+"\n"+propString; + String withConsLabs = constantsString + "\n" + labelString + "\n" + propString; PropertiesFile ff = prism.parsePropertiesString(m, withConsLabs); - + //Validation of number of properties - if(ff.getNumProperties() == 0) throw new PrismException("Empty Property"); - else if(ff.getNumProperties() > 1) throw new PrismException("Contains Multiple Properties"); - + if (ff.getNumProperties() == 0) + throw new PrismException("Empty Property"); + else if (ff.getNumProperties() > 1) + throw new PrismException("Contains Multiple Properties"); + //Validation of constants and labels - if(!couldBeNoConstantsOrLabels) - { - if(ff.getConstantList().size() != fConLab.getConstantList().size()) throw new PrismException("Contains constants"); - if(ff.getLabelList().size() != fConLab.getLabelList().size()) throw new PrismException("Contains labels"); - } - else - { - if(ff.getConstantList().size() != 0) throw new PrismException("Contains constants"); - if(ff.getLabelList().size() != 0) throw new PrismException("Contains labels"); + if (!couldBeNoConstantsOrLabels) { + if (ff.getConstantList().size() != fConLab.getConstantList().size()) + throw new PrismException("Contains constants"); + if (ff.getLabelList().size() != fConLab.getLabelList().size()) + throw new PrismException("Contains labels"); + } else { + if (ff.getConstantList().size() != 0) + throw new PrismException("Contains constants"); + if (ff.getLabelList().size() != 0) + throw new PrismException("Contains labels"); } //Now set the property expr = ff.getProperty(0); parseError = "(Unexpected) no error!"; // if status was previously a parse error, reset status. // otherwise, don't set status - reparse doesn't mean existing results should be lost - if (getStatus() == STATUS_PARSE_ERROR) setStatus(STATUS_NOT_DONE); - } - catch(PrismException ex) - { + if (getStatus() == STATUS_PARSE_ERROR) + setStatus(STATUS_NOT_DONE); + } catch (PrismException ex) { expr = null; setStatus(STATUS_PARSE_ERROR); parseError = ex.getMessage(); diff --git a/prism/src/userinterface/properties/computation/ModelCheckThread.java b/prism/src/userinterface/properties/computation/ModelCheckThread.java index d4c3b7f1..c509293e 100644 --- a/prism/src/userinterface/properties/computation/ModelCheckThread.java +++ b/prism/src/userinterface/properties/computation/ModelCheckThread.java @@ -46,12 +46,12 @@ public class ModelCheckThread extends GUIComputationThread private GUIMultiProperties parent; private Model m; private PropertiesFile prFi; - private ArrayList guiProps; + private ArrayList guiProps; private Values definedMFConstants; private Values definedPFConstants; /** Creates a new instance of ModelCheckThread */ - public ModelCheckThread(GUIMultiProperties parent, Model m, PropertiesFile prFi, ArrayList guiProps, Values definedMFConstants, Values definedPFConstants) + public ModelCheckThread(GUIMultiProperties parent, Model m, PropertiesFile prFi, ArrayList guiProps, Values definedMFConstants, Values definedPFConstants) { super(parent); this.parent = parent; @@ -82,7 +82,7 @@ public class ModelCheckThread extends GUIComputationThread //Set icon for all properties to be verified to a clock for(int i = 0; i < guiProps.size(); i++) { - GUIProperty gp = (GUIProperty)guiProps.get(i); + GUIProperty gp = guiProps.get(i); gp.setStatus(GUIProperty.STATUS_DOING); parent.repaintList(); } @@ -92,7 +92,7 @@ public class ModelCheckThread extends GUIComputationThread for(int i = 0; i < prFi.getNumProperties(); i++) { // get property - GUIProperty gp = (GUIProperty)guiProps.get(i); + GUIProperty gp = guiProps.get(i); // animate it's clock icon ic = new IconThread(gp); ic.start();