Skip to content

Commit 8f5acb7

Browse files
committed
Fix tab selection on move and enhance test coverage
1 parent 62df44b commit 8f5acb7

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ void subscribeTopicChildrenMoved(@UIEventTopic(UIEvents.ElementContainer.TOPIC_C
438438
Font font = item.getFont();
439439
Object data = item.getData();
440440

441+
boolean wasSelected = tabFolder.getSelection() == item;
442+
441443
item.dispose();
442444

443445
CTabItem newItem = new CTabItem(tabFolder, (showClose ? SWT.CLOSE : SWT.NONE), newIndex);
@@ -448,6 +450,9 @@ void subscribeTopicChildrenMoved(@UIEventTopic(UIEvents.ElementContainer.TOPIC_C
448450
newItem.setData(data);
449451
newItem.setData(OWNING_ME, movedElement);
450452
newItem.setControl(control);
453+
if (wasSelected) {
454+
tabFolder.setSelection(newItem);
455+
}
451456
}
452457

453458
@Inject

tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRendererMoveTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.eclipse.e4.ui.workbench.renderers.swt;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertFalse;
45
import static org.junit.jupiter.api.Assertions.assertNotSame;
56
import static org.junit.jupiter.api.Assertions.assertTrue;
67

@@ -84,7 +85,8 @@ public void testPartMoveUpdatesWidget() throws Exception {
8485

8586
// The old item1 should be disposed
8687
assertTrue(item1.isDisposed(), "Old item for part1 should be disposed");
87-
88+
assertFalse(item2.isDisposed(), "Item2 should not be disposed");
89+
8890
// part1 should have a NEW widget item, but the part's widget (content) should be preserved
8991
assertNotSame(item1, newItem1);
9092
assertEquals(part1, newItem1.getData(AbstractPartRenderer.OWNING_ME), "New item should have OWNING_ME set");

0 commit comments

Comments
 (0)