From 552ede3b4bf9c756fae174e43765d1357f2ee144 Mon Sep 17 00:00:00 2001 From: Axel RICHARD Date: Wed, 3 Jun 2026 12:53:39 +0200 Subject: [PATCH] [enh] Move view tool services to service architecture Signed-off-by: Axel RICHARD --- CHANGELOG.adoc | 3 +- .../org/eclipse/syson/JavaServiceTests.java | 8 +- .../services/DiagramMutationToolService.java | 384 ++++++++ .../services/DiagramQueryToolService.java | 187 ++++ .../aql/DiagramMutationAQLService.java | 95 +- .../services/aql/DiagramQueryAQLService.java | 91 +- .../DiagramMutationToolServiceTest.java} | 23 +- .../TreeQuerySelectionDialogService.java | 442 +++++++++ .../services/aql/TreeQueryAQLService.java | 216 +++- ...tionOwnedUsageEdgeDescriptionProvider.java | 3 +- ...ageNestedUsageEdgeDescriptionProvider.java | 3 +- .../AnnotationEdgeDescriptionProvider.java | 4 +- .../view/services/ViewEdgeToolService.java | 6 +- .../common/view/services/ViewToolService.java | 925 ------------------ .../description/ToolDescriptionService.java | 6 +- .../ActorCompartmentNodeToolProvider.java | 6 +- .../AssumeConstraintNodeToolProvider.java | 9 +- .../tools/DecisionActionNodeToolProvider.java | 6 +- .../tools/DoneActionNodeToolProvider.java | 6 +- .../tools/ExhibitStateNodeToolProvider.java | 6 +- .../view/tools/FlowNodeToolProvider.java | 6 +- .../tools/ForkActionNodeToolProvider.java | 6 +- .../tools/FramedConcernNodeToolProvider.java | 6 +- .../tools/JoinActionNodeToolProvider.java | 6 +- .../tools/MergeActionNodeToolProvider.java | 6 +- .../NamespaceImportNodeToolProvider.java | 6 +- ...equirementCompartmentNodeToolProvider.java | 6 +- ...currenceUsageSnapshotNodeToolProvider.java | 4 +- ...urrenceUsageTimesliceNodeToolProvider.java | 4 +- .../tools/PerformActionNodeToolProvider.java | 6 +- .../RequireConstraintNodeToolProvider.java | 9 +- .../view/tools/SatisfyNodeToolProvider.java | 6 +- .../SatisfyRequirementNodeToolProvider.java | 6 +- ...akeholdersCompartmentNodeToolProvider.java | 6 +- .../tools/StartActionNodeToolProvider.java | 6 +- .../tools/StateSubactionNodeToolProvider.java | 6 +- .../SubjectCompartmentNodeToolProvider.java | 6 +- .../syson-standard-diagrams-view/pom.xml | 4 + .../ActionFlowViewJavaServiceProvider.java | 6 +- ...nterconnectionViewJavaServiceProvider.java | 6 +- .../diagrams/view/SDVJavaServiceProvider.java | 6 +- ...tateTransitionViewJavaServiceProvider.java | 6 +- .../NestedActorEdgeDescriptionProvider.java | 6 +- ...tedStakeholderEdgeDescriptionProvider.java | 4 +- .../NestedSubjectEdgeDescriptionProvider.java | 4 +- scripts/check-coverage.jsh | 6 +- 46 files changed, 1486 insertions(+), 1092 deletions(-) create mode 100644 backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/DiagramMutationToolService.java create mode 100644 backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/DiagramQueryToolService.java rename backend/{views/syson-diagram-common-view/src/test/java/org/eclipse/syson/diagram/common/view/services/ViewToolServiceTest.java => services/syson-diagram-services/src/test/java/org/eclipse/syson/diagram/services/DiagramMutationToolServiceTest.java} (89%) create mode 100644 backend/services/syson-tree-services/src/main/java/org/eclipse/syson/tree/services/TreeQuerySelectionDialogService.java delete mode 100644 backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewToolService.java diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 91c0cdbde..72282acab 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -8,6 +8,8 @@ === Breaking changes +- [services] As part of the migration to the new diagram service architecture, the methods that were exposed by `ViewToolService` (which has been deleted) are now split between `org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService` for mutation services, `org.eclipse.syson.diagram.services.aql.DiagramQueryAQLService` for diagram query and tool precondition services, and `org.eclipse.syson.tree.services.aql.TreeQueryAQLService` for selection dialog tree query services. + === Dependency update === Bug fixes @@ -17,7 +19,6 @@ === New features - https://github.com/eclipse-syson/syson/issues/2316[#2316] [diagrams] Add support for list item inheritance in _perform actions_ compartments -s == v2026.7.0 diff --git a/backend/application/syson-application/src/test/java/org/eclipse/syson/JavaServiceTests.java b/backend/application/syson-application/src/test/java/org/eclipse/syson/JavaServiceTests.java index fd724b44e..0aed68425 100644 --- a/backend/application/syson-application/src/test/java/org/eclipse/syson/JavaServiceTests.java +++ b/backend/application/syson-application/src/test/java/org/eclipse/syson/JavaServiceTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024, 2025 Obeo. + * Copyright (c) 2024, 2026 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -30,6 +30,8 @@ import org.eclipse.syson.services.UtilService; import org.eclipse.syson.standard.diagrams.view.SDVDiagramDescriptionProvider; import org.eclipse.syson.standard.diagrams.view.SDVJavaServiceProvider; +import org.eclipse.syson.tree.explorer.view.SysONExplorerJavaServiceProvider; +import org.eclipse.syson.tree.explorer.view.SysONExplorerTreeDescriptionProvider; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -55,8 +57,10 @@ public void setUp() { RepresentationDescription description = provider.create(colorProvider); this.view.getDescriptions().add(description); }); + var sysONExplorerTreeView = new SysONExplorerTreeDescriptionProvider().createView(); + this.view.getDescriptions().addAll(sysONExplorerTreeView.getDescriptions()); - List javaServiceProviders = List.of(new SDVJavaServiceProvider()); + List javaServiceProviders = List.of(new SDVJavaServiceProvider(), new SysONExplorerJavaServiceProvider()); this.serviceClasses = javaServiceProviders.stream() .flatMap(provider -> provider.getServiceClasses(this.view).stream()) .collect(Collectors.toSet()); diff --git a/backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/DiagramMutationToolService.java b/backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/DiagramMutationToolService.java new file mode 100644 index 000000000..a66fa28da --- /dev/null +++ b/backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/DiagramMutationToolService.java @@ -0,0 +1,384 @@ +/******************************************************************************* + * Copyright (c) 2026 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.syson.diagram.services; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.sirius.components.core.api.IFeedbackMessageService; +import org.eclipse.sirius.components.core.api.ILabelService; +import org.eclipse.sirius.components.core.api.labels.StyledString; +import org.eclipse.sirius.components.representations.Message; +import org.eclipse.sirius.components.representations.MessageLevel; +import org.eclipse.syson.services.DeleteService; +import org.eclipse.syson.services.UtilService; +import org.eclipse.syson.services.api.ISysMLMoveElementService; +import org.eclipse.syson.services.api.MoveStatus; +import org.eclipse.syson.sysml.ActorMembership; +import org.eclipse.syson.sysml.CaseDefinition; +import org.eclipse.syson.sysml.CaseUsage; +import org.eclipse.syson.sysml.Comment; +import org.eclipse.syson.sysml.Documentation; +import org.eclipse.syson.sysml.Element; +import org.eclipse.syson.sysml.FeatureMembership; +import org.eclipse.syson.sysml.ObjectiveMembership; +import org.eclipse.syson.sysml.OwningMembership; +import org.eclipse.syson.sysml.Package; +import org.eclipse.syson.sysml.RequirementDefinition; +import org.eclipse.syson.sysml.RequirementUsage; +import org.eclipse.syson.sysml.StakeholderMembership; +import org.eclipse.syson.sysml.SubjectMembership; +import org.eclipse.syson.sysml.SysmlFactory; +import org.eclipse.syson.sysml.Usage; +import org.eclipse.syson.sysml.UseCaseDefinition; +import org.eclipse.syson.sysml.UseCaseUsage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +/** + * Tool-related services doing mutations in diagrams and models. + * + * @author arichard + */ +@Service +public class DiagramMutationToolService { + + private final IFeedbackMessageService feedbackMessageService; + + private final ISysMLMoveElementService moveService; + + private final ILabelService labelService; + + private final DeleteService deleteService; + + private final UtilService utilService; + + private final Logger logger = LoggerFactory.getLogger(DiagramMutationToolService.class); + + /** + * Creates a new tool mutation service. + * + * @param feedbackMessageService + * the service used to report user-facing feedback messages + * @param moveService + * the service used to move SysML semantic elements + * @param labelService + * the service used to compute element labels in feedback messages + */ + public DiagramMutationToolService(IFeedbackMessageService feedbackMessageService, ISysMLMoveElementService moveService, ILabelService labelService) { + this.feedbackMessageService = Objects.requireNonNull(feedbackMessageService); + this.moveService = Objects.requireNonNull(moveService); + this.labelService = Objects.requireNonNull(labelService); + this.deleteService = new DeleteService(); + this.utilService = new UtilService(); + } + + /** + * Moves the given usage under the new container and marks it as composite when the move succeeds. + * + * @param usage + * the usage to move + * @param newContainer + * the new semantic container + * @return the moved usage + */ + public Usage becomeNestedUsage(Usage usage, Element newContainer) { + if (this.getOwnerHierarchy(newContainer).contains(usage) || Objects.equals(newContainer, usage)) { + String message = MessageFormat.format("Cannot change the owner of {0}, this would create a containment cycle", String.valueOf(usage.getName())); + this.feedbackMessageService.addFeedbackMessage(new Message(message, MessageLevel.WARNING)); + this.logger.warn(message); + } else { + MoveStatus moveStatus = this.moveService.moveSemanticElement(usage, newContainer); + if (moveStatus.isSuccess()) { + usage.setIsComposite(true); + } else { + this.feedbackMessageService.addFeedbackMessage(new Message(MessageFormat.format("Unable to move {0} in {1}: {2}", this.getLabel(usage), this.getLabel(newContainer), moveStatus.message()), MessageLevel.WARNING)); + } + + } + return usage; + } + + /** + * Moves the requirement into an objective membership owned by the new container when possible. + * + * @param requirement + * the requirement to use as objective + * @param newContainer + * the target use case element + * @return the requirement + */ + public RequirementUsage becomeObjectiveRequirement(RequirementUsage requirement, Element newContainer) { + if (newContainer instanceof UseCaseUsage || newContainer instanceof UseCaseDefinition) { + if (this.utilService.isEmptyObjectiveRequirement(newContainer)) { + var eContainer = requirement.eContainer(); + if (eContainer instanceof ObjectiveMembership objectiveMembership) { + newContainer.getOwnedRelationship().add(objectiveMembership); + } else if (eContainer instanceof OwningMembership owningMembership) { + var newObjectiveMembership = SysmlFactory.eINSTANCE.createObjectiveMembership(); + newObjectiveMembership.getOwnedRelatedElement().add(requirement); + newContainer.getOwnedRelationship().add(newObjectiveMembership); + this.deleteService.deleteFromModel(owningMembership); + } + } + } + return requirement; + } + + /** + * Reconnects the source of a nested actor edge. + * + * @param self + * the current source semantic element + * @param newSource + * the new source semantic element + * @param otherEnd + * the actor connected by the edge + * @return the actor connected by the edge + */ + public Element reconnectSourceNestedActorEdge(Element self, Element newSource, Element otherEnd) { + if (newSource instanceof UseCaseUsage || newSource instanceof UseCaseDefinition + || newSource instanceof RequirementUsage || newSource instanceof RequirementDefinition) { + if (otherEnd.getOwningMembership() instanceof ActorMembership actorMembership) { + newSource.getOwnedRelationship().add(actorMembership); + } else { + // This is an error, an Actor should always be contained in an ActorMembership. + String errorMessage = "Cannot reconnect the Actor, it is not owned by an " + ActorMembership.class.getSimpleName(); + this.logger.error(errorMessage); + this.feedbackMessageService.addFeedbackMessage(new Message(errorMessage, MessageLevel.ERROR)); + } + } else { + String errorMessage = "Cannot reconnect an Actor to a non-UseCase, non-Requirement element"; + this.logger.warn(errorMessage); + this.feedbackMessageService.addFeedbackMessage(new Message(errorMessage, MessageLevel.WARNING)); + } + return otherEnd; + } + + /** + * Reconnects the source of a nested stakeholder edge. + * + * @param self + * the current source semantic element + * @param newSource + * the new requirement source + * @param otherEnd + * the stakeholder connected by the edge + * @return the stakeholder connected by the edge + */ + public Element reconnectSourceNestedStakeholderEdge(Element self, Element newSource, Element otherEnd) { + if (newSource instanceof RequirementUsage || newSource instanceof RequirementDefinition) { + if (otherEnd.getOwningMembership() instanceof StakeholderMembership stakeholderMembership) { + newSource.getOwnedRelationship().add(stakeholderMembership); + } else { + // This is an error, a Stakeholder should always be contained in a StakeholderMembership. + String errorMessage = "Cannot reconnect the Stakeholder, it is not owned by a " + StakeholderMembership.class.getSimpleName(); + this.logger.error(errorMessage); + this.feedbackMessageService.addFeedbackMessage(new Message(errorMessage, MessageLevel.ERROR)); + } + } else { + String errorMessage = "Cannot reconnect a Stakeholder to a non-Requirement element"; + this.logger.warn(errorMessage); + this.feedbackMessageService.addFeedbackMessage(new Message(errorMessage, MessageLevel.WARNING)); + } + return otherEnd; + } + + /** + * Reconnects the source of a nested subject edge. + * + * @param self + * the current source semantic element + * @param newSource + * the new case or requirement source + * @param otherEnd + * the subject connected by the edge + * @return the subject connected by the edge + */ + public Element reconnectSourceNestedSubjectEdge(Element self, Element newSource, Element otherEnd) { + if (newSource instanceof CaseUsage || newSource instanceof CaseDefinition + || newSource instanceof RequirementUsage || newSource instanceof RequirementDefinition) { + if (otherEnd.getOwningMembership() instanceof SubjectMembership subjectMembership) { + newSource.getOwnedRelationship().add(subjectMembership); + } else { + String errorMessage = "Cannot reconnect the Subject, it is not owned by a " + SubjectMembership.class.getSimpleName(); + this.logger.error(errorMessage); + this.feedbackMessageService.addFeedbackMessage(new Message(errorMessage, MessageLevel.ERROR)); + } + } else { + String errorMessage = "Cannot reconnect a Subject to a non-UseCase, non-Requirement element"; + this.logger.warn(errorMessage); + this.feedbackMessageService.addFeedbackMessage(new Message(errorMessage, MessageLevel.WARNING)); + } + return otherEnd; + } + + /** + * Reconnects the source of a composition edge by moving the other end under the new source. + * + * @param self + * the current semantic element + * @param newSource + * the new owner of the other end + * @param otherEnd + * the semantic element to move + * @return the moved semantic element + */ + public Element reconnnectSourceCompositionEdge(Element self, Element newSource, Element otherEnd) { + Element result = otherEnd; + if (this.getOwnerHierarchy(newSource).contains(otherEnd) || Objects.equals(newSource, otherEnd)) { + String message = MessageFormat.format("Cannot change the owner of {0}, this would create a containment cycle", String.valueOf(otherEnd.getName())); + this.feedbackMessageService.addFeedbackMessage(new Message(message, MessageLevel.WARNING)); + this.logger.warn(message); + } else { + MoveStatus moveStatus = this.moveService.moveSemanticElement(otherEnd, newSource); + if (!moveStatus.isSuccess()) { + this.feedbackMessageService.addFeedbackMessage(new Message(MessageFormat.format("Unable to move {0} in {1}: {2}", this.getLabel(self), this.getLabel(newSource), + moveStatus.message()), MessageLevel.WARNING)); + } + result = otherEnd; + } + return result; + } + + /** + * Reconnects the target of a composition edge by moving the old target to the closest containing package. + * + * @param self + * the semantic element used to find the closest package + * @param oldTarget + * the previous target + * @param newTarget + * the new target + * @param otherEnd + * the opposite edge end + * @return the semantic element used as context + */ + public Element reconnnectTargetCompositionEdge(Element self, Element oldTarget, Element newTarget, Element otherEnd) { + if (this.getOwnerHierarchy(otherEnd).contains(newTarget) || Objects.equals(otherEnd, newTarget)) { + String message = MessageFormat.format("Cannot change the owner of {0}, this would create a containment cycle", String.valueOf(otherEnd.getName())); + this.feedbackMessageService.addFeedbackMessage(new Message(message, MessageLevel.WARNING)); + this.logger.warn(message); + } else { + var oldContainer = oldTarget.eContainer(); + if (newTarget instanceof Usage && oldContainer instanceof FeatureMembership featureMembership) { + var pack = this.getClosestContainingPackageFrom(self); + if (pack != null) { + var owningMembership = SysmlFactory.eINSTANCE.createOwningMembership(); + pack.getOwnedRelationship().add(owningMembership); + owningMembership.getOwnedRelatedElement().add(oldTarget); + var oldMembership = newTarget.eContainer(); + featureMembership.getOwnedRelatedElement().add(newTarget); + if (oldMembership instanceof OwningMembership oldOwningMembership) { + this.deleteService.deleteFromModel(oldOwningMembership); + } + } + } + } + return self; + } + + /** + * Reconnects an annotating element to a new annotated target. + * + * @param self + * the annotating element + * @param newTarget + * the new annotated element + * @return the annotating element + */ + public Element reconnnectTargetAnnotatedEdge(Element self, Element newTarget) { + if (!(newTarget instanceof Comment) && !(newTarget instanceof Documentation)) { + MoveStatus moveStatus = this.moveService.moveSemanticElement(self, newTarget); + if (!moveStatus.isSuccess()) { + this.feedbackMessageService.addFeedbackMessage(new Message(MessageFormat.format("Unable to move {0} in {1}: {2}", this.getLabel(self), this.getLabel(newTarget), + moveStatus.message()), MessageLevel.WARNING)); + } + } + return self; + } + + /** + * Reconnects the target of a nested actor edge (the Actor side of the edge). This service is only used because edge + * preconditions are not taken into account. + * + * @param self + * the current UseCase or Requirement + * @return the given self + */ + public Element reconnectTargetNestedActorEdge(Element self) { + // due to https://github.com/eclipse-sirius/sirius-web/issues/2930 we cannot prevent the user to do the + // reconnect, + // so we just warn him/her that this is not possible. + String errorMessage = "An Actor cannot be disconnected from its UseCase or its Requirement element"; + this.logger.warn(errorMessage); + this.feedbackMessageService.addFeedbackMessage(new Message(errorMessage, MessageLevel.WARNING)); + return self; + } + + /** + * Moves the usage into its closest containing package. + * + * @param usage + * the usage to move + * @return the moved usage + */ + public Element moveToClosestContainingPackage(Usage usage) { + var pack = this.getClosestContainingPackageFrom(usage); + if (pack != null) { + var oldMembership = usage.eContainer(); + var owningMembership = SysmlFactory.eINSTANCE.createOwningMembership(); + pack.getOwnedRelationship().add(owningMembership); + owningMembership.getOwnedRelatedElement().add(usage); + if (oldMembership instanceof OwningMembership oldOwningMembership) { + this.deleteService.deleteFromModel(oldOwningMembership); + } + } + return usage; + } + + private Package getClosestContainingPackageFrom(Element element) { + var owner = element.eContainer(); + while (!(owner instanceof Package) && owner != null) { + owner = owner.eContainer(); + } + return (Package) owner; + } + + private List getOwnerHierarchy(Element element) { + List ownerHierarchy = new ArrayList<>(); + Element currentElement = element; + while (currentElement.getOwner() != null) { + ownerHierarchy.add(currentElement.getOwner()); + currentElement = currentElement.getOwner(); + } + return ownerHierarchy; + } + + private String getLabel(Object droppedElement) { + final String label; + StyledString styledLabel = this.labelService.getStyledLabel(droppedElement); + if (styledLabel != null && !styledLabel.toString().isEmpty()) { + label = styledLabel.toString(); + } else if (droppedElement instanceof EObject droppedEObject) { + label = droppedEObject.eClass().getName(); + } else { + label = ""; + } + return label; + } +} diff --git a/backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/DiagramQueryToolService.java b/backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/DiagramQueryToolService.java new file mode 100644 index 000000000..2aed897e6 --- /dev/null +++ b/backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/DiagramQueryToolService.java @@ -0,0 +1,187 @@ +/******************************************************************************* + * Copyright (c) 2026 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.syson.diagram.services; + +import java.util.List; +import java.util.Objects; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.sirius.components.collaborative.diagrams.DiagramContext; +import org.eclipse.sirius.components.core.api.IEditingContext; +import org.eclipse.sirius.components.core.api.IObjectSearchService; +import org.eclipse.sirius.components.diagrams.Node; +import org.eclipse.syson.services.UtilService; +import org.eclipse.syson.services.api.ViewDefinitionKind; +import org.eclipse.syson.sysml.ActionDefinition; +import org.eclipse.syson.sysml.ActionUsage; +import org.eclipse.syson.sysml.Definition; +import org.eclipse.syson.sysml.Element; +import org.eclipse.syson.sysml.Package; +import org.eclipse.syson.sysml.StateDefinition; +import org.eclipse.syson.sysml.StateUsage; +import org.eclipse.syson.sysml.SysmlPackage; +import org.eclipse.syson.sysml.Type; +import org.eclipse.syson.sysml.Usage; +import org.eclipse.syson.sysml.ViewDefinition; +import org.eclipse.syson.sysml.ViewUsage; +import org.eclipse.syson.util.StandardDiagramsConstants; +import org.springframework.stereotype.Service; + +/** + * Tool-related services doing queries for diagrams. + * + * @author arichard + */ +@Service +public class DiagramQueryToolService { + + private final IObjectSearchService objectSearchService; + + private final UtilService utilService; + + public DiagramQueryToolService(IObjectSearchService objectSearchService) { + this.objectSearchService = Objects.requireNonNull(objectSearchService); + this.utilService = new UtilService(); + } + + /** + * Tool precondition for control node actions (Start/Done/Decision/Fork/Join/Merge) invoked on diagram background. + * + * @param element + * the given {@link Element}. + * @return true if the tool should be available, false otherwise. + */ + public boolean isControlNodeActionCreationToolInsideActionOnAFV(Element element, IEditingContext editingContext, DiagramContext diagramContext) { + if (this.isAFVDiagram(editingContext, diagramContext)) { + var owner = this.utilService.getViewUsageOwner(element); + return owner instanceof ActionUsage || owner instanceof ActionDefinition; + } + return false; + } + + /** + * Tool precondition for control node actions (Start/Done/Decision/Fork/Join/Merge) invoked on a selected node. + * + * @param editingContext + * the (non-{@code null}) {@link IEditingContext}. + * @param selectedNode + * the selected node. It corresponds to a variable accessible from the variable manager. + * @return true if the tool should be available, false otherwise. + */ + public boolean isControlNodeActionCreationToolInAction(IEditingContext editingContext, Node selectedNode) { + return this.objectSearchService.getObject(editingContext, selectedNode.getTargetObjectId()) + .map(object -> { + return object instanceof ActionUsage || object instanceof ActionDefinition; + }).orElse(false); + } + + /** + * Checks if a tool creating the given type should be available for the provided diagram context. + * + * @param element + * the semantic context element + * @param editingContext + * the editing context + * @param diagramContext + * the diagram context + * @param newElementType + * the type created by the tool + * @return {@code true} if the tool should be available, {@code false} otherwise + */ + public boolean toolShouldBeAvailable(Element element, IEditingContext editingContext, DiagramContext diagramContext, EClass newElementType) { + ViewDefinitionKind viewDefinitionKind = this.utilService.getViewDefinitionKind(element, List.of(), editingContext); + var elt = this.utilService.getViewUsageOwner(element); + + return switch (viewDefinitionKind) { + case INTERCONNECTION_VIEW -> this.toolShouldBeAvailableOnInterconnectionView(elt, newElementType); + case ACTION_FLOW_VIEW -> this.toolShouldBeAvailableOnActionFlowView(elt, newElementType); + case STATE_TRANSITION_VIEW -> this.toolShouldBeAvailableOnStateTransitionView(elt, newElementType); + default -> this.toolShouldBeAvailableOnGeneralView(elt, newElementType); + }; + } + + private boolean toolShouldBeAvailableOnGeneralView(Element element, EClass domainClass) { + boolean toolShouldBeAvailable = false; + if (element instanceof Package) { + toolShouldBeAvailable = true; + } else if (element instanceof Usage && !SysmlPackage.eINSTANCE.getDefinition().isSuperTypeOf(domainClass)) { + toolShouldBeAvailable = true; + } else if (element instanceof Definition && !SysmlPackage.eINSTANCE.getDefinition().isSuperTypeOf(domainClass)) { + toolShouldBeAvailable = true; + } + return toolShouldBeAvailable; + } + + private boolean toolShouldBeAvailableOnInterconnectionView(Element element, EClass domainClass) { + boolean toolShouldBeAvailable = false; + if (element instanceof Package) { + toolShouldBeAvailable = true; + if (SysmlPackage.eINSTANCE.getAttributeUsage().isSuperTypeOf(domainClass)) { + toolShouldBeAvailable = false; + } else if (SysmlPackage.eINSTANCE.getPortUsage().isSuperTypeOf(domainClass)) { + toolShouldBeAvailable = false; + } + } else if (element instanceof Usage && !SysmlPackage.eINSTANCE.getDefinition().isSuperTypeOf(domainClass)) { + toolShouldBeAvailable = true; + } else if (element instanceof Definition && !SysmlPackage.eINSTANCE.getDefinition().isSuperTypeOf(domainClass)) { + toolShouldBeAvailable = true; + } + return toolShouldBeAvailable; + } + + private boolean toolShouldBeAvailableOnActionFlowView(Element element, EClass domainClass) { + boolean toolShouldBeAvailable = false; + if (element instanceof ActionUsage) { + toolShouldBeAvailable = !SysmlPackage.eINSTANCE.getDefinition().isSuperTypeOf(domainClass); + } else if (element instanceof ActionDefinition) { + toolShouldBeAvailable = !SysmlPackage.eINSTANCE.getDefinition().isSuperTypeOf(domainClass); + } else { + if (SysmlPackage.eINSTANCE.getActionUsage().equals(domainClass) || SysmlPackage.eINSTANCE.getActionUsage().isSuperTypeOf(domainClass)) { + toolShouldBeAvailable = true; + } else if (SysmlPackage.eINSTANCE.getActionDefinition().equals(domainClass) || SysmlPackage.eINSTANCE.getActionDefinition().isSuperTypeOf(domainClass)) { + toolShouldBeAvailable = true; + } + } + return toolShouldBeAvailable; + } + + private boolean toolShouldBeAvailableOnStateTransitionView(Element element, EClass domainClass) { + boolean toolShouldBeAvailable = false; + if (element instanceof StateUsage) { + toolShouldBeAvailable = !SysmlPackage.eINSTANCE.getDefinition().isSuperTypeOf(domainClass); + } else if (element instanceof StateDefinition) { + toolShouldBeAvailable = !SysmlPackage.eINSTANCE.getDefinition().isSuperTypeOf(domainClass); + } else { + if (SysmlPackage.eINSTANCE.getStateUsage().equals(domainClass) || SysmlPackage.eINSTANCE.getStateUsage().isSuperTypeOf(domainClass)) { + toolShouldBeAvailable = true; + } else if (SysmlPackage.eINSTANCE.getStateDefinition().equals(domainClass) || SysmlPackage.eINSTANCE.getStateDefinition().isSuperTypeOf(domainClass)) { + toolShouldBeAvailable = true; + } + } + return toolShouldBeAvailable; + } + + private boolean isAFVDiagram(IEditingContext editingContext, DiagramContext diagramContext) { + var objectId = diagramContext.diagram().getTargetObjectId(); + return this.objectSearchService.getObject(editingContext, objectId) + .map(object -> { + if (object instanceof ViewUsage viewUsage) { + if (!viewUsage.getType().isEmpty()) { + Type type = viewUsage.getType().getFirst(); + return type instanceof ViewDefinition && StandardDiagramsConstants.AFV_QN.equals(type.getQualifiedName()); + } + } + return false; + }).orElse(false); + } +} diff --git a/backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/aql/DiagramMutationAQLService.java b/backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/aql/DiagramMutationAQLService.java index bc577bd57..3d42de2f5 100644 --- a/backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/aql/DiagramMutationAQLService.java +++ b/backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/aql/DiagramMutationAQLService.java @@ -27,6 +27,7 @@ import org.eclipse.syson.diagram.services.DiagramMutationElementService; import org.eclipse.syson.diagram.services.DiagramMutationExposeService; import org.eclipse.syson.diagram.services.DiagramMutationLabelService; +import org.eclipse.syson.diagram.services.DiagramMutationToolService; import org.eclipse.syson.sysml.BindingConnectorAsUsage; import org.eclipse.syson.sysml.ConnectionUsage; import org.eclipse.syson.sysml.Connector; @@ -35,6 +36,7 @@ import org.eclipse.syson.sysml.FlowUsage; import org.eclipse.syson.sysml.InterfaceUsage; import org.eclipse.syson.sysml.PortUsage; +import org.eclipse.syson.sysml.RequirementUsage; import org.eclipse.syson.sysml.SatisfyRequirementUsage; import org.eclipse.syson.sysml.StateUsage; import org.eclipse.syson.sysml.Type; @@ -61,15 +63,50 @@ public class DiagramMutationAQLService { private final DiagramMutationCompartmentService diagramMutationCompartmentService; + private final DiagramMutationToolService diagramMutationToolService; + + /** + * Creates a new diagram mutation AQL service. + * + * @param diagramMutationDndService + * the diagram drag and drop mutation service + * @param diagramMutationElementService + * the diagram element mutation service + * @param diagramMutationExposeService + * the diagram exposed element mutation service + * @param diagramMutationLabelService + * the diagram label mutation service + * @param diagramMutationDiagramService + * the diagram mutation service + * @param diagramMutationCompartmentService + * the diagram compartment mutation service + * @param diagramMutationToolService + * the diagram tool mutation service + */ public DiagramMutationAQLService(DiagramMutationDndService diagramMutationDndService, DiagramMutationElementService diagramMutationElementService, DiagramMutationExposeService diagramMutationExposeService, DiagramMutationLabelService diagramMutationLabelService, DiagramMutationDiagramService diagramMutationDiagramService, - DiagramMutationCompartmentService diagramMutationCompartmentService) { + DiagramMutationCompartmentService diagramMutationCompartmentService, DiagramMutationToolService diagramMutationToolService) { this.diagramMutationDndService = Objects.requireNonNull(diagramMutationDndService); this.diagramMutationElementService = Objects.requireNonNull(diagramMutationElementService); this.diagramMutationExposeService = Objects.requireNonNull(diagramMutationExposeService); this.diagramMutationLabelService = Objects.requireNonNull(diagramMutationLabelService); this.diagramMutationDiagramService = Objects.requireNonNull(diagramMutationDiagramService); this.diagramMutationCompartmentService = Objects.requireNonNull(diagramMutationCompartmentService); + this.diagramMutationToolService = Objects.requireNonNull(diagramMutationToolService); + } + + /** + * {@link DiagramMutationToolService#becomeNestedUsage(Usage, Element)}. + */ + public Usage becomeNestedUsage(Usage usage, Element newContainer) { + return this.diagramMutationToolService.becomeNestedUsage(usage, newContainer); + } + + /** + * {@link DiagramMutationToolService#becomeObjectiveRequirement(RequirementUsage, Element)}. + */ + public RequirementUsage becomeObjectiveRequirement(RequirementUsage requirement, Element newContainer) { + return this.diagramMutationToolService.becomeObjectiveRequirement(requirement, newContainer); } /** @@ -257,6 +294,34 @@ public Element expose(Element element, IEditingContext editingContext, DiagramCo return this.diagramMutationExposeService.expose(element, editingContext, diagramContext, selectedNode, convertedNodes); } + /** + * {@link DiagramMutationToolService#moveToClosestContainingPackage(Usage)}. + */ + public Element moveToClosestContainingPackage(Usage usage) { + return this.diagramMutationToolService.moveToClosestContainingPackage(usage); + } + + /** + * {@link DiagramMutationToolService#reconnectSourceNestedActorEdge(Element, Element, Element)}. + */ + public Element reconnectSourceNestedActorEdge(Element self, Element newSource, Element otherEnd) { + return this.diagramMutationToolService.reconnectSourceNestedActorEdge(self, newSource, otherEnd); + } + + /** + * {@link DiagramMutationToolService#reconnectSourceNestedStakeholderEdge(Element, Element, Element)}. + */ + public Element reconnectSourceNestedStakeholderEdge(Element self, Element newSource, Element otherEnd) { + return this.diagramMutationToolService.reconnectSourceNestedStakeholderEdge(self, newSource, otherEnd); + } + + /** + * {@link DiagramMutationToolService#reconnectSourceNestedSubjectEdge(Element, Element, Element)}. + */ + public Element reconnectSourceNestedSubjectEdge(Element self, Element newSource, Element otherEnd) { + return this.diagramMutationToolService.reconnectSourceNestedSubjectEdge(self, newSource, otherEnd); + } + /** * {@link DiagramMutationElementService#reconnectSatisfyRequirementSource(SatisfyRequirementUsage, Element)}. */ @@ -271,6 +336,13 @@ public SatisfyRequirementUsage reconnectSatisfyRequirementTarget(SatisfyRequirem return this.diagramMutationElementService.reconnectSatisfyRequirementTarget(sru, newTarget); } + /** + * {@link DiagramMutationToolService#reconnnectSourceCompositionEdge(Element, Element, Element)}. + */ + public Element reconnnectSourceCompositionEdge(Element self, Element newSource, Element otherEnd) { + return this.diagramMutationToolService.reconnnectSourceCompositionEdge(self, newSource, otherEnd); + } + /** * {@link DiagramMutationElementService#reconnectSource(Connector, Feature, Node, Node, IEditingContext, Diagram)}. */ @@ -287,6 +359,27 @@ public Connector reconnectTarget(Connector connector, Feature newTarget, Node so return this.diagramMutationElementService.reconnectTarget(connector, newTarget, sourceNode, newTargetNode, editingContext, diagram); } + /** + * {@link DiagramMutationToolService#reconnnectTargetAnnotatedEdge(Element, Element)}. + */ + public Element reconnnectTargetAnnotatedEdge(Element self, Element newTarget) { + return this.diagramMutationToolService.reconnnectTargetAnnotatedEdge(self, newTarget); + } + + /** + * {@link DiagramMutationToolService#reconnnectTargetCompositionEdge(Element, Element, Element, Element)}. + */ + public Element reconnnectTargetCompositionEdge(Element self, Element oldTarget, Element newTarget, Element otherEnd) { + return this.diagramMutationToolService.reconnnectTargetCompositionEdge(self, oldTarget, newTarget, otherEnd); + } + + /** + * {@link DiagramMutationToolService#reconnectTargetNestedActorEdge(Element)}. + */ + public Element reconnectTargetNestedActorEdge(Element self) { + return this.diagramMutationToolService.reconnectTargetNestedActorEdge(self); + } + /** * {@link DiagramMutationExposeService#removeFromExposedElements(Element, Node, IEditingContext, DiagramContext)}. */ diff --git a/backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/aql/DiagramQueryAQLService.java b/backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/aql/DiagramQueryAQLService.java index 3cccf6d1b..8912aad39 100644 --- a/backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/aql/DiagramQueryAQLService.java +++ b/backend/services/syson-diagram-services/src/main/java/org/eclipse/syson/diagram/services/aql/DiagramQueryAQLService.java @@ -27,6 +27,7 @@ import org.eclipse.syson.diagram.services.DiagramQueryExposeService; import org.eclipse.syson.diagram.services.DiagramQueryGraphicalService; import org.eclipse.syson.diagram.services.DiagramQueryLabelService; +import org.eclipse.syson.diagram.services.DiagramQueryToolService; import org.eclipse.syson.diagram.services.DiagramQueryViewService; import org.eclipse.syson.sysml.Comment; import org.eclipse.syson.sysml.ConnectionUsage; @@ -66,15 +67,36 @@ public class DiagramQueryAQLService { private final DiagramQueryAnnotatingService diagramQueryAnnotatingService; + private final DiagramQueryToolService diagramQueryToolService; + + /** + * Creates a new diagram query AQL service. + * + * @param diagramQueryElementService + * the diagram element query service + * @param diagramQueryLabelService + * the diagram label query service + * @param diagramQueryExposeService + * the diagram exposed element query service + * @param diagramQueryGraphicalService + * the diagram graphical query service + * @param diagramQueryViewService + * the diagram view query service + * @param diagramQueryAnnotatingService + * the diagram annotating query service + * @param diagramQueryToolService + * the diagram tool query service + */ public DiagramQueryAQLService(DiagramQueryElementService diagramQueryElementService, DiagramQueryLabelService diagramQueryLabelService, DiagramQueryExposeService diagramQueryExposeService, DiagramQueryGraphicalService diagramQueryGraphicalService, DiagramQueryViewService diagramQueryViewService, - DiagramQueryAnnotatingService diagramQueryAnnotatingService) { + DiagramQueryAnnotatingService diagramQueryAnnotatingService, DiagramQueryToolService diagramQueryToolService) { this.diagramQueryElementService = Objects.requireNonNull(diagramQueryElementService); this.diagramQueryLabelService = Objects.requireNonNull(diagramQueryLabelService); this.diagramQueryExposeService = Objects.requireNonNull(diagramQueryExposeService); this.diagramQueryGraphicalService = Objects.requireNonNull(diagramQueryGraphicalService); this.diagramQueryViewService = Objects.requireNonNull(diagramQueryViewService); this.diagramQueryAnnotatingService = Objects.requireNonNull(diagramQueryAnnotatingService); + this.diagramQueryToolService = Objects.requireNonNull(diagramQueryToolService); } /** @@ -238,6 +260,20 @@ public Object infoMessage(Object self, String message) { return self; } + /** + * {@link DiagramQueryElementService#isControlNodeActionCreationToolInAction(editingContext, selectedNode)}. + */ + public boolean isControlNodeActionCreationToolInsideActionOnAFV(Element element, IEditingContext editingContext, DiagramContext diagramContext) { + return this.diagramQueryToolService.isControlNodeActionCreationToolInsideActionOnAFV(element, editingContext, diagramContext); + } + + /** + * {@link DiagramQueryElementService#isControlNodeActionCreationToolInAction(editingContext, selectedNode)}. + */ + public boolean isControlNodeActionCreationToolInAction(IEditingContext editingContext, Node selectedNode) { + return this.diagramQueryToolService.isControlNodeActionCreationToolInAction(editingContext, selectedNode); + } + /** * {@link DiagramQueryElementService#isDiagramEmpty(editingContext, diagramContext, previousDiagram)}. */ @@ -252,6 +288,36 @@ public boolean isHiddenByDefault(Element self, String compartmentName, Listtrue if this node should be hidden by default or false if it should be + * displayed. + */ + public boolean isHiddenControlNodeByDefault(Element element, List ancestors) { + // A control node on the top of the GV diagram should be hidden by default + // A control node on the top of the AFV diagram should be hidden by default if it has not been created on the + // AFV background + boolean result = false; + if (element instanceof ControlNode controlNode && !ancestors.isEmpty() && ancestors.getFirst() instanceof ViewUsage viewUsage) { + if (this.isGVDiagram(viewUsage)) { + result = true; + } else if (this.isAFVDiagram(viewUsage)) { + Element owner = controlNode.getOwner(); + Element viewUsageOwner = viewUsage.getOwner(); + if (!Objects.equals(owner, viewUsageOwner)) { + result = true; + } + } + } + return result; + } + /** * {@link DiagramQueryGraphicalService#isNotAncestorOf(org.eclipse.sirius.components.representations.Element, org.eclipse.sirius.components.representations.Element, DiagramRenderingCache)}. */ @@ -290,27 +356,10 @@ public boolean showAnnotatingNode(Element element, DiagramContext diagramContext } /** - * AQL Service to control the default visibility of control nodes (Decision, Fork, Join, Merge) in diagrams (GV and AFV). - * @param element the control node to display or not - * @param ancestors the semantic ancestor of the given element - * @return true if this node should be hidden by default or false if it should be displayed. + * {@link DiagramQueryToolService#toolShouldBeAvailable(Element, IEditingContext, DiagramContext, EClass)}. */ - public boolean isHiddenControlNodeByDefault(Element element, List ancestors) { - // A control node on the top of the GV diagram should be hidden by default - // A control node on the top of the AFV diagram should be hidden by default if it has not been created on the AFV background - boolean result = false; - if (element instanceof ControlNode controlNode && !ancestors.isEmpty() && ancestors.getFirst() instanceof ViewUsage viewUsage) { - if (this.isGVDiagram(viewUsage)) { - result = true; - } else if (this.isAFVDiagram(viewUsage)) { - Element owner = controlNode.getOwner(); - Element viewUsageOwner = viewUsage.getOwner(); - if (!Objects.equals(owner, viewUsageOwner)) { - result = true; - } - } - } - return result; + public boolean toolShouldBeAvailable(Element element, IEditingContext editingContext, DiagramContext diagramContext, EClass newElementType) { + return this.diagramQueryToolService.toolShouldBeAvailable(element, editingContext, diagramContext, newElementType); } private boolean isGVDiagram(ViewUsage viewUsage) { diff --git a/backend/views/syson-diagram-common-view/src/test/java/org/eclipse/syson/diagram/common/view/services/ViewToolServiceTest.java b/backend/services/syson-diagram-services/src/test/java/org/eclipse/syson/diagram/services/DiagramMutationToolServiceTest.java similarity index 89% rename from backend/views/syson-diagram-common-view/src/test/java/org/eclipse/syson/diagram/common/view/services/ViewToolServiceTest.java rename to backend/services/syson-diagram-services/src/test/java/org/eclipse/syson/diagram/services/DiagramMutationToolServiceTest.java index 8e134c866..90e1bbad5 100644 --- a/backend/views/syson-diagram-common-view/src/test/java/org/eclipse/syson/diagram/common/view/services/ViewToolServiceTest.java +++ b/backend/services/syson-diagram-services/src/test/java/org/eclipse/syson/diagram/services/DiagramMutationToolServiceTest.java @@ -10,7 +10,7 @@ * Contributors: * Obeo - initial API and implementation *******************************************************************************/ -package org.eclipse.syson.diagram.common.view.services; +package org.eclipse.syson.diagram.services; import static org.assertj.core.api.Assertions.assertThat; @@ -19,29 +19,25 @@ import java.util.List; import org.eclipse.sirius.components.core.api.IFeedbackMessageService; -import org.eclipse.sirius.components.core.api.IIdentityService; import org.eclipse.sirius.components.core.api.ILabelService; -import org.eclipse.sirius.components.core.api.IObjectSearchService; import org.eclipse.sirius.components.core.api.labels.StyledString; import org.eclipse.sirius.components.representations.Message; import org.eclipse.sirius.components.representations.MessageLevel; -import org.eclipse.sirius.components.view.emf.IViewRepresentationDescriptionSearchService; import org.eclipse.syson.services.api.ISysMLMoveElementService; import org.eclipse.syson.services.api.MoveStatus; import org.eclipse.syson.sysml.Element; import org.eclipse.syson.sysml.PartUsage; import org.eclipse.syson.sysml.SysmlFactory; import org.eclipse.syson.sysml.Usage; -import org.eclipse.syson.tree.explorer.services.api.ISysONExplorerService; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; /** - * Tests for {@link ViewToolService}. + * Tests for {@link DiagramMutationToolService}. * * @author Arthur Daussy */ -public class ViewToolServiceTest { +public class DiagramMutationToolServiceTest { private static final String FAILURE_MESSAGE = "move refused"; @@ -109,14 +105,7 @@ private TestServices createService(Object firstObject, String firstLabel, Object labelService.withLabel(thirdObject, thirdLabel); } - ViewToolService service = new ViewToolService( - new IIdentityService.NoOp(), - new IObjectSearchService.NoOp(), - new IViewRepresentationDescriptionSearchService.NoOp(), - feedbackMessageService, - moveService, - new ISysONExplorerService.NoOp(), - labelService); + DiagramMutationToolService service = new DiagramMutationToolService(feedbackMessageService, moveService, labelService); return new TestServices(service, moveService, feedbackMessageService); } @@ -130,7 +119,7 @@ private TestServices createService(Object firstObject, String firstLabel, Object * @param feedbackMessageService * the feedback message service collecting messages */ - private record TestServices(ViewToolService service, TestMoveElementService moveService, CapturingFeedbackMessageService feedbackMessageService) { + private record TestServices(DiagramMutationToolService service, TestMoveElementService moveService, CapturingFeedbackMessageService feedbackMessageService) { } /** @@ -194,6 +183,4 @@ public StyledString getStyledLabel(Object object) { return this.labels.getOrDefault(object, StyledString.of("")); } } - - } diff --git a/backend/services/syson-tree-services/src/main/java/org/eclipse/syson/tree/services/TreeQuerySelectionDialogService.java b/backend/services/syson-tree-services/src/main/java/org/eclipse/syson/tree/services/TreeQuerySelectionDialogService.java new file mode 100644 index 000000000..840075b44 --- /dev/null +++ b/backend/services/syson-tree-services/src/main/java/org/eclipse/syson/tree/services/TreeQuerySelectionDialogService.java @@ -0,0 +1,442 @@ +/******************************************************************************* + * Copyright (c) 2026 Obeo. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.syson.tree.services; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.Objects; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.sirius.components.core.api.IEditingContext; +import org.eclipse.sirius.components.emf.ResourceMetadataAdapter; +import org.eclipse.syson.sysml.AllocationDefinition; +import org.eclipse.syson.sysml.ConnectionDefinition; +import org.eclipse.syson.sysml.ConstraintDefinition; +import org.eclipse.syson.sysml.Element; +import org.eclipse.syson.sysml.ItemDefinition; +import org.eclipse.syson.sysml.Membership; +import org.eclipse.syson.sysml.PartDefinition; +import org.eclipse.syson.sysml.SysmlPackage; +import org.eclipse.syson.sysml.Type; +import org.eclipse.syson.sysml.Usage; +import org.eclipse.syson.tree.explorer.services.api.ISysONExplorerFragment; +import org.eclipse.syson.tree.explorer.services.api.ISysONExplorerService; +import org.springframework.stereotype.Service; + +/** + * Selection dialog services doing tree queries. + * + * @author arichard + */ +@Service +public class TreeQuerySelectionDialogService { + + private final ISysONExplorerService sysONExplorerService; + + /** + * Creates a new selection dialog query service. + * + * @param sysONExplorerService + * the explorer service used to retrieve root elements and fragment children + */ + public TreeQuerySelectionDialogService(ISysONExplorerService sysONExplorerService) { + this.sysONExplorerService = Objects.requireNonNull(sysONExplorerService); + } + + /** + * Provides the children of element in the tree of the selection dialog for presenting all existing ConstraiNtUsage. + * + * @param selectionDialogTreeElement + * a (non-{@code null}) selection dialog tree element. + * @param editingContext + * the (non-{@code null}) {@link IEditingContext}. + * @param expandedIds + * the list of already expanded treeItems, by their Ids. + * @return the (non-{@code null}) {@link List} of all children that contain (possibly indirectly) an + * {@link org.eclipse.syson.sysml.ConstraintUsage}. + */ + public List getConstraintReferenceSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { + return this.getSelectionDialogChildren(selectionDialogTreeElement, editingContext, expandedIds, List.of(SysmlPackage.eINSTANCE.getConstraintUsage())); + } + + /** + * Provides the root elements in the tree of the selection dialog for presenting all existing ConstraintUsage. + * + * @param editingContext + * the (non-{@code null}) {@link IEditingContext}. + * @return the (non-{@code null}) {@link List} of all {@link Resource} and {@link ISysONExplorerFragment} that + * contain at least one {@link org.eclipse.syson.sysml.ConstraintUsage}. + */ + public List getConstraintReferenceSelectionDialogElements(IEditingContext editingContext) { + return this.getSelectionDialogElements(editingContext, List.of(SysmlPackage.eINSTANCE.getConstraintUsage())); + } + + /** + * Provides the root elements for the namespace import selection dialog. + * + * @param editingContext + * the editing context + * @return the root elements containing packages + */ + public List getNamespaceImportSelectionDialogElements(IEditingContext editingContext) { + return this.getSelectionDialogElements(editingContext, List.of(SysmlPackage.eINSTANCE.getPackage())); + } + + /** + * Provides the children for the namespace import selection dialog. + * + * @param selectionDialogTreeElement + * the expanded tree element + * @param editingContext + * the editing context + * @param expandedIds + * the expanded tree item ids + * @return the children containing packages + */ + public List getNamespaceImportSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { + return this.getSelectionDialogChildren(selectionDialogTreeElement, editingContext, expandedIds, List.of(SysmlPackage.eINSTANCE.getPackage())); + } + + /** + * Provides the root elements for the stakeholder selection dialog. + * + * @param editingContext + * the editing context + * @return the root elements containing part usages + */ + public List getStakeholderSelectionDialogElements(IEditingContext editingContext) { + return this.getSelectionDialogElements(editingContext, List.of(SysmlPackage.eINSTANCE.getPartUsage())); + } + + /** + * Provides the children for the stakeholder selection dialog. + * + * @param selectionDialogTreeElement + * the expanded tree element + * @param editingContext + * the editing context + * @param expandedIds + * the expanded tree item ids + * @return the children containing part usages + */ + public List getStakeholderSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { + return this.getSelectionDialogChildren(selectionDialogTreeElement, editingContext, expandedIds, List.of(SysmlPackage.eINSTANCE.getPartUsage())); + } + + /** + * Provides the root elements for the subject selection dialog. + * + * @param editingContext + * the editing context + * @return the root elements containing types + */ + public List getSubjectSelectionDialogElements(IEditingContext editingContext) { + return this.getSelectionDialogElements(editingContext, List.of(SysmlPackage.eINSTANCE.getType())); + } + + /** + * Provides the children for the subject selection dialog. + * + * @param selectionDialogTreeElement + * the expanded tree element + * @param editingContext + * the editing context + * @param expandedIds + * the expanded tree item ids + * @return the children containing types + */ + public List getSubjectSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { + return this.getSelectionDialogChildren(selectionDialogTreeElement, editingContext, expandedIds, List.of(SysmlPackage.eINSTANCE.getType())); + } + + /** + * Provides the root elements for the actor selection dialog. + * + * @param editingContext + * the editing context + * @return the root elements containing part usages or part definitions + */ + public List getActorSelectionDialogElements(IEditingContext editingContext) { + return this.getSelectionDialogElements(editingContext, List.of(SysmlPackage.eINSTANCE.getPartUsage(), SysmlPackage.eINSTANCE.getPartDefinition())); + } + + /** + * Provides the children for the actor selection dialog. + * + * @param selectionDialogTreeElement + * the expanded tree element + * @param editingContext + * the editing context + * @param expandedIds + * the expanded tree item ids + * @return the children containing part usages or part definitions + */ + public List getActorSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { + return this.getSelectionDialogChildren(selectionDialogTreeElement, editingContext, expandedIds, List.of(SysmlPackage.eINSTANCE.getPartUsage(), SysmlPackage.eINSTANCE.getPartDefinition())); + } + + /** + * Provides the root elements for the objective requirement selection dialog. + * + * @param editingContext + * the editing context + * @return the root elements containing requirement usages or definitions + */ + public List getObjectiveRequirementSelectionDialogElements(IEditingContext editingContext) { + return this.getSelectionDialogElements(editingContext, List.of(SysmlPackage.eINSTANCE.getRequirementUsage(), SysmlPackage.eINSTANCE.getRequirementDefinition())); + } + + /** + * Provides the children for the objective requirement selection dialog. + * + * @param selectionDialogTreeElement + * the expanded tree element + * @param editingContext + * the editing context + * @param expandedIds + * the expanded tree item ids + * @return the children containing requirement usages or definitions + */ + public List getObjectiveRequirementSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { + return this.getSelectionDialogChildren(selectionDialogTreeElement, editingContext, expandedIds, + List.of(SysmlPackage.eINSTANCE.getRequirementUsage(), SysmlPackage.eINSTANCE.getRequirementDefinition())); + } + + /** + * Provides the root elements for the action reference selection dialog. + * + * @param editingContext + * the editing context + * @return the root elements containing action usages + */ + public List getActionReferenceSelectionDialogElements(IEditingContext editingContext) { + return this.getSelectionDialogElements(editingContext, List.of(SysmlPackage.eINSTANCE.getActionUsage())); + } + + /** + * Provides the children for the action reference selection dialog. + * + * @param selectionDialogTreeElement + * the expanded tree element + * @param editingContext + * the editing context + * @param expandedIds + * the expanded tree item ids + * @return the children containing action usages + */ + public List getActionReferenceSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { + return this.getSelectionDialogChildren(selectionDialogTreeElement, editingContext, expandedIds, List.of(SysmlPackage.eINSTANCE.getActionUsage())); + } + + /** + * Provides the root elements for the exhibit state selection dialog. + * + * @param editingContext + * the editing context + * @return the root elements containing state usages + */ + public List getExhibitStateSelectionDialogElements(IEditingContext editingContext) { + return this.getSelectionDialogElements(editingContext, List.of(SysmlPackage.eINSTANCE.getStateUsage())); + } + + /** + * Provides the children for the exhibit state selection dialog. + * + * @param selectionDialogTreeElement + * the expanded tree element + * @param editingContext + * the editing context + * @param expandedIds + * the expanded tree item ids + * @return the children containing state usages + */ + public List getExhibitStateSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { + return this.getSelectionDialogChildren(selectionDialogTreeElement, editingContext, expandedIds, List.of(SysmlPackage.eINSTANCE.getStateUsage())); + } + + /** + * Provides the root elements for the concern reference selection dialog. + * + * @param editingContext + * the editing context + * @return the root elements containing concern usages + */ + public List getConcernReferenceSelectionDialogElements(IEditingContext editingContext) { + return this.getSelectionDialogElements(editingContext, List.of(SysmlPackage.eINSTANCE.getConcernUsage())); + } + + /** + * Provides the children for the concern reference selection dialog. + * + * @param selectionDialogTreeElement + * the expanded tree element + * @param editingContext + * the editing context + * @param expandedIds + * the expanded tree item ids + * @return the children containing concern usages + */ + public List getConcernReferenceSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { + return this.getSelectionDialogChildren(selectionDialogTreeElement, editingContext, expandedIds, List.of(SysmlPackage.eINSTANCE.getConcernUsage())); + } + + /** + * Return the {@code Usage} {@link EClass} corresponding to the given {@link Type}. + * + * @param type + * the type we want the {@code Usage} {@link EClass} + * @return the {@code Usage} {@link EClass} corresponding to the given {@link Type} + */ + public EClass getPortionKindSelectionDialogElement(Type type) { + return switch (type) { + case AllocationDefinition a -> SysmlPackage.eINSTANCE.getAllocationUsage(); + case ConnectionDefinition c -> SysmlPackage.eINSTANCE.getConnectionUsage(); + case PartDefinition p -> SysmlPackage.eINSTANCE.getPartUsage(); + case ConstraintDefinition c -> SysmlPackage.eINSTANCE.getConstraintUsage(); + case ItemDefinition i -> SysmlPackage.eINSTANCE.getItemUsage(); + case Usage u -> u.eClass(); + default -> SysmlPackage.eINSTANCE.getOccurrenceUsage(); + }; + } + + /** + * Provides the root elements for a selection dialog using the given candidates. + * + * @param editingContext + * the editing context + * @param candidates + * the accepted candidate classifiers + * @return the root elements containing candidate instances + */ + public List getSelectionDialogElements(IEditingContext editingContext, List candidates) { + var elementsContainingClassifiers = new ArrayList<>(); + List elements = this.sysONExplorerService.getElements(editingContext, List.of()); + for (Object rootElement : elements) { + if (rootElement instanceof Resource resource && this.containsDirectlyOrIndirectlyInstancesOf(resource, candidates)) { + elementsContainingClassifiers.add(resource); + } else if (rootElement instanceof ISysONExplorerFragment fragment) { + elementsContainingClassifiers.add(fragment); + } + } + + return elementsContainingClassifiers.stream() + .sorted(Comparator.comparingInt(this::getSelectionDialogRootSortRank) + .thenComparing(this::getElementName, String.CASE_INSENSITIVE_ORDER)) + .toList(); + } + + /** + * Provides the children for a selection dialog using the given candidates. + * + * @param selectionDialogTreeElement + * the expanded tree element + * @param editingContext + * the editing context + * @param expandedIds + * the expanded tree item ids + * @param candidates + * the accepted candidate classifiers + * @return the children containing candidate instances + */ + public List getSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds, List candidates) { + final List result; + + if (selectionDialogTreeElement instanceof Resource resource) { + result = resource.getContents().stream() + .filter(content -> candidates.stream().anyMatch(eClassifier -> eClassifier.isInstance(content)) || this.containsDirectlyOrIndirectlyInstancesOf(content, candidates)) + .toList(); + } else if (selectionDialogTreeElement instanceof Element sysmlElement) { + result = sysmlElement.getOwnedRelationship().stream() + .filter(Membership.class::isInstance) + .map(Membership.class::cast) + .map(Membership::getOwnedRelatedElement).flatMap(List::stream) + .filter(content -> candidates.stream().anyMatch(eClassifier -> eClassifier.isInstance(content)) || this.containsDirectlyOrIndirectlyInstancesOf(content, candidates)) + .toList(); + } else if (selectionDialogTreeElement instanceof ISysONExplorerFragment fragment) { + result = fragment.getChildren(editingContext, List.of(), expandedIds, List.of()).stream().filter(child -> { + if (child instanceof Resource childResource && !this.containsDirectlyOrIndirectlyInstancesOf(childResource, candidates)) { + return false; + } + return true; + }).toList(); + } else { + result = new ArrayList<>(); + } + + return result; + } + + private boolean containsDirectlyOrIndirectlyInstancesOf(Resource resource, List eClassifiers) { + boolean found = false; + final Iterator allContents = resource.getAllContents(); + while (!found && allContents.hasNext()) { + var eObject = allContents.next(); + for (EClassifier it : eClassifiers) { + found = it.isInstance(eObject); + if (found) { + break; + } + } + } + return found; + } + + private boolean containsDirectlyOrIndirectlyInstancesOf(EObject eObject, List eClassifiers) { + boolean found = false; + final Iterator allContents = eObject.eAllContents(); + while (!found && allContents.hasNext()) { + var content = allContents.next(); + for (EClassifier it : eClassifiers) { + found = it.isInstance(content); + if (found) { + break; + } + } + } + return found; + } + + private String getResourceName(Resource resource) { + return resource.eAdapters().stream() + .filter(ResourceMetadataAdapter.class::isInstance) + .map(ResourceMetadataAdapter.class::cast) + .findFirst() + .map(ResourceMetadataAdapter::getName) + .orElse(resource.getURI().lastSegment()); + } + + private String getElementName(Object element) { + String elementName = ""; + if (element instanceof Resource resource) { + elementName = this.getResourceName(resource); + } else if (element instanceof ISysONExplorerFragment fragment) { + elementName = fragment.getLabel(); + } + return elementName; + } + + private int getSelectionDialogRootSortRank(Object element) { + int rank = Integer.MAX_VALUE; + if (element instanceof Resource) { + rank = 0; + } else if (element instanceof ISysONExplorerFragment) { + rank = 1; + } + return rank; + } +} diff --git a/backend/services/syson-tree-services/src/main/java/org/eclipse/syson/tree/services/aql/TreeQueryAQLService.java b/backend/services/syson-tree-services/src/main/java/org/eclipse/syson/tree/services/aql/TreeQueryAQLService.java index 41ca52ebf..0ec4d427b 100644 --- a/backend/services/syson-tree-services/src/main/java/org/eclipse/syson/tree/services/aql/TreeQueryAQLService.java +++ b/backend/services/syson-tree-services/src/main/java/org/eclipse/syson/tree/services/aql/TreeQueryAQLService.java @@ -15,9 +15,13 @@ import java.util.List; import java.util.Objects; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; import org.eclipse.sirius.components.core.api.IEditingContext; import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata; +import org.eclipse.syson.sysml.Type; import org.eclipse.syson.tree.explorer.services.api.ISysONExplorerService; +import org.eclipse.syson.tree.services.TreeQuerySelectionDialogService; /** * Entry point for all tree-related services doing queries in trees and called by AQL expressions in tree descriptions. @@ -28,75 +32,233 @@ public class TreeQueryAQLService { private final ISysONExplorerService sysonExplorerService; - public TreeQueryAQLService(ISysONExplorerService sysonExplorerService) { + private final TreeQuerySelectionDialogService treeQuerySelectionDialogService; + + /** + * Creates a new tree query AQL service. + * + * @param sysonExplorerService + * the SysON explorer query service + * @param treeQuerySelectionDialogService + * the selection dialog query service + */ + public TreeQueryAQLService(ISysONExplorerService sysonExplorerService, TreeQuerySelectionDialogService treeQuerySelectionDialogService) { this.sysonExplorerService = Objects.requireNonNull(sysonExplorerService); + this.treeQuerySelectionDialogService = Objects.requireNonNull(treeQuerySelectionDialogService); } - public String getTreeItemId(Object self) { - return this.sysonExplorerService.getTreeItemId(self); + public boolean isEditable(Object self) { + return this.sysonExplorerService.isEditable(self); } - public String getTreeItemTooltip(Object self) { - return this.sysonExplorerService.getTreeItemTooltip(self); + public boolean isDeletable(Object self) { + return this.sysonExplorerService.isDeletable(self); + } + + public boolean isSelectable(Object self) { + return this.sysonExplorerService.isSelectable(self); + } + + public List getChildren(Object self, IEditingContext editingContext, List existingRepresentations, List expandedIds, List activeFilterIds) { + return this.sysonExplorerService.getChildren(self, editingContext, existingRepresentations, expandedIds, activeFilterIds); } public String getKind(Object self) { return this.sysonExplorerService.getKind(self); } + public List getImageURL(Object self) { + return this.sysonExplorerService.getImageURL(self); + } + public String getLabel(Object self) { return this.sysonExplorerService.getLabel(self); } - public boolean isEditable(Object self) { - return this.sysonExplorerService.isEditable(self); + public String getLibraryLabel(Object self) { + return this.sysonExplorerService.getLibraryLabel(self); } - public boolean isDeletable(Object self) { - return this.sysonExplorerService.isDeletable(self); + public Object getParent(Object self, String treeItemId, IEditingContext editingContext) { + return this.sysonExplorerService.getParent(self, treeItemId, editingContext); } - public boolean isSelectable(Object self) { - return this.sysonExplorerService.isSelectable(self); + public String getReadOnlyTag(Object self) { + return this.sysonExplorerService.getReadOnlyTag(self); } - public List getImageURL(Object self) { - return this.sysonExplorerService.getImageURL(self); + public String getShortName(Object self) { + return this.sysonExplorerService.getShortName(self); + } + + public String getTreeItemId(Object self) { + return this.sysonExplorerService.getTreeItemId(self); } public Object getTreeItemObject(String treeItemId, IEditingContext editingContext) { return this.sysonExplorerService.getTreeItemObject(treeItemId, editingContext); } - public Object getParent(Object self, String treeItemId, IEditingContext editingContext) { - return this.sysonExplorerService.getParent(self, treeItemId, editingContext); + public String getTreeItemTooltip(Object self) { + return this.sysonExplorerService.getTreeItemTooltip(self); } - public boolean hasChildren(Object self, IEditingContext editingContext, List existingRepresentations, List expandedIds, List activeFilterIds) { - return this.sysonExplorerService.hasChildren(self, editingContext, existingRepresentations, expandedIds, activeFilterIds); + public String getType(Object self) { + return this.sysonExplorerService.getType(self); } - public List getChildren(Object self, IEditingContext editingContext, List existingRepresentations, List expandedIds, List activeFilterIds) { - return this.sysonExplorerService.getChildren(self, editingContext, existingRepresentations, expandedIds, activeFilterIds); + public boolean hasChildren(Object self, IEditingContext editingContext, List existingRepresentations, List expandedIds, List activeFilterIds) { + return this.sysonExplorerService.hasChildren(self, editingContext, existingRepresentations, expandedIds, activeFilterIds); } public List getElements(IEditingContext editingContext, List activeFilterIds) { return this.sysonExplorerService.getElements(editingContext, activeFilterIds); } - public String getType(Object self) { - return this.sysonExplorerService.getType(self); + /** + * {@link TreeQuerySelectionDialogService#getActionReferenceSelectionDialogChildren(Object, IEditingContext, List)}. + */ + public List getActionReferenceSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { + return this.treeQuerySelectionDialogService.getActionReferenceSelectionDialogChildren(selectionDialogTreeElement, editingContext, expandedIds); } - public String getShortName(Object self) { - return this.sysonExplorerService.getShortName(self); + /** + * {@link TreeQuerySelectionDialogService#getActionReferenceSelectionDialogElements(IEditingContext)}. + */ + public List getActionReferenceSelectionDialogElements(IEditingContext editingContext) { + return this.treeQuerySelectionDialogService.getActionReferenceSelectionDialogElements(editingContext); } - public String getReadOnlyTag(Object self) { - return this.sysonExplorerService.getReadOnlyTag(self); + /** + * {@link TreeQuerySelectionDialogService#getActorSelectionDialogChildren(Object, IEditingContext, List)}. + */ + public List getActorSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { + return this.treeQuerySelectionDialogService.getActorSelectionDialogChildren(selectionDialogTreeElement, editingContext, expandedIds); } - public String getLibraryLabel(Object self) { - return this.sysonExplorerService.getLibraryLabel(self); + /** + * {@link TreeQuerySelectionDialogService#getActorSelectionDialogElements(IEditingContext)}. + */ + public List getActorSelectionDialogElements(IEditingContext editingContext) { + return this.treeQuerySelectionDialogService.getActorSelectionDialogElements(editingContext); + } + + /** + * {@link TreeQuerySelectionDialogService#getConcernReferenceSelectionDialogChildren(Object, IEditingContext, List)}. + */ + public List getConcernReferenceSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { + return this.treeQuerySelectionDialogService.getConcernReferenceSelectionDialogChildren(selectionDialogTreeElement, editingContext, expandedIds); + } + + /** + * {@link TreeQuerySelectionDialogService#getConcernReferenceSelectionDialogElements(IEditingContext)}. + */ + public List getConcernReferenceSelectionDialogElements(IEditingContext editingContext) { + return this.treeQuerySelectionDialogService.getConcernReferenceSelectionDialogElements(editingContext); + } + + /** + * {@link TreeQuerySelectionDialogService#getConstraintReferenceSelectionDialogChildren(Object, IEditingContext, List)}. + */ + public List getConstraintReferenceSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { + return this.treeQuerySelectionDialogService.getConstraintReferenceSelectionDialogChildren(selectionDialogTreeElement, editingContext, expandedIds); + } + + /** + * {@link TreeQuerySelectionDialogService#getConstraintReferenceSelectionDialogElements(IEditingContext)}. + */ + public List getConstraintReferenceSelectionDialogElements(IEditingContext editingContext) { + return this.treeQuerySelectionDialogService.getConstraintReferenceSelectionDialogElements(editingContext); + } + + /** + * {@link TreeQuerySelectionDialogService#getExhibitStateSelectionDialogChildren(Object, IEditingContext, List)}. + */ + public List getExhibitStateSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { + return this.treeQuerySelectionDialogService.getExhibitStateSelectionDialogChildren(selectionDialogTreeElement, editingContext, expandedIds); + } + + /** + * {@link TreeQuerySelectionDialogService#getExhibitStateSelectionDialogElements(IEditingContext)}. + */ + public List getExhibitStateSelectionDialogElements(IEditingContext editingContext) { + return this.treeQuerySelectionDialogService.getExhibitStateSelectionDialogElements(editingContext); + } + + /** + * {@link TreeQuerySelectionDialogService#getPortionKindSelectionDialogElement(Type)}. + */ + public EClass getPortionKindSelectionDialogElement(Type type) { + return this.treeQuerySelectionDialogService.getPortionKindSelectionDialogElement(type); + } + + /** + * {@link TreeQuerySelectionDialogService#getNamespaceImportSelectionDialogChildren(Object, IEditingContext, List)}. + */ + public List getNamespaceImportSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { + return this.treeQuerySelectionDialogService.getNamespaceImportSelectionDialogChildren(selectionDialogTreeElement, editingContext, expandedIds); + } + + /** + * {@link TreeQuerySelectionDialogService#getNamespaceImportSelectionDialogElements(IEditingContext)}. + */ + public List getNamespaceImportSelectionDialogElements(IEditingContext editingContext) { + return this.treeQuerySelectionDialogService.getNamespaceImportSelectionDialogElements(editingContext); + } + + /** + * {@link TreeQuerySelectionDialogService#getObjectiveRequirementSelectionDialogChildren(Object, IEditingContext, List)}. + */ + public List getObjectiveRequirementSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { + return this.treeQuerySelectionDialogService.getObjectiveRequirementSelectionDialogChildren(selectionDialogTreeElement, editingContext, expandedIds); + } + + /** + * {@link TreeQuerySelectionDialogService#getObjectiveRequirementSelectionDialogElements(IEditingContext)}. + */ + public List getObjectiveRequirementSelectionDialogElements(IEditingContext editingContext) { + return this.treeQuerySelectionDialogService.getObjectiveRequirementSelectionDialogElements(editingContext); + } + + /** + * {@link TreeQuerySelectionDialogService#getStakeholderSelectionDialogChildren(Object, IEditingContext, List)}. + */ + public List getStakeholderSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { + return this.treeQuerySelectionDialogService.getStakeholderSelectionDialogChildren(selectionDialogTreeElement, editingContext, expandedIds); + } + + /** + * {@link TreeQuerySelectionDialogService#getStakeholderSelectionDialogElements(IEditingContext)}. + */ + public List getStakeholderSelectionDialogElements(IEditingContext editingContext) { + return this.treeQuerySelectionDialogService.getStakeholderSelectionDialogElements(editingContext); + } + + /** + * {@link TreeQuerySelectionDialogService#getSubjectSelectionDialogChildren(Object, IEditingContext, List)}. + */ + public List getSubjectSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { + return this.treeQuerySelectionDialogService.getSubjectSelectionDialogChildren(selectionDialogTreeElement, editingContext, expandedIds); + } + + /** + * {@link TreeQuerySelectionDialogService#getSubjectSelectionDialogElements(IEditingContext)}. + */ + public List getSubjectSelectionDialogElements(IEditingContext editingContext) { + return this.treeQuerySelectionDialogService.getSubjectSelectionDialogElements(editingContext); + } + + /** + * {@link TreeQuerySelectionDialogService#getSelectionDialogChildren(Object, IEditingContext, List, List)}. + */ + public List getSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds, List candidates) { + return this.treeQuerySelectionDialogService.getSelectionDialogChildren(selectionDialogTreeElement, editingContext, expandedIds, candidates); + } + + /** + * {@link TreeQuerySelectionDialogService#getSelectionDialogElements(IEditingContext, List)}. + */ + public List getSelectionDialogElements(IEditingContext editingContext, List candidates) { + return this.treeQuerySelectionDialogService.getSelectionDialogElements(editingContext, candidates); } } diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/edges/AbstractDefinitionOwnedUsageEdgeDescriptionProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/edges/AbstractDefinitionOwnedUsageEdgeDescriptionProvider.java index ee70c7c1a..8beb00d15 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/edges/AbstractDefinitionOwnedUsageEdgeDescriptionProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/edges/AbstractDefinitionOwnedUsageEdgeDescriptionProvider.java @@ -30,7 +30,6 @@ import org.eclipse.sirius.components.view.diagram.LineStyle; import org.eclipse.sirius.components.view.diagram.NodeDescription; import org.eclipse.sirius.components.view.diagram.SynchronizationPolicy; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; import org.eclipse.syson.diagram.services.aql.DiagramQueryAQLService; import org.eclipse.syson.util.AQLConstants; @@ -114,7 +113,7 @@ protected boolean isDeletable() { @Override protected DeleteTool getEdgeDeleteTool() { var changeContext = this.viewBuilderHelper.newChangeContext() - .expression(ServiceMethod.of0(ViewToolService::moveToClosestContainingPackage).aql(org.eclipse.sirius.components.diagrams.description.EdgeDescription.SEMANTIC_EDGE_TARGET)); + .expression(ServiceMethod.of0(DiagramMutationAQLService::moveToClosestContainingPackage).aql(org.eclipse.sirius.components.diagrams.description.EdgeDescription.SEMANTIC_EDGE_TARGET)); return this.diagramBuilderHelper.newDeleteTool() .name("Delete from Model") diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/edges/AbstractUsageNestedUsageEdgeDescriptionProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/edges/AbstractUsageNestedUsageEdgeDescriptionProvider.java index d51f2b6fd..134185270 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/edges/AbstractUsageNestedUsageEdgeDescriptionProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/edges/AbstractUsageNestedUsageEdgeDescriptionProvider.java @@ -31,7 +31,6 @@ import org.eclipse.sirius.components.view.diagram.LineStyle; import org.eclipse.sirius.components.view.diagram.NodeDescription; import org.eclipse.sirius.components.view.diagram.SynchronizationPolicy; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; import org.eclipse.syson.diagram.services.aql.DiagramQueryAQLService; import org.eclipse.syson.util.AQLConstants; @@ -140,7 +139,7 @@ protected boolean isDeletable() { @Override protected DeleteTool getEdgeDeleteTool() { var changeContext = this.viewBuilderHelper.newChangeContext() - .expression(ServiceMethod.of0(ViewToolService::moveToClosestContainingPackage).aql(org.eclipse.sirius.components.diagrams.description.EdgeDescription.SEMANTIC_EDGE_TARGET)); + .expression(ServiceMethod.of0(DiagramMutationAQLService::moveToClosestContainingPackage).aql(org.eclipse.sirius.components.diagrams.description.EdgeDescription.SEMANTIC_EDGE_TARGET)); return this.diagramBuilderHelper.newDeleteTool() .name("Delete from Model") diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/edges/AnnotationEdgeDescriptionProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/edges/AnnotationEdgeDescriptionProvider.java index f0a426f75..4d8346ec6 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/edges/AnnotationEdgeDescriptionProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/edges/AnnotationEdgeDescriptionProvider.java @@ -26,7 +26,7 @@ import org.eclipse.sirius.components.view.diagram.LineStyle; import org.eclipse.sirius.components.view.diagram.NodeDescription; import org.eclipse.sirius.components.view.diagram.SynchronizationPolicy; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; import org.eclipse.syson.services.UtilService; import org.eclipse.syson.sysml.SysmlPackage; import org.eclipse.syson.util.AQLConstants; @@ -108,7 +108,7 @@ protected ChangeContextBuilder getSourceReconnectToolBody() { @Override protected ChangeContextBuilder getTargetReconnectToolBody() { return this.viewBuilderHelper.newChangeContext() - .expression(ServiceMethod.of1(ViewToolService::reconnnectTargetAnnotatedEdge) + .expression(ServiceMethod.of1(DiagramMutationAQLService::reconnnectTargetAnnotatedEdge) .aql(AQLConstants.EDGE_SEMANTIC_ELEMENT, AQLConstants.SEMANTIC_RECONNECTION_TARGET)); } diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewEdgeToolService.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewEdgeToolService.java index c8ccc8ad1..c157463b5 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewEdgeToolService.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewEdgeToolService.java @@ -539,7 +539,7 @@ public EdgeTool createAddAsNestedEdgeTool(NodeDescription targetElementDescripti var builder = this.diagramBuilderHelper.newEdgeTool(); var callService = this.viewBuilderHelper.newChangeContext() - .expression(ServiceMethod.of1(ViewToolService::becomeNestedUsage).aql(EdgeDescription.SEMANTIC_EDGE_TARGET, EdgeDescription.SEMANTIC_EDGE_SOURCE)); + .expression(ServiceMethod.of1(DiagramMutationAQLService::becomeNestedUsage).aql(EdgeDescription.SEMANTIC_EDGE_TARGET, EdgeDescription.SEMANTIC_EDGE_SOURCE)); return builder .name(this.nameGenerator.getCreationToolName("Add as nested ", SysMLMetamodelHelper.toEClass(targetElementDescription.getDomainType()))) @@ -553,7 +553,7 @@ public EdgeTool createBecomeNestedElementEdgeTool(EClass eClass, List t var builder = this.diagramBuilderHelper.newEdgeTool(); var callService = this.viewBuilderHelper.newChangeContext() - .expression(ServiceMethod.of1(ViewToolService::becomeObjectiveRequirement).aql(EdgeDescription.SEMANTIC_EDGE_SOURCE, EdgeDescription.SEMANTIC_EDGE_TARGET)); + .expression(ServiceMethod.of1(DiagramMutationAQLService::becomeObjectiveRequirement).aql(EdgeDescription.SEMANTIC_EDGE_SOURCE, EdgeDescription.SEMANTIC_EDGE_TARGET)); return builder .name(this.nameGenerator.getCreationToolName("Become objective", SysmlPackage.eINSTANCE.getRequirementUsage())) diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewToolService.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewToolService.java deleted file mode 100644 index 9631abaf4..000000000 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewToolService.java +++ /dev/null @@ -1,925 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2023, 2026 Obeo. - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Obeo - initial API and implementation - *******************************************************************************/ -package org.eclipse.syson.diagram.common.view.services; - -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.Objects; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.sirius.components.collaborative.diagrams.DiagramContext; -import org.eclipse.sirius.components.core.api.IEditingContext; -import org.eclipse.sirius.components.core.api.IFeedbackMessageService; -import org.eclipse.sirius.components.core.api.IIdentityService; -import org.eclipse.sirius.components.core.api.ILabelService; -import org.eclipse.sirius.components.core.api.IObjectSearchService; -import org.eclipse.sirius.components.core.api.labels.StyledString; -import org.eclipse.sirius.components.diagrams.Node; -import org.eclipse.sirius.components.emf.ResourceMetadataAdapter; -import org.eclipse.sirius.components.representations.Message; -import org.eclipse.sirius.components.representations.MessageLevel; -import org.eclipse.sirius.components.view.emf.IViewRepresentationDescriptionSearchService; -import org.eclipse.syson.services.ToolService; -import org.eclipse.syson.services.api.ISysMLMoveElementService; -import org.eclipse.syson.services.api.MoveStatus; -import org.eclipse.syson.services.api.ViewDefinitionKind; -import org.eclipse.syson.sysml.ActionDefinition; -import org.eclipse.syson.sysml.ActionUsage; -import org.eclipse.syson.sysml.ActorMembership; -import org.eclipse.syson.sysml.AllocationDefinition; -import org.eclipse.syson.sysml.CaseDefinition; -import org.eclipse.syson.sysml.CaseUsage; -import org.eclipse.syson.sysml.Comment; -import org.eclipse.syson.sysml.ConnectionDefinition; -import org.eclipse.syson.sysml.ConstraintDefinition; -import org.eclipse.syson.sysml.Definition; -import org.eclipse.syson.sysml.Documentation; -import org.eclipse.syson.sysml.Element; -import org.eclipse.syson.sysml.FeatureMembership; -import org.eclipse.syson.sysml.ItemDefinition; -import org.eclipse.syson.sysml.Membership; -import org.eclipse.syson.sysml.ObjectiveMembership; -import org.eclipse.syson.sysml.OwningMembership; -import org.eclipse.syson.sysml.Package; -import org.eclipse.syson.sysml.PartDefinition; -import org.eclipse.syson.sysml.PartUsage; -import org.eclipse.syson.sysml.RequirementDefinition; -import org.eclipse.syson.sysml.RequirementUsage; -import org.eclipse.syson.sysml.StakeholderMembership; -import org.eclipse.syson.sysml.StateDefinition; -import org.eclipse.syson.sysml.StateUsage; -import org.eclipse.syson.sysml.SubjectMembership; -import org.eclipse.syson.sysml.SysmlFactory; -import org.eclipse.syson.sysml.SysmlPackage; -import org.eclipse.syson.sysml.Type; -import org.eclipse.syson.sysml.Usage; -import org.eclipse.syson.sysml.UseCaseDefinition; -import org.eclipse.syson.sysml.UseCaseUsage; -import org.eclipse.syson.sysml.ViewDefinition; -import org.eclipse.syson.sysml.ViewUsage; -import org.eclipse.syson.tree.explorer.services.api.ISysONExplorerFragment; -import org.eclipse.syson.tree.explorer.services.api.ISysONExplorerService; -import org.eclipse.syson.util.StandardDiagramsConstants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Tool-related Java services used by all diagrams. - * - * @author arichard - */ -public class ViewToolService extends ToolService { - - protected final IViewRepresentationDescriptionSearchService viewRepresentationDescriptionSearchService; - - protected final ISysONExplorerService sysONExplorerService; - - protected final Logger logger = LoggerFactory.getLogger(ViewToolService.class); - - private final ILabelService labelService; - - public ViewToolService(IIdentityService identityService, IObjectSearchService objectSearchService, IViewRepresentationDescriptionSearchService viewRepresentationDescriptionSearchService, - IFeedbackMessageService feedbackMessageService, ISysMLMoveElementService moveService, ISysONExplorerService sysONExplorerService, ILabelService labelService) { - super(identityService, objectSearchService, feedbackMessageService, moveService); - this.viewRepresentationDescriptionSearchService = Objects.requireNonNull(viewRepresentationDescriptionSearchService); - this.sysONExplorerService = Objects.requireNonNull(sysONExplorerService); - this.labelService = Objects.requireNonNull(labelService); - } - - /** - * Tool precondition for control node actions (Start/Done/Decision/Fork/Join/Merge) invoked on diagram background. - * - * @param element - * the given {@link Element}. - * @return true if the tool should be available, false otherwise. - */ - public boolean isControlNodeActionCreationToolInsideActionOnAFV(Element element, IEditingContext editingContext, DiagramContext diagramContext) { - if (this.isAFVDiagram(editingContext, diagramContext)) { - var owner = this.utilService.getViewUsageOwner(element); - return owner instanceof ActionUsage || owner instanceof ActionDefinition; - } - return false; - } - - /** - * Tool precondition for control node actions (Start/Done/Decision/Fork/Join/Merge) invoked on a selected node. - * - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @param selectedNode - * the selected node. It corresponds to a variable accessible from the variable - * manager. - * @return true if the tool should be available, false otherwise. - */ - public boolean isControlNodeActionCreationToolInAction(IEditingContext editingContext, Node selectedNode) { - return this.objectSearchService.getObject(editingContext, selectedNode.getTargetObjectId()) - .map(object -> { - return object instanceof ActionUsage || object instanceof ActionDefinition; - }).orElse(false); - } - - private boolean isAFVDiagram(IEditingContext editingContext, DiagramContext diagramContext) { - var objectId = diagramContext.diagram().getTargetObjectId(); - return this.objectSearchService.getObject(editingContext, objectId) - .map(object -> { - if (object instanceof ViewUsage viewUsage) { - if (!viewUsage.getType().isEmpty()) { - Type type = viewUsage.getType().getFirst(); - return type instanceof ViewDefinition && StandardDiagramsConstants.AFV_QN.equals(type.getQualifiedName()); - } - } - return false; - }).orElse(false); - } - - /** - * Check if a tool that will create an instance of the given type should be available for a diagram associated to - * the given {@link Element}. - * - * @param element - * the given {@link Element}. - * @param newElementType - * the given type. - * @return true if the tool should be available, false otherwise. - */ - public boolean toolShouldBeAvailable(Element element, IEditingContext editingContext, DiagramContext diagramContext, EClass newElementType) { - ViewDefinitionKind viewDefinitionKind = this.utilService.getViewDefinitionKind(element, List.of(), editingContext); - var elt = this.utilService.getViewUsageOwner(element); - - return switch (viewDefinitionKind) { - case INTERCONNECTION_VIEW -> this.toolShouldBeAvailableOnInterconnectionView(elt, newElementType); - case ACTION_FLOW_VIEW -> this.toolShouldBeAvailableOnActionFlowView(elt, newElementType); - case STATE_TRANSITION_VIEW -> this.toolShouldBeAvailableOnStateTransitionView(elt, newElementType); - default -> this.toolShouldBeAvailableOnGeneralView(elt, newElementType); - }; - } - - private boolean toolShouldBeAvailableOnGeneralView(Element element, EClass domainClass) { - boolean toolShouldBeAvailable = false; - if (element instanceof Package) { - toolShouldBeAvailable = true; - } else if (element instanceof Usage && !SysmlPackage.eINSTANCE.getDefinition().isSuperTypeOf(domainClass)) { - toolShouldBeAvailable = true; - } else if (element instanceof Definition && !SysmlPackage.eINSTANCE.getDefinition().isSuperTypeOf(domainClass)) { - toolShouldBeAvailable = true; - } - return toolShouldBeAvailable; - } - - private boolean toolShouldBeAvailableOnInterconnectionView(Element element, EClass domainClass) { - boolean toolShouldBeAvailable = false; - if (element instanceof Package) { - toolShouldBeAvailable = true; - if (SysmlPackage.eINSTANCE.getAttributeUsage().isSuperTypeOf(domainClass)) { - toolShouldBeAvailable = false; - } else if (SysmlPackage.eINSTANCE.getPortUsage().isSuperTypeOf(domainClass)) { - toolShouldBeAvailable = false; - } - } else if (element instanceof Usage && !SysmlPackage.eINSTANCE.getDefinition().isSuperTypeOf(domainClass)) { - toolShouldBeAvailable = true; - } else if (element instanceof Definition && !SysmlPackage.eINSTANCE.getDefinition().isSuperTypeOf(domainClass)) { - toolShouldBeAvailable = true; - } - return toolShouldBeAvailable; - } - - private boolean toolShouldBeAvailableOnActionFlowView(Element element, EClass domainClass) { - boolean toolShouldBeAvailable = false; - if (element instanceof ActionUsage) { - toolShouldBeAvailable = !SysmlPackage.eINSTANCE.getDefinition().isSuperTypeOf(domainClass); - } else if (element instanceof ActionDefinition) { - toolShouldBeAvailable = !SysmlPackage.eINSTANCE.getDefinition().isSuperTypeOf(domainClass); - } else { - if (SysmlPackage.eINSTANCE.getActionUsage().equals(domainClass) || SysmlPackage.eINSTANCE.getActionUsage().isSuperTypeOf(domainClass)) { - toolShouldBeAvailable = true; - } else if (SysmlPackage.eINSTANCE.getActionDefinition().equals(domainClass) || SysmlPackage.eINSTANCE.getActionDefinition().isSuperTypeOf(domainClass)) { - toolShouldBeAvailable = true; - } - } - return toolShouldBeAvailable; - } - - private boolean toolShouldBeAvailableOnStateTransitionView(Element element, EClass domainClass) { - boolean toolShouldBeAvailable = false; - if (element instanceof StateUsage) { - toolShouldBeAvailable = !SysmlPackage.eINSTANCE.getDefinition().isSuperTypeOf(domainClass); - } else if (element instanceof StateDefinition) { - toolShouldBeAvailable = !SysmlPackage.eINSTANCE.getDefinition().isSuperTypeOf(domainClass); - } else { - if (SysmlPackage.eINSTANCE.getStateUsage().equals(domainClass) || SysmlPackage.eINSTANCE.getStateUsage().isSuperTypeOf(domainClass)) { - toolShouldBeAvailable = true; - } else if (SysmlPackage.eINSTANCE.getStateDefinition().equals(domainClass) || SysmlPackage.eINSTANCE.getStateDefinition().isSuperTypeOf(domainClass)) { - toolShouldBeAvailable = true; - } - } - return toolShouldBeAvailable; - } - - public Usage becomeNestedUsage(Usage usage, Element newContainer) { - if (this.getOwnerHierarchy(newContainer).contains(usage) || Objects.equals(newContainer, usage)) { - String message = MessageFormat.format("Cannot change the owner of {0}, this would create a containment cycle", String.valueOf(usage.getName())); - this.feedbackMessageService.addFeedbackMessage(new Message(message, MessageLevel.WARNING)); - this.logger.warn(message); - } else { - MoveStatus moveStatus = this.moveService.moveSemanticElement(usage, newContainer); - if (moveStatus.isSuccess()) { - usage.setIsComposite(true); - } else { - this.feedbackMessageService.addFeedbackMessage(new Message(MessageFormat.format("Unable to move {0} in {1}: {2}", this.getLabel(usage), this.getLabel(newContainer), moveStatus.message()), MessageLevel.WARNING)); - } - - } - return usage; - } - - public RequirementUsage becomeObjectiveRequirement(RequirementUsage requirement, Element newContainer) { - if (newContainer instanceof UseCaseUsage || newContainer instanceof UseCaseDefinition) { - if (this.utilService.isEmptyObjectiveRequirement(newContainer)) { - var eContainer = requirement.eContainer(); - if (eContainer instanceof ObjectiveMembership objectiveMembership) { - // requirement is already an objective of another usecaseXXX - newContainer.getOwnedRelationship().add(objectiveMembership); - } else if (eContainer instanceof OwningMembership owningMembership) { - var newObjectiveMembership = SysmlFactory.eINSTANCE.createObjectiveMembership(); - newObjectiveMembership.getOwnedRelatedElement().add(requirement); - newContainer.getOwnedRelationship().add(newObjectiveMembership); - this.deleteService.deleteFromModel(owningMembership); - } - } - } - return requirement; - } - - /** - * Reconnects the source of a nested actor edge. - *

