Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 323198 - CCE thrown in RepositoryAction from invoking IEvaluationContext's getVariable(String)
Summary: CCE thrown in RepositoryAction from invoking IEvaluationContext's getVariable...
Status: RESOLVED FIXED
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: 0.9.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 0.9.0-M3   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-19 19:26 EDT by Remy Suen CLA
Modified: 2010-09-08 04:22 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Remy Suen CLA 2010-08-19 19:26:51 EDT
Got this while using EGit. The code looks like this...

IHandlerService hsr = (IHandlerService) PlatformUI.getWorkbench()
    .getActiveWorkbenchWindow().getService(IHandlerService.class);
IEvaluationContext ctx = hsr.getCurrentState();
selection = (ISelection) ctx.getVariable(ISources.ACTIVE_MENU_SELECTION_NAME);

java.lang.ClassCastException: java.lang.Object cannot be cast to org.eclipse.jface.viewers.ISelection
at org.eclipse.egit.ui.internal.actions.RepositoryAction.getSelection(RepositoryAction.java:71)
at org.eclipse.egit.ui.internal.actions.RepositoryAction.run(RepositoryAction.java:94)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:724)
Comment 1 Paul Webster CLA 2010-08-19 19:52:58 EDT
In eclipse we return IEvaluationContext.UNDEFINED_VARIABLE (or something to that effect) when variables are "null".

In this case, if the context menu is not provided a selection, or if this code is called outside of a popup menu showing.

PW
Comment 2 Remy Suen CLA 2010-08-19 22:12:55 EDT
(In reply to comment #1)
> In eclipse we return IEvaluationContext.UNDEFINED_VARIABLE (or something to
> that effect) when variables are "null".

Mm...I actually just got the exception while working on EGit in 3.x. I have not been able to reproduce it at the moment though.
Comment 3 Remy Suen CLA 2010-08-25 07:03:07 EDT
I think there is probably still a source provider issue in 4.x but EGit should add an instanceof check to their code instead of arbitrarily downcasting.
Comment 4 Remy Suen CLA 2010-08-25 07:12:45 EDT
Please also fix the code in RepositoryActionHandler.
Comment 5 Mathias Kinzler CLA 2010-08-25 07:41:30 EDT
Code review at http://egit.eclipse.org/r/#change,1412
Comment 6 Mathias Kinzler CLA 2010-08-25 12:51:43 EDT
First one is merged as 51fab2f07155099d6ee08986f6c1d8dc1f67b0af, but we need another round: http://egit.eclipse.org/r/#change,1419
Comment 7 Mathias Kinzler CLA 2010-09-08 04:22:29 EDT
Merged as 0f65928171227869936e05703709ec00e7ef3f89