org.eclipse.ui.IWorkbenchPage#getViewReferences ( )源码实例Demo

下面列出了org.eclipse.ui.IWorkbenchPage#getViewReferences ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: wildwebdeveloper   文件: TestTypeScript.java
@Before
public void setUpProject() throws Exception {
	ScopedPreferenceStore prefs = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.lsp4e");
	prefs.putValue("org.eclipse.wildwebdeveloper.angular.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.jsts.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.css.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.html.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.json.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.xml.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.yaml.file.logging.enabled", Boolean.toString(true));
	this.project = ResourcesPlugin.getWorkspace().getRoot().getProject(getClass().getName() + System.nanoTime());
	project.create(null);
	project.open(null);
	IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	for (IViewReference ref : activePage.getViewReferences()) {
		activePage.hideView(ref);
	}
}
 
源代码2 项目: wildwebdeveloper   文件: TestLanguageServers.java
@Before
public void setUpProject() throws Exception {
	ScopedPreferenceStore prefs = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.lsp4e");
	prefs.putValue("org.eclipse.wildwebdeveloper.angular.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.jsts.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.css.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.html.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.json.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.xml.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.yaml.file.logging.enabled", Boolean.toString(true));
	this.project = ResourcesPlugin.getWorkspace().getRoot().getProject(getClass().getName() + System.nanoTime());
	project.create(null);
	project.open(null);
	IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	for (IViewReference ref : activePage.getViewReferences()) {
		activePage.hideView(ref);
	}
}
 
源代码3 项目: wildwebdeveloper   文件: AllCleanRule.java
@Override
protected void starting(Description description) {
	super.starting(description);
	IIntroPart intro = PlatformUI.getWorkbench().getIntroManager().getIntro();
	if (intro != null) {
		PlatformUI.getWorkbench().getIntroManager().closeIntro(intro);
	}
	IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	for (IViewReference ref : activePage.getViewReferences()) {
		activePage.hideView(ref);
	}
	ScopedPreferenceStore prefs = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.lsp4e");
	prefs.putValue("org.eclipse.wildwebdeveloper.angular.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.jsts.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.css.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.html.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.json.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.xml.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.yaml.file.logging.enabled", Boolean.toString(true));
	clearProjects();
}
 
源代码4 项目: Pydev   文件: ScriptConsole.java
/**
 * @param page the page where the console view is
 * @param restore whether we should try to restore it
 * @return a list with the parts containing the console
 */
private static List<IViewPart> getConsoleParts(IWorkbenchPage page, boolean restore) {
    List<IViewPart> consoleParts = new ArrayList<IViewPart>();

    IViewReference[] viewReferences = page.getViewReferences();
    for (IViewReference ref : viewReferences) {
        if (ref.getId().equals(IConsoleConstants.ID_CONSOLE_VIEW)) {
            IViewPart part = ref.getView(restore);
            if (part != null) {
                consoleParts.add(part);
                if (restore) {
                    return consoleParts;
                }
            }
        }
    }
    return consoleParts;
}
 
/**
 * The refresher for Current ReportList View. 
 *
 * @param pages the page list for the currently active workbench windows
 * @param project the project, the user change his/her view to
 * @param filename the filename
 * @param considerViewerRefresh false if the refresh should always happen despite of no real need to force refresh
 */
private void refreshCurrent(IWorkbenchPage[] pages, IProject project, String filename,
        boolean considerViewerRefresh) {
    for(IWorkbenchPage page : pages) {
        for (IViewReference vp : page.getViewReferences()) {
            if (vp.getId().equals(ReportListView.ID)) {
                ReportListView rlv = (ReportListView) vp.getView(true);
                if (!considerViewerRefresh || rlv.getViewerRefresh()) {
                    rlv.onEditorChanged(project, filename);
                } else {
                    rlv.setViewerRefresh(true);
                }
            }
        }
    }
}
 
/**
 * The refresher for Custom ReportList View. If secondary id is empty, 
 * it checks if a refresh really needs to happen and if so updates every 
 * custom view for the current project. If secondary-id is not empty, 
 * it will search for the secondary-id custom view and 
 * updates that particular one.
 *
 * @param pages the page list for the currently active workbench windows.
 * @param project the project, the user change his/her view to
 * @param secondaryId id of the {@link ReportListViewCustom} the refresh
 * @param considerProjectChange false if the refresh should always happen despite of no real need to force refresh
 */
