Lines 362-378
Link Here
|
362 |
} |
362 |
} |
363 |
|
363 |
|
364 |
/** |
364 |
/** |
365 |
* If the help frame is opened from a modal dialog, it should be closed |
365 |
* If the help frame is opened from a dialog, it should be |
366 |
* automatically if that dialog closes. See bug 233543. Also the windows |
366 |
* <ol> |
367 |
* should be rearranged so that both are visible. See bug #233542. |
367 |
* <li>closed automatically if the dialog is modal (bug 233543)</li> |
|
|
368 |
* <li>brought to front if the dialog is non-modal (bug 241351).</li> |
369 |
* </ol> |
370 |
* when that dialog closes. Also the windows should be rearranged so that |
371 |
* both are visible. See bug #233542. |
368 |
*/ |
372 |
*/ |
369 |
private void bindFrameViewerToCurrentDialog() { |
373 |
private void bindFrameViewerToCurrentDialog() { |
|
|
374 |
|
375 |
Dialog topDialog = findTopDialog(false); |
376 |
if (topDialog == null) { |
377 |
topDialog = findTopDialog(true); |
378 |
} |
379 |
if (topDialog != null) { |
380 |
rearrange(topDialog, frameViewer); |
381 |
final Dialog finalTopDialog = topDialog; |
382 |
topDialog.addWindowListener(new WindowAdapter() { |
383 |
|
384 |
@Override |
385 |
public void windowClosed(WindowEvent e) { |
386 |
if (frameViewer != null) { |
387 |
if (finalTopDialog.isModal()) { |
388 |
frameViewer.setVisible(false); |
389 |
} else { |
390 |
frameViewer.toFront(); |
391 |
} |
392 |
} |
393 |
finalTopDialog.removeWindowListener(this); |
394 |
} |
395 |
}); |
396 |
} |
397 |
} |
398 |
|
399 |
private Dialog findTopDialog(boolean acceptModal) { |
370 |
int maxDepth = 0; |
400 |
int maxDepth = 0; |
371 |
Dialog topDialog = null; |
401 |
Dialog topDialog = null; |
372 |
for (Window w : JDialog.getWindows()) { |
402 |
for (Window w : JDialog.getWindows()) { |
373 |
if (w instanceof Dialog && w.isVisible()) { |
403 |
if (w instanceof Dialog && w.isVisible()) { |
374 |
Dialog d = (Dialog) w; |
404 |
Dialog d = (Dialog) w; |
375 |
if (isRelevantDialog(d)) { |
405 |
if (isRelevantDialog(d, acceptModal)) { |
376 |
int depth = 0; |
406 |
int depth = 0; |
377 |
for (Window o = d.getOwner(); o != null; o = o.getOwner()) { |
407 |
for (Window o = d.getOwner(); o != null; o = o.getOwner()) { |
378 |
depth++; |
408 |
depth++; |
Lines 386-405
Link Here
|
386 |
} |
416 |
} |
387 |
} |
417 |
} |
388 |
} |
418 |
} |
389 |
if (topDialog != null) { |
419 |
return topDialog; |
390 |
rearrange(topDialog, frameViewer); |
|
|
391 |
final Dialog finalTopDialog = topDialog; |
392 |
topDialog.addWindowListener(new WindowAdapter() { |
393 |
|
394 |
@Override |
395 |
public void windowClosed(WindowEvent e) { |
396 |
if (frameViewer != null) { |
397 |
frameViewer.setVisible(false); |
398 |
} |
399 |
finalTopDialog.removeWindowListener(this); |
400 |
} |
401 |
}); |
402 |
} |
403 |
} |
420 |
} |
404 |
|
421 |
|
405 |
private void displayHelpInDialog(JHelp jh) { |
422 |
private void displayHelpInDialog(JHelp jh) { |
Lines 620-626
Link Here
|
620 |
if (w instanceof Dialog) { |
637 |
if (w instanceof Dialog) { |
621 |
Dialog d = (Dialog)w; |
638 |
Dialog d = (Dialog)w; |
622 |
|
639 |
|
623 |
if (isRelevantDialog(d) || d == dialogViewer) { |
640 |
if (isRelevantDialog(d, false) || d == dialogViewer) { |
624 |
|
641 |
|
625 |
//#47150: Race condition in toolkit if two dialogs are shown in a row |
642 |
//#47150: Race condition in toolkit if two dialogs are shown in a row |
626 |
if (d instanceof JDialog) { |
643 |
if (d instanceof JDialog) { |
Lines 703-713
Link Here
|
703 |
|
720 |
|
704 |
/** |
721 |
/** |
705 |
* Test whether a window is a dialog that is relevant to the help displayer. |
722 |
* Test whether a window is a dialog that is relevant to the help displayer. |
706 |
* Only modal dialogs that are NOT print dialogs, progress dialog or similar |
723 |
* Only dialogs that are NOT print dialogs, progress dialog or similar |
707 |
* system dialogs are relevant. |
724 |
* system dialogs are relevant. |
|
|
725 |
* |
726 |
* @param acceptNonModal True to accept both modal and non-modal dialogs, |
727 |
* false to accept modal dialogs only. |
708 |
*/ |
728 |
*/ |
709 |
private static boolean isRelevantDialog(Dialog d) { |
729 |
private static boolean isRelevantDialog(Dialog d, boolean acceptNonModal) { |
710 |
if (!d.isModal() || d instanceof ProgressDialog) { |
730 |
if ((!acceptNonModal && !d.isModal()) || d instanceof ProgressDialog) { |
711 |
return false; |
731 |
return false; |
712 |
} |
732 |
} |
713 |
String dlgClass = d.getClass().getName(); |
733 |
String dlgClass = d.getClass().getName(); |