Java Code Examples for com.google.gwt.user.client.Timer#scheduleRepeating()

The following examples show how to use com.google.gwt.user.client.Timer#scheduleRepeating() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MaterialBarChart.java    From gwt-material-demo with Apache License 2.0 6 votes vote down vote up
private void setLoop() {

		Timer timer = new Timer() {

			public void run() {
				if (isLoop) {
					drawChart(values);
					isLoop = false;
				}
				else {
					drawChart(valuesInitial);
					isLoop = true;
				}

			}
		};
		timer.scheduleRepeating(1000);
	}
 
Example 2
Source File: DomPopupManager.java    From jetpad-projectional-open-source with Apache License 2.0 6 votes vote down vote up
@Override
protected Registration setPopupUpdate() {
  final Timer timer = new Timer() {
    @Override
    public void run() {
      updatePopupPositions();
    }
  };
  timer.scheduleRepeating(POPUPS_REFRESH_MILLIS);
  return new Registration() {
    @Override
    protected void doRemove() {
      timer.cancel();
    }
  };
}
 
Example 3
Source File: GwtCookieModel.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public GwtCookieModel(boolean refresh) {
  listeners = new Listeners();
  cookies = new HashMap<String, String>();
  for (String name : Cookies.getCookieNames()) {
    cookies.put(name, Cookies.getCookie(name));
  }
  if (refresh) {
    refresher = new Timer() {
      @Override
      public void run() {
        refresh();
      }
    };
    refresher.scheduleRepeating(REFRESH_TIME);
  }
}
 
Example 4
Source File: ChatMessagesPanel.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Takes care of installing the timer responsible of opening the tree
 */
private void startTimer() {
	stopTimer();
	timer = new Timer() {
		public void run() {
			if (isVisible()) {
				messages.refresh(new ChatMessagesDS());
			}
		}
	};
	timer.scheduleRepeating(120 * 1000);
}
 
Example 5
Source File: OnlineUsersPanel.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Takes care of installing the timer responsible of opening the tree
 */
private void startTimer() {
	stopTimer();
	timer = new Timer() {
		public void run() {
			if (isVisible())
				onlineUsers.refresh(new OnlineUsersDS());
		}
	};
	timer.scheduleRepeating(60 * 1000);
}
 
Example 6
Source File: Dashboard.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * startRefreshingDashboard
 *
 * @param scheduleTime
 */
public void startRefreshingDashboard(double scheduleTime) {
	dashboardRefreshing = new Timer() {
		public void run() {
			refreshAll();
		}
	};

	dashboardRefreshing.scheduleRepeating(new Double(scheduleTime).intValue());
}
 
Example 7
Source File: StartUp.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * startKeepAlive
 */
public void startKeepAlive(double scheduleTime) {
	// KeepAlieve thread
	keepAlive = new Timer() {
		public void run() {
			authService.keepAlive(callbackKeepAlive);
		}
	};

	keepAlive.scheduleRepeating(new Double(scheduleTime).intValue()); // 15 min
}
 
Example 8
Source File: MainMenu.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * startRefreshingMenus
 */
public void startRefreshingMenus(double scheduleTime) {
	menusRefreshing = new Timer() {
		@Override
		public void run() {
			refreshAvailableTemplates();
		}
	};

	menusRefreshing.scheduleRepeating(new Double(scheduleTime).intValue());
}
 
Example 9
Source File: Poller.java    From flow with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the polling interval.
 * <p>
 * Changing the polling interval will stop any current polling and schedule
 * a new poll to happen after the given interval.
 *
 * @param interval
 *            The interval to use
 */
public void setInterval(int interval) {
    stop();
    if (interval >= 0) {
        pollTimer = new Timer() {
            @Override
            public void run() {
                poll();
            }

        };
        pollTimer.scheduleRepeating(interval);
    }
}
 
Example 10
Source File: CircularProgressView.java    From gwt-material-demo with Apache License 2.0 5 votes vote down vote up
protected void buildCircularContinuos() {
    Timer timer = new Timer() {
        @Override
        public void run() {
            double total = (i * 100) / 5;
            circContinuos.setValue(total / 100, true);
            if (i >= 5) {
                MaterialToast.fireToast("Finished");
                cancel();
            }
            i++;
        }
    };
    timer.scheduleRepeating(1000);
}
 
Example 11
Source File: MaterialAreaChart.java    From gwt-material-demo with Apache License 2.0 5 votes vote down vote up
private void setLoop() {
	Timer timer = new Timer() {
	  public void run() {
		  if(isLoop) {
			  drawChart(values);
			  isLoop = false;
		  } else {
			  drawChart(valuesInitial);
			  isLoop = true;
		  }
	  }
	};
	timer.scheduleRepeating(1000);
}
 
