Merge lp:~tapaal-contributor/tapaal/load-and-save-time-and-game-net-properties into lp:tapaal

Proposed by Lena Ernstsen
Status: Merged
Approved by: Jiri Srba
Approved revision: 1090
Merged at revision: 1069
Proposed branch: lp:~tapaal-contributor/tapaal/load-and-save-time-and-game-net-properties
Merge into: lp:tapaal
Diff against target: 856 lines (+348/-80)
12 files modified
src/dk/aau/cs/gui/TabContent.java (+40/-10)
src/dk/aau/cs/io/LoadedModel.java (+19/-3)
src/dk/aau/cs/io/TapnXmlLoader.java (+56/-21)
src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java (+41/-1)
src/dk/aau/cs/io/batchProcessing/BatchProcessingLoader.java (+25/-2)
src/dk/aau/cs/model/tapn/TimedArcPetriNet.java (+29/-7)
src/pipe/dataLayer/Template.java (+1/-1)
src/pipe/gui/GuiFrame.java (+12/-0)
src/pipe/gui/GuiFrameActions.java (+1/-0)
src/pipe/gui/GuiFrameController.java (+1/-0)
src/pipe/gui/widgets/NewTAPNPanel.java (+112/-11)
src/pipe/gui/widgets/QueryPane.java (+11/-24)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/load-and-save-time-and-game-net-properties
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Kenneth Yrke Jørgensen Approve
Lena Ernstsen (community) Needs Resubmitting
Review via email: mp+387301@code.launchpad.net

Commit message

Added the possibility to choose which time and game properties a net should include.

Description of the change

When creating a new net, it is possible to choose which kind of properties should be accessible (whether is is timed or untimed and whether it should contain game features).

This information is displayed in the toolbar beside the tokens.

The information will also be displayed when loading a file. However, only timing information is displayed. Game information is not displayed yet because the implementation of games is not included in this branch.

To post a comment you must log in.
1072. By Lena Ernstsen

Net information is saved in .tapn files (games are not implemented fully because these features are not included in this branch)

1073. By Lena Ernstsen

Minor fix

Revision history for this message
Kenneth Yrke Jørgensen (yrke) :
review: Needs Fixing
Revision history for this message
Kenneth Yrke Jørgensen (yrke) wrote :

See comments in code.

Revision history for this message
Jiri Srba (srba) wrote :

Loading and saving of net features does not work. Make a game untimed net and add just one place. Then save the net and open it again and it will say that the game is not a game net anymore.

When creating a new net, the layout is confusing. Instead, try to make a dialog like:

Use time semantics: [ ] Yes [ ] No
Use game semantics: [ ] Yes [ ] No

The status can contain information saying: "Time: Yes, Game: No" etc.
Kenneth, I like the current placement of this information next to the buttons, as it should be always
visible, the status bar is used more as context sensitive guide.

When you make a new query, it should offer either the CTL or Reachability dialog without asking,
depending on the Timed flag (if Timed, offer Reachability, if not Timed offer CTL).

review: Needs Fixing
1074. By Lena Ernstsen

Changed the dialog message when creating a new net. Changed the text in the toolbar. When saving, the time/game info is placed on each tapn instead of the entire net. Removed global lense information from TimedArcPetriNet. Made lense information invisble for guiframe again.

1075. By Lena Ernstsen

When net is timed, only reachability queries are available. When net is untimed, only CTL queries are available.

1076. By Lena Ernstsen

Net information is saved correctly.

1077. By Lena Ernstsen

Net information is loaded correctly.

1078. By Lena Ernstsen

Added the property as a tag for the entire net net, instead of each tapn.

Revision history for this message
Lena Ernstsen (lsaid) wrote :

The saving and loading should work now.
CTL queries are only available when the net is untimed.
Dialog message is changed to be more readable, as well as the text in the toolbar.
Made the lens information as a tag to the entire net instead of for each tapn.

review: Needs Resubmitting
1079. By Lena Ernstsen

Minor fix

1080. By Lena Ernstsen

Renamed property to feature

Revision history for this message
Jiri Srba (srba) wrote :

When you open a .tapn file that does not have any information about whether it is timed/untimed
and game/not game, it should autodetect the type of the net. In net statistics you can find the check for timed/untimed - all components, even the nonactive ones must be untimed in order to call the net untimed. The test for game must be implemented - if there is any controllable/environmental player information in the XML file then it is a game, otherwise it is not.

review: Needs Fixing
1081. By Lena Ernstsen

Added sanity check for loading the time/game info of nets. Renamed property to feature and removed unused methods.

1082. By Lena Ernstsen

Added warning message when net is timed/game and the feature says otherwise.

Revision history for this message
Lena Ernstsen (lsaid) wrote :

Added sanity check for loading time/game info of nets. A warning will appear if the net is timed/game, but the loaded info says otherwise.

The warning for the game feature is not fully implemented, because it can't be tested whether the network is a game yet.

review: Needs Resubmitting
1083. By Lena Ernstsen

Removed warning messages

1084. By Lena Ernstsen

Warning messages for time/game is shown in debugger

Revision history for this message
Jiri Srba (srba) wrote :

We need to change the method checking if a net is timed. At the moment, if there are no time intervals but the net has urgent transitions or age invariants, it will be still declared as "untimed" which we don't want anymore. So change the definition of untimed such that it will also check whether the net has urgent transitions or age invariants (except for the trivial one < infty), and if yes then report the net as timed.

