Search in sources :

Example 6 with BusinessObjectContext

use of org.osate.ge.BusinessObjectContext in project osate2 by osate.

the class GoToImplementationDiagramHandler 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 bo = selectedBusinessObjectContexts.get(0).getBusinessObject();
    final DiagramService diagramService = Objects.requireNonNull(Adapters.adapt(activeEditor, DiagramService.class), "Unable to retrieve diagram service");
    final ComponentImplementation ci = Objects.requireNonNull(getComponentImplementation(bo), "Unable to retrieve component implementation");
    diagramService.openOrCreateDiagramForBusinessObject(ci);
    return null;
}
Also used : InternalDiagramEditor(org.osate.ge.internal.ui.editor.InternalDiagramEditor) ComponentImplementation(org.osate.aadl2.ComponentImplementation) IEditorPart(org.eclipse.ui.IEditorPart) DiagramService(org.osate.ge.internal.services.DiagramService) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 7 with BusinessObjectContext

use of org.osate.ge.BusinessObjectContext in project osate2 by osate.

the class GoToPackageDiagramHandler 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 bo = selectedBusinessObjectContexts.get(0).getBusinessObject();
    final DiagramService diagramService = Objects.requireNonNull(Adapters.adapt(activeEditor, DiagramService.class), "Unable to retrieve diagram service");
    final AadlPackage pkg = Objects.requireNonNull(getPackage(bo), "Unable to retrieve package");
    diagramService.openOrCreateDiagramForBusinessObject(pkg);
    return null;
}
Also used : InternalDiagramEditor(org.osate.ge.internal.ui.editor.InternalDiagramEditor) AadlPackage(org.osate.aadl2.AadlPackage) IEditorPart(org.eclipse.ui.IEditorPart) DiagramService(org.osate.ge.internal.services.DiagramService) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 8 with BusinessObjectContext

use of org.osate.ge.BusinessObjectContext in project osate2 by osate.

the class OpenAssociatedDiagramHandler method setEnabled.

@Override
public void setEnabled(final Object evaluationContext) {
    boolean enabled = false;
    final List<BusinessObjectContext> selectedBusinessObjectContexts = AgeHandlerUtil.getSelectedBusinessObjectContexts();
    if (selectedBusinessObjectContexts.size() == 1) {
        final BusinessObjectContext selectedBusinessObjectContext = selectedBusinessObjectContexts.get(0);
        final Object bo = selectedBusinessObjectContext.getBusinessObject();
        enabled = (bo instanceof AadlPackage || bo instanceof Classifier || (bo instanceof Subcomponent && AadlSubcomponentUtil.getComponentClassifier(selectedBusinessObjectContext, (Subcomponent) bo) != null)) && ProjectUtil.getProjectForBo(bo).isPresent();
    }
    setBaseEnabled(enabled);
}
Also used : AadlPackage(org.osate.aadl2.AadlPackage) Subcomponent(org.osate.aadl2.Subcomponent) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 9 with BusinessObjectContext

use of org.osate.ge.BusinessObjectContext in project osate2 by osate.

the class OpenAssociatedDiagramHandler 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 BusinessObjectContext selectedBusinessObjectContext = selectedBusinessObjectContexts.get(0);
    final Object bo = selectedBusinessObjectContext.getBusinessObject();
    final DiagramService diagramService = Objects.requireNonNull(Adapters.adapt(activeEditor, DiagramService.class), "Unable to retrieve diagram service");
    if (bo instanceof AadlPackage || bo instanceof Classifier) {
        diagramService.openOrCreateDiagramForBusinessObject(bo);
    } else if (bo instanceof Subcomponent) {
        final ComponentClassifier cc = AadlSubcomponentUtil.getComponentClassifier(selectedBusinessObjectContext, (Subcomponent) bo);
        if (cc != null) {
            diagramService.openOrCreateDiagramForBusinessObject(cc);
        }
    }
    return null;
}
Also used : InternalDiagramEditor(org.osate.ge.internal.ui.editor.InternalDiagramEditor) ComponentClassifier(org.osate.aadl2.ComponentClassifier) AadlPackage(org.osate.aadl2.AadlPackage) Subcomponent(org.osate.aadl2.Subcomponent) IEditorPart(org.eclipse.ui.IEditorPart) DiagramService(org.osate.ge.internal.services.DiagramService) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 10 with BusinessObjectContext

use of org.osate.ge.BusinessObjectContext in project osate2 by osate.

