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);
}
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;
}
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;
}
Aggregations