use of org.eclipse.xtext.ui.editor.XtextReadonlyEditorInput in project dsl-devkit by dsldevkit.
the class PlatformPluginAwareEditorOpener method open.
/**
* If a platform plugin URI is given, a read-only Xtext editor is opened and returned. {@inheritDoc}
*
* @see {@link org.eclipse.emf.common.util.URI#isPlatformPlugin()}
*/
@Override
public IEditorPart open(final URI uri, final EReference crossReference, final int indexInList, final boolean select) {
IEditorPart result = super.open(uri, crossReference, indexInList, select);
if (result == null && (uri.isPlatformPlugin() || OSGI_RESOURCE_URL_PROTOCOL.equals(uri.scheme()))) {
final IModelLocation modelLocation = getModelLocation(uri.trimFragment());
if (modelLocation != null) {
PlatformPluginStorage storage = new PlatformPluginStorage(modelLocation);
IEditorInput editorInput = new XtextReadonlyEditorInput(storage);
IWorkbenchPage activePage = workbench.getActiveWorkbenchWindow().getActivePage();
try {
IEditorPart editor = IDE.openEditor(activePage, editorInput, editorID);
selectAndReveal(editor, uri, crossReference, indexInList, select);
return EditorUtils.getXtextEditor(editor);
} catch (WrappedException e) {
// $NON-NLS-1$ //$NON-NLS-2$
LOG.error("Error while opening editor part for EMF URI '" + uri + "'", e.getCause());
} catch (PartInitException partInitException) {
// $NON-NLS-1$ //$NON-NLS-2$
LOG.error("Error while opening editor part for EMF URI '" + uri + "'", partInitException);
}
}
}
return result;
}
use of org.eclipse.xtext.ui.editor.XtextReadonlyEditorInput in project dsl-devkit by dsldevkit.
the class CheckHyperlinkHelper method createHyperlinksByOffset.
@Override
public void createHyperlinksByOffset(final XtextResource resource, final int offset, final IHyperlinkAcceptor acceptor) {
IEditorPart activeEditor = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (activeEditor.getEditorInput() instanceof XtextReadonlyEditorInput) {
INode crossRefNode = eObjectAtOffsetHelper.getCrossReferenceNode(resource, new TextRegion(offset, 0));
if (crossRefNode == null) {
return;
}
EObject crossLinkedEObject = eObjectAtOffsetHelper.getCrossReferencedElement(crossRefNode);
if (crossLinkedEObject != null && crossLinkedEObject.eClass().getEPackage() != CheckPackage.eINSTANCE) {
return;
}
// if EPackage of referenced object is CheckPackage, try to provide hyperlinks: works for included catalogs
}
super.createHyperlinksByOffset(resource, offset, acceptor);
}
use of org.eclipse.xtext.ui.editor.XtextReadonlyEditorInput in project xtext-eclipse by eclipse.
the class JavaClassPathResourceForIEditorInputFactoryTest method testBug463258_03b.
@Test(expected = CoreException.class)
public void testBug463258_03b() throws Throwable {
IJavaProject project = createJavaProject("foo");
IFile file = project.getProject().getFile("foo.jar");
file.create(jarInputStream(new TextFile("foo/bar.testlanguage", "//empty")), true, monitor());
IPackageFragmentRoot root = JarPackageFragmentRootTestUtil.getJarPackageFragmentRoot(file, (JavaProject) project);
IPackageFragment foo = root.getPackageFragment("foo");
JarEntryFile fileInJar = new JarEntryFile("bar.testlanguage");
fileInJar.setParent(foo);
File jarFile = file.getLocation().toFile();
assertTrue("exists", jarFile.exists());
assertTrue("delete", jarFile.delete());
XtextReadonlyEditorInput editorInput = new XtextReadonlyEditorInput(fileInJar);
try {
factory.createResource(editorInput);
} catch (WrappedException e) {
throw e.getCause();
}
}
use of org.eclipse.xtext.ui.editor.XtextReadonlyEditorInput in project xtext-eclipse by eclipse.
the class JavaClassPathResourceForIEditorInputFactoryTest method testBug463258_01.
@Test
public void testBug463258_01() throws Exception {
IJavaProject project = createJavaProject("foo");
IFile file = project.getProject().getFile("foo.jar");
file.create(jarInputStream(new TextFile("foo/A.testlanguage", "//empty")), true, monitor());
addJarToClasspath(project, file);
IPackageFragmentRoot root = project.getPackageFragmentRoot(file);
IPackageFragment foo = root.getPackageFragment("foo");
JarEntryFile fileInJar = new JarEntryFile("A.testlanguage");
fileInJar.setParent(foo);
XtextReadonlyEditorInput editorInput = new XtextReadonlyEditorInput(fileInJar);
Resource resource = factory.createResource(editorInput);
assertNotNull(resource);
resource.load(null);
}
Aggregations