Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 376253 - Handler with no command NPEs in E4Workbench.processHierarchy
Summary: Handler with no command NPEs in E4Workbench.processHierarchy
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.2 M7   Edit
Assignee: Paul Webster CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-06 09:26 EDT by Marc Teufel CLA
Modified: 2012-05-01 15:03 EDT (History)
2 users (show)

See Also:


Attachments
Patch avoiding the NPE (1.40 KB, patch)
2012-04-10 17:25 EDT, Nobody - feel free to take it CLA
pwebster: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Teufel CLA 2012-04-06 09:26:33 EDT
If i put two Handlers to a TrimmedWindow and use only of it (attribut commandId of one of the both handlers isn't used) i get following error:

!ENTRY org.eclipse.e4.ui.workbench 4 0 2012-04-06 15:04:44.918
!MESSAGE Exception occurred while rendering: org.eclipse.e4.ui.model.application.ui.basic.impl.TrimmedWindowImpl@c1a0eb (elementId: null, tags: null, contributorURI: platform:/plugin/net.teufel.e4.helloworld.ui) (widget: null, renderer: null, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (label: Hello world, iconURI: null, tooltip: null, context: TrimmedWindowImplContext, variables: [], x: -2147483648, y: -2147483648, width: 640, height: 480)
!STACK 0
java.lang.NullPointerException
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.processHierarchy(E4Workbench.java:164)


What is the idea behind putting Handlers to Window or TrimmedWindow? To get a better structure? When does it makes sense to collect more than one item in a window? Each handler has to be conntected to a command, why am i only able to define commands inside of Application? 
At the moment I have to connect each Handler to a command otherwise i get the error above so its not possible to hold two times a similar handler in a TrimmedWindow and decide during runtime wich of the two handlers gets active finally and will be connected to the Toolbaritem.
Comment 1 Paul Webster CLA 2012-04-10 08:50:07 EDT
The model describes the starting state of the system, and currently it is required to be valid.  That means your handlers must handle a command.

If you are trying to decide which handler to use for a command at runtime, in Eclipse4, you would use the EHandlerService to activate the specific handler, or you would remove the existing handler from the model and then add the new one.

Commands are global semantic abstractions.  They're on the application because it doesn't make sense to scope them lower that than.  There's only one Exit command or one Copy command ... Exit probably only has one handler, and Copy has many handlers.

The handlers can be defined at the appropriate level to avoid the complex activeWhen core expressions used in 3.x, simply to have handlers at the window or part level.

That being said, it still shouldn't NPE.  That must be fixed.

PW
Comment 2 Nobody - feel free to take it CLA 2012-04-10 17:25:26 EDT
Created attachment 213826 [details]
Patch avoiding the NPE

Patch which avoids the NPE on starting of an application with a handler without a command.
Comment 4 Paul Webster CLA 2012-05-01 15:03:27 EDT
by inspection in I20120430-1800
PW