Search in sources :

Example 1 with ICommonFilterDescriptor

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

the class CommonFilterSelectionDialog method okPressed.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
	 */
protected void okPressed() {
    if (contentExtensionsTab != null) {
        List checkedExtensions = new ArrayList();
        TableItem[] tableItems = contentExtensionsTab.getTable().getItems();
        INavigatorContentDescriptor descriptor;
        for (int i = 0; i < tableItems.length; i++) {
            descriptor = (INavigatorContentDescriptor) tableItems[i].getData();
            if (tableItems[i].getChecked()) {
                checkedExtensions.add(descriptor.getId());
            }
        }
        String[] contentExtensionIdsToActivate = (String[]) checkedExtensions.toArray(new String[checkedExtensions.size()]);
        UpdateActiveExtensionsOperation updateExtensions = new UpdateActiveExtensionsOperation(commonViewer, contentExtensionIdsToActivate);
        updateExtensions.execute(null, null);
    }
    if (commonFiltersTab != null) {
        Set checkedFilters = commonFiltersTab.getCheckedItems();
        String[] filterIdsToActivate = new String[checkedFilters.size()];
        int indx = 0;
        for (Iterator iterator = checkedFilters.iterator(); iterator.hasNext(); ) {
            ICommonFilterDescriptor descriptor = (ICommonFilterDescriptor) iterator.next();
            filterIdsToActivate[indx++] = descriptor.getId();
        }
        UpdateActiveFiltersOperation updateFilters = new UpdateActiveFiltersOperation(commonViewer, filterIdsToActivate);
        updateFilters.execute(null, null);
    }
    super.okPressed();
}
Also used : INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) Set(java.util.Set) ICommonFilterDescriptor(org.eclipse.ui.navigator.ICommonFilterDescriptor) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with ICommonFilterDescriptor

use of org.eclipse.ui.navigator.ICommonFilterDescriptor 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 3 with ICommonFilterDescriptor

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

the class FilterDialogSelectionListener method selectionChanged.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
	 */
public void selectionChanged(SelectionChangedEvent event) {
    IStructuredSelection structuredSelection = (IStructuredSelection) event.getSelection();
    Object element = structuredSelection.getFirstElement();
    if (element instanceof INavigatorContentDescriptor) {
        INavigatorContentDescriptor ncd = (INavigatorContentDescriptor) element;
        String desc = NLS.bind(CommonNavigatorMessages.CommonFilterSelectionDialog_Hides_all_content_associated, new Object[] { ncd.getName() });
        descriptionText.setText(desc);
    } else if (element instanceof ICommonFilterDescriptor) {
        ICommonFilterDescriptor cfd = (ICommonFilterDescriptor) element;
        String description = cfd.getDescription();
        if (description != null)
            descriptionText.setText(description);
        else
            descriptionText.setText(NLS.bind(CommonNavigatorMessages.FilterDialogSelectionListener_Enable_the_0_filter_, cfd.getName()));
    }
}
Also used : INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) ICommonFilterDescriptor(org.eclipse.ui.navigator.ICommonFilterDescriptor) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 4 with ICommonFilterDescriptor

use of org.eclipse.ui.navigator.ICommonFilterDescriptor 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)4 INavigatorContentDescriptor (org.eclipse.ui.navigator.INavigatorContentDescriptor)2 INavigatorFilterService (org.eclipse.ui.navigator.INavigatorFilterService)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Set (java.util.Set)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 TableItem (org.eclipse.swt.widgets.TableItem)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1 CommonNavigator (org.eclipse.ui.navigator.CommonNavigator)1 INavigatorContentService (org.eclipse.ui.navigator.INavigatorContentService)1