Ticket #24944: 24944_new.patch

File 24944_new.patch, 1.8 KB (added by DanProgs <Abenteurer.2901@…>, 3 weeks ago)

replaced tabs

  • src/org/openstreetmap/josm/actions/AboutAction.java

    ### Eclipse Workspace Patch 1.0
    #P josm
    diff --git src/org/openstreetmap/josm/actions/AboutAction.java src/org/openstreetmap/josm/actions/AboutAction.java
    index e0d3aef..fafb322 100644
     
    1919import java.io.InputStream;
    2020import java.io.InputStreamReader;
    2121import java.nio.charset.StandardCharsets;
     22import java.nio.file.Files;
     23import java.nio.file.InvalidPathException;
     24import java.nio.file.Path;
    2225import java.util.Map.Entry;
    2326
    2427import javax.swing.AbstractAction;
    … …  
    179182    }
    180183
    181184    private static class OpenDirAction extends AbstractAction {
    182         final String dir;
     185        private final Path dirPath;
    183186
    184187        OpenDirAction(String dir) {
    185             putValue(Action.NAME, "...");
    186             this.dir = dir;
    187             try {
    188                 setEnabled(dir != null && new File(dir).isDirectory());
    189             } catch (SecurityException e) {
    190                 setEnabled(false);
    191                 Logging.warn(e);
     188            super("...");
     189           
     190            Path path = null;
     191            boolean isValidDir = false;
     192
     193            if (dir != null) {
     194                try {
     195                    path = Path.of(dir);
     196                    isValidDir = Files.isDirectory(path);
     197                } catch (InvalidPathException | SecurityException e) {
     198                    Logging.warn(e);
     199                }
    192200            }
     201
     202            this.dirPath = isValidDir ? path : null;
     203            setEnabled(isValidDir);
    193204        }
    194205
    195206        @Override
    196207        public void actionPerformed(ActionEvent e) {
    197             OpenBrowser.displayUrl(new File(dir).toURI());
     208            if (dirPath != null) {
     209                OpenBrowser.displayUrl(dirPath.toUri());
     210            }
    198211        }
    199212    }
    200213