Home » Eclipse Projects » Remote Application Platform (RAP) » Joblistener
Joblistener [message #11914] |
Mon, 26 March 2007 06:42  |
Eclipse User |
|
|
|
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 #12600 is a reply to message #12458] |
Tue, 27 March 2007 07:17   |
Eclipse User |
|
|
|
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 16:08   |
Eclipse User |
|
|
|
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 16:37   |
Eclipse User |
|
|
|
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 13:41   |
Eclipse User |
|
|
|
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 18:22   |
Eclipse User |
|
|
|
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 #79473 is a reply to message #12600] |
Thu, 27 March 2008 10:23   |
Eclipse User |
|
|
|
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 06:06  |
Eclipse User |
|
|
|
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
>>>
>>
>>
|
|
|
Goto Forum:
Current Time: Fri May 09 01:25:15 EDT 2025
Powered by FUDForum. Page generated in 0.11360 seconds
|