| Summary: | Declarative Services using EMF suppress Choose Workspace Dialog | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Modeling] EMF | Reporter: | Gregor Pfeifer <gregor.pfeifer> | ||||||
| Component: | Core | Assignee: | Ed Merks <Ed.Merks> | ||||||
| Status: | CLOSED FIXED | QA Contact: | |||||||
| Severity: | normal | ||||||||
| Priority: | P3 | CC: | ekke, john.arthorne | ||||||
| Version: | unspecified | ||||||||
| Target Milestone: | --- | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows 7 | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
|
Description
Gregor Pfeifer
Created attachment 205588 [details]
ZIP to reproduce the problem
Created attachment 205589 [details]
Patch with proposed solution
Sorry, I don't understand any of this so I'm reluctant to make changes I don't understand. It appears I'd be forcing the UI to start as well, which seems bad because nothing here relies on that and the next guy might complain that they want something even further downstream to be started before the UI or that they don't want the UI started at all, even though it's available. Hopefully John could comment on this. After all, E4 uses EMF and hasn't had this problem. Maybe this problem should be fixed in the UI or maybe the workspace needs to have an extension point the UI uses to ensure that what the UI wants to happen happens when the workspace starts. I don't know... The proposed solution is an extension to the current code and is very similar to the existing code.
The existing code in EMFPlugin checks if org.eclipse.core.resources is available:
public static final boolean IS_RESOURCES_BUNDLE_AVAILABLE;
static
{
// code to initialize IS_RESOURCES_BUNDLE_AVAILABLE
...
}
The proposed solution checks in addition if org.eclipse.ui is available:
public static final boolean IS_ECLIPSE_UI_AVAILABLE;
static
{
// code to initialize IS_ECLIPSE_UI_AVAILABLE (similar to existing code)
....
}
The existing code calls ResourcesPlugin.getWorkspace().getRoot() when "org.eclipse.core.resources" is available
if (IS_RESOURCES_BUNDLE_AVAILABLE) {
workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
}
The proposed solution add an additional check:
if (IS_RESOURCES_BUNDLE_AVAILABLE {
if (IS_ECLIPSE_UI_AVAILABLE) {
// If org.eclipse.ui is available
// set workSpaceRoot after the workbench is initialized
new WorkbenchTracker(context).open();
} else {
workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
}
}
The WorkbenchTracker subclasses org.osgi.util.tracker.ServiceTracker and will never ever force any UI to start. It even has no dependency to "org.eclipse.ui". The WorkbenchTracker will be called when the Eclipse Workbench is initialized and will then initialize the static variable workspaceRoot (workspaceRoot = ResourcesPlugin.getWorkspace().getRoot())
Just discovered: Same problem occurs with Riena EMF Dynamic Views https://bugs.eclipse.org/bugs/show_bug.cgi?id=288063 Might it be simpler to move the code:
private static IWorkspaceRoot workspaceRoot = null;
/**
* Returns the workspace root, or <code>null</code>, if the runtime environment is stand-alone.
* @return the workspace root, or <code>null</code>.
*/
public static IWorkspaceRoot getWorkspaceRoot()
{
if (workspaceRoot == null && IS_RESOURCES_BUNDLE_AVAILABLE && System.getProperty("org.eclipse.emf.ecore.plugin.EcorePlugin.doNotLoadResourcesPlugin") == null)
{
workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
}
return workspaceRoot;
}
This way the workspace is created on demand by anyone who needs it. I'd feel more comfortable with that because I understand it better and it's harder to imagine anyone even being able to notice...
Yes, this is much simpler. Since in my environment no bundle calls EcorePlugin>>getWorkspaceRoot during Eclipse startup it solves my problem. Thank you! The change was committed to CVS for EMF 2.8. The changes are available in builds. *** Bug 288063 has been marked as a duplicate of this bug. *** |