Example 12
Source File: JsEventDispatchThread.java    From mapper with Apache License 2.0 5 votes vote down vote up
@Override
public Registration scheduleRepeating(final int period, final Runnable r) {
  Timer timer = new Timer() {
    private long myLastInvocation = 0L;
    @Override
    public void run() {
      long current = getCurrentTimeMillis();
      if (current - myLastInvocation < period) return;
      myLastInvocation = current;
      doExecute(r);
    }
  };
  timer.scheduleRepeating(period);
  return timerReg(timer);
}
 
Example 13
Source File: TasksPanel.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void init() {
	results.setShowResizeBar(true);
	results.setHeight("60%");
	body.addMember(results);

	detailPanel = new Label("&nbsp;" + I18N.message("selecttask"));
	details = new VLayout();
	details.setAlign(Alignment.CENTER);
	details.addMember(detailPanel);
	body.addMember(details);

	prepareTasksGrid();

	/*
	 * Create the timer that synchronize the view
	 */
	timer = new Timer() {
		public void run() {
			SystemService.Instance.get().loadTasks(I18N.getLocale(), new AsyncCallback<GUITask[]>() {
				@Override
				public void onFailure(Throwable caught) {
					Log.serverError(caught);
				}

				@Override
				public void onSuccess(GUITask[] tasks) {
					for (GUITask guiTask : tasks) {
						Progressbar p = progresses.get(guiTask.getName());
						if (p == null)
							continue;

						if (guiTask.isIndeterminate()) {
							p.setPercentDone(0);
						} else {
							p.setPercentDone(guiTask.getCompletionPercentage());
						}
						p.redraw();

						for (ListGridRecord record : list.getRecords()) {
							if (record.getAttribute("name").equals(guiTask.getName())
									&& guiTask.getStatus() != GUITask.STATUS_IDLE) {
								record.setAttribute("runningIcon", "running_task");
								record.setAttribute("completion", guiTask.getCompletionPercentage());
								list.refreshRow(list.getRecordIndex(record));
								break;
							} else if (record.getAttribute("name").equals(guiTask.getName())
									&& guiTask.getStatus() == GUITask.STATUS_IDLE) {
								record.setAttribute("runningIcon", "idle_task");
								record.setAttribute("completion", guiTask.getCompletionPercentage());
								list.refreshRow(list.getRecordIndex(record));
								break;
							}
						}
					}
				}
			});
		}
	};

	timer.scheduleRepeating(5 * 1000);
}
 
Example 14
Source File: TextCellMapper.java    From jetpad-projectional-open-source with Apache License 2.0 4 votes vote down vote up
@Override
public void refreshProperties() {
  super.refreshProperties();

  Boolean focused = getSource().get(Cell.FOCUSED);
  if (focused) {
    if (myFocusRegistration == null) {
      final Timer timer = new Timer() {
        @Override
        public void run() {
          if (System.currentTimeMillis() - myLastChangeTime < CARET_BLINK_DELAY) return;
          myCaretVisible = !myCaretVisible;
          updateCaretVisibility();
        }
      };
      timer.scheduleRepeating(500);
      myContainerFocused = getContext().focused.get();
      myFocusRegistration = new CompositeRegistration(
        getContext().focused.addHandler(new EventHandler<PropertyChangeEvent<Boolean>>() {
          @Override
          public void onEvent(PropertyChangeEvent<Boolean> event) {
            myContainerFocused = event.getNewValue();
            updateCaretVisibility();
          }
        }),
        getSource().caretVisible().addHandler(new EventHandler<PropertyChangeEvent<Boolean>>() {
          @Override
          public void onEvent(PropertyChangeEvent<Boolean> event) {
            if (event.getNewValue()) {
              myLastChangeTime = System.currentTimeMillis();
              myCaretVisible = true;
            }
          }
        }),
        new Registration() {
          @Override
          protected void doRemove() {
            timer.cancel();
          }
        }
      );
    }
  } else {
    if (myFocusRegistration != null) {
      myFocusRegistration.remove();
      myFocusRegistration = null;
    }
  }

  myLastChangeTime = System.currentTimeMillis();

  myTextEditor.setText(getSource().text().get());
  myTextEditor.setCaretPosition(getSource().caretPosition().get());
  myTextEditor.setCaretVisible(getSource().caretVisible().get());
  myTextEditor.setTextColor(getSource().textColor().get());
  myTextEditor.setBold(getSource().bold().get());
  myTextEditor.setFontFamily(getSource().fontFamily().get());
  myTextEditor.setFontSize(getSource().fontSize().get());

  myTextEditor.setSelectionVisible(getSource().selectionVisible().get());
  myTextEditor.setSelectionStart(getSource().selectionStart().get());
}