Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Joblistener
Joblistener [message #11914] Mon, 26 March 2007 10:42 Go to next message
Markus  rüger is currently offline Markus rügerFriend
Messages: 369
Registered: July 2009
Senior Member
Hello,

I have a Problem using job listner and RAP. I urgently need to run a job and
update a view upon finishing, but as I try to get my view useing the code
below I get an IlligalStateException in line 43-47 of the ContextProvider.
Is there a way to refresh my view from a job listener? I need this bad...

Best regards,

Markus
Re: Joblistener [message #12458 is a reply to message #11914] Mon, 26 March 2007 10:44 Go to previous messageGo to next message
Markus  rüger is currently offline Markus rügerFriend
Messages: 369
Registered: July 2009
Senior Member
Sorry, forgot the code I used to get my view within a job listener. Here it
is:

IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
return (MyView)workbenchPage.findView(MyView.VIEW_ID);



"Markus Kr
Re: Joblistener [message #12600 is a reply to message #12458] Tue, 27 March 2007 11:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rsternberg.innoopract.com

Hi Markus,

if I get you right, you start a new thread to process some task and then
try to invoke a change in the UI when your task is done. The problem
with this approach is that your task probably finishes *after* the
current request is processed, i.e. the response is already sent to the
client. That is, the context of the request (in which the references to
the Display and the widget hierarchy are valid) is no longer available
and that's why you get an IllegalStateException.

Remember that we cannot push updates to the client due to the
request/response nature of HTTP. Processing long-running tasks is a
general problem with the RAP approach and we currently have no quick and
simple solution.

One approach, that we used this successfully for the EclipseCon showcase
application, is polling. However, this still involves some JavaScript
hacking and is not the perfect solution for a productive application. If
you're interested anyway, you can have a look at it:

http://innoopract.com/components/org.eclipse.rap.showcase_1. 0.0.jar

Hope this helps,
Ralf

Markus Krüger schrieb:
> Sorry, forgot the code I used to get my view within a job listener. Here it
> is:
>
> IWorkbench workbench = PlatformUI.getWorkbench();
> IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
> IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
> return (MyView)workbenchPage.findView(MyView.VIEW_ID);
>
>
>
> "Markus Krüger" <krueger@ion.ag> schrieb im Newsbeitrag
> news:eu882j$is2$1@utils.eclipse.org...
>> Hello,
>>
>> I have a Problem using job listner and RAP. I urgently need to run a job
>> and update a view upon finishing, but as I try to get my view useing the
>> code below I get an IlligalStateException in line 43-47 of the
>> ContextProvider. Is there a way to refresh my view from a job listener? I
>> need this bad...
>>
>> Best regards,
>>
>> Markus
>>
>
>
Re: Joblistener [message #13622 is a reply to message #12600] Wed, 28 March 2007 20:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jkrause.innoopract.com

I would like to add that you are trying to access widgets from a thread
which is not the "UI thread", which is also not possible in SWT. You
would need to use the syncexec or asyncexec methods of the display
class, which we currently do not implement. It should be possible to
implement those methods, but this will not happen within the next couple
of weeks.

see also: http://wiki.eclipse.org/index.php/5_Display and the section on
multithreaded programming.

Jochen


Ralf Sternberg wrote:
> Hi Markus,
>
> if I get you right, you start a new thread to process some task and then
> try to invoke a change in the UI when your task is done. The problem
> with this approach is that your task probably finishes *after* the
> current request is processed, i.e. the response is already sent to the
> client. That is, the context of the request (in which the references to
> the Display and the widget hierarchy are valid) is no longer available
> and that's why you get an IllegalStateException.
>
> Remember that we cannot push updates to the client due to the
> request/response nature of HTTP. Processing long-running tasks is a
> general problem with the RAP approach and we currently have no quick and
> simple solution.
>
> One approach, that we used this successfully for the EclipseCon showcase
> application, is polling. However, this still involves some JavaScript
> hacking and is not the perfect solution for a productive application. If
> you're interested anyway, you can have a look at it:
>
> http://innoopract.com/components/org.eclipse.rap.showcase_1. 0.0.jar
>
> Hope this helps,
> Ralf
>
> Markus Krüger schrieb:
>> Sorry, forgot the code I used to get my view within a job listener.
>> Here it is:
>>
>> IWorkbench workbench = PlatformUI.getWorkbench();
>> IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
>> IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
>> return (MyView)workbenchPage.findView(MyView.VIEW_ID);
>>
>>
>>
>> "Markus Krüger" <krueger@ion.ag> schrieb im Newsbeitrag
>> news:eu882j$is2$1@utils.eclipse.org...
>>> Hello,
>>>
>>> I have a Problem using job listner and RAP. I urgently need to run a
>>> job and update a view upon finishing, but as I try to get my view
>>> useing the code below I get an IlligalStateException in line 43-47 of
>>> the ContextProvider. Is there a way to refresh my view from a job
>>> listener? I need this bad...
>>>
>>> Best regards,
>>>
>>> Markus
>>>
>>
>>
Re: Joblistener [message #13642 is a reply to message #13622] Wed, 28 March 2007 20:37 Go to previous messageGo to next message
Markus  rüger is currently offline Markus rügerFriend
Messages: 369
Registered: July 2009
Senior Member
Ok, thats what I wanted to hear ;-)
I'm not in a hurry for that, but good to know that it will be implemented.
For now it is ok to click on a refresh button for the user.

"Jochen Krause" <jkrause@innoopract.com> schrieb im Newsbeitrag
news:euei0n$ig8$1@build.eclipse.org...
>I would like to add that you are trying to access widgets from a thread
>which is not the "UI thread", which is also not possible in SWT. You would
>need to use the syncexec or asyncexec methods of the display class, which
>we currently do not implement. It should be possible to implement those
>methods, but this will not happen within the next couple of weeks.
>
> see also: http://wiki.eclipse.org/index.php/5_Display and the section on
> multithreaded programming.
>
> Jochen
>
>
> Ralf Sternberg wrote:
>> Hi Markus,
>>
>> if I get you right, you start a new thread to process some task and then
>> try to invoke a change in the UI when your task is done. The problem with
>> this approach is that your task probably finishes *after* the current
>> request is processed, i.e. the response is already sent to the client.
>> That is, the context of the request (in which the references to the
>> Display and the widget hierarchy are valid) is no longer available and
>> that's why you get an IllegalStateException.
>>
>> Remember that we cannot push updates to the client due to the
>> request/response nature of HTTP. Processing long-running tasks is a
>> general problem with the RAP approach and we currently have no quick and
>> simple solution.
>>
>> One approach, that we used this successfully for the EclipseCon showcase
>> application, is polling. However, this still involves some JavaScript
>> hacking and is not the perfect solution for a productive application. If
>> you're interested anyway, you can have a look at it:
>>
>> http://innoopract.com/components/org.eclipse.rap.showcase_1. 0.0.jar
>>
>> Hope this helps,
>> Ralf
>>
>> Markus Kr
Re: Joblistener [message #14728 is a reply to message #12600] Thu, 29 March 2007 17:41 Go to previous messageGo to next message
Markus  rüger is currently offline Markus rügerFriend
Messages: 369
Registered: July 2009
Senior Member
Hi Ralf,

could You give a hint what to look at, or a little snippet?
I have View with a tree viewer in it and I would like to refresh it every 5
seconds (This is for a kind of rough view for current running eclipse jobs).

Thanks you in advance,

Markus

"Ralf Sternberg" <rsternberg@innoopract.com> schrieb im Newsbeitrag
news:euaufr$5ct$1@utils.eclipse.org...
> Hi Markus,
>
> if I get you right, you start a new thread to process some task and then
> try to invoke a change in the UI when your task is done. The problem with
> this approach is that your task probably finishes *after* the current
> request is processed, i.e. the response is already sent to the client.
> That is, the context of the request (in which the references to the
> Display and the widget hierarchy are valid) is no longer available and
> that's why you get an IllegalStateException.
>
> Remember that we cannot push updates to the client due to the
> request/response nature of HTTP. Processing long-running tasks is a
> general problem with the RAP approach and we currently have no quick and
> simple solution.
>
> One approach, that we used this successfully for the EclipseCon showcase
> application, is polling. However, this still involves some JavaScript
> hacking and is not the perfect solution for a productive application. If
> you're interested anyway, you can have a look at it:
>
> http://innoopract.com/components/org.eclipse.rap.showcase_1. 0.0.jar
>
> Hope this helps,
> Ralf
>
> Markus Kr
Re: Joblistener [message #14756 is a reply to message #14728] Thu, 29 March 2007 22:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rsternberg.innoopract.com

Hi Markus,

Markus Krüger schrieb:
> could You give a hint what to look at, or a little snippet?
> I have View with a tree viewer in it and I would like to refresh it every 5
> seconds (This is for a kind of rough view for current running eclipse jobs).

There are two steps to do this: the first is to make the client send
requests periodically, the second is to make the server take a certain
action on every request (update the tree).

For the first, simply copy Trigger.js and TriggerJS.java from
org.eclipse.rap.showcase (adapt getLocation() in TriggerJS.java
to match your location). To deliver the JS file to the client, RAP
provides an extension point that allows to register resources. Extend it
like this:

<extension
id="your.namespace.something"
point="org.eclipse.rap.ui.workbench.resources">
<resource class="your.namespace.TriggerJS"/>
</extension>

For the second step, have a look at Explorer.java in the views package.
Like the class ChatNotificator, you need to implement a PhaseListener
and HttpSessionBindingListener. The request processing is divided into
several phases [1], a phase listener is called whenever it enters /
leaves a certain phase (ProcessAction is suitable here). In the
beforePhase() method, you can update your tree. Register the phase
listener when the view is created:

Notificator notificator = new Notificator();
ILifeCycle lifeCycle = LifeCycleFactory.loadLifeCycle();
String id = Notificator.class.getName();
ContextProvider.getSession().setAttribute( id, notificator );
lifeCycle.addPhaseListener( notificator );

If your model does not depend on the user session, you can probably
leave out the 4th line and the implementation of HttpSessionBindingListener.

I hope this works for you. Maybe there's a better way for the second
part that I just don't see now.

Regards,
Ralf

[1] http://wiki.eclipse.org/index.php/WidgetToolkit#LifeCycle
Re: Joblistener [message #15178 is a reply to message #14756] Mon, 02 April 2007 10:32 Go to previous messageGo to next message
Markus  rüger is currently offline Markus rügerFriend
Messages: 369
Registered: July 2009
Senior Member
Thank You, Ralf. It works great!

Markus


"Ralf Sternberg" <rsternberg@innoopract.com> schrieb im Newsbeitrag
news:euhe7f$4ct$1@build.eclipse.org...
> Hi Markus,
>
> Markus Kr
Re: Joblistener [message #20372 is a reply to message #12600] Thu, 26 April 2007 19:53 Go to previous messageGo to next message
Frank Gerhardt is currently offline Frank GerhardtFriend
Messages: 81
Registered: July 2009
Member
Ralf Sternberg schrieb:

> http://innoopract.com/components/org.eclipse.rap.showcase_1. 0.0.jar

This has a dependency on org.eclipse.rap.gmap. Where is this?

Frank.
Re: Joblistener [message #21691 is a reply to message #20372] Wed, 02 May 2007 20:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jkrause.innoopract.com

Hi, we had uploaded this example to the Eclipsezilla, but it has been
deleted from there. We will upload it to a webserver and provide a link.
Jochen

Frank Gerhardt wrote:
> Ralf Sternberg schrieb:
>
>> http://innoopract.com/components/org.eclipse.rap.showcase_1. 0.0.jar
>
> This has a dependency on org.eclipse.rap.gmap. Where is this?
>
> Frank.
Re: Joblistener - gmap example [message #22048 is a reply to message #20372] Fri, 04 May 2007 07:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jkrause.innoopract.com

For now you can download it here:

http://innoopract.com/components/org.eclipse.rap.gmaps_1.0.0 .jar

I think that we will move this into a tutorial for creating custom widgets.

Jochen

Frank Gerhardt wrote:
> Ralf Sternberg schrieb:
>
>> http://innoopract.com/components/org.eclipse.rap.showcase_1. 0.0.jar
>
> This has a dependency on org.eclipse.rap.gmap. Where is this?
>
> Frank.
Re: Joblistener [message #79473 is a reply to message #12600] Thu, 27 March 2008 14:23 Go to previous messageGo to next message
Mike Wrighton is currently offline Mike WrightonFriend
Messages: 19
Registered: July 2009
Junior Member
Hi,

Can I just confirm that this is still the case as this thread started
about a year ago? I want to update my console view during a build job
which obviously runs inside a non-UI thread, but I can't get a Display
object to call asyncExec() - Display.getDefault() returns null and
Workbench.getInstance() throws an IllegalStateException. I've
experimented with UICallBack.activate() but to be honest I'm not 100%
sure what it does or where I should be calling it.

Mike


Ralf Sternberg wrote:
> Hi Markus,
>
> if I get you right, you start a new thread to process some task and then
> try to invoke a change in the UI when your task is done. The problem
> with this approach is that your task probably finishes *after* the
> current request is processed, i.e. the response is already sent to the
> client. That is, the context of the request (in which the references to
> the Display and the widget hierarchy are valid) is no longer available
> and that's why you get an IllegalStateException.
>
> Remember that we cannot push updates to the client due to the
> request/response nature of HTTP. Processing long-running tasks is a
> general problem with the RAP approach and we currently have no quick and
> simple solution.
>
> One approach, that we used this successfully for the EclipseCon showcase
> application, is polling. However, this still involves some JavaScript
> hacking and is not the perfect solution for a productive application. If
> you're interested anyway, you can have a look at it:
>
> http://innoopract.com/components/org.eclipse.rap.showcase_1. 0.0.jar
>
> Hope this helps,
> Ralf
>
> Markus Krüger schrieb:
>> Sorry, forgot the code I used to get my view within a job listener.
>> Here it is:
>>
>> IWorkbench workbench = PlatformUI.getWorkbench();
>> IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
>> IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
>> return (MyView)workbenchPage.findView(MyView.VIEW_ID);
>>
>>
>>
>> "Markus Krüger" <krueger@ion.ag> schrieb im Newsbeitrag
>> news:eu882j$is2$1@utils.eclipse.org...
>>> Hello,
>>>
>>> I have a Problem using job listner and RAP. I urgently need to run a
>>> job and update a view upon finishing, but as I try to get my view
>>> useing the code below I get an IlligalStateException in line 43-47 of
>>> the ContextProvider. Is there a way to refresh my view from a job
>>> listener? I need this bad...
>>>
>>> Best regards,
>>>
>>> Markus
>>>
>>
>>
Re: Joblistener [message #79714 is a reply to message #79473] Fri, 28 March 2008 10:06 Go to previous message
Eclipse UserFriend
Originally posted by: fappel.innoopract.com

Hi,

this is how in principle you have to deal with Jobs in RAP if you want
to have access to the display:

final Display display = Display.getCurrent();
Job job = new Job( "MyJob" ) {
protected IStatus run( final IProgressMonitor monitor ) {
display.asyncExec( new Runnable() {
public void run() {
// Do what ever you want to do
}
} );
return Status.OK_STATUS;
}
};
job.schedule();

This differs from RCP since in RCP there is only on display per process,
so Display#getDefault() will find the correct one. In RAP there are
displays for every user session so there's no way for
Display#getDefault() to decide which one is the one that's needed. So
the display has to be passed from the 'outside'.


Ciao
Frank

-----Ursprüngliche Nachricht-----
Von: Mike Wrighton [mailto:mike.wrighton@googlemail.com]
Bereitgestellt: Donnerstag, 27. März 2008 15:23
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: Joblistener
Betreff: Re: Joblistener


Hi,

Can I just confirm that this is still the case as this thread started
about a year ago? I want to update my console view during a build job
which obviously runs inside a non-UI thread, but I can't get a Display
object to call asyncExec() - Display.getDefault() returns null and
Workbench.getInstance() throws an IllegalStateException. I've
experimented with UICallBack.activate() but to be honest I'm not 100%
sure what it does or where I should be calling it.

Mike


Ralf Sternberg wrote:
> Hi Markus,
>
> if I get you right, you start a new thread to process some task and
> then try to invoke a change in the UI when your task is done. The
> problem with this approach is that your task probably finishes *after*

> the current request is processed, i.e. the response is already sent to

> the client. That is, the context of the request (in which the
> references to the Display and the widget hierarchy are valid) is no
> longer available and that's why you get an IllegalStateException.
>
> Remember that we cannot push updates to the client due to the
> request/response nature of HTTP. Processing long-running tasks is a
> general problem with the RAP approach and we currently have no quick
> and simple solution.
>
> One approach, that we used this successfully for the EclipseCon
> showcase application, is polling. However, this still involves some
> JavaScript hacking and is not the perfect solution for a productive
> application. If you're interested anyway, you can have a look at it:
>
> http://innoopract.com/components/org.eclipse.rap.showcase_1. 0.0.jar
>
> Hope this helps,
> Ralf
>
> Markus Krüger schrieb:
>> Sorry, forgot the code I used to get my view within a job listener.
>> Here it is:
>>
>> IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbenchWindow
>> workbenchWindow = workbench.getActiveWorkbenchWindow();
>> IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
>> return (MyView)workbenchPage.findView(MyView.VIEW_ID);
>>
>>
>>
>> "Markus Krüger" <krueger@ion.ag> schrieb im Newsbeitrag
>> news:eu882j$is2$1@utils.eclipse.org...
>>> Hello,
>>>
>>> I have a Problem using job listner and RAP. I urgently need to run a

>>> job and update a view upon finishing, but as I try to get my view
>>> useing the code below I get an IlligalStateException in line 43-47
>>> of the ContextProvider. Is there a way to refresh my view from a job

>>> listener? I need this bad...
>>>
>>> Best regards,
>>>
>>> Markus
>>>
>>
>>
Previous Topic:CSS styles
Next Topic:TreeViewer refresh
Goto Forum:
  


Current Time: Thu Apr 25 12:00:14 GMT 2024

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

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

Back to the top