Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,9 @@ private void shouldTopRightAdjusted(Event event) {
// Ensure that it's a View part's menu or toolbar
MUIElement uiElement = (MUIElement) objElement;
MUIElement parent = modelService.getContainer(uiElement);
while (parent instanceof MMenu && !(parent instanceof MPopupMenu)) {
parent = modelService.getContainer(parent);
}
if (!(parent instanceof MPart)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,48 @@ public void testPartStack_ViewMenuShowWhenItemsAdded_Bug385083() {
// assertFalse(toolbar.getVisible());
}

@Test
public void testPartStack_ViewMenuFollowsItemVisibility() {
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);

MDirectMenuItem item = ems.createModelElement(MDirectMenuItem.class);
item.setVisible(false);
menu.getChildren().add(item);

contextRule.createAndRunWorkbench(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;
}
}
assertNotNull(toolbar);
assertFalse(toolbar.getVisible());

item.setVisible(true);
contextRule.spinEventLoop();
assertTrue(toolbar.getVisible());

item.setVisible(false);
contextRule.spinEventLoop();
assertFalse(toolbar.getVisible());
}

@Test
public void testCreateGuiBug301021() {
// create two descriptors
Expand Down
Loading