the class ShowElementsInModeHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final InternalDiagramEditor editor = getDiagramEditor(event);
    referenceService = Objects.requireNonNull(Adapters.adapt(editor, ProjectReferenceService.class), "Unable to retrieve reference service");
    final ExtensionRegistryService extService = Objects.requireNonNull(Adapters.adapt(editor, ExtensionRegistryService.class), "Unable to retrieve extension service");
    final BusinessObjectProviderHelper bopHelper = new BusinessObjectProviderHelper(extService);
    final BusinessObjectTreeUpdater boTreeUpdater = editor.getBoTreeUpdater();
    final BusinessObjectNode boTree = getBoTree(editor, boTreeUpdater);
    final List<BusinessObjectContext> selectedModes = AgeHandlerUtil.getSelectedBusinessObjectContexts().stream().filter(de -> isModal(de.getBusinessObject())).collect(Collectors.toList());
    for (final BusinessObjectContext selectedMode : selectedModes) {
        enableInModeNodes(bopHelper, boTree, selectedMode);
    }
    final AgeDiagram diagram = editor.getDiagram();
    final DiagramUpdater diagramUpdater = editor.getDiagramUpdater();
    final LayoutInfoProvider layoutInfoProvider = Objects.requireNonNull(Adapters.adapt(editor, LayoutInfoProvider.class), "Unable to retrieve layout info provider");
    editor.getActionExecutor().execute("Show Elements In Mode", ExecutionMode.NORMAL, () -> {
        // Update the diagram
        diagramUpdater.updateDiagram(diagram, boTree);
        // Update layout
        diagram.modify("Layout Incrementally", m -> DiagramElementLayoutUtil.layoutIncrementally(diagram, m, layoutInfoProvider));
        return null;
    });
    return null;
}
Also used : InternalDiagramEditor(org.osate.ge.internal.ui.editor.InternalDiagramEditor) BusinessObjectNode(org.osate.ge.internal.diagram.runtime.updating.BusinessObjectNode) ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) ModalElement(org.osate.aadl2.ModalElement) DiagramToBusinessObjectTreeConverter(org.osate.ge.internal.diagram.runtime.updating.DiagramToBusinessObjectTreeConverter) ProjectReferenceService(org.osate.ge.internal.services.ProjectReferenceService) ExtensionRegistryService(org.osate.ge.internal.services.ExtensionRegistryService) DiagramElementLayoutUtil(org.osate.ge.internal.diagram.runtime.layout.DiagramElementLayoutUtil) BusinessObjectNode(org.osate.ge.internal.diagram.runtime.updating.BusinessObjectNode) HandlerUtil(org.eclipse.ui.handlers.HandlerUtil) InternalDiagramEditor(org.osate.ge.internal.ui.editor.InternalDiagramEditor) BusinessObjectContext(org.osate.ge.BusinessObjectContext) ModeTransition(org.osate.aadl2.ModeTransition) LinkedList(java.util.LinkedList) RelativeBusinessObjectReference(org.osate.ge.RelativeBusinessObjectReference) Completeness(org.osate.ge.internal.diagram.runtime.updating.Completeness) IEditorPart(org.eclipse.ui.IEditorPart) BusinessObjectTreeUpdater(org.osate.ge.internal.diagram.runtime.updating.BusinessObjectTreeUpdater) FeatureGroup(org.osate.aadl2.FeatureGroup) DiagramUpdater(org.osate.ge.internal.diagram.runtime.updating.DiagramUpdater) AadlInstanceObjectUtil(org.osate.ge.aadl2.internal.util.AadlInstanceObjectUtil) ModeFeature(org.osate.aadl2.ModeFeature) UUID(java.util.UUID) ExecutionException(org.eclipse.core.commands.ExecutionException) Collectors(java.util.stream.Collectors) ModeTransitionInstance(org.osate.aadl2.instance.ModeTransitionInstance) Objects(java.util.Objects) Adapters(org.eclipse.core.runtime.Adapters) Mode(org.osate.aadl2.Mode) AgeDiagram(org.osate.ge.internal.diagram.runtime.AgeDiagram) List(java.util.List) ModeInstance(org.osate.aadl2.instance.ModeInstance) ExecutionMode(org.osate.ge.internal.services.ActionExecutor.ExecutionMode) AgeHandlerUtil(org.osate.ge.internal.ui.handlers.AgeHandlerUtil) AadlModalElementUtil(org.osate.ge.aadl2.internal.util.AadlModalElementUtil) BusinessObjectProviderHelper(org.osate.ge.internal.util.BusinessObjectProviderHelper) Queue(java.util.Queue) AbstractHandler(org.eclipse.core.commands.AbstractHandler) NamedElement(org.osate.aadl2.NamedElement) LayoutInfoProvider(org.osate.ge.internal.diagram.runtime.layout.LayoutInfoProvider) Collections(java.util.Collections) InstanceObject(org.osate.aadl2.instance.InstanceObject) BusinessObjectTreeUpdater(org.osate.ge.internal.diagram.runtime.updating.BusinessObjectTreeUpdater) AgeDiagram(org.osate.ge.internal.diagram.runtime.AgeDiagram) ExtensionRegistryService(org.osate.ge.internal.services.ExtensionRegistryService) DiagramUpdater(org.osate.ge.internal.diagram.runtime.updating.DiagramUpdater) BusinessObjectProviderHelper(org.osate.ge.internal.util.BusinessObjectProviderHelper) BusinessObjectContext(org.osate.ge.BusinessObjectContext) LayoutInfoProvider(org.osate.ge.internal.diagram.runtime.layout.LayoutInfoProvider)

Aggregations

BusinessObjectContext (org.osate.ge.BusinessObjectContext)104 List (java.util.List)26 Optional (java.util.Optional)22 NamedElement (org.osate.aadl2.NamedElement)20 Subcomponent (org.osate.aadl2.Subcomponent)20 QueryService (org.osate.ge.services.QueryService)19 Collectors (java.util.stream.Collectors)18 Objects (java.util.Objects)17 EObject (org.eclipse.emf.ecore.EObject)17 DiagramElement (org.osate.ge.internal.diagram.runtime.DiagramElement)16 InternalDiagramEditor (org.osate.ge.internal.ui.editor.InternalDiagramEditor)16 Collections (java.util.Collections)15 ComponentImplementation (org.osate.aadl2.ComponentImplementation)15 ArrayList (java.util.ArrayList)14 IEditorPart (org.eclipse.ui.IEditorPart)14 ComponentClassifier (org.osate.aadl2.ComponentClassifier)12 InstanceObject (org.osate.aadl2.instance.InstanceObject)12 Adapters (org.eclipse.core.runtime.Adapters)11 AgeDiagram (org.osate.ge.internal.diagram.runtime.AgeDiagram)10 RelativeBusinessObjectReference (org.osate.ge.RelativeBusinessObjectReference)8