Merge lp:~tapaal-contributor/tapaal/only-dirs-batch-export-3.6-1870887 into lp:tapaal

Proposed by Peter Haahr Taankvist
Status: Rejected
Rejected by: Kenneth Yrke Jørgensen
Proposed branch: lp:~tapaal-contributor/tapaal/only-dirs-batch-export-3.6-1870887
Merge into: lp:tapaal
Diff against target: 727 lines (+362/-12) (has conflicts)
13 files modified
src/dk/aau/cs/gui/BatchProcessingDialog.java (+67/-0)
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/ExportBatchDialog.java (+14/-3)
src/pipe/gui/undo/TranslatePetriNetObjectEdit.java (+24/-0)
src/pipe/gui/undo/UndoManager.java (+91/-0)
src/pipe/gui/widgets/filebrowser/FileBrowser.java (+3/-2)
src/pipe/gui/widgets/filebrowser/NativeFileBrowser.java (+33/-5)
src/pipe/gui/widgets/filebrowser/NativeFileBrowserFallback.java (+30/-1)
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/ExportBatchDialog.java
Text conflict in src/pipe/gui/undo/TranslatePetriNetObjectEdit.java
Text conflict in src/pipe/gui/undo/UndoManager.java
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/only-dirs-batch-export-3.6-1870887
Reviewer Review Type Date Requested Status
Jiri Srba Pending
Review via email: mp+383884@code.launchpad.net

Commit message

Batch export now only shows dirs in save dialog for windows and linux and has better functionality for mac.

To post a comment you must log in.

Unmerged revisions

1051. By Peter Taankvist <email address hidden>

Batch export now only shows dirs when selecting destination

1050. By Jiri Srba

merged in lp:~tapaal-contributor/tapaal/undo-redo-batchprocessing-3.6-1870904 fixing redo/undo in batch processing in the file selection dialog

1049. By Jiri Srba