private void refreshCustom(IWorkbenchPage[] pages, IProject project, String secondaryId,
        boolean considerProjectChange) {
    for(IWorkbenchPage page : pages) {
        for (IViewReference vp : page.getViewReferences()) {
            if (vp.getId().equals(ReportListViewCustom.ID)) {
                ReportListViewCustom rlvc = (ReportListViewCustom) vp.getView(true);
                if(secondaryId.isEmpty() && rlvc.getViewSite().getSecondaryId() != null) {
                    if (!considerProjectChange || this.activeProject != project) {
                        rlvc.onEditorChanged(project);
                    }
                } else if(rlvc.getViewSite().getSecondaryId() != null && 
                        rlvc.getViewSite().getSecondaryId().equals(secondaryId)){
                    rlvc.onEditorChanged(project);
                    return;
                }
            }
        }
    }
}
 
源代码7 项目: jbt   文件: Utilities.java
/**
 * Returns a IViewPart by its class. If cannot be found, returns null.
 */
public static IViewPart getView(Class c) {
	IWorkbenchPage page = getMainWindowActivePage();

	if (page != null) {
		IViewReference[] views = page.getViewReferences();
		for (int i = 0; i < views.length; i++) {
			if (views[i].getView(true) != null) {
				if (c.isInstance(views[i].getView(false))) {
					return views[i].getView(false);
				}
			}
		}
	}
	return null;
}
 
源代码8 项目: tracecompass   文件: TmfAlignmentSynchronizer.java
/**
 * Get a view that corresponds to the alignment information. The view is
 * meant to be used as a "reference" for other views to align on. Heuristics
 * are applied to choose the best view. For example, the view has to be
 * visible. It also will prioritize the view with lowest time axis offset
 * because most of the interesting data should be in the time widget.
 *
 * @param alignmentInfo
 *            alignment information
 * @param blackListedView
 *            an optional black listed view that will not be used as
 *            reference (useful for a view that just got created)
 * @return the reference view
 */
private static ITmfTimeAligned getReferenceView(TmfTimeViewAlignmentInfo alignmentInfo, TmfView blackListedView) {
    IWorkbenchWindow workbenchWindow = getWorkbenchWindow(alignmentInfo.getShell());
    if (workbenchWindow == null || workbenchWindow.getActivePage() == null) {
        // Only time aligned views that are part of a workbench window are supported
        return null;
    }
    IWorkbenchPage page = workbenchWindow.getActivePage();

    int lowestTimeAxisOffset = Integer.MAX_VALUE;
    ITmfTimeAligned referenceView = null;
    for (IViewReference ref : page.getViewReferences()) {
        IViewPart view = ref.getView(false);
        if (view != blackListedView && isTimeAlignedView(view)) {
            if (isCandidateForReferenceView((TmfView) view, alignmentInfo, lowestTimeAxisOffset)) {
                referenceView = (ITmfTimeAligned) view;
                lowestTimeAxisOffset = getClampedTimeAxisOffset(referenceView.getTimeViewAlignmentInfo());
            }
        }
    }
    return referenceView;
}
 
源代码9 项目: tracecompass   文件: TmfAlignmentSynchronizer.java
/**
 * Get the narrowest view that corresponds to the given alignment information.
 */
private static TmfView getNarrowestView(TmfTimeViewAlignmentInfo alignmentInfo) {
    IWorkbenchWindow workbenchWindow = getWorkbenchWindow(alignmentInfo.getShell());
    if (workbenchWindow == null || workbenchWindow.getActivePage() == null) {
        // Only time aligned views that are part of a workbench window are supported
        return null;
    }
    IWorkbenchPage page = workbenchWindow.getActivePage();

    int narrowestWidth = Integer.MAX_VALUE;
    TmfView narrowestView = null;
    for (IViewReference ref : page.getViewReferences()) {
        IViewPart view = ref.getView(false);
        if (isTimeAlignedView(view)) {
            TmfView tmfView = (TmfView) view;
            if (isCandidateForNarrowestView(tmfView, alignmentInfo, narrowestWidth)) {
                narrowestWidth = ((ITmfTimeAligned) tmfView).getAvailableWidth(getClampedTimeAxisOffset(alignmentInfo));
                narrowestWidth = getClampedTimeAxisWidth(alignmentInfo, narrowestWidth);
                narrowestView = tmfView;
            }
        }
    }

    return narrowestView;
}
 
