Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » get shell from jobs
get shell from jobs [message #461237] Sun, 07 January 2007 18:19 Go to next message
janko is currently offline jankoFriend
Messages: 7
Registered: July 2009
Junior Member
I start Job.shedule(); and before end of run method
I try open same Dialog. How do I get shell from RCP ?

PlatformUI.getWorkbench().getDisplay() don't work,
because it is not UI thread.
Re: get shell from jobs [message #461240 is a reply to message #461237] Sun, 07 January 2007 18:55 Go to previous messageGo to next message
Brandon Kane is currently offline Brandon KaneFriend
Messages: 7
Registered: July 2009
Junior Member
I haven't tried it in this context, but Display.getCurrent() or
getDefault() might work.

Brandon

janko wrote:
> I start Job.shedule(); and before end of run method
> I try open same Dialog. How do I get shell from RCP ?
>
> PlatformUI.getWorkbench().getDisplay() don't work,
> because it is not UI thread.
Re: get shell from jobs [message #461242 is a reply to message #461240] Sun, 07 January 2007 19:10 Go to previous messageGo to next message
Charlie Kelly is currently offline Charlie KellyFriend
Messages: 276
Registered: July 2009
Senior Member
Hi Janko,

You might try something like the following:

In your Action (or other code that is on a UI thread, pass the Display
as a parameter to your Job (for example, in its constructor).

Then open your dialog within the run() method of display.asyncExec


class RequestMailDownloadServiceJobChangeAdapter extends JobChangeAdapter
{
Display display;
public RequestMailDownloadServiceJobChangeAdapter (Display display)
{
this.display = display;
}// public RequestCertificateJobChangeAdapter (Composite parent)
//////////////////////////////////////////////////////////// ////////////////
public void done (final IJobChangeEvent iJobChangeEvent)
{

display.asyncExec
(
new Runnable ()
{
public void run ()
{
Shell shell = display.getActiveShell();
Job job = iJobChangeEvent.getJob();
RequestMailDownloadServiceJob requestMailDownloadServiceJob =
(RequestMailDownloadServiceJob) job;
int encryptedObjectCount =
requestMailDownloadServiceJob.getEncryptedObjectCount();
String message = "";
if (0 == encryptedObjectCount)
message = "No Messages available for download";
else
message = "Sucessfully downloaded " + encryptedObjectCount + "
messages";
;
MessageDialog.openInformation(shell, "Message Download Request",
message);
}// public void run ()
}// new Runnable ()
); // display.asyncExec

}// public void done (IJobChangeEvent iJobChangeEvent)
}// class RequestMailDownloadServiceJobChangeAdapter extends
JobChangeAdapter
//////////////////////////////////////////////////////////// ////////////////

Hope this helps.

Charlie


Brandon Kane wrote:
> I haven't tried it in this context, but Display.getCurrent() or
> getDefault() might work.
>
> Brandon
>
> janko wrote:
>
>> I start Job.shedule(); and before end of run method
>> I try open same Dialog. How do I get shell from RCP ?
>>
>> PlatformUI.getWorkbench().getDisplay() don't work,
>> because it is not UI thread.
Re: get shell from jobs [message #461246 is a reply to message #461242] Sun, 07 January 2007 23:31 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Just a side note ... if possible, be careful with getActiveShell() ...
content assist and those little transient javadoc popups are also
shells, and you wouldn't want to have it disappear on you. Sometimes
it's OK, but where possible perhaps pass in a solid shell ... like the
workbench window shell, that's it no likely to disappear on you (but of
course, you still have to be careful ... what happens to your Job when
someone closes your workbench window).

Later,
PW


Previous Topic:Accessing the workbench from "outside" thread
Next Topic:How to make my RCP application more beautiful?
Goto Forum:
  


Current Time: Fri Mar 29 01:59:38 GMT 2024

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

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

Back to the top