review: Needs Fixing
Revision history for this message
Jiri Srba (srba) wrote :

The default options when making a new net should be No/No both for time and game semantics.

review: Needs Fixing
1085. By Lena Ernstsen

Set default game/time features to 'No'. Changed isUntimed to check urgent transitions and nontrivial age invariants.

Revision history for this message
Lena Ernstsen (lsaid) :
1086. By Lena Ernstsen

Fixed logic

Revision history for this message
Jiri Srba (srba) wrote :

The new semantics of inUntimed() where urgent transitions and nontrivial age invariants make the net timed it not reflected in net statistics panel.

review: Needs Fixing
Revision history for this message
Kenneth Yrke Jørgensen (yrke) :
review: Approve
1087. By Lena Ernstsen

Fixed statistics concering untimed net

1088. By Lena Ernstsen

Merge

Revision history for this message
Jiri Srba (srba) wrote :

The statistics cannot be fixed this way. It must be done online, everytime the dialog is called
it should be recomputed as the net could have been edited in between.
E.g. make two components, first one has urgent transition, the second one not - it will report the statistics in a wrong way.

review: Needs Fixing
1089. By Lena Ernstsen

Fixed wrong untimed information in statistics

Revision history for this message
Jiri Srba (srba) wrote :

Still does not work. Try to make several components, some untimed, other with urgent transition. Now depending which component is shown, different answer are given. E.g. if you are in the untimed component it will claim that all components are untimed.

review: Needs Fixing
1090. By Lena Ernstsen

urgent transitions are checked correctly when checking whether net is untimed

Revision history for this message
Jiri Srba (srba) wrote :

