Ticket #17270: 17270-focus-and-count.patch
File 17270-focus-and-count.patch, 3.2 KB (added by , 4 years ago) |
---|
-
src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java
2 2 package org.openstreetmap.josm.gui.history; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.trn; 5 6 6 7 import java.awt.Component; 7 8 import java.awt.Dimension; … … 8 9 import java.awt.Point; 9 10 import java.util.ArrayList; 10 11 import java.util.Collection; 11 import java.util.HashMap;12 12 import java.util.Iterator; 13 import java.util.LinkedHashMap; 14 import java.util.LinkedList; 13 15 import java.util.List; 14 import java.util.Map;15 16 import java.util.Map.Entry; 16 17 import java.util.Objects; 17 18 import java.util.function.Predicate; … … 28 29 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; 29 30 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 30 31 import org.openstreetmap.josm.gui.util.WindowGeometry; 32 import org.openstreetmap.josm.spi.preferences.Config; 31 33 import org.openstreetmap.josm.tools.JosmRuntimeException; 32 34 import org.openstreetmap.josm.tools.Logging; 33 35 import org.openstreetmap.josm.tools.SubclassFilteredCollection; … … 58 60 59 61 private static HistoryBrowserDialogManager instance; 60 62 61 private final Map<Long, HistoryBrowserDialog> dialogs = newHashMap<>();63 private final LinkedHashMap<Long, HistoryBrowserDialog> dialogs = new LinkedHashMap<>(); 62 64 63 65 private final Predicate<PrimitiveId> unloadedHistoryPredicate = new UnloadedHistoryPredicate(); 64 66 … … 143 145 } 144 146 dialog.setVisible(false); 145 147 dialog.dispose(); 148 149 if (!dialogs.isEmpty()) { 150 // see #17270: set focus to last dialog 151 new LinkedList<>(dialogs.values()).getLast().toFront(); 152 } 146 153 } 147 154 148 155 /** … … 224 231 * @since 16123 225 232 */ 226 233 public void showHistory(Component parent, final Collection<? extends PrimitiveId> primitives) { 234 if (primitives.size() > Config.getPref().getInt("warn.open.maxhistory", 5) && 235 /* I18N english text for value 1 makes no real sense, never called for values <= maxhistory (usually 5) */ 236 JOptionPane.OK_OPTION != JOptionPane.showConfirmDialog(MainApplication.getMainFrame(), 237 "<html>" + trn( 238 "You are about to open <b>{0}</b> different history dialog simultaneously.<br/>Do you want to continue?", 239 "You are about to open <b>{0}</b> different history dialogs simultaneously.<br/>Do you want to continue?", 240 primitives.size(), primitives.size()) + "</html>", 241 tr("Confirmation"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE)) { 242 return; 243 } 244 227 245 final List<PrimitiveId> realPrimitives = new ArrayList<>(primitives); 228 246 hooks.forEach(h -> h.modifyRequestedIds(realPrimitives)); 229 247 final Collection<? extends PrimitiveId> notNewPrimitives = SubclassFilteredCollection.filter(realPrimitives, notNewPredicate);