源代码10 项目: APICloud-Studio   文件: InvasiveThemeHijacker.java
protected void hijackOutline()
{
	IWorkbenchPage page = UIUtils.getActivePage();
	if (page != null)
	{
		IViewReference[] refs = page.getViewReferences();
		for (IViewReference ref : refs)
		{
			if (ref.getId().equals(IPageLayout.ID_OUTLINE))
			{
				hijackView(ref.getView(false), false);
				return;
			}
		}
	}
}
 
public RenameSelectionState(Object element) {
	fElement= element;
	fParts= new ArrayList<IWorkbenchPart>();
	fSelections= new ArrayList<IStructuredSelection>();

	IWorkbenchWindow dw = JavaPlugin.getActiveWorkbenchWindow();
	if (dw ==  null) {
		fDisplay= null;
		return;
	}
	fDisplay= dw.getShell().getDisplay();
	IWorkbenchPage page = dw.getActivePage();
	if (page == null)
		return;
	IViewReference vrefs[]= page.getViewReferences();
	for(int i= 0; i < vrefs.length; i++) {
		consider(vrefs[i].getPart(false));
	}
	IEditorReference refs[]= page.getEditorReferences();
	for(int i= 0; i < refs.length; i++) {
		consider(refs[i].getPart(false));
	}
}
 
源代码12 项目: birt   文件: UIUtil.java
/**
 * Gets the ViewPart with the specified id
 * 
 * @param id
 *            the id of view part
 * 
 * @return Returns the view part, or null if not found
 */

public static IViewPart getView( String id )
{
	IWorkbenchPage tPage = PlatformUI.getWorkbench( )
			.getActiveWorkbenchWindow( )
			.getActivePage( );
	IViewReference[] v = tPage.getViewReferences( );
	int i;
	for ( i = 0; i < v.length; i++ )
	{
		if ( v[i].getId( ).equals( id ) )
			return (IViewPart) v[i].getPart( true );
	}
	return null;
}
 
源代码13 项目: codewind-eclipse   文件: ViewHelper.java
public static IViewPart getViewPart(String viewId) {
   	for (IWorkbenchWindow window : PlatformUI.getWorkbench().getWorkbenchWindows()) {
   		for (IWorkbenchPage page : window.getPages()) {
   			for (IViewReference reference : page.getViewReferences()) {
   				if (viewId.equals(reference.getId())) {
   					return reference.getView(false);
   				}
   			}
   		}
   	}
   	return null;
}
 
源代码14 项目: wildwebdeveloper   文件: TestESLint.java
@Before
public void setUpProject() throws Exception {
	ScopedPreferenceStore prefs = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.lsp4e");
	prefs.putValue("org.eclipse.wildwebdeveloper.angular.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.jsts.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.css.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.html.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.json.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.xml.file.logging.enabled", Boolean.toString(true));
	prefs.putValue("org.eclipse.wildwebdeveloper.yaml.file.logging.enabled", Boolean.toString(true));
	this.project = ResourcesPlugin.getWorkspace().getRoot().getProject(getClass().getName() + System.nanoTime());
	project.create(null);
	project.open(null);

	// Setup ESLint configuration and dependencies
	IFile eslintConfig = project.getFile(".eslintrc");
	eslintConfig.create(getClass().getResourceAsStream("/testProjects/eslint/.eslintrc"), true, null);
	IFile tsConfig = project.getFile("tsconfig.json");
	tsConfig.create(getClass().getResourceAsStream("/testProjects/eslint/tsconfig.json"), true, null);
	IFile packageJson = project.getFile("package.json");
	packageJson.create(getClass().getResourceAsStream("/testProjects/eslint/package.json"), true, null);
	Process dependencyInstaller = new ProcessBuilder(TestAngular.getNpmLocation(), "install")
			.directory(project.getLocation().toFile()).start();
	assertEquals("npm install didn't complete properly", 0, dependencyInstaller.waitFor());

	IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	for (IViewReference ref : activePage.getViewReferences()) {
		activePage.hideView(ref);
	}
}
 
源代码15 项目: corrosion   文件: TestDebugConfiguration.java
@After
@Before
public void stopLaunchesAndCloseConsoles() throws DebugException {
	for (ILaunch launch : DebugPlugin.getDefault().getLaunchManager().getLaunches()) {
		launch.terminate();
	}
	IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
	consoleManager.removeConsoles(consoleManager.getConsoles());
	IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	for (IViewReference view : activePage.getViewReferences()) {
		if (IConsoleConstants.ID_CONSOLE_VIEW.equals(view.getId())) {
			activePage.hideView(view);
		}
	}
}
 
