Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRolf Theunissen2019-04-14 15:26:32 -0400
committerLars Vogel2019-04-15 05:33:00 -0400
commit289aa70e87506a076e6382b229a38a281a52a1de (patch)
tree40072c289b76c3927aefbb0358465aa32dc7271c
parentd63fece7b3bcd528c9eaa9efb54abdd3300b6ee5 (diff)
downloadeclipse.platform.ui-289aa70e87506a076e6382b229a38a281a52a1de.tar.gz
eclipse.platform.ui-289aa70e87506a076e6382b229a38a281a52a1de.tar.xz
eclipse.platform.ui-289aa70e87506a076e6382b229a38a281a52a1de.zip
Bug 385083 - Part menu doesn't show on part when adding items to itI20190415-1800
Also updating TopRight when the View Menu changes Change-Id: Id049cd808f1596ee0c18db3863e15e52f26edb4e Signed-off-by: Rolf Theunissen <rolf.theunissen@gmail.com>
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java6
-rw-r--r--tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/workbench/PartRenderingEngineTests.java48
2 files changed, 52 insertions, 2 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java
index 446c55afe9..c672737b5a 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/StackRenderer.java
@@ -56,6 +56,7 @@ import org.eclipse.e4.ui.model.application.ui.basic.MStackElement;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;
+import org.eclipse.e4.ui.model.application.ui.menu.MPopupMenu;
import org.eclipse.e4.ui.model.application.ui.menu.MToolBar;
import org.eclipse.e4.ui.workbench.IPresentationEngine;
import org.eclipse.e4.ui.workbench.UIEvents;
@@ -298,8 +299,9 @@ public class StackRenderer extends LazyStackRenderer implements IPreferenceChang
void subscribeTopicChildrenChanged(@UIEventTopic(UIEvents.ElementContainer.TOPIC_CHILDREN) Event event) {
Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
- // only interested in changes to toolbars
- if (!(changedObj instanceof MToolBar)) {
+ // only interested in changes to toolbars and view menu (not popup menus)
+ if (!(changedObj instanceof MToolBar)
+ && !(changedObj instanceof MMenu && !(changedObj instanceof MPopupMenu))) {
return;
}
diff --git a/tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/workbench/PartRenderingEngineTests.java b/tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/workbench/PartRenderingEngineTests.java
index 01ca93be34..41bf9ec039 100644
--- a/tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/workbench/PartRenderingEngineTests.java
+++ b/tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/workbench/PartRenderingEngineTests.java
@@ -503,6 +503,54 @@ public class PartRenderingEngineTests {
}
@Test
+ public void testPartStack_ViewMenuShowWhenItemsAdded_Bug385083() throws Exception {
+ MApplication application = ems.createModelElement(MApplication.class);
+ application.setContext(appContext);
+ appContext.set(MApplication.class, application);
+
+ MWindow window = ems.createModelElement(MWindow.class);
+ application.getChildren().add(window);
+
+ MPartStack stack = ems.createModelElement(MPartStack.class);
+ window.getChildren().add(stack);
+
+ MPart part = ems.createModelElement(MPart.class);
+ part.setContributionURI("bundleclass://org.eclipse.e4.ui.tests/org.eclipse.e4.ui.tests.workbench.SampleView");
+ stack.getChildren().add(part);
+
+ MMenu menu = ems.createModelElement(MMenu.class);
+ menu.getTags().add(StackRenderer.TAG_VIEW_MENU);
+ part.getMenus().add(menu);
+
+ wb = new E4Workbench(application, appContext);
+ wb.createAndRunUI(window);
+
+ CTabFolder folder = (CTabFolder) stack.getWidget();
+ Composite compA = (Composite) folder.getTopRight();
+ ToolBar toolbar = null;
+ for (Control child : compA.getChildren()) {
+ if (child.getData().equals(StackRenderer.TAG_VIEW_MENU)) {
+ toolbar = (ToolBar) child;
+ }
+ }
+ assertTrue(toolbar != null);
+
+ assertFalse(toolbar.getVisible());
+
+ MDirectMenuItem item = ems.createModelElement(MDirectMenuItem.class);
+ menu.getChildren().add(item);
+ spinEventLoop();
+
+ assertTrue(toolbar.getVisible());
+
+ // TODO disabled due to bug 461655/498320
+ // menu.getChildren().remove(item);
+ // spinEventLoop();
+ //
+ // assertFalse(toolbar.getVisible());
+ }
+
+ @Test
public void testCreateGuiBug301021() throws Exception {
MApplication application = ems.createModelElement(MApplication.class);
application.setContext(appContext);

Back to the top