Ticket #24944: patch_24944.txt

File patch_24944.txt, 1.8 KB (added by DanProgs <Abenteurer.2901@…>, 21 hours ago)
Line 
1### Eclipse Workspace Patch 1.0
2#P josm
3diff --git src/org/openstreetmap/josm/actions/AboutAction.java src/org/openstreetmap/josm/actions/AboutAction.java
4index e0d3aef..fafb322 100644
5--- src/org/openstreetmap/josm/actions/AboutAction.java
6+++ src/org/openstreetmap/josm/actions/AboutAction.java
7@@ -19,6 +19,9 @@
8 import java.io.InputStream;
9 import java.io.InputStreamReader;
10 import java.nio.charset.StandardCharsets;
11+import java.nio.file.Files;
12+import java.nio.file.InvalidPathException;
13+import java.nio.file.Path;
14 import java.util.Map.Entry;
15
16 import javax.swing.AbstractAction;
17@@ -179,22 +182,32 @@
18 }
19
20 private static class OpenDirAction extends AbstractAction {
21- final String dir;
22+ private final Path dirPath;
23
24 OpenDirAction(String dir) {
25- putValue(Action.NAME, "...");
26- this.dir = dir;
27- try {
28- setEnabled(dir != null && new File(dir).isDirectory());
29- } catch (SecurityException e) {
30- setEnabled(false);
31- Logging.warn(e);
32+ super("...");
33+
34+ Path path = null;
35+ boolean isValidDir = false;
36+
37+ if (dir != null) {
38+ try {
39+ path = Path.of(dir);
40+ isValidDir = Files.isDirectory(path);
41+ } catch (InvalidPathException | SecurityException e) {
42+ Logging.warn(e);
43+ }
44 }
45+
46+ this.dirPath = isValidDir ? path : null;
47+ setEnabled(isValidDir);
48 }
49
50 @Override
51 public void actionPerformed(ActionEvent e) {
52- OpenBrowser.displayUrl(new File(dir).toURI());
53+ if (dirPath != null) {
54+ OpenBrowser.displayUrl(dirPath.toUri());
55+ }
56 }
57 }
58