- Timestamp:
- 2023-12-21T13:32:11+01:00 (12 months ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/ConditionalOptionPaneUtil.java
r18849 r18923 5 5 6 6 import java.awt.Component; 7 import java.awt.Dialog;8 7 import java.awt.GridBagLayout; 9 8 import java.util.HashMap; … … 16 15 import javax.swing.JPanel; 17 16 import javax.swing.JRadioButton; 18 import javax.swing.event.AncestorEvent; 19 import javax.swing.event.AncestorListener; 20 17 18 import org.openstreetmap.josm.gui.util.WindowOnTopListener; 21 19 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; 22 20 import org.openstreetmap.josm.spi.preferences.Config; … … 43 41 /** a set indication that (preference key) is or may be stored for the currently active bulk operation */ 44 42 private static final Set<String> immediateActive = new HashSet<>(); 43 /** The prefix for config options */ 44 private static final String CONFIG_PREFIX = "message."; 45 45 46 46 /** … … 61 61 return Utils.firstNonNull(immediateChoices.get(prefKey), 62 62 sessionChoices.get(prefKey), 63 !Config.getPref().getBoolean("message." + prefKey, true) ? Config.getPref().getInt("message." + prefKey + ".value", -1) : -1 63 !Config.getPref().getBoolean(CONFIG_PREFIX + prefKey, true) 64 ? Config.getPref().getInt(CONFIG_PREFIX + prefKey + ".value", -1) 65 : -1 64 66 ); 65 67 } … … 228 230 break; 229 231 case PERMANENT: 230 Config.getPref().putBoolean( "message."+ prefKey, false);231 Config.getPref().putInt( "message."+ prefKey + ".value", value);232 Config.getPref().putBoolean(CONFIG_PREFIX + prefKey, false); 233 Config.getPref().putInt(CONFIG_PREFIX + prefKey + ".value", value); 232 234 break; 233 235 } … … 288 290 add(cbStandard, GBC.eol()); 289 291 290 this.addAncestorListener(new AncestorListener() { 291 boolean wasAlwaysOnTop; 292 @Override 293 public void ancestorAdded(AncestorEvent event) { 294 if (event.getAncestor() instanceof Dialog) { 295 Dialog dialog = (Dialog) event.getAncestor(); 296 wasAlwaysOnTop = dialog.isAlwaysOnTop(); 297 if (dialog.isVisible() && dialog.isModal()) { 298 dialog.setAlwaysOnTop(true); 299 } 300 } 301 } 302 303 @Override 304 public void ancestorRemoved(AncestorEvent event) { 305 if (event.getAncestor() instanceof Dialog) { 306 Dialog dialog = (Dialog) event.getAncestor(); 307 if (dialog.isVisible() && dialog.isModal()) { 308 dialog.setAlwaysOnTop(wasAlwaysOnTop); 309 } 310 } 311 } 312 313 @Override 314 public void ancestorMoved(AncestorEvent event) { 315 // Do nothing 316 } 317 }); 292 this.addAncestorListener(new WindowOnTopListener()); 318 293 } 319 294 320 295 NotShowAgain getNotShowAgain() { 321 return cbStandard.isSelected() 322 ? NotShowAgain.NO 323 : cbShowImmediateDialog.isSelected() 324 ? NotShowAgain.OPERATION 325 : cbShowSessionDialog.isSelected() 326 ? NotShowAgain.SESSION 327 : cbShowPermanentDialog.isSelected() 328 ? NotShowAgain.PERMANENT 329 : null; 296 if (cbStandard.isSelected()) { 297 return NotShowAgain.NO; 298 } 299 if (cbShowImmediateDialog.isSelected()) { 300 return NotShowAgain.OPERATION; 301 } 302 if (cbShowSessionDialog.isSelected()) { 303 return NotShowAgain.SESSION; 304 } 305 if (cbShowPermanentDialog.isSelected()) { 306 return NotShowAgain.PERMANENT; 307 } 308 return null; 330 309 } 331 310 } -
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r18849 r18923 31 31 import javax.swing.KeyStroke; 32 32 import javax.swing.UIManager; 33 import javax.swing.WindowConstants; 33 34 34 35 import org.openstreetmap.josm.gui.help.HelpBrowser; … … 36 37 import org.openstreetmap.josm.gui.util.GuiHelper; 37 38 import org.openstreetmap.josm.gui.util.WindowGeometry; 39 import org.openstreetmap.josm.gui.util.WindowOnTopListener; 38 40 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; 39 41 import org.openstreetmap.josm.io.NetworkManager; … … 48 50 /** 49 51 * General configurable dialog window. 50 * 52 * <p> 51 53 * If dialog is modal, you can use {@link #getValue()} to retrieve the 52 54 * button index. Note that the user can close the dialog 53 55 * by other means. This is usually equivalent to cancel action. 54 * 56 * <p> 55 57 * For non-modal dialogs, {@link #buttonAction(int, ActionEvent)} can be overridden. 56 * 58 * <p> 57 59 * There are various options, see below. 58 * 60 * <p> 59 61 * Note: The button indices are counted from 1 and upwards. 60 62 * So for {@link #getValue()}, {@link #setDefaultButton(int)} and 61 63 * {@link #setCancelButton} the first button has index 1. 62 * 64 * <p> 63 65 * Simple example: 64 66 * <pre> … … 85 87 private int toggleValue = -1; 86 88 private ConditionalOptionPaneUtil.MessagePanel togglePanel; 87 private final Component parent ;89 private final Component parentComponent; 88 90 private Component content; 89 91 private final String[] bTexts; … … 94 96 protected JButton defaultButton; 95 97 private transient Icon icon; 96 private final boolean modal;98 private final boolean isModal; 97 99 private boolean focusOnDefaultButton; 98 100 … … 158 160 public ExtendedDialog(Component parent, String title, String[] buttonTexts, boolean modal, boolean disposeOnClose) { 159 161 super(searchRealParent(parent), title, modal ? ModalityType.DOCUMENT_MODAL : ModalityType.MODELESS); 160 this.parent = parent;161 this. modal = modal;162 this.parentComponent = parent; 163 this.isModal = modal; 162 164 bTexts = Utils.copyArray(buttonTexts); 163 165 if (disposeOnClose) { 164 setDefaultCloseOperation( JDialog.DISPOSE_ON_CLOSE);166 setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); 165 167 } 166 168 this.disposeOnClose = disposeOnClose; … … 372 374 373 375 setSize(d); 374 setLocationRelativeTo(parent );376 setLocationRelativeTo(parentComponent); 375 377 } 376 378 … … 401 403 Dimension screenSize = GuiHelper.getScreenSize(); 402 404 Dimension x = new Dimension(screenSize.width*2/3, screenSize.height*2/3); 403 if (parent != null && parent.isVisible()) {404 x = GuiHelper.getFrameForComponent(parent ).getSize();405 if (parentComponent != null && parentComponent.isVisible()) { 406 x = GuiHelper.getFrameForComponent(parentComponent).getSize(); 405 407 } 406 408 return x; … … 462 464 if (visible && isModal()) { 463 465 this.setAlwaysOnTop(true); 466 this.addWindowFocusListener(new WindowOnTopListener()); 464 467 } 465 468 super.setVisible(visible); … … 479 482 @Override 480 483 public ExtendedDialog toggleEnable(String togglePref) { 481 if (! modal) {484 if (!isModal) { 482 485 throw new IllegalStateException(); 483 486 } … … 495 498 @Override 496 499 public ExtendedDialog setCancelButton(Integer... cancelButtonIdx) { 497 this.cancelButtonIdx = new HashSet<>(Arrays. <Integer>asList(cancelButtonIdx));500 this.cancelButtonIdx = new HashSet<>(Arrays.asList(cancelButtonIdx)); 498 501 return this; 499 502 } -
trunk/src/org/openstreetmap/josm/gui/HelpAwareOptionPane.java
r18849 r18923 28 28 import org.openstreetmap.josm.gui.util.GuiHelper; 29 29 import org.openstreetmap.josm.gui.util.WindowGeometry; 30 import org.openstreetmap.josm.gui.util.WindowOnTopListener; 30 31 import org.openstreetmap.josm.gui.widgets.HtmlPanel; 31 32 import org.openstreetmap.josm.tools.ImageProvider; … … 353 354 if (dialog.isModal()) { 354 355 dialog.setAlwaysOnTop(true); 356 dialog.addWindowFocusListener(new WindowOnTopListener()); 355 357 } 356 358 dialog.setVisible(true);
Note:
See TracChangeset
for help on using the changeset viewer.