源代码16 项目: bonita-studio   文件: PlatformUtil.java
public static boolean isIntroOpen() {
    final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null) {
        final IWorkbenchPage activePage = window.getActivePage();
        if (activePage != null) {
            for (final IViewReference vr : activePage.getViewReferences()) {
                if (vr.getId().equals(INTROVIEW_ID)) {
                    return true;
                }
            }
            final IWorkbenchPart part = activePage.getActivePart();
            if (part != null) {
                final IIntroManager introManager = PlatformUI.getWorkbench().getIntroManager();
                if (introManager != null) {
                    if (introManager.getIntro() != null) {
                        return true;
                    } else {
                        final IViewPart view = activePage.findView(INTROVIEW_ID);
                        return view != null;
                    }
                }
            }
        }

    }
    return false;
}
 
源代码17 项目: tracecompass   文件: TmfViewFactoryTest.java
/**
 * Test method for
 * {@link org.eclipse.tracecompass.tmf.ui.views.TmfViewFactory#newView(java.lang.String, boolean)}.
 */
@Test
public void testNewView() {
    IViewPart firstView = TmfViewFactory.newView(checkNotNull(TmfViewStub.TMF_VIEW_STUB_ID), false);
    IViewPart sameAsFirstView = TmfViewFactory.newView(checkNotNull(TmfViewStub.TMF_VIEW_STUB_ID), false);
    IViewPart secondView = TmfViewFactory.newView(checkNotNull(TmfViewStub.TMF_VIEW_STUB_ID), true);
    IViewPart failView1 = TmfViewFactory.newView("this.is.a.failing.view.id", false);
    IViewPart failView2 = TmfViewFactory.newView("this.is.a.failing.view.id", true);

    assertNotNull("Failed to spawn first view", firstView);
    assertEquals("Same id returned different instance", sameAsFirstView, firstView);
    assertNotNull("Failed to open second view with suffix", secondView);
    assertNull("Expected to fail on dummy view id", failView1);
    assertNull("Expected to fail on dummy view id with suffix", failView2);

    /** Test for new view from a duplicate view */
    /* Fetch duplicate view complete id */
    IWorkbench wb = PlatformUI.getWorkbench();
    IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
    IWorkbenchPage page = win.getActivePage();
    IViewReference[] viewRefs = page.getViewReferences();

    String fullId = null;
    for (IViewReference view : viewRefs) {
        if (view.getSecondaryId() != null && view.getId().equals(TmfViewStub.TMF_VIEW_STUB_ID)) {
            assertTrue("Instanceof a TmfViewStub", view.getView(false) instanceof TmfViewStub);
            fullId = ((TmfViewStub) view.getView(false)).getViewId();
            break;
        }
    }
    assertNotNull(fullId);
    IViewPart thirdView = TmfViewFactory.newView(fullId, true);
    assertNotNull("Creation from a view id with suffix failed", fullId);
    assertFalse("New view from view id with suffix was not created", Arrays.asList(viewRefs).contains(thirdView));
}
 
源代码18 项目: tracecompass   文件: SDView.java
/**
 * Checks if current view is ready to be used.
 *
 * @return boolean <code>true</code> if view is ready else <code>false</code>.
 */
protected boolean isViewReady() {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (page == null) {
        return false;
    }

    IViewReference[] ref = page.getViewReferences();
    for (int i = 0; i < ref.length; i++) {
        if (ref[i].getView(false) == this) {
            return true;
        }
    }
    return false;
}
 
源代码19 项目: tracecompass   文件: TmfAlignmentSynchronizer.java
/**
 * Restore the views to their respective maximum widths
 */
private static void restoreViews() {
    // We set the width to Integer.MAX_VALUE so that the
    // views remove any "filler" space they might have.
    for (IWorkbenchWindow window : PlatformUI.getWorkbench().getWorkbenchWindows()) {
        for (IWorkbenchPage page : window.getPages()) {
            for (IViewReference ref : page.getViewReferences()) {
                restoreView(ref);
            }
        }
    }
}
 
源代码20 项目: APICloud-Studio   文件: CommonEditorPlugin.java
protected IViewReference findView(IWorkbenchPage page, String viewId)
{
	for (IViewReference ref : page.getViewReferences())
	{
		if (viewId.equals(ref.getId()))
		{
			return ref;
		}
	}
	return null;
}