Changeset 15725 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2020-01-19T10:36:30+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/UserIdentityManager.java
r14121 r15725 22 22 import org.openstreetmap.josm.tools.CheckParameterUtil; 23 23 import org.openstreetmap.josm.tools.JosmRuntimeException; 24 import org.openstreetmap.josm.tools.ListenerList; 24 25 import org.openstreetmap.josm.tools.Logging; 25 26 … … 57 58 58 59 private static UserIdentityManager instance; 60 private final ListenerList<UserIdentityListener> listeners = ListenerList.create(); 59 61 60 62 /** … … 97 99 userName = null; 98 100 userInfo = null; 101 fireUserIdentityChanged(); 99 102 } 100 103 … … 115 118 this.userName = trimmedUserName; 116 119 userInfo = null; 120 fireUserIdentityChanged(); 117 121 } 118 122 … … 135 139 this.userName = trimmedUserName; 136 140 this.userInfo = userInfo; 141 fireUserIdentityChanged(); 137 142 } 138 143 … … 209 214 */ 210 215 public void initFromPreferences() { 211 String userName = CredentialsManager.getInstance().getUsername();216 String credentialsUserName = CredentialsManager.getInstance().getUsername(); 212 217 if (isAnonymous()) { 213 if ( userName != null && !userName.trim().isEmpty()) {214 setPartiallyIdentified( userName);218 if (credentialsUserName != null && !credentialsUserName.trim().isEmpty()) { 219 setPartiallyIdentified(credentialsUserName); 215 220 } 216 221 } else { 217 if ( userName != null && !userName.equals(this.userName)) {218 setPartiallyIdentified( userName);222 if (credentialsUserName != null && !credentialsUserName.equals(this.userName)) { 223 setPartiallyIdentified(credentialsUserName); 219 224 } 220 225 // else: same name in the preferences as JOSM already knows about. … … 312 317 } 313 318 } 319 320 /** 321 * This listener is notified whenever the osm user is changed. 322 */ 323 @FunctionalInterface 324 public interface UserIdentityListener { 325 /** 326 * The current user was changed. 327 */ 328 void userIdentityChanged(); 329 } 330 331 /** 332 * Add a listener that listens to changes of the current user. 333 * @param listener The listener 334 */ 335 public void addListener(UserIdentityListener listener) { 336 listeners.addListener(listener); 337 } 338 339 private void fireUserIdentityChanged() { 340 listeners.fireEvent(UserIdentityListener::userIdentityChanged); 341 } 314 342 } -
trunk/src/org/openstreetmap/josm/gui/MainFrame.java
r14273 r15725 21 21 import javax.swing.JPanel; 22 22 23 import org.openstreetmap.josm.data.UserIdentityManager; 23 24 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; 24 25 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; … … 103 104 MainApplication.getLayerManager().addActiveLayerChangeListener(e -> refreshTitle()); 104 105 MainApplication.getLayerManager().addAndFireLayerChangeListener(new ManageLayerListeners()); 105 106 UserIdentityManager.getInstance().addListener(this::refreshTitle); 107 Config.getPref().addKeyPreferenceChangeListener("draw.show-user", e -> refreshTitle()); 106 108 refreshTitle(); 107 109 … … 166 168 boolean dirty = editLayer != null && (editLayer.requiresSaveToFile() 167 169 || (editLayer.requiresUploadToServer() && !editLayer.isUploadDiscouraged())); 168 setTitle((dirty ? "* " : "") + tr("Java OpenStreetMap Editor")); 170 String userInfo = UserIdentityManager.getInstance().getUserName(); 171 if (userInfo != null && Config.getPref().getBoolean("draw.show-user", false)) 172 userInfo = tr(" ({0})", "@" + userInfo); 173 else 174 userInfo = ""; 175 setTitle((dirty ? "* " : "") + tr("Java OpenStreetMap Editor") + userInfo); 169 176 getRootPane().putClientProperty("Window.documentModified", dirty); 170 177 } -
trunk/src/org/openstreetmap/josm/gui/preferences/display/LafPreference.java
r14306 r15725 81 81 VerticallyScrollablePanel panel; 82 82 private final JCheckBox showSplashScreen = new JCheckBox(tr("Show splash screen at startup")); 83 private final JCheckBox showUser = new JCheckBox(tr("Show user name in title")); 83 84 private final JCheckBox showID = new JCheckBox(tr("Show object ID in selection lists")); 84 85 private final JCheckBox showVersion = new JCheckBox(tr("Show object version in selection lists")); … … 130 131 panel.add(showSplashScreen, GBC.eop().insets(20, 0, 0, 0)); 131 132 133 // Show user name in title 134 showUser.setToolTipText(tr("Show user name in title")); 135 showUser.setSelected(Config.getPref().getBoolean("draw.show-user", false)); 136 132 137 // Show ID in selection 133 138 showID.setToolTipText(tr("Show object ID in selection lists")); … … 151 156 ExpertToggleAction.addVisibilitySwitcher(modeless); 152 157 158 panel.add(showUser, GBC.eop().insets(20, 0, 0, 0)); 153 159 panel.add(showID, GBC.eop().insets(20, 0, 0, 0)); 154 160 panel.add(showVersion, GBC.eop().insets(20, 0, 0, 0)); … … 216 222 boolean mod = false; 217 223 Config.getPref().putBoolean("draw.splashscreen", showSplashScreen.isSelected()); 224 Config.getPref().putBoolean("draw.show-user", showUser.isSelected()); 218 225 Config.getPref().putBoolean("osm-primitives.showid", showID.isSelected()); 219 226 Config.getPref().putBoolean("osm-primitives.showversion", showVersion.isSelected());
Note:
See TracChangeset
for help on using the changeset viewer.