Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354967 - [Compatibility] Menu items appear where they shouldn't with Eclipse 4.2
Summary: [Compatibility] Menu items appear where they shouldn't with Eclipse 4.2
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.2 M2   Edit
Assignee: Remy Suen CLA
QA Contact: Remy Suen CLA
URL:
Whiteboard:
Keywords:
: 355512 (view as bug list)
Depends on: 355210
Blocks: 354962 354965 333742 334303
  Show dependency tree
 
Reported: 2011-08-17 11:32 EDT by Nicolas Bros CLA
Modified: 2012-11-07 08:21 EST (History)
2 users (show)

See Also:


Attachments
MenuHelper patch v1 (3.23 KB, patch)
2011-08-24 09:29 EDT, Remy Suen CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Bros CLA 2011-08-17 11:32:39 EDT
We have discovered with MoDisco and EMF Facet that many context menu items appear in every context menu in Eclipse 4.2.
They shouldn't, and they didn't with Eclipse 3.x => this looks like a bug with the E4 compatibility layer.
Comment 1 Remy Suen CLA 2011-08-17 11:50:24 EDT
Please provide the XML snippets you are using for these actions. Your repository is very fine-grained and it's hard for me to know which bundle is contributing these menu items.
Comment 2 Remy Suen CLA 2011-08-17 14:13:25 EDT
I think this is because the enabledWhen clauses are on the handlers themselves. Will have to do some more poking.

http://dev.eclipse.org/viewcvs/viewvc.cgi/plugins/trunk/org.eclipse.gmt.modisco.infra.query.ui/plugin.xml?view=markup&root=Modeling_MODISCO
Comment 3 Remy Suen CLA 2011-08-17 16:19:10 EDT
When the visibleWhen is just one line as <visibleWhen checkEnabled="true"/>, our code doesn't generate an expression for it.

See MenuHelper's getVisibleWhen(IConfigurationElement).
Comment 5 Steffen Pingel CLA 2011-08-18 08:09:39 EDT
I also noticed that Source > Format shows up in various context menus in the Juno EPP Java package.
Comment 6 Remy Suen CLA 2011-08-18 14:37:09 EDT
(In reply to comment #3)
> When the visibleWhen is just one line as <visibleWhen checkEnabled="true"/>,
> our code doesn't generate an expression for it.

For this case we can choose to create a new expression that asks the handler service whether the handler for the given command can be executed. Then the visibility would just toggle accordingly based on the handler's enabledWhen clause.
Comment 7 Remy Suen CLA 2011-08-19 08:39:20 EDT
Even if we fix the problem per comment 6, there are still issues with the context menu because of exceptions being thrown in the handler implementations of isEnabled. We protect this code in 3.x but do not have this protection in 4.x at the moment, see bug 355210.

EMF Facet should probably still safe up their code though. A 3.x trace can be seen below.

java.lang.NullPointerException
	at org.eclipse.emf.facet.widgets.nattable.internal.handlers.RemoveLineHandler.isEnabled(RemoveLineHandler.java:52)
	at org.eclipse.ui.internal.handlers.HandlerProxy.isEnabled(HandlerProxy.java:320)
	at org.eclipse.core.commands.Command.isEnabled(Command.java:833)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:468)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:178)
	at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:247)
	at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:247)
Comment 8 Remy Suen CLA 2011-08-23 10:21:16 EDT
(In reply to comment #5)
> I also noticed that Source > Format shows up in various context menus in the
> Juno EPP Java package.

Opened bug 355512 for this problem. Not sure where it's coming from right now. Perhaps WindowBuilder?
Comment 9 Remy Suen CLA 2011-08-23 13:41:37 EDT
*** Bug 355512 has been marked as a duplicate of this bug. ***
Comment 10 Remy Suen CLA 2011-08-24 09:29:06 EDT
Created attachment 202082 [details]
MenuHelper patch v1

This patch illustrates the approach outlined in comment 6.
Comment 11 Remy Suen CLA 2011-08-29 14:57:52 EDT
Fix pushed to R4_development.
http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?h=R4_development&id=33fa8a7105586caa53036e753aa547294953b9b2

Thanks for bringing this problem to our attention, Nicholas and Steffen!
Comment 12 Remy Suen CLA 2011-09-13 09:46:31 EDT
Verified with I20110913-0200 on Windows XP.