List of usage examples for com.google.gwt.user.client Timer Timer
Timer
From source file:com.gwtcx.sample.serendipity.client.view.AmChartsDashboardsView.java
License:Open Source License
public void loadAmChart() { Timer t = new Timer() { public void run() { Log.debug("run()"); Element div = DOM.getElementById("chart_nested_div"); if (div != null) { Log.debug("DOM.getElementById(\"chart_nested_div\") - " + div.getId()); }/*from w w w. j a v a 2s. c o m*/ Log.debug("drawAmChart()"); drawAmChart(); } }; // Schedule the timer to run once after waiting 2 seconds t.schedule(2000); }
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()); }/*www . j av a2 s . 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.gwtext.client.widgets.grid.GridPanel.java
License:Open Source License
/** * Hides the specified column./* w w w.java2s.co m*/ * * @param colIndex the column index */ public void hideColumn(int colIndex) { getColumnModel().setHidden(colIndex, true); if (isRendered() && Ext.isIE()) { Timer t = new Timer() { public void run() { getView().refresh(); getView().updateHeaderSortState(); } }; t.schedule(10); } }
From source file:com.gwtext.client.widgets.grid.GridPanel.java
License:Open Source License
/** * Shows the specified column.//from ww w .j av a 2 s .c o m * * @param colIndex the column index */ public void showColumn(int colIndex) { getColumnModel().setHidden(colIndex, false); if (Ext.isIE()) { Timer t = new Timer() { public void run() { getView().refresh(); getView().updateHeaderSortState(); } }; t.schedule(10); } }
From source file:com.gwtext.sample.showcase2.client.misc.ProgressBarSample.java
License:Open Source License
public Panel getViewPanel() { if (panel == null) { panel = new Panel(); panel.setLayout(new VerticalLayout(15)); final ProgressBar pbar1 = new ProgressBar(); pbar1.setWidth(300);//from w w w. jav a 2 s . c om pbar1.setText("Ready"); Panel panel1 = new Panel(); panel1.setTitle("Basic Progress Bar"); panel1.setFrame(true); panel1.setWidth(400); panel1.setHeight(150); panel1.setPaddings(20); Button button1 = new Button("Start", new ButtonListenerAdapter() { public void onClick(final Button button, EventObject e) { button.disable(); pbar1.reset(); for (int i = 1; i < 12; i++) { final int j = i; Timer timer = new Timer() { public void run() { if (j == 11) { pbar1.setText("Done."); button.enable(); } else { pbar1.setText(Format.format("Loading item {0} of 10...", j + "")); pbar1.setValue(pbar1.getValue() + 0.1f); } } }; timer.schedule(i * 1000); } } }); panel1.add(new HTMLPanel("A Basic ProgressBar with build-in progress text.", 0, 0, 0, 10)); panel1.add(pbar1); panel1.addButton(button1); panel.add(panel1); Panel panel2 = new Panel(); panel2.setTitle("Left Align Text"); panel2.setFrame(true); panel2.setWidth(400); panel2.setHeight(150); panel2.setPaddings(20); final ProgressBar pbar2 = new ProgressBar(); pbar2.setCls("left-align"); pbar2.setWidth(300); pbar2.setText("Ready"); Button button2 = new Button("Start", new ButtonListenerAdapter() { public void onClick(final Button button, EventObject e) { button.disable(); pbar2.reset(); for (int i = 1; i < 12; i++) { final int j = i; Timer timer = new Timer() { public void run() { if (j > 11) { pbar2.setText("Done."); button.enable(); } else { pbar2.setText(Format.format("Loading item {0} of 10...", j + "")); pbar2.setValue(pbar2.getValue() + 0.1f); } } }; timer.schedule(i * 1000); } } }); panel2.add(new HTMLPanel("A ProgressBar with label left aligned via CSS.", 0, 0, 0, 10)); panel2.add(pbar2); panel2.addButton(button2); panel.add(panel2); Panel panel3 = new Panel(); panel3.setTitle("Waiting Bar"); panel3.setFrame(true); panel3.setWidth(400); panel3.setHeight(150); panel3.setPaddings(20); final ProgressBar pbar3 = new ProgressBar(); pbar3.setWidth(300); Button button3 = new Button("Start", new ButtonListenerAdapter() { public void onClick(final Button button, EventObject e) { button.disable(); pbar3.reset(); pbar3.wait(new WaitConfig() { { setInterval(200); setDuration(8000); setIncrement(15); setCallback(new Function() { public void execute() { button.enable(); } }); } }); } }); panel3.add(new HTMLPanel( "Wait for a long operation to complete (example will stop after 8 secs) with progress update every 200ms and in increments of 15 segments.", 0, 0, 0, 10)); panel3.add(pbar3); panel3.addButton(button3); panel.add(panel3); Panel panel4 = new Panel(); panel4.setTitle("Custom Styles"); panel4.setFrame(true); panel4.setWidth(400); panel4.setHeight(170); panel4.setPaddings(20); final ProgressBar pbar4 = new ProgressBar(); pbar4.setText("Waiting on you..."); pbar4.setTextEl("p4text"); pbar4.setCls("custom"); pbar4.setWidth(300); Button button4 = new Button("Start", new ButtonListenerAdapter() { public void onClick(final Button button, EventObject e) { button.disable(); pbar4.reset(); for (int i = 1; i < 12; i++) { final int j = i; Timer timer = new Timer() { public void run() { if (j == 11) { pbar4.setText("All Done!"); button.enable(); } else { float value = pbar4.getValue() + 0.1f; pbar4.setText(Format.format("{0}% completed... ", (int) (value * 100) + "")); pbar4.setValue(value); } } }; timer.schedule(i * 1000); } } }); panel4.add(new HTMLPanel("Rendered like Windows XP with custom progress text element.", 0, 0, 0, 10)); panel4.add(pbar4); HTMLPanel status = new HTMLPanel( "<div class=\"status\"><b>Status:</b> <span id=\"p4text\"></span></div>", 10, 0, 0, 0); //the textEl must be already present in the DOM prior to ProgressBar creation status.render(Ext.getBody().getDOM()); panel4.add(status); panel4.addButton(button4); panel.add(panel4); } return panel; }
From source file:com.gwtext.sample.showcase2.client.tree.CheckboxTreePanel.java
License:Open Source License
public Panel getViewPanel() { if (panel == null) { panel = new Panel(); final TreePanel treePanel = new TreePanel(); treePanel.setTitle("Checkbox Tree"); treePanel.setCollapsible(true);/* w w w.ja v a 2 s. c o m*/ treePanel.setIconCls("world-icon"); treePanel.setHeight(400); treePanel.setWidth(200); treePanel.setAnimate(true); treePanel.setEnableDD(true); treePanel.setContainerScroll(true); treePanel.setAutoScroll(true); treePanel.setRootVisible(true); treePanel.setFrame(true); XMLTreeLoader loader = new XMLTreeLoader(); loader.setDataUrl("countries-cb.xml"); loader.setMethod(Connection.GET); loader.setRootTag("countries"); loader.setFolderIdMapping("@id"); loader.setLeafIdMapping("@id"); loader.setFolderTitleMapping("@title"); loader.setFolderTag("team"); loader.setLeafTitleMapping("@title"); loader.setLeafTag("country"); loader.setQtipMapping("@qtip"); loader.setDisabledMapping("@disabled"); loader.setCheckedMapping("@checked"); loader.setIconMapping("@icon"); loader.setAttributeMappings(new String[] { "@rank" }); final AsyncTreeNode root = new AsyncTreeNode("Countries", loader); treePanel.setRootNode(root); root.expand(); treePanel.addTool(new Tool(Tool.REFRESH, new Function() { public void execute() { treePanel.getEl().mask("Loading", "x-mask-loading"); root.reload(); root.collapse(true, false); Timer timer = new Timer() { public void run() { treePanel.getEl().unmask(); root.expand(true, true); } }; timer.schedule(1000); } }, "Refresh")); treePanel.expandAll(); Button button = new Button("Show Checked", new ButtonListenerAdapter() { public void onClick(Button button, EventObject e) { TreeNode[] checkedNodes = treePanel.getChecked(); String checkedNodesString = ""; for (int i = 0; i < checkedNodes.length; i++) { TreeNode checkedNode = checkedNodes[i]; checkedNodesString += "<br>" + checkedNode.getText(); } Showcase2.showMessage("Checked Nodes", checkedNodesString); } }); Button toggle = new Button("Toggle Team A", new ButtonListenerAdapter() { public void onClick(Button button, EventObject e) { treePanel.getNodeById("team-a").getUI().toggleCheck(); } }); treePanel.addButton(button); treePanel.addButton(toggle); panel.add(treePanel); } return panel; }
From source file:com.gwtext.sample.showcase2.client.tree.EditableTreePanel.java
License:Open Source License
public Panel getViewPanel() { if (panel == null) { final Store store = new SimpleStore(new String[] { "abbr", "country" }, SampleData.getCountries()); store.load();//from ww w.j a v a 2s .c om final Template template = new Template( "<div class=\"x-combo-list-item\"><img src=\"images/flags/{abbr}.gif\"> " + "{country}<div class=\"x-clear\"></div></div>"); ComboBox cb = new ComboBox(); cb.setMinChars(1); cb.setFieldLabel("Countries"); cb.setStore(store); cb.setDisplayField("country"); cb.setMode(ComboBox.LOCAL); cb.setTriggerAction(ComboBox.ALL); cb.setEmptyText("Select Country"); cb.setTypeAhead(true); cb.setSelectOnFocus(true); cb.setWidth(60); cb.setResizable(true); cb.setTpl(template); cb.setTitle("Countries"); cb.setAllowBlank(false); final TreePanel treePanel = new TreePanel(); treePanel.setWidth(240); treePanel.setHeight(400); treePanel.setTitle("Editable Tree"); treePanel.setAnimate(true); treePanel.setEnableDD(true); treePanel.setContainerScroll(true); treePanel.setRootVisible(true); final XMLTreeLoader loader = new XMLTreeLoader(); loader.setDataUrl("data/countries.xml"); loader.setMethod(Connection.GET); loader.setRootTag("countries"); loader.setFolderTitleMapping("@title"); loader.setFolderTag("team"); loader.setLeafTitleMapping("@title"); loader.setLeafTag("country"); loader.setQtipMapping("@qtip"); loader.setDisabledMapping("@disabled"); loader.setCheckedMapping("@checked"); loader.setIconMapping("@icon"); loader.setAttributeMappings(new String[] { "@rank" }); final AsyncTreeNode root = new AsyncTreeNode("Countries", loader); treePanel.setRootNode(root); root.expand(); treePanel.expandAll(); treePanel.addTool(new Tool(Tool.REFRESH, new Function() { public void execute() { treePanel.getEl().mask("Loading", "x-mask-loading"); root.reload(); root.collapse(true, false); Timer timer = new Timer() { public void run() { treePanel.getEl().unmask(); root.expand(true, true); } }; timer.schedule(1000); } }, "Refresh")); TreeEditor treeEditor = new TreeEditor(treePanel, cb); panel = new Panel(); panel.setBorder(false); panel.add(treePanel); } return panel; }
From source file:com.gwtext.sample.showcase2.client.window.MessageBoxSample.java
License:Open Source License
public Panel getViewPanel() { if (panel == null) { panel = new Panel(); panel.setLayout(new TableLayout(2)); Panel panel1 = new Panel(); panel1.setTitle("Confirm"); panel1.setFrame(true);/*from w w w.j a v a2 s . c o m*/ panel1.setWidth(250); panel1.setHeight(150); panel1.setPaddings(20); Button button1 = new Button("Show Me", new ButtonListenerAdapter() { public void onClick(Button button, EventObject e) { MessageBox.confirm("Confirm", "Are you sure you want to do that?", new MessageBox.ConfirmCallback() { public void execute(String btnID) { Showcase2.showMessage("Button Click", Format.format("You clicked the {0} button", btnID)); } }); } }); panel1.add(new HTMLPanel("A Standard Yes/No Confirm Dialog.", 0, 0, 0, 10)); panel1.addButton(button1); panel.add(new PaddedPanel(panel1, 0, 0, 10, 10)); Panel panel2 = new Panel(); panel2.setTitle("Prompt"); panel2.setFrame(true); panel2.setWidth(250); panel2.setHeight(150); panel2.setPaddings(20); Button button2 = new Button("Show Me", new ButtonListenerAdapter() { public void onClick(Button button, EventObject e) { MessageBox.prompt("Name", "Please enter your name:", new MessageBox.PromptCallback() { public void execute(String btnID, String text) { Showcase2.showMessage("Button Click", Format.format( "You clicked the {0} button and entered the text \"{1}\"", btnID, text)); } }); } }); panel2.add(new HTMLPanel("A Standard prompt dialog.", 0, 0, 0, 10)); panel2.addButton(button2); panel.add(new PaddedPanel(panel2, 0, 0, 10, 10)); Panel panel3 = new Panel(); panel3.setTitle("Multi-line Prompt"); panel3.setFrame(true); panel3.setWidth(250); panel3.setHeight(150); panel3.setPaddings(20); Button button3 = new Button("Show Me", new ButtonListenerAdapter() { public void onClick(final Button button, EventObject e) { MessageBox.show(new MessageBoxConfig() { { setTitle("Address"); setMsg("Please enter your address:"); setWidth(300); setButtons(MessageBox.OKCANCEL); setMultiline(true); setCallback(new MessageBox.PromptCallback() { public void execute(String btnID, String text) { Showcase2.showMessage("Button Click", Format.format("You clicked the {0} button and entered the text \"{1}\"", btnID, text)); } }); setAnimEl(button.getId()); } }); } }); panel3.add(new HTMLPanel("A multi-line prompt dialog.", 0, 0, 0, 10)); panel3.addButton(button3); panel.add(new PaddedPanel(panel3, 0, 0, 10, 10)); Panel panel4 = new Panel(); panel4.setTitle("Yes/No/Cancel"); panel4.setFrame(true); panel4.setWidth(250); panel4.setHeight(150); panel4.setPaddings(20); Button button4 = new Button("Show Me", new ButtonListenerAdapter() { public void onClick(final Button button, EventObject e) { MessageBox.show(new MessageBoxConfig() { { setTitle("Save Changes?"); setMsg("Your are closing a tab that has unsaved changes. Would you like to save your changes?"); setButtons(MessageBox.YESNOCANCEL); setCallback(new MessageBox.PromptCallback() { public void execute(String btnID, String text) { Showcase2.showMessage("Button Click", Format.format("You clicked the {0} button", btnID)); } }); setAnimEl(button.getId()); } }); } }); panel4.add(new HTMLPanel("Standard Yes/No/Cancel dialog.", 0, 0, 0, 10)); panel4.addButton(button4); panel.add(new PaddedPanel(panel4, 0, 0, 10, 10)); Panel panel5 = new Panel(); panel5.setTitle("Progress Dialog"); panel5.setFrame(true); panel5.setWidth(250); panel5.setHeight(150); panel5.setPaddings(20); Button button5 = new Button("Show Me", new ButtonListenerAdapter() { public void onClick(final Button button, EventObject e) { MessageBox.show(new MessageBoxConfig() { { setTitle("Please wait..."); setMsg("Initializing..."); setWidth(240); setProgress(true); setClosable(false); setCallback(new MessageBox.PromptCallback() { public void execute(String btnID, String text) { Showcase2.showMessage("Button Click", Format.format( "You clicked the {0} button and entered the text {1}", btnID, text)); } }); setAnimEl(button.getId()); } }); //create bogus progress for (int i = 1; i < 12; i++) { final int j = i; Timer timer = new Timer() { public void run() { if (j == 11) { MessageBox.hide(); } else { MessageBox.updateProgress(j * 10, "Loading item " + j + " of 10... "); } } }; timer.schedule(i * 1000); } } }); panel5.add(new HTMLPanel("You can set a progress on a progress MessageBox..", 0, 0, 0, 10)); panel5.addButton(button5); panel.add(new PaddedPanel(panel5, 0, 0, 10, 10)); Panel panel6 = new Panel(); panel6.setTitle("Wait Dialog"); panel6.setFrame(true); panel6.setWidth(250); panel6.setHeight(150); panel6.setPaddings(20); Button button6 = new Button("Show Me", new ButtonListenerAdapter() { public void onClick(final Button button, EventObject e) { MessageBox.show(new MessageBoxConfig() { { setMsg("Saving your data, please wait..."); setProgressText("Saving..."); setWidth(300); setWait(true); setWaitConfig(new WaitConfig() { { setInterval(200); } }); setAnimEl(button.getId()); } }); Timer timer = new Timer() { public void run() { MessageBox.hide(); Showcase2.showMessage("Done", "Your fake data was saved!"); } }; timer.schedule(8000); } }); panel6.add(new HTMLPanel("Dialog with indefinite progress bar (will close after 8 sec).", 0, 0, 0, 10)); panel6.addButton(button6); panel.add(new PaddedPanel(panel6, 0, 0, 10, 10)); Panel panel7 = new Panel(); panel7.setTitle("Alert"); panel7.setFrame(true); panel7.setWidth(250); panel7.setHeight(150); panel7.setPaddings(20); Button button7 = new Button("Show Me", new ButtonListenerAdapter() { public void onClick(Button button, EventObject e) { MessageBox.alert("Changes saved successfully"); } }); panel7.add(new HTMLPanel("Standard Alert dialog.", 0, 0, 0, 10)); panel7.addButton(button7); panel.add(new PaddedPanel(panel7, 0, 0, 10, 10)); } return panel; }
From source file:com.gwtm.ui.client.widgets.ListPanel.java
License:Apache License
@Override public void onDraggingStart(DraggingEvent e) { if (selectable) { selected = Utils.Html.getTargetItemIndex(getElement(), e.getNativeEvent().getEventTarget()); // if nothing selected, return if (selected < 0) return; // set timer to detect a click new Timer() { @Override/* w w w . ja v a2 s . co m*/ public void run() { if (selected >= 0) { ListItem item = (ListItem) getWidget(selected); if (item.isEnabled()) { Utils.Widgets.setExtensionCssClass(getWidget(selected), ThemeConstants.Extension.pressed); } } } }.schedule(75); } }
From source file:com.gwtm.ui.client.widgets.ProgressBar.java
License:Apache License
private void updatePosition_() { css_().setWidth((value * 100), Unit.PCT); final int pctVal = getPercentValue(); if (pctVal >= 100) { state = State.COMPLETED;/*from w ww .jav a2s. co m*/ } if (transistionTiming > -1) { css_().setProperty("webkitTransitionDuration", transistionTiming + "ms"); new Timer() { public void run() { label.setHTML(formatLabel(pctVal)); } }.schedule(transistionTiming); } else { new Timer() { public void run() { label.setHTML(formatLabel(pctVal)); } }.schedule(500/* defined at css */); } }