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
9 changes: 9 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ The `org.eclipse.syson.services.grammars` package in `syson-direct-edit-grammar`
As a consequence, the `syson-table-requirements-view` and `syson-common-view` modules has been created.
`IViewDescriptionProvider.java` and `SysONViewDescriptionProvider.java` have been moved from `syson-diagram-common-view` to `syson-common-view`.
`GetIntermediateContainerCreationSwitch.java` has been moved from `syson-application-configuration` to `syson-services`.
- https://github.com/eclipse-syson/syson/issues/1245[#1245] [syson] Standardize read-only computation.
The class `SysMLReadOnlyService` and the interface `ISysMLReadOnlyService` have been removed, use `IReadOnlyObjectPredicate` instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't mention this API break in the release notes, I don't think it is very useful to the end users. Let me know if I should add it there.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, no need to mention API breaks in the release notes


=== Dependency update

Expand Down Expand Up @@ -91,6 +93,13 @@ Consumers may override this by providing an implementation of `org.eclipse.syson
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`.
- https://github.com/eclipse-syson/syson/issues/1245[#1245] [syson] Standardize read-only computation.
We removed the assumptions SysON made on whether a resource is read-only.
Resources are now considered read-only if:
* They are Sirius Web libraries imported by reference
* They are textual SysML files imported as read-only
* They are standard libraries (SysML and KerML)
All the other resources are read-write.

=== New features

Expand Down
2 changes: 1 addition & 1 deletion backend/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<groupId>org.eclipse.syson</groupId>
<artifactId>syson-application-parent</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>

<name>syson-application-parent</name>
<description>SysON Application Parent</description>
Expand Down
14 changes: 7 additions & 7 deletions backend/application/syson-application-configuration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</parent>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-application-configuration</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
<name>syson-application-configuration</name>
<description>SysON Application Configuration</description>

Expand Down Expand Up @@ -69,27 +69,27 @@
<dependency>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-sysml-metamodel</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
</dependency>
<dependency>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-sysml-metamodel-edit</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
</dependency>
<dependency>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-services</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
</dependency>
<dependency>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-siriusweb-customnodes-metamodel</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
</dependency>
<dependency>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-siriusweb-customnodes-metamodel-edit</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
</dependency>
<!-- Test Dependencies -->
<dependency>
Expand All @@ -105,7 +105,7 @@
<dependency>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-tests</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@
*******************************************************************************/
package org.eclipse.syson.application.services;

import java.util.Objects;

