Merge lp:~tapaal-contributor/tapaal/pnml-disable-buttons-1868535 into lp:tapaal

Proposed by Peter Haahr Taankvist
Status: Merged
Approved by: Jiri Srba
Approved revision: 1042
Merged at revision: 1043
Proposed branch: lp:~tapaal-contributor/tapaal/pnml-disable-buttons-1868535
Merge into: lp:tapaal
Diff against target: 42 lines (+8/-1)
2 files modified
src/pipe/gui/CreateGui.java (+4/-0)
src/pipe/gui/GuiFrame.java (+4/-1)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/pnml-disable-buttons-1868535
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Review via email: mp+381064@code.launchpad.net

Commit message

When import PNML fails and there are no other tabs open buttons are correctly disabled (as when closing a last tab).

SmartDrawDialog also does not appear if import PNML fails.

To post a comment you must log in.
Revision history for this message
Jiri Srba (srba) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/pipe/gui/CreateGui.java'
2--- src/pipe/gui/CreateGui.java 2018-10-19 14:18:17 +0000
3+++ src/pipe/gui/CreateGui.java 2020-03-23 20:00:20 +0000
4@@ -97,4 +97,8 @@
5 public static GuiFrame getAppGui() {
6 return appGui;
7 }
8+
9+ public static int getTabsSize(){
10+ return tabs.size();
11+ }
12 }
13
14=== modified file 'src/pipe/gui/GuiFrame.java'
15--- src/pipe/gui/GuiFrame.java 2020-03-18 19:23:12 +0000
16+++ src/pipe/gui/GuiFrame.java 2020-03-23 20:00:20 +0000
17@@ -1492,6 +1492,7 @@
18
19 //XXX 2018-05-23 kyrke, implementation close to closeTab, needs refactoring
20 private void undoAddTab(int currentlySelected) {
21+ if(appTab.getTabCount() == 1) { CreateGui.getApp().setGUIMode(GUIMode.noNet); }
22 CreateGui.removeTab(appTab.getSelectedIndex() );
23 appTab.removeTabAt(appTab.getSelectedIndex());
24 appTab.setSelectedIndex(currentlySelected);
25@@ -2558,6 +2559,7 @@
26
27 importMenu.add(importPNMLAction = new GuiAction("PNML untimed net", "Import an untimed net in the PNML format", KeyStroke.getKeyStroke('X', shortcutkey)) {
28 public void actionPerformed(ActionEvent arg0) {
29+ int currNumTabs = CreateGui.getTabsSize();
30 final File[] files = FileBrowser.constructor("Import PNML", "pnml", FileBrowser.userPath).openFiles();
31
32 //Show loading cursor
33@@ -2600,7 +2602,8 @@
34 e.printStackTrace();
35 }
36 }
37- if(files.length != 0 && !CreateGui.getCurrentTab().currentTemplate().getHasPositionalInfo()) {
38+ //files.length != 0 makes sure a file has been selected, CreateGui.getTabsSize() > currNumTabs makes sure the new tab was added
39+ if(files.length != 0 && CreateGui.getTabsSize() > currNumTabs && !CreateGui.getCurrentTab().currentTemplate().getHasPositionalInfo()) {
40 int dialogResult = JOptionPane.showConfirmDialog (null, "The net does not have any layout information. Would you like to do automatic layout?","Automatic Layout?", JOptionPane.YES_NO_OPTION);
41 if(dialogResult == JOptionPane.YES_OPTION) {
42 SmartDrawDialog.showSmartDrawDialog();

Subscribers

People subscribed via source and target branches