Priyadarshini
Priyadarshini

Reputation: 129

Eclipse: How to perform a task before eclipse view starts

I have only one view in my plugin. And before the view starts, I want to make sure my server has been started as the view will be started depending on server. Currently, I start my server in Display thread as Display.getDefault().syncExec(), while starting my plugin - start(BundleContext context).

Sometimes, I see a deadlock between bundleloader and this thread. Bundleloader is waiting for my plugin to start, whereas my plugin start is waiting for the server to start because of syncExec() call.

How can I achieve this? Is there any way to perform a particular task before my view start?

Upvotes: 1

Views: 85

Answers (2)

flavio.donze
flavio.donze

Reputation: 8100

If you are not using E4 and your view extends org.eclipse.ui.part.ViewPart, there is an init()

void init(IViewSite site) throws PartInitException

which is called before createPartControl(Composite parent).

Maybe that helps?

Upvotes: 1

Aaron Digulla
Aaron Digulla

Reputation: 328780

Try to avoid Display.getDefault().syncExec(); this call can block the UI - Eclipse will freeze without any indication why.

Instead, you should start a background thread / worker job. When the worker is done (your server has been started), you should send a signal to the view.

The view should initialize itself with "Starting server...". When the signal arrives, you can update the UI to display the actual content. That way, you don't have to block and the user will see why they don't see anything :-) You can also display error messages when you couldn't start the server, etc.

Upvotes: 0

Related Questions