Ticket #17192: 17192-v5.patch

File 17192-v5.patch, 8.0 KB (added by GerdP, 5 years ago)
  • src/org/openstreetmap/josm/actions/AboutAction.java

     
    22package org.openstreetmap.josm.actions;
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
    5 import static org.openstreetmap.josm.tools.Utils.getSystemEnv;
    65import static org.openstreetmap.josm.tools.Utils.getSystemProperty;
    76
    87import java.awt.Color;
     
    1918import java.io.IOException;
    2019import java.io.InputStream;
    2120import java.io.InputStreamReader;
     21import java.util.Map.Entry;
    2222
    2323import javax.swing.AbstractAction;
    2424import javax.swing.Action;
     
    3030import javax.swing.JTabbedPane;
    3131import javax.swing.JTextArea;
    3232
     33import org.openstreetmap.josm.data.Preferences;
    3334import org.openstreetmap.josm.data.Version;
    3435import org.openstreetmap.josm.gui.ExtendedDialog;
    3536import org.openstreetmap.josm.gui.MainApplication;
     
    4445import org.openstreetmap.josm.tools.ImageProvider.ImageSizes;
    4546import org.openstreetmap.josm.tools.Logging;
    4647import org.openstreetmap.josm.tools.OpenBrowser;
    47 import org.openstreetmap.josm.tools.PlatformManager;
    4848import org.openstreetmap.josm.tools.Shortcut;
    4949import org.openstreetmap.josm.tools.Utils;
    5050
     
    121121        info.add(GBC.glue(0, 5), GBC.eol());
    122122
    123123        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);
     124        inst.add(new JLabel(tr("Symbolic names for directories and the actual paths:")),
     125                GBC.eol().insets(0, 0, 0, 10));
     126        final String pathToPreferences = ShowStatusReportAction
     127                .paramCleanup(Preferences.main().getPreferenceFile().getAbsolutePath());
     128        inst.add(new JLabel(tr("Preferences are stored in {0}",pathToPreferences)),
     129                GBC.eol().insets(0, 0, 0, 10));
     130        for (Entry<String, String> entry : ShowStatusReportAction.getAnonimicDirectorySymbolMap().entrySet()) {
     131            addInstallationLine(inst, entry.getValue(), entry.getKey());
     132        }
    129133
     134
    130135        about.addTab(tr("Info"), info);
    131136        about.addTab(tr("Readme"), createScrollPane(readme));
    132137        about.addTab(tr("Revision"), createScrollPane(revision));
     
    183188     * @param source source for symbol
    184189     */
    185190    private void addInstallationLine(JPanel inst, String dir, String source) {
    186         if (dir == null && source == null)
     191        if (source == null)
    187192            return;
    188         JLabel symbol = new JLabel();
     193        JLabel symbol = new JLabel(source);
     194        symbol.setFont(GuiHelper.getMonospacedFont(symbol));
    189195        JosmTextArea dirLabel = new JosmTextArea();
    190196        if (dir != null && !dir.isEmpty()) {
    191             symbol.setText(ShowStatusReportAction.paramCleanup(dir));
    192197            dirLabel.setText(dir);
    193198            dirLabel.setEditable(false);
    194199        } else {
    195             symbol.setText(source);
    196200            dirLabel.setText(tr("(unset)"));
    197201            dirLabel.setFont(dirLabel.getFont().deriveFont(Font.ITALIC));
    198202        }
    199         symbol.setFont(GuiHelper.getMonospacedFont(symbol));
    200203        inst.add(symbol, GBC.std().insets(5, 0, 0, 0));
    201204        inst.add(GBC.glue(10, 0), GBC.std());
    202205        dirLabel.setFont(GuiHelper.getMonospacedFont(dirLabel));
  • src/org/openstreetmap/josm/actions/ShowStatusReportAction.java

     
    1515import java.util.ArrayList;
    1616import java.util.Arrays;
    1717import java.util.Collection;
     18import java.util.LinkedHashMap;
    1819import java.util.List;
    1920import java.util.ListIterator;
    2021import java.util.Locale;
     22import java.util.Map;
     23import java.util.Map.Entry;
    2124import java.util.Set;
    2225import java.util.stream.Collectors;
    2326
     
    5053 * @author xeen
    5154 */
    5255public final class ShowStatusReportAction extends JosmAction {
    53 
    5456    /**
    5557     * Constructs a new {@code ShowStatusReportAction}
    5658     */
     
    219221    }
    220222
    221223    /**
     224     * Fill map with anonymized name to the actual used path.
     225     * @return map that maps shortened name to full directory path
     226     */
     227    static Map<String, String> getAnonimicDirectorySymbolMap() {
     228        /** maps the anonymized name to the actual used path */
     229        Map<String, String> map = new LinkedHashMap<>();
     230        map.put(PlatformManager.isPlatformWindows() ? "%JAVA_HOME%" : "${JAVA_HOME}", getSystemEnv("JAVA_HOME"));
     231        map.put("<java.home>", getSystemProperty("java.home"));
     232        map.put("<josm.pref>", Config.getDirs().getPreferencesDirectory(false).toString());
     233        map.put("<josm.userdata>", Config.getDirs().getUserDataDirectory(false).toString());
     234        map.put("<josm.cache>", Config.getDirs().getCacheDirectory(false).toString());
     235        map.put(PlatformManager.isPlatformWindows() ? "%UserProfile%" : "${HOME}", getSystemProperty("user.home"));
     236        return map;
     237    }
     238
     239    /**
    222240     * Shortens and removes private informations from a parameter used for status report.
    223241     * @param param parameter to cleanup
    224242     * @return shortened/anonymized parameter
    225243     */
    226244    static String paramCleanup(String param) {
    227         final String envJavaHome = getSystemEnv("JAVA_HOME");
    228         final String envJavaHomeAlt = PlatformManager.isPlatformWindows() ? "%JAVA_HOME%" : "${JAVA_HOME}";
    229         final String propJavaHome = getSystemProperty("java.home");
    230         final String propJavaHomeAlt = "<java.home>";
    231         final String prefDir = Config.getDirs().getPreferencesDirectory(false).toString();
    232         final String prefDirAlt = "<josm.pref>";
    233         final String userDataDir = Config.getDirs().getUserDataDirectory(false).toString();
    234         final String userDataDirAlt = "<josm.userdata>";
    235         final String userCacheDir = Config.getDirs().getCacheDirectory(false).toString();
    236         final String userCacheDirAlt = "<josm.cache>";
    237         final String userHomeDir = getSystemProperty("user.home");
    238         final String userHomeDirAlt = PlatformManager.isPlatformWindows() ? "%UserProfile%" : "${HOME}";
    239245        final String userName = getSystemProperty("user.name");
    240246        final String userNameAlt = "<user.name>";
    241247
    242248        String val = param;
    243         val = paramReplace(val, envJavaHome, envJavaHomeAlt);
    244         val = paramReplace(val, propJavaHome, propJavaHomeAlt);
    245         val = paramReplace(val, prefDir, prefDirAlt);
    246         val = paramReplace(val, userDataDir, userDataDirAlt);
    247         val = paramReplace(val, userCacheDir, userCacheDirAlt);
    248         val = paramReplace(val, userHomeDir, userHomeDirAlt);
     249        for (Entry<String, String> entry : getAnonimicDirectorySymbolMap().entrySet()) {
     250            val = paramReplace(val, entry.getValue(), entry.getKey());
     251        }
    249252        if (userName != null && userName.length() >= 3) {
    250253            val = paramReplace(val, userName, userNameAlt);
    251254        }
     
    299302        ed.setMinimumSize(new Dimension(380, 200));
    300303        ed.setPreferredSize(new Dimension(700, MainApplication.getMainFrame().getHeight()-50));
    301304
    302         switch (ed.showDialog().getValue()) {
     305        int rc = ed.showDialog().getValue();
     306        GuiHelper.destroyComponents(ed, false);
     307        ed.dispose();
     308        switch (rc) {
    303309            case 1: ta.copyToClipboard(); break;
    304310            case 2: BugReportSender.reportBug(reportHeader); break;
    305             default: // Do nothing
     311            default: // do nothing
    306312        }
    307313    }
    308314}