Changeset 14701 in josm
- Timestamp:
- 2019-01-16T15:42:29+01:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AboutAction.java
r14697 r14701 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 … … 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; … … 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; … … 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; … … 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 final String pathToPreferences = ShowStatusReportAction 125 .paramCleanup(Preferences.main().getPreferenceFile().getAbsolutePath()); 126 inst.add(new JLabel(tr("Preferences are stored in {0}", pathToPreferences)), GBC.eol().insets(0, 0, 0, 10)); 127 inst.add(new JLabel(tr("Symbolic names for directories and the actual paths:")), 128 GBC.eol().insets(0, 0, 0, 10)); 129 for (Entry<String, String> entry : ShowStatusReportAction.getAnonimicDirectorySymbolMap().entrySet()) { 130 addInstallationLine(inst, entry.getValue(), entry.getKey()); 131 } 132 129 133 130 134 about.addTab(tr("Info"), info); … … 184 188 */ 185 189 private void addInstallationLine(JPanel inst, String dir, String source) { 186 if ( dir == null &&source == null)190 if (source == null) 187 191 return; 188 JLabel symbol = new JLabel(); 192 JLabel symbol = new JLabel(source); 193 symbol.setFont(GuiHelper.getMonospacedFont(symbol)); 189 194 JosmTextArea dirLabel = new JosmTextArea(); 190 195 if (dir != null && !dir.isEmpty()) { 191 symbol.setText(ShowStatusReportAction.paramCleanup(dir));192 196 dirLabel.setText(dir); 193 197 dirLabel.setEditable(false); 194 198 } else { 195 symbol.setText(source);196 199 dirLabel.setText(tr("(unset)")); 197 200 dirLabel.setFont(dirLabel.getFont().deriveFont(Font.ITALIC)); 198 201 } 199 symbol.setFont(GuiHelper.getMonospacedFont(symbol));200 202 inst.add(symbol, GBC.std().insets(5, 0, 0, 0)); 201 203 inst.add(GBC.glue(10, 0), GBC.std()); -
trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java
r14693 r14701 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; … … 220 223 221 224 /** 225 * Fill map with anonymized name to the actual used path. 226 * @return map that maps shortened name to full directory path 227 */ 228 static Map<String, String> getAnonimicDirectorySymbolMap() { 229 /** maps the anonymized name to the actual used path */ 230 Map<String, String> map = new LinkedHashMap<>(); 231 map.put(PlatformManager.isPlatformWindows() ? "%JAVA_HOME%" : "${JAVA_HOME}", getSystemEnv("JAVA_HOME")); 232 map.put("<java.home>", getSystemProperty("java.home")); 233 map.put("<josm.pref>", Config.getDirs().getPreferencesDirectory(false).toString()); 234 map.put("<josm.userdata>", Config.getDirs().getUserDataDirectory(false).toString()); 235 map.put("<josm.cache>", Config.getDirs().getCacheDirectory(false).toString()); 236 map.put(PlatformManager.isPlatformWindows() ? "%UserProfile%" : "${HOME}", getSystemProperty("user.home")); 237 return map; 238 } 239 240 /** 222 241 * Shortens and removes private informations from a parameter used for status report. 223 242 * @param param parameter to cleanup … … 225 244 */ 226 245 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 246 final String userName = getSystemProperty("user.name"); 240 247 final String userNameAlt = "<user.name>"; 241 248 242 249 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); 250 for (Entry<String, String> entry : getAnonimicDirectorySymbolMap().entrySet()) { 251 val = paramReplace(val, entry.getValue(), entry.getKey()); 252 } 249 253 if (userName != null && userName.length() >= 3) { 250 254 val = paramReplace(val, userName, userNameAlt); … … 303 307 case 1: ta.copyToClipboard(); break; 304 308 case 2: BugReportSender.reportBug(reportHeader); break; 305 default: // Do nothing 306 } 309 default: // do nothing 310 } 311 GuiHelper.destroyComponents(ed, false); 307 312 } 308 313 }
Note:
See TracChangeset
for help on using the changeset viewer.