Changeset 18849 in josm
- Timestamp:
- 2023-10-03T17:20:32+02:00 (17 months ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/ConditionalOptionPaneUtil.java
r14380 r18849 5 5 6 6 import java.awt.Component; 7 import java.awt.Dialog; 7 8 import java.awt.GridBagLayout; 8 9 import java.util.HashMap; … … 15 16 import javax.swing.JPanel; 16 17 import javax.swing.JRadioButton; 18 import javax.swing.event.AncestorEvent; 19 import javax.swing.event.AncestorListener; 17 20 18 21 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; … … 24 27 * ConditionalOptionPaneUtil provides static utility methods for displaying modal message dialogs 25 28 * which can be enabled/disabled by the user. 26 * 29 * <p> 27 30 * They wrap the methods provided by {@link JOptionPane}. Within JOSM you should use these 28 31 * methods rather than the bare methods from {@link JOptionPane} because the methods provided … … 93 96 * It is always on top even if there are other open windows like detached dialogs, 94 97 * relation editors, history browsers and the like. 95 * 98 * <p> 96 99 * Set <code>optionType</code> to {@link JOptionPane#YES_NO_OPTION} for a dialog with a YES and 97 100 * a NO button. 98 101 * <p> 99 102 * Set <code>optionType</code> to {@link JOptionPane#YES_NO_CANCEL_OPTION} for a dialog with a YES, 100 103 * a NO and a CANCEL button 101 * 104 * <p> 102 105 * Returns one of the constants JOptionPane.YES_OPTION, JOptionPane.NO_OPTION, 103 106 * JOptionPane.CANCEL_OPTION or JOptionPane.CLOSED_OPTION depending on the action chosen by … … 133 136 * It is always on top even if there are other open windows like detached dialogs, 134 137 * relation editors, history browsers and the like. 135 * 138 * <p> 136 139 * Set <code>optionType</code> to {@link JOptionPane#YES_NO_OPTION} for a dialog with a YES and 137 140 * a NO button. 138 141 * <p> 139 142 * Set <code>optionType</code> to {@link JOptionPane#YES_NO_CANCEL_OPTION} for a dialog with a YES, 140 143 * a NO and a CANCEL button 141 * 144 * <p> 142 145 * Replies true, if the selected option is equal to <code>trueOption</code>, otherwise false. 143 146 * Replies true, if the dialog is not displayed because the respective preference option … … 181 184 * is always on top even if there are other open windows like detached dialogs, 182 185 * relation editors, history browsers and the like. 183 * 186 * <p> 184 187 * If there is a preference with key <code>preferenceKey</code> and value <code>false</code> 185 188 * the dialog is not show. … … 284 287 } 285 288 add(cbStandard, GBC.eol()); 289 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 }); 286 318 } 287 319 -
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r18211 r18849 460 460 } 461 461 } 462 if (visible && isModal()) { 463 this.setAlwaysOnTop(true); 464 } 462 465 super.setVisible(visible); 463 466 -
trunk/src/org/openstreetmap/josm/gui/HelpAwareOptionPane.java
r16217 r18849 219 219 * user clicks on the "Help" button the option dialog remains open and JOSM launches the help 220 220 * browser. 221 * 221 * <p> 222 222 * <code>helpTopic</code> is the trailing part of a JOSM online help URL, i.e. the part after the leading 223 * <code>https://josm.openstreetmap.de/wiki/Help</code>. It should start with a leading '/' and it223 * {@code https://josm.openstreetmap.de/wiki/Help}. It should start with a leading '/' and it 224 224 * may include an anchor after a '#'. 225 * 225 * <p> 226 226 * <strong>Examples</strong> 227 227 * <ul> … … 351 351 HelpUtil.setHelpContext(dialog.getRootPane(), helpTopic); 352 352 } 353 if (dialog.isModal()) { 354 dialog.setAlwaysOnTop(true); 355 } 353 356 dialog.setVisible(true); 354 357 } … … 372 375 * Run it in Event Dispatch Thread. 373 376 * This version does not return anything, so it is more like {@code showMessageDialog}. 374 * 377 * <p> 375 378 * It can be used, when you need to show a message dialog from a worker thread, 376 379 * e.g. from {@code PleaseWaitRunnable}.
Note:
See TracChangeset
for help on using the changeset viewer.