Search in sources :

Example 11 with CommonNavigator

use of org.eclipse.ui.navigator.CommonNavigator 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)

Example 12 with CommonNavigator

use of org.eclipse.ui.navigator.CommonNavigator in project tdq-studio-se by Talend.

the class RepositoryNodeHelper method getDQCommonViewer.

/**
 * DOC klliu 15750 Comment method "getDQRespositoryView".
 *
 * @return
 */
public static CommonViewer getDQCommonViewer() {
    IViewPart part = null;
    CommonViewer commonViewer = null;
    IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (activeWorkbenchWindow != null) {
        IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
        if (activePage != null) {
            part = activePage.findView(DQRESPOSITORYVIEW);
            if (part == null) {
                return null;
            }
            CommonNavigator dqView = (CommonNavigator) part;
            commonViewer = dqView.getCommonViewer();
        }
    }
    return commonViewer;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) CommonNavigator(org.eclipse.ui.navigator.CommonNavigator) IViewPart(org.eclipse.ui.IViewPart) CommonViewer(org.eclipse.ui.navigator.CommonViewer) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 13 with CommonNavigator

use of org.eclipse.ui.navigator.CommonNavigator in project abstools by abstools.

the class ActionUtils method getSelectedResourceOrNull.

private static IResource getSelectedResourceOrNull(IWorkbenchWindow window) throws PartInitException {
    CommonNavigator explorer = (CommonNavigator) window.getActivePage().showView(IPageLayout.ID_PROJECT_EXPLORER);
    Object e = ((StructuredSelection) explorer.getCommonViewer().getSelection()).getFirstElement();
    if (e instanceof IResource)
        return (IResource) e;
    return null;
}
Also used : CommonNavigator(org.eclipse.ui.navigator.CommonNavigator) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IResource(org.eclipse.core.resources.IResource)

Example 14 with CommonNavigator

use of org.eclipse.ui.navigator.CommonNavigator in project tmdm-studio-se by Talend.

the class DeployOnMDMAction method refreshMdmRepositoryViewTree.

/**
 * If the MDM Repository View is showing,refresh the navigator tree in it.
 */
private void refreshMdmRepositoryViewTree() {
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    // $NON-NLS-1$
    IViewPart mdmRepositoryView = activePage.findView("org.talend.mdm.repository.ui.navigator.MDMRepositoryView");
    if (mdmRepositoryView instanceof CommonNavigator) {
        CommonNavigator cNavigator = (CommonNavigator) mdmRepositoryView;
        cNavigator.getCommonViewer().refresh();
    }
}
Also used : CommonNavigator(org.eclipse.ui.navigator.CommonNavigator) IViewPart(org.eclipse.ui.IViewPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 15 with CommonNavigator

use of org.eclipse.ui.navigator.CommonNavigator in project tbd-studio-se by Talend.

the class MetadataHadoopClusterContentProvider method addResourceVisitor.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.repository.viewer.content.FolderListenerSingleTopContentProvider#addResourceVisitor(org.eclipse.ui
     * .navigator.CommonViewer)
     */
@Override
protected void addResourceVisitor(CommonViewer v) {
    // super.addResourceVisitor(v);
    if (v == null) {
        return;
    }
    RepoViewCommonNavigator navigator = null;
    if (v instanceof RepoViewCommonViewer) {
        CommonNavigator commonNavigator = ((RepoViewCommonViewer) v).getCommonNavigator();
        if (commonNavigator instanceof RepoViewCommonNavigator) {
            navigator = ((RepoViewCommonNavigator) commonNavigator);
        }
    }
    if (navigator == null) {
        return;
    }
    if (this.testVisitor != null) {
        navigator.removeVisitor(this.testVisitor);
    }
    this.testVisitor = new MetadataHadoopClusterChildrenNodeVisitor();
    navigator.addVisitor(this.testVisitor);
}
Also used : RepoViewCommonNavigator(org.talend.repository.navigator.RepoViewCommonNavigator) CommonNavigator(org.eclipse.ui.navigator.CommonNavigator) RepoViewCommonNavigator(org.talend.repository.navigator.RepoViewCommonNavigator) RepoViewCommonViewer(org.talend.repository.navigator.RepoViewCommonViewer)

Aggregations

CommonNavigator (org.eclipse.ui.navigator.CommonNavigator)20 IViewPart (org.eclipse.ui.IViewPart)9 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)9 CommonViewer (org.eclipse.ui.navigator.CommonViewer)8 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)4 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)4 CoreException (org.eclipse.core.runtime.CoreException)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 UserException (org.eclipse.titan.log.viewer.exceptions.UserException)3 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)3 IOException (java.io.IOException)2 IFile (org.eclipse.core.resources.IFile)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 Job (org.eclipse.core.runtime.jobs.Job)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)2 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)2 TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)2