Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ Consumers may override this by providing an implementation of `org.eclipse.syson
- https://github.com/eclipse-syson/syson/issues/1432[#1432] [metamodel] Add implicit `Subclassification` or `Subsetting` when using semantic `MetadataUsage`.
- https://github.com/eclipse-syson/syson/issues/1355[#1355] [tests] Add coding rules tests on all modules.
- https://github.com/eclipse-syson/syson/issues/1530[#1530] [details] Move `RequirementUsage`'s _ReqId_ property from the _Advanced_ tab to the _Core_ tab of the _Details View_.
- https://github.com/eclipse-syson/syson/issues/1534[#1534] [explorer] Since it is now possible to switch from a _Standard Diagram View_ to another in SysON (for example from _General View_ to _Interconnection View_), the `ViewDefinition` name in displayed in the label of the `ViewUsage` in the _Explorer View_.
With this enhancement, users can now easily identify which `ViewDefinition` is used by a `ViewUsage`.
- https://github.com/eclipse-syson/syson/issues/1535[#1535] [explorer] Since it is now possible to switch from a _Standard Diagram View_ to another in SysON (for example from _General View_ to _Interconnection View_), the `ViewUsages` default name does not contain the name of the `ViewDefinition` anymore.
With this enhancement, users avoid confusion when switching from one _ViewDefinition_ to another one in a `ViewUsage`.

=== New features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public SysMLv2PropertiesConfigurer(ComposedAdapterFactory composedAdapterFactory
@Override
public void addPropertiesDescriptions(IPropertiesDescriptionRegistry registry) {
// Build the actual FormDescription that will be used in Detail view.
FormDescription viewFormDescription = this.createDetailsView();
FormDescription viewFormDescription = this.createDetailsViewForElement();

// The FormDescription must be part of View inside a proper EMF Resource to be correctly handled
URI uri = URI.createURI(IEMFEditingContext.RESOURCE_SCHEME + ":///" + UUID.nameUUIDFromBytes(SysMLv2PropertiesConfigurer.class.getCanonicalName().getBytes()));
Expand All @@ -150,7 +150,7 @@ public void addPropertiesDescriptions(IPropertiesDescriptionRegistry registry) {
}
}

private FormDescription createDetailsView() {
private FormDescription createDetailsViewForElement() {
String domainType = SysMLMetamodelHelper.buildQualifiedName(SysmlPackage.eINSTANCE.getElement());
FormDescription form = FormFactory.eINSTANCE.createFormDescription();
form.setName("SysON Details View");
Expand Down Expand Up @@ -187,6 +187,7 @@ private FormDescription createDetailsView() {
return form;
}


/**
* Creates a group to display the value of a Feature or FeatureValue.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,18 @@ private Optional<RepresentationMetadata> initializeSysMLv2Project(ICause cause,
var resource = this.defaultSysMLv2ResourceProvider.getDefaultSysMLv2Resource(UUID.randomUUID(), SYSMLV2_DOCUMENT_NAME);
resourceSet.getResources().add(resource);

// General View is the description name of SDVDiagramDescriptionProvider
var optionalGeneralViewDiagram = this.findDiagramDescription(editingContext, "General View");
if (optionalGeneralViewDiagram.isPresent()) {
DiagramDescription generalViewDiagram = optionalGeneralViewDiagram.get();
var viewUsage = this.getOrCreateViewUsage(resource);
if (viewUsage.isPresent()) {
var optViewUsage = this.getOrCreateViewUsage(resource);
if (optViewUsage.isPresent()) {
var variableManager = new VariableManager();
var viewUsage = optViewUsage.get();
variableManager.put(VariableManager.SELF, viewUsage);
variableManager.put(DiagramDescription.LABEL, generalViewDiagram.getLabel());
variableManager.put(DiagramDescription.LABEL, viewUsage.getDeclaredName());
String label = generalViewDiagram.getLabelProvider().apply(variableManager);
Diagram diagram = this.diagramCreationService.create(viewUsage.get(), generalViewDiagram, editingContext);
Diagram diagram = this.diagramCreationService.create(viewUsage, generalViewDiagram, editingContext);
List<String> iconURLs = generalViewDiagram.getIconURLsProvider().apply(variableManager);

var representationMetadata = RepresentationMetadata.newRepresentationMetadata(diagram.getId())
Expand All @@ -139,16 +141,18 @@ private Optional<RepresentationMetadata> initializeSysMLv2LibraryProject(ICause
var resource = this.defaultSysMLv2ResourceProvider.getDefaultSysMLv2LibraryResource(UUID.randomUUID(), SYSMLV2_LIBRARY_DOCUMENT_NAME);
resourceSet.getResources().add(resource);

// General View is the description name of SDVDiagramDescriptionProvider
var optionalGeneralViewDiagram = this.findDiagramDescription(editingContext, "General View");
if (optionalGeneralViewDiagram.isPresent()) {
DiagramDescription generalViewDiagram = optionalGeneralViewDiagram.get();
var viewUsage = this.getOrCreateViewUsage(resource);
if (viewUsage.isPresent()) {
var optViewUsage = this.getOrCreateViewUsage(resource);
if (optViewUsage.isPresent()) {
var variableManager = new VariableManager();
var viewUsage = optViewUsage.get();
variableManager.put(VariableManager.SELF, viewUsage);
variableManager.put(DiagramDescription.LABEL, generalViewDiagram.getLabel());
variableManager.put(DiagramDescription.LABEL, viewUsage.getDeclaredName());
String label = generalViewDiagram.getLabelProvider().apply(variableManager);
Diagram diagram = this.diagramCreationService.create(viewUsage.get(), generalViewDiagram, editingContext);
Diagram diagram = this.diagramCreationService.create(viewUsage, generalViewDiagram, editingContext);
List<String> iconURLs = generalViewDiagram.getIconURLsProvider().apply(variableManager);

var representationMetadata = RepresentationMetadata.newRepresentationMetadata(diagram.getId())
Expand Down Expand Up @@ -177,16 +181,18 @@ private Optional<RepresentationMetadata> initializeBatmobileProject(ICause cause
// Load after adding the resource to the resourceSet, to be sure that references will be resolved.
this.defaultSysMLv2ResourceProvider.loadBatmobileResource(resource);

// General View is the description name of SDVDiagramDescriptionProvider
var optionalGeneralViewDiagram = this.findDiagramDescription(editingContext, "General View");
if (optionalGeneralViewDiagram.isPresent()) {
DiagramDescription generalViewDiagram = optionalGeneralViewDiagram.get();
var viewUsage = this.getOrCreateViewUsage(resource);
if (viewUsage.isPresent()) {
var optViewUsage = this.getOrCreateViewUsage(resource);
if (optViewUsage.isPresent()) {
var variableManager = new VariableManager();
var viewUsage = optViewUsage.get();
variableManager.put(VariableManager.SELF, viewUsage);
variableManager.put(DiagramDescription.LABEL, generalViewDiagram.getLabel());
variableManager.put(DiagramDescription.LABEL, viewUsage.getDeclaredName());
String label = generalViewDiagram.getLabelProvider().apply(variableManager);
Diagram diagram = this.diagramCreationService.create(viewUsage.get(), generalViewDiagram, editingContext);
Diagram diagram = this.diagramCreationService.create(viewUsage, generalViewDiagram, editingContext);
List<String> iconURLs = generalViewDiagram.getIconURLsProvider().apply(variableManager);

var representationMetadata = RepresentationMetadata.newRepresentationMetadata(diagram.getId())
Expand Down Expand Up @@ -249,7 +255,7 @@ private Optional<ViewUsage> getViewUsage(Element element) {
return element.getOwnedElement().stream()
.filter(ViewUsage.class::isInstance)
.map(ViewUsage.class::cast)
.filter(vu -> Objects.equals(vu.getDeclaredName(), "General View"))
.filter(vu -> Objects.equals(vu.getDeclaredName(), "view1"))
.findFirst();
}

Expand All @@ -258,7 +264,7 @@ private Optional<ViewUsage> createViewUsage(Element element) {
var viewUsage = SysmlFactory.eINSTANCE.createViewUsage();
element.getOwnedRelationship().add(viewUsageMembership);
viewUsageMembership.getOwnedRelatedElement().add(viewUsage);
viewUsage.setDeclaredName("General View");
viewUsage.setDeclaredName("view1");
viewUsage.setElementId(ElementUtil.generateUUID(viewUsage).toString());

var featureTyping = SysmlFactory.eINSTANCE.createFeatureTyping();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Resource getDefaultSysMLv2Resource(UUID resourcePath, String name) {
var package1 = SysmlFactory.eINSTANCE.createPackage();
rootNamespace.getOwnedRelationship().add(rootMembership);
rootMembership.getOwnedRelatedElement().add(package1);
package1.setDeclaredName("Package 1");
package1.setDeclaredName("Package1");
package1.setElementId(ElementUtil.generateUUID(package1).toString());

resource.getContents().add(rootNamespace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6276,7 +6276,7 @@
"id": "b38b489f-9052-47f7-a417-0c1e137d0dca",
"eClass": "sysml:ViewUsage",
"data": {
"declaredName": "General View",
"declaredName": "view1",
"elementId": "b63738a8-448c-4de2-a71d-00c512807fdf",
"ownedRelationship": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ package Batmobile {
part :>> wheels = wheels.xWheel;
}

view 'General View' : StandardViewDefinitions::GeneralView {
view 'view1' : StandardViewDefinitions::GeneralView {
expose Vehicle;
expose Vehicle::driver;
expose Vehicle::engine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void givenSysMLv2ProjectTemplateWhenMutationIsPerformedThenTheProjectIsCr
var emfEditingContext = (IEMFEditingContext) editingContext;
var rootObject = this.getRooObject(emfEditingContext);
assertNotNull(rootObject);
assertEquals("Package 1", rootObject.getDeclaredName());
assertEquals("Package1", rootObject.getDeclaredName());
}

@DisplayName("GIVEN the SysMLv2-Library project template, WHEN the mutation is performed, THEN the project is created")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,14 @@ public ViewDefinition getViewDefinition() {
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
* @generated NOT
*/
public ViewDefinition basicGetViewDefinition() {
// TODO: implement this method to return the 'View Definition' reference
// -> do not perform proxy resolution
// Ensure that you remove @generated or mark it @generated NOT
return null;
return this.getType().stream()
.filter(ViewDefinition.class::isInstance)
.map(ViewDefinition.class::cast)
.findFirst()
.orElse(null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,25 @@ public <T extends Element> T findByNameAndType(Collection<EObject> roots, String
return null;
}

/**
* Count the number of existing elements having the same type than the given Element inside the owning Namespace of
* the given Element.
*
* @param element
* the given {@link Element}.
* @return the number of existing elements having the same type than the given Element inside the owning Namespace
* of the given Element.
*/
public long existingElementsCount(Element element) {
Namespace owningNamespace = element.getOwningNamespace();
if (owningNamespace != null) {
return owningNamespace.getOwnedMember().stream()
.filter(member -> element.eClass().equals(member.eClass()))
.count();
}
return 0;
}

/**
* Iterate over the children of the given root {@link EObject} to find an {@link Element} with the given qualified
* name and type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public Element caseDependency(Dependency object) {

@Override
public Element caseDefinition(Definition object) {
var existingElements = this.existingElementsCount(object);
var existingElements = this.elementUtil.existingElementsCount(object);
object.setDeclaredName(object.eClass().getName() + existingElements);
return object;
}
Expand All @@ -138,7 +138,7 @@ public Element caseElement(Element object) {
@Override
public Element caseEnumerationDefinition(EnumerationDefinition object) {
object.setIsVariation(true);
var existingElements = this.existingElementsCount(object);
var existingElements = this.elementUtil.existingElementsCount(object);
object.setDeclaredName(object.eClass().getName() + existingElements);
return object;
}
Expand All @@ -155,7 +155,7 @@ public Element caseFlowUsage(FlowUsage object) {

@Override
public Element casePackage(Package object) {
var existingElements = this.existingElementsCount(object);
var existingElements = this.elementUtil.existingElementsCount(object);
object.setDeclaredName(object.eClass().getName() + existingElements);
return object;
}
Expand Down Expand Up @@ -193,7 +193,7 @@ public Element casePerformActionUsage(PerformActionUsage object) {

@Override
public Element casePortDefinition(PortDefinition object) {
var existingElements = this.existingElementsCount(object);
var existingElements = this.elementUtil.existingElementsCount(object);
object.setDeclaredName(object.eClass().getName() + existingElements);
OwningMembership owningMembership = SysmlFactory.eINSTANCE.createOwningMembership();
object.getOwnedRelationship().add(owningMembership);
Expand Down Expand Up @@ -272,7 +272,7 @@ public Element caseUsage(Usage object) {
defaultName = defaultName.substring(0, defaultName.length() - 5);
}

var existingElements = this.existingElementsCount(object);
var existingElements = this.elementUtil.existingElementsCount(object);

object.setDeclaredName(defaultName + existingElements);
object.setIsComposite(true);
Expand All @@ -290,16 +290,6 @@ public Element caseViewUsage(ViewUsage object) {
return object;
}

private long existingElementsCount(Element element) {
Namespace owningNamespace = element.getOwningNamespace();
if (owningNamespace != null) {
return owningNamespace.getOwnedMember().stream()
.filter(member -> element.eClass().equals(member.eClass()))
.count();
}
return 0;
}

private ParameterMembership createParameterMembershipWithReferenceUsage(String refName, FeatureDirectionKind direction) {
var reference = SysmlFactory.eINSTANCE.createReferenceUsage();
reference.setDirection(direction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -976,13 +976,10 @@ public Element getViewUsageOwner(Element element) {
* @param editingContext
* the {@link IEditingContext} of the element. It corresponds to a variable accessible from the variable
* manager.
* @param diagramContext
* the {@link IDiagramContext} of the element. It corresponds to a variable accessible from the variable
* manager.
* @return true if the given {@link Element} displayed in the given {@link IDiagramContext} is of the given
* {@link ViewDefinition}, false otherwise.
*/
public ViewDefinitionKind getViewDefinitionKind(Element element, List<Object> ancestors, IEditingContext editingContext, IDiagramContext diagramContext) {
public ViewDefinitionKind getViewDefinitionKind(Element element, List<Object> ancestors, IEditingContext editingContext) {
ViewDefinitionKind kind = ViewDefinitionKind.GENERAL_VIEW;
if (element instanceof ViewUsage viewUsage) {
var types = viewUsage.getType();
Expand All @@ -995,7 +992,7 @@ public ViewDefinitionKind getViewDefinitionKind(Element element, List<Object> an
var viewUsageContainingElement = ancestors.stream().filter(ViewUsage.class::isInstance).map(ViewUsage.class::cast).findFirst();
if (viewUsageContainingElement.isPresent()) {
ViewUsage viewUsage = viewUsageContainingElement.get();
kind = this.getViewDefinitionKind(viewUsage, List.of(), editingContext, diagramContext);
kind = this.getViewDefinitionKind(viewUsage, List.of(), editingContext);
}
}
return kind;
Expand All @@ -1017,6 +1014,19 @@ public boolean isEmptyObjectiveRequirement(Element self) {
.isEmpty();
}

/**
* Count the number of existing elements having the same type than the given Element inside the owning Namespace of
* the given Element.
*
* @param element
* the given {@link Element}.
* @return the number of existing elements having the same type than the given Element inside the owning Namespace
* of the given Element.
*/
public long existingElementsCount(Element element) {
return this.elementUtil.existingElementsCount(element);
}

private ReferenceUsage addConnectorEnd(ConnectorAsUsage connectorAsUsage, Feature end, Type connectorContainer) {
FeatureChainComputer cmp = new FeatureChainComputer();
List<Feature> sourceFeaturePath = cmp.computeShortestPath(connectorContainer, end).orElse(List.of());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public List<Element> getExposedElements(Element element, Element parent, EClass
elementsToExpose.addAll(filteredExposedElements);
// if it is not a General View, we don't want to display nested nodes as tree (i.e. sibling nodes +
// composition edges), if it an ActionFlow view, we only want to display Action Nodes as root nodes, ...
var viewDefKind = this.utilService.getViewDefinitionKind(viewUsage, ancestors, editingContext, diagramContext);
var viewDefKind = this.utilService.getViewDefinitionKind(viewUsage, ancestors, editingContext);
for (Element filteredExposedElement : filteredExposedElements) {
boolean canBeDisplayed = new ViewFilterSwitch(viewDefKind, exposedElements, parent).doSwitch(filteredExposedElement);
if (!canBeDisplayed) {
Expand Down
Loading
Loading