Using a ListSelectionDialog in a E4 RCP Application [message #901113] |
Thu, 09 August 2012 20:47 |
Vince Cadmus Messages: 16 Registered: July 2012 |
Junior Member |
|
|
When I try to open a ListSelectionDialog in an E4 RCP application, I get an exception :
java.lang.IllegalStateException: Workbench has not been created yet.
at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92)
at org.eclipse.ui.dialogs.ListSelectionDialog.configureShell(ListSelectionDialog.java:156)
at org.eclipse.jface.window.Window.createShell(Window.java:502)
at org.eclipse.jface.window.Window.create(Window.java:430)
at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089)
at org.eclipse.jface.window.Window.open(Window.java:790)
In fact, looking at the problem in debug, the Workbench.getInstance() used in PlatformUI.getWorkbench() returns null.
As far as I understand, the workbench instance is created in Workbench.createAndRunWorkbench, which is called by PlatformUI.createAndRunWorkbench, which is called by IDEApplication.start().
But when running an E4 RCP application (and not a plugin), IDEApplication is not used : E4Application is the one that is launched, and it does not create a Workbench instance (but a E4Workbench is instanciated).
So I don't know if this is a bug in E4 that makes the ListSelectionDialog (and all dialogs that don't override the Dialog.open method) unavailable, or if I should use it another way.
Can somebody help me about this ?
Thanks !
EDIT :
I made a mistake : the PlatformUI.getWorkbench() is just used by the ListSelectionDialog.configureShell() method, so the other dialogs are not impacted. To bypass the problem, I overrided the configureShell method to catch the exception, but it's not very nice :
new ListSelectionDialog(Display.getCurrent().getActiveShell(),
new String[] { "1", "2", "3" },
new ArrayContentProvider(),
new LabelProvider(),
"Please choose!") {
protected void configureShell(org.eclipse.swt.widgets.Shell shell) {
try {
super.configureShell(shell);
}
catch(IllegalStateException e) {}
};
}.open();
[Updated on: Thu, 09 August 2012 21:02] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06555 seconds