Skip to content

Commit

Permalink
[619] Fix Inherited members inside compartments don't display palette
Browse files Browse the repository at this point in the history
Bug: eclipse-syson#619
Signed-off-by: Axel RICHARD <axel.richard@obeo.fr>
  • Loading branch information
AxelRICHARD committed Aug 1, 2024
1 parent c8987a0 commit 16ee4ab
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ The following classes & methods have been deleted or modified to simplify the ha
- [releng] Add a dependency to CycloneDX to compute the backend software bill of materials during the build

=== Bug fixes

- https://github.com/eclipse-syson/syson/issues/606[#606] [interconnection-view] Prevent nested part to be rendered as border nodes
- https://github.com/eclipse-syson/syson/issues/619[#619] [diagrams] Fix an issue where a click on inherited members inside compartments was raising an error instead of displaying the palette.

=== Improvements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
import org.eclipse.sirius.components.core.api.IEditingContext;
import org.eclipse.sirius.components.core.api.IEditingContextProcessor;
import org.eclipse.sirius.components.emf.ResourceMetadataAdapter;
import org.eclipse.sirius.components.emf.services.IDAdapter;
import org.eclipse.sirius.components.emf.services.JSONResourceFactory;
import org.eclipse.sirius.components.emf.services.api.IEMFEditingContext;
import org.eclipse.sirius.emfjson.resource.JsonResource;
import org.eclipse.syson.util.SysONEContentAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -71,7 +73,7 @@ public void preProcess(IEditingContext editingContext) {
targetResourceSet.getResources().add(targetResource);
EList<EObject> contents = sourceResource.getContents();
for (EObject eObject : contents) {
targetResource.getContents().add(EcoreUtil.copy(eObject));
targetResource.getContents().add(this.copy(eObject, (JsonResource) targetResource));
}
}
});
Expand All @@ -84,4 +86,48 @@ public void preProcess(IEditingContext editingContext) {
@Override
public void postProcess(IEditingContext editingContext) {
}

private EObject copy(EObject eObject, JsonResource resource) {
SysONCopier copier = new SysONCopier(resource);
EObject result = copier.copy(eObject);
copier.copyReferences();
return result;
}

/**
* Copier that also copies the IDAdapter.
*
* @author arichard
*/
private class SysONCopier extends Copier {

private static final long serialVersionUID = 1L;

private final JsonResource resource;

SysONCopier(JsonResource resource) {
super();
this.resource = resource;
}

@Override
public EObject copy(EObject eObject) {
EObject copy = super.copy(eObject);
var adapter = this.findIDAdapter(eObject);
if (adapter != null) {
var oldId = adapter.getId().toString();
this.resource.setID(copy, oldId);
}
return copy;
}

private IDAdapter findIDAdapter(EObject eObject) {
for (var adapter : eObject.eAdapters()) {
if (adapter instanceof IDAdapter idAdapter) {
return idAdapter;
}
}
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ The changes are:
- Add a dependency to CycloneDX to compute the backend software bill of materials during the build

== Bug fixes
- Prevent nested part to be rendered as border nodes in the Interconnection View diagram

- Prevent nested part to be rendered as border nodes in the Interconnection View diagram.
- Fix an issue where a click on inherited members inside compartments was raising an error instead of displaying the palette.


== Improvements
Expand Down

0 comments on commit 16ee4ab

Please sign in to comment.