[jbosstools-dev] Fwd: Quick SWT Question
phantomjinx
p.g.richardson at phantomjinx.co.uk
Wed Jul 15 11:19:56 EDT 2015
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
In addition to Display.asyncExec, you make want to put your code inside a runnable, launched from
its own thread.
My reasoning:
The workbench can be started after some plugins have already been activated as such
getWorkbench().getActiveWorkbenchWindow() can be null even on the UI thread. Consequently, I find
it prudent to create a polling thread that listens on getWorkbench().isStarting().
Returns true then delay
Returns false then the workbench window should exist as well as the Display thread and so
Display.asyncExec(addSelectionServiceRunnable) should be good to go.
Once control has been passed to the Display thread, the original polling thread will finish and
disappear.
HTH
PGR
On 15/07/15 15:26, Fred Bricon wrote:
> CC-ing to jbosstools-dev for more exposure
>
>> Début du message réexpédié :
>>
>> *De: *Ian Stewart-Binks <istewart at redhat.com <mailto:istewart at redhat.com>> *Objet: **Quick
>> SWT Question* *Date: *15 juillet 2015 09:05:06 UTC?4 *À: *Denis Golovin <degolovi at redhat.com
>> <mailto:degolovi at redhat.com>> *Cc: *Fred Bricon <fbricon at redhat.com
>> <mailto:fbricon at redhat.com>>
>>
>> Hi Denis,
>>
>> I'm the JBoss Tools intern here at Red Hat, working on an Eclipse plugin called
>> Buildship[1].
>>
>> I have an SWT related question, and my mentor, Fred Bricon, has suggested that I ask it to
>> you.
>>
>> The plugin I'm working with makes a call to getWorkbench().getActiveWorkbenchWindow() in the
>> plugin's Activator's .start() method. This call returns null when it is not run on the UI
>> thread, so the code is assuming that the .start() method will always be run on the UI thread.
>> The AbstractUIPlugin[2] states that the deprecated method startup(), which start() is meant
>> to replace cannot assume that it is run on the UI thread. This may be a bit pedantic: the
>> specification for start() doesn't mention anything about the UI thread- is it still the case
>> that we can't assume the start() method is run on the UI thread?
>>
>> If it is the case that the start method can't assume that it's run on the UI thread, I will
>> need to change some of the code to ensure that this assumption is not made.
>>
>> The offending line attempts to register a selection listener. Here it is:
>> ((ISelectionService)
>> getWorkbench().getActiveWorkbenchWindow().getService(ISelectionService.class)).addSelectionListen
er(this.contextActivatingSelectionListener);
>>
>>
>>
Do you know of any other ways to register this listener?
>>
>> Your help is greatly appreciated.
>>
>> Thank you, Ian
>>
>> [1] - https://github.com/eclipse/buildship/ [2] -
>> http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2F
org%2Feclipse%2Fui%2Fplugin%2FAbstractUIPlugin.html
>
>>
>
>
> _______________________________________________ jbosstools-dev mailing list
> jbosstools-dev at lists.jboss.org https://lists.jboss.org/mailman/listinfo/jbosstools-dev
>
- --
Paul Richardson
* p.g.richardson at phantomjinx.co.uk
* p.g.richardson at redhat.com
* pgrichardson at linux.com
"I know exactly who reads the papers ...
* The Daily Mirror is read by people who think they run the country.
* The Guardian is read by people who think they ought to run the country.
* The Times is read by people who do actually run the country.
* The Daily Mail is read by the wives of the people who run the country.
* The Financial Times is read by the people who own the country.
* The Morning Star is read by the people who think the country ought to be run by another country.
* The Daily Telegraph is read by the people who think it is."
Jim Hacker, Yes Minister
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iEYEARECAAYFAlWmehwACgkQcthLMIwdEb1rygCdECvm0duMrJpHjzzfgcEz4fT8
6MkAn2iIcYAU6CHLRRD8Q4rlj8yhD66/
=vSmD
-----END PGP SIGNATURE-----
More information about the jbosstools-dev
mailing list