Changeset 9519 in josm for trunk/src/org
- Timestamp:
- 2016-01-17T23:24:09+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CloseChangesetAction.java
r8510 r9519 55 55 56 56 protected void onPostDownloadOpenChangesets() { 57 List<Changeset> openChangesets = ChangesetCache.getInstance().getOpenChangesets ();57 List<Changeset> openChangesets = ChangesetCache.getInstance().getOpenChangesetsForCurrentUser(); 58 58 if (openChangesets.isEmpty()) { 59 59 JOptionPane.showMessageDialog( -
trunk/src/org/openstreetmap/josm/data/osm/ChangesetCache.java
r9059 r9519 14 14 import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent; 15 15 import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener; 16 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 16 17 import org.openstreetmap.josm.gui.util.GuiHelper; 18 import org.openstreetmap.josm.tools.Predicate; 19 import org.openstreetmap.josm.tools.Utils; 17 20 18 21 /** … … 192 195 } 193 196 197 /** 198 * If the current user {@link JosmUserIdentityManager#isAnonymous() is known}, the {@link #getOpenChangesets() open changesets} 199 * for the {@link JosmUserIdentityManager#isCurrentUser(User) current user} are returned. Otherwise, 200 * the unfiltered {@link #getOpenChangesets() open changesets} are returned. 201 * 202 * @return a list of changesets 203 */ 204 public List<Changeset> getOpenChangesetsForCurrentUser() { 205 if (JosmUserIdentityManager.getInstance().isAnonymous()) { 206 return getOpenChangesets(); 207 } else { 208 return new ArrayList<>(Utils.filter(getOpenChangesets(), new Predicate<Changeset>() { 209 @Override 210 public boolean evaluate(Changeset object) { 211 return JosmUserIdentityManager.getInstance().isCurrentUser(object.getUser()); 212 } 213 })); 214 } 215 } 216 194 217 /* ------------------------------------------------------------------------- */ 195 218 /* interface PreferenceChangedListener */ -
trunk/src/org/openstreetmap/josm/gui/JosmUserIdentityManager.java
r9059 r9519 10 10 import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener; 11 11 import org.openstreetmap.josm.data.Preferences.StringSetting; 12 import org.openstreetmap.josm.data.osm.User; 12 13 import org.openstreetmap.josm.data.osm.UserInfo; 13 14 import org.openstreetmap.josm.gui.preferences.server.OAuthAccessTokenHolder; … … 223 224 224 225 /** 225 * Replies true if the user with name <code>username</code> is the current 226 * user 226 * Replies true if the user with name <code>username</code> is the current user 227 227 * 228 228 * @param username the user name 229 * @return true if the user with name <code>username</code> is the current 230 * user 229 * @return true if the user with name <code>username</code> is the current user 231 230 */ 232 231 public boolean isCurrentUser(String username) { 233 if (username == null || this.userName == null) return false; 234 return this.userName.equals(username); 232 return username != null && this.userName != null && this.userName.equals(username); 233 } 234 235 /** 236 * Replies true if the current user is {@link #isFullyIdentified() fully identified} and the {@link #getUserId() user ids} match, 237 * or if the current user is not {@link #isFullyIdentified() fully identified} and the {@link #userName user names} match. 238 * 239 * @param user the user to test 240 * @return true if given user is the current user 241 */ 242 public boolean isCurrentUser(User user) { 243 if (user == null) { 244 return false; 245 } else if (isFullyIdentified()) { 246 return getUserId() == user.getId(); 247 } else { 248 return isCurrentUser(user.getName()); 249 } 235 250 } 236 251 -
trunk/src/org/openstreetmap/josm/gui/io/OpenChangesetComboBoxModel.java
r9078 r9519 41 41 public void refresh() { 42 42 changesets.clear(); 43 changesets.addAll(ChangesetCache.getInstance().getOpenChangesets ());43 changesets.addAll(ChangesetCache.getInstance().getOpenChangesetsForCurrentUser()); 44 44 fireContentsChanged(this, 0, getSize()); 45 45 int idx = changesets.indexOf(selectedChangeset);
Note:
See TracChangeset
for help on using the changeset viewer.