org.eclipse.ui.part.ViewPart#org.eclipse.ui.PartInitException源码实例Demo

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

源代码1 项目: erflute   文件: ERFluteMultiPageEditor.java
public void initVirtualPage() { // called by ERDiagram
    final String diagramName = diagram.getDefaultDiagramName();
    if (diagramName != null) {
        try {
            final int pageIndex = removePage(diagramName);

            final ERVirtualDiagram vdiagram = diagram.getDiagramContents().getVirtualDiagramSet().getVdiagramByName(diagramName);
            diagram.setCurrentVirtualDiagram(vdiagram);

            final VirtualDiagramEditor vdiagramEditor =
                    new VirtualDiagramEditor(diagram, vdiagram, editPartFactory, zoomComboContributionItem, outlinePage);
            addPage(getNewPageIndexIfLessThanZero(pageIndex), vdiagramEditor, getEditorInput());
            setPageText(getNewPageIndexIfLessThanZero(pageIndex), Format.null2blank(vdiagram.getName()));
        } catch (final PartInitException e) {
            Activator.showExceptionDialog(e);
        }
    }
}
 
源代码2 项目: APICloud-Studio   文件: WorkspaceAction.java
/**
 * Most SVN workspace actions modify the workspace and thus should
 * save dirty editors.
 * @see org.tigris.subversion.subclipse.ui.actions.SVNAction#needsToSaveDirtyEditors()
 */
protected boolean needsToSaveDirtyEditors() {

	IResource[] selectedResources = getSelectedResources();
	if (selectedResources != null && selectedResources.length > 0) {
		IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
		for (IEditorReference editorReference : editorReferences) {
			if (editorReference.isDirty()) {
				try {
					IEditorInput editorInput = editorReference.getEditorInput();
					if (editorInput instanceof IFileEditorInput) {
						IFile file = ((IFileEditorInput)editorInput).getFile();
						if (needsToSave(file, selectedResources)) {
							return true;
						}
					}
				} catch (PartInitException e) {}
			}
		}
	}
	
	return false;
}
 
源代码3 项目: n4js   文件: AbstractOutlineWorkbenchTest.java
protected void openOutlineView() throws PartInitException, InterruptedException {
	outlineView = editor.getEditorSite().getPage().showView("org.eclipse.ui.views.ContentOutline");
	executeAsyncDisplayJobs();
	Object adapter = editor.getAdapter(IContentOutlinePage.class);
	assertTrue(adapter instanceof OutlinePage);
	outlinePage = new SyncableOutlinePage((OutlinePage) adapter);
	outlinePage.resetSyncer();
	try {
		outlinePage.waitForUpdate(EXPECTED_TIMEOUT);
	} catch (TimeoutException e) {
		System.out.println("Expected timeout exceeded: " + EXPECTED_TIMEOUT);// timeout is OK here
	}
	treeViewer = outlinePage.getTreeViewer();
	assertSelected(treeViewer);
	assertExpanded(treeViewer);
	assertTrue(treeViewer.getInput() instanceof IOutlineNode);
	IOutlineNode rootNode = (IOutlineNode) treeViewer.getInput();
	List<IOutlineNode> children = rootNode.getChildren();
	assertEquals(1, children.size());
	modelNode = children.get(0);
}
 
源代码4 项目: n4js   文件: EclipseUIUtils.java
/** Opens given file in a editor with given ID within given workbench page. Returns opened editor on null. */
public static IEditorPart openFileEditor(final IFile file, final IWorkbenchPage page, String editorId) {
	checkNotNull(file, "Provided file was null.");
	checkNotNull(page, "Provided page was null.");
	checkNotNull(editorId, "Provided editor ID was null.");

	AtomicReference<IEditorPart> refFileEditor = new AtomicReference<>();

	UIUtils.getDisplay().syncExec(new Runnable() {

		@Override
		public void run() {
			try {
				refFileEditor.set(IDE.openEditor(page, file, editorId, true));
			} catch (PartInitException e) {
				e.printStackTrace();
			}
		}
	});
	return refFileEditor.get();
}
 
源代码5 项目: xtext-xtend   文件: OpenEditorAction.java
@Override
public void run() {
	if (inputFile == null) {
		return;
	}
	IWorkbenchPartSite workbenchPartSite = derivedSourceView.getSite();
	IWorkbenchPage workbenchPage = workbenchPartSite.getPage();
	try {
		IEditorPart editorPart = workbenchPage.openEditor(new FileEditorInput(inputFile),
				COMPILATION_UNIT_EDITOR_ID, true, IWorkbenchPage.MATCH_ID | IWorkbenchPage.MATCH_INPUT);
		if (selectedRegion != null) {
			((ITextEditor) editorPart).selectAndReveal(selectedRegion.getOffset(), selectedRegion.getLength());
		}
	} catch (PartInitException partInitException) {
		throw new WrappedRuntimeException(partInitException);
	}

}
 
