org.eclipse.ui.PartInitException Java Examples
The following examples show how to use
org.eclipse.ui.PartInitException.
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: ModulaSearchResultPage.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
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(); } } }
Example #2
Source File: FileOpener.java From gama with GNU General Public License v3.0 | 6 votes |
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; }
Example #3
Source File: WorkspaceAction.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * 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; }
Example #4
Source File: ERFluteMultiPageEditor.java From erflute with Apache License 2.0 | 6 votes |
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); } } }
Example #5
Source File: RustManager.java From corrosion with Eclipse Public License 2.0 | 6 votes |
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; }
Example #6
Source File: SyncGraphvizExportHandler.java From gef with Eclipse Public License 2.0 | 6 votes |
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); } } }); } }
Example #7
Source File: ShowViewScanner.java From workspacemechanic with Eclipse Public License 1.0 | 6 votes |
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); } } } }); }
Example #8
Source File: AbstractOutlineWorkbenchTest.java From n4js with Eclipse Public License 1.0 | 6 votes |
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); }
Example #9
Source File: EclipseUIUtils.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** 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(); }
Example #10
Source File: N4IDEXpectRunListener.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * 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); } } }); }
Example #11
Source File: XpectCompareCommandHandler.java From n4js with Eclipse Public License 1.0 | 6 votes |
@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; }
Example #12
Source File: OpenEditorAction.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@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); } }
Example #13
Source File: NewFileWizard.java From solidity-ide with Eclipse Public License 1.0 | 6 votes |
@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; }
Example #14
Source File: AbstractItemAction.java From neoscada with Eclipse Public License 1.0 | 6 votes |
@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 ); } }
Example #15
Source File: AbstractAlarmsEventsView.java From neoscada with Eclipse Public License 1.0 | 6 votes |
@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; } }
Example #16
Source File: AbstractUiTest.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * 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); } } } }); }
Example #17
Source File: MarkerResolutionGenerator.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@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; }
Example #18
Source File: TMinGenericEditorTest.java From tm4e with Eclipse Public License 1.0 | 6 votes |
@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)); }
Example #19
Source File: LogDocument.java From LogViewer with Eclipse Public License 2.0 | 6 votes |
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); }
Example #20
Source File: N4IDEXpectRunListener.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * 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); } } }); }
Example #21
Source File: TLAEditorAndPDFViewer.java From tlaplus with MIT License | 5 votes |
@Override protected void addPages() { try { // This code moves the tabs to the top of the page. // This makes them more obvious to the user. if (getContainer() instanceof CTabFolder) { final CTabFolder cTabFolder = (CTabFolder) getContainer(); cTabFolder.setTabPosition(SWT.TOP); // If there is only the editor but no PDF shown next to it, the tab bar of the // ctabfolder just wastes screen estate. if (cTabFolder.getItemCount() <= 1) { cTabFolder.setTabHeight(0); } else { cTabFolder.setTabHeight(-1); } } tlaEditor = new TLAEditor(); addPage(tlaEditorIndex, tlaEditor, tlaEditorInput); setPageText(tlaEditorIndex, "TLA Module"); } catch (PartInitException e) { // I hope you don't choke swallowing all those exceptions... e.printStackTrace(); } }
Example #22
Source File: PDFBrowserEditor.java From tlaplus with MIT License | 5 votes |
@Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { setSite(site); setInput(input); this.setPartName(input.getName()); if (browser != null && input instanceof IFileEditorInput) { setFileInput((IFileEditorInput) input); } }
Example #23
Source File: SecurityActionBarContributor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public void run () { try { getPage ().showView ( "org.eclipse.ui.views.PropertySheet" ); //$NON-NLS-1$ } catch ( PartInitException exception ) { SecurityEditorPlugin.INSTANCE.log ( exception ); } }
Example #24
Source File: MonitorsView.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public void init ( final IViewSite site, final IMemento memento ) throws PartInitException { super.init ( site, memento ); if ( memento != null ) { final String s = memento.getString ( "columnSettings" ); //$NON-NLS-1$ if ( s != null ) { this.initialColumnSettings = this.gson.fromJson ( s, new TypeToken<List<ColumnProperties>> () {}.getType () ); } } }
Example #25
Source File: OpenUrlAction.java From workspacemechanic with Eclipse Public License 1.0 | 5 votes |
@Override public void run() { IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport(); try { support.getExternalBrowser().openURL(url); } catch (PartInitException e) { throw new IllegalStateException( "Eeep! Coudn't initialize part.", e); } }
Example #26
Source File: TmfXmlViewOutput.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override protected IViewPart openView() throws PartInitException { final IWorkbench wb = PlatformUI.getWorkbench(); final IWorkbenchPage activePage = wb.getActiveWorkbenchWindow().getActivePage(); return activePage.showView(getViewId(), getName(), IWorkbenchPage.VIEW_ACTIVATE); }
Example #27
Source File: ComponentActionBarContributor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public void run () { try { getPage ().showView ( "org.eclipse.ui.views.PropertySheet" ); //$NON-NLS-1$ } catch ( PartInitException exception ) { ComponentEditorPlugin.INSTANCE.log ( exception ); } }
Example #28
Source File: NodeListEditor.java From depan with Apache License 2.0 | 5 votes |
@Override public void run() { IWorkbenchPage page = PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage(); try { page.openEditor(input, NodeListEditor.ID); } catch (PartInitException errInit) { GraphDocLogger.LOG.error("Unable to start NodeListEditor", errInit); } }
Example #29
Source File: WorkbenchTestHelper.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public ITextEditor openLikeTextEditor(IFile file) throws PartInitException { IEditorPart editor = IDE.openEditor(workbench.getActiveWorkbenchWindow().getActivePage(), file); if (editor instanceof ITextEditor) { return (ITextEditor) editor; } return null; }
Example #30
Source File: NewFileWizard.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
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) { DialogUtil.openError(dw.getShell(), ResourceMessages.FileResource_errorMessage, e.getMessage(), e); } return true; }