Changeset 16622 in josm for trunk/src/org
- Timestamp:
- 2020-06-14T14:55:14+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r16426 r16622 29 29 import java.util.TreeMap; 30 30 import java.util.concurrent.TimeUnit; 31 import java.util.function.Predicate;32 31 import java.util.stream.Collectors; 33 32 import java.util.stream.Stream; … … 184 183 protected final SortedMap<String, Setting<?>> defaultsMap = new TreeMap<>(); 185 184 186 private final Predicate<Entry<String, Setting<?>>> NO_DEFAULT_SETTINGS_ENTRY =187 e -> !e.getValue().equals(defaultsMap.get(e.getKey()));188 189 185 /** 190 186 * Indicates whether {@link #init(boolean)} completed successfully. … … 420 416 */ 421 417 public synchronized void save() throws IOException { 422 save(getPreferenceFile(), settingsMap.entrySet().stream().filter( NO_DEFAULT_SETTINGS_ENTRY), false);418 save(getPreferenceFile(), settingsMap.entrySet().stream().filter(e -> !e.getValue().equals(defaultsMap.get(e.getKey()))), false); 423 419 } 424 420 -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java
r16592 r16622 16 16 import java.util.Map.Entry; 17 17 import java.util.Objects; 18 import java.util.function.Predicate;19 18 20 19 import javax.swing.JOptionPane; … … 42 41 public final class HistoryBrowserDialogManager implements LayerChangeListener { 43 42 44 static final class UnloadedHistoryPredicate implements Predicate<PrimitiveId> { 45 private final HistoryDataSet hds = HistoryDataSet.getInstance(); 46 47 @Override 48 public boolean test(PrimitiveId p) { 49 History h = hds.getHistory(p); 50 if (h == null) 51 // reload if the history is not in the cache yet 52 return true; 53 else 54 // reload if the history object of the selected object is not in the cache yet 55 return !p.isNew() && h.getByVersion(p.getUniqueId()) == null; 56 } 43 private static boolean isUnloaded(PrimitiveId p) { 44 History h = HistoryDataSet.getInstance().getHistory(p); 45 if (h == null) 46 // reload if the history is not in the cache yet 47 return true; 48 else 49 // reload if the history object of the selected object is not in the cache yet 50 return !p.isNew() && h.getByVersion(p.getUniqueId()) == null; 57 51 } 58 52 … … 62 56 63 57 private final LinkedHashMap<Long, HistoryBrowserDialog> dialogs = new LinkedHashMap<>(); 64 65 private final Predicate<PrimitiveId> unloadedHistoryPredicate = new UnloadedHistoryPredicate();66 67 private final Predicate<PrimitiveId> notNewPredicate = p -> !p.isNew();68 58 69 59 private static final List<HistoryHook> hooks = new ArrayList<>(); … … 217 207 final List<PrimitiveId> realPrimitives = new ArrayList<>(primitives); 218 208 hooks.forEach(h -> h.modifyRequestedIds(realPrimitives)); 219 final Collection<? extends PrimitiveId> notNewPrimitives = SubclassFilteredCollection.filter(realPrimitives, notNewPredicate);209 final Collection<? extends PrimitiveId> notNewPrimitives = SubclassFilteredCollection.filter(realPrimitives, p1 -> !p1.isNew()); 220 210 if (notNewPrimitives.isEmpty()) { 221 211 JOptionPane.showMessageDialog( … … 237 227 } 238 228 239 Collection<? extends PrimitiveId> toLoad = SubclassFilteredCollection.filter(notNewPrimitives, unloadedHistoryPredicate);229 Collection<? extends PrimitiveId> toLoad = SubclassFilteredCollection.filter(notNewPrimitives, HistoryBrowserDialogManager::isUnloaded); 240 230 if (!toLoad.isEmpty()) { 241 231 MainApplication.worker.submit(new HistoryLoadTask(parent).addPrimitiveIds(toLoad));
Note:
See TracChangeset
for help on using the changeset viewer.