Ticket #17192: 17192-v4.patch

File 17192-v4.patch, 6.1 KB (added by GerdP, 5 years ago)

Hopefully final version

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

     
    22package org.openstreetmap.josm.actions;
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
     5import static org.openstreetmap.josm.tools.Utils.getSystemEnv;
     6import static org.openstreetmap.josm.tools.Utils.getSystemProperty;
    57
    68import java.awt.Color;
    79import java.awt.Dimension;
    810import java.awt.FlowLayout;
     11import java.awt.Font;
    912import java.awt.GridBagLayout;
    1013import java.awt.event.ActionEvent;
    1114import java.awt.event.KeyEvent;
     
    1215import java.awt.event.MouseAdapter;
    1316import java.awt.event.MouseEvent;
    1417import java.io.BufferedReader;
     18import java.io.File;
    1519import java.io.IOException;
    1620import java.io.InputStream;
    1721import java.io.InputStreamReader;
    1822
     23import javax.swing.AbstractAction;
     24import javax.swing.Action;
    1925import javax.swing.BorderFactory;
     26import javax.swing.JButton;
    2027import javax.swing.JLabel;
    2128import javax.swing.JPanel;
    2229import javax.swing.JScrollPane;
     
    112119        info.add(logos, GBC.eol().insets(0, 10, 0, 0));
    113120        info.add(GBC.glue(0, 5), GBC.eol());
    114121
     122        JPanel inst = new JPanel(new GridBagLayout());
     123        addInstLine(inst, getSystemEnv("JAVA_HOME"));
     124        addInstLine(inst, getSystemProperty("java.home"));
     125        addInstLine(inst, Config.getDirs().getPreferencesDirectory(false).toString());
     126        addInstLine(inst, Config.getDirs().getUserDataDirectory(false).toString());
     127        addInstLine(inst, Config.getDirs().getCacheDirectory(false).toString());
     128
    115129        about.addTab(tr("Info"), info);
    116130        about.addTab(tr("Readme"), createScrollPane(readme));
    117131        about.addTab(tr("Revision"), createScrollPane(revision));
     
    118132        about.addTab(tr("Contribution"), createScrollPane(contribution));
    119133        about.addTab(tr("License"), createScrollPane(license));
    120134        about.addTab(tr("Plugins"), new JScrollPane(PluginHandler.getInfoPanel()));
     135        about.addTab(tr("Installation Details"), inst);
    121136
    122137        // Get the list of Launchpad contributors using customary msgid “translator-credits”
    123138        String translators = tr("translator-credits");
     
    133148        panel.add(about, GBC.std().fill());
    134149
    135150        GuiHelper.prepareResizeableOptionPane(panel, panel.getPreferredSize());
    136         int ret = new ExtendedDialog(MainApplication.getMainFrame(), tr("About JOSM..."), tr("OK"), tr("Report bug"))
    137             .setButtonIcons("ok", "bug")
    138             .setContent(panel, false)
    139             .showDialog().getValue();
     151        ExtendedDialog dlg = new ExtendedDialog(MainApplication.getMainFrame(), tr("About JOSM..."), tr("OK"), tr("Report bug"));
     152        int ret = dlg.setButtonIcons("ok", "bug")
     153                .setContent(panel, false)
     154                .showDialog().getValue();
    140155        if (2 == ret) {
    141156            MainApplication.getMenu().reportbug.actionPerformed(null);
    142157        }
     158        GuiHelper.destroyComponents(panel, false);
     159        dlg.dispose();
    143160    }
    144161
     162    private static class OpenDirAction extends AbstractAction {
     163        final String dir;
     164
     165        OpenDirAction(String dir) {
     166            super();
     167            putValue(Action.NAME, "...");
     168            this.dir = dir;
     169            setEnabled(dir != null && new File(dir).isDirectory());
     170        }
     171
     172        @Override
     173        public void actionPerformed(ActionEvent e) {
     174            OpenBrowser.displayUrl(new File(dir).toURI());
     175        }
     176    }
     177
     178    /**
     179     * Add line to installation details showing symbolic name used in status report and actual directory.
     180     * @param inst the panel
     181     * @param dir the actual path represented by a symbol
     182     */
     183    private void addInstLine(JPanel inst, String dir) {
     184        JLabel symbol = new JLabel(ShowStatusReportAction.paramCleanup(dir));
     185        symbol.setFont(GuiHelper.getMonospacedFont(symbol));
     186        inst.add(symbol, GBC.std().insets(5, 0, 0, 0));
     187        inst.add(GBC.glue(10, 0), GBC.std());
     188        JosmTextArea dirLabel = new JosmTextArea();
     189        if (dir != null && !dir.isEmpty()) {
     190            dirLabel.setText(dir);
     191            dirLabel.setEditable(false);
     192        } else {
     193            dirLabel.setText("(unset)");
     194            dirLabel.setFont(dirLabel.getFont().deriveFont(Font.ITALIC));
     195        }
     196        dirLabel.setFont(GuiHelper.getMonospacedFont(dirLabel));
     197        dirLabel.setOpaque(false);
     198        inst.add(dirLabel, GBC.std().fill(GBC.HORIZONTAL));
     199        JButton btn = new JButton(new OpenDirAction(dir));
     200        btn.setToolTipText(tr("Open directory"));
     201        inst.add(btn, GBC.eol().insets(0, 0, 5, 0));
     202    }
     203
    145204    private static JLabel createImageLink(String tooltip, String icon, final String link) {
    146205        JLabel label = new JLabel(ImageProvider.get("dialogs/about", icon, ImageSizes.LARGEICON));
    147206        label.setToolTipText(tooltip);
  • src/org/openstreetmap/josm/actions/ShowStatusReportAction.java

     
    223223     * @param param parameter to cleanup
    224224     * @return shortened/anonymized parameter
    225225     */
    226     private static String paramCleanup(String param) {
     226    public static String paramCleanup(String param) {
    227227        final String envJavaHome = getSystemEnv("JAVA_HOME");
    228228        final String envJavaHomeAlt = PlatformManager.isPlatformWindows() ? "%JAVA_HOME%" : "${JAVA_HOME}";
    229229        final String propJavaHome = getSystemProperty("java.home");
     
    241241
    242242        String val = param;
    243243        val = paramReplace(val, envJavaHome, envJavaHomeAlt);
    244         val = paramReplace(val, envJavaHome, envJavaHomeAlt);
    245244        val = paramReplace(val, propJavaHome, propJavaHomeAlt);
    246245        val = paramReplace(val, prefDir, prefDirAlt);
    247246        val = paramReplace(val, userDataDir, userDataDirAlt);