merged in lp:~tapaal-contributor/tapaal/undo-redo-update-scrollbar-3.6-1875174 fixing unde/redo if a an object is placed outside of the drawing area

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

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-05-03 09:49:19 +0000
3+++ src/dk/aau/cs/gui/BatchProcessingDialog.java 2020-05-13 15:54:44 +0000
4@@ -24,14 +24,25 @@
5 import javax.swing.table.TableModel;
6 import javax.swing.table.TableRowSorter;
7
8+<<<<<<< TREE
9 import dk.aau.cs.gui.undo.AddFileBatchProcessingCommand;
10 import dk.aau.cs.gui.undo.Command;
11 import dk.aau.cs.gui.undo.RemoveFileBatchProcessingCommand;
12+=======
13+import dk.aau.cs.gui.undo.Command;
14+import dk.aau.cs.verification.batchProcessing.Undo.AddFileCommand;
15+import dk.aau.cs.verification.batchProcessing.Undo.RemoveFileCommand;
16+>>>>>>> MERGE-SOURCE
17 import pipe.dataLayer.TAPNQuery;
18 import pipe.dataLayer.TAPNQuery.SearchOption;
19 import pipe.gui.CreateGui;
20+<<<<<<< TREE
21 import net.tapaal.swinghelpers.CustomJSpinner;
22 import pipe.gui.undo.UndoManager;
23+=======
24+import pipe.gui.undo.UndoManager;
25+import pipe.gui.widgets.CustomJSpinner;
26+>>>>>>> MERGE-SOURCE
27 import pipe.gui.widgets.EscapableDialog;
28 import pipe.gui.widgets.filebrowser.FileBrowser;
29 import pipe.gui.widgets.QueryPane;
30@@ -237,6 +248,7 @@
31 private static int memoryTimerCount = 0;
32 private static int memoryTimerMode = 0;
33 private static int peakMemory = -1;
34+ private UndoManager undoManager = new UndoManager(null,null,null);
35
36 private void startMemoryTimer(){
37 if(memoryTimer.isRunning()){
38@@ -465,25 +477,51 @@
39 FileBrowser browser = FileBrowser.constructor("Timed-Arc Petri Nets","tapn", "xml", lastPath);
40 File[] filesArray = browser.openFiles();
41 if (filesArray.length>0) {
42+<<<<<<< TREE
43 undoManager.newEdit();
44 for (File file : filesArray) {
45+=======
46+ undoManager.newEdit();
47+ for (File file : filesArray) {
48+>>>>>>> MERGE-SOURCE
49 lastPath = file.getParent();
50 if (!files.contains(file)) {
51+<<<<<<< TREE
52 Command c = new AddFileBatchProcessingCommand(listModel,file, files, this );
53 c.redo();
54 undoManager.addEdit(c);
55+=======
56+ Command c = new AddFileCommand(listModel,file,files,this);
57+ c.redo();
58+ undoManager.addEdit(c);
59+
60+>>>>>>> MERGE-SOURCE
61 }
62 }
63+<<<<<<< TREE
64+=======
65+ enableButtons();
66+>>>>>>> MERGE-SOURCE
67 }
68 }
69
70 private void removeSelectedFiles() {
71+<<<<<<< TREE
72 undoManager.newEdit();
73+=======
74+ undoManager.newEdit();
75+>>>>>>> MERGE-SOURCE
76 for (Object o : fileList.getSelectedValuesList()) {
77 File file = (File) o;
78+<<<<<<< TREE
79 Command c = new RemoveFileBatchProcessingCommand(listModel,file, files, this );
80 c.redo();
81 undoManager.addEdit(c);
82+=======
83+ Command c = new RemoveFileCommand(listModel, file,files,this);
84+ c.redo();
85+ undoManager.addEdit(c);
86+>>>>>>> MERGE-SOURCE
87 }
88 }
89
90@@ -1383,6 +1421,7 @@
91 }
92
93 private void clearFiles() {
94+<<<<<<< TREE
95 undoManager.newEdit();
96
97 for (Object o : listModel.toArray()) {
98@@ -1391,6 +1430,15 @@
99 c.redo();
100 undoManager.addEdit(c);
101 }
102+=======
103+ undoManager.newEdit();
104+ for (Object o : listModel.toArray()) {
105+ File file = (File)o;
106+ Command c = new RemoveFileCommand(listModel,file, files, this );
107+ c.redo();
108+ undoManager.addEdit(c);
109+ }
110+>>>>>>> MERGE-SOURCE
111 }
112
113 private void disableButtonsDuringProcessing() {
114@@ -1425,6 +1473,25 @@
115
116 enabledVerificationOptionButtons();
117 }
118+ private void makeShortcuts(){
119+ int shortcutkey = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
120+ ActionMap am = splitpane.getActionMap();
121+ am.put("undo", new AbstractAction() {
122+ @Override
123+ public void actionPerformed(ActionEvent e) {
124+ undoManager.undo();
125+ }
126+ });
127+ am.put("redo", new AbstractAction() {
128+ @Override
129+ public void actionPerformed(ActionEvent e) {
130+ undoManager.redo();
131+ }
132+ });
133+ InputMap im = splitpane.getInputMap(JPanel.WHEN_IN_FOCUSED_WINDOW);
134+ im.put(KeyStroke.getKeyStroke('Z', shortcutkey), "undo");
135+ im.put(KeyStroke.getKeyStroke('Y', shortcutkey), "redo");
136+ }
137
138 // Custom cell renderer for the Query Column of the result table display the
139 // property of the query
140
141=== modified file 'src/dk/aau/cs/gui/TabContent.java'
142--- src/dk/aau/cs/gui/TabContent.java 2020-04-30 12:51:14 +0000
143+++ src/dk/aau/cs/gui/TabContent.java 2020-05-13 15:54:44 +0000
144@@ -51,6 +51,7 @@
145 private TimedArcPetriNetNetwork tapnNetwork = new TimedArcPetriNetNetwork();
146 private HashMap<TimedArcPetriNet, DataLayer> guiModels = new HashMap<TimedArcPetriNet, DataLayer>();
147 private HashMap<TimedArcPetriNet, Zoomer> zoomLevels = new HashMap<TimedArcPetriNet, Zoomer>();
148+<<<<<<< TREE
149
150
151 private UndoManager undoManager = new UndoManager();
152@@ -182,6 +183,9 @@
153
154 private HashMap<TimedArcPetriNet, Boolean> hasPositionalInfos = new HashMap<TimedArcPetriNet, Boolean>();
155
156+=======
157+ private HashMap<TimedArcPetriNet, Boolean> hasPositionalInfos = new HashMap<TimedArcPetriNet, Boolean>();
158+>>>>>>> MERGE-SOURCE
159 private JScrollPane drawingSurfaceScroller;
160 private JScrollPane editorSplitPaneScroller;
161 private JScrollPane animatorSplitPaneScroller;
162@@ -229,7 +233,11 @@
163 for (TimedArcPetriNet net : tapnNetwork.allTemplates()) {
164 guiModels.put(net, new DataLayer());
165 zoomLevels.put(net, new Zoomer());
166+<<<<<<< TREE
167 hasPositionalInfos.put(net, Boolean.FALSE);
168+=======
169+ hasPositionalInfos.put(net, new Boolean(false));
170+>>>>>>> MERGE-SOURCE
171 }
172
173 drawingSurface = new DrawingSurfaceImpl(new DataLayer(), this, managerRef);
174
175=== modified file 'src/dk/aau/cs/gui/undo/MakePlaceNewSharedMultiCommand.java'
176--- src/dk/aau/cs/gui/undo/MakePlaceNewSharedMultiCommand.java 2020-04-18 14:41:05 +0000
177+++ src/dk/aau/cs/gui/undo/MakePlaceNewSharedMultiCommand.java 2020-05-13 15:54:44 +0000
178@@ -36,6 +36,7 @@
179 boolean first = true;
180 for(Template template : context.tabContent().allTemplates()) {
181 TimedPlaceComponent component = (TimedPlaceComponent)template.guiModel().getPlaceByName(place.getName());
182+<<<<<<< TREE
183
184 if (component != null) {
185 if (first) { //We make a new shared place with the first place
186@@ -50,6 +51,21 @@
187 commands.add(command);
188 }
189 }
190+=======
191+ //We make a new shared place with the first place
192+ if(component != null && i < 1) {
193+ command = new MakePlaceNewSharedCommand(template.model(), newSharedName, component.underlyingPlace(), component, context.tabContent(), true);
194+ command.redo();
195+ sharedPlace = (SharedPlace)component.underlyingPlace();
196+ commands.add(command);
197+ i++;
198+ //For the rest we make them shared with the recently made place
199+ } else if (component != null && i >= 1){
200+ command = new MakePlaceSharedCommand(context.activeModel(), sharedPlace, component.underlyingPlace(), component, context.tabContent(), true);
201+ command.redo();
202+ commands.add(command);
203+ }
204+>>>>>>> MERGE-SOURCE
205 }
206 }
207
208
209=== modified file 'src/dk/aau/cs/gui/undo/MakePlaceSharedCommand.java'
210--- src/dk/aau/cs/gui/undo/MakePlaceSharedCommand.java 2020-04-18 14:41:05 +0000
211+++ src/dk/aau/cs/gui/undo/MakePlaceSharedCommand.java 2020-05-13 15:54:44 +0000
212@@ -27,9 +27,15 @@
213
214 private final Hashtable<TAPNQuery, TAPNQuery> newQueryToOldQueryMapping;
215 private final List<TimedToken> oldTokens;
216+<<<<<<< TREE
217 private final TabContent currentTab;
218
219 public MakePlaceSharedCommand(TimedArcPetriNet tapn, SharedPlace sharedPlace, TimedPlace place, TimedPlaceComponent placeComponent, TabContent currentTab, boolean multishare){
220+=======
221+ private TabContent currentTab;
222+
223+ public MakePlaceSharedCommand(TimedArcPetriNet tapn, SharedPlace sharedPlace, TimedPlace place, TimedPlaceComponent placeComponent, TabContent currentTab, boolean multishare){
224+>>>>>>> MERGE-SOURCE
225 Require.that(tapn != null, "tapn cannot be null");
226 Require.that(sharedPlace != null, "sharedPlace cannot be null");
227 Require.that(place != null, "timedPlace cannot be null");
228
229=== added directory 'src/dk/aau/cs/verification/batchProcessing/Undo'
230=== added file 'src/dk/aau/cs/verification/batchProcessing/Undo/AddFileCommand.java'
231--- src/dk/aau/cs/verification/batchProcessing/Undo/AddFileCommand.java 1970-01-01 00:00:00 +0000
232+++ src/dk/aau/cs/verification/batchProcessing/Undo/AddFileCommand.java 2020-05-13 15:54:44 +0000
233@@ -0,0 +1,34 @@
234+package dk.aau.cs.verification.batchProcessing.Undo;
235+
236+import dk.aau.cs.gui.BatchProcessingDialog;
237+import dk.aau.cs.gui.undo.Command;
238+
239+import javax.swing.*;
240+import java.io.File;
241+import java.util.List;
242+
243+public class AddFileCommand extends Command {
244+ private DefaultListModel listModel;
245+ List<File> files;
246+ File file;
247+ private BatchProcessingDialog dialog;
248+ public AddFileCommand(DefaultListModel listModel, File file, List<File> files, BatchProcessingDialog dialog){
249+ this.listModel = listModel;
250+ this.file = file;
251+ this.files = files;
252+ this.dialog = dialog;
253+ }
254+ @Override
255+ public void redo() {
256+ files.add(file);
257+ listModel.addElement(file);
258+ dialog.enableButtons();
259+ }
260+
261+ @Override
262+ public void undo() {
263+ files.remove(file);
264+ listModel.removeElement(file);
265+ dialog.enableButtons();
266+ }
267+}
268
269=== added file 'src/dk/aau/cs/verification/batchProcessing/Undo/RemoveFileCommand.java'
270--- src/dk/aau/cs/verification/batchProcessing/Undo/RemoveFileCommand.java 1970-01-01 00:00:00 +0000
271+++ src/dk/aau/cs/verification/batchProcessing/Undo/RemoveFileCommand.java 2020-05-13 15:54:44 +0000
272@@ -0,0 +1,35 @@
273+package dk.aau.cs.verification.batchProcessing.Undo;
274+
275+import dk.aau.cs.gui.BatchProcessingDialog;
276+import dk.aau.cs.gui.undo.Command;
277+
278+import javax.swing.*;
279+import java.io.File;
280+import java.util.List;
281+
282+public class RemoveFileCommand extends Command {
283+ private DefaultListModel listModel;
284+ List<File> files;
285+ File file;
286+ private BatchProcessingDialog dialog;
287+ public RemoveFileCommand(DefaultListModel listModel, File file, List<File> files, BatchProcessingDialog dialog){
288+ this.listModel = listModel;
289+ this.file = file;
290+ this.files = files;
291+ this.dialog = dialog;
292+ }
293+ @Override
294+ public void redo() {
295+ files.remove(file);
296+ listModel.removeElement(file);
297+ dialog.enableButtons();
298+ }
299+
300+ @Override
301+ public void undo() {
302+ files.add(file);
303+ listModel.addElement(file);
304+ dialog.enableButtons();
305+ }
306+}
307+
308
309=== modified file 'src/net/tapaal/TAPAAL.java'
310--- src/net/tapaal/TAPAAL.java 2020-04-18 16:13:35 +0000
311+++ src/net/tapaal/TAPAAL.java 2020-05-13 15:54:44 +0000
312@@ -39,7 +39,7 @@
313 public class TAPAAL {
314
315 public static final String TOOLNAME = "TAPAAL";
316- public static final String VERSION = "DEV";
317+ public static final String VERSION = "3.6.1";
318
319 public static String getProgramName(){
320 return "" + TAPAAL.TOOLNAME + " " + TAPAAL.VERSION;
321
322=== modified file 'src/pipe/gui/ExportBatchDialog.java'
323--- src/pipe/gui/ExportBatchDialog.java 2020-04-18 16:08:44 +0000
324+++ src/pipe/gui/ExportBatchDialog.java 2020-05-13 15:54:44 +0000
325@@ -235,10 +235,21 @@
326 gbc.anchor = GridBagConstraints.WEST;
327 gbc.insets = new Insets(0, 10, 0, 0);
328 JButton destinationPathSelector = new JButton("Select destination folder");
329+<<<<<<< TREE
330 destinationPathSelector.addActionListener(e -> {
331 selectDestinationPath();
332 destinationPathField.setText(destinationFile.getParent());
333 enableButtons();
334+=======
335+ destinationPathSelector.addActionListener(new ActionListener() {
336+ public void actionPerformed(ActionEvent e) {
337+ selectDestinationPath();
338+ if(destinationFile != null) {
339+ destinationPathField.setText(lastExportPath);
340+ }
341+ enableButtons();
342+ }
343+>>>>>>> MERGE-SOURCE
344 });
345 chooserPanel.add(destinationPathSelector, gbc);
346
347@@ -450,10 +461,10 @@
348 }
349
350 private void selectDestinationPath() {
351- String chosenFile = FileBrowser.constructor("Select an export folder", ".", lastExportPath).saveFile("Export");
352+ File chosenFile = FileBrowser.constructor("Select an export folder", ".", lastExportPath).saveFileToDir();
353 if(chosenFile != null) {
354- destinationFile = new File(chosenFile);
355- lastExportPath = chosenFile;
356+ destinationFile = chosenFile;
357+ lastExportPath = destinationFile.getAbsolutePath();
358 }
359 else return;
360 }
361
362=== modified file 'src/pipe/gui/undo/TranslatePetriNetObjectEdit.java'
363--- src/pipe/gui/undo/TranslatePetriNetObjectEdit.java 2020-05-02 15:30:09 +0000
364+++ src/pipe/gui/undo/TranslatePetriNetObjectEdit.java 2020-05-13 15:54:44 +0000
365@@ -4,7 +4,11 @@
366
367 package pipe.gui.undo;
368
369+<<<<<<< TREE
370 import pipe.gui.canvas.DrawingSurfaceImpl;
371+=======
372+import pipe.gui.DrawingSurfaceImpl;
373+>>>>>>> MERGE-SOURCE
374 import pipe.gui.graphicElements.PetriNetObject;
375 import dk.aau.cs.gui.undo.Command;
376
377@@ -17,29 +21,49 @@
378 PetriNetObject pnObject;
379 Integer transX;
380 Integer transY;
381+<<<<<<< TREE
382 DrawingSurfaceImpl ds;
383+=======
384+ DrawingSurfaceImpl view;
385+>>>>>>> MERGE-SOURCE
386
387 /** Creates a new instance of */
388 public TranslatePetriNetObjectEdit(PetriNetObject _pnObject,
389+<<<<<<< TREE
390 Integer _transX, Integer _transY, DrawingSurfaceImpl drawingSurface) {
391+=======
392+ Integer _transX, Integer _transY, DrawingSurfaceImpl view) {
393+>>>>>>> MERGE-SOURCE
394 pnObject = _pnObject;
395 transX = _transX;
396 transY = _transY;
397+<<<<<<< TREE
398 ds = drawingSurface;
399+=======
400+ this.view = view;
401+>>>>>>> MERGE-SOURCE
402 }
403
404 /** */
405 @Override
406 public void undo() {
407 pnObject.translate(-transX, -transY);
408+<<<<<<< TREE
409 ds.updatePreferredSize();
410+=======
411+ view.updatePreferredSize();
412+>>>>>>> MERGE-SOURCE
413 }
414
415 /** */
416 @Override
417 public void redo() {
418 pnObject.translate(transX, transY);
419+<<<<<<< TREE
420 ds.updatePreferredSize();
421+=======
422+ view.updatePreferredSize();
423+>>>>>>> MERGE-SOURCE
424 }
425
426 @Override
427
428=== modified file 'src/pipe/gui/undo/UndoManager.java'
429--- src/pipe/gui/undo/UndoManager.java 2020-05-03 09:49:19 +0000
430+++ src/pipe/gui/undo/UndoManager.java 2020-05-13 15:54:44 +0000
431@@ -38,10 +38,21 @@
432 /**
433 * Creates a new instance of UndoManager
434 */
435+<<<<<<< TREE
436 public UndoManager() {
437
438 app.ifPresent(a -> a.setUndoActionEnabled(false));
439 app.ifPresent(a -> a.setRedoActionEnabled(false));
440+=======
441+ public UndoManager(DrawingSurfaceImpl _view, DataLayer _model, GuiFrame _app) {
442+ view = _view;
443+ guiModel = _model;
444+ app = _app;
445+ if(app != null) {
446+ app.setUndoActionEnabled(false);
447+ app.setRedoActionEnabled(false);
448+ }
449+>>>>>>> MERGE-SOURCE
450 for (int i = 0; i < UNDO_BUFFER_CAPACITY; i++) {
451 edits.add(null);
452 }
453@@ -50,7 +61,14 @@
454 public void redo() {
455
456 if (undoneEdits > 0) {
457+<<<<<<< TREE
458 checkArcBeingDrawn();
459+=======
460+ if(app != null && view != null) {
461+ checkArcBeingDrawn();
462+ checkMode();
463+ }
464+>>>>>>> MERGE-SOURCE
465
466 // The currentEdit to redo
467 for (Command command : edits.get(indexOfNextAdd)) {
468@@ -59,10 +77,21 @@
469 indexOfNextAdd = (indexOfNextAdd + 1) % UNDO_BUFFER_CAPACITY;
470 sizeOfBuffer++;
471 undoneEdits--;
472+<<<<<<< TREE
473 if (undoneEdits == 0) {
474 app.ifPresent(a -> a.setRedoActionEnabled(false));
475+=======
476+ if(app != null) {
477+ if (undoneEdits == 0) {
478+ app.setRedoActionEnabled(false);
479+ }
480+ app.setUndoActionEnabled(true);
481+>>>>>>> MERGE-SOURCE
482 }
483+<<<<<<< TREE
484 app.ifPresent(a -> a.setUndoActionEnabled(true));
485+=======
486+>>>>>>> MERGE-SOURCE
487 }
488 }
489
490@@ -79,7 +108,14 @@
491 public void undo() {
492
493 if (sizeOfBuffer > 0) {
494+<<<<<<< TREE
495 checkArcBeingDrawn();
496+=======
497+ if(app != null && view != null) {
498+ checkArcBeingDrawn();
499+ checkMode();
500+ }
501+>>>>>>> MERGE-SOURCE
502
503 if (--indexOfNextAdd < 0) {
504 indexOfNextAdd += UNDO_BUFFER_CAPACITY;
505@@ -92,11 +128,22 @@
506 for (int i = currentEdit.size() - 1; i >= 0; i--) {
507 currentEdit.get(i).undo();
508 }
509+<<<<<<< TREE
510
511 if (sizeOfBuffer == 0) {
512 app.ifPresent(a -> a.setUndoActionEnabled(false));
513+=======
514+ if(app != null) {
515+ if (sizeOfBuffer == 0) {
516+ app.setUndoActionEnabled(false);
517+ }
518+ app.setRedoActionEnabled(true);
519+>>>>>>> MERGE-SOURCE
520 }
521+<<<<<<< TREE
522 app.ifPresent(a -> a.setRedoActionEnabled(true));
523+=======
524+>>>>>>> MERGE-SOURCE
525 }
526 }
527
528@@ -116,11 +163,21 @@
529 }
530
531 undoneEdits = 0;
532+<<<<<<< TREE
533 app.ifPresent(a -> a.setUndoActionEnabled(true));
534 app.ifPresent(a -> a.setRedoActionEnabled(false));
535 if(CreateGui.getCurrentTab() != null) {
536 CreateGui.getCurrentTab().setNetChanged(true);
537 }
538+=======
539+ if(app != null) {
540+ app.setUndoActionEnabled(true);
541+ app.setRedoActionEnabled(false);
542+ }
543+ if(view != null){
544+ view.setNetChanged(true);
545+ }
546+>>>>>>> MERGE-SOURCE
547
548 ArrayList<Command> compoundEdit = new ArrayList<Command>();
549 edits.set(indexOfNextAdd, compoundEdit);
550@@ -143,6 +200,40 @@
551 addEdit(undoableEdit);
552 }
553
554+<<<<<<< TREE
555+=======
556+ private void deleteSelection(PetriNetObject pnObject) {
557+ if(pnObject instanceof PlaceTransitionObject){
558+ PlaceTransitionObject pto = (PlaceTransitionObject)pnObject;
559+
560+ for(Arc arc : pto.getPreset()){
561+ deleteObject(arc);
562+ }
563+
564+ for(Arc arc : pto.getPostset()){
565+ deleteObject(arc);
566+ }
567+ }
568+
569+ deleteObject(pnObject);
570+ }
571+
572+ public void deleteSelection(ArrayList<PetriNetObject> selection) {
573+ for (PetriNetObject pnObject : selection) {
574+ deleteSelection(pnObject);
575+ }
576+ }
577+
578+ public void translateSelection(ArrayList<PetriNetObject> objects,
579+ int transX, int transY) {
580+ newEdit(); // new "transaction""
581+ Iterator<PetriNetObject> iterator = objects.iterator();
582+ while (iterator.hasNext()) {
583+ addEdit(new TranslatePetriNetObjectEdit(iterator.next(), transX,
584+ transY, view));
585+ }
586+ }
587+>>>>>>> MERGE-SOURCE
588
589 private int currentIndex() {
590 int lastAdd = indexOfNextAdd - 1;
591
592=== modified file 'src/pipe/gui/widgets/filebrowser/FileBrowser.java'
593--- src/pipe/gui/widgets/filebrowser/FileBrowser.java 2020-04-18 15:39:19 +0000
594+++ src/pipe/gui/widgets/filebrowser/FileBrowser.java 2020-05-13 15:54:44 +0000
595@@ -11,8 +11,8 @@
596 //Default value null makes the open dialog open default folder, For Windows, My Documents, For *nix ~ , etc
597 //XXX 2018-05-23 moved from CreateGUI, refactor with regards to usage with lastPath local var in this class
598 public static String userPath = null;
599- static String lastSavePath = null;
600- static String lastOpenPath = null;
601+ static String lastSavePath = ".";
602+ static String lastOpenPath = ".";
603
604 public static FileBrowser constructor(String filetype, final String ext) {
605 return constructor(filetype, ext, null);
606@@ -48,5 +48,6 @@
607 }
608
609 public abstract String saveFile(String suggestedName);
610+ public abstract File saveFileToDir();
611
612 }
613
614=== modified file 'src/pipe/gui/widgets/filebrowser/NativeFileBrowser.java'
615--- src/pipe/gui/widgets/filebrowser/NativeFileBrowser.java 2020-04-18 15:39:19 +0000
616+++ src/pipe/gui/widgets/filebrowser/NativeFileBrowser.java 2020-05-13 15:54:44 +0000
617@@ -7,8 +7,7 @@
618 import java.util.regex.Matcher;
619 import java.util.regex.Pattern;
620
621-import javax.swing.JOptionPane;
622-
623+import javax.swing.*;
624 import pipe.gui.CreateGui;
625
626 class NativeFileBrowser extends FileBrowser {
627@@ -23,7 +22,7 @@
628 NativeFileBrowser(String filetype, final String ext, final String optionalExt, String path) {
629 fc = new FileDialog(CreateGui.getAppGui(), filetype);
630 this.specifiedPath = path;
631-
632+
633 if (filetype == null) {
634 filetype = "file";
635 }
636@@ -85,7 +84,7 @@
637 lastOpenPath = fc.getDirectory();
638 return selectedFiles;
639 }
640-
641+
642 public String saveFile(String suggestedName) {
643 if(specifiedPath == null) specifiedPath = lastSavePath;
644 fc.setDirectory(specifiedPath);
645@@ -146,5 +145,34 @@
646
647 return file;
648 }
649-
650+ public File saveFileToDir(){
651+ //In Windows the native FileDialog only works with files
652+ //So we make a JFileChooser in which we can control it
653+ if(System.getProperty("os.name").startsWith("Windows")) {
654+ File selectedDir = null;
655+ if (specifiedPath == null) specifiedPath = lastSavePath;
656+ JFileChooser c = new JFileChooser(specifiedPath);
657+ c.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
658+ c.setDialogTitle("Choose target directory for export");
659+ int rVal = c.showSaveDialog(c);
660+ if (rVal == JFileChooser.APPROVE_OPTION) {
661+ selectedDir = c.getSelectedFile();
662+ lastSavePath = selectedDir.getPath();
663+ }
664+
665+ return selectedDir;
666+ } else{
667+ //For Mac we can set Directories only
668+ //For linux a save dialog only shows directories
669+ System.setProperty("apple.awt.fileDialogForDirectories", "true");
670+ String selection = saveFile("Choose Directory");
671+ System.setProperty("apple.awt.fileDialogForDirectories", "false");
672+ if(selection != null) {
673+ return new File(fc.getDirectory());
674+ } else{
675+ return null;
676+ }
677+ }
678+
679+ }
680 }
681
682=== modified file 'src/pipe/gui/widgets/filebrowser/NativeFileBrowserFallback.java'
683--- src/pipe/gui/widgets/filebrowser/NativeFileBrowserFallback.java 2020-04-18 14:41:05 +0000
684+++ src/pipe/gui/widgets/filebrowser/NativeFileBrowserFallback.java 2020-05-13 15:54:44 +0000
685@@ -10,7 +10,6 @@
686 import javax.swing.JFileChooser;
687 import javax.swing.JOptionPane;
688 import javax.swing.filechooser.FileNameExtensionFilter;
689-
690 import pipe.gui.CreateGui;
691
692 class NativeFileBrowserFallback extends FileBrowser {
693@@ -159,4 +158,34 @@
694 }
695 return file;
696 }
697+ public File saveFileToDir(){
698+ //In Windows the native FileDialog only works with files
699+ //So we make a JFileChooser in which we can control it
700+ if(System.getProperty("os.name").startsWith("Windows")) {
701+ File selectedDir = null;
702+ if (specifiedPath == null) specifiedPath = lastSavePath;
703+ JFileChooser c = new JFileChooser(specifiedPath);
704+ c.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
705+ c.setDialogTitle("Choose target directory for export");
706+ int rVal = c.showSaveDialog(c);
707+ if (rVal == JFileChooser.APPROVE_OPTION) {
708+ selectedDir = c.getSelectedFile();
709+ lastSavePath = selectedDir.getPath();
710+ }
711+
712+ return selectedDir;
713+ } else{
714+ //For Mac we can set Directories only
715+ //For linux a save dialog only shows directories
716+ System.setProperty("apple.awt.fileDialogForDirectories", "true");
717+ String selection = saveFile("Choose Directory");
718+ System.setProperty("apple.awt.fileDialogForDirectories", "false");
719+ if(selection != null) {
720+ return new File(fc.getDirectory());
721+ } else{
722+ return null;
723+ }
724+ }
725+
726+ }
727 }

Subscribers

People subscribed via source and target branches