源代码6 项目: n4js   文件: N4IDEXpectRunListener.java
/**
 * Called when an atomic test fails.
 *
 * @param failure
 *            describes the test that failed and the exception that was thrown
 */
@Override
public void testFailure(Failure failure) throws Exception {
	Display.getDefault().syncExec(new Runnable() {
		@Override
		public void run() {

			IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
			try {
				N4IDEXpectView view = (N4IDEXpectView) windows[0].getActivePage().showView(
						N4IDEXpectView.ID);
				view.notifyFailedExecutionOf(failure);
			} catch (PartInitException e) {
				N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
			}
		}
	});
}
 
源代码7 项目: n4js   文件: N4IDEXpectRunListener.java
/**
 * Called when an atomic test flags that it assumes a condition that is false
 *
 * describes the test that failed and the {@link AssumptionViolatedException} that was thrown
 */
@Override
public void testAssumptionFailure(Failure failure) {
	Display.getDefault().syncExec(new Runnable() {
		@Override
		public void run() {

			IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
			try {
				N4IDEXpectView view = (N4IDEXpectView) windows[0].getActivePage().showView(
						N4IDEXpectView.ID);
				view.notifyFailedExecutionOf(failure);
			} catch (PartInitException e) {
				N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
			}
		}
	});
}
 
源代码8 项目: n4js   文件: XpectCompareCommandHandler.java
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

	IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);

	IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
	try {
		view = (N4IDEXpectView) windows[0].getActivePage().showView(
				N4IDEXpectView.ID);
	} catch (PartInitException e) {
		N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
	}

	Description desc = (Description) selection.getFirstElement();
	if (desc.isTest() && view.testsExecutionStatus.hasFailed(desc)) {
		Throwable failureException = view.testsExecutionStatus.getFailure(desc).getException();

		if (failureException instanceof ComparisonFailure) {
			ComparisonFailure cf = (ComparisonFailure) failureException;
			// display comparison view
			displayComparisonView(cf, desc);
		}
	}
	return null;
}
 
源代码9 项目: xtext-eclipse   文件: MarkerResolutionGenerator.java
@Deprecated
public IXtextDocument getXtextDocument(IResource resource) {
	IXtextDocument result = xtextDocumentUtil.getXtextDocument(resource);
	if(result == null) {
		IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
		try {
			IFile file = ResourceUtil.getFile(resource);
			IEditorInput input = new FileEditorInput(file);
			IEditorPart newEditor = page.openEditor(input, getEditorId());
			return xtextDocumentUtil.getXtextDocument(newEditor);
		} catch (PartInitException e) {
			return null;
		}
	}
	return result;
}
 
源代码10 项目: dsl-devkit   文件: AbstractUiTest.java
/**
 * Opens the editor asynchronously.
 *
 * @param file
 *          the file
 * @param editorId
 *          the editor id
 * @param activate
 *          true to activate, false otherwise
 */
protected void openEditorAsync(final IFile file, final String editorId, final boolean activate) {
  asyncExec(new VoidResult() {
    @Override
    public void run() {
      try {
        IWorkbench workbench = PlatformUI.getWorkbench();
        IWorkbenchPage activePage = workbench.getActiveWorkbenchWindow().getActivePage();
        final int matchFlags = IWorkbenchPage.MATCH_ID | IWorkbenchPage.MATCH_INPUT;
        final IEditorInput input = new FileEditorInput(file);
        IEditorPart editor = activePage.openEditor(input, editorId, activate, matchFlags);
        editor.setFocus();
        waitForEditorJobs(editor);
      } catch (PartInitException e) {
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug(e.getMessage(), e);
        }
      }
    }
  });
}
 
源代码11 项目: neoscada   文件: AbstractItemAction.java
@Override
public void run ( final IAction action )
{
    final MultiStatus status = new MultiStatus ( Activator.PLUGIN_ID, 0, this.message, null );
    for ( final Item item : this.items )
    {
        try
        {
            processItem ( item );
        }
        catch ( final PartInitException e )
        {
            status.add ( e.getStatus () );
        }
    }
    if ( !status.isOK () )
    {
        showError ( status );
    }
}
 
