Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » get shell from jobs
get shell from jobs [message #461237] Sun, 07 January 2007 13:19 Go to next message
Eclipse UserFriend
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 13:55 Go to previous messageGo to next message
Eclipse UserFriend
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 14:10 Go to previous messageGo to next message
Eclipse UserFriend
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 18:31 Go to previous message
Eclipse UserFriend
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: Mon Mar 17 14:58:42 EDT 2025

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

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

Back to the top