Java Code Examples for org.eclipse.ui.IWorkbenchPage#closeAllEditors()

The following examples show how to use org.eclipse.ui.IWorkbenchPage#closeAllEditors() . 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: RCPTestSetupHelper.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * Close all open windows, editors, perspectives. Open and reset default perspective.
 */
private static void resetWorkbench() {
    try {
        IWorkbench workbench = PlatformUI.getWorkbench();
        IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
        IWorkbenchPage page = workbenchWindow.getActivePage();
        
        Shell activeShell = Display.getCurrent().getActiveShell();
        if (activeShell != null && activeShell != workbenchWindow.getShell()) {
            activeShell.close();
        }
        
        page.closeAllEditors(false);
        page.resetPerspective();
        
        String defaultPerspectiveId = workbench.getPerspectiveRegistry().getDefaultPerspective();
        workbench.showPerspective(defaultPerspectiveId, workbenchWindow);
        page.resetPerspective();
        
        page.showView("org.eclipse.ui.internal.introview");
    } catch (WorkbenchException e) {
        throw new RuntimeException(e);
    }
}
 
Example 2
Source File: Bug326812Test.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testCloseTwoEditorsForSameLanguage() throws Exception {
	modelAsText = "one { two {} three {} } four {}";
	IFile file = IResourcesSetupUtil.createFile("test/othertest.outlinetestlanguage", modelAsText);
	openEditor(file);
	IWorkbenchPage page = editor.getSite().getPage();
	page.closeAllEditors(false);
	assertFalse(CustomOutlineWithEditorLinker.DEACTIVATE_CALLED_WITH_NULL_TEXT_LISTENER);
}
 
Example 3
Source File: AbstractPluginTest.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    // Start with a clean FindBugs state
    clearBugsState();
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    activePage.closeAllEditors(false);
    IViewPart view = activePage.findView("org.eclipse.ui.internal.introview");
    if (view != null) {
        activePage.hideView(view);
    }
    getPreferenceStore().setValue(FindBugsConstants.ASK_ABOUT_PERSPECTIVE_SWITCH, false);
    waitForJobs();
    processUiEvents();
}
 
Example 4
Source File: AbstractBuilderTest.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
private void closeAllEditorsForTearDown() {
	IWorkbenchPage page = EclipseUIUtils.getActivePage();
	if (page != null)
		page.closeAllEditors(false);
}