Search in sources :

Example 1 with INavigatorFilterService

use of org.eclipse.ui.navigator.INavigatorFilterService in project polymap4-core by Polymap4.

the class CommonFiltersTab method updateFiltersCheckState.

private void updateFiltersCheckState() {
    Object[] children = filterContentProvider.getElements(getContentService());
    ICommonFilterDescriptor filterDescriptor;
    INavigatorFilterService filterService = getContentService().getFilterService();
    for (int i = 0; i < children.length; i++) {
        filterDescriptor = (ICommonFilterDescriptor) children[i];
        if (filterService.isActive(filterDescriptor.getId())) {
            getTableViewer().setChecked(children[i], true);
            getCheckedItems().add(children[i]);
        } else {
            getTableViewer().setChecked(children[i], false);
        }
    }
}
Also used : ICommonFilterDescriptor(org.eclipse.ui.navigator.ICommonFilterDescriptor) INavigatorFilterService(org.eclipse.ui.navigator.INavigatorFilterService)

Example 2 with INavigatorFilterService

use of org.eclipse.ui.navigator.INavigatorFilterService in project liferay-ide by liferay.

the class ProjectExplorerLayoutUtil method _execute.

private static void _execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchPart part = HandlerUtil.getActivePart(event);
    String nestedProjectsContentProviderExtensionId = "org.eclipse.ui.navigator.resources.nested.nestedProjectContentProvider";
    String hideTopLevelProjectIfNested = "org.eclipse.ui.navigator.resources.nested.HideTopLevelProjectIfNested";
    String hideFolderWhenProjectIsShownAsNested = "org.eclipse.ui.navigator.resources.nested.HideFolderWhenProjectIsShownAsNested";
    if (part instanceof CommonNavigator) {
        CommonNavigator navigator = (CommonNavigator) part;
        INavigatorContentService navigatorContentService = navigator.getNavigatorContentService();
        boolean previousNest = navigatorContentService.getActivationService().isNavigatorExtensionActive(nestedProjectsContentProviderExtensionId);
        String newNestParam = event.getParameter(_nestParameter);
        boolean newNest = false;
        if (newNestParam != null) {
            newNest = Boolean.parseBoolean(newNestParam);
        }
        if (newNest != previousNest) {
            ISelection initialSelection = navigator.getCommonViewer().getSelection();
            INavigatorFilterService filterService = navigatorContentService.getFilterService();
            Set<String> filters = new HashSet<>();
            for (ICommonFilterDescriptor desc : filterService.getVisibleFilterDescriptors()) {
                if (filterService.isActive(desc.getId())) {
                    filters.add(desc.getId());
                }
            }
            if (newNest) {
                navigatorContentService.getActivationService().activateExtensions(new String[] { nestedProjectsContentProviderExtensionId }, false);
                filters.add(hideTopLevelProjectIfNested);
                filters.add(hideFolderWhenProjectIsShownAsNested);
            } else {
                navigatorContentService.getActivationService().deactivateExtensions(new String[] { nestedProjectsContentProviderExtensionId }, false);
                filters.remove(hideTopLevelProjectIfNested);
                filters.remove(hideFolderWhenProjectIsShownAsNested);
            }
            filterService.activateFilterIdsAndUpdateViewer(filters.toArray(new String[filters.size()]));
            navigatorContentService.getActivationService().persistExtensionActivations();
            navigator.getCommonViewer().refresh();
            navigator.getCommonViewer().setSelection(initialSelection);
        }
        HandlerUtil.updateRadioState(event.getCommand(), Boolean.toString(newNest));
    }
}
Also used : CommonNavigator(org.eclipse.ui.navigator.CommonNavigator) ICommonFilterDescriptor(org.eclipse.ui.navigator.ICommonFilterDescriptor) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ISelection(org.eclipse.jface.viewers.ISelection) INavigatorFilterService(org.eclipse.ui.navigator.INavigatorFilterService) INavigatorContentService(org.eclipse.ui.navigator.INavigatorContentService) HashSet(java.util.HashSet)

Aggregations

ICommonFilterDescriptor (org.eclipse.ui.navigator.ICommonFilterDescriptor)2 INavigatorFilterService (org.eclipse.ui.navigator.INavigatorFilterService)2 HashSet (java.util.HashSet)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1 CommonNavigator (org.eclipse.ui.navigator.CommonNavigator)1 INavigatorContentService (org.eclipse.ui.navigator.INavigatorContentService)1