From 3eeab958f37512b315b85aec44e37e75a3708391 Mon Sep 17 00:00:00 2001 From: Mikkel Tygesen Date: Mon, 18 Nov 2024 17:21:53 +0100 Subject: [PATCH] added guard for models with strict intervals when using smc --- .../net/tapaal/gui/petrinet/widgets/QueryPane.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/tapaal/gui/petrinet/widgets/QueryPane.java b/src/main/java/net/tapaal/gui/petrinet/widgets/QueryPane.java index fd04dc7fe..eba26ec5a 100644 --- a/src/main/java/net/tapaal/gui/petrinet/widgets/QueryPane.java +++ b/src/main/java/net/tapaal/gui/petrinet/widgets/QueryPane.java @@ -36,6 +36,8 @@ import pipe.gui.petrinet.undo.UndoManager; import net.tapaal.gui.petrinet.dialog.QueryDialog.QueryDialogueOption; import dk.aau.cs.Messenger; +import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork; +import net.tapaal.gui.petrinet.TAPNLens; import net.tapaal.gui.petrinet.dialog.BatchProcessingDialog; import pipe.gui.petrinet.PetriNetTab; import net.tapaal.gui.petrinet.undo.Command; @@ -310,9 +312,17 @@ private void addButtons() { addQueryButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - TAPNQuery q = QueryDialog.showQueryDialogue(QueryDialogueOption.Save, null, tabContent.network(), tabContent.getGuiModels(), tabContent.getLens(), tabContent); + TimedArcPetriNetNetwork network = tabContent.network(); + TAPNLens lens = tabContent.getLens(); - if(q == null) return; + if (lens.isStochastic() && !network.isNonStrict()) { + JOptionPane.showMessageDialog(null, "SMC queries are only allowed for models with nonstrict intervals.", "Error", JOptionPane.ERROR_MESSAGE); + return; + } + + TAPNQuery q = QueryDialog.showQueryDialogue(QueryDialogueOption.Save, null, network, tabContent.getGuiModels(), lens, tabContent); + + if (q == null) return; undoManager.addNewEdit(new AddQueryCommand(q, tabContent)); addQuery(q);