use of org.eclipse.ui.PartInitException in project eclipse.platform.text by eclipse.
the class FileSearchPage method handleOpen.
@Override
protected void handleOpen(OpenEvent event) {
if (showLineMatches()) {
Object firstElement = ((IStructuredSelection) event.getSelection()).getFirstElement();
if (firstElement instanceof IFile) {
if (getDisplayedMatchCount(firstElement) == 0) {
try {
open(getSite().getPage(), (IFile) firstElement, false);
} catch (PartInitException e) {
ErrorDialog.openError(getSite().getShell(), SearchMessages.FileSearchPage_open_file_dialog_title, SearchMessages.FileSearchPage_open_file_failed, e.getStatus());
}
return;
}
}
}
super.handleOpen(event);
Object firstElement = ((IStructuredSelection) event.getSelection()).getFirstElement();
if (firstElement == null) {
return;
}
Viewer viewer = event.getViewer();
if (viewer instanceof TreeViewer) {
TreeViewer treeViewer = (TreeViewer) viewer;
if (treeViewer.getExpandedState(firstElement)) {
autoExpand(treeViewer, firstElement);
}
}
}
use of org.eclipse.ui.PartInitException in project eclipse.platform.text by eclipse.
the class AbstractTextEditor method internalInit.
/**
* Implements the <code>init</code> method of <code>IEditorPart</code>.
* Subclasses replacing <code>init</code> may choose to call this method in
* their implementation.
*
* @param window the workbench window
* @param site the editor's site
* @param input the editor input for the editor being created
* @throws PartInitException if {@link #doSetInput(IEditorInput)} fails or gets canceled
*
* @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
* @since 2.1
*/
protected final void internalInit(IWorkbenchWindow window, final IEditorSite site, final IEditorInput input) throws PartInitException {
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
if (getDocumentProvider() instanceof IDocumentProviderExtension2) {
IDocumentProviderExtension2 extension = (IDocumentProviderExtension2) getDocumentProvider();
extension.setProgressMonitor(monitor);
}
doSetInput(input);
} catch (CoreException x) {
throw new InvocationTargetException(x);
} finally {
if (getDocumentProvider() instanceof IDocumentProviderExtension2) {
IDocumentProviderExtension2 extension = (IDocumentProviderExtension2) getDocumentProvider();
extension.setProgressMonitor(null);
}
}
}
};
try {
// When using the progress service always a modal dialog pops up. The site should be asked for a runnable context
// which could be the workbench window or the progress service, depending on what the site represents.
// getSite().getWorkbenchWindow().getWorkbench().getProgressService().run(false, true, runnable);
getSite().getWorkbenchWindow().run(false, true, runnable);
} catch (InterruptedException x) {
} catch (InvocationTargetException x) {
Throwable t = x.getTargetException();
if (t instanceof CoreException) {
/*
/* XXX: Remove unpacking of CoreException once the following bug is
* fixed: https://bugs.eclipse.org/bugs/show_bug.cgi?id=81640
*/
CoreException e = (CoreException) t;
IStatus status = e.getStatus();
if (status.getException() != null)
throw new PartInitException(status);
throw new PartInitException(new Status(status.getSeverity(), status.getPlugin(), status.getCode(), status.getMessage(), t));
}
throw new PartInitException(new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK, EditorMessages.Editor_error_init, t));
}
}
use of org.eclipse.ui.PartInitException in project eclipse.platform.text by eclipse.
the class URLHyperlink method open.
@Override
public void open() {
// Create the browser
IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
IWebBrowser browser;
try {
browser = support.createBrowser(null);
} catch (PartInitException e) {
// $NON-NLS-1$
EditorsPlugin.logErrorStatus("Could not create Web browser for URLHyperlink", e.getStatus());
super.open();
return;
}
try {
browser.openURL(new URL(getURLString()));
} catch (PartInitException e) {
super.open();
} catch (MalformedURLException e) {
super.open();
}
}
use of org.eclipse.ui.PartInitException in project eclipse.platform.text by eclipse.
the class UntitledTextFileWizard method performFinish.
@Override
public boolean performFinish() {
IFileStore fileStore = queryFileStore();
IEditorInput input = createEditorInput(fileStore);
String editorId = getEditorId(fileStore);
IWorkbenchPage page = fWindow.getActivePage();
try {
page.openEditor(input, editorId);
} catch (PartInitException e) {
EditorsPlugin.log(e);
return false;
}
return true;
}
use of org.eclipse.ui.PartInitException in project linuxtools by eclipse.
the class ChartView method createChartView.
/**
* Create and open a new chart view <br/>
* <br/>
* <u><b>Note</b></u>: this method uses the UI thread to open the view and then it sets the input chart. The UI
* thread execution is synchronized on internal Integer SEC_ID which is the secondary id of the chart view. Each new
* chart view has a secondary id equal to SEC_ID++.
*
* @param chart The chart to create view for.
*/
public static void createChartView(final Chart chart) {
PlatformUI.getWorkbench().getDisplay().syncExec(() -> {
try {
synchronized (lock) {
ChartView view = (ChartView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(VIEW_ID, String.valueOf(SEC_ID++), IWorkbenchPage.VIEW_ACTIVATE);
view.setChart(chart);
}
} catch (PartInitException e) {
Status s = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e);
Activator.getDefault().getLog().log(s);
}
});
}
Aggregations