Merge lp:~tapaal-contributor/tapaal/open-on-windows-1868525 into lp:tapaal

Proposed by Peter Haahr Taankvist
Status: Merged
Approved by: Jiri Srba
Approved revision: 1043
Merged at revision: 1042
Proposed branch: lp:~tapaal-contributor/tapaal/open-on-windows-1868525
Merge into: lp:tapaal
Diff against target: 118 lines (+34/-22)
2 files modified
src/pipe/gui/widgets/filebrowser/NativeFileBrowser.java (+28/-21)
src/pipe/gui/widgets/filebrowser/NativeFileBrowserFallback.java (+6/-1)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/open-on-windows-1868525
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Review via email: mp+381045@code.launchpad.net

Commit message

Open on Windows now also shows both xml and tapn files as on Linux and Mac

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

As on Mac this was not a problem, I just want to ask whether this has been properly tested on Windows?

review: Needs Information
Revision history for this message
Peter Haahr Taankvist (ptaank) wrote :

I tested it on my Windows machine and it works. Maybe Kenneth can confirm?

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/widgets/filebrowser/NativeFileBrowser.java'
2--- src/pipe/gui/widgets/filebrowser/NativeFileBrowser.java 2020-01-13 10:28:16 +0000
3+++ src/pipe/gui/widgets/filebrowser/NativeFileBrowser.java 2020-03-23 16:27:17 +0000
4@@ -14,6 +14,7 @@
5 class NativeFileBrowser extends FileBrowser {
6 private FileDialog fc;
7 private String ext;
8+ private String optionalExt;
9 private String specifiedPath;
10 NativeFileBrowser(String filetype, final String ext, String path) {
11 this(filetype, ext, "", path);
12@@ -29,9 +30,11 @@
13 //if(path == null) path = lastPath;
14
15 this.ext = ext;
16+ this.optionalExt = optionalExt;
17 //fc.setDirectory(path);
18
19 // Setup filter if extension specified
20+ //This is needed for Linux and Mac
21 if(!ext.equals("")){
22 if(!optionalExt.equals("")) {
23 fc.setFilenameFilter(new FilenameFilter() {
24@@ -54,30 +57,34 @@
25
26
27 public File openFile() {
28- if(specifiedPath == null) specifiedPath = lastOpenPath;
29- fc.setDirectory(specifiedPath);
30- fc.setFile(ext.equals("")? "":"*."+ext);
31- fc.setMode(FileDialog.LOAD);
32- fc.setMultipleMode(false);
33- fc.setVisible(true);
34- String selectedFile = fc.getFile();
35- String selectedDir = fc.getDirectory();
36- lastOpenPath = selectedDir;
37- File file = selectedFile == null? null:new File(selectedDir + selectedFile);
38- return file;
39+ if(specifiedPath == null) specifiedPath = lastOpenPath;
40+ fc.setDirectory(specifiedPath);
41+ //This is needed for Windows
42+ if(optionalExt.equals("")) fc.setFile(ext.equals("")? "":("*."+ext));
43+ else fc.setFile(ext.equals("")? "":("*."+ext+";*."+optionalExt));
44+ fc.setMode(FileDialog.LOAD);
45+ fc.setMultipleMode(false);
46+ fc.setVisible(true);
47+ String selectedFile = fc.getFile();
48+ String selectedDir = fc.getDirectory();
49+ lastOpenPath = selectedDir;
50+ File file = selectedFile == null? null:new File(selectedDir + selectedFile);
51+ return file;
52 }
53
54 public File[] openFiles() {
55- if(specifiedPath == null) specifiedPath = lastOpenPath;
56- fc.setDirectory(specifiedPath);
57- fc.setFile(ext.equals("")? "":"*."+ext);
58- fc.setMultipleMode(true);
59- fc.setMode(FileDialog.LOAD);
60- fc.setVisible(true);
61- File[] selectedFiles = fc.getFiles();
62- String selectedDir = fc.getDirectory();
63- lastOpenPath = selectedDir;
64- return selectedFiles;
65+ if(specifiedPath == null) specifiedPath = lastOpenPath;
66+ fc.setDirectory(specifiedPath);
67+ //This is needed for Windows
68+ if(optionalExt.equals("")) fc.setFile(ext.equals("")? "":("*."+ext));
69+ else fc.setFile(ext.equals("")? "":("*."+ext+";*."+optionalExt));
70+ fc.setMultipleMode(true);
71+ fc.setMode(FileDialog.LOAD);
72+ fc.setVisible(true);
73+ File[] selectedFiles = fc.getFiles();
74+ String selectedDir = fc.getDirectory();
75+ lastOpenPath = selectedDir;
76+ return selectedFiles;
77 }
78
79 public String saveFile(String suggestedName) {
80
81=== modified file 'src/pipe/gui/widgets/filebrowser/NativeFileBrowserFallback.java'
82--- src/pipe/gui/widgets/filebrowser/NativeFileBrowserFallback.java 2020-01-13 10:10:50 +0000
83+++ src/pipe/gui/widgets/filebrowser/NativeFileBrowserFallback.java 2020-03-23 16:27:17 +0000
84@@ -17,6 +17,7 @@
85 class NativeFileBrowserFallback extends FileBrowser {
86 private FileDialog fc;
87 private String ext;
88+ private String optionalExt;
89 private String specifiedPath;
90 private JFileChooser fileChooser;
91 /**
92@@ -36,6 +37,7 @@
93 //if(path == null) path = lastPath;
94
95 this.ext = ext;
96+ this.optionalExt = optionalExt;
97 //fc.setDirectory(path);
98
99 /* Setup JFileChooser for multi file selection */
100@@ -44,6 +46,7 @@
101 FileNameExtensionFilter filter;
102
103 // Setup filter if extension specified
104+ //This is needed for Linux and Mac
105 if(!ext.equals("")){
106 if(!optionalExt.equals("")) {
107 fc.setFilenameFilter(new FilenameFilter() {
108@@ -76,7 +79,9 @@
109 public File openFile() {
110 if(specifiedPath == null) specifiedPath = lastOpenPath;
111 fc.setDirectory(specifiedPath);
112- fc.setFile(ext.equals("")? "":"*."+ext);
113+ //This is needed for windows
114+ if(optionalExt.equals("")) fc.setFile(ext.equals("")? "":("*."+ext));
115+ else fc.setFile(ext.equals("")? "":("*."+ext+";*."+optionalExt));
116 fc.setMode(FileDialog.LOAD);
117 fc.setVisible(true);
118 String selectedFile = fc.getFile();

Subscribers

People subscribed via source and target branches