org.eclipse.ui.internal.ErrorEditorPart Java Examples

The following examples show how to use org.eclipse.ui.internal.ErrorEditorPart. 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: AbstractEditorTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private XtextEditor getXtextEditor(IEditorPart openEditor) throws NoSuchFieldException, IllegalAccessException {
	XtextEditor xtextEditor = EditorUtils.getXtextEditor(openEditor);
	if (xtextEditor != null) {
		ISourceViewer sourceViewer = xtextEditor.getInternalSourceViewer();
		((ProjectionViewer) sourceViewer).doOperation(ProjectionViewer.EXPAND_ALL);
		return xtextEditor;
	} else if (openEditor instanceof ErrorEditorPart) {
		Field field = openEditor.getClass().getDeclaredField("error");
		field.setAccessible(true);
		throw new IllegalStateException("Couldn't open the editor.", ((Status) field.get(openEditor)).getException());
	} else {
		fail("Opened Editor with id:" + getEditorId() + ", is not an XtextEditor");
	}
	return null;
}
 
Example #2
Source File: TestProcessZoo.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected void applyTestsOnProcess(final URL url) throws Throwable {
    final int beforeImport = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences().length;
    final File file = new File(FileLocator.toFileURL(url).getFile());
    final ImportBosArchiveOperation ibao = new ImportBosArchiveOperation(repositoryAccessor);
    ibao.setArchiveFile(file.getAbsolutePath());
    ibao.setCurrentRepository(repositoryAccessor.getCurrentRepository());
    ibao.run(Repository.NULL_PROGRESS_MONITOR);

    for (final IRepositoryFileStore f : ibao.getFileStoresToOpen()) {
        f.open();
    }

    final IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (editor instanceof ErrorEditorPart) {
        final ErrorEditorPart errorEditor = (ErrorEditorPart) editor;
        final IStatus error = (IStatus) ErrorEditorPart.class.getField("error").get(errorEditor);
        throw error.getException();
    }
    final ProcessDiagramEditor processEditor = (ProcessDiagramEditor) editor;
    /* for mickeyprocessses .proc will overrided (as it is sorted) when they come so need */
    if (url.toString().contains("mickeyProcesses/") && url.toString().contains(".proc")) {
        assertEquals("Import should have opened another process editor but colsed another one for " + url, beforeImport,
                PlatformUI.getWorkbench()
                        .getActiveWorkbenchWindow().getActivePage().getEditorReferences().length);
    } else {
        assertEquals("Import should have opened another process editor for " + url, beforeImport + 1,
                PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                        .getActivePage().getEditorReferences().length);
    }
    final AbstractProcess diagram = (AbstractProcess) processEditor.getDiagramEditPart().resolveSemanticElement();
    if (file.getAbsolutePath().endsWith(".bos")) {// Check unresolved dependencies for BAR Files
        final DependencyRepositoryStore store = repositoryAccessor.getRepositoryStore(DependencyRepositoryStore.class);
        for (final Element element : diagram.getElements()) {
            if (element instanceof AbstractProcess) {
                for (final Configuration config : ((AbstractProcess) element).getConfigurations()) {
                    for (final FragmentContainer fragmentContainer : config.getProcessDependencies()) {
                        for (final Fragment fragment : fragmentContainer.getFragments()) {
                            final String lib = fragment.getValue();
                            if (lib.endsWith(DependencyRepositoryStore.JAR_EXT)) {
                                assertNotNull("A lib is unresolved " + lib, store.getChild(lib, true));
                            }
                        }
                    }
                }
            }
        }
    }

    final RunProcessCommand runProcessCommand = new RunProcessCommand(true);
    runProcessCommand.execute(ProcessSelector.createExecutionEvent((AbstractProcess) diagram.getElements().get(0)));
    assertThat(runProcessCommand.getUrl()).isNotNull();
    assertNotNull("There should be an application deployed and running for " + url,
            runProcessCommand.getUrl().getContent());
}