Search in sources :

Example 61 with PartInitException

use of org.eclipse.ui.PartInitException in project archi by archimatetool.

the class CheckForNewVersionAction method run.

@Override
public void run() {
    try {
        URL url = new URL(versionFile);
        String newVersion = getOnlineVersion(url);
        // Get this app's main version number
        String thisVersion = System.getProperty(Application.APPLICATION_VERSIONID);
        if (StringUtils.compareVersionNumbers(newVersion, thisVersion) > 0) {
            boolean reply = MessageDialog.openQuestion(null, Messages.CheckForNewVersionAction_1, Messages.CheckForNewVersionAction_2 + " (" + newVersion + // $NON-NLS-1$ //$NON-NLS-2$
            "). " + Messages.CheckForNewVersionAction_3);
            if (reply) {
                IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
                IWebBrowser browser = support.getExternalBrowser();
                if (browser != null) {
                    URL url2 = new URL(downloadPage);
                    browser.openURL(url2);
                }
            }
        } else {
            MessageDialog.openInformation(null, Messages.CheckForNewVersionAction_1, Messages.CheckForNewVersionAction_4);
        }
    } catch (MalformedURLException ex) {
        ex.printStackTrace();
    } catch (IOException ex) {
        ex.printStackTrace();
        showErrorMessage(Messages.CheckForNewVersionAction_5);
        return;
    } catch (PartInitException ex) {
        ex.printStackTrace();
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) IWebBrowser(org.eclipse.ui.browser.IWebBrowser) IOException(java.io.IOException) PartInitException(org.eclipse.ui.PartInitException) URL(java.net.URL)

Example 62 with PartInitException

use of org.eclipse.ui.PartInitException in project xtext-eclipse by eclipse.

the class ClassFileBasedOpenerContributor method collectSourceFileOpeners.

@Override
public boolean collectSourceFileOpeners(IEditorPart editor, IAcceptor<FileOpener> acceptor) {
    if (!(editor instanceof XtextEditor) && editor.getEditorInput() != null) {
        try {
            IClassFile classFile = (IClassFile) editor.getEditorInput().getAdapter(IClassFile.class);
            if (classFile == null) {
                return false;
            }
            ITrace trace = traceForTypeRootProvider.getTraceToSource(classFile);
            if (trace == null) {
                return false;
            }
            for (ILocationInResource location : trace.getAllAssociatedLocations()) {
                String name = location.getAbsoluteResourceURI().getURI().lastSegment();
                IEditorDescriptor editorDescriptor = IDE.getEditorDescriptor(name);
                acceptor.accept(createEditorOpener(editor.getEditorInput(), editorDescriptor.getId()));
                return true;
            }
        } catch (PartInitException e) {
            LOG.error(e.getMessage(), e);
        }
    }
    return false;
}
Also used : IClassFile(org.eclipse.jdt.core.IClassFile) XtextEditor(org.eclipse.xtext.ui.editor.XtextEditor) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) ITrace(org.eclipse.xtext.generator.trace.ITrace) PartInitException(org.eclipse.ui.PartInitException) ILocationInResource(org.eclipse.xtext.generator.trace.ILocationInResource)

Example 63 with PartInitException

use of org.eclipse.ui.PartInitException in project xtext-eclipse by eclipse.

the class MultiPageEditor method createXtextPage.

void createXtextPage() {
    try {
        Injector injector = org.eclipse.xtext.ui.tests.internal.TestsActivator.getInstance().getInjector("org.eclipse.xtext.ui.tests.TestLanguage");
        editor = injector.getInstance(XtextEditor.class);
        int index = addPage(editor, getEditorInput());
        setPageText(index, editor.getTitle());
    } catch (PartInitException e) {
        ErrorDialog.openError(getSite().getShell(), "Error creating nested text editor", null, e.getStatus());
    }
}
Also used : Injector(com.google.inject.Injector) XtextEditor(org.eclipse.xtext.ui.editor.XtextEditor) PartInitException(org.eclipse.ui.PartInitException)

Example 64 with PartInitException

use of org.eclipse.ui.PartInitException in project xtext-eclipse by eclipse.

the class TypeResourceUnloaderTest method testCloseAndReopenEditor.

@Test
public void testCloseAndReopenEditor() throws InterruptedException, PartInitException, JavaModelException {
    waitForEvent(new Procedure0() {

        @Override
        public void apply() {
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeEditor(editor, false);
            try {
                editor = JavaUI.openInEditor(compilationUnit);
            } catch (PartInitException e) {
                fail(e.getMessage());
            } catch (JavaModelException e) {
                fail(e.getMessage());
            }
        }
    });
    assertNull(event);
}
Also used : JavaModelException(org.eclipse.jdt.core.JavaModelException) Procedure0(org.eclipse.xtext.xbase.lib.Procedures.Procedure0) PartInitException(org.eclipse.ui.PartInitException) Test(org.junit.Test)

Example 65 with PartInitException

use of org.eclipse.ui.PartInitException in project xtext-eclipse by eclipse.

the class GlobalURIEditorOpener method openDefaultEditor.

protected IEditorPart openDefaultEditor(URI uri, EReference crossReference, int indexInList, boolean select) {
    Iterator<Pair<IStorage, IProject>> storages = mapper.getStorages(uri.trimFragment()).iterator();
    if (storages != null && storages.hasNext()) {
        try {
            IStorage storage = storages.next().getFirst();
            IEditorPart editor = null;
            if (storage instanceof IFile) {
                editor = openDefaultEditor((IFile) storage);
            } else {
                editor = openDefaultEditor(storage, uri);
            }
            selectAndReveal(editor, uri, crossReference, indexInList, select);
            return editor;
        } catch (WrappedException e) {
            logger.error("Error while opening editor part for EMF URI '" + uri + "'", e.getCause());
        } catch (PartInitException partInitException) {
            logger.error("Error while opening editor part for EMF URI '" + uri + "'", partInitException);
        }
    }
    return null;
}
Also used : WrappedException(org.eclipse.emf.common.util.WrappedException) IFile(org.eclipse.core.resources.IFile) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) IStorage(org.eclipse.core.resources.IStorage) Pair(org.eclipse.xtext.util.Pair)

Aggregations

PartInitException (org.eclipse.ui.PartInitException)720 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)300 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)177 IFile (org.eclipse.core.resources.IFile)146 IEditorPart (org.eclipse.ui.IEditorPart)141 CoreException (org.eclipse.core.runtime.CoreException)94 FileEditorInput (org.eclipse.ui.part.FileEditorInput)88 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)82 IEditorInput (org.eclipse.ui.IEditorInput)74 ISelection (org.eclipse.jface.viewers.ISelection)62 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)60 IResource (org.eclipse.core.resources.IResource)59 IEditorReference (org.eclipse.ui.IEditorReference)53 IViewPart (org.eclipse.ui.IViewPart)53 IOException (java.io.IOException)42 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)41 Point (org.eclipse.swt.graphics.Point)40 IWorkbench (org.eclipse.ui.IWorkbench)40 Path (org.eclipse.core.runtime.Path)39 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)39