Search in sources :

Example 11 with ExtensionRegistryService

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;
        });
    }
}
Also used : InternalDiagramEditor(org.osate.ge.internal.ui.editor.InternalDiagramEditor) DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) AgeDiagram(org.osate.ge.internal.diagram.runtime.AgeDiagram) ReferenceBuilderService(org.osate.ge.services.ReferenceBuilderService) ExtensionRegistryService(org.osate.ge.internal.services.ExtensionRegistryService) DiagramUpdater(org.osate.ge.internal.diagram.runtime.updating.DiagramUpdater) IEditorPart(org.eclipse.ui.IEditorPart)

Example 12 with ExtensionRegistryService

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;
}
Also used : Bundle(org.osgi.framework.Bundle) ExtensionRegistryService(org.osate.ge.internal.services.ExtensionRegistryService)

Aggregations

ExtensionRegistryService (org.osate.ge.internal.services.ExtensionRegistryService)12 AgeDiagram (org.osate.ge.internal.diagram.runtime.AgeDiagram)8 IEditorPart (org.eclipse.ui.IEditorPart)7 Bundle (org.osgi.framework.Bundle)7 InternalDiagramEditor (org.osate.ge.internal.ui.editor.InternalDiagramEditor)6 DiagramElement (org.osate.ge.internal.diagram.runtime.DiagramElement)5 DiagramUpdater (org.osate.ge.internal.diagram.runtime.updating.DiagramUpdater)5 List (java.util.List)3 Objects (java.util.Objects)3 AbstractHandler (org.eclipse.core.commands.AbstractHandler)3 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)3 ExecutionException (org.eclipse.core.commands.ExecutionException)3 HandlerUtil (org.eclipse.ui.handlers.HandlerUtil)3 LayoutInfoProvider (org.osate.ge.internal.diagram.runtime.layout.LayoutInfoProvider)3 ProjectProvider (org.osate.ge.internal.services.ProjectProvider)3 ProjectReferenceService (org.osate.ge.internal.services.ProjectReferenceService)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 LinkedList (java.util.LinkedList)2