- * The source of this edge is either an UseCase or a Requirement, and can only be reconnected to UseCase or - * Requirements. - *

- * - * @param self - * the current UseCase or Requirement - * @param newSource - * the new UseCase or Requirement - * @param otherEnd - * the Actor connected to the UseCase or Requirement - * @return the Actor - */ - public Element reconnectSourceNestedActorEdge(Element self, Element newSource, Element otherEnd) { - if (newSource instanceof UseCaseUsage || newSource instanceof UseCaseDefinition - || newSource instanceof RequirementUsage || newSource instanceof RequirementDefinition) { - if (otherEnd.getOwningMembership() instanceof ActorMembership actorMembership) { - newSource.getOwnedRelationship().add(actorMembership); - } else { - // This is an error, an Actor should always be contained in an ActorMembership. - String errorMessage = "Cannot reconnect the Actor, it is not owned by an " + ActorMembership.class.getSimpleName(); - this.logger.error(errorMessage); - this.feedbackMessageService.addFeedbackMessage(new Message(errorMessage, MessageLevel.ERROR)); - } - } else { - String errorMessage = "Cannot reconnect an Actor to a non-UseCase, non-Requirement element"; - this.logger.warn(errorMessage); - this.feedbackMessageService.addFeedbackMessage(new Message(errorMessage, MessageLevel.WARNING)); - } - return otherEnd; - } - - /** - * Reconnects the target of a nested actor edge (the Actor side of the edge). - * This service is only used because edge preconditions are not taken into account. - * - * @param self - * the current UseCase or Requirement - * @return the given self - */ - public Element reconnectTargetNestedActorEdge(Element self) { - // due to https://github.com/eclipse-sirius/sirius-web/issues/2930 we cannot prevent the user to do the reconnect, - // so we just warn him/her that this is not possible. - String errorMessage = "An Actor cannot be disconnected from its UseCase or its Requirement element"; - this.logger.warn(errorMessage); - this.feedbackMessageService.addFeedbackMessage(new Message(errorMessage, MessageLevel.WARNING)); - return self; - } - - /** - * Reconnects the source of a nested stakeholder edge. - *

- * The source of this edge is a Requirement, and can only be reconnected to Requirements. - *

- * - * @param self - * the current Requirement - * @param newSource - * the new Requirement - * @param otherEnd - * the Stakeholder connected to the Requirement - * @return the Stakeholder - */ - public Element reconnectSourceNestedStakeholderEdge(Element self, Element newSource, Element otherEnd) { - if (newSource instanceof RequirementUsage || newSource instanceof RequirementDefinition) { - if (otherEnd.getOwningMembership() instanceof StakeholderMembership stakeholderMembership) { - newSource.getOwnedRelationship().add(stakeholderMembership); - } else { - // This is an error, a Stakeholder should always be contained in a StakeholderMembership. - String errorMessage = "Cannot reconnect the Stakeholder, it is not owned by a " + StakeholderMembership.class.getSimpleName(); - this.logger.error(errorMessage); - this.feedbackMessageService.addFeedbackMessage(new Message(errorMessage, MessageLevel.ERROR)); - } - } else { - String errorMessage = "Cannot reconnect a Stakeholder to a non-Requirement element"; - this.logger.warn(errorMessage); - this.feedbackMessageService.addFeedbackMessage(new Message(errorMessage, MessageLevel.WARNING)); - } - return otherEnd; - } - - /** - * Reconnects the source of a nested subject edge. - *

- * The source of this edge is either an UseCase or a Requirement, and can only be reconnected to UseCase or - * Requirements. - *

- * - * @param self - * the current UseCase or Requirement - * @param newSource - * the new UseCase or Requirement - * @param otherEnd - * the Subject connected to the UseCase or Requirement - * @return the Subject - */ - public Element reconnectSourceNestedSubjectEdge(Element self, Element newSource, Element otherEnd) { - if (newSource instanceof CaseUsage || newSource instanceof CaseDefinition - || newSource instanceof RequirementUsage || newSource instanceof RequirementDefinition) { - if (otherEnd.getOwningMembership() instanceof SubjectMembership subjectMembership) { - newSource.getOwnedRelationship().add(subjectMembership); - } else { - // This is an error, an Subject should always be contained in an ActorMembership. - String errorMessage = "Cannot reconnect the Subject, it is not owned by a " + SubjectMembership.class.getSimpleName(); - this.logger.error(errorMessage); - this.feedbackMessageService.addFeedbackMessage(new Message(errorMessage, MessageLevel.ERROR)); - } - } else { - String errorMessage = "Cannot reconnect a Subject to a non-UseCase, non-Requirement element"; - this.logger.warn(errorMessage); - this.feedbackMessageService.addFeedbackMessage(new Message(errorMessage, MessageLevel.WARNING)); - } - return otherEnd; - } - - public Element reconnnectSourceCompositionEdge(Element self, Element newSource, Element otherEnd) { - Element result = otherEnd; - if (this.getOwnerHierarchy(newSource).contains(otherEnd) || Objects.equals(newSource, otherEnd)) { - String message = MessageFormat.format("Cannot change the owner of {0}, this would create a containment cycle", String.valueOf(otherEnd.getName())); - this.feedbackMessageService.addFeedbackMessage(new Message(message, MessageLevel.WARNING)); - this.logger.warn(message); - } else { - MoveStatus moveStatus = this.moveService.moveSemanticElement(otherEnd, newSource); - if (!moveStatus.isSuccess()) { - this.feedbackMessageService.addFeedbackMessage(new Message(MessageFormat.format("Unable to move {0} in {1}: {2}", this.getLabel(self), this.getLabel(newSource), - moveStatus.message()), MessageLevel.WARNING)); - } - result = otherEnd; - } - return result; - } - - public Element reconnnectTargetCompositionEdge(Element self, Element oldTarget, Element newTarget, Element otherEnd) { - if (this.getOwnerHierarchy(otherEnd).contains(newTarget) || Objects.equals(otherEnd, newTarget)) { - String message = MessageFormat.format("Cannot change the owner of {0}, this would create a containment cycle", String.valueOf(otherEnd.getName())); - this.feedbackMessageService.addFeedbackMessage(new Message(message, MessageLevel.WARNING)); - this.logger.warn(message); - } else { - var oldContainer = oldTarget.eContainer(); - if (newTarget instanceof Usage && oldContainer instanceof FeatureMembership featureMembership) { - // Move the old target to the innermost package - // We don't use moveToClosestContainingPackage here because we are moving oldTarget in the closest - // containing package and updating newTarget at the same time. - var pack = this.getClosestContainingPackageFrom(self); - if (pack != null) { - var owningMembership = SysmlFactory.eINSTANCE.createOwningMembership(); - pack.getOwnedRelationship().add(owningMembership); - owningMembership.getOwnedRelatedElement().add(oldTarget); - // reuse feature membership of the previous nested - var oldMembership = newTarget.eContainer(); - featureMembership.getOwnedRelatedElement().add(newTarget); - if (oldMembership instanceof OwningMembership oldOwningMembership) { - this.deleteService.deleteFromModel(oldOwningMembership); - } - } - } - } - return self; - } - - /** - * Reconnects the annotation to the annotated element target. - *

- * The target of this edge can be all elements except a Documentation or a Comment. - *

- * - * @param self - * the current annotating element - * @param newTarget - * the new Annotated element - * @return the annotating element - */ - public Element reconnnectTargetAnnotatedEdge(Element self, Element newTarget) { - if (!(newTarget instanceof Comment) && !(newTarget instanceof Documentation)) { - MoveStatus moveStatus = this.moveService.moveSemanticElement(self, newTarget); - if (!moveStatus.isSuccess()) { - this.feedbackMessageService.addFeedbackMessage(new Message(MessageFormat.format("Unable to move {0} in {1}: {2}", this.getLabel(self), this.getLabel(newTarget), - moveStatus.message()), MessageLevel.WARNING)); - } - } - return self; - } - - /** - * Moves the provided {@code usage} in the closest containing package. - * - * @param usage - * the usage to move - * @return the moved element - */ - public Element moveToClosestContainingPackage(Usage usage) { - var pack = this.getClosestContainingPackageFrom(usage); - if (pack != null) { - var oldMembership = usage.eContainer(); - var owningMembership = SysmlFactory.eINSTANCE.createOwningMembership(); - pack.getOwnedRelationship().add(owningMembership); - owningMembership.getOwnedRelatedElement().add(usage); - if (oldMembership instanceof OwningMembership oldOwningMembership) { - this.deleteService.deleteFromModel(oldOwningMembership); - } - } - return usage; - } - - /** - * Service to retrieve the root elements of the selection dialog of the NamespaceImport creation tool. - * - * @param editingContext - * the editing context - * @return the list of resources that contain at least one {@link Package} - */ - public List getNamespaceImportSelectionDialogElements(IEditingContext editingContext) { - return this.getAllResourcesWithInstancesOf(editingContext, List.of(SysmlPackage.eINSTANCE.getPackage())); - } - - /** - * Service to retrieve the children of a given element in the selection dialog of the NamespaceImport creation tool. - * - * @param selectionDialogTreeElement - * a (non-{@code null}) selection dialog tree element. - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @param expandedIds - * the list of already expanded treeItems, by their Ids. - * @return the (non-{@code null}) {@link List} of all children that contain (possibly indirectly) or are - * {@link Package}. - */ - public List getNamespaceImportSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { - return this.getChildrenWithInstancesOf(selectionDialogTreeElement, editingContext, expandedIds, List.of(SysmlPackage.eINSTANCE.getPackage())); - - } - - /** - * Provides the root elements in the tree of the selection dialog for the StakeholderParameter creation tool. - * - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @return the (non-{@code null}) {@link List} of all {@link Resource} and {@link ISysONExplorerFragment} that - * contain at least one {@link PartUsage}. - */ - public List getStakeholderSelectionDialogElements(IEditingContext editingContext) { - return this.getAllResourcesWithInstancesOf(editingContext, List.of(SysmlPackage.eINSTANCE.getPartUsage())); - } - - /** - * Provides the children of element in the tree of the selection dialog for the StakeholderParameter creation tool. - * - * @param selectionDialogTreeElement - * a (non-{@code null}) selection dialog tree element. - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @param expandedIds - * the list of already expanded treeItems, by their Ids. - * @return the (non-{@code null}) {@link List} of all children that contain (possibly indirectly) or are - * {@link PartUsage}. - */ - public List getStakeholderSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { - return this.getChildrenWithInstancesOf(selectionDialogTreeElement, editingContext, expandedIds, List.of(SysmlPackage.eINSTANCE.getPartUsage())); - } - - /** - * Provides the root elements in the tree of the selection dialog for the SubjectParameter creation tool. - * - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @return the (non-{@code null}) {@link List} of all {@link Resource} and {@link ISysONExplorerFragment} that - * contain at least one {@link Type}. - */ - public List getSubjectSelectionDialogElements(IEditingContext editingContext) { - return this.getAllResourcesWithInstancesOf(editingContext, List.of(SysmlPackage.eINSTANCE.getType())); - } - - /** - * Provides the children of element in the tree of the selection dialog for the SubjectParameter creation tool. - * - * @param selectionDialogTreeElement - * a (non-{@code null}) selection dialog tree element. - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @param expandedIds - * the list of already expanded treeItems, by their Ids. - * @return the (non-{@code null}) {@link List} of all children that contain (possibly indirectly) or are - * {@link Usage}. - */ - public List getSubjectSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { - return this.getChildrenWithInstancesOf(selectionDialogTreeElement, editingContext, expandedIds, List.of(SysmlPackage.eINSTANCE.getType())); - } - - /** - * Provides the root elements in the tree of the selection dialog for the ActorParameter creation tool. - * - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @return the (non-{@code null}) {@link List} of all {@link Resource} and {@link ISysONExplorerFragment} that - * contain at least one {@link PartUsage} or {@link PartDefinition}. - */ - public List getActorSelectionDialogElements(IEditingContext editingContext) { - return this.getAllResourcesWithInstancesOf(editingContext, List.of(SysmlPackage.eINSTANCE.getPartUsage(), SysmlPackage.eINSTANCE.getPartDefinition())); - } - - /** - * Provides the children of element in the tree of the selection dialog for the Objective Requirement creation tool. - * - * @param selectionDialogTreeElement - * a (non-{@code null}) selection dialog tree element. - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @return the (non-{@code null}) {@link List} of all children that contain (possibly indirectly) or are - * {@link RequirementUsage} or {@link RequirementDefinition}. - */ - public List getObjectiveRequirementSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { - return this.getChildrenWithInstancesOf(selectionDialogTreeElement, editingContext, expandedIds, - List.of(SysmlPackage.eINSTANCE.getRequirementUsage(), SysmlPackage.eINSTANCE.getRequirementDefinition())); - } - - /** - * Provides the root elements in the tree of the selection dialog for the Objective Requirement creation tool. - * - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @return the (non-{@code null}) {@link List} of all {@link Resource} and {@link ISysONExplorerFragment} that - * contain at least one {@link RequirementUsage} or {@link RequirementDefinition}. - */ - public List getObjectiveRequirementSelectionDialogElements(IEditingContext editingContext) { - return this.getAllResourcesWithInstancesOf(editingContext, List.of(SysmlPackage.eINSTANCE.getRequirementUsage(), SysmlPackage.eINSTANCE.getRequirementDefinition())); - } - - /** - * Provides the children of element in the tree of the selection dialog for the ActorParameter creation tool. - * - * @param selectionDialogTreeElement - * a (non-{@code null}) selection dialog tree element. - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @return the (non-{@code null}) {@link List} of all children that contain (possibly indirectly) or are - * {@link PartUsage} or {@link PartDefinition}. - */ - public List getActorSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { - return this.getChildrenWithInstancesOf(selectionDialogTreeElement, editingContext, expandedIds, List.of(SysmlPackage.eINSTANCE.getPartUsage(), SysmlPackage.eINSTANCE.getPartDefinition())); - } - - /** - * Provides the root elements in the tree of the selection dialog for presenting all existing ActionUsage. - * - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @return the (non-{@code null}) {@link List} of all {@link Resource} and {@link ISysONExplorerFragment} that - * contain at least one {@link ActionUsage}. - */ - public List getActionReferenceSelectionDialogElements(IEditingContext editingContext) { - return this.getAllResourcesWithInstancesOf(editingContext, List.of(SysmlPackage.eINSTANCE.getActionUsage())); - } - - /** - * Provides the children of element in the tree of the selection dialog for presenting all existing ActionUsage. - * - * @param selectionDialogTreeElement - * a (non-{@code null}) selection dialog tree element. - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @param expandedIds - * the list of already expanded treeItems, by their Ids. - * @return the (non-{@code null}) {@link List} of all children that contain (possibly indirectly) an - * {@link ActionUsage}. - */ - public List getActionReferenceSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { - return this.getChildrenWithInstancesOf(selectionDialogTreeElement, editingContext, expandedIds, List.of(SysmlPackage.eINSTANCE.getActionUsage())); - } - - /** - * Provides the root elements in the tree of the selection dialog for presenting all existing StateUsage. - * - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @return the (non-{@code null}) {@link List} of all {@link Resource} and {@link ISysONExplorerFragment} that - * contain at least one {@link StateUsage}. - */ - public List getExhibitStateSelectionDialogElements(IEditingContext editingContext) { - return this.getAllResourcesWithInstancesOf(editingContext, List.of(SysmlPackage.eINSTANCE.getStateUsage())); - } - - /** - * Provides the children of element in the tree of the selection dialog for presenting all existing StateUsage. - * - * @param selectionDialogTreeElement - * a (non-{@code null}) selection dialog tree element. - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @param expandedIds - * the list of already expanded treeItems, by their Ids. - * @return the (non-{@code null}) {@link List} of all children that contain (possibly indirectly) an - * {@link StateUsage}. - */ - public List getExhibitStateSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { - return this.getChildrenWithInstancesOf(selectionDialogTreeElement, editingContext, expandedIds, List.of(SysmlPackage.eINSTANCE.getStateUsage())); - } - - /** - * Provides the root elements in the tree of the selection dialog for presenting all existing ConcernUsage. - * - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @return the (non-{@code null}) {@link List} of all {@link Resource} and {@link ISysONExplorerFragment} that - * contain at least one {@link org.eclipse.syson.sysml.ConcernUsage}. - */ - public List getConcernReferenceSelectionDialogElements(IEditingContext editingContext) { - return this.getAllResourcesWithInstancesOf(editingContext, List.of(SysmlPackage.eINSTANCE.getConcernUsage())); - } - - /** - * Provides the children of element in the tree of the selection dialog for presenting all existing ConcernUsage. - * - * @param selectionDialogTreeElement - * a (non-{@code null}) selection dialog tree element. - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @param expandedIds - * the list of already expanded treeItems, by their Ids. - * @return the (non-{@code null}) {@link List} of all children that contain (possibly indirectly) an - * {@link org.eclipse.syson.sysml.ConcernUsage}. - */ - public List getConcernReferenceSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { - return this.getChildrenWithInstancesOf(selectionDialogTreeElement, editingContext, expandedIds, List.of(SysmlPackage.eINSTANCE.getConcernUsage())); - } - - /** - * Provides the root elements in the tree of the selection dialog for presenting all existing ConstraintUsage. - * - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @return the (non-{@code null}) {@link List} of all {@link Resource} and {@link ISysONExplorerFragment} that - * contain at least one {@link org.eclipse.syson.sysml.ConstraintUsage}. - */ - public List getConstraintReferenceSelectionDialogElements(IEditingContext editingContext) { - return this.getAllResourcesWithInstancesOf(editingContext, List.of(SysmlPackage.eINSTANCE.getConstraintUsage())); - } - - /** - * Provides the children of element in the tree of the selection dialog for presenting all existing ConstraiNtUsage. - * - * @param selectionDialogTreeElement - * a (non-{@code null}) selection dialog tree element. - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @param expandedIds - * the list of already expanded treeItems, by their Ids. - * @return the (non-{@code null}) {@link List} of all children that contain (possibly indirectly) an - * {@link org.eclipse.syson.sysml.ConstraintUsage}. - */ - public List getConstraintReferenceSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds) { - return this.getChildrenWithInstancesOf(selectionDialogTreeElement, editingContext, expandedIds, List.of(SysmlPackage.eINSTANCE.getConstraintUsage())); - } - - - - /** - * Provides the root elements in the tree of the selection dialog for the any creation tool. - * - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @param candidates - * the EClassifier candidates. - * @return the (non-{@code null}) {@link List} of all {@link Resource} that contain at least one candidates. - */ - public List getSelectionDialogElements(IEditingContext editingContext, List candidates) { - return this.getAllResourcesWithInstancesOf(editingContext, candidates); - } - - /** - * Provides the children of element in the tree of the selection dialog for the ActorParameter creation tool. - * - * @param selectionDialogTreeElement - * a (non-{@code null}) selection dialog tree element. - * @param editingContext - * the (non-{@code null}) {@link IEditingContext}. - * @param expandedIds - * the list of already expanded treeItems, by their Ids. - * @param candidates - * the EClassifier candidates. - * @return the (non-{@code null}) {@link List} of all children that contain (possibly indirectly) or are candidates. - */ - public List getSelectionDialogChildren(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds, List candidates) { - return this.getChildrenWithInstancesOf(selectionDialogTreeElement, editingContext, expandedIds, candidates); - } - - /** - * Return the {@code Usage} {@link EClass} corresponding to the given {@link Type}. - * - * @param type - * the type we want the {@code Usage} {@link EClass} - * @return the {@code Usage} {@link EClass} corresponding to the given {@link Type} - */ - public EClass getPortionKindSelectionDialogElement(Type type) { - return switch (type) { - case AllocationDefinition a -> SysmlPackage.eINSTANCE.getAllocationUsage(); - case ConnectionDefinition c -> SysmlPackage.eINSTANCE.getConnectionUsage(); - case PartDefinition p -> SysmlPackage.eINSTANCE.getPartUsage(); - case ConstraintDefinition c -> SysmlPackage.eINSTANCE.getConstraintUsage(); - case ItemDefinition i -> SysmlPackage.eINSTANCE.getItemUsage(); - case Usage u -> u.eClass(); - default -> SysmlPackage.eINSTANCE.getOccurrenceUsage(); - }; - } - - protected List getAllResourcesWithInstancesOf(IEditingContext editingContext, List eClassifiers) { - var elementsContainingClassifiers = new ArrayList<>(); - List elements = this.sysONExplorerService.getElements(editingContext, List.of()); - for (Object rootElement : elements) { - if (rootElement instanceof Resource resource && this.containsDirectlyOrIndirectlyInstancesOf(resource, eClassifiers)) { - elementsContainingClassifiers.add(resource); - } else if (rootElement instanceof ISysONExplorerFragment fragment) { - elementsContainingClassifiers.add(fragment); - } - } - - return elementsContainingClassifiers.stream() - .sorted(Comparator.comparingInt(this::getSelectionDialogRootSortRank) - .thenComparing(this::getElementName, String.CASE_INSENSITIVE_ORDER)) - .toList(); - } - - protected List getChildrenWithInstancesOf(Object selectionDialogTreeElement, IEditingContext editingContext, List expandedIds, List eClassifiers) { - final List result; - - if (selectionDialogTreeElement instanceof Resource resource) { - result = resource.getContents().stream() - .filter(content -> eClassifiers.stream().anyMatch(eClassifier -> eClassifier.isInstance(content)) || this.containsDirectlyOrIndirectlyInstancesOf(content, eClassifiers)) - .toList(); - } else if (selectionDialogTreeElement instanceof Element sysmlElement) { - result = sysmlElement.getOwnedRelationship().stream() - .filter(Membership.class::isInstance) - .map(Membership.class::cast) - .map(Membership::getOwnedRelatedElement).flatMap(List::stream) - .filter(content -> eClassifiers.stream().anyMatch(eClassifier -> eClassifier.isInstance(content)) || this.containsDirectlyOrIndirectlyInstancesOf(content, eClassifiers)) - .toList(); - } else if (selectionDialogTreeElement instanceof ISysONExplorerFragment fragment) { - result = fragment.getChildren(editingContext, List.of(), expandedIds, List.of()).stream().filter(child -> { - if (child instanceof Resource childResource && !this.containsDirectlyOrIndirectlyInstancesOf(childResource, eClassifiers)) { - return false; - } - return true; - }).toList(); - } else { - result = new ArrayList<>(); - } - - return result; - } - - protected boolean containsDirectlyOrIndirectlyInstancesOf(Resource resource, List eClassifiers) { - boolean found = false; - final Iterator allContents = resource.getAllContents(); - while (!found && allContents.hasNext()) { - var eObject = allContents.next(); - for (EClassifier it : eClassifiers) { - found = it.isInstance(eObject); - if (found) { - break; - } - } - } - return found; - } - - protected boolean containsDirectlyOrIndirectlyInstancesOf(EObject eObject, List eClassifiers) { - boolean found = false; - final Iterator allContents = eObject.eAllContents(); - while (!found && allContents.hasNext()) { - var content = allContents.next(); - for (EClassifier it : eClassifiers) { - found = it.isInstance(content); - if (found) { - break; - } - } - } - return found; - } - - protected String getResourceName(Resource resource) { - return resource.eAdapters().stream() - .filter(ResourceMetadataAdapter.class::isInstance) - .map(ResourceMetadataAdapter.class::cast) - .findFirst() - .map(ResourceMetadataAdapter::getName) - .orElse(resource.getURI().lastSegment()); - } - - protected String getElementName(Object element) { - String elementName = ""; - if (element instanceof Resource resource) { - elementName = this.getResourceName(resource); - } else if (element instanceof ISysONExplorerFragment fragment) { - elementName = fragment.getLabel(); - } - return elementName; - } - - protected int getSelectionDialogRootSortRank(Object element) { - int rank = Integer.MAX_VALUE; - if (element instanceof Resource) { - rank = 0; - } else if (element instanceof ISysONExplorerFragment) { - rank = 1; - } - return rank; - } - - protected List findClosestPackageInChildren(Element element) { - var result = new ArrayList(); - if (element instanceof Package packageElement) { - result.add(packageElement); - } else if (element instanceof Membership membership) { - membership.getOwnedRelatedElement() - .forEach(child -> result.addAll(this.findClosestPackageInChildren(child))); - } else { - element.getOwnedRelationship().stream() - .filter(Membership.class::isInstance) - .map(Membership.class::cast) - .forEach(membership -> result.addAll(this.findClosestPackageInChildren(membership))); - } - return result; - } - - protected Package getClosestContainingPackageFrom(Element element) { - var owner = element.eContainer(); - while (!(owner instanceof Package) && owner != null) { - owner = owner.eContainer(); - } - return (Package) owner; - } - - protected List getOwnerHierarchy(Element element) { - List ownerHierarchy = new ArrayList<>(); - Element currentElement = element; - while (currentElement.getOwner() != null) { - ownerHierarchy.add(currentElement.getOwner()); - currentElement = currentElement.getOwner(); - } - return ownerHierarchy; - } - - private String getLabel(Object droppedElement) { - final String label; - StyledString styledLabel = this.labelService.getStyledLabel(droppedElement); - if (styledLabel != null && !styledLabel.toString().isEmpty()) { - label = styledLabel.toString(); - } else if (droppedElement instanceof EObject droppedEObject) { - label = droppedEObject.eClass().getName(); - } else { - label = ""; - } - return label; - } -} diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/description/ToolDescriptionService.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/description/ToolDescriptionService.java index 5734e05b6..65ec2e8ce 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/description/ToolDescriptionService.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/description/ToolDescriptionService.java @@ -33,7 +33,7 @@ import org.eclipse.sirius.components.view.diagram.NodeToolSection; import org.eclipse.sirius.components.view.emf.diagram.ViewDiagramDescriptionConverter; import org.eclipse.syson.diagram.common.view.services.ViewCreateService; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.diagram.services.aql.DiagramQueryAQLService; import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; import org.eclipse.syson.model.services.aql.ModelMutationAQLService; import org.eclipse.syson.services.UtilService; @@ -523,7 +523,7 @@ public NodeTool createNodeToolFromDiagramWithDirection(NodeDescription nodeDescr .iconURLsExpression(iconPath.toString()) .body(changeContextRoot.build()) .elementsToSelectExpression("aql:newInstance") - .preconditionExpression(ServiceMethod.of3(ViewToolService::toolShouldBeAvailable).aqlSelf(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT, + .preconditionExpression(ServiceMethod.of3(DiagramQueryAQLService::toolShouldBeAvailable).aqlSelf(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT, SysMLMetamodelHelper.buildQualifiedName(eClass))) .build(); } @@ -614,7 +614,7 @@ public NodeTool createNodeToolWithDirection(NodeDescription nodeDescription, ECl .iconURLsExpression(iconPath.toString()) .body(changeContextRoot.build()) .elementsToSelectExpression("aql:newInstance") - .preconditionExpression(ServiceMethod.of3(ViewToolService::toolShouldBeAvailable).aqlSelf(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT, + .preconditionExpression(ServiceMethod.of3(DiagramQueryAQLService::toolShouldBeAvailable).aqlSelf(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT, SysMLMetamodelHelper.buildQualifiedName(eClass))) .build(); } diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/ActorCompartmentNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/ActorCompartmentNodeToolProvider.java index ddd0718ee..42619b285 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/ActorCompartmentNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/ActorCompartmentNodeToolProvider.java @@ -16,7 +16,7 @@ import org.eclipse.sirius.components.trees.renderer.TreeRenderer; import org.eclipse.sirius.components.view.diagram.SelectionDialogDescription; import org.eclipse.syson.diagram.common.view.services.ViewCreateService; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.eclipse.syson.sysml.SysmlPackage; import org.eclipse.syson.util.AQLConstants; import org.eclipse.syson.util.ServiceMethod; @@ -40,8 +40,8 @@ protected SelectionDialogDescription getSelectionDialogDescription() { String partDefType = SysMLMetamodelHelper.buildQualifiedName(SysmlPackage.eINSTANCE.getPartDefinition()); var selectionDialogTree = this.diagramBuilderHelper.newSelectionDialogTreeDescription() - .elementsExpression(ServiceMethod.of0(ViewToolService::getActorSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) - .childrenExpression(ServiceMethod.of2(ViewToolService::getActorSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) + .elementsExpression(ServiceMethod.of0(TreeQueryAQLService::getActorSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) + .childrenExpression(ServiceMethod.of2(TreeQueryAQLService::getActorSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) .isSelectableExpression(AQLConstants.AQL_SELF + ".oclIsKindOf(" + partUsageType + ") or self.oclIsKindOf(" + partDefType + ")") .build(); return this.diagramBuilderHelper.newSelectionDialogDescription() diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/AssumeConstraintNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/AssumeConstraintNodeToolProvider.java index d0f6de1cd..116b2a273 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/AssumeConstraintNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/AssumeConstraintNodeToolProvider.java @@ -23,11 +23,11 @@ import org.eclipse.sirius.components.view.diagram.DialogDescription; import org.eclipse.sirius.components.view.diagram.NodeTool; import org.eclipse.sirius.components.view.emf.diagram.ViewDiagramDescriptionConverter; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; import org.eclipse.syson.model.services.aql.ModelMutationAQLService; import org.eclipse.syson.sysml.RequirementConstraintKind; import org.eclipse.syson.sysml.SysmlPackage; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.eclipse.syson.util.AQLConstants; import org.eclipse.syson.util.ServiceMethod; import org.eclipse.syson.util.SysMLMetamodelHelper; @@ -51,7 +51,8 @@ public NodeTool create(IViewDiagramElementFinder cache) { .expression(ServiceMethod.of4(DiagramMutationAQLService::expose).aqlSelf(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT, Node.SELECTED_NODE, ViewDiagramDescriptionConverter.CONVERTED_NODES_VARIABLE)); - // We expose both the reference constraint and owned constraint because the tool `show content as tree` should display the owned constraint. + // We expose both the reference constraint and owned constraint because the tool "show content as tree" should + // display the owned constraint. // However, if the reference constraint and the owned constraint are different, it means the owned constraint is subsetted by reference, and thus we hide the owned constraint graphical node // thanks to DiagramMutationExposeService#hideNodeIfHasReferenceSubset var exposeReferenceConstraint = this.viewBuilderHelper.newChangeContext() @@ -89,8 +90,8 @@ private DialogDescription getDialogDescription() { var selectionDialogTree = this.diagramBuilderHelper.newSelectionDialogTreeDescription() .isSelectableExpression(AQLConstants.AQL_SELF + ".oclIsKindOf(" + constraintUsageType + ")") - .elementsExpression(ServiceMethod.of0(ViewToolService::getConstraintReferenceSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) - .childrenExpression(ServiceMethod.of2(ViewToolService::getConstraintReferenceSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) + .elementsExpression(ServiceMethod.of0(TreeQueryAQLService::getConstraintReferenceSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) + .childrenExpression(ServiceMethod.of2(TreeQueryAQLService::getConstraintReferenceSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) .build(); return this.diagramBuilderHelper.newSelectionDialogDescription() diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/DecisionActionNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/DecisionActionNodeToolProvider.java index 0c9e63515..6ae460945 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/DecisionActionNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/DecisionActionNodeToolProvider.java @@ -19,7 +19,7 @@ import org.eclipse.syson.diagram.common.view.nodes.ActionFlowCompartmentNodeDescriptionProvider; import org.eclipse.syson.diagram.common.view.nodes.DecisionActionNodeDescriptionProvider; import org.eclipse.syson.diagram.common.view.services.ViewCreateService; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.diagram.services.aql.DiagramQueryAQLService; import org.eclipse.syson.util.IDescriptionNameGenerator; import org.eclipse.syson.util.ServiceMethod; @@ -58,10 +58,10 @@ protected String getIconPath() { protected String getPreconditionServiceCallExpression() { if (this.ownerEClass == null) { // this tool will be invoked on the diagram background - return ServiceMethod.of2(ViewToolService::isControlNodeActionCreationToolInsideActionOnAFV).aqlSelf(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT); + return ServiceMethod.of2(DiagramQueryAQLService::isControlNodeActionCreationToolInsideActionOnAFV).aqlSelf(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT); } else { // this tool will be invoked from a selected node - return ServiceMethod.of1(ViewToolService::isControlNodeActionCreationToolInAction).aql(IEditingContext.EDITING_CONTEXT, Node.SELECTED_NODE); + return ServiceMethod.of1(DiagramQueryAQLService::isControlNodeActionCreationToolInAction).aql(IEditingContext.EDITING_CONTEXT, Node.SELECTED_NODE); } } } diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/DoneActionNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/DoneActionNodeToolProvider.java index 935db9baa..958d93449 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/DoneActionNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/DoneActionNodeToolProvider.java @@ -19,7 +19,7 @@ import org.eclipse.syson.diagram.common.view.nodes.ActionFlowCompartmentNodeDescriptionProvider; import org.eclipse.syson.diagram.common.view.nodes.DoneActionNodeDescriptionProvider; import org.eclipse.syson.diagram.common.view.services.ViewCreateService; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.diagram.services.aql.DiagramQueryAQLService; import org.eclipse.syson.util.IDescriptionNameGenerator; import org.eclipse.syson.util.ServiceMethod; @@ -58,10 +58,10 @@ protected String getIconPath() { protected String getPreconditionServiceCallExpression() { if (this.ownerEClass == null) { // this tool will be invoked on the diagram background - return ServiceMethod.of2(ViewToolService::isControlNodeActionCreationToolInsideActionOnAFV).aqlSelf(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT); + return ServiceMethod.of2(DiagramQueryAQLService::isControlNodeActionCreationToolInsideActionOnAFV).aqlSelf(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT); } else { // this tool will be invoked from a selected node - return ServiceMethod.of1(ViewToolService::isControlNodeActionCreationToolInAction).aql(IEditingContext.EDITING_CONTEXT, Node.SELECTED_NODE); + return ServiceMethod.of1(DiagramQueryAQLService::isControlNodeActionCreationToolInAction).aql(IEditingContext.EDITING_CONTEXT, Node.SELECTED_NODE); } } } diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/ExhibitStateNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/ExhibitStateNodeToolProvider.java index d738eef28..f90d4cb4d 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/ExhibitStateNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/ExhibitStateNodeToolProvider.java @@ -24,7 +24,7 @@ import org.eclipse.sirius.components.view.diagram.SelectionDialogDescription; import org.eclipse.sirius.components.view.emf.diagram.ViewDiagramDescriptionConverter; import org.eclipse.syson.diagram.common.view.services.ViewCreateService; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; import org.eclipse.syson.services.UtilService; import org.eclipse.syson.sysml.SysmlPackage; @@ -118,8 +118,8 @@ private SelectionDialogDescription getSelectionDialog() { var domainType = SysMLMetamodelHelper.buildQualifiedName(SysmlPackage.eINSTANCE.getStateUsage()); var selectionDialogTree = this.diagramBuilderHelper.newSelectionDialogTreeDescription() - .elementsExpression(ServiceMethod.of0(ViewToolService::getExhibitStateSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) - .childrenExpression(ServiceMethod.of2(ViewToolService::getExhibitStateSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) + .elementsExpression(ServiceMethod.of0(TreeQueryAQLService::getExhibitStateSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) + .childrenExpression(ServiceMethod.of2(TreeQueryAQLService::getExhibitStateSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) .isSelectableExpression(AQLConstants.AQL_SELF + ".oclIsKindOf(" + domainType + ")") .build(); diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/FlowNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/FlowNodeToolProvider.java index bce2fe554..ae4b65cd0 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/FlowNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/FlowNodeToolProvider.java @@ -20,7 +20,7 @@ import org.eclipse.sirius.components.view.builder.providers.INodeToolProvider; import org.eclipse.sirius.components.view.diagram.NodeTool; import org.eclipse.sirius.components.view.diagram.SelectionDialogDescription; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; import org.eclipse.syson.diagram.services.aql.DiagramQueryAQLService; import org.eclipse.syson.sysml.ConnectionUsage; @@ -65,8 +65,8 @@ private SelectionDialogDescription getSelectionDialogDescription() { var domainType = SysMLMetamodelHelper.buildQualifiedName(SysmlPackage.eINSTANCE.getType()); var selectionDialogTree = this.diagramBuilderHelper.newSelectionDialogTreeDescription() - .elementsExpression(ServiceMethod.of1(ViewToolService::getSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT, "Sequence{" + domainType + "}")) - .childrenExpression(ServiceMethod.of3(ViewToolService::getSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED, "Sequence{" + domainType + "}")) + .elementsExpression(ServiceMethod.of1(TreeQueryAQLService::getSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT, "Sequence{" + domainType + "}")) + .childrenExpression(ServiceMethod.of3(TreeQueryAQLService::getSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED, "Sequence{" + domainType + "}")) .isSelectableExpression(AQLConstants.AQL_SELF + ".oclIsKindOf(" + domainType + ")") .build(); return this.diagramBuilderHelper.newSelectionDialogDescription() diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/ForkActionNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/ForkActionNodeToolProvider.java index be8f08fa0..942ad997d 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/ForkActionNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/ForkActionNodeToolProvider.java @@ -19,7 +19,7 @@ import org.eclipse.syson.diagram.common.view.nodes.ActionFlowCompartmentNodeDescriptionProvider; import org.eclipse.syson.diagram.common.view.nodes.ForkActionNodeDescriptionProvider; import org.eclipse.syson.diagram.common.view.services.ViewCreateService; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.diagram.services.aql.DiagramQueryAQLService; import org.eclipse.syson.util.IDescriptionNameGenerator; import org.eclipse.syson.util.ServiceMethod; @@ -58,10 +58,10 @@ protected String getIconPath() { protected String getPreconditionServiceCallExpression() { if (this.ownerEClass == null) { // this tool will be invoked on the diagram background - return ServiceMethod.of2(ViewToolService::isControlNodeActionCreationToolInsideActionOnAFV).aqlSelf(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT); + return ServiceMethod.of2(DiagramQueryAQLService::isControlNodeActionCreationToolInsideActionOnAFV).aqlSelf(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT); } else { // this tool will be invoked from a selected node - return ServiceMethod.of1(ViewToolService::isControlNodeActionCreationToolInAction).aql(IEditingContext.EDITING_CONTEXT, Node.SELECTED_NODE); + return ServiceMethod.of1(DiagramQueryAQLService::isControlNodeActionCreationToolInAction).aql(IEditingContext.EDITING_CONTEXT, Node.SELECTED_NODE); } } } diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/FramedConcernNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/FramedConcernNodeToolProvider.java index 9548130b5..2bab79b63 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/FramedConcernNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/FramedConcernNodeToolProvider.java @@ -23,7 +23,7 @@ import org.eclipse.sirius.components.view.diagram.DialogDescription; import org.eclipse.sirius.components.view.diagram.NodeTool; import org.eclipse.sirius.components.view.emf.diagram.ViewDiagramDescriptionConverter; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; import org.eclipse.syson.model.services.aql.ModelMutationAQLService; import org.eclipse.syson.sysml.SysmlPackage; @@ -75,8 +75,8 @@ private DialogDescription getSelectionDialogDescription() { var selectionDialogTree = this.diagramBuilderHelper.newSelectionDialogTreeDescription() .isSelectableExpression(AQLConstants.AQL_SELF + ".oclIsKindOf(" + concernUsageType + ")") - .elementsExpression(ServiceMethod.of0(ViewToolService::getConcernReferenceSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) - .childrenExpression(ServiceMethod.of2(ViewToolService::getConcernReferenceSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) + .elementsExpression(ServiceMethod.of0(TreeQueryAQLService::getConcernReferenceSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) + .childrenExpression(ServiceMethod.of2(TreeQueryAQLService::getConcernReferenceSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) .build(); return this.diagramBuilderHelper.newSelectionDialogDescription() diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/JoinActionNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/JoinActionNodeToolProvider.java index 12211ecef..35a672c91 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/JoinActionNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/JoinActionNodeToolProvider.java @@ -19,7 +19,7 @@ import org.eclipse.syson.diagram.common.view.nodes.ActionFlowCompartmentNodeDescriptionProvider; import org.eclipse.syson.diagram.common.view.nodes.JoinActionNodeDescriptionProvider; import org.eclipse.syson.diagram.common.view.services.ViewCreateService; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.diagram.services.aql.DiagramQueryAQLService; import org.eclipse.syson.util.IDescriptionNameGenerator; import org.eclipse.syson.util.ServiceMethod; @@ -58,10 +58,10 @@ protected String getIconPath() { protected String getPreconditionServiceCallExpression() { if (this.ownerEClass == null) { // this tool will be invoked on the diagram background - return ServiceMethod.of2(ViewToolService::isControlNodeActionCreationToolInsideActionOnAFV).aqlSelf(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT); + return ServiceMethod.of2(DiagramQueryAQLService::isControlNodeActionCreationToolInsideActionOnAFV).aqlSelf(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT); } else { // this tool will be invoked from a selected node - return ServiceMethod.of1(ViewToolService::isControlNodeActionCreationToolInAction).aql(IEditingContext.EDITING_CONTEXT, Node.SELECTED_NODE); + return ServiceMethod.of1(DiagramQueryAQLService::isControlNodeActionCreationToolInAction).aql(IEditingContext.EDITING_CONTEXT, Node.SELECTED_NODE); } } } diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/MergeActionNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/MergeActionNodeToolProvider.java index ac238515d..1b5dc15f5 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/MergeActionNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/MergeActionNodeToolProvider.java @@ -19,7 +19,7 @@ import org.eclipse.syson.diagram.common.view.nodes.ActionFlowCompartmentNodeDescriptionProvider; import org.eclipse.syson.diagram.common.view.nodes.MergeActionNodeDescriptionProvider; import org.eclipse.syson.diagram.common.view.services.ViewCreateService; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.diagram.services.aql.DiagramQueryAQLService; import org.eclipse.syson.util.IDescriptionNameGenerator; import org.eclipse.syson.util.ServiceMethod; @@ -58,10 +58,10 @@ protected String getIconPath() { protected String getPreconditionServiceCallExpression() { if (this.ownerEClass == null) { // this tool will be invoked on the diagram background - return ServiceMethod.of2(ViewToolService::isControlNodeActionCreationToolInsideActionOnAFV).aqlSelf(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT); + return ServiceMethod.of2(DiagramQueryAQLService::isControlNodeActionCreationToolInsideActionOnAFV).aqlSelf(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT); } else { // this tool will be invoked from a selected node - return ServiceMethod.of1(ViewToolService::isControlNodeActionCreationToolInAction).aql(IEditingContext.EDITING_CONTEXT, Node.SELECTED_NODE); + return ServiceMethod.of1(DiagramQueryAQLService::isControlNodeActionCreationToolInAction).aql(IEditingContext.EDITING_CONTEXT, Node.SELECTED_NODE); } } } diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/NamespaceImportNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/NamespaceImportNodeToolProvider.java index 89042e398..090ba422e 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/NamespaceImportNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/NamespaceImportNodeToolProvider.java @@ -26,7 +26,7 @@ import org.eclipse.sirius.components.view.diagram.NodeTool; import org.eclipse.sirius.components.view.diagram.SelectionDialogDescription; import org.eclipse.syson.diagram.common.view.services.ViewCreateService; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.eclipse.syson.services.UtilService; import org.eclipse.syson.sysml.NamespaceImport; import org.eclipse.syson.sysml.SysmlPackage; @@ -85,8 +85,8 @@ private SelectionDialogDescription getSelectionDialogDescription() { var domainType = SysMLMetamodelHelper.buildQualifiedName(SysmlPackage.eINSTANCE.getPackage()); var selectionDialogTree = this.diagramBuilderHelper.newSelectionDialogTreeDescription() - .elementsExpression(ServiceMethod.of0(ViewToolService::getNamespaceImportSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) - .childrenExpression(ServiceMethod.of2(ViewToolService::getNamespaceImportSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) + .elementsExpression(ServiceMethod.of0(TreeQueryAQLService::getNamespaceImportSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) + .childrenExpression(ServiceMethod.of2(TreeQueryAQLService::getNamespaceImportSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) .isSelectableExpression(AQLConstants.AQL_SELF + ".oclIsKindOf(" + domainType + ")") .build(); return this.diagramBuilderHelper.newSelectionDialogDescription() diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/ObjectiveRequirementCompartmentNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/ObjectiveRequirementCompartmentNodeToolProvider.java index a6ebacb5f..ce85b41c8 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/ObjectiveRequirementCompartmentNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/ObjectiveRequirementCompartmentNodeToolProvider.java @@ -16,7 +16,7 @@ import org.eclipse.sirius.components.trees.renderer.TreeRenderer; import org.eclipse.sirius.components.view.diagram.SelectionDialogDescription; import org.eclipse.syson.diagram.common.view.services.ViewCreateService; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.eclipse.syson.sysml.RequirementUsage; import org.eclipse.syson.sysml.SysmlPackage; import org.eclipse.syson.util.AQLConstants; @@ -46,8 +46,8 @@ protected SelectionDialogDescription getSelectionDialogDescription() { String reqDefType = SysMLMetamodelHelper.buildQualifiedName(SysmlPackage.eINSTANCE.getRequirementDefinition()); var selectionDialogTree = this.diagramBuilderHelper.newSelectionDialogTreeDescription() - .elementsExpression(ServiceMethod.of0(ViewToolService::getObjectiveRequirementSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) - .childrenExpression(ServiceMethod.of2(ViewToolService::getObjectiveRequirementSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) + .elementsExpression(ServiceMethod.of0(TreeQueryAQLService::getObjectiveRequirementSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) + .childrenExpression(ServiceMethod.of2(TreeQueryAQLService::getObjectiveRequirementSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) .isSelectableExpression(AQLConstants.AQL_SELF + ".oclIsKindOf(" + reqUsageType + ") or self.oclIsKindOf(" + reqDefType + ")") .build(); return this.diagramBuilderHelper.newSelectionDialogDescription() diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/OccurrenceUsageSnapshotNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/OccurrenceUsageSnapshotNodeToolProvider.java index 7fd49a41b..b408ce15b 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/OccurrenceUsageSnapshotNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/OccurrenceUsageSnapshotNodeToolProvider.java @@ -24,10 +24,10 @@ import org.eclipse.sirius.components.view.diagram.SelectionDialogTreeDescription; import org.eclipse.sirius.components.view.emf.diagram.ViewDiagramDescriptionConverter; import org.eclipse.syson.diagram.common.view.services.ViewCreateService; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; import org.eclipse.syson.sysml.PortionKind; import org.eclipse.syson.sysml.SysmlPackage; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.eclipse.syson.util.AQLConstants; import org.eclipse.syson.util.ServiceMethod; @@ -105,7 +105,7 @@ private DialogDescription getDescriptionDialog() { private SelectionDialogTreeDescription getDialogTreeDescriptionDialog() { return this.diagramBuilderHelper.newSelectionDialogTreeDescription() - .elementsExpression(ServiceMethod.of0(ViewToolService::getPortionKindSelectionDialogElement).aqlSelf()) + .elementsExpression(ServiceMethod.of0(TreeQueryAQLService::getPortionKindSelectionDialogElement).aqlSelf()) .isSelectableExpression(AQLConstants.AQL_TRUE) .build(); } diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/OccurrenceUsageTimesliceNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/OccurrenceUsageTimesliceNodeToolProvider.java index 8878ea4bf..9d15f3c2c 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/OccurrenceUsageTimesliceNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/OccurrenceUsageTimesliceNodeToolProvider.java @@ -24,11 +24,11 @@ import org.eclipse.sirius.components.view.diagram.SelectionDialogTreeDescription; import org.eclipse.sirius.components.view.emf.diagram.ViewDiagramDescriptionConverter; import org.eclipse.syson.diagram.common.view.services.ViewCreateService; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; import org.eclipse.syson.model.services.aql.ModelMutationAQLService; import org.eclipse.syson.sysml.PortionKind; import org.eclipse.syson.sysml.SysmlPackage; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.eclipse.syson.util.AQLConstants; import org.eclipse.syson.util.ServiceMethod; @@ -106,7 +106,7 @@ private DialogDescription getDescriptionDialog() { private SelectionDialogTreeDescription getDialogTreeDescriptionDialog() { return this.diagramBuilderHelper.newSelectionDialogTreeDescription() - .elementsExpression(ServiceMethod.of0(ViewToolService::getPortionKindSelectionDialogElement).aqlSelf()) + .elementsExpression(ServiceMethod.of0(TreeQueryAQLService::getPortionKindSelectionDialogElement).aqlSelf()) .isSelectableExpression(AQLConstants.AQL_TRUE) .build(); } diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/PerformActionNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/PerformActionNodeToolProvider.java index 556819c32..9a20d982f 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/PerformActionNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/PerformActionNodeToolProvider.java @@ -21,7 +21,7 @@ import org.eclipse.sirius.components.view.diagram.SelectionDialogDescription; import org.eclipse.sirius.components.view.emf.diagram.ViewDiagramDescriptionConverter; import org.eclipse.syson.diagram.common.view.services.ViewCreateService; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; import org.eclipse.syson.sysml.SysmlPackage; import org.eclipse.syson.util.AQLConstants; @@ -108,8 +108,8 @@ protected SelectionDialogDescription getSelectionDialogDescription() { var selectionDialogTree = this.diagramBuilderHelper.newSelectionDialogTreeDescription() .isSelectableExpression(AQLConstants.AQL_SELF + ".oclIsKindOf(" + actionUsageType + ")") - .elementsExpression(ServiceMethod.of0(ViewToolService::getActionReferenceSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) - .childrenExpression(ServiceMethod.of2(ViewToolService::getActionReferenceSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) + .elementsExpression(ServiceMethod.of0(TreeQueryAQLService::getActionReferenceSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) + .childrenExpression(ServiceMethod.of2(TreeQueryAQLService::getActionReferenceSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) .build(); return this.diagramBuilderHelper.newSelectionDialogDescription() diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/RequireConstraintNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/RequireConstraintNodeToolProvider.java index fd6447423..0dbab876f 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/RequireConstraintNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/RequireConstraintNodeToolProvider.java @@ -23,11 +23,11 @@ import org.eclipse.sirius.components.view.diagram.DialogDescription; import org.eclipse.sirius.components.view.diagram.NodeTool; import org.eclipse.sirius.components.view.emf.diagram.ViewDiagramDescriptionConverter; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; import org.eclipse.syson.model.services.aql.ModelMutationAQLService; import org.eclipse.syson.sysml.RequirementConstraintKind; import org.eclipse.syson.sysml.SysmlPackage; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.eclipse.syson.util.AQLConstants; import org.eclipse.syson.util.ServiceMethod; import org.eclipse.syson.util.SysMLMetamodelHelper; @@ -51,7 +51,8 @@ public NodeTool create(IViewDiagramElementFinder cache) { .expression(ServiceMethod.of4(DiagramMutationAQLService::expose).aqlSelf(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT, Node.SELECTED_NODE, ViewDiagramDescriptionConverter.CONVERTED_NODES_VARIABLE)); - // We expose both the reference constraint and owned constraint because the tool `show content as tree` should display the owned constraint. + // We expose both the reference constraint and owned constraint because the tool "show content as tree" should + // display the owned constraint. // However, if the reference constraint and the owned constraint are different, it means the owned constraint is subsetted by reference, and thus we hide the owned constraint graphical node // thanks to DiagramMutationExposeService#hideNodeIfHasReferenceSubset var exposeReferenceConstraint = this.viewBuilderHelper.newChangeContext() @@ -89,8 +90,8 @@ private DialogDescription getDialogDescription() { var selectionDialogTree = this.diagramBuilderHelper.newSelectionDialogTreeDescription() .isSelectableExpression(AQLConstants.AQL_SELF + ".oclIsKindOf(" + constraintUsageType + ")") - .elementsExpression(ServiceMethod.of0(ViewToolService::getConstraintReferenceSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) - .childrenExpression(ServiceMethod.of2(ViewToolService::getConstraintReferenceSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) + .elementsExpression(ServiceMethod.of0(TreeQueryAQLService::getConstraintReferenceSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) + .childrenExpression(ServiceMethod.of2(TreeQueryAQLService::getConstraintReferenceSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) .build(); return this.diagramBuilderHelper.newSelectionDialogDescription() diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/SatisfyNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/SatisfyNodeToolProvider.java index 2af3ed2c0..c2cd1363d 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/SatisfyNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/SatisfyNodeToolProvider.java @@ -24,7 +24,7 @@ import org.eclipse.sirius.components.view.builder.providers.INodeToolProvider; import org.eclipse.sirius.components.view.diagram.NodeTool; import org.eclipse.sirius.components.view.emf.diagram.ViewDiagramDescriptionConverter; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; import org.eclipse.syson.model.services.aql.ModelMutationAQLService; import org.eclipse.syson.sysml.SysmlPackage; @@ -51,9 +51,9 @@ public NodeTool create(IViewDiagramElementFinder cache) { String reqUsageType = SysMLMetamodelHelper.buildQualifiedName(SysmlPackage.eINSTANCE.getRequirementUsage()); var selectionDialogTree = this.diagramBuilderHelper.newSelectionDialogTreeDescription() - .elementsExpression(ServiceMethod.of1(ViewToolService::getSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT, AQLUtils.aqlSequence(List.of(reqUsageType)))) + .elementsExpression(ServiceMethod.of1(TreeQueryAQLService::getSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT, AQLUtils.aqlSequence(List.of(reqUsageType)))) .childrenExpression( - ServiceMethod.of3(ViewToolService::getSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED, AQLUtils.aqlSequence(List.of(reqUsageType)))) + ServiceMethod.of3(TreeQueryAQLService::getSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED, AQLUtils.aqlSequence(List.of(reqUsageType)))) .isSelectableExpression(AQLConstants.AQL_SELF + ".oclIsKindOf(" + reqUsageType + ")") .build(); var selectionDialog = this.diagramBuilderHelper.newSelectionDialogDescription() diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/SatisfyRequirementNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/SatisfyRequirementNodeToolProvider.java index aaf66b23a..6ef0b3fec 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/SatisfyRequirementNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/SatisfyRequirementNodeToolProvider.java @@ -25,7 +25,7 @@ import org.eclipse.sirius.components.view.diagram.DialogDescription; import org.eclipse.sirius.components.view.diagram.NodeTool; import org.eclipse.sirius.components.view.emf.diagram.ViewDiagramDescriptionConverter; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; import org.eclipse.syson.model.services.aql.ModelMutationAQLService; import org.eclipse.syson.sysml.SysmlPackage; @@ -73,9 +73,9 @@ private DialogDescription getDialogDescription() { var selectableTypes = List.of(reqUsageType, defType); var selectionDialogTreeDescription = this.diagramBuilderHelper.newSelectionDialogTreeDescription() - .elementsExpression(ServiceMethod.of1(ViewToolService::getSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT, AQLUtils.aqlSequence(selectableTypes))) + .elementsExpression(ServiceMethod.of1(TreeQueryAQLService::getSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT, AQLUtils.aqlSequence(selectableTypes))) .childrenExpression( - ServiceMethod.of3(ViewToolService::getSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED, AQLUtils.aqlSequence(selectableTypes))) + ServiceMethod.of3(TreeQueryAQLService::getSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED, AQLUtils.aqlSequence(selectableTypes))) .isSelectableExpression(AQLConstants.AQL + "self.oclIsKindOf(" + defType + ") or self.oclIsKindOf(" + reqUsageType + ")") .build(); diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StakeholdersCompartmentNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StakeholdersCompartmentNodeToolProvider.java index 714200664..bd9f24403 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StakeholdersCompartmentNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StakeholdersCompartmentNodeToolProvider.java @@ -16,7 +16,7 @@ import org.eclipse.sirius.components.trees.renderer.TreeRenderer; import org.eclipse.sirius.components.view.diagram.SelectionDialogDescription; import org.eclipse.syson.diagram.common.view.services.ViewCreateService; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.eclipse.syson.sysml.RequirementDefinition; import org.eclipse.syson.sysml.RequirementUsage; import org.eclipse.syson.sysml.SysmlPackage; @@ -41,8 +41,8 @@ protected String getServiceCallExpression() { protected SelectionDialogDescription getSelectionDialogDescription() { var domainName = SysMLMetamodelHelper.buildQualifiedName(SysmlPackage.eINSTANCE.getPartUsage()); var selectionDialogTree = this.diagramBuilderHelper.newSelectionDialogTreeDescription() - .elementsExpression(ServiceMethod.of0(ViewToolService::getStakeholderSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) - .childrenExpression(ServiceMethod.of2(ViewToolService::getStakeholderSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) + .elementsExpression(ServiceMethod.of0(TreeQueryAQLService::getStakeholderSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) + .childrenExpression(ServiceMethod.of2(TreeQueryAQLService::getStakeholderSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) .isSelectableExpression(AQLConstants.AQL_SELF + ".oclIsKindOf(" + domainName + ")") .build(); return this.diagramBuilderHelper.newSelectionDialogDescription() diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StartActionNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StartActionNodeToolProvider.java index 7ebc34a85..f2ccee66d 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StartActionNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StartActionNodeToolProvider.java @@ -19,7 +19,7 @@ import org.eclipse.syson.diagram.common.view.nodes.ActionFlowCompartmentNodeDescriptionProvider; import org.eclipse.syson.diagram.common.view.nodes.StartActionNodeDescriptionProvider; import org.eclipse.syson.diagram.common.view.services.ViewCreateService; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.diagram.services.aql.DiagramQueryAQLService; import org.eclipse.syson.util.IDescriptionNameGenerator; import org.eclipse.syson.util.ServiceMethod; @@ -58,10 +58,10 @@ protected String getIconPath() { protected String getPreconditionServiceCallExpression() { if (this.ownerEClass == null) { // this tool will be invoked on the diagram background - return ServiceMethod.of2(ViewToolService::isControlNodeActionCreationToolInsideActionOnAFV).aqlSelf(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT); + return ServiceMethod.of2(DiagramQueryAQLService::isControlNodeActionCreationToolInsideActionOnAFV).aqlSelf(IEditingContext.EDITING_CONTEXT, DiagramContext.DIAGRAM_CONTEXT); } else { // this tool will be invoked from a selected node - return ServiceMethod.of1(ViewToolService::isControlNodeActionCreationToolInAction).aql(IEditingContext.EDITING_CONTEXT, Node.SELECTED_NODE); + return ServiceMethod.of1(DiagramQueryAQLService::isControlNodeActionCreationToolInAction).aql(IEditingContext.EDITING_CONTEXT, Node.SELECTED_NODE); } } } diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StateSubactionNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StateSubactionNodeToolProvider.java index cdce66566..9c0794d44 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StateSubactionNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/StateSubactionNodeToolProvider.java @@ -29,7 +29,7 @@ import org.eclipse.sirius.components.view.diagram.NodeTool; import org.eclipse.sirius.components.view.emf.diagram.ViewDiagramDescriptionConverter; import org.eclipse.syson.diagram.common.view.services.ViewCreateService; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; import org.eclipse.syson.sysml.StateSubactionKind; import org.eclipse.syson.sysml.SysmlPackage; @@ -86,8 +86,8 @@ private DialogDescription getExistingActionSelectionDialog() { var selectionDialogTree = this.diagramBuilderHelper.newSelectionDialogTreeDescription() .isSelectableExpression(AQLConstants.AQL_SELF + ".oclIsKindOf(" + actionUsageType + ")") - .elementsExpression(ServiceMethod.of0(ViewToolService::getActionReferenceSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) - .childrenExpression(ServiceMethod.of2(ViewToolService::getActionReferenceSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) + .elementsExpression(ServiceMethod.of0(TreeQueryAQLService::getActionReferenceSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) + .childrenExpression(ServiceMethod.of2(TreeQueryAQLService::getActionReferenceSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) .build(); var actionKind = StringUtils.capitalize(this.kind.getName()); diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/SubjectCompartmentNodeToolProvider.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/SubjectCompartmentNodeToolProvider.java index 5cb7da823..11f14983a 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/SubjectCompartmentNodeToolProvider.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/tools/SubjectCompartmentNodeToolProvider.java @@ -16,7 +16,7 @@ import org.eclipse.sirius.components.trees.renderer.TreeRenderer; import org.eclipse.sirius.components.view.diagram.SelectionDialogDescription; import org.eclipse.syson.diagram.common.view.services.ViewCreateService; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.eclipse.syson.sysml.SysmlPackage; import org.eclipse.syson.util.AQLConstants; import org.eclipse.syson.util.ServiceMethod; @@ -38,8 +38,8 @@ protected String getServiceCallExpression() { protected SelectionDialogDescription getSelectionDialogDescription() { String domainType = SysMLMetamodelHelper.buildQualifiedName(SysmlPackage.eINSTANCE.getType()); var selectionDialogTree = this.diagramBuilderHelper.newSelectionDialogTreeDescription() - .elementsExpression(ServiceMethod.of0(ViewToolService::getSubjectSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) - .childrenExpression(ServiceMethod.of2(ViewToolService::getSubjectSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) + .elementsExpression(ServiceMethod.of0(TreeQueryAQLService::getSubjectSelectionDialogElements).aql(IEditingContext.EDITING_CONTEXT)) + .childrenExpression(ServiceMethod.of2(TreeQueryAQLService::getSubjectSelectionDialogChildren).aqlSelf(IEditingContext.EDITING_CONTEXT, TreeRenderer.EXPANDED)) .isSelectableExpression(AQLConstants.AQL_SELF + ".oclIsKindOf(" + domainType + ")") .build(); return this.diagramBuilderHelper.newSelectionDialogDescription() diff --git a/backend/views/syson-standard-diagrams-view/pom.xml b/backend/views/syson-standard-diagrams-view/pom.xml index ff8157173..f12a2caa1 100644 --- a/backend/views/syson-standard-diagrams-view/pom.xml +++ b/backend/views/syson-standard-diagrams-view/pom.xml @@ -99,6 +99,10 @@ org.eclipse.syson syson-representation-services + + org.eclipse.syson + syson-tree-services + org.eclipse.syson syson-common-view diff --git a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/ActionFlowViewJavaServiceProvider.java b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/ActionFlowViewJavaServiceProvider.java index 2c0115ed8..775266e8f 100644 --- a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/ActionFlowViewJavaServiceProvider.java +++ b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/ActionFlowViewJavaServiceProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2025 Obeo. + * Copyright (c) 2025, 2026 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -24,6 +24,7 @@ import org.eclipse.syson.representation.services.aql.RepresentationQueryAQLService; import org.eclipse.syson.services.UtilService; import org.eclipse.syson.standard.diagrams.view.services.ActionFlowViewCreateService; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.springframework.context.annotation.Configuration; /** @@ -48,7 +49,8 @@ public List> getServiceClasses(View view) { ModelMutationAQLService.class, ModelQueryAQLService.class, RepresentationMutationAQLService.class, - RepresentationQueryAQLService.class); + RepresentationQueryAQLService.class, + TreeQueryAQLService.class); } return List.of(); } diff --git a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/InterconnectionViewJavaServiceProvider.java b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/InterconnectionViewJavaServiceProvider.java index 54558daf2..8a7e974c1 100644 --- a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/InterconnectionViewJavaServiceProvider.java +++ b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/InterconnectionViewJavaServiceProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2025 Obeo. + * Copyright (c) 2025, 2026 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -24,6 +24,7 @@ import org.eclipse.syson.representation.services.aql.RepresentationQueryAQLService; import org.eclipse.syson.services.UtilService; import org.eclipse.syson.standard.diagrams.view.services.InterconnectionViewCreateService; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.springframework.context.annotation.Configuration; /** @@ -48,7 +49,8 @@ public List> getServiceClasses(View view) { ModelMutationAQLService.class, ModelQueryAQLService.class, RepresentationMutationAQLService.class, - RepresentationQueryAQLService.class); + RepresentationQueryAQLService.class, + TreeQueryAQLService.class); } return List.of(); } diff --git a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/SDVJavaServiceProvider.java b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/SDVJavaServiceProvider.java index 6b5756628..97a2d695f 100644 --- a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/SDVJavaServiceProvider.java +++ b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/SDVJavaServiceProvider.java @@ -19,7 +19,6 @@ import org.eclipse.syson.diagram.common.view.services.ViewCreateService; import org.eclipse.syson.diagram.common.view.services.ViewEdgeService; import org.eclipse.syson.diagram.common.view.services.ViewLabelService; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; import org.eclipse.syson.diagram.services.aql.DiagramQueryAQLService; import org.eclipse.syson.model.services.aql.ModelMutationAQLService; @@ -28,6 +27,7 @@ import org.eclipse.syson.representation.services.aql.RepresentationQueryAQLService; import org.eclipse.syson.services.DeleteService; import org.eclipse.syson.services.UtilService; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.springframework.context.annotation.Configuration; /** @@ -49,14 +49,14 @@ public List> getServiceClasses(View view) { ViewCreateService.class, ViewEdgeService.class, ViewLabelService.class, - ViewToolService.class, UtilService.class, DiagramMutationAQLService.class, DiagramQueryAQLService.class, ModelMutationAQLService.class, ModelQueryAQLService.class, RepresentationMutationAQLService.class, - RepresentationQueryAQLService.class); + RepresentationQueryAQLService.class, + TreeQueryAQLService.class); } return List.of(); } diff --git a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/StateTransitionViewJavaServiceProvider.java b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/StateTransitionViewJavaServiceProvider.java index 401892b59..f99131bce 100644 --- a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/StateTransitionViewJavaServiceProvider.java +++ b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/StateTransitionViewJavaServiceProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2025 Obeo. + * Copyright (c) 2025, 2026 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -24,6 +24,7 @@ import org.eclipse.syson.representation.services.aql.RepresentationQueryAQLService; import org.eclipse.syson.services.UtilService; import org.eclipse.syson.standard.diagrams.view.services.StateTransitionViewCreateService; +import org.eclipse.syson.tree.services.aql.TreeQueryAQLService; import org.springframework.context.annotation.Configuration; /** @@ -48,7 +49,8 @@ public List> getServiceClasses(View view) { ModelMutationAQLService.class, ModelQueryAQLService.class, RepresentationMutationAQLService.class, - RepresentationQueryAQLService.class); + RepresentationQueryAQLService.class, + TreeQueryAQLService.class); } return List.of(); } diff --git a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/edges/NestedActorEdgeDescriptionProvider.java b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/edges/NestedActorEdgeDescriptionProvider.java index feaef81bc..3097b9c2c 100644 --- a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/edges/NestedActorEdgeDescriptionProvider.java +++ b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/edges/NestedActorEdgeDescriptionProvider.java @@ -28,7 +28,7 @@ import org.eclipse.sirius.components.view.diagram.NodeDescription; import org.eclipse.sirius.components.view.diagram.SynchronizationPolicy; import org.eclipse.syson.diagram.common.view.edges.AbstractEdgeDescriptionProvider; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; import org.eclipse.syson.standard.diagrams.view.nodes.ActorNodeDescriptionProvider; import org.eclipse.syson.util.AQLConstants; import org.eclipse.syson.util.IDescriptionNameGenerator; @@ -114,7 +114,7 @@ protected boolean isDeletable() { @Override protected ChangeContextBuilder getSourceReconnectToolBody() { return this.viewBuilderHelper.newChangeContext() - .expression(ServiceMethod.of2(ViewToolService::reconnectSourceNestedActorEdge).aql(AQLConstants.EDGE_SEMANTIC_ELEMENT, AQLConstants.SEMANTIC_RECONNECTION_TARGET, + .expression(ServiceMethod.of2(DiagramMutationAQLService::reconnectSourceNestedActorEdge).aql(AQLConstants.EDGE_SEMANTIC_ELEMENT, AQLConstants.SEMANTIC_RECONNECTION_TARGET, AQLConstants.SEMANTIC_OTHER_END)); } @@ -122,7 +122,7 @@ protected ChangeContextBuilder getSourceReconnectToolBody() { protected ChangeContextBuilder getTargetReconnectToolBody() { // Because of https://github.com/eclipse-sirius/sirius-web/issues/2930, it is not possible to prevent user to do the reconnection. return this.viewBuilderHelper.newChangeContext() - .expression(ServiceMethod.of0(ViewToolService::reconnectTargetNestedActorEdge).aql(AQLConstants.EDGE_SEMANTIC_ELEMENT)); + .expression(ServiceMethod.of0(DiagramMutationAQLService::reconnectTargetNestedActorEdge).aql(AQLConstants.EDGE_SEMANTIC_ELEMENT)); } @Override diff --git a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/edges/NestedStakeholderEdgeDescriptionProvider.java b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/edges/NestedStakeholderEdgeDescriptionProvider.java index 95fd83773..c2ad272bb 100644 --- a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/edges/NestedStakeholderEdgeDescriptionProvider.java +++ b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/edges/NestedStakeholderEdgeDescriptionProvider.java @@ -28,7 +28,7 @@ import org.eclipse.sirius.components.view.diagram.NodeDescription; import org.eclipse.sirius.components.view.diagram.SynchronizationPolicy; import org.eclipse.syson.diagram.common.view.edges.AbstractEdgeDescriptionProvider; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; import org.eclipse.syson.standard.diagrams.view.nodes.StakeholderNodeDescriptionProvider; import org.eclipse.syson.util.AQLConstants; import org.eclipse.syson.util.IDescriptionNameGenerator; @@ -114,7 +114,7 @@ protected boolean isDeletable() { @Override protected ChangeContextBuilder getSourceReconnectToolBody() { return this.viewBuilderHelper.newChangeContext() - .expression(ServiceMethod.of2(ViewToolService::reconnectSourceNestedStakeholderEdge).aql(AQLConstants.EDGE_SEMANTIC_ELEMENT, AQLConstants.SEMANTIC_RECONNECTION_TARGET, + .expression(ServiceMethod.of2(DiagramMutationAQLService::reconnectSourceNestedStakeholderEdge).aql(AQLConstants.EDGE_SEMANTIC_ELEMENT, AQLConstants.SEMANTIC_RECONNECTION_TARGET, AQLConstants.SEMANTIC_OTHER_END)); } diff --git a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/edges/NestedSubjectEdgeDescriptionProvider.java b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/edges/NestedSubjectEdgeDescriptionProvider.java index 696e1d8f5..d71fc193d 100644 --- a/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/edges/NestedSubjectEdgeDescriptionProvider.java +++ b/backend/views/syson-standard-diagrams-view/src/main/java/org/eclipse/syson/standard/diagrams/view/edges/NestedSubjectEdgeDescriptionProvider.java @@ -28,7 +28,7 @@ import org.eclipse.sirius.components.view.diagram.NodeDescription; import org.eclipse.sirius.components.view.diagram.SynchronizationPolicy; import org.eclipse.syson.diagram.common.view.edges.AbstractEdgeDescriptionProvider; -import org.eclipse.syson.diagram.common.view.services.ViewToolService; +import org.eclipse.syson.diagram.services.aql.DiagramMutationAQLService; import org.eclipse.syson.standard.diagrams.view.nodes.SubjectNodeDescriptionProvider; import org.eclipse.syson.util.AQLConstants; import org.eclipse.syson.util.IDescriptionNameGenerator; @@ -113,7 +113,7 @@ protected boolean isDeletable() { @Override protected ChangeContextBuilder getSourceReconnectToolBody() { return this.viewBuilderHelper.newChangeContext() - .expression(ServiceMethod.of2(ViewToolService::reconnectSourceNestedSubjectEdge).aql(AQLConstants.EDGE_SEMANTIC_ELEMENT, AQLConstants.SEMANTIC_RECONNECTION_TARGET, + .expression(ServiceMethod.of2(DiagramMutationAQLService::reconnectSourceNestedSubjectEdge).aql(AQLConstants.EDGE_SEMANTIC_ELEMENT, AQLConstants.SEMANTIC_RECONNECTION_TARGET, AQLConstants.SEMANTIC_OTHER_END)); } diff --git a/scripts/check-coverage.jsh b/scripts/check-coverage.jsh index 86c4b32b3..91efb822c 100755 --- a/scripts/check-coverage.jsh +++ b/scripts/check-coverage.jsh @@ -34,8 +34,8 @@ var moduleCoverageData = List.of( new ModuleCoverage("syson-application", 37.0), new ModuleCoverage("syson-application-configuration", 77.0), new ModuleCoverage("syson-common-view", 100.0), - new ModuleCoverage("syson-diagram-common-view", 89.0), - new ModuleCoverage("syson-diagram-services", 86.0), + new ModuleCoverage("syson-diagram-common-view", 93.0), + new ModuleCoverage("syson-diagram-services", 81.0), new ModuleCoverage("syson-direct-edit-grammar", 66.0), new ModuleCoverage("syson-form-services", 100.0), new ModuleCoverage("syson-model-services", 95.0), @@ -54,7 +54,7 @@ var moduleCoverageData = List.of( new ModuleCoverage("syson-table-requirements-view", 73.0), new ModuleCoverage("syson-table-services", 100.0), new ModuleCoverage("syson-tree-explorer-view", 90.0), - new ModuleCoverage("syson-tree-services", 80.0) + new ModuleCoverage("syson-tree-services", 75.0) ); void display(String module, double coverage, double expected) {