@@ -183,6 +183,29 @@ public void run() {
183
183
}
184
184
}
185
185
186
+ private class PinAction extends Action {
187
+ PinAction () {
188
+ super (JFaceResources .getString ("PopupDialog.pinDialog" ), IAction .AS_CHECK_BOX ); //$NON-NLS-1$
189
+ setChecked (pinDialog );
190
+ }
191
+
192
+ @ Override
193
+ public void run () {
194
+ pinDialog = isChecked ();
195
+ }
196
+ }
197
+
198
+ private class CloseAction extends Action {
199
+ CloseAction () {
200
+ super (JFaceResources .getString ("PopupDialog.close" ), IAction .AS_PUSH_BUTTON ); //$NON-NLS-1$
201
+ }
202
+
203
+ @ Override
204
+ public void run () {
205
+ close ();
206
+ }
207
+ }
208
+
186
209
/**
187
210
*
188
211
* Remember location action for the dialog.
@@ -341,6 +364,9 @@ private static GridLayoutFactory getPopupLayout() {
341
364
* shown.
342
365
*/
343
366
private boolean persistLocation = false ;
367
+
368
+ private boolean pinDialog = false ;
369
+
344
370
/**
345
371
* Flag specifying whether to use new 3.4 API instead of the old one.
346
372
*
@@ -358,6 +384,8 @@ private static GridLayoutFactory getPopupLayout() {
358
384
*/
359
385
private String infoText ;
360
386
387
+ private boolean showPinAction ;
388
+
361
389
/**
362
390
* Constructs a new instance of <code>PopupDialog</code>.
363
391
*
@@ -407,51 +435,103 @@ public PopupDialog(Shell parent, int shellStyle, boolean takeFocusOnOpen,
407
435
boolean showDialogMenu , boolean showPersistActions ,
408
436
String titleText , String infoText ) {
409
437
this (parent , shellStyle , takeFocusOnOpen , persistSize , persistLocation ,
410
- showDialogMenu , showPersistActions , titleText , infoText , true );
438
+ showDialogMenu , showPersistActions , false , titleText , infoText , true );
439
+ }
411
440
441
+ /**
442
+ * Constructs a new instance of <code>PopupDialog</code>.
443
+ *
444
+ * @param parent The parent shell.
445
+ * @param shellStyle The shell style.
446
+ * @param takeFocusOnOpen A boolean indicating whether focus should be taken
447
+ * by this popup when it opens.
448
+ * @param persistSize A boolean indicating whether the size should be
449
+ * persisted upon close of the dialog. The size can
450
+ * only be persisted if the dialog settings for
451
+ * persisting the bounds are also specified. If a menu
452
+ * action will be provided that allows the user to
453
+ * control this feature and the user hasn't changed
454
+ * that setting, then this flag is used as initial
455
+ * default for the menu.
456
+ * @param persistLocation A boolean indicating whether the location should be
457
+ * persisted upon close of the dialog. The location
458
+ * can only be persisted if the dialog settings for
459
+ * persisting the bounds are also specified. If a menu
460
+ * action will be provided that allows the user to
461
+ * control this feature and the user hasn't changed
462
+ * that setting, then this flag is used as initial
463
+ * default for the menu. default for the menu until
464
+ * the user changed it.
465
+ * @param showDialogMenu A boolean indicating whether a menu for moving and
466
+ * resizing the popup should be provided.
467
+ * @param showPersistActions A boolean indicating whether actions allowing the
468
+ * user to control the persisting of the dialog bounds
469
+ * and location should be shown in the dialog menu.
470
+ * This parameter has no effect if
471
+ * <code>showDialogMenu</code> is <code>false</code>.
472
+ * @param showPinAction A boolean indicating whether actions allowing the
473
+ * user to pin the dialog so it remains visible and
474
+ * accessible when deactivated should be shown in the
475
+ * dialog menu. This parameter has no effect if
476
+ * <code>showDialogMenu</code> is <code>false</code>.
477
+ * @param titleText Text to be shown in an upper title area, or
478
+ * <code>null</code> if there is no title.
479
+ * @param infoText Text to be shown in a lower info area, or
480
+ * <code>null</code> if there is no info area.
481
+ *
482
+ * @see PopupDialog#getDialogSettings()
483
+ *
484
+ * @since 3.35
485
+ */
486
+ public PopupDialog (Shell parent , int shellStyle , boolean takeFocusOnOpen ,
487
+ boolean persistSize , boolean persistLocation ,
488
+ boolean showDialogMenu , boolean showPersistActions , boolean showPinAction ,
489
+ String titleText , String infoText ) {
490
+ this (parent , shellStyle , takeFocusOnOpen , persistSize , persistLocation ,
491
+ showDialogMenu , showPersistActions , showPinAction , titleText , infoText , true );
412
492
}
413
493
414
494
/**
415
495
* Constructs a new instance of <code>PopupDialog</code>.
416
496
*
417
- * @param parent
418
- * The parent shell.
419
- * @param shellStyle
420
- * The shell style .
421
- * @param takeFocusOnOpen
422
- * A boolean indicating whether focus should be taken by this
423
- * popup when it opens.
424
- * @param persistSize
425
- * A boolean indicating whether the size should be persisted upon
426
- * close of the dialog. The size can only be persisted if the
427
- * dialog settings for persisting the bounds are also specified.
428
- * If a menu action will be provided that allows the user to
429
- * control this feature and the user hasn't changed that setting,
430
- * then this flag is used as initial default for the menu.
431
- * @param persistLocation
432
- * A boolean indicating whether the location should be persisted
433
- * upon close of the dialog. The location can only be persisted
434
- * if the dialog settings for persisting the bounds are also
435
- * specified. If a menu action will be provided that allows the
436
- * user to control this feature and the user hasn't changed that
437
- * setting, then this flag is used as initial default for the
438
- * menu. default for the menu until the user changed it.
439
- * @param showDialogMenu
440
- * A boolean indicating whether a menu for moving and resizing
441
- * the popup should be provided.
442
- * @param showPersistActions
443
- * A boolean indicating whether actions allowing the user to
444
- * control the persisting of the dialog bounds and location
445
- * should be shown in the dialog menu. This parameter has no
446
- * effect if <code>showDialogMenu</code> is <code>false</code>.
447
- * @param titleText
448
- * Text to be shown in an upper title area, or <code>null</code>
449
- * if there is no title .
450
- * @param infoText
451
- * Text to be shown in a lower info area, or <code>null</code>
452
- * if there is no info area.
453
- * @param use34API
454
- * <code>true</code> if 3.4 API should be used
497
+ * @param parent The parent shell.
498
+ * @param shellStyle The shell style .
499
+ * @param takeFocusOnOpen A boolean indicating whether focus should be taken
500
+ * by this popup when it opens .
501
+ * @param persistSize A boolean indicating whether the size should be
502
+ * persisted upon close of the dialog. The size can
503
+ * only be persisted if the dialog settings for
504
+ * persisting the bounds are also specified. If a menu
505
+ * action will be provided that allows the user to
506
+ * control this feature and the user hasn't changed
507
+ * that setting, then this flag is used as initial
508
+ * default for the menu.
509
+ * @param persistLocation A boolean indicating whether the location should be
510
+ * persisted upon close of the dialog. The location
511
+ * can only be persisted if the dialog settings for
512
+ * persisting the bounds are also specified. If a menu
513
+ * action will be provided that allows the user to
514
+ * control this feature and the user hasn't changed
515
+ * that setting, then this flag is used as initial
516
+ * default for the menu. default for the menu until
517
+ * the user changed it.
518
+ * @param showDialogMenu A boolean indicating whether a menu for moving and
519
+ * resizing the popup should be provided.
520
+ * @param showPersistActions A boolean indicating whether actions allowing the
521
+ * user to control the persisting of the dialog bounds
522
+ * and location should be shown in the dialog menu.
523
+ * This parameter has no effect if
524
+ * <code>showDialogMenu</code> is <code>false</code>.
525
+ * @param showPinAction A boolean indicating whether actions allowing the
526
+ * user to pin the dialog so it remains visible and
527
+ * accessible when deactivated should be shown in the
528
+ * dialog menu. This parameter has no effect if
529
+ * <code>showDialogMenu</code> is <code>false</code> .
530
+ * @param titleText Text to be shown in an upper title area, or
531
+ * <code>null</code> if there is no title.
532
+ * @param infoText Text to be shown in a lower info area, or
533
+ * <code>null</code> if there is no info area.
534
+ * @param use34API <code>true</code> if 3.4 API should be used
455
535
*
456
536
* @see PopupDialog#getDialogSettings()
457
537
*
@@ -460,6 +540,7 @@ public PopupDialog(Shell parent, int shellStyle, boolean takeFocusOnOpen,
460
540
private PopupDialog (Shell parent , int shellStyle , boolean takeFocusOnOpen ,
461
541
boolean persistSize , boolean persistLocation ,
462
542
boolean showDialogMenu , boolean showPersistActions ,
543
+ boolean showPinAction ,
463
544
String titleText , String infoText , boolean use34API ) {
464
545
super (parent );
465
546
// Prior to 3.4, we encouraged use of SWT.NO_TRIM and provided a
@@ -477,6 +558,7 @@ private PopupDialog(Shell parent, int shellStyle, boolean takeFocusOnOpen,
477
558
this .takeFocusOnOpen = takeFocusOnOpen ;
478
559
this .showDialogMenu = showDialogMenu ;
479
560
this .showPersistActions = showPersistActions ;
561
+ this .showPinAction = showPinAction ;
480
562
this .titleText = titleText ;
481
563
this .infoText = infoText ;
482
564
@@ -504,7 +586,7 @@ protected void configureShell(Shell shell) {
504
586
* the asyncClose() call is disabled in GTK. See Eclipse Bugs
505
587
* 466500 and 113577 for more information.
506
588
*/
507
- if (listenToDeactivate && event .widget == getShell ()
589
+ if (! pinDialog && listenToDeactivate && event .widget == getShell ()
508
590
&& getShell ().getShells ().length == 0 ) {
509
591
if (!Util .isGtk ()) {
510
592
asyncClose ();
@@ -538,7 +620,7 @@ && getShell().getShells().length == 0) {
538
620
if (parent != null ) {
539
621
if ((getShellStyle () & SWT .ON_TOP ) != 0 ) {
540
622
parentDeactivateListener = event -> {
541
- if (listenToParentDeactivate ) {
623
+ if (! pinDialog && listenToParentDeactivate ) {
542
624
asyncClose ();
543
625
} else {
544
626
// Our first deactivate, now start listening on the Mac.
@@ -565,7 +647,7 @@ public void handleEvent(Event event) {
565
647
* "Show all Instances" and "Show all References" do.
566
648
* They all are InspectPopupDialog instances...
567
649
*/
568
- if (event .widget != parent || !listenToDeactivate || parent .isDisposed ()) {
650
+ if (pinDialog || event .widget != parent || !listenToDeactivate || parent .isDisposed ()) {
569
651
return ;
570
652
}
571
653
parent .removeListener (SWT .Activate , this );
@@ -893,6 +975,10 @@ protected void fillDialogMenu(IMenuManager dialogMenu) {
893
975
dialogMenu .add (new PersistBoundsAction ());
894
976
}
895
977
}
978
+ if (this .showPinAction ) {
979
+ dialogMenu .add (new PinAction ());
980
+ }
981
+ dialogMenu .add (new CloseAction ());
896
982
dialogMenu .add (new Separator ("SystemMenuEnd" )); //$NON-NLS-1$
897
983
}
898
984
@@ -1524,4 +1610,5 @@ private void handleDispose() {
1524
1610
}
1525
1611
titleFont = null ;
1526
1612
}
1613
+
1527
1614
}
0 commit comments