org.eclipse.ui.navigator.CommonNavigator Java Examples

The following examples show how to use org.eclipse.ui.navigator.CommonNavigator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ViewHelper.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static void toggleExpansion(Object element) {
	final Object obj = element == null ? CodewindManager.getManager() : element;
	Display.getDefault().asyncExec(new Runnable() {
           @Override
           public void run() {
			IViewPart view = getViewPart(CodewindExplorerView.VIEW_ID);
			if (view instanceof CommonNavigator) {
				CommonViewer viewer = ((CommonNavigator)view).getCommonViewer();
		
				if (!viewer.getExpandedState(obj)) {
					viewer.expandToLevel(obj, AbstractTreeViewer.ALL_LEVELS);
				} else {
					viewer.collapseToLevel(obj, AbstractTreeViewer.ALL_LEVELS);
				}
            }
			}
	});
}
 
Example #2
Source File: ViewHelper.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static void expandConnection(CodewindConnection connection) {
	if (connection == null) {
		return;
	}
	List<CodewindApplication> apps = connection.getApps();
	if (!apps.isEmpty()) {
		Display.getDefault().asyncExec(new Runnable() {
            @Override
            public void run() {
				IViewPart view = getViewPart(CodewindExplorerView.VIEW_ID);
				if (view instanceof CommonNavigator) {
					CommonViewer viewer = ((CommonNavigator)view).getCommonViewer();
			
					if (!viewer.getExpandedState(connection)) {
						viewer.expandToLevel(AbstractTreeViewer.ALL_LEVELS);
					}
	            }
 			}
		});
	}
}
 
Example #3
Source File: PyFocusExplorerAction.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public List<StructuredViewer> getViewers() {
    List<StructuredViewer> viewers = new ArrayList<StructuredViewer>();

    IViewPart view = super.getPartForAction();
    if (view instanceof CommonNavigator) {
        CommonNavigator navigator = (CommonNavigator) view;
        viewers.add(navigator.getCommonViewer());
    }
    return viewers;
}
 
Example #4
Source File: TabbedPropertySheetAdapterFactory.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public Object getAdapter(Object adaptableObject, Class adapterType) {
    if (adaptableObject instanceof ProjectExplorer) {
    	if (IPropertySheetPage.class == adapterType)
            return new TabbedPropertySheetPage(
                new TabbedPropertySheetProjectExplorerContributor(
                    (CommonNavigator) adaptableObject));
    }
    return null;
}
 
Example #5
Source File: ApplicationWorkbenchWindowAdvisor.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 当程序第一次运行时(或是重新换了命名空间),设置项目视图的 link with editor 按钮处于选中状态
 * robert	2013-01-04
 */
private void setInitLinkEnable(){
	IPreferenceStore store = Activator.getDefault().getPreferenceStore();
	boolean isInitialRun = !store.getBoolean(IPreferenceConstants.INITIAL_RUN);
	if (isInitialRun) {
		IViewPart navigator = getWindowConfigurer().getWindow().getActivePage().findView("net.heartsome.cat.common.ui.navigator.view");
		System.out.println("navigator.getViewSite() = " + navigator.getViewSite());
		CommonNavigator commonNavigator = (CommonNavigator) navigator;
		commonNavigator.setLinkingEnabled(true);
		store.setValue(IPreferenceConstants.INITIAL_RUN, true);
	}
}
 
Example #6
Source File: TabbedPropertySheetAdapterFactory.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public Object getAdapter(Object adaptableObject, Class adapterType) {
    if (adaptableObject instanceof ProjectExplorer) {
    	if (IPropertySheetPage.class == adapterType)
            return new TabbedPropertySheetPage(
                new TabbedPropertySheetProjectExplorerContributor(
                    (CommonNavigator) adaptableObject));
    }
    return null;
}
 
Example #7
Source File: ApplicationWorkbenchWindowAdvisor.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 当程序第一次运行时(或是重新换了命名空间),设置项目视图的 link with editor 按钮处于选中状态
 * robert	2013-01-04
 */
private void setInitLinkEnable(){
	IPreferenceStore store = Activator.getDefault().getPreferenceStore();
	boolean isInitialRun = !store.getBoolean(IPreferenceConstants.INITIAL_RUN);
	if (isInitialRun) {
		IViewPart navigator = getWindowConfigurer().getWindow().getActivePage().findView("net.heartsome.cat.common.ui.navigator.view");
		CommonNavigator commonNavigator = (CommonNavigator) navigator;
		commonNavigator.setLinkingEnabled(true);
		store.setValue(IPreferenceConstants.INITIAL_RUN, true);
	}
}
 
Example #8
Source File: TmfProjectModelElement.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Refresh the common navigator viewer starting with this element. Does not
 * refresh the model.
 *
 * @since 3.1
 */
