Skip to content

Commit

Permalink
[722] Allow to drop any element on the diagram background
Browse files Browse the repository at this point in the history
Bug: #722
Signed-off-by: Gwendal Daniel <gwendal.daniel@obeosoft.com>
  • Loading branch information
gdaniel committed Sep 5, 2024
1 parent 7b26a6c commit d635ca0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ It is now possible to reference an element in any of the containing namespaces o
The drop doesn't reveal the _documentation_ compartment anymore, and a warning message is displayed to indicate that the drop is not possible.
- https://github.com/eclipse-syson/syson/issues/711[#711] [diagrams] Prevent feature typing from disappearing when nesting a PartUsage in a PartDefinition.
* The tool _Add Part as nested Part_ now correctly keeps the existing relationships of the PartUsage after its owner is changed.
- https://github.com/eclipse-syson/syson/issues/722[#722] [diagrams] Allow the drop of the root element of a diagram on its background.

=== Improvements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,9 @@ public Element dropElementFromExplorer(Element element, IEditingContext editingC
optTargetElement = this.objectService.getObject(editingContext, diagramContext.getDiagram().getTargetObjectId());
}
if (optTargetElement.isPresent() && optTargetElement.get() instanceof Element targetElement) {
// Check if the element we attempt to drop is in the ancestors of the target element. If it is the case we
// want to prevent the drop.
if (EMFUtils.isAncestor(element, targetElement)) {
// Check if the element we attempt to drop is in the ancestors of the target element and we attempt to drop
// it on anything else than the diagram background. If it is the case we want to prevent the drop.
if (EMFUtils.isAncestor(element, targetElement) && selectedNode != null) {
final String errorMessage;
if (element == targetElement) {
errorMessage = MessageFormat.format("Cannot drop {0} on itself", element.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ It is now possible to reference an element in any of the containing namespaces o
The drop isn't allowed anymore, and a warning message is displayed.
- Fix an issue that deleted feature typing specialization when nesting a PartUsage in a PartDefinition.
* The tool _Add Part as nested Part_ now correctly keeps the existing relationships of the PartUsage after its owner is changed.
- Fix an issue that prevented the drop of the root element of a diagram on its background.

== Improvements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ describe('Drop From Explorer Tests', () => {
.should('exist');
});

it.only('Then we can drop the Package on the diagram', () => {
const dataTransfer = new DataTransfer();
explorer.dragTreeItem(sysmlv2.getRootElementLabel(), dataTransfer);
diagram.dropOnDiagram(diagramLabel, dataTransfer);

diagram.getNodes(diagramLabel, sysmlv2.getRootElementLabel()).should('exist');
});

it('Then we can drop the PartUsage on the diagram, and its compartment are not visible', () => {
const dataTransfer = new DataTransfer();
explorer.dragTreeItem('part', dataTransfer);
Expand Down

0 comments on commit d635ca0

Please sign in to comment.