01: /*
02: * ChainBuilder ESB
03: * Visual Enterprise Integration
04: *
05: * Copyright (C) 2006 Bostech Corporation
06: *
07: * This program is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU General Public License as published by the
09: * Free Software Foundation; either version 2 of the License, or (at your option)
10: * any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15: * for more details.
16: *
17: * You should have received a copy of the GNU General Public License along with
18: * this program; if not, write to the Free Software Foundation, Inc.,
19: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: *
21: *
22: * $Id$
23: */
24: package com.bostechcorp.cbesb.console.client;
25:
26: import com.google.gwt.core.client.GWT;
27: import com.google.gwt.user.client.Timer;
28:
29: public abstract class AdminWithTimer extends Admin {
30:
31: public int INTERVAL = 60000;
32: protected Timer currentTimer;
33:
34: public ConsoleImageBundle images = (ConsoleImageBundle) GWT
35: .create(ConsoleImageBundle.class);
36:
37: public abstract void updateContent(boolean isPolling);
38:
39: public void initTimer() {
40: currentTimer = new Timer() {
41: public void run() {
42: updateContent(true);
43:
44: }
45: };
46:
47: currentTimer.scheduleRepeating(INTERVAL);
48: }
49:
50: public void onHide() {
51: stopPolling();
52: }
53:
54: public void onShow() {
55: currentTimer.scheduleRepeating(INTERVAL);
56: updateContent(false);
57:
58: }
59:
60: public void refresh() {
61:
62: }
63:
64: protected void onDetach() {
65:
66: stopPolling();
67: super .onDetach();
68: }
69:
70: protected void stopPolling() {
71: currentTimer.cancel();
72:
73: }
74:
75: public int getINTERVAL() {
76: return INTERVAL;
77: }
78:
79: public void setINTERVAL(int interval) {
80: if (INTERVAL != interval) {
81: INTERVAL = interval;
82: currentTimer.scheduleRepeating(interval);
83: }
84:
85: }
86:
87: }
|