public void refreshViewer() {
    Display.getDefault().asyncExec(() -> {
        IWorkbench wb = PlatformUI.getWorkbench();
        IWorkbenchWindow wbWindow = wb.getActiveWorkbenchWindow();
        if (wbWindow == null) {
            return;
        }
        IWorkbenchPage activePage = wbWindow.getActivePage();
        if (activePage == null) {
            return;
        }

        for (IViewReference viewReference : activePage.getViewReferences()) {
            IViewPart viewPart = viewReference.getView(false);
            if (viewPart instanceof CommonNavigator) {
                CommonViewer commonViewer = ((CommonNavigator) viewPart).getCommonViewer();
                Object element = TmfProjectModelElement.this;
                if (element instanceof TmfProjectElement) {
                    IProject project = (IProject) getResource();
                    if (project != null && !TmfProjectModelHelper.isShadowProject(project)) {
                        // for the project element the viewer uses the IProject resource
                        element = getResource();
                    }
                }
                commonViewer.refresh(element);
            }
        }
    });
}
 
Example #9
Source File: ToolboxExplorer.java    From tlaplus with MIT License 5 votes vote down vote up
/**
  * Retrieves the current viewer if any
  * @return the instance of common viewer or <code>null</code>
  */
 public static CommonViewer getViewer()
 {
     CommonNavigator navigator = findCommonNavigator(ToolboxExplorer.VIEW_ID);
     if (navigator != null) 
     {
         final CommonViewer commonViewer = navigator.getCommonViewer();
         commonViewer.setAutoExpandLevel(DEFAULT_EXPAND_LEVEL);
return commonViewer;
     }
     
     return null;
 }
 
Example #10
Source File: ToolboxExplorer.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * Finds the CommonNavigatorViewer by name
 * @param navigatorViewId
 * @return
 */
private static CommonNavigator findCommonNavigator(String navigatorViewId)
{
    IWorkbenchPage page = UIHelper.getActivePage();
    if (page != null)
    {
        IViewPart findView = UIHelper.getActivePage().findView(navigatorViewId);
        if (findView != null && findView instanceof CommonNavigator)
        {
            return ((CommonNavigator) findView);
        }
    }
    return null;
}
 
Example #11
Source File: FilterPatternAction.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
    if (targetPart instanceof CommonNavigator) {
        navigator = (CommonNavigator) targetPart;
        useSpecificPattern = action.getId().startsWith("de.tobject.findbugs.filterSpecificPattern");
    }
}
 
Example #12
Source File: SelectAllProjectExplorerHandler.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	if (null == activeWorkbenchWindow) {
		return null;
	}
	IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
	if (null == activePage) {
		return null;
	}
	IWorkbenchPart activePart = activePage.getActivePart();
	if (!(activePart instanceof CommonNavigator)) {
		return null;
	}

	CommonNavigator navigator = (CommonNavigator) activePart;
	CommonViewer commonViewer = navigator.getCommonViewer();

	Tree navigatorTree = commonViewer.getTree();
	List<TreeItem> visibleItems = new ArrayList<>();
	collectChildren(navigatorTree.getItems(), visibleItems);

	List<Object> visibleData = visibleItems.stream().map(i -> i.getData()).collect(Collectors.toList());

	commonViewer.setSelection(new StructuredSelection(visibleData), false);

	return null;
}
 
Example #13
Source File: ViewHelper.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public static void refreshNavigatorView(String viewId, Object element) {
	Display.getDefault().asyncExec(new Runnable() {
        @Override
        public void run() {
  	IViewPart part = getViewPart(viewId);
      if (part != null) {
          if (part instanceof CommonNavigator) {
              CommonNavigator v = (CommonNavigator) part;
              v.getCommonViewer().refresh(element);
              v.getCommonViewer().expandToLevel(element, AbstractTreeViewer.ALL_LEVELS);
          }
      }
        }
	});
}
 
Example #14
Source File: ExpandAllAction.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void init(IViewPart view) {
    if (view instanceof CommonNavigator) {
        navigator = (CommonNavigator) view;
    }
}
 
Example #15
Source File: GroupByAction.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void init(IViewPart view) {
    if (view instanceof CommonNavigator) {
        navigator = (CommonNavigator) view;
    }
}
 
Example #16
Source File: RefreshAction.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void init(IViewPart view) {
    if (view instanceof CommonNavigator) {
        navigator = (CommonNavigator) view;
    }
}
 
Example #17
Source File: FilterBugsDialogAction.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void init(IViewPart view) {
    if (view instanceof CommonNavigator) {
        navigator = (CommonNavigator) view;
    }
}
 
Example #18
Source File: OpenGroupDialogAction.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void init(IViewPart view) {
    if (view instanceof CommonNavigator) {
        navigator = (CommonNavigator) view;
    }
}
 
Example #19
Source File: TabbedPropertySheetProjectExplorerContributor.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
protected TabbedPropertySheetProjectExplorerContributor(CommonNavigator aCommonNavigator) {
	contributorId = aCommonNavigator.getViewSite().getId();
}
 
Example #20
Source File: TabbedPropertySheetProjectExplorerContributor.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
protected TabbedPropertySheetProjectExplorerContributor(CommonNavigator aCommonNavigator) {
	contributorId = aCommonNavigator.getViewSite().getId();
}