|
1 | 1 | /*******************************************************************************
|
2 |
| - * Copyright (c) 2010, 2018 IBM Corporation and others. |
| 2 | + * Copyright (c) 2010, 2025 IBM Corporation and others. |
3 | 3 | *
|
4 | 4 | * This program and the accompanying materials
|
5 | 5 | * are made available under the terms of the Eclipse Public License 2.0
|
|
21 | 21 | import java.util.stream.Stream;
|
22 | 22 | import org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer;
|
23 | 23 | import org.eclipse.e4.ui.model.application.ui.MUIElement;
|
| 24 | +import org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder; |
24 | 25 | import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
|
25 | 26 | import org.eclipse.e4.ui.model.application.ui.basic.MStackElement;
|
26 | 27 | import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
|
@@ -260,13 +261,19 @@ private void dock(MUIElement dragElement, int dropIndex) {
|
260 | 261 | // Note 3: currently if we drag/drop parts, it looks like for editor parts we
|
261 | 262 | // always drop PartImpl instances, for views we drop PartStackImpl or
|
262 | 263 | // 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. |
263 | 268 | MStackElement viewWithSameId = null;
|
264 | 269 | if (elementIndex == -1 && !dragElement.getTags().contains("Editor")) { //$NON-NLS-1$
|
265 | 270 | 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 | + } |
270 | 277 | }
|
271 | 278 | }
|
272 | 279 | }
|
|
0 commit comments