Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 316701 - [Contributions] Service initialization wrong! Sources must be initialized before Handlers
Summary: [Contributions] Service initialization wrong! Sources must be initialized bef...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows Vista
: P3 major (vote)
Target Milestone: 3.6.1   Edit
Assignee: Paul Webster CLA
QA Contact: Paul Webster CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 323393
  Show dependency tree
 
Reported: 2010-06-13 11:31 EDT by Tonny Madsen CLA
Modified: 2010-11-10 05:23 EST (History)
4 users (show)

See Also:


Attachments
Sample code for problem (64.96 KB, application/octet-stream)
2010-06-13 11:33 EDT, Tonny Madsen CLA
no flags Details
WorkbenchServiceRegistry v01 (8.09 KB, patch)
2010-06-14 11:00 EDT, Paul Webster CLA
no flags Details | Diff
A fragment for 3.6.0 (80.44 KB, application/octet-stream)
2010-06-14 11:32 EDT, Paul Webster CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tonny Madsen CLA 2010-06-13 11:31:52 EDT
The initialization of services in the Workbench has been reworked in in 3.6 compared with 3.5

Unfortunately source providers (initialized in Workbench.startSourceProviders()) are now initialized *after* handlers (in Workbench.initializeDefaultServices()).

The result is that a handler with an activeWhen expression which refers to a source variable _other_ that the built-in variables from SourcePriorityNameMapping, will get source priority 0 - same as if it does not have an expression. Which is wrong, if the used variables have priorities installed via the extension point org.eclipse.ui.services/sourceProvider/variable.

This is a blocking issues for RCP applications, as far as I can see, as later execution of the command results in no active handler!

I cannot say, why the change was made between 3.5 and 3.6 - quite deliberate as seen from comments in workbench.java - so I cannot guess on a fix...

-- Configuration Details --
Product: Eclipse 1.3.0.20100526-1137 (org.eclipse.epp.package.rcp.product)
Installed Features:
 org.eclipse.platform 3.6.0.v20100527-9gF78GpqFt6trOGhCMC-p4sxjlLvz0FU_i
Comment 1 Tonny Madsen CLA 2010-06-13 11:33:05 EDT
Created attachment 171804 [details]
Sample code for problem

Attached a sample RCP project that illustrates the problem with the copy command
Comment 2 Remy Suen CLA 2010-06-13 16:40:43 EDT
Likely caused by bug 306736.
Comment 3 Tonny Madsen CLA 2010-06-13 17:18:48 EDT
(In reply to comment #2)
> Likely caused by bug 306736.
I agree.

The initialization of sources most likely should be split into two parts:

- reading the services extensions - but not creating the providers themselves - very early in the initialization. Likely as in 3.5
- creating the providers themselves. Likely as in 3.6
Comment 4 Tonny Madsen CLA 2010-06-14 06:27:13 EDT
Paul, how can you work around this problem in an application?`By setting the severity to major you essentially say, there exists a work-around for this... Or?
Comment 5 Paul Webster CLA 2010-06-14 09:00:31 EDT
It represents a major loss of functionality (major).  Specifically, only for handlers that are competing for the same command and their only differentiator is a user supplied variable will now conflict instead of choosing one.  Normal says "some loss of functionality under specific circumstances" since it only effects certain types of handlers, which could be applied, but I think it's more serious than that.

As for a workaround, there is only a programmatic one ... adding an existing variable to the activeWhen, or in your application start after you've called PlatformUI.createDisplay() but before PlatformUI.createAndRunWorkbench(*) to call org.eclipse.ui.internal.services.SourcePriorityNameMapping.addMapping(String, int).

The advantage of calling SourcePriorityNameMapping.addMapping(String, int) is that in 3.6.1 it will only be filling in the values that will once again be coming from the XML.  The algorithm is in org.eclipse.ui.internal.services.WorkbenchServiceRegistry.processVariables(IConfigurationElement[]), but basically it's "one greater than the provided name" for names defined in org.eclipse.ui.internal.services.WorkbenchServiceRegistry.supportedLevels

I can even provide a small programmatic snippet (with on reflective call) that could be used as a workaround in your app if you think that will help.


I'm going to ask around today, but I'm pretty sure that the 3.6 boat has sailed.  I'll try and get a patch today, but I believe the best I can do is commit this to R3_6_maintenance so it will be in the first maintenance build.

PW
Comment 6 Tonny Madsen CLA 2010-06-14 09:22:31 EDT
I'll see if I can get the work-around to work as a fragment against Workbench 3.6.0 using the data from the extension point.

Note that this problem will be seen in a very large set of RCP applications, as the common pattern here is to install a number of sources and propertyTesters to access to the global state in expressions.
Comment 7 Paul Webster CLA 2010-06-14 11:00:10 EDT
Created attachment 171833 [details]
WorkbenchServiceRegistry v01

Initialize the SourcePriorityNameMapping from the same place they were initialized before.

PW
Comment 8 Paul Webster CLA 2010-06-14 11:32:38 EDT
Created attachment 171840 [details]
A fragment for 3.6.0

This is an example of using the e4-workbench.jar hook to patch the 3.6.0 workbench.  I just put it in eclipse/dropins.  I can provide the project zip as well, if it helps.

PW
Comment 9 Tonny Madsen CLA 2010-06-14 14:53:23 EDT
Thanks, I'll test later tonight or early tomorrow...
Comment 10 Paul Webster CLA 2010-08-18 15:14:11 EDT
(In reply to comment #9)
> Thanks, I'll test later tonight or early tomorrow...

I was considering this for 3.6.1.  Tonny, does my intended fix help in your case?

PW
Comment 11 Paul Webster CLA 2010-08-19 07:53:28 EDT
Boris, can I get a +1 for 3.6.1?

PW
Comment 12 Boris Bokowski CLA 2010-08-19 10:14:47 EDT
+1 from me, but it would be really good to hear from Tonny if this indeed fixes his problem.
Comment 13 Tonny Madsen CLA 2010-08-19 15:19:33 EDT
+1 from me as well.

Without the patch my tests fails on 3.6.1. With the patch, all the tests succeeds!

Thanks in advance...
Comment 14 Paul Webster CLA 2010-08-23 10:41:30 EDT
Released into 3.6.1
PW