Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Auto Refresh(refreshing view)
Auto Refresh [message #636170] Fri, 29 October 2010 14:13 Go to next message
MohanVaradharajan  is currently offline MohanVaradharajan
Messages: 7
Registered: October 2010
Junior Member
Hi all,

i would like to know how to refresh the view at scheduled interval ?. what is the best way to implement this functionality ?

here is the scenario :
- user will set auto refresh interval
- once he pressed ok button, current view should be refreshed automatically which involves server communication at the scheduled interval...

thanks for your help..

Re: Auto Refresh [message #636205 is a reply to message #636170] Fri, 29 October 2010 16:01 Go to previous messageGo to next message
Devi Vara Prasad Bandaru is currently offline Devi Vara Prasad Bandaru
Messages: 98
Registered: March 2010
Location: Hyderabad
Member

One way i could think of..
not sure if this is the best way to do it.

	private Runnable refreshTask = null;
	private int scheduled_interval = 2000;
	private boolean autoRefresh = true;
	void scheduleAutoRefresh() {
		refreshTask = new Runnable() {
			public void run() {
				//code to refresh view here
				System.out.println("Refreshing view at : " + new Date());
				if (autoRefresh) { // a variable to stop the refresh task when the view is disposed or no longer used.
					Display.getDefault().timerExec(scheduled_interval, refreshTask);
				} else {
					System.out.println("Stopped refreshing view at : " + new Date());
				}
			}
		};
		Display.getDefault().timerExec(scheduled_interval, refreshTask);		
	}


Re: Auto Refresh [message #636276 is a reply to message #636205] Sat, 30 October 2010 09:42 Go to previous messageGo to next message
MohanVaradharajan  is currently offline MohanVaradharajan
Messages: 7
Registered: October 2010
Junior Member
thanks prasad. is that possible to do with Jobs API?
Re: Auto Refresh [message #636289 is a reply to message #636276] Sat, 30 October 2010 13:05 Go to previous messageGo to next message
Devi Vara Prasad Bandaru is currently offline Devi Vara Prasad Bandaru
Messages: 98
Registered: March 2010
Location: Hyderabad
Member

You can use jobs combined with the timer thread.. i.e., create a job and schedule it at regular intervals using the timer thread .

Inside the job once you are done with the server communication you need to use the display thread again to refresh the view. This approach actually prevents the freezing of UI which might occur during the server communication.





Re: Auto Refresh [message #636409 is a reply to message #636276] Mon, 01 November 2010 06:00 Go to previous message
Prakash G.R. is currently offline Prakash G.R.
Messages: 621
Registered: July 2009
Senior Member
On 30/10/10 3:12 PM, MohanVaradharajan wrote:
> thanks prasad. is that possible to do with Jobs API?

Yes a job can reschedule itself:
http://wiki.eclipse.org/FAQ_How_do_I_create_a_repeating_back ground_task%3F

--
- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Previous Topic:the default typing language problem
Next Topic:Expand the properties popup menu
Goto Forum:
  


Current Time: Sun Oct 26 07:00:46 GMT 2014

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

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