import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.sirius.components.core.api.IReadOnlyObjectPredicate;
import org.eclipse.sirius.components.core.api.IReadOnlyObjectPredicateDelegate;
import org.eclipse.syson.services.UtilService;
import org.eclipse.syson.services.api.ISysONResourceService;
import org.eclipse.sirius.components.emf.ResourceMetadataAdapter;
import org.eclipse.syson.sysml.Element;
import org.eclipse.syson.sysml.util.ElementUtil;
import org.springframework.stereotype.Service;
Expand All @@ -42,12 +38,6 @@
@Service
public class SysONReadOnlyObjectPredicateDelegate implements IReadOnlyObjectPredicateDelegate {

private final ISysONResourceService sysONResourceService;

public SysONReadOnlyObjectPredicateDelegate(final ISysONResourceService sysONResourceService) {
this.sysONResourceService = Objects.requireNonNull(sysONResourceService);
}

@Override
public boolean canHandle(Object candidate) {
return candidate instanceof Element || candidate instanceof Resource || candidate instanceof EAnnotation;
Expand All @@ -60,12 +50,18 @@ public boolean test(Object candidate) {

if (candidate instanceof Resource resource) {
isReadOnly = ElementUtil.isStandardLibraryResource(resource)
|| this.sysONResourceService.isImported(resource) && !new UtilService().getLibraries(resource, false).isEmpty();
} else if (candidate instanceof Element || candidate instanceof EAnnotation) {
// Derive editability from the editability of the containing resource.
final EObject eObject = (EObject) candidate;
final Resource resource = eObject.eResource();
isReadOnly = this.test(resource);
|| resource.eAdapters().stream()
.filter(ResourceMetadataAdapter.class::isInstance)
.map(ResourceMetadataAdapter.class::cast)
.map(ResourceMetadataAdapter::isReadOnly)
.findFirst()
.orElse(false);
} else if (candidate instanceof Element element) {
// An element is read-only if it is contained in a standard LibraryPackage, regardless of whether its
// containing resource is read-only or not.
isReadOnly = this.test(element.eResource()) || ElementUtil.isFromStandardLibrary(element);
} else if (candidate instanceof EAnnotation eAnnotation) {
isReadOnly = this.test(eAnnotation.eResource());
}

return isReadOnly;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.sirius.components.core.api.IFeedbackMessageService;
import org.eclipse.sirius.components.core.services.ComposedReadOnlyObjectPredicate;
import org.eclipse.sirius.components.emf.ResourceMetadataAdapter;
import org.eclipse.sirius.components.emf.services.JSONResourceFactory;
import org.eclipse.sirius.web.application.object.services.DefaultReadOnlyObjectPredicate;
import org.eclipse.syson.sysml.LibraryPackage;
Expand All @@ -46,7 +47,7 @@ public class DetailsViewServiceTest {
public void setUp() {
// Use a dummy CompsedAdapterFactory, we don't test methods that require the one used by SysON for the moment.
this.detailsViewService = new DetailsViewService(new ComposedAdapterFactory(), new IFeedbackMessageService.NoOp(),
new ComposedReadOnlyObjectPredicate(List.of(new SysONReadOnlyObjectPredicateDelegate(new SysONResourceService())), new DefaultReadOnlyObjectPredicate()));
new ComposedReadOnlyObjectPredicate(List.of(new SysONReadOnlyObjectPredicateDelegate()), new DefaultReadOnlyObjectPredicate()));
}

@Test
Expand Down Expand Up @@ -95,6 +96,20 @@ public void isReadOnlyElementInImportedLibrary() {
namespace.getOwnedRelationship().add(owningMembership);
owningMembership.getOwnedRelatedElement().add(libraryPackage);
ElementUtil.setIsImported(resource, true);
assertThat(this.detailsViewService.isReadOnly(libraryPackage)).isFalse();
}

@Test
public void isReadOnlyElementInImportedLibraryFlaggedAsReadOnly() {
Resource resource = new JSONResourceFactory().createResourceFromPath("testResource");
Namespace namespace = SysmlFactory.eINSTANCE.createNamespace();
resource.getContents().add(namespace);
LibraryPackage libraryPackage = SysmlFactory.eINSTANCE.createLibraryPackage();
OwningMembership owningMembership = SysmlFactory.eINSTANCE.createOwningMembership();
namespace.getOwnedRelationship().add(owningMembership);
owningMembership.getOwnedRelatedElement().add(libraryPackage);
ElementUtil.setIsImported(resource, true);
resource.eAdapters().add(new ResourceMetadataAdapter("test", true));
assertThat(this.detailsViewService.isReadOnly(libraryPackage)).isTrue();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.sirius.components.core.api.IReadOnlyObjectPredicateDelegate;
import org.eclipse.sirius.components.core.services.ComposedReadOnlyObjectPredicate;
import org.eclipse.sirius.components.emf.ResourceMetadataAdapter;
import org.eclipse.sirius.components.emf.services.api.IEMFEditingContext;
import org.eclipse.sirius.web.application.library.services.LibraryMetadataAdapter;
import org.eclipse.syson.application.configuration.SysONDefaultLibrariesConfiguration;
Expand Down Expand Up @@ -57,7 +58,7 @@
*/
public class SysONReadOnlyObjectPredicateDelegateTests {

private final IReadOnlyObjectPredicateDelegate readOnlyObjectPredicateDelegate = new SysONReadOnlyObjectPredicateDelegate(new SysONResourceService());
private final IReadOnlyObjectPredicateDelegate readOnlyObjectPredicateDelegate = new SysONReadOnlyObjectPredicateDelegate();

@SafeVarargs
private static Resource createResource(final URI uri, final Consumer<Resource>... postTreatments) {
Expand Down Expand Up @@ -282,6 +283,8 @@ public class ImportedResources {

private final Resource importedResourceWithSysmlLibraryPackage;

private final Resource importedResourceWithSysmlLibraryPackageAndFlaggedAsReadOnly;

private final Resource importedResourceWithSysmlMixedPackages;

public ImportedResources() {
Expand All @@ -295,6 +298,13 @@ public ImportedResources() {
ElementUtil.setIsImported(resource, true);
});

this.importedResourceWithSysmlLibraryPackageAndFlaggedAsReadOnly = createResource(createEmfUri(), resource -> {
resource.getContents().addAll(EcoreUtil.copyAll(SysMLResources.this.resourceWithSysmlLibraryPackage.getContents()));
ElementUtil.setIsImported(resource, true);
ResourceMetadataAdapter resourceMetadataAdapter = new ResourceMetadataAdapter("test", true);
resource.eAdapters().add(resourceMetadataAdapter);
});

this.importedResourceWithSysmlMixedPackages = createResource(createEmfUri(), resource -> {
resource.getContents().addAll(EcoreUtil.copyAll(SysMLResources.this.resourceWithSysmlMixedPackages.getContents()));
ElementUtil.setIsImported(resource, true);
Expand All @@ -308,15 +318,21 @@ public void testResourceWithSysmlPackageImported() {
}

@Test
@DisplayName("Imported resource containing LibraryPackage is read-only (both the resource and all of its contents)")
@DisplayName("Imported resource containing LibraryPackage is not read-only (both the resource and all of its contents)")
public void testResourceWithSysmlLibraryPackageImported() {
SysONReadOnlyObjectPredicateDelegateTests.this.assertResourceAndAllContentsIsReadOnly(this.importedResourceWithSysmlLibraryPackage, true);
SysONReadOnlyObjectPredicateDelegateTests.this.assertResourceAndAllContentsIsReadOnly(this.importedResourceWithSysmlLibraryPackage, false);
}

@Test
@DisplayName("Imported resource containing LibraryPackage and flagged as read-only is read-only (both the resource and all of its contents)")
public void testResourceWithSysmlLibraryPackageImportedAndFlaggedAsReadOnly() {
SysONReadOnlyObjectPredicateDelegateTests.this.assertResourceAndAllContentsIsReadOnly(this.importedResourceWithSysmlLibraryPackageAndFlaggedAsReadOnly, true);
}

@Test
@DisplayName("Imported resource containing Package and LibraryPackage is read-only (both the resource and all of its contents)")
@DisplayName("Imported resource containing Package and LibraryPackage is not read-only (both the resource and all of its contents)")
public void testResourceWithSysmlMixedPackagesImported() {
SysONReadOnlyObjectPredicateDelegateTests.this.assertResourceAndAllContentsIsReadOnly(this.importedResourceWithSysmlMixedPackages, true);
SysONReadOnlyObjectPredicateDelegateTests.this.assertResourceAndAllContentsIsReadOnly(this.importedResourceWithSysmlMixedPackages, false);
}
}

Expand All @@ -339,26 +355,26 @@ public class ReferencedResources {
public ReferencedResources() {
this.referencedResourceWithSysmlPackage = createResource(createEmfUri(), resource -> {
resource.getContents().addAll(EcoreUtil.copyAll(SysMLResources.this.resourceWithSysmlPackage.getContents()));
}, resource -> resource.eAdapters().add(createLibraryMetadataAdapter()));
}, ReferencedResources::addReferencedResourceAdapters);

this.referencedResourceWithSysmlLibraryPackage = createResource(createEmfUri(), resource -> {
resource.getContents().addAll(EcoreUtil.copyAll(SysMLResources.this.resourceWithSysmlLibraryPackage.getContents()));
}, resource -> resource.eAdapters().add(createLibraryMetadataAdapter()));
}, ReferencedResources::addReferencedResourceAdapters);

this.referencedResourceWithSysmlMixedPackages = createResource(createEmfUri(), resource -> {
resource.getContents().addAll(EcoreUtil.copyAll(SysMLResources.this.resourceWithSysmlMixedPackages.getContents()));
}, resource -> resource.eAdapters().add(createLibraryMetadataAdapter()));
}, ReferencedResources::addReferencedResourceAdapters);
}

private static LibraryMetadataAdapter createLibraryMetadataAdapter() {
return new LibraryMetadataAdapter("namespace", "name", "version");
private static void addReferencedResourceAdapters(Resource resource) {
resource.eAdapters().add(new LibraryMetadataAdapter("namespace", "name", "version"));
resource.eAdapters().add(new ResourceMetadataAdapter("test", true));
}

@Test
@DisplayName("Resource from referenced library containing Package is read-only (both the resource and all of its contents)")
public void testResourceWithSysmlPackageImported() {
// Note that this might be a bug, see https://github.com/eclipse-syson/syson/issues/1342.
SysONReadOnlyObjectPredicateDelegateTests.this.assertResourceAndAllContentsIsReadOnly(this.referencedResourceWithSysmlPackage, false);
SysONReadOnlyObjectPredicateDelegateTests.this.assertResourceAndAllContentsIsReadOnly(this.referencedResourceWithSysmlPackage, true);
}

@Test
Expand Down
28 changes: 14 additions & 14 deletions backend/application/syson-application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</parent>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-application</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
<name>syson-application</name>
<description>SysON Application</description>

Expand Down Expand Up @@ -82,62 +82,62 @@
<dependency>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-sysml-metamodel</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
</dependency>
<dependency>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-sysml-metamodel-edit</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
</dependency>
<dependency>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-frontend</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
</dependency>
<dependency>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-application-configuration</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
</dependency>
<dependency>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-sysml-rest-api-services</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
</dependency>
<dependency>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-diagram-common-view</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
</dependency>
<dependency>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-standard-diagrams-view</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
</dependency>
<dependency>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-table-requirements-view</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
</dependency>
<dependency>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-tree-explorer-view</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
</dependency>
<dependency>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-sysml-import</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
</dependency>
<dependency>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-sysml-export</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
</dependency>
<dependency>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-sysml-validation</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
</dependency>

<!-- Test Dependencies -->
Expand Down Expand Up @@ -194,7 +194,7 @@
<dependency>
<groupId>org.eclipse.syson</groupId>
<artifactId>syson-sysml-metamodel</artifactId>
<version>2025.8.5</version>
<version>2025.8.8</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
Expand Down
Loading
Loading