源代码12 项目: xds-ide   文件: ModulaSearchResultPage.java
protected void showMatch( Match match, int currentOffset
                        , int currentLength, boolean activate 
                        ) throws PartInitException 
{
    if (match instanceof ModulaSymbolMatch) {
        try {
            ModulaSymbolMatch em = (ModulaSymbolMatch)match;
            IFile f = em.getFile();
            IWorkbenchPage page = WorkbenchUtils.getActivePage();
            IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(f.getName());
            IEditorPart ep = page.openEditor(new FileEditorInput(f), desc.getId());
            ITextEditor te = (ITextEditor)ep;
            Control ctr = (Control)te.getAdapter(Control.class);
            ctr.setFocus();
            te.selectAndReveal(em.getOffset(), em.getLength());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
源代码13 项目: solidity-ide   文件: NewFileWizard.java
@Override
public boolean performFinish() {
	IFile file = mainPage.createNewFile();
	if (file == null) {
		return false;
	}

	selectAndReveal(file);

	// Open editor on new file.
	IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
	try {
		if (dw != null) {
			IWorkbenchPage page = dw.getActivePage();
			if (page != null) {
				IDE.openEditor(page, file, true);
			}
		}
	} catch (PartInitException e) {
		openError(dw.getShell(), "Problems opening editor", e.getMessage(), e);
	}

	return true;
}
 
源代码14 项目: neoscada   文件: AbstractAlarmsEventsView.java
@Override
public void init ( final IViewSite site, final IMemento memento ) throws PartInitException
{
    if ( memento != null )
    {
        this.connectionId = memento.getString ( CONNECTION_ID );
        this.connectionUri = memento.getString ( CONNECTION_URI );
    }

    super.init ( site, memento );
    try
    {
        // it is OK to fail at this stage
        reInitializeConnection ( this.connectionId, this.connectionUri );
    }
    catch ( final Exception e )
    {
        logger.warn ( "init () - couldn't recreate connection", e ); //$NON-NLS-1$
        // just reset all values
        this.connectionId = null;
        this.connectionUri = null;
        this.connectionService = null;
        this.connectionTracker = null;
    }
}
 
源代码15 项目: tm4e   文件: TMinGenericEditorTest.java
@Test
public void testTMHighlightInGenericEditorEdit() throws IOException, PartInitException {
	f = File.createTempFile("test" + System.currentTimeMillis(), ".ts");
	FileOutputStream fileOutputStream = new FileOutputStream(f);
	fileOutputStream.write("let a = '';".getBytes());
	fileOutputStream.close();
	f.deleteOnExit();
	editor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(),
			f.toURI(), editorDescriptor.getId(), true);
	StyledText text = (StyledText)editor.getAdapter(Control.class);
	Assert.assertTrue(new DisplayHelper() {
		@Override
		protected boolean condition() {
			return text.getStyleRanges().length > 1;
		}
	}.waitForCondition(text.getDisplay(), 3000));
	int initialNumberOfRanges = text.getStyleRanges().length;
	text.setText("let a = '';\nlet b = 10;\nlet c = true;");
	Assert.assertTrue("More styles should have been added", new DisplayHelper() {
		@Override protected boolean condition() {
			return text.getStyleRanges().length > initialNumberOfRanges + 3;
		}
	}.waitForCondition(text.getDisplay(), 300000));
}
 
源代码16 项目: LogViewer   文件: LogDocument.java
public LogDocument(LogFile file, String encoding) throws SecurityException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, PartInitException {
	super();
	if (file.getEncoding() == null) {
		file.setEncoding(encoding);
	}
	this.file = file;
	this.encoding = file.getEncoding();
	this.charset = Charset.forName(file.getEncoding());
	IPreferenceStore store = LogViewerPlugin.getDefault().getPreferenceStore();
	store.addPropertyChangeListener(new PropertyChangeListener());
	backlogLines = store.getInt(ILogViewerConstants.PREF_BACKLOG);
	setTextStore(new GapTextStore(50, 300, 1f));
	setLineTracker(new DefaultLineTracker());
	completeInitialization();
	reader = new BackgroundReader(file.getType(), file.getPath(), file.getNamePattern(), charset,this);
}
 
源代码17 项目: gef   文件: SyncGraphvizExportHandler.java
private void openFile(IFile file) {
	IEditorRegistry registry = PlatformUI.getWorkbench()
			.getEditorRegistry();
	if (registry.isSystemExternalEditorAvailable(file.getName())) {

		/**
		 * in case of opening the exported file from an other thread e.g. in
		 * case of listening to an IResourceChangeEvent
		 */
		Display.getDefault().asyncExec(new Runnable() {

			@Override
			public void run() {
				IWorkbenchPage page = PlatformUI.getWorkbench()
						.getActiveWorkbenchWindow().getActivePage();
				try {
					page.openEditor(new FileEditorInput(file),
							IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
				} catch (PartInitException e) {
					DotActivatorEx.logError(e);
				}
			}
		});
	}
}
 
源代码18 项目: workspacemechanic   文件: ShowViewScanner.java
public void run() {
  Display.getDefault().syncExec(new Runnable() {
    public void run() {
      IWorkbench workbench = PlatformUI.getWorkbench();
      IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
      IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
      for (String viewId : list) {
        try {
          activePage.showView(viewId);
        } catch (PartInitException e) {
          LOG.log(Level.SEVERE, "Can't open view " + viewId, e);
        }
      }
    }
  });
}
 
源代码19 项目: corrosion   文件: RustManager.java
private static LSPDocumentInfo infoFromOpenEditors() {
	for (IWorkbenchWindow window : PlatformUI.getWorkbench().getWorkbenchWindows()) {
		for (IWorkbenchPage page : window.getPages()) {
			for (IEditorReference editor : page.getEditorReferences()) {
				IEditorInput input;
				try {
					input = editor.getEditorInput();
				} catch (PartInitException e) {
					continue;
				}
				if (input.getName().endsWith(".rs") && editor.getEditor(false) instanceof ITextEditor) { //$NON-NLS-1$
					IDocument document = (((ITextEditor) editor.getEditor(false)).getDocumentProvider())
							.getDocument(input);
					Collection<LSPDocumentInfo> infos = LanguageServiceAccessor.getLSPDocumentInfosFor(document,
							capabilities -> Boolean.TRUE.equals(capabilities.getReferencesProvider()));
					if (!infos.isEmpty()) {
						return infos.iterator().next();
					}
				}
			}
		}
	}
	return null;
}
 
源代码20 项目: gama   文件: FileOpener.java
public static IEditorPart openFile(final URI uri) {
	if (uri == null) {
		MessageDialog.openWarning(WorkbenchHelper.getShell(), "No file found", "Trying to open a null file");
		return null;
	}
	try {
		if (uri.isPlatformResource()) { return FileOpener.openFileInWorkspace(uri); }
		if (uri.isFile()) { return FileOpener.openFileInFileSystem(uri); }
	} catch (final PartInitException e) {
		MessageDialog.openWarning(WorkbenchHelper.getShell(), "No file found",
				"The file'" + uri.toString() + "' does not exist on disk.");
	}
	MessageDialog.openWarning(WorkbenchHelper.getShell(), "No file found",
			"The file'" + uri.toString() + "' cannot be found.");
	return null;
}
 
源代码21 项目: txtUML   文件: Exporter.java
/**
 * Opens visualize.html in the default browser
 * 
 * @throws PartInitException
 * @throws MalformedURLException
 */
private void display() throws PartInitException, MalformedURLException {
	// set to use external browser due to internal browser bug
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=501978
	final IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser();
	browser.openURL(Paths.get(target, FILE_TO_OPEN_IN_BROWSER).toUri().toURL());
}
 
源代码22 项目: statecharts   文件: NavigatorActionProvider.java
public void run() {
	if (myDiagram == null || myDiagram.eResource() == null) {
		return;
	}

	IEditorInput editorInput = getEditorInput();
	IWorkbenchPage page = myViewerSite.getPage();
	try {
		page.openEditor(editorInput, ID);
	} catch (PartInitException e) {

		e.printStackTrace();
	}
}
 
源代码23 项目: codewind-eclipse   文件: WelcomePageEditorPart.java
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
	if (!(input instanceof WelcomePageEditorInput)) {
		Logger.logError("The editor input is not valid for the welcome page: " + input.getClass()); //$NON-NLS-1$
       	throw new PartInitException(Messages.WelcomePageEditorCreateError);
	}
	
	setSite(site);
       setInput(input);
       
       setPartName(Messages.WelcomePageEditorPartName);
       
       CodewindUIPlugin.getUpdateHandler().addUpdateListener(this);
}
 
源代码24 项目: spotbugs   文件: GroupByActionTest.java
@Test
public void testAction_Project_Priority_Category_PatternType_Pattern_Marker() throws PartInitException {
    runAction(PROJECT_PRIORITY_CATEGORY_PATTERN_TYPE_PATTERN_MARKER_ID);

    assertExpectedGroupTypes(GroupType.Project, GroupType.Confidence, GroupType.Category, GroupType.PatternType,
            GroupType.Pattern, GroupType.Marker);
}
 
源代码25 项目: APICloud-Studio   文件: APICloudWizardEditor.java
@Override
public void init(IEditorSite site, IEditorInput input)
		throws PartInitException {
	setSite(site);
	setInput(input);
	initInfo();
}
 
源代码26 项目: LogViewer   文件: ConsoleOpenAction.java
/**
 * @see IActionDelegate#run(IAction)
 */
public void run(IAction action) {

	if (!isEnabled()) {
		MessageDialog.openInformation(
			new Shell(),
			"Logfile Viewer",
			"Wrong Selection");
		return;
	}

	for (int i=0;i<resource.length;i++) {

		if (resource[i] == null)
			continue;

		String full_path = resource[i].getClass().toString().replaceFirst("class ", "") + System.getProperty("file.separator") + resource[i].getName();
		LogViewer view = null;

		try {
			view = (LogViewer) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("de.anbos.eclipse.logviewer.plugin.LogViewer");
		} catch (PartInitException e) {
			e.printStackTrace();
		}

		view.checkAndOpenFile(LogFileType.LOGFILE_ECLIPSE_CONSOLE, full_path, null, false);
	}
}
 
源代码27 项目: typescript.java   文件: AbstractFormEditor.java
@Override
protected void addPages() {
	this.jsonEditor = new StructuredTextEditor();
	jsonEditor.setEditorPart(this);
	try {
		// Add pages like overview, etc
		doAddPages();
		// Add source page
		jsonEditorIndex = addPage(jsonEditor, getEditorInput());
		setPageText(jsonEditorIndex, "Source");
	} catch (PartInitException e) {
		e.printStackTrace();
	}
}
 
源代码28 项目: xds-ide   文件: XBookmarkHandler.java
/**
 * Jumps to the xBookmark with the given number, if there is one.
 * When necessary an editor will be opened.
 * If there are multiple marks with the same number then the previous/next
 * one from the current selection will be jumped to (when exactly on
 * a xBookmark that mark isn't considered as a jump target).
 * If after any xBookmark with that number, the search toggles around
 * to the first one and vice versa.
 * 
 * @param markerNumber  the number of the mark to jump to
 * @param backward  true, if the previous mark should be jumped to instead
 *                  of the next one
 */
protected void gotoBookmark (int markerNumber) {
    IResource scope = XBookmarksUtils.getWorkspaceScope();
    if (scope == null) {
        return;
    }
    IMarker marker = XBookmarksUtils.fetchBookmark(scope, markerNumber);
    if (marker == null) {
        statusLine.showErrMessage(MessageFormat.format(Messages.BookmarkAction_BM_NotFound, markerNumber));
        return;
    }
    IResource resource = marker.getResource();
    if (! (resource instanceof IFile)) {
        statusLine.showErrMessage(MessageFormat.format(Messages.BookmarkAction_BM_HbzWhere, markerNumber));
        return;
    }
    IWorkbenchPage page = WorkbenchUtils.getActivePage();
    if (page == null) {
        statusLine.showErrMessage(MessageFormat.format(Messages.BookmarkAction_CantGoBM_NoActivePage, markerNumber));
        return;
    }
    // now try to jump and open the right editor, if necessary
    try {
        IDE.openEditor(page, marker, OpenStrategy.activateOnOpen());
        statusLine.showMessage(
                MessageFormat.format(Messages.BookmarkAction_OnBM, markerNumber),
                XBookmarksPlugin.IMGID_GOTO);
    }
    catch (PartInitException e) {
        XBookmarksUtils.logError(e);
        statusLine.showErrMessage(MessageFormat.format(Messages.BookmarkAction_CantGoBM, markerNumber));
    }
}
 
源代码29 项目: depan   文件: NodeListEditor.java
@Override
public void init(IEditorSite site, IEditorInput input)
    throws PartInitException {
  setSite(site);
  setInput(input);
  initFromInput(input);
}
 
源代码30 项目: texlipse   文件: ViewerOutputScanner.java
public void run() {
    
    IWorkbenchPage page = TexlipsePlugin.getCurrentWorkbenchPage();
    if (page == null) {
        return;
    }
    
    try {
        IDE.openEditor(page, marker, false);
    } catch (PartInitException e) {
    }
}