Merge lp:~tapaal-contributor/tapaal/Gui-freeze-1896457 into lp:tapaal

Proposed by Peter Haahr Taankvist
Status: Merged
Approved by: Jiri Srba
Approved revision: 1105
Merged at revision: 1109
Proposed branch: lp:~tapaal-contributor/tapaal/Gui-freeze-1896457
Merge into: lp:tapaal
Diff against target: 218 lines (+53/-18)
6 files modified
src/dk/aau/cs/io/LoadedQueries.java (+18/-0)
src/dk/aau/cs/io/TapnXmlLoader.java (+6/-3)
src/dk/aau/cs/io/queries/QueryLoader.java (+7/-5)
src/dk/aau/cs/io/queries/SUMOQueryLoader.java (+14/-3)
src/dk/aau/cs/io/queries/TAPNQueryLoader.java (+5/-5)
src/dk/aau/cs/io/queries/XMLQueryLoader.java (+3/-2)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/Gui-freeze-1896457
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Peter Haahr Taankvist (community) Needs Resubmitting
Kenneth Yrke Jørgensen Needs Fixing
Review via email: mp+391151@code.launchpad.net

Commit message

I threaded the error/warning messages so that they do not halt the gui thread.

To post a comment you must log in.
Kenneth Yrke Jørgensen (yrke) wrote :

Don't think we should call a gui-popup from a parser, instead use the same pattern as for the XML loader to return a list of messages/warnings.
This way the code can be reused also for other implementation not using the gui, eg. batchprocessing and commandline.

review: Needs Fixing
Peter Haahr Taankvist (ptaank) wrote :

It now returns a LoadedQueries (like LoadedModel) containing the queries and a message. This is added to any other messages from the XML loader.

review: Needs Resubmitting
Kenneth Yrke Jørgensen (yrke) wrote :

branch does not seem to be updated?

1104. By Peter Taankvist <email address hidden> on 2020-10-09

Queryloader returns messages like TapnLoader does

Peter Haahr Taankvist (ptaank) wrote :

Seems the push did not go through. It should be updated now.

review: Needs Resubmitting
review: Needs Fixing
1105. By Peter Taankvist <email address hidden> on 2020-10-30

Clean up

Peter Haahr Taankvist (ptaank) wrote :

Did some requested clean up

