Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » how to know workbench is ready to use
how to know workbench is ready to use [message #332333] Mon, 20 October 2008 04:34 Go to next message
Hao Missing name is currently offline Hao Missing nameFriend
Messages: 115
Registered: July 2009
Senior Member
I tried to call org.eclipse.ui.PlatformUI.getWorkbench() but got the
following error:
java.lang.IllegalStateException: Workbench has not been created yet.

Highly appreciate if some one tells me how I can know the workbench is
ready to use.

thanks!
Re: how to know workbench is ready to use [message #332353 is a reply to message #332333] Mon, 20 October 2008 10:35 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Hao,

I've never seen such a thing before. At what point are you calling this?


Hao wrote:
> I tried to call org.eclipse.ui.PlatformUI.getWorkbench() but got the
> following error:
> java.lang.IllegalStateException: Workbench has not been created yet.
>
> Highly appreciate if some one tells me how I can know the workbench is
> ready to use.
>
> thanks!


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: how to know workbench is ready to use [message #332363 is a reply to message #332353] Mon, 20 October 2008 14:05 Go to previous messageGo to next message
Hao Missing name is currently offline Hao Missing nameFriend
Messages: 115
Registered: July 2009
Senior Member
<
I've never seen such a thing before. At what point are you calling this?


Hao wrote:

I tried to call org.eclipse.ui.PlatformUI.getWorkbench() but got the
following error:
java.lang.IllegalStateException: Workbench has not been created yet.

>

I am calling this in plugin activator's start() method.

thanks
Re: how to know workbench is ready to use [message #332369 is a reply to message #332363] Mon, 20 October 2008 15:46 Go to previous messageGo to next message
Boris Bokowski is currently offline Boris BokowskiFriend
Messages: 272
Registered: July 2009
Senior Member
Would it work to use Display.asyncExec to delay running the code that needs
to access the Workbench?

Boris

"Hao " <d95776@yahoo.com> wrote in message
news:aa091c8b136931aaff0ea0e0fb5a24e8$1@www.eclipse.org...
> <
> I've never seen such a thing before. At what point are you calling this?
>
>
> Hao wrote:
>
> I tried to call org.eclipse.ui.PlatformUI.getWorkbench() but got the
> following error:
> java.lang.IllegalStateException: Workbench has not been created yet.
>
>>
>
> I am calling this in plugin activator's start() method.
>
> thanks
>
Re: how to know workbench is ready to use [message #332373 is a reply to message #332363] Mon, 20 October 2008 16:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Hao,

That's a bad idea. What goal are you trying to achieve?


Hao wrote:
> <
> I've never seen such a thing before. At what point are you calling this?
>
>
> Hao wrote:
>
> I tried to call org.eclipse.ui.PlatformUI.getWorkbench() but got the
> following error:
> java.lang.IllegalStateException: Workbench has not been created yet.
>
>>
>
> I am calling this in plugin activator's start() method.
>
> thanks
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: how to know workbench is ready to use [message #332401 is a reply to message #332373] Tue, 21 October 2008 02:42 Go to previous messageGo to next message
Hao Missing name is currently offline Hao Missing nameFriend
Messages: 115
Registered: July 2009
Senior Member
<
That's a bad idea. What goal are you trying to achieve?
>

I tried to load the plug-in configuration information when the plug-in
starts. The configuration information is in a file which locates at the
root of the plug-in. I try to do the following
DDPlatformActivator.getDefault().getBundle().getEntry(ENV_CO NFIG_FILE) in
start.
Re: how to know workbench is ready to use [message #332404 is a reply to message #332373] Tue, 21 October 2008 02:47 Go to previous messageGo to next message
Hao Missing name is currently offline Hao Missing nameFriend
Messages: 115
Registered: July 2009
Senior Member
<
That's a bad idea. What goal are you trying to achieve?
>

I also tried to enable/disable activities by calling
PlatformUI.getWorkbench().getActivitySupport();
Re: how to know workbench is ready to use [message #332414 is a reply to message #332404] Tue, 21 October 2008 08:43 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Hao,

As Boris suggests, the only way is to delay what you're doing and the
way to achieve that is to post an event to the event queue. Hopefully
calling Display.getDefault wouldn't cause any problems and then you can
use that to follow Boris' advice. I'm still not sure why your plugin is
starting so early. It's usually a bad design idea to start plugins
early. If everyone did that, it could take minutes for the IDE to start...


Hao wrote:
> <
> That's a bad idea. What goal are you trying to achieve?
>>
>
> I also tried to enable/disable activities by calling
> PlatformUI.getWorkbench().getActivitySupport();
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: how to know workbench is ready to use [message #332418 is a reply to message #332414] Tue, 21 October 2008 09:05 Go to previous messageGo to next message
Remy Suen is currently offline Remy SuenFriend
Messages: 462
Registered: July 2009
Senior Member
Ed Merks wrote:
> As Boris suggests, the only way is to delay what you're doing and the
> way to achieve that is to post an event to the event queue. Hopefully
> calling Display.getDefault wouldn't cause any problems and then you can
> use that to follow Boris' advice.

Calling Display.getDefault() in a BundleActivator implementation may
cause problems. Bug 250048 will provide some additional context
regarding this problem.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=250048

> Hao wrote:
>> I also tried to enable/disable activities by calling
>> PlatformUI.getWorkbench().getActivitySupport();

This is certainly odd. I would expect the workbench to be up when your
plug-in has started. Your plug-in depends on org.eclipse.ui after all,
right? Is this consistently reproducible? This getActivitySupport()
invocation is in your AbstractUIPlugin subclass's start(BundleContext)
method, correct?

Remy
Re: how to know workbench is ready to use [message #332421 is a reply to message #332418] Tue, 21 October 2008 11:02 Go to previous messageGo to next message
Hao Missing name is currently offline Hao Missing nameFriend
Messages: 115
Registered: July 2009
Senior Member
[
This is certainly odd. I would expect the workbench to be up when your
plug-in has started. Your plug-in depends on org.eclipse.ui after all,
right? Is this consistently reproducible? This getActivitySupport()
invocation is in your AbstractUIPlugin subclass's start(BundleContext)
method, correct?
]

Yes. That's exactly what I am doing for both activities hiding/showing and
loading configuration file.
Re: how to know workbench is ready to use [message #332429 is a reply to message #332414] Tue, 21 October 2008 16:12 Go to previous messageGo to next message
Hao Missing name is currently offline Hao Missing nameFriend
Messages: 115
Registered: July 2009
Senior Member
[
As Boris suggests, the only way is to delay what you're doing and the way
to achieve that is to post an event to the event queue. Hopefully calling
Display.getDefault wouldn't cause any problems and then you can use that
to follow Boris' advice. I'm still not sure why your plugin is starting
so early. It's usually a bad design idea to start plugins early. If
everyone did that, it could take minutes for the IDE to start...
]

I tried
Display.getDefault().syncExec(new Runnable(){

public void run() {
getConfigManager();
}

});
in activator and got the following error.

Caused by: java.lang.IllegalStateException: Workbench has not been created
yet.
and
org.eclipse.swt.SWTException: Invalid thread access


Is there any way to be notified when Workbench is ready?
Re: how to know workbench is ready to use [message #332433 is a reply to message #332429] Tue, 21 October 2008 16:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: zx.code9.com

Hao wrote:
> Is there any way to be notified when Workbench is ready?

Create a new UIJob, that ensures that your job won't be run until the
workbench is up and ready.

Cheers,

~ Chris
Re: how to know workbench is ready to use [message #332503 is a reply to message #332433] Thu, 23 October 2008 18:45 Go to previous messageGo to next message
Hao Missing name is currently offline Hao Missing nameFriend
Messages: 115
Registered: July 2009
Senior Member
[
Create a new UIJob, that ensures that your job won't be run until the
workbench is up and ready
]

Hi,
do you mind tell how the UIJob will ensure my job won't be run until the
workbench is ready? From UIJob itself, I could not find the fact.

thanks
Re: how to know workbench is ready to use [message #332504 is a reply to message #332503] Thu, 23 October 2008 18:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: zx.code9.com

Hao wrote:
> [
> Create a new UIJob, that ensures that your job won't be run until the
> workbench is up and ready
> ]
>
> Hi,
> do you mind tell how the UIJob will ensure my job won't be run until the
> workbench is ready? From UIJob itself, I could not find the fact.

It happens for free :)

UIJob's won't run until the workbench is ready.

Cheers,

~ Chris
Re: how to know workbench is ready to use [message #332523 is a reply to message #332504] Fri, 24 October 2008 20:55 Go to previous messageGo to next message
Hao Missing name is currently offline Hao Missing nameFriend
Messages: 115
Registered: July 2009
Senior Member
[UIJob's won't run until the workbench is ready.]

Hi,

UIJob does make it work. Thanks a lot. I am curious a little bit. Can you
briefly explain how the UIJob knows the workbench is ready?

thanks
Re: how to know workbench is ready to use [message #332628 is a reply to message #332523] Mon, 03 November 2008 09:24 Go to previous message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
Hao wrote:
> [UIJob's won't run until the workbench is ready.]
>
> Hi,
>
> UIJob does make it work. Thanks a lot. I am curious a little bit. Can
> you briefly explain how the UIJob knows the workbench is ready?

Checking the (public) query function

PlatformUI.isWorkbenchRunning()

HTH & Greetings from Bremen,

Daniel Krügler
Previous Topic:extending Update Manager
Next Topic:[DataBinding] AssertionFailedException: "null argument" when using DataBindingContext's de
Goto Forum:
  


Current Time: Tue Apr 23 17:51:55 GMT 2024

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

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

Back to the top