use of org.osate.ge.internal.services.ExtensionRegistryService in project osate2 by osate.
the class ShowContentsUtil method addContentsToSelectedElements.
/**
* Adds contents to the selected diagram elements. Adds all children which pass the specified filter.
* @param event is the ExecutionEvent of the handler which provides the active editor.
* @param filters determines the filters to apply to the selected elements.
*/
public static void addContentsToSelectedElements(final ExecutionEvent event, final Function<DiagramElement, ImmutableSet<ContentFilter>> filters) {
final IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
if (!(activeEditor instanceof InternalDiagramEditor)) {
throw new RuntimeException("Unexpected editor: " + activeEditor);
}
final InternalDiagramEditor diagramEditor = (InternalDiagramEditor) activeEditor;
final ExtensionRegistryService extService = Objects.requireNonNull(Adapters.adapt(diagramEditor, ExtensionRegistryService.class), "Unable to retrieve extension service");
final List<DiagramElement> selectedDiagramElements = AgeHandlerUtil.getSelectedDiagramElements();
final AgeDiagram diagram = diagramEditor.getDiagram();
if (diagram == null) {
throw new RuntimeException("Unable to retrieve diagram");
}
final DiagramUpdater diagramUpdater = Objects.requireNonNull(diagramEditor.getDiagramUpdater(), "Unable to retrieve diagram updater");
final ReferenceBuilderService referenceBuilder = Objects.requireNonNull(Adapters.adapt(diagramEditor, ReferenceBuilderService.class), "Unable to retrieve reference builder service");
if (addChildrenDuringNextUpdate(selectedDiagramElements, diagramUpdater, extService, referenceBuilder, filters)) {
diagramEditor.getActionExecutor().execute("Show Contents", ExecutionMode.NORMAL, () -> {
diagramEditor.updateDiagram();
return null;
});
}
}
use of org.osate.ge.internal.services.ExtensionRegistryService in project osate2 by osate.
the class ShowDefaultContentsHandler method getContentFilterProvider.
private ContentFilterProvider getContentFilterProvider() {
final Bundle bundle = FrameworkUtil.getBundle(getClass());
final ExtensionRegistryService extService = Objects.requireNonNull(EclipseContextFactory.getServiceContext(bundle.getBundleContext()).get(ExtensionRegistryService.class), "Unable to retrieve extension registry");
return extService;
}
Aggregations