Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Auto Refresh(refreshing view)
Auto Refresh [message #636170] Fri, 29 October 2010 10:13 Go to next message
Eclipse UserFriend
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 12:01 Go to previous messageGo to next message
Eclipse UserFriend
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 05:42 Go to previous messageGo to next message
Eclipse UserFriend
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 09:05 Go to previous messageGo to next message
Eclipse UserFriend
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 02:00 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 18:29:25 EDT 2025

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

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

Back to the top