@Override public boolean gotoBookmark(IWorkbenchWindow window, Bookmark bookmark, IBookmarkLocation bookmarkLocation) { if (!(bookmarkLocation instanceof WorkspaceFolderBookmarkLocation)) { return false; } WorkspaceFolderBookmarkLocation workspaceFileBookmarkLocation = (WorkspaceFolderBookmarkLocation) bookmarkLocation; IFolder folder = workspaceFileBookmarkLocation.getWorkspaceFolder(); try { ProjectExplorer projectExplorer = (ProjectExplorer) PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage().showView(ProjectExplorer.VIEW_ID); projectExplorer.selectReveal(new StructuredSelection(folder)); return true; } catch (PartInitException e) { return false; } }
/** * Constructor for CommonNavigatorTitleProvider. */ public TabbedPropertySheetTitleProvider() { super(); IWorkbenchPart part = PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage().findView(ProjectExplorer.VIEW_ID); INavigatorContentService contentService = (INavigatorContentService) part .getAdapter(INavigatorContentService.class); if (contentService != null) { labelProvider = contentService.createCommonLabelProvider(); descriptionProvider = contentService .createCommonDescriptionProvider(); } else { WorkbenchNavigatorPlugin.log( "Could not acquire INavigatorContentService from part (\"" //$NON-NLS-1$ + part.getTitle() + "\").", null); //$NON-NLS-1$ } }
@Override @Before public void setUp() throws Exception { super.setUp(); waitForIdleState(); projectExplorer = (ProjectExplorer) showView(ProjectExplorer.VIEW_ID); waitForUiThread(); assertNotNull("Cannot show Project Explorer.", projectExplorer); commonViewer = projectExplorer.getCommonViewer(); assertFalse("Expected projects as top level elements in navigator.", broker.isWorkingSetTopLevel()); assertNull( "Select working set drop down contribution was visible when projects are configured as top level elements.", getWorkingSetDropDownContribution()); }
@Override @Before public void setUp() throws Exception { super.setUp(); waitForIdleState(); projectExplorer = (ProjectExplorer) showView(ProjectExplorer.VIEW_ID); waitForUiThread(); assertNotNull("Cannot show Project Explorer.", projectExplorer); commonViewer = projectExplorer.getCommonViewer(); assertFalse("Expected projects as top level elements in navigator.", broker.isWorkingSetTopLevel()); assertNull( "Select working set drop down contribution was visible when projects are configured as top level elements.", getWorkingSetDropDownContribution()); final Multimap<ProjectType, String> typeNamesMapping = HashMultimap.create(); typeNamesMapping.putAll(LIBRARY, LIBRARY_PROJECTS); typeNamesMapping.putAll(TEST, TEST_PROJECTS); for (final Entry<ProjectType, Collection<String>> entry : typeNamesMapping.asMap().entrySet()) { for (final String projectName : entry.getValue()) { createN4JSProject(projectName, entry.getKey()); } } // Actually close "Closed*" projects closeProject("ClosedL2"); closeProject("ClosedT2"); // Wait for workbench to reflect project changes waitForIdleState(); commonViewer.refresh(); // Disable auto-building, as there is no real code to build involved ResourcesPlugin.getWorkspace().getDescription().setAutoBuilding(false); }
private void asyncRefreshCommonViewer(final ProjectExplorer explorer, final boolean resetInput) { // do deferred initialization this.getWorkingSetManagers().stream() .filter(m -> (m instanceof IDeferredInitializer)) .map(m -> (IDeferredInitializer) m) .filter(m -> m.isInitializationRequired()) .forEach(m -> { m.lateInit(); }); final CommonViewer viewer = explorer.getCommonViewer(); final Display d = getDisplay(); if (!d.isDisposed()) { if (resetInput) { d.asyncExec(() -> { if (!viewer.getTree().isDisposed()) viewer.setInput(viewer.getInput()); }); } else { d.asyncExec(() -> { if (!viewer.getTree().isDisposed()) viewer.refresh(true); }); } } }
/** * This method refresh Project Explorer View when the actions (Mark/Mark All/Delete/Delete All) * have been completed. * */ public static void refreshProjectExp() { try { ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null); final IViewPart viewPart = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getActivePage() .findView("org.eclipse.ui.navigator.ProjectExplorer"); if (viewPart == null) { return; } ((ProjectExplorer) viewPart).getCommonViewer().refresh(); } catch (final CoreException e) { e.printStackTrace(); } }
/** * Binds all controls in an IWorkbenchPartReference that is * an instance of IEditorPartReference to their appropriate * gaze handlers if the handler exists. * Binds the IWorkbenchPartReference that is an instance of * IViewPartReference to the appropriate gaze handler if the * handler exists. * @param partRef Workbench part from which to get controls. */ public static void bind(IWorkbenchPartReference partRef) { IWorkbenchPart part = partRef.getPart(true); Control control = part.getAdapter(Control.class); System.out.println(control); //is an EditorPart if (control != null) { bindControl(partRef, control, false); //is a ViewPart } else { //must be handled on a case to case basis //Browser - always look through all controls in the shell for browsers and bind them //regardless of the partRef that has become visible //not possible to get a Browser control from a partRef Shell workbenchShell = partRef.getPage().getWorkbenchWindow().getShell(); for (Control ctrl : workbenchShell.getChildren()) { bind(ctrl); //call recursive helper function to find all browser controls } //Project Explorer if (part.getAdapter(ProjectExplorer.class) != null) { ProjectExplorer explorer = part.getAdapter(ProjectExplorer.class); //this control is the primary control associated with a ProjectExplorer Control viewControl = explorer.getCommonViewer().getControl(); bindControl(partRef, viewControl, false); } } }
/** * Unbinds all controls in an IWorkbenchPartReference that is an instance * of IEditorPartReference which are currently bound to a gaze handler. * Unbinds an IWorkbenchPartReference that is an instance of IViewPartReference * which is currently bound to a gaze handler. * @param partRef Workbench part from which to get controls. */ public static void unbind(IWorkbenchPartReference partRef) { IWorkbenchPart part = partRef.getPart(true); Control control = part.getAdapter(Control.class); //is an EditorPart if (control != null) { bindControl(partRef, control, true); //is a ViewPart } else { //must be handled on a case to case basis //Browser - always look through all controls in the shell for browsers and unbind them //regardless of the partRef that has been hidden //not possible to get Browser control from a partRef Shell workbenchShell = partRef.getPage().getWorkbenchWindow().getShell(); for (Control ctrl : workbenchShell.getChildren()) { unbind(ctrl); } //Project Explorer if (part.getAdapter(ProjectExplorer.class) != null) { ProjectExplorer explorer = part.getAdapter(ProjectExplorer.class); //this control is the primary control associated with a ProjectExplorer Control viewControl = explorer.getCommonViewer().getControl(); bindControl(partRef, viewControl, true); } } }
/** * @generated */ @SuppressWarnings("rawtypes") public Object getAdapter(Class type) { if (type == IShowInTargetList.class) { return new IShowInTargetList() { public String[] getShowInTargetIds() { return new String[] { ProjectExplorer.VIEW_ID }; } }; } return super.getAdapter(type); }
public Object getAdapter(Object adaptableObject, Class adapterType) { if (adaptableObject instanceof ProjectExplorer) { if (IPropertySheetPage.class == adapterType) return new TabbedPropertySheetPage( new TabbedPropertySheetProjectExplorerContributor( (CommonNavigator) adaptableObject)); } return null; }
public Object[] getChildren(Object parentElement) { if (parentElement instanceof IWorkingSet) { IWorkingSet workingSet = (IWorkingSet) parentElement; if (workingSet.isAggregateWorkingSet() && projectExplorer != null) { switch (projectExplorer.getRootMode()) { case ProjectExplorer.WORKING_SETS : return ((IAggregateWorkingSet) workingSet).getComponents(); case ProjectExplorer.PROJECTS : return getWorkingSetElements(workingSet); } } return getWorkingSetElements(workingSet); } return NO_CHILDREN; }
private void updateRootMode() { if (projectExplorer == null) { return; } if( extensionStateModel.getBooleanProperty(SHOW_TOP_LEVEL_WORKING_SETS) ) projectExplorer.setRootMode(ProjectExplorer.WORKING_SETS); else projectExplorer.setRootMode(ProjectExplorer.PROJECTS); }
/** * @generated */ public Object getAdapter(Class type) { if (type == IShowInTargetList.class) { return new IShowInTargetList() { public String[] getShowInTargetIds() { return new String[] { ProjectExplorer.VIEW_ID }; } }; } return super.getAdapter(type); }
/** * @generated */ @SuppressWarnings("rawtypes") public Object getAdapterGen(Class type) { if (type == IShowInTargetList.class) { return new IShowInTargetList() { public String[] getShowInTargetIds() { return new String[] { ProjectExplorer.VIEW_ID }; } }; } return super.getAdapter(type); }