Merge lp:~tapaal-contributor/tapaal/undo-redo-batchprocessing-3.6-1870904 into lp:tapaal

Proposed by Peter Haahr Taankvist
Status: Rejected
Rejected by: Kenneth Yrke Jørgensen
Proposed branch: lp:~tapaal-contributor/tapaal/undo-redo-batchprocessing-3.6-1870904
Merge into: lp:tapaal
Diff against target: 463 lines (+208/-22) (has conflicts)
8 files modified
src/dk/aau/cs/gui/BatchProcessingDialog.java (+51/-21)
src/dk/aau/cs/gui/TabContent.java (+8/-0)
src/dk/aau/cs/gui/undo/MakePlaceNewSharedMultiCommand.java (+16/-0)
src/dk/aau/cs/gui/undo/MakePlaceSharedCommand.java (+6/-0)
src/dk/aau/cs/verification/batchProcessing/Undo/AddFileCommand.java (+34/-0)
src/dk/aau/cs/verification/batchProcessing/Undo/RemoveFileCommand.java (+35/-0)
src/net/tapaal/TAPAAL.java (+1/-1)
src/pipe/gui/undo/UndoManager.java (+57/-0)
Text conflict in src/dk/aau/cs/gui/BatchProcessingDialog.java
Text conflict in src/dk/aau/cs/gui/TabContent.java
Text conflict in src/dk/aau/cs/gui/undo/MakePlaceNewSharedMultiCommand.java
Text conflict in src/dk/aau/cs/gui/undo/MakePlaceSharedCommand.java
Text conflict in src/pipe/gui/undo/UndoManager.java
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/undo-redo-batchprocessing-3.6-1870904
Reviewer Review Type Date Requested Status
Jiri Srba Pending
Review via email: mp+383459@code.launchpad.net

Commit message

Can now undo/redo adding/removing files in batch processing in 3.6

To post a comment you must log in.

Unmerged revisions

1050. By Peter Haahr Taankvist

Add files

1049. By Peter Haahr Taankvist

Add undo/redo functionality when adding/removing files in batch processing

1048. By Jiri Srba

merged in lp:~tapaal-contributor/tapaal/fix-shared-places-exception-1871091 fixing exceptions in component copying and shared places

1047. By Jiri Srba

merged in lp:~tapaal-contributor/tapaal/fix-positionalInfo-detection-1870899 fixing positional info loading for PNML files

1046. By Jiri Srba

merged in lp:~tapaal-contributor/tapaal/shared-place-transition-rename-1871091 fixing problem with renaming of shared places

1045. By Jiri Srba

merged in lp:~tapaal-contributor/tapaal/pnml-disable-buttons-1868535 fixing enabled buttons when pnml file open fails

1044. By Jiri Srba

merged in lp:~tapaal-contributor/tapaal/open-on-windows-1868525 fixing .xml file open on windows

1043. By <email address hidden>

changed version number to 3.6.1 - this is the release version

1042. By <email address hidden>

changed year from 2019 to 2020

1041. By Jiri Srba

