private static void throwPartInitException(String message, int code) throws PartInitException { IStatus status= new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, code, message, null); throw new PartInitException(status); }
public void run() { final IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage(); try { IDE.openEditor(page, file, true); } catch (final PartInitException e) { logger.error(e.getMessage(), e); } } });
private static void handleViewError(String id, PartInitException e) { StatusUtil.handleStatus(e.getStatus(), "View could not be opened: " + id, //$NON-NLS-1$ StatusManager.SHOW); }
@Override public Object execute(final ExecutionEvent event) throws ExecutionException { final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil .getActiveWorkbenchWindowChecked(event); final IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage(); if (activePage == null) { return null; } try { activePage.showView(viewId); } catch (PartInitException e) { IStatus status = StatusUtil .newStatus(e.getStatus(), e.getMessage()); StatusManager.getManager().handle(status, StatusManager.SHOW); } return null; } }
public void displayURL(String url) throws Exception { try { IWebBrowser browser = getExternalBrowser(); if (browser != null) { browser.openURL(new URL(url)); } } catch (PartInitException pie) { ErrorUtil.displayErrorDialog(pie.getLocalizedMessage()); } }
/** * Opens a editor on the given file resource. * * @param file * the workspace file */ protected void openWorkspaceFile(IFile file) { try { boolean activate = OpenStrategy.activateOnOpen(); IDE.openEditor(getWorkbenchPage(), file, activate); } catch (PartInitException e) { ErrorDialog.openError(getWorkbenchPage().getWorkbenchWindow() .getShell(), UIText.OpenWorkingFileAction_openWorkingFileShellTitle, e .getMessage(), e.getStatus()); } }
viewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { try { } catch (PartInitException e) { e.printStackTrace(); } } });
public void mouseUp(MouseEvent e) { if (commitLink.getSelectionText().length() != 0) return; try { getShell().dispose(); CommitEditor.open(new RepositoryCommit(revision .getRepository(), revision.getCommit())); } catch (PartInitException pie) { Activator.logError(pie.getLocalizedMessage(), pie); } } });
private static void throwPartInitException(String message) throws PartInitException { IStatus status= new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, IStatus.OK, message, null); throw new PartInitException(status); }
/** * Creates a new exception object. Note that as of 3.5, this constructor * expects exactly one exception object in the given array, with all other * array positions being <code>null</code>. The restriction may be lifted in * the future, and clients of this class must not make this assumption. * * @param references * @param exceptions */ public MultiPartInitException(IWorkbenchPartReference[] references, PartInitException[] exceptions) { super(exceptions[findFirstException(exceptions)].getStatus()); this.references = references; this.exceptions = exceptions; }
public void widgetSelected(SelectionEvent e) { try { URL url = new URL( "http://maven.apache.org/plugins/maven-archetype-plugin/specification/archetype-catalog.html"); //$NON-NLS-1$ IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser(); browser.openURL(url); } catch(MalformedURLException ex) { log.error("Malformed URL", ex); //$NON-NLS-1$ } catch(PartInitException ex) { log.error(ex.getMessage(), ex); } } });
/** * Opens external file, the editor that is used is based on best guess from * file name. * * @param file * the external file */ protected void openExternalFile(File file) { try { boolean activate = OpenStrategy.activateOnOpen(); IEditorDescriptor desc = IDE.getEditorDescriptor(file.getName()); IDE.openEditor(getWorkbenchPage(), file.toURI(), desc.getId(), activate); } catch (PartInitException e) { ErrorDialog.openError(getWorkbenchPage().getWorkbenchWindow() .getShell(), UIText.OpenWorkingFileAction_openWorkingFileShellTitle, e .getMessage(), e.getStatus()); } }
PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(new IPerspectiveListener() { @Override public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) { try { page.showView("...", null, IWorkbenchPage.VIEW_VISIBLE); } catch (PartInitException ex) { ex.printStackTrace(); } } @Override public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) { } });
private void open(KeyReference keyReference) { if (keyReference == null) return; try { IEditorPart part= keyReference.element != null ? EditorUtility.openInEditor(keyReference.element, true) : EditorUtility.openInEditor(keyReference.resource, true); if (part != null) EditorUtility.revealInEditor(part, keyReference.offset, keyReference.length); } catch (PartInitException x) { String message= null; IWorkbenchAdapter wbAdapter= ((IAdaptable)keyReference).getAdapter(IWorkbenchAdapter.class); if (wbAdapter != null) message= Messages.format(PropertiesFileEditorMessages.OpenAction_error_messageArgs, new String[] { wbAdapter.getLabel(keyReference), x.getLocalizedMessage() } ); if (message == null) message= Messages.format(PropertiesFileEditorMessages.OpenAction_error_message, x.getLocalizedMessage()); MessageDialog.openError(fShell, PropertiesFileEditorMessages.OpenAction_error_messageProblems, message); } }
private static void throwPartInitException(String message, int code) throws PartInitException { IStatus status= new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, code, message, null); throw new PartInitException(status); }
private IEditorPart showWithoutReuse(Object element) throws PartInitException { try { return EditorUtility.openInEditor(element, false); } catch (PartInitException e) { if (e.getStatus().getCode() != IJavaStatusConstants.EDITOR_NO_EDITOR_INPUT) { throw e; } } return null; }
/** * Open commit in editor * * @param commit * @param activateOnOpen <code>true</code> if the newly opened editor should be activated * @return opened editor part or null if opening fails * @since 2.1 */ public static final IEditorPart openQuiet(RepositoryCommit commit, boolean activateOnOpen) { try { return open(commit, activateOnOpen); } catch (PartInitException e) { Activator.logError(e.getMessage(), e); return null; } }
/** * Shows the Navigator view and sets its selection to the resources * selected in this action's selection provider. */ @Override public void run() { List<IResource> v = getResources(getStructuredSelection()); if (v.isEmpty()) { return; } try { IViewPart view = page.showView(IPageLayout.ID_RES_NAV); if (view instanceof ISetSelectionTarget) { ISelection selection = new StructuredSelection(v); ((ISetSelectionTarget) view).selectReveal(selection); } } catch (PartInitException e) { ErrorDialog.openError(page.getWorkbenchWindow().getShell(), ResourceNavigatorMessages.ShowInNavigator_errorMessage, e.getMessage(), e.getStatus()); } }
public void createPartControl(Composite parent) { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage(); IViewReference ref = page.findViewReference(IConsoleConstants.ID_CONSOLE_VIEW); IOConsole console = createConsole(); // here create new console // this will ad console page to corresponding view IPageBookViewPage pageBook = targetConsole.createPage(this); try { pageBook.init(new PageSite((IViewSite) ref.getView(true).getSite())); } catch (PartInitException e) { e.printStackTrace(); } pageBook.createControl(parent); }