List of usage examples for com.google.gwt.user.client Timer schedule
public synchronized void schedule(int delayMs)
From source file:com.gwtext.client.widgets.grid.GridPanel.java
License:Open Source License
/** * Shows the specified column./*from w ww . jav a2 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);/* w w w . jav a 2 s . c o m*/ 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);/* www .j a 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();// w w w . j a v a 2 s .co m 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 ww w. j av a 2 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.gwtmobile.ui.client.page.Page.java
License:Apache License
@Override public void onTransitionEnd(TransitionDirection direction) { if (direction != TransitionDirection.To) { return;//from w w w. j a va 2 s.co m } final Page to; final PageHistory pageHistory = PageHistory.Instance; final NavigateInfo info = pageHistory.getNavigateInfo(); if (false == info.isGoBack()) { // goto to = this; // TODO: change to use scheduler deferred command. Timer timer = new Timer() { @Override public void run() { to.onNavigateTo(info.getFromPage(), info.getValue()); to.initNavigationIfRequired(); } }; timer.schedule(1); } else { // goback to = pageHistory.current(); Timer timer = new Timer() { @Override public void run() { to.onNavigateBack(info.getFromPage(), info.getValue()); to.initNavigationIfRequired(); } }; timer.schedule(1); } _inTransition = false; }
From source file:com.haulmont.cuba.web.toolkit.ui.client.downloader.CubaFileDownloaderConnector.java
License:Apache License
public void downloadFileById(String resourceId) { final String url = getResourceUrl(resourceId); if (url != null && !url.isEmpty()) { final IFrameElement iframe = Document.get().createIFrameElement(); Style style = iframe.getStyle(); style.setVisibility(Style.Visibility.HIDDEN); style.setHeight(0, Style.Unit.PX); style.setWidth(0, Style.Unit.PX); iframe.setFrameBorder(0);//from w w w. j a v a2 s .c om iframe.setTabIndex(-1); iframe.setSrc(url); RootPanel.getBodyElement().appendChild(iframe); Timer removeTimer = new Timer() { @Override public void run() { iframe.removeFromParent(); } }; removeTimer.schedule(60 * 1000); } }
From source file:com.haulmont.cuba.web.toolkit.ui.client.orderedactionslayout.CubaOrderedLayoutSlot.java
License:Apache License
public void setCaption(String captionText, boolean contextHelpIconEnabled, Icon icon, List<String> styles, String error, boolean showError, boolean required, boolean enabled, boolean captionAsHtml) { // CAUTION copied from super // Caption wrappers Widget widget = getWidget();//from w w w . j ava 2s .c o m final Element focusedElement = WidgetUtil.getFocusedElement(); // By default focus will not be lost boolean focusLost = false; if (captionText != null || icon != null || error != null || required || contextHelpIconEnabled) { if (caption == null) { caption = DOM.createDiv(); captionWrap = DOM.createDiv(); captionWrap.addClassName(StyleConstants.UI_WIDGET); captionWrap.addClassName("v-has-caption"); getElement().appendChild(captionWrap); orphan(widget); captionWrap.appendChild(widget.getElement()); adopt(widget); // Made changes to DOM. Focus can be lost if it was in the // widget. focusLost = (focusedElement == null ? false : widget.getElement().isOrHasChild(focusedElement)); } } else if (caption != null) { orphan(widget); getElement().appendChild(widget.getElement()); adopt(widget); captionWrap.removeFromParent(); caption = null; captionWrap = null; // Made changes to DOM. Focus can be lost if it was in the widget. focusLost = (focusedElement == null ? false : widget.getElement().isOrHasChild(focusedElement)); } // Caption text if (captionText != null) { if (this.captionText == null) { this.captionText = DOM.createSpan(); this.captionText.addClassName("v-captiontext"); if (caption != null) { caption.appendChild(this.captionText); } } if (captionText.trim().equals("")) { this.captionText.setInnerHTML(" "); } else { if (captionAsHtml) { this.captionText.setInnerHTML(captionText); } else { this.captionText.setInnerText(captionText); } } } else if (this.captionText != null) { this.captionText.removeFromParent(); this.captionText = null; } // Icon if (this.icon != null) { this.icon.getElement().removeFromParent(); } if (icon != null) { if (caption != null) { caption.insertFirst(icon.getElement()); } } this.icon = icon; // Required if (required) { if (requiredIcon == null) { requiredIcon = DOM.createSpan(); // TODO decide something better (e.g. use CSS to insert the // character) requiredIcon.setInnerHTML("*"); requiredIcon.setClassName("v-required-field-indicator"); // The star should not be read by the screen reader, as it is // purely visual. Required state is set at the element level for // the screen reader. Roles.getTextboxRole().setAriaHiddenState(requiredIcon, true); } if (caption != null) { caption.appendChild(requiredIcon); } } else if (requiredIcon != null) { requiredIcon.removeFromParent(); requiredIcon = null; } // Context Help // Haulmont API if (contextHelpIconEnabled) { if (contextHelpIcon == null) { contextHelpIcon = DOM.createSpan(); // TODO decide something better (e.g. use CSS to insert the character) contextHelpIcon.setInnerHTML("?"); contextHelpIcon.setClassName(CONTEXT_HELP_CLASSNAME); // The question mark should not be read by the screen reader, as it is // purely visual. Required state is set at the element level for // the screen reader. Roles.getTextboxRole().setAriaHiddenState(contextHelpIcon, true); } if (caption != null) { caption.appendChild(contextHelpIcon); if (clickHandlerRegistration == null) { clickHandlerRegistration = addDomHandler(this, ClickEvent.getType()); } } } else { if (this.contextHelpIcon != null) { this.contextHelpIcon.removeFromParent(); this.contextHelpIcon = null; } if (clickHandlerRegistration != null) { clickHandlerRegistration.removeHandler(); clickHandlerRegistration = null; } } // Error if (error != null && showError) { if (errorIcon == null) { errorIcon = DOM.createSpan(); errorIcon.setClassName("v-errorindicator"); } if (caption != null) { caption.appendChild(errorIcon); } } else if (errorIcon != null) { errorIcon.removeFromParent(); errorIcon = null; } if (caption != null) { // Styles caption.setClassName("v-caption"); if (styles != null) { for (String style : styles) { caption.addClassName("v-caption-" + style); } } if (enabled) { caption.removeClassName("v-disabled"); } else { caption.addClassName("v-disabled"); } // Caption position if (captionText != null || icon != null) { setCaptionPosition(CaptionPosition.TOP); } else { setCaptionPosition(CaptionPosition.RIGHT); } } if (focusLost) { // Find out what element is currently focused. Element currentFocus = WidgetUtil.getFocusedElement(); if (currentFocus != null && currentFocus.equals(Document.get().getBody())) { // Focus has moved to BodyElement and should be moved back to // original location. This happened because of adding or // removing the captionWrap focusedElement.focus(); } else if (currentFocus != focusedElement) { // Focus is either moved somewhere else on purpose or IE has // lost it. Investigate further. Timer focusTimer = new Timer() { @Override public void run() { if (WidgetUtil.getFocusedElement() == null) { // This should never become an infinite loop and // even if it does it will be stopped once something // is done with the browser. schedule(25); } else if (WidgetUtil.getFocusedElement().equals(Document.get().getBody())) { // Focus found it's way to BodyElement. Now it can // be restored focusedElement.focus(); } } }; if (BrowserInfo.get().isIE8()) { // IE8 can't fix the focus immediately. It will fail. focusTimer.schedule(25); } else { // Newer IE versions can handle things immediately. focusTimer.run(); } } } }
From source file:com.haulmont.cuba.web.widgets.client.orderedactionslayout.CubaOrderedLayoutSlot.java
License:Apache License
public void setCaption(String captionText, boolean contextHelpIconEnabled, Icon icon, List<String> styles, String error, boolean showError, boolean required, boolean enabled, boolean captionAsHtml) { // CAUTION copied from super // Caption wrappers Widget widget = getWidget();// w ww.ja v a 2s. c o m final Element focusedElement = WidgetUtil.getFocusedElement(); // By default focus will not be lost boolean focusLost = false; if (captionText != null || icon != null || error != null || required || contextHelpIconEnabled) { if (caption == null) { caption = DOM.createDiv(); captionWrap = DOM.createDiv(); captionWrap.addClassName(StyleConstants.UI_WIDGET); captionWrap.addClassName("v-has-caption"); getElement().appendChild(captionWrap); orphan(widget); captionWrap.appendChild(widget.getElement()); adopt(widget); // Made changes to DOM. Focus can be lost if it was in the // widget. focusLost = (focusedElement == null ? false : widget.getElement().isOrHasChild(focusedElement)); } } else if (caption != null) { orphan(widget); getElement().appendChild(widget.getElement()); adopt(widget); captionWrap.removeFromParent(); caption = null; captionWrap = null; // Made changes to DOM. Focus can be lost if it was in the widget. focusLost = (focusedElement == null ? false : widget.getElement().isOrHasChild(focusedElement)); } // Caption text if (captionText != null) { if (this.captionText == null) { this.captionText = DOM.createSpan(); this.captionText.addClassName("v-captiontext"); if (caption != null) { caption.appendChild(this.captionText); } } if (captionText.trim().equals("")) { this.captionText.setInnerHTML(" "); } else { if (captionAsHtml) { this.captionText.setInnerHTML(captionText); } else { this.captionText.setInnerText(captionText); } } } else if (this.captionText != null) { this.captionText.removeFromParent(); this.captionText = null; } // Icon if (this.icon != null) { this.icon.getElement().removeFromParent(); } if (icon != null) { if (caption != null) { caption.insertFirst(icon.getElement()); } } this.icon = icon; // Required if (required) { if (requiredIcon == null) { requiredIcon = DOM.createSpan(); // TODO decide something better (e.g. use CSS to insert the // character) requiredIcon.setInnerHTML("*"); requiredIcon.setClassName("v-required-field-indicator"); // The star should not be read by the screen reader, as it is // purely visual. Required state is set at the element level for // the screen reader. Roles.getTextboxRole().setAriaHiddenState(requiredIcon, true); } if (caption != null) { caption.appendChild(requiredIcon); } } else if (requiredIcon != null) { requiredIcon.removeFromParent(); requiredIcon = null; } // Context Help // Haulmont API if (contextHelpIconEnabled) { if (contextHelpIcon == null) { contextHelpIcon = DOM.createSpan(); // TODO decide something better (e.g. use CSS to insert the character) contextHelpIcon.setInnerHTML("?"); contextHelpIcon.setClassName(CONTEXT_HELP_CLASSNAME); ComponentConnector componentConnector = Util.findConnectorFor(widget); if (hasContextHelpIconListeners(componentConnector.getState())) { contextHelpIcon.addClassName(CONTEXT_HELP_CLICKABLE_CLASSNAME); } // The question mark should not be read by the screen reader, as it is // purely visual. Required state is set at the element level for // the screen reader. Roles.getTextboxRole().setAriaHiddenState(contextHelpIcon, true); } if (caption != null) { caption.appendChild(contextHelpIcon); if (clickHandlerRegistration == null) { clickHandlerRegistration = addDomHandler(this, ClickEvent.getType()); } } } else { if (this.contextHelpIcon != null) { this.contextHelpIcon.removeFromParent(); this.contextHelpIcon = null; } if (clickHandlerRegistration != null) { clickHandlerRegistration.removeHandler(); clickHandlerRegistration = null; } } // Error if (error != null && showError) { if (errorIcon == null) { errorIcon = DOM.createSpan(); errorIcon.setClassName("v-errorindicator"); } if (caption != null) { caption.appendChild(errorIcon); } } else if (errorIcon != null) { errorIcon.removeFromParent(); errorIcon = null; } if (caption != null) { // Styles caption.setClassName("v-caption"); if (styles != null) { for (String style : styles) { caption.addClassName("v-caption-" + style); } } if (enabled) { caption.removeClassName("v-disabled"); } else { caption.addClassName("v-disabled"); } // Caption position if (captionText != null || icon != null) { setCaptionPosition(CaptionPosition.TOP); } else { setCaptionPosition(CaptionPosition.RIGHT); } } if (focusLost) { // Find out what element is currently focused. Element currentFocus = WidgetUtil.getFocusedElement(); if (currentFocus != null && currentFocus.equals(Document.get().getBody())) { // Focus has moved to BodyElement and should be moved back to // original location. This happened because of adding or // removing the captionWrap focusedElement.focus(); } else if (currentFocus != focusedElement) { // Focus is either moved somewhere else on purpose or IE has // lost it. Investigate further. Timer focusTimer = new Timer() { @Override public void run() { if (WidgetUtil.getFocusedElement() == null) { // This should never become an infinite loop and // even if it does it will be stopped once something // is done with the browser. schedule(25); } else if (WidgetUtil.getFocusedElement().equals(Document.get().getBody())) { // Focus found it's way to BodyElement. Now it can // be restored focusedElement.focus(); } } }; if (BrowserInfo.get().isIE8()) { // IE8 can't fix the focus immediately. It will fail. focusTimer.schedule(25); } else { // Newer IE versions can handle things immediately. focusTimer.run(); } } } }
From source file:com.ikon.frontend.client.util.ConversionStatus.java
License:Open Source License
/** * refreshStatus// w ww. j a va 2s . co m */ private void refreshStatus() { Timer refreshStatus = new Timer() { @Override public void run() { getStatus(); } }; refreshStatus.schedule(REFRESH_STATUS_DELAY); }