List of usage examples for com.google.gwt.user.client Timer Timer
Timer
From source file:com.googlecode.mgwt.ui.client.widget.CellList.java
License:Apache License
protected void fixBug(final String html) { new Timer() { @Override/* w w w .ja v a 2 s . c o m*/ public void run() { getElement().setInnerHTML(html); String innerHTML = getElement().getInnerHTML(); if ("".equals(innerHTML.trim())) { fixBug(html); } } }.schedule(100); }
From source file:com.googlecode.mgwt.ui.client.widget.list.celllist.CellList.java
License:Apache License
protected void startTimer(final Element node) { if (timer != null) { timer.cancel();/*from w w w.j a v a2 s.com*/ timer = null; } timer = new Timer() { @Override public void run() { node.addClassName(CellList.this.appearance.css().selected()); } }; timer.schedule(150); }
From source file:com.googlesource.gerrit.plugins.cookbook.client.ChangeScreenPreferencePanel.java
License:Apache License
private void showSavedStatus() { if (hideTimer != null) { hideTimer.cancel();// w w w. jav a 2 s .c om hideTimer = null; } savedLabel.setVisible(true); hideTimer = new Timer() { @Override public void run() { savedLabel.setVisible(false); hideTimer = null; } }; hideTimer.schedule(1000); }
From source file:com.griddynamics.jagger.facade.client.navigation.LocationForm.java
License:Open Source License
public LocationForm(final Layout layout, final LocationNode locationNode) { this.locationNode = locationNode; setWidth(250);// w w w . jav a2s . co m final JaggerFacade facade = locationNode.getNavigationTree().getFacade(); startSessionButton.setTitle("Start new session"); startSessionButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { startSessionButton.disable(); JaggerFacadeService.App.getInstance().startSession(facade.getUserId(), locationNode.getLocationDTO().getName(), new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(Void result) { locationNode.createForm(); } }); } }); stopSessionButton.setTitle("Stop session"); stopSessionButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { stopSessionButton.disable(); JaggerFacadeService.App.getInstance().stopSession(facade.getUserId(), locationNode.getLocationDTO().getName(), new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(Void result) { locationNode.createForm(); } }); } }); killSessionButton.setTitle("Kill session"); killSessionButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { killSessionButton.disable(); JaggerFacadeService.App.getInstance().killSession(facade.getUserId(), locationNode.getLocationDTO().getName(), new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(Void result) { locationNode.createForm(); } }); } }); JaggerFacadeService.App.getInstance().isSessionStarted(facade.getUserId(), locationNode.getLocationDTO().getName(), new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(Boolean result) { if (!result) { setFields(startSessionButton); layout.setMembers(); layout.addMember(LocationForm.this); layout.redraw(); } else { JaggerFacadeService.App.getInstance().getFullSessionLog(facade.getUserId(), locationNode.getLocationDTO().getName(), new AsyncCallback<ArrayList<String>>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(ArrayList<String> result) { setFields(stopSessionButton, killSessionButton); StringBuilder log = new StringBuilder(result.size() * 256); for (String str : result) { if (log.length() > 0) { log.append("<br>"); } log.append(str); } logPane.setContents(log.toString()); layout.setMembers(); layout.addMember(LocationForm.this); layout.addMember(logPane); layout.redraw(); LocationForm.this.timer = new Timer() { @Override public void run() { JaggerFacadeService.App.getInstance().getSessionLog( facade.getUserId(), locationNode.getLocationDTO().getName(), new AsyncCallback<ArrayList<String>>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(ArrayList<String> result) { StringBuilder log = new StringBuilder( logPane.getContents()); for (String str : result) { if (log.length() > 0) { log.append("<br>"); } log.append(str); } logPane.setContents(log.toString()); } }); } }; LocationForm.this.timer.scheduleRepeating(1000); } }); } } }); }
From source file:com.griddynamics.jagger.facade.client.navigation.LocationNode.java
License:Open Source License
public LocationNode(NavigationTree navigationTree, final LocationDTO locationDTO) { this.navigationTree = navigationTree; this.locationDTO = locationDTO; setAttribute("id", "Location: " + locationDTO.getName()); setAttribute("name", locationDTO.getName()); navigationTree.getTree().add(this, navigationTree.getRootNode()); final JaggerFacade facade = navigationTree.getFacade(); this.timer = new Timer() { @Override/*from w w w.jav a 2 s. c om*/ public void run() { JaggerFacadeService.App.getInstance().getSessionCount(facade.getUserId(), locationDTO.getName(), new AsyncCallback<Integer>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(Integer count) { if (count > getSessionNodeCount()) { JaggerFacadeService.App.getInstance().getSessions(facade.getUserId(), locationDTO.getName(), new AsyncCallback<SessionDTO[]>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(SessionDTO[] sessionDTOs) { SessionNode.createNewSessionNodes(LocationNode.this, sessionDTOs); Canvas[] children = getNavigationTree().getFacade() .getViewLayout().getChildren(); if ((children.length > 0) && (children[0] instanceof LocationForm)) { createForm(); } } }); } } }); } }; timer.scheduleRepeating(5000); }
From source file:com.gtl.fonecta.client.GwtSmppSim.java
License:Open Source License
/** * This is the entry point method.//from w w w . jav a 2s. c om */ public void onModuleLoad() { hiddenHost = new Hidden(); hiddenHttpPort = new Hidden(); mainVPanel = new VerticalPanel(); handsetNumLabel = new Label("Handset number :"); serviceNumLabel = new Label("Service number :"); messageLabel = new Label("Message :"); hansetNum = new TextBox(); setHansetNo("4477665544"); hansetNo = "4477665544"; hansetNum.setText(hansetNo); hansetNum.setWidth("200px"); serviceNum = new TextBox(); serviceNo = "337788665522"; serviceNum.setText(serviceNo); serviceNum.setEnabled(false); serviceNum.setWidth("200px"); textMessage = new TextArea(); textMessage.setWidth("200px"); textMessage.setText("Hello from SMPPSim"); changeButton = new Button("Change"); submitButton = new Button("Send Message"); changeButton.addClickHandler(new ChangeBtnHandler(this)); submitButton.addClickHandler(new MessageHandler(this)); topGrid = new Grid(3, 3); topGrid.setCellSpacing(5); topGrid.setWidget(0, 0, handsetNumLabel); topGrid.setWidget(1, 0, serviceNumLabel); topGrid.setWidget(2, 0, messageLabel); topGrid.setWidget(0, 1, hansetNum); topGrid.setWidget(1, 1, serviceNum); topGrid.setWidget(2, 1, textMessage); topGrid.setWidget(0, 2, changeButton); topGrid.setWidget(1, 2, submitButton); topGrid.setWidget(2, 2, new HTML()); msgTitleGrid = new Grid(1, 2); msgTitleGrid.setCellSpacing(10); msgTitleGrid.setWidget(0, 0, new HTML("<font face='sans-serif'>Mobile Originated <i>messages</i> </font>")); msgTitleGrid.getWidget(0, 0).setWidth("350px"); msgTitleGrid.setWidget(0, 1, new HTML("<font face='sans-serif'>Mobile Terminated <i>messages</i> </font>")); msgTitleGrid.getWidget(0, 1).setWidth("350px"); msgTitleGrid.getWidget(0, 1).setStyleName("rightAlign"); messageVPanel = new VerticalPanel(); mainVPanel.add(topGrid); mainVPanel.add(msgTitleGrid); mainVPanel.add(messageVPanel); mainVPanel.setSpacing(5); mainVPanel.setStyleName("table-center"); RootPanel.get().add(mainVPanel); try { // Setup timer to refresh MT and MO messages automatically. Timer refreshTimer = new Timer() { @Override public void run() { serviceProxy.getInitialData(new AsyncCallback<Map<String, String>>() { @Override public void onFailure(Throwable caught) { System.out.println("FAIL" + caught.getMessage()); caught.getStackTrace(); } @Override public void onSuccess(Map<String, String> result) { initMap = result; setComponetValue(); } }); } }; refreshTimer.scheduleRepeating(10000); } catch (Exception e) { System.out.println("EXCEPTION"); } }
From source file:com.guit.junit.SchedulerMock.java
License:Apache License
@Override public void scheduleFixedDelay(final RepeatingCommand cmd, final int delayMs) { new Timer() { @Override//w ww .j a v a2 s. c o m public void run() { boolean repeat = cmd.execute(); if (repeat) { this.schedule(delayMs); } } }.schedule(delayMs); }
From source file:com.guit.junit.SchedulerMock.java
License:Apache License
@Override public void scheduleFixedPeriod(final RepeatingCommand cmd, int delayMs) { new Timer() { @Override//from ww w.j a va 2s .c o m public void run() { boolean repeat = cmd.execute(); if (!repeat) { cancel(); } } }.scheduleRepeating(delayMs); }
From source file:com.gwos.client.ui.desktop.TasksBar.java
License:Apache License
private void launchActiveRefresh() { final Timer timer = new Timer() { public void run() { systemHour.setText(Constants.TIME_FORMAT.format(new Date())); }/*from ww w.j av a 2s . c o m*/ }; Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { timer.scheduleRepeating(Constants.TIME_REFRESHING_PERIOD); } }); }
From source file:com.gwt.conn.client.Communicate.java
public static void authenticate(final String restID, final String license, final HTML commError, final DialogBox startupBox, final Button submitButton, final TextBox submitLicense, final TextBox submitRestID) { // attempt to sync with server storage.setItem("authenticated?", "null"); String result = sync("menu", restID, true); // true because authenticating if (!result.equals("")) { commError.setText("<br>No internet connection detected."); return;// w w w. j av a 2s . c om } // hide authentication submission form and replace with an "Authenticating..." message submitButton.setEnabled(false); submitLicense.setEnabled(false); submitRestID.setEnabled(false); startupBox.hide(); final DialogBox authBox = new DialogBox(); authBox.setAnimationEnabled(true); final VerticalPanel authPanel = new VerticalPanel(); authPanel.addStyleName("marginPanel"); // interacts with Connfrontend.css authPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); authPanel.add(new HTML("Authenticating...")); authBox.setWidget(authPanel); authBox.center(); // repeat a timer until the value of "authenticated?" changes final Timer timer = new Timer() { public void run() { // authentication unsuccessful if (storage.getItem("authenticated?").equals("no")) { // report error and show authentication form again authBox.hide(); commError.setText("<br>Something went wrong. Please try again."); submitButton.setEnabled(true); submitLicense.setEnabled(true); submitRestID.setEnabled(true); startupBox.center(); this.cancel(); } // authentication successful else if (storage.getItem("authenticated?").equals("yes")) { // save license and restaurant id and setup storage authBox.hide(); storage.setItem("license", license); // secret key for security storage.setItem("restID", restID); // used for almost every call to the backend storage.setItem("numMenus", Integer.toString(0)); StorageContainer.initStorage(); // go to dashboard (true meaning there is internet since we were able to authenticate) // "firstTime" causes a popup box to appear explaining how to use Connoisseur this.cancel(); Dashboard.loadMenu(deserialize(storage.getItem("menu")), "firstTime", true); } } }; // repeat once every half second timer.scheduleRepeating(500); // 500 milliseconds }