diff --git a/org.eclipse.lsp4e/icons/full/dlcl16/fields_co.png b/org.eclipse.lsp4e/icons/full/dlcl16/fields_co.png new file mode 100644 index 000000000..2820f965a Binary files /dev/null and b/org.eclipse.lsp4e/icons/full/dlcl16/fields_co.png differ diff --git a/org.eclipse.lsp4e/icons/full/elcl16/fields_co.png b/org.eclipse.lsp4e/icons/full/elcl16/fields_co.png new file mode 100644 index 000000000..0f6575427 Binary files /dev/null and b/org.eclipse.lsp4e/icons/full/elcl16/fields_co.png differ diff --git a/org.eclipse.lsp4e/plugin.properties b/org.eclipse.lsp4e/plugin.properties index 97215c502..6d832ee62 100644 --- a/org.eclipse.lsp4e/plugin.properties +++ b/org.eclipse.lsp4e/plugin.properties @@ -27,6 +27,8 @@ command.toggle.highlight.label = Toggle Mark Occurrences command.toggle.highlight.name = Toggle Highlight command.toggle.outline.sort.name = Sort command.toggle.outline.sort.label = Sort +command.toggle.outline.hideFields.name = Hide Fields +command.toggle.outline.hideFields.label = Hide Fields command.open.call.hierarchy.name = Open Call Hierarchy command.open.call.hierarchy.description = Open Call Hierarchy for the selected item command.open.type.hierarchy.name = Open Type Hierarchy diff --git a/org.eclipse.lsp4e/plugin.xml b/org.eclipse.lsp4e/plugin.xml index 2ad76b750..5b21300a1 100644 --- a/org.eclipse.lsp4e/plugin.xml +++ b/org.eclipse.lsp4e/plugin.xml @@ -90,6 +90,15 @@ class="org.eclipse.ui.handlers.RegistryToggleState:false" id="org.eclipse.ui.commands.toggleState" /> + + + + + + + + @@ -336,12 +351,30 @@ - + + + + + + + + + + + toggleHideFieldsCommand; + + public ToggleHideFieldsOutlineHandler() { + preferences = InstanceScope.INSTANCE.getNode(LanguageServerPlugin.PLUGIN_ID); + preferences.addPreferenceChangeListener(this); + + ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class); + if (commandService != null) { + toggleHideFieldsCommand = Optional.of(commandService.getCommand(COMMAND_ID_HIDE_FIELDS)); + } else { + toggleHideFieldsCommand = Optional.empty(); + } + } + + @Override + public @Nullable Object execute(final ExecutionEvent event) throws ExecutionException { + OutlineViewHideSymbolKindMenuContributor.toggleHideSymbolKind(SymbolKind.Field); + return null; + } + + @Override + public void dispose() { + super.dispose(); + preferences.removePreferenceChangeListener(this); + } + + @Override + public void preferenceChange(PreferenceChangeEvent event) { + if (toggleHideFieldsCommand.isPresent() + && event.getKey().startsWith(CNFOutlinePage.HIDE_DOCUMENT_SYMBOL_KIND_PREFERENCE_PREFIX) + && event.getKey().endsWith(SymbolKind.Field.name())) { + try { + HandlerUtil.toggleCommandState(toggleHideFieldsCommand.get()); + } catch (ExecutionException e) { + LanguageServerPlugin.logError(e); + } + } + } +}