Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Using a ListSelectionDialog in a E4 RCP Application
Using a ListSelectionDialog in a E4 RCP Application [message #901113] Thu, 09 August 2012 20:47 Go to next message
Vince Cadmus is currently offline Vince CadmusFriend
Messages: 14
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

Re: Using a ListSelectionDialog in a E4 RCP Application [message #901131 is a reply to message #901113] Thu, 09 August 2012 22:50 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 242
Registered: July 2009
Senior Member
Pure E4 apps can't use anything in org.eclipse.ui.*.
Re: Using a ListSelectionDialog in a E4 RCP Application [message #901161 is a reply to message #901131] Fri, 10 August 2012 07:41 Go to previous messageGo to next message
Vince Cadmus is currently offline Vince CadmusFriend
Messages: 14
Registered: July 2012
Junior Member
Brian de Alwis wrote on Thu, 09 August 2012 18:50
Pure E4 apps can't use anything in org.eclipse.ui.*.


Wah, this sounds a bit harsh, so many useful things in org.eclipse.ui.* that can't be used in E4 apps ! Sad

(by the way, my ugly try/catch seems to work well for the ListSelectionDialog, so as it is just an internal app I'll keep with this for now)
Re: Using a ListSelectionDialog in a E4 RCP Application [message #901171 is a reply to message #901161] Fri, 10 August 2012 08:14 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot CelaFriend
Messages: 597
Registered: December 2010
Senior Member

In e4 you do things through services and DI (org.eclipse.e4.ui.*), not singletons like 3.x.

I gave a quick look at your code and if the active shell is what you need, simply inject it like this:

@Inject 
@Named(IServiceConstants.ACTIVE_SHELL)
private Shell shell;
Re: Using a ListSelectionDialog in a E4 RCP Application [message #901174 is a reply to message #901171] Fri, 10 August 2012 08:17 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5470
Registered: July 2009
Senior Member
The problem is the reachout to the help system!

Tom

Am 10.08.12 10:14, schrieb Sopot Cela:
> In e4 you do things through services and DI (org.eclipse.e4.ui.*), not
> singletons like 3.x.
> I gave a quick look at your code and if the active shell is what you
> need, simply inject it like this:
>
>
> @Inject @Named(IServiceConstants.ACTIVE_SHELL)
> private Shell shell;
>
Re: Using a ListSelectionDialog in a E4 RCP Application [message #901175 is a reply to message #901161] Fri, 10 August 2012 08:18 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5470
Registered: July 2009
Senior Member
You are welcome to help us refactoring the stuff found there. We would
have to split things into bundles, abstract away calls through services.
The ListSelectionDialog is a nice candidate, if you copy it to a project
which only depends SWT/JFace you'll immediately spot what needs to be
changed.

Tom

Am 10.08.12 09:41, schrieb Vince Cadmus:
> Brian de Alwis wrote on Thu, 09 August 2012 18:50
>> Pure E4 apps can't use anything in org.eclipse.ui.*.
>
>
> Wah, this sounds a bit harsh, so many useful things in org.eclipse.ui.*
> that can't be used in E4 apps ! :(
>
> (by the way, my ugly try/catch seems to work well for the
> ListSelectionDialog, so as it is just an internal app I'll keep with
> this for now)
Re: Using a ListSelectionDialog in a E4 RCP Application [message #901311 is a reply to message #901161] Fri, 10 August 2012 17:22 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 242
Registered: July 2009
Senior Member
Vince Cadmus wrote on Fri, 10 August 2012 03:41
Brian de Alwis wrote on Thu, 09 August 2012 18:50
Pure E4 apps can't use anything in org.eclipse.ui.*.


Wah, this sounds a bit harsh, so many useful things in org.eclipse.ui.* that can't be used in E4 apps ! Sad


Sorry, should have added ", unfortunately" Wink

Brian.
Re: Using a ListSelectionDialog in a E4 RCP Application [message #902052 is a reply to message #901311] Wed, 15 August 2012 16:25 Go to previous messageGo to next message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1049
Registered: July 2009
Senior Member

I migrated ListSelectionDialog to JFace. Follow https://bugs.eclipse.org/bugs/show_bug.cgi?id=350251 to see if it gets accepted.
Re: Using a ListSelectionDialog in a E4 RCP Application [message #902277 is a reply to message #902052] Thu, 16 August 2012 18:02 Go to previous messageGo to next message
Vince Cadmus is currently offline Vince CadmusFriend
Messages: 14
Registered: July 2012
Junior Member
Thanks Lars ! By the way, the discussion on the target link is interesting (and could help me to participate to some refactoring one day, as for now I feel a bit newby to do it Wink )

(and by the way too, thanks also for your wonderful tutorials, Lars, it helps me - and lot of people I think - a lot ! Wink )
Re: Using a ListSelectionDialog in a E4 RCP Application [message #902281 is a reply to message #902277] Thu, 16 August 2012 18:09 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot CelaFriend
Messages: 597
Registered: December 2010
Senior Member

It's never too early to contribute.
Re: Using a ListSelectionDialog in a E4 RCP Application [message #902361 is a reply to message #902277] Fri, 17 August 2012 10:17 Go to previous message
Lars Vogel is currently offline Lars VogelFriend
Messages: 1049
Registered: July 2009
Senior Member

Thanks Vince for the feedback. Would be great if you to migrate another ListDialog.
Previous Topic:PartSashContainer: Children
Next Topic:SplashScreen
Goto Forum:
  


Current Time: Sat Nov 29 10:13:21 GMT 2014

Powered by FUDForum. Page generated in 0.02302 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software