Search in sources :

Example 21 with INavigatorContentDescriptor

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

the class NavigatorPipelineService method interceptAdd.

public PipelinedShapeModification interceptAdd(PipelinedShapeModification anAddModification) {
    ContributorTrackingSet trackedSet = (ContributorTrackingSet) anAddModification.getChildren();
    Set contentDescriptors = contentService.findDescriptorsByTriggerPoint(anAddModification.getParent(), !NavigatorContentService.CONSIDER_OVERRIDES);
    for (Iterator descriptorsItr = contentDescriptors.iterator(); descriptorsItr.hasNext(); ) {
        INavigatorContentDescriptor descriptor = (INavigatorContentDescriptor) descriptorsItr.next();
        pipelineInterceptAdd(anAddModification, trackedSet, descriptor);
    }
    return anAddModification;
}
Also used : INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) Iterator(java.util.Iterator)

Example 22 with INavigatorContentDescriptor

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

the class NavigatorSorterService method findSorter.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.navigator.INavigatorSorterService#findSorterForParent(org.eclipse.ui.navigator.INavigatorContentDescriptor,
	 *      java.lang.Object, java.lang.Object, java.lang.Object)
	 */
public synchronized ViewerSorter findSorter(INavigatorContentDescriptor source, Object parent, Object lvalue, Object rvalue) {
    CommonSorterDescriptorManager dm = CommonSorterDescriptorManager.getInstance();
    CommonSorterDescriptor[] descriptors;
    INavigatorContentDescriptor lookupDesc;
    for (int i = 0; i < sortOnlyDescriptors.length; i++) {
        lookupDesc = sortOnlyDescriptors[i];
        if (source != null && source.getSequenceNumber() < lookupDesc.getSequenceNumber()) {
            lookupDesc = source;
            source = null;
            i--;
        }
        descriptors = dm.findApplicableSorters(contentService, lookupDesc, parent);
        if (descriptors.length > 0) {
            return getSorter(descriptors[0]);
        }
    }
    if (source != null) {
        descriptors = dm.findApplicableSorters(contentService, source, parent);
        if (descriptors.length > 0) {
            return getSorter(descriptors[0]);
        }
    }
    return null;
}
Also used : INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor)

Example 23 with INavigatorContentDescriptor

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

the class UpdateActiveExtensionsOperation method execute.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor,
	 *      org.eclipse.core.runtime.IAdaptable)
	 */
public IStatus execute(IProgressMonitor monitor, IAdaptable info) {
    boolean updateExtensionActivation = false;
    // we sort the array in order to use Array.binarySearch();
    Arrays.sort(contentExtensionsToActivate);
    IStructuredSelection ssel = null;
    try {
        commonViewer.getControl().setRedraw(false);
        ISelection selection = commonViewer.getSelection();
        if (selection instanceof IStructuredSelection)
            ssel = (IStructuredSelection) selection;
        INavigatorContentDescriptor[] visibleContentDescriptors = contentService.getVisibleExtensions();
        int indexofContentExtensionIdToBeActivated;
        /* is there a delta? */
        for (int i = 0; i < visibleContentDescriptors.length && !updateExtensionActivation; i++) {
            indexofContentExtensionIdToBeActivated = Arrays.binarySearch(contentExtensionsToActivate, visibleContentDescriptors[i].getId());
            /*
				 * Either we have a filter that should be active that isn't XOR
				 * a filter that shouldn't be active that is currently
				 */
            if (indexofContentExtensionIdToBeActivated >= 0 ^ contentService.isActive(visibleContentDescriptors[i].getId())) {
                updateExtensionActivation = true;
            }
        }
        /* If so, update */
        if (updateExtensionActivation) {
            contentService.getActivationService().activateExtensions(contentExtensionsToActivate, true);
            contentService.getActivationService().persistExtensionActivations();
            Object[] expandedElements = commonViewer.getExpandedElements();
            contentService.update();
            commonViewer.refresh();
            Object[] originalObjects = ssel.toArray();
            commonViewer.setExpandedElements(expandedElements);
            IStructuredSelection newSelection = new StructuredSelection(originalObjects);
            commonViewer.setSelection(newSelection, true);
        }
    } finally {
        commonViewer.getControl().setRedraw(true);
    }
    return Status.OK_STATUS;
}
Also used : INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

INavigatorContentDescriptor (org.eclipse.ui.navigator.INavigatorContentDescriptor)23 Set (java.util.Set)10 NavigatorContentDescriptor (org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor)10 ArrayList (java.util.ArrayList)7 LinkedHashSet (java.util.LinkedHashSet)7 List (java.util.List)7 HashSet (java.util.HashSet)6 Iterator (java.util.Iterator)6 SortedSet (java.util.SortedSet)4 TreeSet (java.util.TreeSet)4 ListIterator (java.util.ListIterator)3 NavigatorContentExtension (org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension)3 INavigatorContentExtension (org.eclipse.ui.navigator.INavigatorContentExtension)3 ListenerList (org.eclipse.core.runtime.ListenerList)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 TableItem (org.eclipse.swt.widgets.TableItem)2 ICommonFilterDescriptor (org.eclipse.ui.navigator.ICommonFilterDescriptor)2 HashMap (java.util.HashMap)1 TreeMap (java.util.TreeMap)1 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)1