lp:~tapaal-contributor/tapaal/select-all-disable-1835873 fixed focus issues when changing template

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/BatchProcessingDialog.java'
2--- src/dk/aau/cs/gui/BatchProcessingDialog.java 2020-04-18 13:49:06 +0000
3+++ src/dk/aau/cs/gui/BatchProcessingDialog.java 2020-05-05 19:33:18 +0000
4@@ -1,15 +1,6 @@
5 package dk.aau.cs.gui;
6
7-import java.awt.Color;
8-import java.awt.Component;
9-import java.awt.Dimension;
10-import java.awt.FlowLayout;
11-import java.awt.Frame;
12-import java.awt.GridBagConstraints;
13-import java.awt.GridBagLayout;
14-import java.awt.GridLayout;
15-import java.awt.Insets;
16-import java.awt.Point;
17+import java.awt.*;
18 import java.awt.event.ActionEvent;
19 import java.awt.event.ActionListener;
20 import java.awt.event.KeyAdapter;
21@@ -23,6 +14,7 @@
22 import java.util.Comparator;
23 import java.util.List;
24
25+<<<<<<< TREE
26 import javax.swing.AbstractAction;
27 import javax.swing.BorderFactory;
28 import javax.swing.ButtonGroup;
29@@ -42,9 +34,10 @@
30 import javax.swing.JTable;
31 import javax.swing.ListSelectionModel;
32 import javax.swing.SwingConstants;
33+=======
34+import javax.swing.*;
35+>>>>>>> MERGE-SOURCE
36 import javax.swing.SwingWorker.StateValue;
37-import javax.swing.Timer;
38-import javax.swing.ToolTipManager;
39 import javax.swing.border.Border;
40 import javax.swing.event.ChangeEvent;
41 import javax.swing.event.ChangeListener;
42@@ -53,10 +46,18 @@
43 import javax.swing.table.TableModel;
44 import javax.swing.table.TableRowSorter;
45
46+import dk.aau.cs.gui.undo.Command;
47+import dk.aau.cs.verification.batchProcessing.Undo.AddFileCommand;
48+import dk.aau.cs.verification.batchProcessing.Undo.RemoveFileCommand;
49 import pipe.dataLayer.TAPNQuery;
50 import pipe.dataLayer.TAPNQuery.SearchOption;
51 import pipe.gui.CreateGui;
52+<<<<<<< TREE
53 import net.tapaal.swinghelpers.CustomJSpinner;
54+=======
55+import pipe.gui.undo.UndoManager;
56+import pipe.gui.widgets.CustomJSpinner;
57+>>>>>>> MERGE-SOURCE
58 import pipe.gui.widgets.EscapableDialog;
59 import pipe.gui.widgets.filebrowser.FileBrowser;
60 import pipe.gui.widgets.QueryPane;
61@@ -261,6 +262,7 @@
62 private static int memoryTimerCount = 0;
63 private static int memoryTimerMode = 0;
64 private static int peakMemory = -1;
65+ private UndoManager undoManager = new UndoManager(null,null,null);
66
67 private void startMemoryTimer(){
68 if(memoryTimer.isRunning()){
69@@ -345,6 +347,7 @@
70 this.ListOfQueries = ListOfQueries;
71
72 initComponents();
73+ makeShortcuts();
74 //Runs the BatchProcessing if it is called from the QueryPane
75 if(!(isQueryListEmpty())) {
76 process();
77@@ -489,24 +492,27 @@
78
79 File[] filesArray = browser.openFiles();
80 if (filesArray.length>0) {
81+ undoManager.newEdit();
82 for (File file : filesArray) {
83 lastPath = file.getParent();
84 if (!files.contains(file)) {
85- files.add(file);
86- listModel.addElement(file);
87+ Command c = new AddFileCommand(listModel,file,files,this);
88+ c.redo();
89+ undoManager.addEdit(c);
90+
91 }
92 }
93-
94 enableButtons();
95-
96 }
97 }
98
99 private void removeSelectedFiles() {
100+ undoManager.newEdit();
101 for (Object o : fileList.getSelectedValuesList()) {
102 File file = (File) o;
103- files.remove(file);
104- listModel.removeElement(file);
105+ Command c = new RemoveFileCommand(listModel, file,files,this);
106+ c.redo();
107+ undoManager.addEdit(c);
108 }
109
110 enableButtons();
111@@ -1408,8 +1414,13 @@
112 }
113
114 private void clearFiles() {
115- files.clear();
116- listModel.removeAllElements();
117+ undoManager.newEdit();
118+ for (Object o : listModel.toArray()) {
119+ File file = (File)o;
120+ Command c = new RemoveFileCommand(listModel,file, files, this );
121+ c.redo();
122+ undoManager.addEdit(c);
123+ }
124 }
125
126 private void disableButtonsDuringProcessing() {
127@@ -1423,7 +1434,7 @@
128 disableVerificationOptionsButtons();
129 }
130
131- private void enableButtons() {
132+ public void enableButtons() {
133 fileList.setEnabled(true);
134 addFilesButton.setEnabled(true);
135
136@@ -1444,6 +1455,25 @@
137
138 enabledVerificationOptionButtons();
139 }
140+ private void makeShortcuts(){
141+ int shortcutkey = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
142+ ActionMap am = splitpane.getActionMap();
143+ am.put("undo", new AbstractAction() {
144+ @Override
145+ public void actionPerformed(ActionEvent e) {
146+ undoManager.undo();
147+ }
148+ });
149+ am.put("redo", new AbstractAction() {
150+ @Override
151+ public void actionPerformed(ActionEvent e) {
152+ undoManager.redo();
153+ }
154+ });
155+ InputMap im = splitpane.getInputMap(JPanel.WHEN_IN_FOCUSED_WINDOW);
156+ im.put(KeyStroke.getKeyStroke('Z', shortcutkey), "undo");
157+ im.put(KeyStroke.getKeyStroke('Y', shortcutkey), "redo");
158+ }
159
160 // Custom cell renderer for the Query Column of the result table display the
161 // property of the query
162
163=== modified file 'src/dk/aau/cs/gui/TabContent.java'
164--- src/dk/aau/cs/gui/TabContent.java 2020-04-30 12:51:14 +0000
165+++ src/dk/aau/cs/gui/TabContent.java 2020-05-05 19:33:18 +0000
166@@ -51,6 +51,7 @@
167 private TimedArcPetriNetNetwork tapnNetwork = new TimedArcPetriNetNetwork();
168 private HashMap<TimedArcPetriNet, DataLayer> guiModels = new HashMap<TimedArcPetriNet, DataLayer>();
169 private HashMap<TimedArcPetriNet, Zoomer> zoomLevels = new HashMap<TimedArcPetriNet, Zoomer>();
170+<<<<<<< TREE
171
172
173 private UndoManager undoManager = new UndoManager();
174@@ -182,6 +183,9 @@
175
176 private HashMap<TimedArcPetriNet, Boolean> hasPositionalInfos = new HashMap<TimedArcPetriNet, Boolean>();
177
178+=======
179+ private HashMap<TimedArcPetriNet, Boolean> hasPositionalInfos = new HashMap<TimedArcPetriNet, Boolean>();
180+>>>>>>> MERGE-SOURCE
181 private JScrollPane drawingSurfaceScroller;
182 private JScrollPane editorSplitPaneScroller;
183 private JScrollPane animatorSplitPaneScroller;
184@@ -229,7 +233,11 @@
185 for (TimedArcPetriNet net : tapnNetwork.allTemplates()) {
186 guiModels.put(net, new DataLayer());
187 zoomLevels.put(net, new Zoomer());
188+<<<<<<< TREE
189 hasPositionalInfos.put(net, Boolean.FALSE);
190+=======
191+ hasPositionalInfos.put(net, new Boolean(false));
192+>>>>>>> MERGE-SOURCE
193 }
194
195 drawingSurface = new DrawingSurfaceImpl(new DataLayer(), this, managerRef);
196
197=== modified file 'src/dk/aau/cs/gui/undo/MakePlaceNewSharedMultiCommand.java'
198--- src/dk/aau/cs/gui/undo/MakePlaceNewSharedMultiCommand.java 2020-04-18 14:41:05 +0000
199+++ src/dk/aau/cs/gui/undo/MakePlaceNewSharedMultiCommand.java 2020-05-05 19:33:18 +0000
200@@ -36,6 +36,7 @@
201 boolean first = true;
202 for(Template template : context.tabContent().allTemplates()) {
203 TimedPlaceComponent component = (TimedPlaceComponent)template.guiModel().getPlaceByName(place.getName());
204+<<<<<<< TREE
205
206 if (component != null) {
207 if (first) { //We make a new shared place with the first place
208@@ -50,6 +51,21 @@
209 commands.add(command);
210 }
211 }
212+=======
213+ //We make a new shared place with the first place
214+ if(component != null && i < 1) {
215+ command = new MakePlaceNewSharedCommand(template.model(), newSharedName, component.underlyingPlace(), component, context.tabContent(), true);
216+ command.redo();
217+ sharedPlace = (SharedPlace)component.underlyingPlace();
218+ commands.add(command);
219+ i++;
220+ //For the rest we make them shared with the recently made place
221+ } else if (component != null && i >= 1){
222+ command = new MakePlaceSharedCommand(context.activeModel(), sharedPlace, component.underlyingPlace(), component, context.tabContent(), true);
223+ command.redo();
224+ commands.add(command);
225+ }
226+>>>>>>> MERGE-SOURCE
227 }
228 }
229
230
231=== modified file 'src/dk/aau/cs/gui/undo/MakePlaceSharedCommand.java'
232--- src/dk/aau/cs/gui/undo/MakePlaceSharedCommand.java 2020-04-18 14:41:05 +0000
233+++ src/dk/aau/cs/gui/undo/MakePlaceSharedCommand.java 2020-05-05 19:33:18 +0000
234@@ -27,9 +27,15 @@
235
236 private final Hashtable<TAPNQuery, TAPNQuery> newQueryToOldQueryMapping;
237 private final List<TimedToken> oldTokens;
238+<<<<<<< TREE
239 private final TabContent currentTab;
240
241 public MakePlaceSharedCommand(TimedArcPetriNet tapn, SharedPlace sharedPlace, TimedPlace place, TimedPlaceComponent placeComponent, TabContent currentTab, boolean multishare){
242+=======
243+ private TabContent currentTab;
244+
245+ public MakePlaceSharedCommand(TimedArcPetriNet tapn, SharedPlace sharedPlace, TimedPlace place, TimedPlaceComponent placeComponent, TabContent currentTab, boolean multishare){
246+>>>>>>> MERGE-SOURCE
247 Require.that(tapn != null, "tapn cannot be null");
248 Require.that(sharedPlace != null, "sharedPlace cannot be null");
249 Require.that(place != null, "timedPlace cannot be null");
250
251=== added directory 'src/dk/aau/cs/verification/batchProcessing/Undo'
252=== added file 'src/dk/aau/cs/verification/batchProcessing/Undo/AddFileCommand.java'
253--- src/dk/aau/cs/verification/batchProcessing/Undo/AddFileCommand.java 1970-01-01 00:00:00 +0000
254+++ src/dk/aau/cs/verification/batchProcessing/Undo/AddFileCommand.java 2020-05-05 19:33:18 +0000
255@@ -0,0 +1,34 @@
256+package dk.aau.cs.verification.batchProcessing.Undo;
257+
258+import dk.aau.cs.gui.BatchProcessingDialog;
259+import dk.aau.cs.gui.undo.Command;
260+
261+import javax.swing.*;
262+import java.io.File;
263+import java.util.List;
264+
265+public class AddFileCommand extends Command {
266+ private DefaultListModel listModel;
267+ List<File> files;
268+ File file;
269+ private BatchProcessingDialog dialog;
270+ public AddFileCommand(DefaultListModel listModel, File file, List<File> files, BatchProcessingDialog dialog){
271+ this.listModel = listModel;
272+ this.file = file;
273+ this.files = files;
274+ this.dialog = dialog;
275+ }
276+ @Override
277+ public void redo() {
278+ files.add(file);
279+ listModel.addElement(file);
280+ dialog.enableButtons();
281+ }
282+
283+ @Override
284+ public void undo() {
285+ files.remove(file);
286+ listModel.removeElement(file);
287+ dialog.enableButtons();
288+ }
289+}
290
291=== added file 'src/dk/aau/cs/verification/batchProcessing/Undo/RemoveFileCommand.java'
292--- src/dk/aau/cs/verification/batchProcessing/Undo/RemoveFileCommand.java 1970-01-01 00:00:00 +0000
293+++ src/dk/aau/cs/verification/batchProcessing/Undo/RemoveFileCommand.java 2020-05-05 19:33:18 +0000
294@@ -0,0 +1,35 @@
295+package dk.aau.cs.verification.batchProcessing.Undo;
296+
297+import dk.aau.cs.gui.BatchProcessingDialog;
298+import dk.aau.cs.gui.undo.Command;
299+
300+import javax.swing.*;
301+import java.io.File;
302+import java.util.List;
303+
304+public class RemoveFileCommand extends Command {
305+ private DefaultListModel listModel;
306+ List<File> files;
307+ File file;
308+ private BatchProcessingDialog dialog;
309+ public RemoveFileCommand(DefaultListModel listModel, File file, List<File> files, BatchProcessingDialog dialog){
310+ this.listModel = listModel;
311+ this.file = file;
312+ this.files = files;
313+ this.dialog = dialog;
314+ }
315+ @Override
316+ public void redo() {
317+ files.remove(file);
318+ listModel.removeElement(file);
319+ dialog.enableButtons();
320+ }
321+
322+ @Override
323+ public void undo() {
324+ files.add(file);
325+ listModel.addElement(file);
326+ dialog.enableButtons();
327+ }
328+}
329+
330
331=== modified file 'src/net/tapaal/TAPAAL.java'
332--- src/net/tapaal/TAPAAL.java 2020-04-18 16:13:35 +0000
333+++ src/net/tapaal/TAPAAL.java 2020-05-05 19:33:18 +0000
334@@ -39,7 +39,7 @@
335 public class TAPAAL {
336
337 public static final String TOOLNAME = "TAPAAL";
338- public static final String VERSION = "DEV";
339+ public static final String VERSION = "3.6.1";
340
341 public static String getProgramName(){
342 return "" + TAPAAL.TOOLNAME + " " + TAPAAL.VERSION;
343
344=== modified file 'src/pipe/gui/undo/UndoManager.java'
345--- src/pipe/gui/undo/UndoManager.java 2020-04-03 11:05:40 +0000
346+++ src/pipe/gui/undo/UndoManager.java 2020-05-05 19:33:18 +0000
347@@ -38,10 +38,21 @@
348 /**
349 * Creates a new instance of UndoManager
350 */
351+<<<<<<< TREE
352 public UndoManager() {
353
354 app.ifPresent(a -> a.setUndoActionEnabled(false));
355 app.ifPresent(a -> a.setRedoActionEnabled(false));
356+=======
357+ public UndoManager(DrawingSurfaceImpl _view, DataLayer _model, GuiFrame _app) {
358+ view = _view;
359+ guiModel = _model;
360+ app = _app;
361+ if(app != null) {
362+ app.setUndoActionEnabled(false);
363+ app.setRedoActionEnabled(false);
364+ }
365+>>>>>>> MERGE-SOURCE
366 for (int i = 0; i < UNDO_BUFFER_CAPACITY; i++) {
367 edits.add(null);
368 }
369@@ -50,7 +61,14 @@
370 public void redo() {
371
372 if (undoneEdits > 0) {
373+<<<<<<< TREE
374 checkArcBeingDrawn();
375+=======
376+ if(app != null && view != null) {
377+ checkArcBeingDrawn();
378+ checkMode();
379+ }
380+>>>>>>> MERGE-SOURCE
381
382 // The currentEdit to redo
383 for (Command command : edits.get(indexOfNextAdd)) {
384@@ -59,10 +77,21 @@
385 indexOfNextAdd = (indexOfNextAdd + 1) % UNDO_BUFFER_CAPACITY;
386 sizeOfBuffer++;
387 undoneEdits--;
388+<<<<<<< TREE
389 if (undoneEdits == 0) {
390 app.ifPresent(a -> a.setRedoActionEnabled(false));
391+=======
392+ if(app != null) {
393+ if (undoneEdits == 0) {
394+ app.setRedoActionEnabled(false);
395+ }
396+ app.setUndoActionEnabled(true);
397+>>>>>>> MERGE-SOURCE
398 }
399+<<<<<<< TREE
400 app.ifPresent(a -> a.setUndoActionEnabled(true));
401+=======
402+>>>>>>> MERGE-SOURCE
403 }
404 }
405
406@@ -79,7 +108,14 @@
407 public void undo() {
408
409 if (sizeOfBuffer > 0) {
410+<<<<<<< TREE
411 checkArcBeingDrawn();
412+=======
413+ if(app != null && view != null) {
414+ checkArcBeingDrawn();
415+ checkMode();
416+ }
417+>>>>>>> MERGE-SOURCE
418
419 if (--indexOfNextAdd < 0) {
420 indexOfNextAdd += UNDO_BUFFER_CAPACITY;
421@@ -92,11 +128,22 @@
422 for (int i = currentEdit.size() - 1; i >= 0; i--) {
423 currentEdit.get(i).undo();
424 }
425+<<<<<<< TREE
426
427 if (sizeOfBuffer == 0) {
428 app.ifPresent(a -> a.setUndoActionEnabled(false));
429+=======
430+ if(app != null) {
431+ if (sizeOfBuffer == 0) {
432+ app.setUndoActionEnabled(false);
433+ }
434+ app.setRedoActionEnabled(true);
435+>>>>>>> MERGE-SOURCE
436 }
437+<<<<<<< TREE
438 app.ifPresent(a -> a.setRedoActionEnabled(true));
439+=======
440+>>>>>>> MERGE-SOURCE
441 }
442 }
443
444@@ -116,9 +163,19 @@
445 }
446
447 undoneEdits = 0;
448+<<<<<<< TREE
449 app.ifPresent(a -> a.setUndoActionEnabled(true));
450 app.ifPresent(a -> a.setRedoActionEnabled(false));
451 CreateGui.getCurrentTab().setNetChanged(true);
452+=======
453+ if(app != null) {
454+ app.setUndoActionEnabled(true);
455+ app.setRedoActionEnabled(false);
456+ }
457+ if(view != null){
458+ view.setNetChanged(true);
459+ }
460+>>>>>>> MERGE-SOURCE
461
462 ArrayList<Command> compoundEdit = new ArrayList<Command>();
463 edits.set(indexOfNextAdd, compoundEdit);

Subscribers

People subscribed via source and target branches