Search in sources :

Example 1 with GlobalURIEditorOpener

use of org.eclipse.xtext.ui.editor.GlobalURIEditorOpener in project AGREE by loonwerks.

the class GenericPropertySection method openSource.

private void openSource(final Object obj) {
    final EObject boEObj = (EObject) obj;
    final URI uri = Objects.requireNonNull(EcoreUtil.getURI(boEObj), "Unable to get URI for business object");
    if (!(boEObj.eResource() instanceof XtextResource)) {
        throw new RuntimeException("The resource of the business object resource is not an XtextResource");
    }
    final XtextResource res = (XtextResource) boEObj.eResource();
    final GlobalURIEditorOpener opener = Objects.requireNonNull(res.getResourceServiceProvider().get(GlobalURIEditorOpener.class), "unable to get global URI Editor opener");
    opener.open(uri, true);
}
Also used : GlobalURIEditorOpener(org.eclipse.xtext.ui.editor.GlobalURIEditorOpener) EObject(org.eclipse.emf.ecore.EObject) XtextResource(org.eclipse.xtext.resource.XtextResource) URI(org.eclipse.emf.common.util.URI)

Example 2 with GlobalURIEditorOpener

use of org.eclipse.xtext.ui.editor.GlobalURIEditorOpener in project osate2 by osate.

the class GoToAadlSourceHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
    if (!(activeEditor instanceof InternalDiagramEditor)) {
        throw new RuntimeException("Unexpected editor: " + activeEditor);
    }
    // Get diagram and selected BOCs
    final List<BusinessObjectContext> selectedBusinessObjectContexts = AgeHandlerUtil.getSelectedBusinessObjectContexts();
    if (selectedBusinessObjectContexts.size() == 0) {
        throw new RuntimeException("No element selected");
    }
    final Object selectedBo = selectedBusinessObjectContexts.get(0).getBusinessObject();
    final EObject boEObj = getEObject(selectedBo);
    if (boEObj == null) {
        throw new RuntimeException("Unsupported type: " + selectedBo);
    }
    final URI uri = Objects.requireNonNull(EcoreUtil.getURI(boEObj), "Unable to get URI for business object");
    if (!(boEObj.eResource() instanceof XtextResource)) {
        throw new RuntimeException("The resource of the loaded business object resource is not an XtextResource");
    }
    final XtextResource res = (XtextResource) boEObj.eResource();
    final GlobalURIEditorOpener opener = Objects.requireNonNull((GlobalURIEditorOpener) res.getResourceServiceProvider().get(GlobalURIEditorOpener.class), "unable to get global URI Editor opener");
    opener.open(uri, true);
    return true;
}
Also used : InternalDiagramEditor(org.osate.ge.internal.ui.editor.InternalDiagramEditor) GlobalURIEditorOpener(org.eclipse.xtext.ui.editor.GlobalURIEditorOpener) EObject(org.eclipse.emf.ecore.EObject) EObject(org.eclipse.emf.ecore.EObject) XtextResource(org.eclipse.xtext.resource.XtextResource) IEditorPart(org.eclipse.ui.IEditorPart) BusinessObjectContext(org.osate.ge.BusinessObjectContext) URI(org.eclipse.emf.common.util.URI)

Example 3 with GlobalURIEditorOpener

use of org.eclipse.xtext.ui.editor.GlobalURIEditorOpener in project AGREE by loonwerks.

the class AgreeUtils method getGlobalURIEditorOpener.

public static GlobalURIEditorOpener getGlobalURIEditorOpener() {
    if (globalURIEditorOpener == null) {
        AgreeActivator activator = AgreeActivator.getInstance();
        String language = AgreeActivator.COM_ROCKWELLCOLLINS_ATC_AGREE_AGREE;
        Injector injector = activator.getInjector(language);
        globalURIEditorOpener = injector.getInstance(GlobalURIEditorOpener.class);
    }
    return globalURIEditorOpener;
}
Also used : AgreeActivator(com.rockwellcollins.atc.agree.ui.internal.AgreeActivator) GlobalURIEditorOpener(org.eclipse.xtext.ui.editor.GlobalURIEditorOpener) Injector(com.google.inject.Injector)

Aggregations

GlobalURIEditorOpener (org.eclipse.xtext.ui.editor.GlobalURIEditorOpener)3 URI (org.eclipse.emf.common.util.URI)2 EObject (org.eclipse.emf.ecore.EObject)2 XtextResource (org.eclipse.xtext.resource.XtextResource)2 Injector (com.google.inject.Injector)1 AgreeActivator (com.rockwellcollins.atc.agree.ui.internal.AgreeActivator)1 IEditorPart (org.eclipse.ui.IEditorPart)1 BusinessObjectContext (org.osate.ge.BusinessObjectContext)1 InternalDiagramEditor (org.osate.ge.internal.ui.editor.InternalDiagramEditor)1