From 4fc61415fb442d3296532f6bfe0d4ef35a5f8b4e Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Fri, 27 Jan 2012 00:45:04 +0000 Subject: [PATCH] Display notification of warnings after computations in GUI. git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@4497 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/src/userinterface/GUIPrism.java | 26 +++++ .../userinterface/model/GUIMultiModel.java | 15 ++- .../model/computation/BuildModelThread.java | 2 +- .../computation/ComputeSteadyStateThread.java | 2 +- .../computation/ComputeTransientThread.java | 2 +- .../computation/ExportBuiltModelThread.java | 2 +- .../computation/LoadGraphicModelThread.java | 2 +- .../computation/LoadPEPAModelThread.java | 2 +- .../computation/LoadPRISMModelThread.java | 2 +- .../model/computation/ParseModelThread.java | 2 +- .../computation/SaveGraphicModelThread.java | 2 +- .../computation/SavePEPAModelThread.java | 2 +- .../computation/SavePRISMModelThread.java | 2 +- .../properties/GUIMultiProperties.java | 100 ++++++++++++++---- .../computation/ExportResultsThread.java | 2 +- .../computation/LoadPropertiesThread.java | 2 +- .../computation/SavePropertiesThread.java | 2 +- 17 files changed, 134 insertions(+), 35 deletions(-) diff --git a/prism/src/userinterface/GUIPrism.java b/prism/src/userinterface/GUIPrism.java index 0e374ed8..66a9fb95 100644 --- a/prism/src/userinterface/GUIPrism.java +++ b/prism/src/userinterface/GUIPrism.java @@ -155,6 +155,7 @@ public class GUIPrism extends JFrame private JFileChooser choose; private JProgressBar progress; private GUITaskBar taskbar; + private String taskbarText = ""; private Action prismOptions; private Action fontIncrease; private Action fontDecrease; @@ -528,6 +529,7 @@ public class GUIPrism extends JFrame else if(e.getID() == GUIComputationEvent.COMPUTATION_DONE) { prismOptions.setEnabled(true); + appendWarningsNoteToTaskBarText(prism.getMainLog()); } else if(e.getID() == GUIComputationEvent.COMPUTATION_ERROR) { @@ -606,6 +608,30 @@ public class GUIPrism extends JFrame public void setTaskBarText(String message) { taskbar.setText(message); + // Store message to in case we want to append a (single) warning later + taskbarText = message; + } + + /** Utility update method to append a note about warnings to the taskbar + * @param log PrismLog to check for warnings + */ + public void appendWarningsNoteToTaskBarText(PrismLog log) + { + int numWarnings = log.getNumberOfWarnings(); + String message = null; + if (numWarnings == 1) + message = "[ There was 1 warning - see log for details ]"; + else if (numWarnings > 1) + message = "[ There were " + numWarnings + " warnings - see log for details ]"; + if (message != null) { + String taskbarTextNew = taskbarText; + if (taskbarTextNew == null) + taskbarTextNew = ""; + if (taskbarTextNew.length() > 0) + taskbarTextNew += " "; + taskbarTextNew += message; + taskbar.setText(taskbarTextNew); + } } /** Utility update method to set the JProgressBar to an indeterminate state. */ diff --git a/prism/src/userinterface/model/GUIMultiModel.java b/prism/src/userinterface/model/GUIMultiModel.java index 629b2078..72062506 100644 --- a/prism/src/userinterface/model/GUIMultiModel.java +++ b/prism/src/userinterface/model/GUIMultiModel.java @@ -300,7 +300,9 @@ public class GUIMultiModel extends GUIPlugin implements PrismSettingsListener protected void a_build() { - //check modified since build + // Reset warnings counter + getPrism().getMainLog().resetNumberOfWarnings(); + // Request build handler.forceBuild(); } /* @@ -321,12 +323,17 @@ public class GUIMultiModel extends GUIPlugin implements PrismSettingsListener default: res = showSaveFileDialog(textFilter, textFilter[0]); break; } if (res != JFileChooser.APPROVE_OPTION) return; + // Reset warnings counter + getPrism().getMainLog().resetNumberOfWarnings(); // do export... handler.exportBuild(exportEntity, exportType, getChooserFile()); } protected void a_viewBuild(int exportEntity, int exportType) { + // Reset warnings counter + getPrism().getMainLog().resetNumberOfWarnings(); + // Do view... handler.exportBuild(exportEntity, exportType, null); } @@ -342,11 +349,17 @@ public class GUIMultiModel extends GUIPlugin implements PrismSettingsListener protected void a_computeSteadyState() { + // Reset warnings counter + getPrism().getMainLog().resetNumberOfWarnings(); + // Do steady-state handler.computeSteadyState(); } protected void a_computeTransient() { + // Reset warnings counter + getPrism().getMainLog().resetNumberOfWarnings(); + // Do transient int result = GUITransientTime.requestTime(this.getGUI()); if (result == GUITransientTime.OK) { handler.computeTransient(GUITransientTime.getTime()); diff --git a/prism/src/userinterface/model/computation/BuildModelThread.java b/prism/src/userinterface/model/computation/BuildModelThread.java index f95e7e25..68530b3b 100644 --- a/prism/src/userinterface/model/computation/BuildModelThread.java +++ b/prism/src/userinterface/model/computation/BuildModelThread.java @@ -244,8 +244,8 @@ public class BuildModelThread extends GUIComputationThread //If we are here, the build was successful, notify the interface SwingUtilities.invokeLater(new Runnable() { public void run() { plug.stopProgress(); - plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); plug.setTaskBarText("Building model... done."); + plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); handler.modelBuildSuccessful(model, buildValues); }}); } diff --git a/prism/src/userinterface/model/computation/ComputeSteadyStateThread.java b/prism/src/userinterface/model/computation/ComputeSteadyStateThread.java index a7ba05bf..738457d7 100644 --- a/prism/src/userinterface/model/computation/ComputeSteadyStateThread.java +++ b/prism/src/userinterface/model/computation/ComputeSteadyStateThread.java @@ -84,8 +84,8 @@ public class ComputeSteadyStateThread extends GUIComputationThread { public void run() { - plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); plug.setTaskBarText("Computing steady-state probabilities... done."); + plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); plug.stopProgress(); } }); diff --git a/prism/src/userinterface/model/computation/ComputeTransientThread.java b/prism/src/userinterface/model/computation/ComputeTransientThread.java index 53a7032d..f7f9d6b5 100644 --- a/prism/src/userinterface/model/computation/ComputeTransientThread.java +++ b/prism/src/userinterface/model/computation/ComputeTransientThread.java @@ -86,8 +86,8 @@ public class ComputeTransientThread extends GUIComputationThread { public void run() { - plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); plug.setTaskBarText("Computing transient probabilities... done."); + plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); plug.stopProgress(); } }); diff --git a/prism/src/userinterface/model/computation/ExportBuiltModelThread.java b/prism/src/userinterface/model/computation/ExportBuiltModelThread.java index 7c705f09..b1fbff7e 100644 --- a/prism/src/userinterface/model/computation/ExportBuiltModelThread.java +++ b/prism/src/userinterface/model/computation/ExportBuiltModelThread.java @@ -108,8 +108,8 @@ public class ExportBuiltModelThread extends GUIComputationThread //If we get here export was successful, notify interface SwingUtilities.invokeAndWait(new Runnable() { public void run() { plug.stopProgress(); - plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); plug.setTaskBarText("Exporting... done."); + plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); }}); } // catch and ignore any thread exceptions diff --git a/prism/src/userinterface/model/computation/LoadGraphicModelThread.java b/prism/src/userinterface/model/computation/LoadGraphicModelThread.java index f1331473..ecc27226 100644 --- a/prism/src/userinterface/model/computation/LoadGraphicModelThread.java +++ b/prism/src/userinterface/model/computation/LoadGraphicModelThread.java @@ -613,8 +613,8 @@ public class LoadGraphicModelThread extends Thread implements EntityResolver public void run() { plug.stopProgress(); - plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); plug.setTaskBarText("Loading model... done."); + plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); handler.graphicModelLoaded(graphicEdit, f ); } }); diff --git a/prism/src/userinterface/model/computation/LoadPEPAModelThread.java b/prism/src/userinterface/model/computation/LoadPEPAModelThread.java index dea3aa38..2702507b 100644 --- a/prism/src/userinterface/model/computation/LoadPEPAModelThread.java +++ b/prism/src/userinterface/model/computation/LoadPEPAModelThread.java @@ -101,8 +101,8 @@ public class LoadPEPAModelThread extends Thread //If we get here, the load has been successful, notify the interface and tell the handler. SwingUtilities.invokeAndWait(new Runnable() { public void run() { plug.stopProgress(); - plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); plug.setTaskBarText("Loading model... done."); + plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); if(!reload) handler.pepaModelLoaded(pepaEdit, f ,replace); else diff --git a/prism/src/userinterface/model/computation/LoadPRISMModelThread.java b/prism/src/userinterface/model/computation/LoadPRISMModelThread.java index 29ef0953..3cdd1e04 100644 --- a/prism/src/userinterface/model/computation/LoadPRISMModelThread.java +++ b/prism/src/userinterface/model/computation/LoadPRISMModelThread.java @@ -101,8 +101,8 @@ public class LoadPRISMModelThread extends Thread //If we get here, the load has been successful, notify the interface and tell the handler. SwingUtilities.invokeAndWait(new Runnable() { public void run() { plug.stopProgress(); - plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); plug.setTaskBarText("Loading model... done."); + plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); if(!reload) handler.prismModelLoaded(textEdit, f ,replace); else diff --git a/prism/src/userinterface/model/computation/ParseModelThread.java b/prism/src/userinterface/model/computation/ParseModelThread.java index cbfaa5b7..582f657f 100644 --- a/prism/src/userinterface/model/computation/ParseModelThread.java +++ b/prism/src/userinterface/model/computation/ParseModelThread.java @@ -105,8 +105,8 @@ public class ParseModelThread extends GUIComputationThread //If we get here, the parse has been successful, notify the interface and tell the handler. SwingUtilities.invokeLater(new Runnable() { public void run() { if(!background) plug.stopProgress(); - plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); if(!background) plug.setTaskBarText("Parsing model... done."); + plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); handler.modelParsedSuccessful(mod); }}); } diff --git a/prism/src/userinterface/model/computation/SaveGraphicModelThread.java b/prism/src/userinterface/model/computation/SaveGraphicModelThread.java index 73ae07f2..a63581d2 100644 --- a/prism/src/userinterface/model/computation/SaveGraphicModelThread.java +++ b/prism/src/userinterface/model/computation/SaveGraphicModelThread.java @@ -556,8 +556,8 @@ public class SaveGraphicModelThread extends Thread public void run() { plug.stopProgress(); - plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); plug.setTaskBarText("Saving model... done."); + plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); handler.graphicFileWasSaved(f); } }); diff --git a/prism/src/userinterface/model/computation/SavePEPAModelThread.java b/prism/src/userinterface/model/computation/SavePEPAModelThread.java index c2dbe58d..75edbd60 100644 --- a/prism/src/userinterface/model/computation/SavePEPAModelThread.java +++ b/prism/src/userinterface/model/computation/SavePEPAModelThread.java @@ -89,8 +89,8 @@ public class SavePEPAModelThread extends Thread //If we get here, the save has been successful, notify the interface and tell the handler. SwingUtilities.invokeAndWait(new Runnable() { public void run() { plug.stopProgress(); - plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); plug.setTaskBarText("Saving model... done."); + plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); handler.pepaFileWasSaved(f); }}); } diff --git a/prism/src/userinterface/model/computation/SavePRISMModelThread.java b/prism/src/userinterface/model/computation/SavePRISMModelThread.java index 8b303c63..0fe3ce40 100644 --- a/prism/src/userinterface/model/computation/SavePRISMModelThread.java +++ b/prism/src/userinterface/model/computation/SavePRISMModelThread.java @@ -88,8 +88,8 @@ public class SavePRISMModelThread extends Thread //If we get here, the save has been successful, notify the interface and tell the handler. SwingUtilities.invokeAndWait(new Runnable() { public void run() { plug.stopProgress(); - plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); plug.setTaskBarText("Saving model... done."); + plug.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, plug)); handler.prismFileWasSaved(f); }}); } diff --git a/prism/src/userinterface/properties/GUIMultiProperties.java b/prism/src/userinterface/properties/GUIMultiProperties.java index 461af14f..229c7712 100644 --- a/prism/src/userinterface/properties/GUIMultiProperties.java +++ b/prism/src/userinterface/properties/GUIMultiProperties.java @@ -29,26 +29,83 @@ package userinterface.properties; -import java.io.*; -import java.util.*; -import java.awt.*; -import java.awt.event.*; -import java.awt.datatransfer.*; - -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.border.*; - -import userinterface.*; -import userinterface.model.*; -import userinterface.properties.computation.*; -import userinterface.util.*; -import userinterface.simulator.*; -import userinterface.simulator.networking.*; -import prism.*; -import parser.*; -import parser.ast.*; -import parser.type.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.event.ActionEvent; +import java.awt.event.ContainerEvent; +import java.awt.event.ContainerListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Vector; + +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JMenu; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.JSeparator; +import javax.swing.JSplitPane; +import javax.swing.JTextArea; +import javax.swing.JToolBar; +import javax.swing.KeyStroke; +import javax.swing.border.TitledBorder; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +import parser.Values; +import parser.ast.Expression; +import parser.ast.ModulesFile; +import parser.ast.PropertiesFile; +import parser.ast.Property; +import parser.type.Type; +import parser.type.TypeDouble; +import parser.type.TypeInt; +import parser.type.TypeInterval; +import prism.Model; +import prism.ModelType; +import prism.PrismException; +import prism.PrismSettings; +import prism.PrismSettingsListener; +import prism.UndefinedConstants; +import userinterface.GUIClipboardEvent; +import userinterface.GUIConstantsPicker; +import userinterface.GUIPlugin; +import userinterface.GUIPrism; +import userinterface.GUISimulationPicker; +import userinterface.OptionsPanel; +import userinterface.SimulationInformation; +import userinterface.model.GUIModelEvent; +import userinterface.properties.computation.ExportResultsThread; +import userinterface.properties.computation.LoadPropertiesThread; +import userinterface.properties.computation.ModelCheckThread; +import userinterface.properties.computation.SimulateModelCheckThread; +import userinterface.simulator.GUISimulator; +import userinterface.simulator.networking.GUISimulatorDistributionDialog; +import userinterface.util.GUIComputationEvent; +import userinterface.util.GUIEvent; +import userinterface.util.GUIExitEvent; +import userinterface.util.GUIPrismFileFilter; /** * Properties tab of the PRISM GUI. @@ -949,6 +1006,9 @@ public class GUIMultiProperties extends GUIPlugin implements MouseListener, List public void a_newExperiment() { + // Reset warnings counter + getPrism().getMainLog().resetNumberOfWarnings(); + // Start expt experimentAfterReceiveParseNotification = true; notifyEventListeners(new GUIPropertiesEvent(GUIPropertiesEvent.REQUEST_MODEL_PARSE)); } diff --git a/prism/src/userinterface/properties/computation/ExportResultsThread.java b/prism/src/userinterface/properties/computation/ExportResultsThread.java index 9c5fc982..80a5562f 100644 --- a/prism/src/userinterface/properties/computation/ExportResultsThread.java +++ b/prism/src/userinterface/properties/computation/ExportResultsThread.java @@ -125,8 +125,8 @@ public class ExportResultsThread extends Thread public void run() { parent.stopProgress(); - parent.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, parent)); parent.setTaskBarText("Exporting results... done."); + parent.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, parent)); } }); } diff --git a/prism/src/userinterface/properties/computation/LoadPropertiesThread.java b/prism/src/userinterface/properties/computation/LoadPropertiesThread.java index 3b186f45..9c4824c6 100644 --- a/prism/src/userinterface/properties/computation/LoadPropertiesThread.java +++ b/prism/src/userinterface/properties/computation/LoadPropertiesThread.java @@ -99,8 +99,8 @@ public class LoadPropertiesThread extends Thread //If we get here, the load has been successful, notify the interface and tell the handler. SwingUtilities.invokeAndWait(new Runnable() { public void run() { parent.stopProgress(); - parent.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, parent)); parent.setTaskBarText("Loading properties... done."); + parent.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, parent)); if(isInsert) parent.propertyInsertSuccessful(props); else diff --git a/prism/src/userinterface/properties/computation/SavePropertiesThread.java b/prism/src/userinterface/properties/computation/SavePropertiesThread.java index 945c549d..8f14008b 100644 --- a/prism/src/userinterface/properties/computation/SavePropertiesThread.java +++ b/prism/src/userinterface/properties/computation/SavePropertiesThread.java @@ -83,8 +83,8 @@ public class SavePropertiesThread extends Thread //Computation successful, notify the user interface SwingUtilities.invokeAndWait(new Runnable() { public void run() { parent.stopProgress(); - parent.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, parent)); parent.setTaskBarText("Saving properties... done."); + parent.notifyEventListeners(new GUIComputationEvent(GUIComputationEvent.COMPUTATION_DONE, parent)); parent.propertySaveSuccessful(f); }}); }