Ticket #17192: 17192-v5.patch
File 17192-v5.patch, 8.0 KB (added by , 5 years ago) |
---|
-
src/org/openstreetmap/josm/actions/AboutAction.java
2 2 package org.openstreetmap.josm.actions; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.Utils.getSystemEnv;6 5 import static org.openstreetmap.josm.tools.Utils.getSystemProperty; 7 6 8 7 import java.awt.Color; … … 19 18 import java.io.IOException; 20 19 import java.io.InputStream; 21 20 import java.io.InputStreamReader; 21 import java.util.Map.Entry; 22 22 23 23 import javax.swing.AbstractAction; 24 24 import javax.swing.Action; … … 30 30 import javax.swing.JTabbedPane; 31 31 import javax.swing.JTextArea; 32 32 33 import org.openstreetmap.josm.data.Preferences; 33 34 import org.openstreetmap.josm.data.Version; 34 35 import org.openstreetmap.josm.gui.ExtendedDialog; 35 36 import org.openstreetmap.josm.gui.MainApplication; … … 44 45 import org.openstreetmap.josm.tools.ImageProvider.ImageSizes; 45 46 import org.openstreetmap.josm.tools.Logging; 46 47 import org.openstreetmap.josm.tools.OpenBrowser; 47 import org.openstreetmap.josm.tools.PlatformManager;48 48 import org.openstreetmap.josm.tools.Shortcut; 49 49 import org.openstreetmap.josm.tools.Utils; 50 50 … … 121 121 info.add(GBC.glue(0, 5), GBC.eol()); 122 122 123 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); 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 } 129 133 134 130 135 about.addTab(tr("Info"), info); 131 136 about.addTab(tr("Readme"), createScrollPane(readme)); 132 137 about.addTab(tr("Revision"), createScrollPane(revision)); … … 183 188 * @param source source for symbol 184 189 */ 185 190 private void addInstallationLine(JPanel inst, String dir, String source) { 186 if ( dir == null &&source == null)191 if (source == null) 187 192 return; 188 JLabel symbol = new JLabel(); 193 JLabel symbol = new JLabel(source); 194 symbol.setFont(GuiHelper.getMonospacedFont(symbol)); 189 195 JosmTextArea dirLabel = new JosmTextArea(); 190 196 if (dir != null && !dir.isEmpty()) { 191 symbol.setText(ShowStatusReportAction.paramCleanup(dir));192 197 dirLabel.setText(dir); 193 198 dirLabel.setEditable(false); 194 199 } else { 195 symbol.setText(source);196 200 dirLabel.setText(tr("(unset)")); 197 201 dirLabel.setFont(dirLabel.getFont().deriveFont(Font.ITALIC)); 198 202 } 199 symbol.setFont(GuiHelper.getMonospacedFont(symbol));200 203 inst.add(symbol, GBC.std().insets(5, 0, 0, 0)); 201 204 inst.add(GBC.glue(10, 0), GBC.std()); 202 205 dirLabel.setFont(GuiHelper.getMonospacedFont(dirLabel)); -
src/org/openstreetmap/josm/actions/ShowStatusReportAction.java
15 15 import java.util.ArrayList; 16 16 import java.util.Arrays; 17 17 import java.util.Collection; 18 import java.util.LinkedHashMap; 18 19 import java.util.List; 19 20 import java.util.ListIterator; 20 21 import java.util.Locale; 22 import java.util.Map; 23 import java.util.Map.Entry; 21 24 import java.util.Set; 22 25 import java.util.stream.Collectors; 23 26 … … 50 53 * @author xeen 51 54 */ 52 55 public final class ShowStatusReportAction extends JosmAction { 53 54 56 /** 55 57 * Constructs a new {@code ShowStatusReportAction} 56 58 */ … … 219 221 } 220 222 221 223 /** 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 /** 222 240 * Shortens and removes private informations from a parameter used for status report. 223 241 * @param param parameter to cleanup 224 242 * @return shortened/anonymized parameter 225 243 */ 226 244 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}";239 245 final String userName = getSystemProperty("user.name"); 240 246 final String userNameAlt = "<user.name>"; 241 247 242 248 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 } 249 252 if (userName != null && userName.length() >= 3) { 250 253 val = paramReplace(val, userName, userNameAlt); 251 254 } … … 299 302 ed.setMinimumSize(new Dimension(380, 200)); 300 303 ed.setPreferredSize(new Dimension(700, MainApplication.getMainFrame().getHeight()-50)); 301 304 302 switch (ed.showDialog().getValue()) { 305 int rc = ed.showDialog().getValue(); 306 GuiHelper.destroyComponents(ed, false); 307 ed.dispose(); 308 switch (rc) { 303 309 case 1: ta.copyToClipboard(); break; 304 310 case 2: BugReportSender.reportBug(reportHeader); break; 305 default: // Do nothing311 default: // do nothing 306 312 } 307 313 } 308 314 }