Bug 543269 - reopenEditors ContributionItem causing subsequent menu items to not be displayed
Summary: reopenEditors ContributionItem causing subsequent menu items to not be displayed
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.11   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2019-01-08 12:50 EST by Alex Macdonald CLA
Modified: 2020-08-25 11:47 EDT (History)
2 users (show)

See Also:


Attachments
Gif of the issue (30.78 KB, image/gif)
2019-01-08 12:50 EST, Alex Macdonald CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Macdonald CLA 2019-01-08 12:50:43 EST
Created attachment 277105 [details]
Gif of the issue

Hi!

I'm currently working on an RCP application that uses the reopenEditors ContributionItem in the Menu bar (via the ContributionItemFactory.REOPEN_EDITORS), and it's having an effect where items placed after it are hidden 50% of the time.

It appears that in the chain of adding items to the menu, if menu items are placed after the reopenEditors then they are not visible on the first instance of clicking on the menu drop down, but will be visible on the next click, and not visible on the next click, and so on (I have attached a gif to display what I'm seeing).

To test I've created a barebones RCP application [0] that simply adds a reopenEditors to the menu, and then adds an Exit action.

[0] https://github.com/aptmac/rcp-hello-world/blob/master/src/org/eclipse/ui/tutorials/rcp/part1/ApplicationActionBarAdvisor.java#L36
Comment 1 Massimo Rabbi CLA 2020-08-05 11:43:38 EDT
Hi, I had the same issue that you reported. I suppose it might be related to the changes introduced with the following bug (https://bugs.eclipse.org/bugs/show_bug.cgi?id=530966). In our product all worked fine with platform based on Eclipse 4.7.3a, but not most recent ones.

From my initial tests, I replaced the contribution line moving it to the top of the file menu creation similarly to what is done in the method org.eclipse.ui.internal.ide.WorkbenchActionBuilder#createFileMenu()

This seems to solve the problem of intermittent showing.
Comment 2 Andrey Loskutov CLA 2020-08-05 12:56:04 EDT
Can you please push a Gerrit patch with the fix proposal?
Comment 3 Massimo Rabbi CLA 2020-08-25 11:47:45 EDT
The code I modified is in our class that extends ActionBarAdvisor.
We simply moved the "recent files" menu creation to the beginning similar to what is done in the method org.eclipse.ui.internal.ide.WorkbenchActionBuilder#createFileMenu()

These four lines of code:

MenuManager recent = new MenuManager(WorkbenchMessages.OpenRecentDocuments_text);
recent.add(ContributionItemFactory.REOPEN_EDITORS.create(getWindow()));
recent.add(new GroupMarker(IWorkbenchActionConstants.MRU));
menu.add(recent);

It appears that trying to put the list as flat is causing the issue in this position as well.