review: Needs Resubmitting
Jiri Srba (srba) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'src/dk/aau/cs/io/LoadedQueries.java'
2--- src/dk/aau/cs/io/LoadedQueries.java 1970-01-01 00:00:00 +0000
3+++ src/dk/aau/cs/io/LoadedQueries.java 2020-10-30 12:01:12 +0000
4@@ -0,0 +1,18 @@
5+package dk.aau.cs.io;
6+import dk.aau.cs.model.tapn.TimedArcPetriNetNetwork;
7+import pipe.dataLayer.TAPNQuery;
8+import java.util.Collection;
9+
10+public class LoadedQueries {
11+
12+ private final Collection<TAPNQuery> queries;
13+ private final Collection<String> messages;
14+
15+ public LoadedQueries(Collection<TAPNQuery> queries, Collection<String> messages) {
16+ this.queries = queries;
17+ this.messages = messages;
18+ }
19+
20+ public Collection<TAPNQuery> getQueries(){ return queries; }
21+ public Collection<String> getMessages() { return messages; }
22+}
23
24=== modified file 'src/dk/aau/cs/io/TapnXmlLoader.java'
25--- src/dk/aau/cs/io/TapnXmlLoader.java 2020-08-26 12:29:25 +0000
26+++ src/dk/aau/cs/io/TapnXmlLoader.java 2020-10-30 12:01:12 +0000
27@@ -126,17 +126,20 @@
28 parseSharedTransitions(doc, network);
29
30 Collection<Template> templates = parseTemplates(doc, network, constants);
31- Collection<TAPNQuery> queries = new TAPNQueryLoader(doc, network).parseQueries();
32+ LoadedQueries loadedQueries = new TAPNQueryLoader(doc, network).parseQueries();
33
34+ for(String message : loadedQueries.getMessages()){
35+ messages.add(message);
36+ }
37 network.buildConstraints();
38
39 parseBound(doc, network);
40
41
42 if (hasFeatureTag) {
43- return new LoadedModel(network, templates, queries, messages, lens);
44+ return new LoadedModel(network, templates, loadedQueries.getQueries(), messages, lens);
45 } else {
46- return new LoadedModel(network, templates, queries, messages, null);
47+ return new LoadedModel(network, templates, loadedQueries.getQueries(), messages, null);
48 }
49 }
50
51
52=== modified file 'src/dk/aau/cs/io/queries/QueryLoader.java'
53--- src/dk/aau/cs/io/queries/QueryLoader.java 2017-03-12 00:33:00 +0000
54+++ src/dk/aau/cs/io/queries/QueryLoader.java 2020-10-30 12:01:12 +0000
55@@ -6,6 +6,7 @@
56
57 import javax.swing.JOptionPane;
58
59+import dk.aau.cs.io.LoadedQueries;
60 import pipe.dataLayer.TAPNQuery;
61 import pipe.gui.CreateGui;
62 import dk.aau.cs.TCTL.visitors.VerifyPlaceNamesVisitor;
63@@ -25,7 +26,8 @@
64 boolean queryUsingNonexistentPlaceFound = false;
65 boolean queryUsingNonexistentTransitionFound = false;
66
67- protected boolean showErrorMessage = true;
68+ protected boolean showErrorMessage = true;
69+ protected final Collection<String> messages = new ArrayList<>(10);
70
71 protected TimedArcPetriNetNetwork network;
72
73@@ -33,7 +35,7 @@
74 this.network = network;
75 }
76
77- public Collection<TAPNQuery> parseQueries() {
78+ public LoadedQueries parseQueries() {
79 ArrayList<TAPNQuery> queries = getQueries();
80
81 ArrayList<Tuple<String, String>> templatePlaceNames = getPlaceNames(network);
82@@ -57,14 +59,14 @@
83 }
84
85 if(queryUsingNonexistentPlaceFound && firstQueryParsingWarning && showErrorMessage) {
86- JOptionPane.showMessageDialog(CreateGui.getApp(), ERROR_PARSING_QUERY_MESSAGE, "Error Parsing Query", JOptionPane.ERROR_MESSAGE);
87+ messages.add(ERROR_PARSING_QUERY_MESSAGE);
88 firstQueryParsingWarning = false;
89 } else if(queryUsingNonexistentTransitionFound && firstQueryParsingWarning && showErrorMessage){
90- JOptionPane.showMessageDialog(CreateGui.getApp(), ERROR_PARSING_QUERY_MESSAGE, "Error Parsing Query", JOptionPane.ERROR_MESSAGE);
91+ messages.add(ERROR_PARSING_QUERY_MESSAGE);
92 firstQueryParsingWarning = false;
93 }
94
95- return queries;
96+ return new LoadedQueries(queries,messages);
97 }
98
99 private ArrayList<Tuple<String, String>> getPlaceNames(TimedArcPetriNetNetwork network) {
100
101=== modified file 'src/dk/aau/cs/io/queries/SUMOQueryLoader.java'
102--- src/dk/aau/cs/io/queries/SUMOQueryLoader.java 2020-07-13 13:58:47 +0000
103+++ src/dk/aau/cs/io/queries/SUMOQueryLoader.java 2020-10-30 12:01:12 +0000
104@@ -1,5 +1,6 @@
105 package dk.aau.cs.io.queries;
106
107+import java.awt.*;
108 import java.io.File;
109 import java.io.IOException;
110 import java.nio.file.Files;
111@@ -8,12 +9,14 @@
112 import java.util.regex.Matcher;
113 import java.util.regex.Pattern;
114
115+import dk.aau.cs.io.LoadedQueries;
116 import pipe.dataLayer.TAPNQuery;
117 import pipe.dataLayer.TAPNQuery.ExtrapolationOption;
118 import pipe.dataLayer.TAPNQuery.HashTableSize;
119 import pipe.dataLayer.TAPNQuery.SearchOption;
120 import pipe.dataLayer.TAPNQuery.TraceOption;
121 import pipe.gui.CreateGui;
122+import pipe.gui.MessengerImpl;
123 import pipe.gui.widgets.InclusionPlaces;
124 import dk.aau.cs.TCTL.TCTLAbstractProperty;
125 import dk.aau.cs.TCTL.SUMOParsing.TokenMgrError;
126@@ -74,9 +77,17 @@
127
128 public static void importQueries(File file, TimedArcPetriNetNetwork network){
129 SUMOQueryLoader loader = new SUMOQueryLoader(file, network);
130- Collection<TAPNQuery> queries = loader.parseQueries();
131-
132- for(TAPNQuery query : queries){
133+ LoadedQueries loadedQueries = loader.parseQueries();
134+ if (loadedQueries.getMessages().size() != 0) {
135+ String message = "While loading the net we found one or more warnings: \n\n";
136+ for (String s : loadedQueries.getMessages()) {
137+ message += s + "\n\n";
138+ }
139+
140+ new MessengerImpl().displayInfoMessage(message, "Warning");
141+ }
142+
143+ for(TAPNQuery query : loadedQueries.getQueries()){
144 CreateGui.getCurrentTab().addQuery(query);
145 }
146 }
147
148=== modified file 'src/dk/aau/cs/io/queries/TAPNQueryLoader.java'
149--- src/dk/aau/cs/io/queries/TAPNQueryLoader.java 2020-08-04 08:19:44 +0000
150+++ src/dk/aau/cs/io/queries/TAPNQueryLoader.java 2020-10-30 12:01:12 +0000
151@@ -1,5 +1,6 @@
152 package dk.aau.cs.io.queries;
153
154+import java.awt.*;
155 import java.util.ArrayList;
156 import java.util.List;
157
158@@ -18,6 +19,7 @@
159 import pipe.dataLayer.TAPNQuery.SearchOption;
160 import pipe.dataLayer.TAPNQuery.TraceOption;
161 import pipe.gui.CreateGui;
162+import pipe.gui.MessengerImpl;
163 import pipe.gui.widgets.InclusionPlaces;
164 import pipe.gui.widgets.InclusionPlaces.InclusionPlacesOption;
165 import dk.aau.cs.TCTL.StringPosition;
166@@ -267,11 +269,10 @@
167
168 private TCTLAbstractProperty parseCTLQueryProperty(Node queryElement){
169 TCTLAbstractProperty query = null;
170-
171 try {
172 query = XMLCTLQueryParser.parse(queryElement);
173 } catch (XMLQueryParseException e) {
174- JOptionPane.showMessageDialog(CreateGui.getApp(), ERROR_PARSING_QUERY_MESSAGE, "Error Parsing Query", JOptionPane.ERROR_MESSAGE);
175+ messages.add(ERROR_PARSING_QUERY_MESSAGE);
176 }
177
178 return query;
179@@ -279,13 +280,12 @@
180
181 private TCTLAbstractProperty parseQueryProperty(String queryToParse) {
182 TCTLAbstractProperty query = null;
183-
184 try {
185 query = TAPAALQueryParser.parse(queryToParse);
186 } catch (Exception e) {
187 if(firstQueryParsingWarning) {
188- JOptionPane.showMessageDialog(CreateGui.getApp(), ERROR_PARSING_QUERY_MESSAGE, "Error Parsing Query", JOptionPane.ERROR_MESSAGE);
189- firstQueryParsingWarning = false;
190+ messages.add(ERROR_PARSING_QUERY_MESSAGE);
191+ firstQueryParsingWarning = false;
192 }
193 System.err.println("No query was specified: ");
194 e.printStackTrace();
195
196=== modified file 'src/dk/aau/cs/io/queries/XMLQueryLoader.java'
197--- src/dk/aau/cs/io/queries/XMLQueryLoader.java 2020-07-13 13:58:47 +0000
198+++ src/dk/aau/cs/io/queries/XMLQueryLoader.java 2020-10-30 12:01:12 +0000
199@@ -6,6 +6,7 @@
200 import java.util.Collection;
201 import javax.swing.JOptionPane;
202
203+import dk.aau.cs.io.LoadedQueries;
204 import pipe.dataLayer.TAPNQuery;
205 import pipe.dataLayer.TAPNQuery.ExtrapolationOption;
206 import pipe.dataLayer.TAPNQuery.HashTableSize;
207@@ -122,9 +123,9 @@
208
209 // Suppress default error message
210 loader.showErrorMessage = false;
211- Collection<TAPNQuery> queries = loader.parseQueries();
212+ LoadedQueries loadedQueries = loader.parseQueries();
213
214- for(TAPNQuery query : queries){
215+ for(TAPNQuery query : loadedQueries.getQueries()){
216 CreateGui.getCurrentTab().addQuery(query);
217
218 // Remove successfully parsed queries from list

Subscribers

People subscribed via source and target branches