Search in sources :

Example 1 with NavigatorContentExtension

use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension in project polymap4-core by Polymap4.

the class NavigatorContentService method updateService.

protected void updateService(Viewer aViewer, Object anOldInput, Object aNewInput) {
    // NavigatorContentServiceContentProvider, which gets us here
    if (isDisposed)
        return;
    synchronized (this) {
        if (structuredViewerManager == null) {
            structuredViewerManager = new StructuredViewerManager((StructuredViewer) aViewer, this);
            structuredViewerManager.inputChanged(anOldInput, aNewInput);
        } else {
            structuredViewerManager.inputChanged(aViewer, anOldInput, aNewInput);
        }
        for (Iterator contentItr = contentExtensions.values().iterator(); contentItr.hasNext(); ) {
            NavigatorContentExtension ext = (NavigatorContentExtension) contentItr.next();
            if (ext.isLoaded()) {
                structuredViewerManager.initialize(ext.internalGetContentProvider());
            }
        }
        rootContentProviders = extractContentProviders(findRootContentExtensions(aNewInput));
    }
}
Also used : NavigatorContentExtension(org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension) INavigatorContentExtension(org.eclipse.ui.navigator.INavigatorContentExtension) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator) StructuredViewerManager(org.eclipse.ui.internal.navigator.extensions.StructuredViewerManager) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer)

Example 2 with NavigatorContentExtension

use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension in project polymap4-core by Polymap4.

the class NavigatorContentService method getExtension.

/**
 * @param aDescriptorKey
 * @param toLoadIfNecessary
 *            True if the extension should be loaded if it is not already.
 * @return The instance of the extension for the given descriptor key.
 */
public final NavigatorContentExtension getExtension(INavigatorContentDescriptor aDescriptorKey, boolean toLoadIfNecessary) {
    /* Query and return the relevant descriptor instance */
    NavigatorContentExtension extension = (NavigatorContentExtension) contentExtensions.get(aDescriptorKey);
    if (extension != null || !toLoadIfNecessary) {
        return extension;
    }
    /*
		 * If the descriptor instance hasn't been created yet, then we need to
		 * (1) verify that it wasn't added by another thread, (2) create and add
		 * the result into the map
		 */
    synchronized (this) {
        extension = (NavigatorContentExtension) contentExtensions.get(aDescriptorKey);
        if (extension == null) {
            contentExtensions.put(aDescriptorKey, (extension = new NavigatorContentExtension((NavigatorContentDescriptor) aDescriptorKey, this, structuredViewerManager)));
            notifyListeners(extension);
        }
    }
    return extension;
}
Also used : NavigatorContentExtension(org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension) INavigatorContentExtension(org.eclipse.ui.navigator.INavigatorContentExtension) INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) NavigatorContentDescriptor(org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor)

Example 3 with NavigatorContentExtension

use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension in project polymap4-core by Polymap4.

the class NavigatorContentService method restoreState.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.ui.internal.navigator.INavigatorContentService#restoreState
	 * (org.eclipse.ui.IMemento)
	 */
public void restoreState(final IMemento aMemento) {
    synchronized (this) {
        for (Iterator extensionItr = getExtensions().iterator(); extensionItr.hasNext(); ) {
            final NavigatorContentExtension element = (NavigatorContentExtension) extensionItr.next();
            SafeRunner.run(new NavigatorSafeRunnable(((NavigatorContentDescriptor) element.getDescriptor()).getConfigElement()) {

                public void run() throws Exception {
                    element.restoreState(aMemento);
                }
            });
        }
    }
}
Also used : NavigatorContentExtension(org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension) INavigatorContentExtension(org.eclipse.ui.navigator.INavigatorContentExtension) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator) INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) NavigatorContentDescriptor(org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor) BackingStoreException(org.osgi.service.prefs.BackingStoreException)

Example 4 with NavigatorContentExtension

use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension in project polymap4-core by Polymap4.

the class NavigatorContentService method dispose.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.internal.navigator.INavigatorContentService#dispose()
	 */
