Search in sources :

Example 1 with IModelLocation

use of com.avaloq.tools.ddk.check.runtime.configuration.IModelLocation 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;
}
Also used : XtextReadonlyEditorInput(org.eclipse.xtext.ui.editor.XtextReadonlyEditorInput) WrappedException(org.eclipse.emf.common.util.WrappedException) IModelLocation(com.avaloq.tools.ddk.check.runtime.configuration.IModelLocation) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 2 with IModelLocation

use of com.avaloq.tools.ddk.check.runtime.configuration.IModelLocation in project dsl-devkit by dsldevkit.

the class CatalogFromExtensionPointScopeHelper method createExtensionScope.

/**
 * Creates an extension scope for each registered check catalog.
 *
 * @param parent
 *          the parent scope
 * @param context
 *          the context object
 * @return the check catalog scope
 */
public IScope createExtensionScope(final IScope parent, final Resource context) {
    IScope result = parent;
    NavigableSet<IModelLocation> locations = ICheckCatalogRegistry.INSTANCE.getAllCheckModelLocations();
    for (IModelLocation locationData : locations.descendingSet()) {
        // The UI proposes parent scope contents after each scope in the chain, so this scope chain must be created in reverse.
        result = new CatalogFromExtensionPointScope(result, locationData, (XtextResourceSet) context.getResourceSet());
    }
    return result;
}
Also used : IModelLocation(com.avaloq.tools.ddk.check.runtime.configuration.IModelLocation) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) IScope(org.eclipse.xtext.scoping.IScope)

Aggregations

IModelLocation (com.avaloq.tools.ddk.check.runtime.configuration.IModelLocation)2 WrappedException (org.eclipse.emf.common.util.WrappedException)1 IEditorInput (org.eclipse.ui.IEditorInput)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 PartInitException (org.eclipse.ui.PartInitException)1 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)1 IScope (org.eclipse.xtext.scoping.IScope)1 XtextReadonlyEditorInput (org.eclipse.xtext.ui.editor.XtextReadonlyEditorInput)1