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();
}
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);
}
}
}
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()));
}
}
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));
}
}
Aggregations