Works as expected now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/dk/aau/cs/gui/TabContent.java'
2--- src/dk/aau/cs/gui/TabContent.java 2020-07-09 12:55:25 +0000
3+++ src/dk/aau/cs/gui/TabContent.java 2020-08-03 12:48:32 +0000
4@@ -476,21 +476,23 @@
5 ModelLoader loader = new ModelLoader();
6 LoadedModel loadedModel = loader.load(file);
7
8- TabContent tab = new TabContent(loadedModel.network(), loadedModel.templates(), loadedModel.queries());
9+ TabContent tab = new TabContent(loadedModel.network(), loadedModel.templates(), loadedModel.queries(), loadedModel.isTimed(), loadedModel.isGame());
10+
11 tab.setInitialName(name);
12
13 tab.selectFirstElements();
14
15 tab.setFile(null);
16- return tab;
17+
18+ return tab;
19 } catch (Exception e) {
20 throw new Exception("TAPAAL encountered an error while loading the file: " + name + "\n\nPossible explanations:\n - " + e.toString());
21 }
22
23 }
24
25- public static TabContent createNewEmptyTab(String name){
26- TabContent tab = new TabContent();
27+ public static TabContent createNewEmptyTab(String name, boolean isTimed, boolean isGame){
28+ TabContent tab = new TabContent(isTimed, isGame);
29 tab.setInitialName(name);
30
31 //Set Default Template
32@@ -631,8 +633,8 @@
33 private WorkflowDialog workflowDialog = null;
34
35
36- private TabContent() {
37- this(new TimedArcPetriNetNetwork(), new ArrayList<>(), new TAPNLens(true,false));
38+ private TabContent(boolean isTimed, boolean isGame) {
39+ this(new TimedArcPetriNetNetwork(), new ArrayList<>(), new TAPNLens(isTimed,isGame));
40 }
41
42 private TabContent(TimedArcPetriNetNetwork network, Collection<Template> templates, TAPNLens lens) {
43@@ -687,6 +689,10 @@
44 animationModeController = new CanvasAnimationController(getAnimator());
45 }
46
47+ private TabContent(TimedArcPetriNetNetwork network, Collection<Template> templates, Iterable<TAPNQuery> tapnqueries, boolean isTimed, boolean isGame) {
48+ this(network, templates, tapnqueries, new TAPNLens(isTimed, isGame));
49+ }
50+
51 private TabContent(TimedArcPetriNetNetwork network, Collection<Template> templates, Iterable<TAPNQuery> tapnqueries) {
52 this(network, templates, tapnqueries, new TAPNLens(true, false));
53 }
54@@ -697,7 +703,7 @@
55 setQueries(tapnqueries);
56 setConstants(network().constants());
57 }
58-
59+
60 public SharedPlacesAndTransitionsPanel getSharedPlacesAndTransitionsPanel(){
61 return sharedPTPanel;
62 }
63@@ -1646,6 +1652,8 @@
64 this.app = Optional.ofNullable(newApp);
65 undoManager.setApp(newApp);
66
67+ updateFeatureText();
68+
69 //XXX
70 if (isInAnimationMode()) {
71 app.ifPresent(o->o.setGUIMode(GuiFrame.GUIMode.animation));
72@@ -1761,7 +1769,7 @@
73 final AbstractDrawingSurfaceManager animationModeController;
74
75 //Writes a tapaal net to a file, with the posibility to overwrite the quires
76- public void writeNetToFile(File outFile, List<TAPNQuery> queriesOverwrite) {
77+ public void writeNetToFile(File outFile, List<TAPNQuery> queriesOverwrite, TAPNLens lens) {
78 try {
79 NetworkMarking currentMarking = null;
80 if(isInAnimationMode()){
81@@ -1773,7 +1781,9 @@
82 network(),
83 allTemplates(),
84 queriesOverwrite,
85- network().constants()
86+ network().constants(),
87+ lens.timed,
88+ lens.game
89 );
90
91 tapnWriter.savePNML(outFile);
92@@ -1790,7 +1800,7 @@
93 }
94
95 public void writeNetToFile(File outFile) {
96- writeNetToFile(outFile, (List<TAPNQuery>) queries());
97+ writeNetToFile(outFile, (List<TAPNQuery>) queries(), lens);
98 }
99
100 @Override
101@@ -2244,6 +2254,26 @@
102 managerRef.get().registerManager(drawingSurface);
103 }
104
105+ public void updateFeatureText() {
106+
107+ String properties = "Timed: " + (lens.isTimed() ? "Yes" : "No") +
108+ ", Game: " + (lens.isGame() ? "Yes" : "No");
109+ app.ifPresent(o->o.setFeatureInfoText(properties));
110+
111+ }
112+
113+ public boolean isNetTimed() {
114+ return lens.isTimed();
115+ }
116+
117+ public boolean isNetGame() {
118+ return lens.isGame();
119+ }
120+
121+ public TAPNLens getLens() {
122+ return lens;
123+ }
124+
125 private final class CanvasTransportarcDrawController extends AbstractDrawingSurfaceManager {
126
127 private TimedTransitionComponent transition;
128
129=== modified file 'src/dk/aau/cs/io/LoadedModel.java'
130--- src/dk/aau/cs/io/LoadedModel.java 2019-03-22 09:17:07 +0000
131+++ src/dk/aau/cs/io/LoadedModel.java 2020-08-03 12:48:32 +0000
132@@ -9,15 +9,31 @@
133 public class LoadedModel{
134 private Collection<Template> templates;
135 private Collection<TAPNQuery> queries;
136- private TimedArcPetriNetNetwork network;
137-
138+ private TimedArcPetriNetNetwork network;
139+ private boolean isTimed;
140+ private boolean isGame;
141+
142 public LoadedModel(TimedArcPetriNetNetwork network, Collection<Template> templates, Collection<TAPNQuery> queries){
143 this.templates = templates;
144 this.network = network;
145- this.queries = queries;
146+ this.queries = queries;
147 }
148
149+ public LoadedModel(TimedArcPetriNetNetwork network, Collection<Template> templates, Collection<TAPNQuery> queries, boolean isTimed, boolean isGame){
150+ this.templates = templates;
151+ this.network = network;
152+ this.queries = queries;
153+ this.isTimed = isTimed;
154+ this.isGame = isGame;
155+ }
156+
157 public Collection<Template> templates(){ return templates; }
158 public Collection<TAPNQuery> queries(){ return queries; }
159 public TimedArcPetriNetNetwork network(){ return network; }
160+ public boolean isTimed() {
161+ return isTimed;
162+ }
163+ public boolean isGame() {
164+ return isGame;
165+ }
166 }
167\ No newline at end of file
168
169=== modified file 'src/dk/aau/cs/io/TapnXmlLoader.java'
170--- src/dk/aau/cs/io/TapnXmlLoader.java 2020-07-14 11:18:47 +0000
171+++ src/dk/aau/cs/io/TapnXmlLoader.java 2020-08-03 12:48:32 +0000
172@@ -8,11 +8,12 @@
173 import java.util.HashMap;
174 import java.util.List;
175
176-import javax.swing.JOptionPane;
177+import javax.swing.*;
178 import javax.xml.parsers.DocumentBuilder;
179 import javax.xml.parsers.DocumentBuilderFactory;
180 import javax.xml.parsers.ParserConfigurationException;
181
182+import dk.aau.cs.debug.Logger;
183 import org.w3c.dom.Document;
184 import org.w3c.dom.Element;
185 import org.w3c.dom.Node;
186@@ -61,7 +62,7 @@
187
188 public class TapnXmlLoader {
189 private static final String PLACENAME_ERROR_MESSAGE = "The keywords \"true\" and \"false\" are reserved and can not be used as place names.\nPlaces with these names will be renamed to \"_true\" and \"_false\" respectively.\n\n Note that any queries using these places may not be parsed correctly.";
190- private HashMap<TimedTransitionComponent, TimedTransportArcComponent> presetArcs = new HashMap<TimedTransitionComponent, TimedTransportArcComponent>();
191+ private HashMap<TimedTransitionComponent, TimedTransportArcComponent> presetArcs = new HashMap<TimedTransitionComponent, TimedTransportArcComponent>();
192 private HashMap<TimedTransitionComponent, TimedTransportArcComponent> postsetArcs = new HashMap<TimedTransitionComponent, TimedTransportArcComponent>();
193 private HashMap<TimedTransportArcComponent, TimeInterval> transportArcsTimeIntervals = new HashMap<TimedTransportArcComponent, TimeInterval>();
194
195@@ -70,6 +71,10 @@
196 private boolean firstPlaceRenameWarning = true;
197 private IdResolver idResolver = new IdResolver();
198
199+ private boolean isTimed;
200+ private boolean isGame;
201+ private boolean hasUncontrollableTransitions = false;
202+
203 public TapnXmlLoader() {
204 }
205
206@@ -124,8 +129,10 @@
207 network.buildConstraints();
208
209 parseBound(doc, network);
210-
211- return new LoadedModel(network, templates, queries);
212+
213+ parseFeature(doc, network);
214+
215+ return new LoadedModel(network, templates, queries, isTimed, isGame);
216 }
217
218 private void parseBound(Document doc, TimedArcPetriNetNetwork network){
219@@ -135,6 +142,30 @@
220 }
221 }
222
223+ private void parseFeature(Document doc, TimedArcPetriNetNetwork network) {
224+ boolean networkIsTimed = !network.isUntimed();
225+
226+ if (doc.getElementsByTagName("feature").getLength() > 0) {
227+ NodeList nodeList = doc.getElementsByTagName("feature");
228+
229+ isTimed = Boolean.parseBoolean(nodeList.item(0).getAttributes().getNamedItem("isTimed").getNodeValue());
230+ isGame = Boolean.parseBoolean(nodeList.item(0).getAttributes().getNamedItem("isGame").getNodeValue());
231+
232+ if (networkIsTimed && !isTimed) {
233+ isTimed = true;
234+ Logger.log("The net contains time features. The entire net will be changed to include time features.");
235+ }
236+ if (hasUncontrollableTransitions && !isGame) {
237+ isGame = true;
238+ Logger.log("The net contains game features. The entire net will be changed to include game features.");
239+
240+ }
241+ } else {
242+ isTimed = networkIsTimed;
243+ isGame = hasUncontrollableTransitions;
244+ }
245+ }
246+
247 private void parseSharedPlaces(Document doc, TimedArcPetriNetNetwork network, ConstantStore constants) {
248 NodeList sharedPlaceNodes = doc.getElementsByTagName("shared-place");
249
250@@ -220,10 +251,10 @@
251 }
252
253 private Template parseTimedArcPetriNet(Node tapnNode, TimedArcPetriNetNetwork network, ConstantStore constants) throws FormatException {
254- String name = getTAPNName(tapnNode);
255+ String name = getTAPNName(tapnNode);
256
257 boolean active = getActiveStatus(tapnNode);
258-
259+
260 TimedArcPetriNet tapn = new TimedArcPetriNet(name);
261 tapn.setActive(active);
262 network.add(tapn);
263@@ -240,23 +271,22 @@
264 }
265 }
266
267-
268 return template;
269 }
270
271 private boolean getActiveStatus(Node tapnNode) {
272- if (tapnNode instanceof Element) {
273- Element element = (Element)tapnNode;
274- String activeString = element.getAttribute("active");
275-
276- if (activeString == null || activeString.equals(""))
277- return true;
278- else
279- return activeString.equals("true");
280- } else {
281- return true;
282- }
283- }
284+ if (tapnNode instanceof Element) {
285+ Element element = (Element)tapnNode;
286+ String activeString = element.getAttribute("active");
287+
288+ if (activeString == null || activeString.equals(""))
289+ return true;
290+ else
291+ return activeString.equals("true");
292+ } else {
293+ return true;
294+ }
295+ }
296
297 private void parseElement(Element element, Template template, TimedArcPetriNetNetwork network, ConstantStore constants) throws FormatException {
298 if ("labels".equals(element.getNodeName())) {
299@@ -269,8 +299,8 @@
300 TimedTransitionComponent transition = parseTransition(element, network, template.model());
301 template.guiModel().addPetriNetObject(transition);
302 } else if ("arc".equals(element.getNodeName())) {
303- parseAndAddArc(element, template, constants);
304- }
305+ parseAndAddArc(element, template, constants);
306+ }
307 }
308
309 private boolean isNameAllowed(String name) {
310@@ -343,6 +373,11 @@
311 String idInput = transition.getAttribute("id");
312 String nameInput = transition.getAttribute("name");
313 boolean isUrgent = Boolean.parseBoolean(transition.getAttribute("urgent"));
314+
315+ String player = transition.getAttribute("player");
316+ if (player.length() > 0 && player.equals("1")) {
317+ hasUncontrollableTransitions = true;
318+ }
319
320 idResolver.add(tapn.name(), idInput, nameInput);
321
322
323=== modified file 'src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java'
324--- src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java 2020-06-18 08:32:13 +0000
325+++ src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java 2020-08-03 12:48:32 +0000
326@@ -55,6 +55,8 @@
327 private Iterable<TAPNQuery> queries;
328 private Iterable<Constant> constants;
329 private final TimedArcPetriNetNetwork network;
330+ private boolean isTimed;
331+ private boolean isGame;
332
333 public TimedArcPetriNetNetworkWriter(
334 TimedArcPetriNetNetwork network,
335@@ -66,6 +68,21 @@
336 this.queries = queries;
337 this.constants = constants;
338 }
339+
340+ public TimedArcPetriNetNetworkWriter(
341+ TimedArcPetriNetNetwork network,
342+ Iterable<Template> templates,
343+ Iterable<TAPNQuery> queries,
344+ Iterable<Constant> constants,
345+ boolean isTimed,
346+ boolean isGame) {
347+ this.network = network;
348+ this.templates = templates;
349+ this.queries = queries;
350+ this.constants = constants;
351+ this.isTimed = isTimed;
352+ this.isGame = isGame;
353+ }
354
355 public ByteArrayOutputStream savePNML() throws IOException, ParserConfigurationException, DOMException, TransformerConfigurationException, TransformerException {
356 Document document = null;
357@@ -89,6 +106,7 @@
358 appendTemplates(document, pnmlRootNode);
359 appendQueries(document, pnmlRootNode);
360 appendDefaultBound(document, pnmlRootNode);
361+ appendFeature(document, pnmlRootNode);
362
363 document.normalize();
364 // Create Transformer with XSL Source File
365@@ -139,6 +157,29 @@
366 element.setAttribute("bound", network.getDefaultBound() + "");
367 root.appendChild(element);
368 }
369+
370+ private void appendFeature(Document document, Element root) {
371+ String isTimed = "true";
372+ String isGame = "true";
373+ if (!this.isTimed) {
374+ isTimed = "false";
375+ }
376+ if (!this.isGame) {
377+ isGame = "false";
378+ }
379+
380+ root.appendChild(createFeatureElement(isTimed, isGame, document));
381+ }
382+
383+ private Element createFeatureElement(String isTimed, String isGame, Document document) {
384+ Require.that(document != null, "Error: document was null");
385+ Element feature = document.createElement("feature");
386+
387+ feature.setAttribute("isTimed", isTimed);
388+ feature.setAttribute("isGame", isGame);
389+
390+ return feature;
391+ }
392
393 private void appendSharedPlaces(Document document, Element root) {
394 for(SharedPlace place : network.sharedPlaces()){
395@@ -194,7 +235,6 @@
396
397 Attr netAttrType = document.createAttribute("type");
398 netAttrType.setValue("P/T net");
399-
400 NET.setAttributeNode(netAttrType);
401
402 appendAnnotationNotes(document, guiModel, NET);
403
404=== modified file 'src/dk/aau/cs/io/batchProcessing/BatchProcessingLoader.java'
405--- src/dk/aau/cs/io/batchProcessing/BatchProcessingLoader.java 2019-03-22 12:45:44 +0000
406+++ src/dk/aau/cs/io/batchProcessing/BatchProcessingLoader.java 2020-08-03 12:48:32 +0000
407@@ -232,10 +232,10 @@
408 }
409
410 private void parseTimedArcPetriNet(Node tapnNode, TimedArcPetriNetNetwork network, ConstantStore constants) throws FormatException {
411- String name = getTAPNName(tapnNode);
412+ String name = getTAPNName(tapnNode);
413 boolean active = getActiveStatus(tapnNode);
414
415- TimedArcPetriNet tapn = new TimedArcPetriNet(name);
416+ TimedArcPetriNet tapn = new TimedArcPetriNet(name);
417 tapn.setActive(active);
418 network.add(tapn);
419 nameGenerator.add(tapn);
420@@ -263,6 +263,29 @@
421 }
422 }
423
424+ private boolean getInfo(Node tapnNode, String attribute) {
425+ Element element = (Element)tapnNode;
426+ String string = element.getAttribute(attribute);
427+ return string.equals("true");
428+ }
429+
430+ private boolean canGetInfo(Node tapnNode) {
431+ if (tapnNode instanceof Element) {
432+ Element element = (Element)tapnNode;
433+ String timedString = element.getAttribute("timed");
434+ String gameString = element.getAttribute("game");
435+
436+ if (timedString == null || timedString.equals("") ||
437+ gameString == null || gameString.equals("")) {
438+ return false;
439+ } else {
440+ return true;
441+ }
442+ } else {
443+ return false;
444+ }
445+ }
446+
447 private void parseElement(Element element, TimedArcPetriNet tapn, TimedArcPetriNetNetwork network, ConstantStore constants) throws FormatException {
448 if ("place".equals(element.getNodeName())) {
449 parsePlace(element, network, tapn, constants);
450
451=== modified file 'src/dk/aau/cs/model/tapn/TimedArcPetriNet.java'
452--- src/dk/aau/cs/model/tapn/TimedArcPetriNet.java 2020-06-22 08:20:47 +0000
453+++ src/dk/aau/cs/model/tapn/TimedArcPetriNet.java 2020-08-03 12:48:32 +0000
454@@ -12,8 +12,8 @@
455 public class TimedArcPetriNet {
456 private String name;
457 private TimedArcPetriNetNetwork parentNetwork;
458- private boolean isActive;
459-
460+ private boolean isActive;
461+
462 //Should the names be checked to see if the name is already used
463 //This is used when loading big nets as the checking of names is slow.
464 private boolean checkNames = true;
465@@ -28,9 +28,9 @@
466 private TimedMarking currentMarking = new LocalTimedMarking();
467
468 public TimedArcPetriNet(String name) {
469- setName(name);
470- isActive = true;
471- }
472+ setName(name);
473+ isActive = true;
474+ }
475
476 public TimedMarking marking(){
477 return currentMarking;
478@@ -436,7 +436,7 @@
479 numberOfOrphanPlaces += t.getOrphanPlaces().size();
480 //Test if all inputarcs is untimed and get the number of untimed input arcs
481 for(TimedInputArc in : t.inputArcs()){
482- if(!((in.interval().lowerBound().value() == 0 && in.interval().IsLowerBoundNonStrict() && in.interval().upperBound().equals(Bound.Infinity)))){
483+ if(!(in.interval().lowerBound().value() == 0 && in.interval().IsLowerBoundNonStrict() && in.interval().upperBound().equals(Bound.Infinity))){
484 networkUntimed = false;
485 } else {
486 numberOfUntimedInputArcs++;
487@@ -447,7 +447,7 @@
488 }
489 //Test if all tansportarcs is untimed and get the number of untimed transport arcs
490 for(TransportArc in : t.transportArcs()){
491- if(!((in.interval().lowerBound().value() == 0 && in.interval().IsLowerBoundNonStrict() && in.interval().upperBound().equals(Bound.Infinity)))){
492+ if(!(in.interval().lowerBound().value() == 0 && in.interval().IsLowerBoundNonStrict() && in.interval().upperBound().equals(Bound.Infinity))){
493 networkUntimed = false;
494 } else {
495 numberOfUntimedTransportArcs++;
496@@ -456,6 +456,18 @@
497 networkWeighted = true;
498 }
499 }
500+
501+ for (TimedPlace p : t.places) {
502+ if (!p.invariant().upperBound().equals(Bound.Infinity)) {
503+ networkUntimed = false;
504+ }
505+ }
506+
507+ for (TimedTransition transition : t.transitions) {
508+ if (transition.isUrgent()) {
509+ networkUntimed = false;
510+ }
511+ }
512
513 // Test all output arcs for weights
514 if(!networkWeighted){
515@@ -613,6 +625,16 @@
516 return false;
517 }
518 }
519+
520+ if (hasUrgentTransitions()) {
521+ return false;
522+ }
523+
524+ for (TimedPlace p : places) {
525+ if (!p.invariant().upperBound().toString().equals("inf")) {
526+ return false;
527+ }
528+ }
529
530 return true;
531 }
532
533=== modified file 'src/pipe/dataLayer/Template.java'
534--- src/pipe/dataLayer/Template.java 2020-06-12 10:28:49 +0000
535+++ src/pipe/dataLayer/Template.java 2020-08-03 12:48:32 +0000
536@@ -54,7 +54,7 @@
537 public void setHasPositionalInfo(boolean positionalInfo) {
538 hasPositionalInfo = positionalInfo;
539 }
540-
541+
542 @Override
543 public boolean equals(Object obj) {
544 if(obj instanceof Template){
545
546=== modified file 'src/pipe/gui/GuiFrame.java'
547--- src/pipe/gui/GuiFrame.java 2020-07-05 18:13:46 +0000
548+++ src/pipe/gui/GuiFrame.java 2020-08-03 12:48:32 +0000
549@@ -58,6 +58,7 @@
550 private StatusBar statusBar;
551 private JMenuBar menuBar;
552 private JToolBar drawingToolBar;
553+ private final JLabel featureInfoText = new JLabel();
554 private JComboBox<String> zoomComboBox;
555
556 private static final int shortcutkey = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
557@@ -898,6 +899,10 @@
558 drawingToolBar.add(new ToggleButtonWithoutText(tokenAction));
559 drawingToolBar.add(new ToggleButtonWithoutText(deleteTokenAction));
560
561+ //Net Type
562+ drawingToolBar.addSeparator();
563+ drawingToolBar.add(featureInfoText);
564+
565 // Create panel to put toolbars in
566 JPanel toolBarPanel = new JPanel();
567 toolBarPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
568@@ -1271,6 +1276,7 @@
569
570 break;
571 case noNet:
572+ setFeatureInfoText("");
573 break;
574
575 default:
576@@ -1642,4 +1648,10 @@
577 return CreateGui.getCurrentTab();
578 }
579
580+ @Override
581+ public void setFeatureInfoText(String s) {
582+ if (s == null) s = "";
583+ featureInfoText.setText(s);
584+ }
585+
586 }
587
588=== modified file 'src/pipe/gui/GuiFrameActions.java'
589--- src/pipe/gui/GuiFrameActions.java 2020-05-18 18:17:06 +0000
590+++ src/pipe/gui/GuiFrameActions.java 2020-08-03 12:48:32 +0000
591@@ -44,4 +44,5 @@
592 void setShowZeroToInfinityIntervalsSelected(boolean b);
593 void setShowTokenAgeSelected(boolean b);
594
595+ void setFeatureInfoText(String s);
596 }
597
598=== modified file 'src/pipe/gui/GuiFrameController.java'
599--- src/pipe/gui/GuiFrameController.java 2020-07-14 11:18:47 +0000
600+++ src/pipe/gui/GuiFrameController.java 2020-08-03 12:48:32 +0000
601@@ -147,6 +147,7 @@
602
603 currentTab.ifPresent(t -> t.setApp(guiFrame));
604 guiFrameDirectAccess.setTitle(currentTab.map(TabContentActions::getTabTitle).orElse(null));
605+
606 }
607
608 @Override
609
610=== modified file 'src/pipe/gui/widgets/NewTAPNPanel.java'
611--- src/pipe/gui/widgets/NewTAPNPanel.java 2020-04-30 12:52:28 +0000
612+++ src/pipe/gui/widgets/NewTAPNPanel.java 2020-08-03 12:48:32 +0000
613@@ -4,17 +4,15 @@
614 import java.awt.GridBagConstraints;
615 import java.awt.GridBagLayout;
616 import java.awt.Insets;
617+import java.awt.event.ActionEvent;
618+import java.awt.event.ActionListener;
619 import java.awt.event.KeyEvent;
620
621-import javax.swing.JButton;
622-import javax.swing.JLabel;
623-import javax.swing.JOptionPane;
624-import javax.swing.JPanel;
625-import javax.swing.JRootPane;
626-import javax.swing.JTextField;
627+import javax.swing.*;
628
629 import dk.aau.cs.gui.TabContent;
630 import pipe.gui.CreateGui;
631+import pipe.gui.Grid;
632 import pipe.gui.GuiFrame;
633
634 public class NewTAPNPanel extends JPanel {
635@@ -22,6 +20,8 @@
636 private JRootPane rootPane;
637 private GuiFrame frame;
638 private JTextField nameTextBox;
639+ private JRadioButton timedNet;
640+ private JRadioButton gameNet;
641
642 public NewTAPNPanel(JRootPane rootPane, GuiFrame frame) {
643 this.rootPane = rootPane;
644@@ -34,6 +34,7 @@
645 this.setLayout(new GridBagLayout());
646
647 initNamePanel();
648+ initSelectionPanel();
649 initButtonPanel();
650 }
651
652@@ -64,7 +65,7 @@
653 gbc.anchor = GridBagConstraints.EAST;
654 buttonPanel.add(cancelButton,gbc);
655
656- okButton.addActionListener(e -> createNewTAPNBasedOnSelection(nameTextBox.getText()));
657+ okButton.addActionListener(e -> createNewTAPNBasedOnSelection(nameTextBox.getText(), timedNet.isSelected(), gameNet.isSelected()));
658
659 rootPane.setDefaultButton(okButton);
660
661@@ -72,7 +73,7 @@
662
663 gbc = new GridBagConstraints();
664 gbc.gridx = 0;
665- gbc.gridy = 1;
666+ gbc.gridy = 2;
667 gbc.insets = new Insets(0, 8, 5, 8);
668 gbc.anchor = GridBagConstraints.EAST;
669 add(buttonPanel, gbc);
670@@ -82,7 +83,7 @@
671 rootPane.getParent().setVisible(false);
672 }
673
674- protected void createNewTAPNBasedOnSelection(String name) {
675+ protected void createNewTAPNBasedOnSelection(String name, boolean isTimed, boolean isGame) {
676 if (!name.endsWith(".tapn")) {
677 name = name + ".tapn";
678 }
679@@ -95,7 +96,7 @@
680 }
681
682 try {
683- TabContent tab = TabContent.createNewEmptyTab(name);
684+ TabContent tab = TabContent.createNewEmptyTab(name, isTimed, isGame);
685 CreateGui.openNewTabFromStream(tab);
686 } catch (Exception e) {
687 JOptionPane
688@@ -113,7 +114,7 @@
689
690 private void initNamePanel() {
691 JPanel namePanel = new JPanel(new GridBagLayout());
692-
693+
694 JLabel nameLabel = new JLabel("Name:");
695 GridBagConstraints gbc = new GridBagConstraints();
696 gbc.gridx = 0;
697@@ -145,4 +146,104 @@
698 gbc.insets = new Insets(5, 5, 5, 5);
699 add(namePanel, gbc);
700 }
701+
702+ private void initSelectionPanel() {
703+ JPanel selectionPanel = new JPanel(new GridBagLayout());
704+
705+ initTimeOptions(selectionPanel);
706+ initGameOptions(selectionPanel);
707+
708+ GridBagConstraints gbc = new GridBagConstraints();
709+ gbc.gridx = 0;
710+ gbc.gridy = 1;
711+ gbc.weightx = 0;
712+ gbc.anchor = GridBagConstraints.WEST;
713+ gbc.insets = new Insets(5, 5, 5, 5);
714+ add(selectionPanel, gbc);
715+ }
716+
717+ private void initTimeOptions(JPanel selectionPanel) {
718+ JPanel isTimedPanel = new JPanel(new GridBagLayout());
719+ ButtonGroup isTimedRadioButtonGroup = new ButtonGroup();
720+
721+ JLabel timedText = new JLabel("Use time semantics: ");
722+ GridBagConstraints gbc = new GridBagConstraints();
723+ gbc.gridx = 0;
724+ gbc.gridy = 0;
725+ gbc.weightx = 0;
726+ gbc.anchor = GridBagConstraints.WEST;
727+ gbc.insets = new Insets(3, 3, 3, 3);
728+ isTimedPanel.add(timedText, gbc);
729+
730+ JRadioButton untimedNet = new JRadioButton("No");
731+ untimedNet.setSelected(true);
732+ gbc = new GridBagConstraints();
733+ gbc.gridx = 1;
734+ gbc.gridy = 0;
735+ gbc.weightx = 0;
736+ gbc.anchor = GridBagConstraints.WEST;
737+ gbc.insets = new Insets(3, 3, 3, 3);
738+ isTimedPanel.add(untimedNet, gbc);
739+ isTimedRadioButtonGroup.add(untimedNet);
740+
741+ timedNet = new JRadioButton("Yes");
742+ gbc = new GridBagConstraints();
743+ gbc.gridx = 2;
744+ gbc.gridy = 0;
745+ gbc.weightx = 0;
746+ gbc.anchor = GridBagConstraints.WEST;
747+ gbc.insets = new Insets(3, 3, 3, 3);
748+ isTimedPanel.add(timedNet, gbc);
749+ isTimedRadioButtonGroup.add(timedNet);
750+
751+ gbc = new GridBagConstraints();
752+ gbc.gridx = 0;
753+ gbc.gridy = 1;
754+ gbc.weightx = 0;
755+ gbc.anchor = GridBagConstraints.WEST;
756+ gbc.insets = new Insets(5, 5, 5, 5);
757+ selectionPanel.add(isTimedPanel, gbc);
758+ }
759+
760+ private void initGameOptions(JPanel selectionPanel) {
761+ JPanel isGamePanel = new JPanel(new GridBagLayout());
762+ ButtonGroup isGameRadioButtonGroup = new ButtonGroup();
763+
764+ JLabel gameText = new JLabel("Use game semantics:");
765+ GridBagConstraints gbc = new GridBagConstraints();
766+ gbc.gridx = 0;
767+ gbc.gridy = 0;
768+ gbc.weightx = 0;
769+ gbc.anchor = GridBagConstraints.WEST;
770+ gbc.insets = new Insets(3, 3, 3, 3);
771+ isGamePanel.add(gameText, gbc);
772+
773+ JRadioButton nonGameNet = new JRadioButton("No");
774+ nonGameNet.setSelected(true);
775+ gbc = new GridBagConstraints();
776+ gbc.gridx = 1;
777+ gbc.gridy = 0;
778+ gbc.weightx = 0;
779+ gbc.anchor = GridBagConstraints.WEST;
780+ gbc.insets = new Insets(3, 3, 3, 3);
781+ isGamePanel.add(nonGameNet, gbc);
782+ isGameRadioButtonGroup.add(nonGameNet);
783+
784+ gameNet = new JRadioButton("Yes");
785+ gbc = new GridBagConstraints();
786+ gbc.gridx = 2;
787+ gbc.gridy = 0;
788+ gbc.weightx = 0;
789+ gbc.anchor = GridBagConstraints.WEST;
790+ gbc.insets = new Insets(3, 3, 3, 3);
791+ isGamePanel.add(gameNet, gbc);
792+ isGameRadioButtonGroup.add(gameNet);
793+
794+ gbc = new GridBagConstraints();
795+ gbc.gridx = 0;
796+ gbc.gridy = 2;
797+ gbc.anchor = GridBagConstraints.EAST;
798+ gbc.insets = new Insets(5, 5, 5, 5);
799+ selectionPanel.add(isGamePanel, gbc);
800+ }
801 }
802
803=== modified file 'src/pipe/gui/widgets/QueryPane.java'
804--- src/pipe/gui/widgets/QueryPane.java 2020-05-27 13:15:44 +0000
805+++ src/pipe/gui/widgets/QueryPane.java 2020-08-03 12:48:32 +0000
806@@ -320,31 +320,18 @@
807 addQueryButton.setPreferredSize(dimension);
808 addQueryButton.setToolTipText(toolTipNewQuery);
809 addQueryButton.addActionListener(new ActionListener() {
810- public void actionPerformed(ActionEvent e) {
811- int openCTLDialog = JOptionPane.YES_OPTION;
812- boolean netIsUntimed = tabContent.network().isUntimed();
813- String optionText = "Do you want to create a CTL query (use for untimed nets) \n or a Reachability query (use for timed nets)?";
814-
815- // YES_OPTION = CTL dialog, NO_OPTION = Reachability dialog
816- Object[] options = {
817- "CTL",
818- "Reachability"};
819-
820- TAPNQuery q = null;
821- if(netIsUntimed){
822- openCTLDialog = JOptionPane.showOptionDialog(CreateGui.getApp(), optionText, "Query Dialog", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
823- if(openCTLDialog == JOptionPane.YES_OPTION){
824- q = CTLQueryDialog.showQueryDialogue(CTLQueryDialog.QueryDialogueOption.Save, null, tabContent.network(), tabContent.getGuiModels());
825- } else if(openCTLDialog == JOptionPane.NO_OPTION){
826- q = QueryDialog.showQueryDialogue(QueryDialogueOption.Save, null, tabContent.network(), tabContent.getGuiModels());
827- }
828- } else{
829+ public void actionPerformed(ActionEvent e) {
830+
831+ TAPNQuery q;
832+ if (!tabContent.isNetTimed()){
833+ q = CTLQueryDialog.showQueryDialogue(CTLQueryDialog.QueryDialogueOption.Save, null, tabContent.network(), tabContent.getGuiModels());
834+ } else {
835 q = QueryDialog.showQueryDialogue(QueryDialogueOption.Save, null, tabContent.network(), tabContent.getGuiModels());
836 }
837- if (q != null) {
838- undoManager.addNewEdit(new AddQueryCommand(q, tabContent));
839- addQuery(q);
840- }
841+
842+ undoManager.addNewEdit(new AddQueryCommand(q, tabContent));
843+ addQuery(q);
844+
845 updateQueryButtons();
846 }
847 });
848@@ -496,7 +483,7 @@
849 tempFile = File.createTempFile(CreateGui.getAppGui().getCurrentTabName(), ".xml");
850
851 TabContent tab = CreateGui.getApp().getCurrentTab();
852- tab.writeNetToFile(tempFile, selectedQueries);
853+ tab.writeNetToFile(tempFile, selectedQueries, tab.getLens());
854 BatchProcessingDialog.showBatchProcessingDialog(queryList);
855 tempFile.deleteOnExit();
856 if(tempFile == null) {

Subscribers

People subscribed via source and target branches