Skip to content

Commit

Permalink
Fix enhancements menu buggy on Linux / GTK
Browse files Browse the repository at this point in the history
  • Loading branch information
RedeemerSK committed Jun 29, 2024
1 parent 7d476d3 commit c4886ff
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public IInformationControl doCreateInformationControl(Shell parent) {
ToolBarManager tbmSecondary= new ToolBarManager(SWT.FLAT);
tbmSecondary.createControl(toolbarComposite).setLayoutData(new GridData(SWT.END, SWT.BEGINNING, false, false));
BrowserTextAccessor browserAccessor= new BrowserTextAccessor(iControl);
var stylingMenuAction= new SignatureStylingMenuToolbarAction(parent, browserAccessor,
var stylingMenuAction= new SignatureStylingMenuToolbarAction(iControl.getShell(), browserAccessor,
() -> iControl.getInput() == null ? null : iControl.getInput().getHtml(),
viewRefreshTask);
tbmSecondary.add(stylingMenuAction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ private JavadocStylingMessages() {
public static String JavadocStyling_typeParamsColoring;
public static String JavadocStyling_enabledTooltip;
public static String JavadocStyling_disabledTooltip;
public static String JavadocStyling_enhancementsDisabled;
public static String JavadocStyling_noEnhancements;
public static String JavadocStyling_colorPreferences_menu;
public static String JavadocStyling_colorPreferences_typeParameter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
JavadocStyling_typeParamsColoring=Type Parameters Coloring
JavadocStyling_enabledTooltip=Disable styling enhancements
JavadocStyling_disabledTooltip=Enable styling enhancements
JavadocStyling_enhancementsDisabled=Styling enhancements are disabled
JavadocStyling_noEnhancements=No styling enhancements available for JavaDoc
JavadocStyling_colorPreferences_menu=Colors Preferences
JavadocStyling_colorPreferences_typeParameter=Type Parameter #{0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ public SignatureStylingMenuToolbarAction(Shell parent, BrowserTextAccessor brows
super(JavadocStylingMessages.JavadocStyling_enabledTooltip, IAction.AS_DROP_DOWN_MENU);
Objects.requireNonNull(parent);
setImageDescriptor(JavaPluginImages.DESC_ETOOL_JDOC_HOVER_EDIT);
// SignatureStylingColorSubMenuItem requires top level shell to display native color picker
// JavadocView passes to level shell but JavadocHover passes hover's shell
// (Display.getActiveShell() would not work since JavadocView is created when active shell is startup splash screen shell)
Shell topLevelShell = (parent.getParent() instanceof Shell parentShell) ? parentShell : parent;
enabledActions= new Action[] {
new ToggleSignatureTypeParametersColoringAction(),
// widget for following action is being removed and re-added repeatedly, see SignatureStylingColorSubMenuItem.menuShown()
new SignatureStylingColorSubMenuItem(parent, javadocContentSupplier)};
new SignatureStylingColorSubMenuItem(topLevelShell, javadocContentSupplier)};
actions= noStylingActions;
setMenuCreator(this);
this.parent= parent;
Expand Down Expand Up @@ -134,6 +138,7 @@ private void runEnhancementsReconfiguredTask() {
private void presentEnhancementsState() {
setImageDescriptor(enhancementsEnabled ? JavaPluginImages.DESC_ETOOL_JDOC_HOVER_EDIT : JavaPluginImages.DESC_DTOOL_JDOC_HOVER_EDIT);
setToolTipText(enhancementsEnabled ? JavadocStylingMessages.JavadocStyling_enabledTooltip : JavadocStylingMessages.JavadocStyling_disabledTooltip);
noStylingActions[0].setText(enhancementsEnabled ? JavadocStylingMessages.JavadocStyling_noEnhancements : JavadocStylingMessages.JavadocStyling_enhancementsDisabled);
}

@Override
Expand Down Expand Up @@ -163,7 +168,6 @@ public void setup(ToolBar toolbar) {

private class NoStylingEnhancementsAction extends Action {
public NoStylingEnhancementsAction() {
super(JavadocStylingMessages.JavadocStyling_noEnhancements);
setEnabled(false);
}
}
Expand Down

0 comments on commit c4886ff

Please sign in to comment.