List of usage examples for com.google.gwt.user.client Timer scheduleRepeating
public synchronized void scheduleRepeating(final int periodMs)
From source file:com.gtl.fonecta.client.GwtSmppSim.java
License:Open Source License
/** * This is the entry point method./*from w ww .j a va 2 s . c o m*/ */ 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.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())); }/* www . ja va 2 s.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;//from ww w . ja v a2 s . c o m } // 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 }
From source file:com.gwtcx.sample.serendipity.client.view.desktop.DashboardsDesktopView.java
License:Open Source License
public Chart createDynamicSplineChart() { final Chart chart = new Chart().setType(Series.Type.SPLINE).setMarginRight(10) .setChartTitleText("Live random data") .setBarPlotOptions(new BarPlotOptions().setDataLabels(new DataLabels().setEnabled(true))) .setLegend(new Legend().setEnabled(false)).setCredits(new Credits().setEnabled(false)) .setToolTip(new ToolTip().setFormatter(new ToolTipFormatter() { public String format(ToolTipData toolTipData) { return "<b>" + toolTipData.getSeriesName() + "</b><br/>" + DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss") .format(new Date(toolTipData.getXAsLong())) + "<br/>" + NumberFormat.getFormat("0.00").format(toolTipData.getYAsDouble()); }//from w w w. ja va 2s . c o m })); chart.getXAxis().setType(Axis.Type.DATE_TIME).setTickPixelInterval(150); chart.getYAxis().setAxisTitleText("Value") .setPlotLines(chart.getYAxis().createPlotLine().setValue(0).setWidth(1).setColor("#808080")); final Series series = chart.createSeries(); chart.addSeries(series.setName("Random data")); // Generate an array of random data long time = new Date().getTime(); for (int i = -19; i <= 0; i++) { series.addPoint(time + i * 1000, com.google.gwt.user.client.Random.nextDouble()); } Timer tempTimer = new Timer() { @Override public void run() { series.addPoint(new Date().getTime(), com.google.gwt.user.client.Random.nextDouble(), true, true, true); } }; tempTimer.scheduleRepeating(1000); return chart; }
From source file:com.gwttest.client.Demo.java
License:Open Source License
public void onModuleLoad() { final ChartWidget chart = new ChartWidget(); HorizontalPanel hp = new HorizontalPanel(); hp.setSpacing(10);/*from w ww .j ava 2 s . c o m*/ VerticalPanel vp = new VerticalPanel(); vp.setSpacing(20); // add home page HTML homeText = new HTML("<h2>Welcome to OFCGWT</h2>" + "<i>....the OpenFlashChart GWT Library</i></br></br>" + "This demonstration site will showcase the many different types of charts that can be inserted into a GWT application."); vp.add(homeText); vp.setCellHeight(homeText, "100"); createPopupDialog(); Button popup = new Button("Show 2nd Chart in Dialog"); popup.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { popupDb.center(); popupDb.show(); } }); vp.add(popup); Button image = new Button("Show Image of Chart"); image.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { ImageServiceAsync imgService = (ImageServiceAsync) GWT.create(ImageService.class); ServiceDefTarget target = (ServiceDefTarget) imgService; target.setServiceEntryPoint(GWT.getHostPageBaseURL() + "ImageService"); imgService.getImageToken(chart.getImageData(), new AsyncCallback<String>() { public void onFailure(Throwable caught) { } public void onSuccess(String result) { createImageDialog(GWT.getHostPageBaseURL() + "image?var=img_" + result); } }); } }); vp.add(image); vp.add(new HTML("Update Speed <i>(0-off, 4-max)</i>")); final SliderBar slider = new SliderBar(0.0, 4.0); slider.setStepSize(1.0); slider.setCurrentValue(1.0); slider.setNumTicks(4); slider.setNumLabels(4); slider.setWidth("100%"); vp.add(slider); hp.add(vp); hp.setCellWidth(vp, "300"); // add chart VerticalPanel vp2 = new VerticalPanel(); DecoratorPanel dp = new DecoratorPanel(); SimplePanel chartPanel = new SimplePanel(); chartPanel.setStylePrimaryName("chartPanel"); chart.setSize("500", "400"); chart.setChartData(getPieChartData()); chartPanel.add(chart); dp.add(chartPanel); vp2.add(dp); vp2.add(new HTML("Chart's JSON data:")); ta = new TextArea(); ta.setWidth("400"); ta.setHeight("100"); ta.setText(chart.getJsonData()); vp2.add(ta); hp.add(vp2); VerticalPanel chartlist = new VerticalPanel(); chartlist.setSpacing(5); Command cmd = new Command() { public void execute() { chart.setChartData(getPieChartData()); ta.setText(chart.getJsonData()); } }; RadioButton rb = createRadioButton("PieChart - No Labels", cmd); updateCmd = cmd; rb.setValue(true); chartlist.add(rb); chartlist.add(createRadioButton("PieChart - Animate", new Command() { public void execute() { chart.setChartData(getAniPieChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("BarChart - Transparent", new Command() { public void execute() { chart.setChartData(getBarChartTransparentData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("BarChart - Glass", new Command() { public void execute() { chart.setChartData(getBarChartGlassData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("3DBarChart + Line", new Command() { public void execute() { chart.setChartData(get3DBarLineChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("CylinderChart", new Command() { public void execute() { chart.setChartData(getCylinderChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("CylinderChart - RoundGlass", new Command() { public void execute() { chart.setChartData(getCylinderChartGlassData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("LineChart - 3 Dot Types", new Command() { public void execute() { chart.setChartData(getLineChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("ScatterChart - Star Dot", new Command() { public void execute() { chart.setChartData(getScatterPointChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("ScatterChart - Line", new Command() { public void execute() { chart.setChartData(getScatterLineChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("RadarChart", new Command() { public void execute() { chart.setChartData(getRadarChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("Horizontal-BarChart", new Command() { public void execute() { chart.setChartData(getHorizBarChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("AreaChart - Hollow", new Command() { public void execute() { chart.setChartData(getAreaHollowChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("AreaChart - Line", new Command() { public void execute() { chart.setChartData(getAreaLineChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("SketchChart", new Command() { public void execute() { chart.setChartData(getSketchChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("StackChart", new Command() { public void execute() { chart.setChartData(getStackChartData()); ta.setText(chart.getJsonData()); } })); chartlist.add(createRadioButton("HorizontalStackChart", new Command() { public void execute() { chart.setChartData(getHorizontalStackChartData()); ta.setText(chart.getJsonData()); } })); hp.add(chartlist); hp.setCellWidth(chartlist, "300"); RootPanel.get().add(hp); final Timer updater = new Timer() { public void run() { updateCmd.execute(); } }; updater.scheduleRepeating(3000); slider.addChangeListener(new ChangeListener() { public void onChange(Widget sender) { switch ((int) (slider.getCurrentValue())) { case 0: updater.cancel(); break; case 1: updater.scheduleRepeating(3000); break; case 2: updater.scheduleRepeating(1000); break; case 3: updater.scheduleRepeating(200); break; case 4: updater.scheduleRepeating(50); break; } } }); }
From source file:com.minesweeper.client.MinesweeperWidget.java
License:Apache License
/** * Timer to clear the UI.//w w w . ja va 2 s . co m */ // Timer timer = new Timer() { // @Override // public void run() { // status.setInnerText(""); // status.setClassName(STATUS_NONE); // } // }; // // private void setStatus(String message, boolean error) { // status.setInnerText(message); // if (error) { // status.setClassName(STATUS_ERROR); // } else { // if (message.length() == 0) { // status.setClassName(STATUS_NONE); // } else { // status.setClassName(STATUS_SUCCESS); // } // } // // timer.schedule(STATUS_DELAY); // } public MinesweeperWidget() { initWidget(uiBinder.createAndBindUi(this)); final EventBus eventBus = new SimpleEventBus(); requestFactory.initialize(eventBus); // Fill the list fillList(); for (int i = 0; i < buttonPanel.length; i++) { previous[i] = new Button("Previous"); buttonPanel[i] = new HorizontalPanel(); buttonPanel[i].add(previous[i]); next[i] = new Button("Next"); buttonPanel[i].add(next[i]); buttonPanel[i].addStyleName("buttonPanel"); next[i].setEnabled(false); next[i].addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { showNext(((Button) event.getSource()).getTitle()); } }); previous[i].setEnabled(false); previous[i].addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { showPrevious(((Button) event.getSource()).getTitle()); } }); } next[0].setTitle("Logs"); next[1].setTitle("Forms"); previous[0].setTitle("Logs"); previous[1].setTitle("Forms"); FlowPanel p = new FlowPanel(); p.add(listBox); p.setStyleName("buttonPanel"); logsPanel.add(logsTable); logsPanel.add(buttonPanel[0]); tabPanel.add(logsPanel, "Logs"); formsPanel.add(formsTable); formsPanel.add(buttonPanel[1]); tabPanel.add(formsPanel, "Forms"); tabPanel.selectTab(0); tabPanel.setPixelSize(Window.getClientWidth(), Window.getClientHeight()); VerticalPanel mainPanel = new VerticalPanel(); mainPanel.add(p); mainPanel.add(tabPanel); ScrollPanel scroll = new ScrollPanel(mainPanel); scroll.setPixelSize(Window.getClientWidth(), Window.getClientHeight()); // Associate the main panel with the HTML host page RootPanel.get("accGames").add(scroll); // List box with accessible games listBox.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { updateTable(listBox.getValue(listBox.getSelectedIndex())); if (indexOfLogs * MAX_LOG + MAX_LOG > logs.size()) next[0].setEnabled(false); else next[0].setEnabled(true); if (indexOfForms * MAX_LOG + MAX_LOG > forms.size()) next[1].setEnabled(false); else next[1].setEnabled(true); } }); // Setup timer to refresh list automatically. Timer refreshTimer = new Timer() { @Override public void run() { fillList(); } }; refreshTimer.scheduleRepeating(REFRESH_INTERVAL); }
From source file:com.moesol.gwt.maps.client.controls.MapPanZoomControl.java
License:Open Source License
private void startZoomLoop(Timer zoomTimer) { m_doingMapAction = true; zoomTimer.run(); zoomTimer.scheduleRepeating(m_millisBetweenConsecutiveActions); }
From source file:com.msco.mil.client.com.sencha.gxt.explorer.client.window.MessageBoxExample.java
License:sencha.com license
public Widget asWidget() { final HideHandler hideHandler = new HideHandler() { @Override/* w w w . j ava 2 s. c o m*/ public void onHide(HideEvent event) { Dialog btn = (Dialog) event.getSource(); String msg = Format.substitute("The '{0}' button was pressed", btn.getHideButton().getText()); Info.display("MessageBox", msg); } }; final ButtonBar buttonBar = new ButtonBar(); buttonBar.setMinButtonWidth(75); buttonBar.getElement().setMargins(10); TextButton b = new TextButton("Confirm"); b.addSelectHandler(new SelectHandler() { @Override public void onSelect(SelectEvent event) { ConfirmMessageBox box = new ConfirmMessageBox("Confirm", "Are you sure you want to do that?"); box.addHideHandler(hideHandler); box.show(); } }); buttonBar.add(b); b = new TextButton("Prompt"); b.addSelectHandler(new SelectHandler() { @Override public void onSelect(SelectEvent event) { final PromptMessageBox box = new PromptMessageBox("Name", "Please enter your name:"); box.addHideHandler(new HideHandler() { @Override public void onHide(HideEvent event) { Info.display("MessageBox", "You entered " + box.getValue()); } }); box.show(); } }); buttonBar.add(b); b = new TextButton("Multiline Prompt"); b.addSelectHandler(new SelectHandler() { @Override public void onSelect(SelectEvent event) { final MultiLinePromptMessageBox box = new MultiLinePromptMessageBox("Address", "Please enter your address:"); box.addHideHandler(new HideHandler() { @Override public void onHide(HideEvent event) { String v = Format.ellipse(box.getValue(), 80); String msg = Format.substitute("You entered '{0}'", new Params(v)); Info.display("MessageBox", msg); } }); box.show(); } }); buttonBar.add(b); b = new TextButton("Yes/No/Cancel"); b.addSelectHandler(new SelectHandler() { @Override public void onSelect(SelectEvent event) { MessageBox box = new MessageBox("Save Changes?", ""); box.setPredefinedButtons(PredefinedButton.YES, PredefinedButton.NO, PredefinedButton.CANCEL); box.setIcon(MessageBox.ICONS.question()); box.setMessage( "You are closing a tab that has unsaved changes. Would you like to save your changes?"); box.addHideHandler(new HideHandler() { @Override public void onHide(HideEvent event) { Dialog btn = (Dialog) event.getSource(); String msg = Format.substitute("The '{0}' button was pressed", btn.getHideButton().getText()); Info.display("MessageBox", msg); } }); box.show(); } }); buttonBar.add(b); b = new TextButton("Progress"); b.addSelectHandler(new SelectHandler() { @Override public void onSelect(SelectEvent event) { final ProgressMessageBox box = new ProgressMessageBox("Please wait", "Loading items..."); box.setProgressText("Initializing..."); box.show(); final Timer t = new Timer() { float i; @Override public void run() { box.updateProgress(i / 100, "{0}% Complete"); i += 5; if (i > 100) { cancel(); Info.display("Message", "Items were loaded"); } } }; t.scheduleRepeating(500); } }); buttonBar.add(b); b = new TextButton("Wait"); b.addSelectHandler(new SelectHandler() { @Override public void onSelect(SelectEvent event) { final AutoProgressMessageBox box = new AutoProgressMessageBox("Progress", "Saving your data, please wait..."); box.setProgressText("Saving..."); box.auto(); box.show(); Timer t = new Timer() { @Override public void run() { Info.display("Message", "Your fake data was saved"); box.hide(); } }; t.schedule(5000); } }); buttonBar.add(b); b = new TextButton("Alert"); b.addSelectHandler(new SelectHandler() { @Override public void onSelect(SelectEvent event) { AlertMessageBox d = new AlertMessageBox("Alert", "Access Denied"); d.addHideHandler(hideHandler); d.show(); } }); buttonBar.add(b); return buttonBar; }
From source file:com.nitrous.gwt.earth.client.demo.DataStreamingProgressDemo.java
License:Apache License
/** * Display content on the map/*from w ww . ja v a 2s.c o m*/ */ private void loadMapContent() { // The GEPlugin is the core class and is a great place to start browsing // the API final GEPlugin ge = earth.getGEPlugin(); ge.getWindow().setVisibility(true); // add a navigation control ge.getNavigationControl().setVisibility(GEVisibility.VISIBILITY_AUTO); // add some layers ge.enableLayer(GELayerId.LAYER_BORDERS, true); ge.enableLayer(GELayerId.LAYER_ROADS, true); // Update streaming progress every 100ms Timer t = new Timer() { @Override public void run() { float streamingPercent = ge.getStreamingPercent(); Element progressBar = Document.get().getElementById("progress-bar"); if (streamingPercent == 100) { // streaming complete, hide the progress bar progressBar.setAttribute("style", "background-color:#0a0; width:250px;"); } else { // show the progress bar, max width is 250 as per the // stylesheet progressBar.setAttribute("style", "background-color:#00f; width:" + (250 * streamingPercent / 100) + "px;"); } } }; t.scheduleRepeating(100); // Fly to the Grand Canyon KmlLookAt la = ge.createLookAt(""); la.set(36.291068, -112.4981896, 0, KmlAltitudeMode.ALTITUDE_RELATIVE_TO_GROUND, 0, // heading 80, 20000); ge.getView().setAbstractView(la); }
From source file:com.nitrous.gwt.earth.client.demo.MovingPlacemarkDemo.java
License:Apache License
/** * Display content on the map/*w w w . jav a 2 s . c o m*/ */ private void loadMapContent() { // The GEPlugin is the core class and is a great place to start browsing the API GEPlugin ge = earth.getGEPlugin(); ge.getWindow().setVisibility(true); // show some layers ge.enableLayer(GELayerId.LAYER_BUILDINGS, true); ge.enableLayer(GELayerId.LAYER_BORDERS, true); ge.enableLayer(GELayerId.LAYER_ROADS, true); ge.enableLayer(GELayerId.LAYER_TERRAIN, true); ge.enableLayer(GELayerId.LAYER_TREES, true); // show an over-view pane ge.getOptions().setOverviewMapVisibility(true); // plot a placemark final String placemarkId = "MyPlacemark1"; final KmlPlacemark placemark = ge.createPlacemark(placemarkId); KmlPoint kmlPoint = ge.createPoint(""); kmlPoint.setLatLng(34.73D, -86.59D); kmlPoint.setAltitudeMode(KmlAltitudeMode.ALTITUDE_CLAMP_TO_GROUND); placemark.setGeometry(kmlPoint); // configure a popup balloon for the placemark final GEHtmlStringBalloon balloon = ge.createHtmlStringBalloon("MyBalloon1"); balloon.setContentString("This is a test"); balloon.setFeature(placemark); ge.getFeatures().appendChild(placemark); // give the map 2 seconds to pan and then show the balloon Timer timer = new Timer() { @Override public void run() { earth.getGEPlugin().setBalloon(balloon); } }; timer.schedule(2000); // look at the placemark KmlLookAt lookAt = ge.getView().copyAsLookAt(KmlAltitudeMode.ALTITUDE_RELATIVE_TO_GROUND); lookAt.setLatitude(kmlPoint.getLatitude()); lookAt.setLongitude(kmlPoint.getLongitude()); lookAt.setRange(500000D); ge.getView().setAbstractView(lookAt); // move the placemark once every second Timer t = new Timer() { @Override public void run() { KmlObject obj = earth.getGEPlugin().getElementById(placemarkId); KmlPlacemark placemark = (KmlPlacemark) obj; KmlPoint point = (KmlPoint) placemark.getGeometry(); point.setLatitude(point.getLatitude() + .1D); } }; t.scheduleRepeating(1000); }