Skip to content

Commit 79f26e4

Browse files
p-O-qmerks
authored andcommitted
Don't remove parts from part stack on DnD drop
Currently when dropping elements onto a part stack MStackElements are removed if their element ids are equal. This leads to disappearing parts in case of - at least one part created using part descriptors allowing multiple instances is present in the part stack - another such part is dropped onto the part stack Following the comments/notes the intention is to remove placeholder parts with the same element id as the element's id being dropped. This fix ensures that only instances of type MPlaceholder are removed from the part stack. Fixes #2771
1 parent abb10ef commit 79f26e4

File tree

4 files changed

+485
-8
lines changed

4 files changed

+485
-8
lines changed

bundles/org.eclipse.e4.ui.workbench.addons.swt/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-SymbolicName: org.eclipse.e4.ui.workbench.addons.swt;singleton:=true
4-
Bundle-Version: 1.5.600.qualifier
4+
Bundle-Version: 1.5.700.qualifier
55
Bundle-Name: %pluginName
66
Bundle-Vendor: %providerName
77
Bundle-Localization: plugin

bundles/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/ui/workbench/addons/dndaddon/StackDropAgent.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2010, 2018 IBM Corporation and others.
2+
* Copyright (c) 2010, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -21,6 +21,7 @@
2121
import java.util.stream.Stream;
2222
import org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer;
2323
import org.eclipse.e4.ui.model.application.ui.MUIElement;
24+
import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder;
2425
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
2526
import org.eclipse.e4.ui.model.application.ui.basic.MStackElement;
2627
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
@@ -260,13 +261,19 @@ private void dock(MUIElement dragElement, int dropIndex) {
260261
// Note 3: currently if we drag/drop parts, it looks like for editor parts we
261262
// always drop PartImpl instances, for views we drop PartStackImpl or
262263
// PlaceholderImpl instances. So one could use this for the check below too.
264+
// Note 4: b/c of parts allowing multiple instances with the same element id
265+
// it is necessary to also test for the instance type of the children of the
266+
// drop stack. If an instance is of type MPlaceholder and the element id is
267+
// equal to the drag element's element id the placeholder is removed.
263268
MStackElement viewWithSameId = null;
264269
if (elementIndex == -1 && !dragElement.getTags().contains("Editor")) { //$NON-NLS-1$
265270
for (MStackElement stackElement : dropChildren) {
266-
String id = stackElement.getElementId();
267-
if (id != null && id.equals(dragElement.getElementId())) {
268-
viewWithSameId = stackElement;
269-
break;
271+
if (stackElement instanceof MPlaceholder placeholder) {
272+
String id = placeholder.getElementId();
273+
if (id != null && id.equals(dragElement.getElementId())) {
274+
viewWithSameId = placeholder;
275+
break;
276+
}
270277
}
271278
}
272279
}

tests/org.eclipse.e4.ui.workbench.addons.swt.test/META-INF/MANIFEST.MF

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.e4.ui.workbench.addons.swt.test
5-
Bundle-Version: 1.5.100.qualifier
5+
Bundle-Version: 1.5.200.qualifier
66
Bundle-Localization: plugin
7-
Fragment-Host: org.eclipse.e4.ui.workbench.addons.swt;bundle-version="[1.1.0,2.0.0)"
7+
Fragment-Host: org.eclipse.e4.ui.workbench.addons.swt;bundle-version="[1.5.700,2.0.0)"
88
Bundle-RequiredExecutionEnvironment: JavaSE-17
99
Require-Bundle: org.eclipse.e4.core.commands;bundle-version="[1.0.0,2.0.0)",
1010
org.eclipse.core.databinding.observable;bundle-version="[1.4.0,2.0.0)",

0 commit comments

Comments
 (0)