public void dispose() {
    if (navigatorSaveablesService != null) {
        assistant.removeListener(navigatorSaveablesService);
    }
    if (navigatorSorterService != null) {
        assistant.removeListener(navigatorSorterService);
    }
    synchronized (this) {
        for (Iterator contentItr = contentExtensions.values().iterator(); contentItr.hasNext(); ) {
            ((NavigatorContentExtension) contentItr.next()).dispose();
        }
    }
    getActivationService().removeExtensionActivationListener(this);
    assistant.dispose();
    isDisposed = true;
}
Also used : NavigatorContentExtension(org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension) INavigatorContentExtension(org.eclipse.ui.navigator.INavigatorContentExtension) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator)

Example 5 with NavigatorContentExtension

use of org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension in project polymap4-core by Polymap4.

the class NavigatorContentServiceContentProvider method internalGetChildren.

private Object[] internalGetChildren(final Object aParentElement, final Object aParentElementOrPath, final Set enabledExtensions, final boolean elements) {
    if (enabledExtensions.size() == 0) {
        return NO_CHILDREN;
    }
    final Set finalSet = new LinkedHashSet();
    final ContributorTrackingSet localSet = new ContributorTrackingSet(contentService);
    for (final Iterator itr = enabledExtensions.iterator(); itr.hasNext(); ) {
        SafeRunner.run(new NavigatorSafeRunnable() {

            NavigatorContentExtension foundExtension = (NavigatorContentExtension) itr.next();

            Object[] contributedChildren = null;

            NavigatorContentExtension[] overridingExtensions;

            public void run() throws Exception {
                if (!isOverridingExtensionInSet(foundExtension.getDescriptor(), enabledExtensions)) {
                    if (elements)
                        contributedChildren = foundExtension.internalGetContentProvider().getElements(aParentElementOrPath);
                    else
                        contributedChildren = foundExtension.internalGetContentProvider().getChildren(aParentElementOrPath);
                    overridingExtensions = foundExtension.getOverridingExtensionsForTriggerPoint(aParentElement);
                    INavigatorContentDescriptor foundDescriptor = foundExtension.getDescriptor();
                    localSet.setContributor(foundDescriptor, foundDescriptor);
                    localSet.setContents(contributedChildren);
                    if (overridingExtensions.length > 0) {
                        pipelineChildren(aParentElement, overridingExtensions, foundDescriptor, localSet, elements);
                    }
                    finalSet.addAll(localSet);
                }
            }

            public void handleException(Throwable e) {
                NavigatorPlugin.logError(0, NLS.bind(CommonNavigatorMessages.Exception_Invoking_Extension, new Object[] { foundExtension.getDescriptor().getId(), aParentElement }), e);
            }
        });
    }
    return finalSet.toArray();
}
Also used : LinkedHashSet(java.util.LinkedHashSet) INavigatorContentDescriptor(org.eclipse.ui.navigator.INavigatorContentDescriptor) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) NavigatorContentExtension(org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension) Iterator(java.util.Iterator)

Aggregations

NavigatorContentExtension (org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension)24 Iterator (java.util.Iterator)14 LinkedHashSet (java.util.LinkedHashSet)9 Set (java.util.Set)9 INavigatorContentDescriptor (org.eclipse.ui.navigator.INavigatorContentDescriptor)7 INavigatorContentExtension (org.eclipse.ui.navigator.INavigatorContentExtension)6 NavigatorContentDescriptor (org.eclipse.ui.internal.navigator.extensions.NavigatorContentDescriptor)5 IPipelinedTreeContentProvider (org.eclipse.ui.navigator.IPipelinedTreeContentProvider)5 ListIterator (java.util.ListIterator)4 SafeDelegateTreeContentProvider (org.eclipse.ui.internal.navigator.extensions.SafeDelegateTreeContentProvider)2 BackingStoreException (org.osgi.service.prefs.BackingStoreException)2 Collection (java.util.Collection)1 SortedSet (java.util.SortedSet)1 TreeSet (java.util.TreeSet)1 CellLabelProvider (org.eclipse.jface.viewers.CellLabelProvider)1 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)1 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)1 TreePath (org.eclipse.jface.viewers.TreePath)1 Image (org.eclipse.swt.graphics.Image)1 NavigatorContentService (org.eclipse.ui.internal.navigator.NavigatorContentService)1