Changeset 14693 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2019-01-13T14:49:19+01:00 (6 years ago)
Author:
GerdP
Message:

fix #17192 Add tab with installation details in "About" popup

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AboutAction.java

    r14623 r14693  
    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;
     
    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;
     
    3845import org.openstreetmap.josm.tools.Logging;
    3946import org.openstreetmap.josm.tools.OpenBrowser;
     47import org.openstreetmap.josm.tools.PlatformManager;
    4048import org.openstreetmap.josm.tools.Shortcut;
    4149import org.openstreetmap.josm.tools.Utils;
     
    113121        info.add(GBC.glue(0, 5), GBC.eol());
    114122
     123        JPanel inst = new JPanel(new GridBagLayout());
     124        addInstallationLine(inst, getSystemEnv("JAVA_HOME"), PlatformManager.isPlatformWindows() ? "%JAVA_HOME%" : "${JAVA_HOME}");
     125        addInstallationLine(inst, getSystemProperty("java.home"), "java.home");
     126        addInstallationLine(inst, Config.getDirs().getPreferencesDirectory(false).toString(), null);
     127        addInstallationLine(inst, Config.getDirs().getUserDataDirectory(false).toString(), null);
     128        addInstallationLine(inst, Config.getDirs().getCacheDirectory(false).toString(), null);
     129
    115130        about.addTab(tr("Info"), info);
    116131        about.addTab(tr("Readme"), createScrollPane(readme));
     
    119134        about.addTab(tr("License"), createScrollPane(license));
    120135        about.addTab(tr("Plugins"), new JScrollPane(PluginHandler.getInfoPanel()));
     136        about.addTab(tr("Installation Details"), inst);
    121137
    122138        // Get the list of Launchpad contributors using customary msgid “translator-credits”
     
    134150
    135151        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();
     152        ExtendedDialog dlg = new ExtendedDialog(MainApplication.getMainFrame(), tr("About JOSM..."), tr("OK"), tr("Report bug"));
     153        int ret = dlg.setButtonIcons("ok", "bug")
     154                .setContent(panel, false)
     155                .showDialog().getValue();
    140156        if (2 == ret) {
    141157            MainApplication.getMenu().reportbug.actionPerformed(null);
    142158        }
     159        GuiHelper.destroyComponents(panel, false);
     160        dlg.dispose();
     161    }
     162
     163    private static class OpenDirAction extends AbstractAction {
     164        final String dir;
     165
     166        OpenDirAction(String dir) {
     167            super();
     168            putValue(Action.NAME, "...");
     169            this.dir = dir;
     170            setEnabled(dir != null && new File(dir).isDirectory());
     171        }
     172
     173        @Override
     174        public void actionPerformed(ActionEvent e) {
     175            OpenBrowser.displayUrl(new File(dir).toURI());
     176        }
     177    }
     178
     179    /**
     180     * Add line to installation details showing symbolic name used in status report and actual directory.
     181     * @param inst the panel
     182     * @param dir the actual path represented by a symbol
     183     * @param source source for symbol
     184     */
     185    private void addInstallationLine(JPanel inst, String dir, String source) {
     186        if (dir == null && source == null)
     187            return;
     188        JLabel symbol = new JLabel();
     189        JosmTextArea dirLabel = new JosmTextArea();
     190        if (dir != null && !dir.isEmpty()) {
     191            symbol.setText(ShowStatusReportAction.paramCleanup(dir));
     192            dirLabel.setText(dir);
     193            dirLabel.setEditable(false);
     194        } else {
     195            symbol.setText(source);
     196            dirLabel.setText(tr("(unset)"));
     197            dirLabel.setFont(dirLabel.getFont().deriveFont(Font.ITALIC));
     198        }
     199        symbol.setFont(GuiHelper.getMonospacedFont(symbol));
     200        inst.add(symbol, GBC.std().insets(5, 0, 0, 0));
     201        inst.add(GBC.glue(10, 0), GBC.std());
     202        dirLabel.setFont(GuiHelper.getMonospacedFont(dirLabel));
     203        dirLabel.setOpaque(false);
     204        inst.add(dirLabel, GBC.std().fill(GBC.HORIZONTAL));
     205        JButton btn = new JButton(new OpenDirAction(dir));
     206        btn.setToolTipText(tr("Open directory"));
     207        inst.add(btn, GBC.eol().insets(0, 0, 5, 0));
    143208    }
    144209
  • trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java

    r14671 r14693  
    224224     * @return shortened/anonymized parameter
    225225     */
    226     private static String paramCleanup(String param) {
     226    static String paramCleanup(String param) {
    227227        final String envJavaHome = getSystemEnv("JAVA_HOME");
    228228        final String envJavaHomeAlt = PlatformManager.isPlatformWindows() ? "%JAVA_HOME%" : "${JAVA_HOME}";
     
    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);
Note: See TracChangeset for help on using the changeset viewer.