List of usage examples for com.google.gwt.user.client.ui HTML getHTML
public String getHTML()
From source file:org.bonitasoft.forms.client.view.widget.FormFieldWidget.java
License:Open Source License
/** * Retrieve the value of the field under the form of a {@link FormFieldValue} object. This conversion is needed because RPC * calls do not support the type 'Object'. * * @return a {@link FormFieldValue} object *///from w w w.j av a 2s. co m @SuppressWarnings("unchecked") public FormFieldValue getValue() { long attachmentId = -1; String attachmentName = null; Serializable value = null; String valueType = null; String format = null; String displayedValue = null; switch (widgetType) { case TEXTBOX: final TextBox textBox = (TextBox) fieldWidget; value = textBox.getValue(); valueType = SupportedFieldTypes.JAVA_STRING_CLASSNAME; break; case TEXTAREA: final TextArea textArea = (TextArea) fieldWidget; value = textArea.getValue(); valueType = SupportedFieldTypes.JAVA_STRING_CLASSNAME; break; case TEXT: final HTML text = (HTML) fieldWidget; value = text.getHTML(); valueType = SupportedFieldTypes.JAVA_STRING_CLASSNAME; break; case RICH_TEXTAREA: final RichTextWidget richTextWidget = (RichTextWidget) fieldWidget; value = richTextWidget.getValue(); valueType = SupportedFieldTypes.JAVA_STRING_CLASSNAME; break; case PASSWORD: final PasswordTextBox passwordTextBox = (PasswordTextBox) fieldWidget; value = passwordTextBox.getValue(); valueType = SupportedFieldTypes.JAVA_STRING_CLASSNAME; break; case CHECKBOX: final CheckBox checkBox = (CheckBox) fieldWidget; value = checkBox.getValue(); valueType = SupportedFieldTypes.JAVA_BOOLEAN_CLASSNAME; break; case RADIOBUTTON_GROUP: final RadioButtonGroupWidget radioButtonGroupWidget = (RadioButtonGroupWidget) fieldWidget; value = radioButtonGroupWidget.getValue(); valueType = SupportedFieldTypes.JAVA_STRING_CLASSNAME; break; case LISTBOX_SIMPLE: final ListBox listBox = (ListBox) fieldWidget; final int index = listBox.getSelectedIndex(); if (index > -1) { value = listBox.getValue(index); } valueType = SupportedFieldTypes.JAVA_STRING_CLASSNAME; break; case LISTBOX_MULTIPLE: value = new ArrayList<String>(); final ListBox listBoxMulti = (ListBox) fieldWidget; for (int i = 0; i < listBoxMulti.getItemCount(); i++) { if (listBoxMulti.isItemSelected(i)) { ((List<String>) value).add(listBoxMulti.getValue(i)); } } valueType = SupportedFieldTypes.JAVA_COLLECTION_CLASSNAME; break; case SUGGESTBOX: final SuggestBox suggestBox = (SuggestBox) fieldWidget; displayedValue = suggestBox.getValue(); value = suggestionsMap.get(displayedValue); if (value == null) { value = displayedValue; } valueType = SupportedFieldTypes.JAVA_STRING_CLASSNAME; break; case SUGGESTBOX_ASYNC: final AsyncSuggestBoxWidget formAsyncSuggestBoxWidget = (AsyncSuggestBoxWidget) fieldWidget; value = formAsyncSuggestBoxWidget.getValue(); valueType = SupportedFieldTypes.JAVA_STRING_CLASSNAME; break; case CHECKBOX_GROUP: value = new ArrayList<String>(); final CheckboxGroupWidget checkboxGroupWidget = (CheckboxGroupWidget) fieldWidget; for (final String checkboxGroupValue : checkboxGroupWidget.getValue()) { ((List<String>) value).add(checkboxGroupValue); } valueType = SupportedFieldTypes.JAVA_COLLECTION_CLASSNAME; break; case DATE: final DateBox dateBox = (DateBox) fieldWidget; final String strValue = dateBox.getTextBox().getValue(); final Date dtValue = dateBox.getValue(); if (strValue != null && strValue.length() > 0 && dtValue == null) { value = strValue; valueType = SupportedFieldTypes.JAVA_STRING_CLASSNAME; } else { value = dtValue; valueType = SupportedFieldTypes.JAVA_DATE_CLASSNAME; } break; case DURATION: final DurationWidget duration = (DurationWidget) fieldWidget; value = duration.getValue(); valueType = SupportedFieldTypes.JAVA_LONG_CLASSNAME; break; case FILEUPLOAD: final FileUploadWidget fileUpload = (FileUploadWidget) fieldWidget; attachmentName = fileUpload.getAttachmentName(); attachmentId = fileUpload.getAttachmentId(); value = fileUpload.getValue(); displayedValue = fileUpload.getDisplayedValue(); valueType = fileUpload.getValueType(); break; case TABLE: final TableWidget table = (TableWidget) fieldWidget; value = (Serializable) table.getValue(); valueType = SupportedFieldTypes.JAVA_COLLECTION_CLASSNAME; break; case EDITABLE_GRID: final EditableGridWidget grid = (EditableGridWidget) fieldWidget; value = (Serializable) grid.getValue(); valueType = SupportedFieldTypes.JAVA_COLLECTION_CLASSNAME; break; case HIDDEN: final Hidden hidden = (Hidden) fieldWidget; value = hidden.getValue(); valueType = SupportedFieldTypes.JAVA_STRING_CLASSNAME; break; default: break; } if (displayFormat != null) { format = displayFormat.getPattern(); } else { format = DateTimeFormat.getFormat(PredefinedFormat.DATE_LONG).getPattern(); } final FormFieldValue formFieldValue = new FormFieldValue(value, valueType, format, fieldOutputType); if (WidgetType.FILEUPLOAD.equals(widgetType)) { formFieldValue.setDocumentName(attachmentName); formFieldValue.setDocumentId(attachmentId); formFieldValue.setDisplayedValue(displayedValue); formFieldValue.setDocument(true); } return formFieldValue; }
From source file:org.bonitasoft.forms.client.view.widget.FormFieldWidget.java
License:Open Source License
/** * Set the value of the widget/* w w w. java 2 s. c om*/ * * @param fieldValue */ public void setValue(final FormFieldValue fieldValue) { if (fieldValue.getValue() != null) { Collection<String> values = null; boolean fireEvents = true; switch (widgetType) { case TEXTBOX: final TextBox textBox = (TextBox) fieldWidget; if (SupportedFieldTypes.JAVA_DATE_CLASSNAME.equals(fieldValue.getValueType())) { textBox.setValue(getDateAsText(fieldValue), fireEvents); } else { textBox.setValue(getStringValue(fieldValue), fireEvents); } break; case TEXTAREA: final TextArea textArea = (TextArea) fieldWidget; if (SupportedFieldTypes.JAVA_DATE_CLASSNAME.equals(fieldValue.getValueType())) { textArea.setValue(getDateAsText(fieldValue), fireEvents); } else { textArea.setValue(getStringValue(fieldValue), fireEvents); } break; case RICH_TEXTAREA: final RichTextWidget richTextWidget = (RichTextWidget) fieldWidget; if (SupportedFieldTypes.JAVA_DATE_CLASSNAME.equals(fieldValue.getValueType())) { richTextWidget.setValue(getDateAsText(fieldValue)); } else { richTextWidget.setValue(getStringValue(fieldValue)); } break; case TEXT: final HTML text = (HTML) fieldWidget; if (text.getHTML() != null && text.getHTML().equals(fieldValue.getValue()) || fieldValue.getValue() != null && fieldValue.getValue().equals(text.getHTML())) { fireEvents = false; } if (SupportedFieldTypes.JAVA_DATE_CLASSNAME.equals(fieldValue.getValueType())) { text.setText(getDateAsText(fieldValue)); } else { text.setHTML(getStringValue(fieldValue)); } if (fireEvents) { DomEvent.fireNativeEvent(Document.get().createChangeEvent(), text); } break; case PASSWORD: final PasswordTextBox passwordTextBox = (PasswordTextBox) fieldWidget; passwordTextBox.setValue(getStringValue(fieldValue), fireEvents); break; case CHECKBOX: final CheckBox checkBox = (CheckBox) fieldWidget; try { checkBox.setValue((Boolean) fieldValue.getValue(), fireEvents); } catch (final Exception e) { checkBox.setValue(false, fireEvents); Window.alert("initial value for checkbox " + widgetId + " should be a Boolean."); } break; case RADIOBUTTON_GROUP: final RadioButtonGroupWidget radioButtonGroupWidget = (RadioButtonGroupWidget) fieldWidget; radioButtonGroupWidget.setValue(getStringValue(fieldValue), fireEvents); break; case LISTBOX_SIMPLE: final ListBox listBox = (ListBox) fieldWidget; final int index = listBox.getSelectedIndex(); if (index < 0) { fireEvents = false; } else { if (listBox.getValue(index).equals(getStringValue(fieldValue))) { fireEvents = false; } } for (int i = 0; i < listBox.getItemCount(); i++) { if (listBox.getItemText(i).equals(getStringValue(fieldValue))) { listBox.setItemSelected(i, true); break; } } if (fireEvents) { DomEvent.fireNativeEvent(Document.get().createChangeEvent(), listBox); } break; case LISTBOX_MULTIPLE: final ListBox listBoxMulti = (ListBox) fieldWidget; values = getStringValues(fieldValue); boolean valueChanged = false; for (int i = 0; i < listBoxMulti.getItemCount(); i++) { if (values != null && values.contains(listBoxMulti.getItemText(i))) { if (!listBoxMulti.isItemSelected(i)) { valueChanged = true; listBoxMulti.setItemSelected(i, true); } } else { if (listBoxMulti.isItemSelected(i)) { valueChanged = true; listBoxMulti.setItemSelected(i, false); } } } if (fireEvents && valueChanged) { DomEvent.fireNativeEvent(Document.get().createChangeEvent(), listBoxMulti); } break; case SUGGESTBOX: final SuggestBox suggestBox = (SuggestBox) fieldWidget; final String stringValue = getStringValue(fieldValue); String labelValue = null; for (final Entry<String, String> suggestionEntry : suggestionsMap.entrySet()) { if (suggestionEntry.getValue() != null && suggestionEntry.getValue().equals(stringValue)) { labelValue = suggestionEntry.getKey(); } } if (labelValue != null) { suggestBox.setValue(labelValue, fireEvents); } else { suggestBox.setValue(stringValue, fireEvents); } break; case SUGGESTBOX_ASYNC: final AsyncSuggestBoxWidget formAsyncSuggestBoxWidget = (AsyncSuggestBoxWidget) fieldWidget; formAsyncSuggestBoxWidget.setValue(getStringValue(fieldValue), fireEvents); break; case CHECKBOX_GROUP: final CheckboxGroupWidget checkboxGroupWidget = (CheckboxGroupWidget) fieldWidget; values = getStringValues(fieldValue); checkboxGroupWidget.setValue(values, fireEvents); break; case DATE: final DateBox dateBox = (DateBox) fieldWidget; try { dateBox.setValue((Date) fieldValue.getValue(), fireEvents); } catch (final Exception e) { dateBox.setValue(null, fireEvents); Window.alert("initial value for date " + widgetId + " should be a Date."); } break; case DURATION: final DurationWidget durationWidget = (DurationWidget) fieldWidget; Long duration = null; try { duration = (Long) fieldValue.getValue(); } catch (final Exception e) { duration = 0L; Window.alert("The initial value for duration widget " + widgetId + " should be a Long."); } durationWidget.setValue(duration, fireEvents); break; case IMAGE: final ImageWidget image = (ImageWidget) fieldWidget; image.setValue(fieldValue.getDocumentId(), getStringValue(fieldValue), fireEvents); break; case TABLE: final TableWidget table = (TableWidget) fieldWidget; table.setValue(getTableValue(fieldValue), fireEvents); if (fireEvents) { DomEvent.fireNativeEvent(Document.get().createChangeEvent(), table); } break; case EDITABLE_GRID: final EditableGridWidget grid = (EditableGridWidget) fieldWidget; grid.setValue(getGridValue(fieldValue)); if (fireEvents) { DomEvent.fireNativeEvent(Document.get().createChangeEvent(), grid); } break; case HIDDEN: final Hidden hidden = (Hidden) fieldWidget; if (hidden.getValue() != null && hidden.getValue().equals(fieldValue.getValue()) || fieldValue.getValue() != null && fieldValue.getValue().equals(hidden.getValue())) { fireEvents = false; } hidden.setValue(getStringValue(fieldValue)); if (fireEvents) { DomEvent.fireNativeEvent(Document.get().createChangeEvent(), hidden); } break; default: Window.alert("The modification of the value of a " + widgetType + " widget is not supported."); break; } } }
From source file:org.curriki.gwt.client.widgets.metadata.MetadataEdit.java
License:Open Source License
public void addEditor(XObject obj, String name, String keyValue, Panel panel, boolean mandatory, boolean visible, boolean forceViewMode) { String divid = null;/* w ww . j a v a2 s . c om*/ String script = null; String html = null; if (obj != null) { if (doc.hasEditRight() && !forceViewMode) html = obj.getEditProperty(name); else html = obj.getViewProperty(name); } HTML htmlblock; VerticalPanel extraPanel = null; if (name.equals("fw_items") && doc.hasEditRight()) { // We need to workaround the fact the Internet Explorer does not executre Javascript // when inserted using an HTMLPanel try { String findstr1 = "<div id=\""; int i1 = html.indexOf(findstr1); int i2 = html.indexOf("\"", i1 + findstr1.length() + 1); divid = html.substring(i1 + findstr1.length(), i2); String findstr2 = "<input"; int i5 = html.indexOf(findstr2); int i6 = html.indexOf("/>", i5 + findstr2.length() + 1); String inputstr = html.substring(i5, i6 + 2); htmlblock = new HTML(inputstr); String findstr3 = "<script type=\"text/javascript\">"; int i3 = html.indexOf(findstr3); int i4 = html.indexOf("</script>", i3 + 1); script = html.substring(i3 + findstr3.length(), i4); } catch (Exception e) { html = Main.getTranslation("metadata.error_displaying_subject_field"); htmlblock = new HTML(html); } } else if (name.equals("trainedTopicsAndCompetencies") || name.equals("eduLevelFine")) { String findstr2 = "<input"; int i5 = html.indexOf(findstr2); int i6 = html.indexOf("/>", i5 + findstr2.length() + 1); html = html.substring(i5, i6 + 2); //Matcher m = Pattern.compile("<input([^>]+)>").matcher(input); String value; String propName; //="XWiki.AssetClass_0_trainedTopicsAndCompetencies"; i5 = html.indexOf("value='") + "value='".length(); i6 = html.indexOf("'", i5); //m = Pattern.compile("value *= *['\"]([^'\"]*)['\"]").matcher(input); value = html.substring(i5, i6); if ("size=".equals(value.trim())) value = ""; if (value.length() == 0) value = Main.getTranslation("metadata." + name + "_content"); //m = Pattern.compile("id *= *['\"]([^'\"]*)['\"]").matcher(input); i5 = html.indexOf("id='") + "id='".length(); i6 = html.indexOf("'", i5); propName = html.substring(i5, i6); String types = "trainedTopicsAndCompetencies".equals(name) ? "competency%2Ctopic%2CabstractTopic" : "level"; StringBuffer buff = new StringBuffer(); buff.append( //assetObj.getEditProperty("fw_items")+ " <a href=\"#\" onclick=\"return window.open" + name + "Editor();\">edit</a>\n" + " <input name=\"" + propName + "\" id=\"" + propName + "\"\n" + " type=\"hidden\" value=\"" + value + "\"></input>\n"); hookOpenSKBEditor(); htmlblock = new HTML(buff.toString()); extraPanel = new VerticalPanel(); extraPanel.setSize("15em", "5em"); displaySkills(value, extraPanel); skillsPanels.put(name, extraPanel); } else { htmlblock = new HTML(html); } VerticalPanel fieldPanel = new VerticalPanel(); fieldPanel.addStyleName("field-panel"); fieldPanel.setVisible(visible); panel.add(fieldPanel); fieldMap.put(name, fieldPanel); FlowPanel hPanel = new FlowPanel(); hPanel.addStyleName("field-panel-field"); fieldPanel.add(hPanel); if (mandatory) { HTML mandatoryHTML = new HTML("! "); mandatoryHTML.addStyleName("required_fields"); hPanel.add(mandatoryHTML); mandatoryFields.add(htmlblock); } if (keyValue != null) { String txt = Main.getTranslation("metadata." + keyValue + "_title"); if (txt.length() > 0 && !txt.equals("metadata." + keyValue + "_title")) { Label title = new HTML(txt + ":"); title.addStyleName("curriki-subtitle"); hPanel.add(title); } hPanel.add(getTooltip(name)); txt = Main.getTranslation("metadata." + keyValue + "_txt"); if (txt.length() > 0 && !txt.equals("metadata." + keyValue + "_txt")) { HTML text = new HTML(txt); text.addStyleName("curriki-txt"); fieldPanel.add(text); } txt = Main.getTranslation("metadata." + keyValue + "_content"); if (txt.equals("metadata." + keyValue + "_content")) { txt = ""; } Element el = htmlblock.getElement(); Element resEl = DOMUtils.getFirstElementByTagName(el, "input"); if (resEl != null) { String origValue = DOM.getAttribute(resEl, "value"); if (origValue == null || origValue.length() == 0) DOM.setAttribute(resEl, "value", txt); } else { resEl = DOMUtils.getFirstElementByTagName(el, "textarea"); if (resEl != null) { String origValue = DOM.getInnerText(resEl); if (origValue == null || origValue.length() == 0) DOM.setInnerText(resEl, txt); } } txt = Main.getTranslation("metadata." + keyValue + "_after"); if (txt.length() > 0 && !txt.equals("metadata." + keyValue + "_after")) { htmlblock.setHTML(htmlblock.getHTML() + txt); } } if (script != null) { SimplePanel hpanel = new SimplePanel(); fieldPanel.add(hpanel); addScript(hpanel, divid, script); } if (extraPanel != null) { fieldPanel.add(extraPanel); } if (htmlblock != null) { fieldPanel.add(htmlblock); } }
From source file:org.freemedsoftware.gwt.client.widget.InfoDialog.java
License:Open Source License
/** * Change displayed HTML content. * * @param text */ public void setContent(HTML text) { content.setHTML(text.getHTML()); }
From source file:org.geowe.client.local.main.tool.info.HtmlReportLayerTool.java
License:Open Source License
private void showDialog(final HTML htmlReport) { final Dialog simple = new Dialog(); simple.setHeadingText("GeoWe Report"); simple.setSize("420px", "420px"); simple.setResizable(true);//from w w w . j a v a 2 s . c o m simple.setHideOnButtonClick(true); simple.setPredefinedButtons(PredefinedButton.CLOSE); simple.setBodyStyleName("pad-text"); simple.getBody().addClassName("pad-text"); simple.add(getPanel(htmlReport)); simple.addButton(new TextButton(UIMessages.INSTANCE.download(), new SelectHandler() { @Override public void onSelect(SelectEvent event) { FileExporter.saveAs(htmlReport.getHTML(), getSelectedVectorLayer().getName() + ".html"); } })); simple.show(); }
From source file:org.geowe.client.local.main.tool.info.WmsGetInfoTool.java
License:Open Source License
private HTML replaceHref(final HTML html) { return new HTML(html.getHTML().replace("<a", "<a target=\"_blank\" ")); }
From source file:org.geowe.client.local.main.tool.project.InfoProjectTool.java
License:Open Source License
private void showDialog(final HTML htmlReport) { final Dialog simple = new Dialog(); simple.setHeadingText(project.getTitle()); simple.setSize("420px", "420px"); simple.setResizable(true);//from ww w .ja v a 2s . com simple.setHideOnButtonClick(true); simple.setPredefinedButtons(PredefinedButton.CLOSE); simple.setBodyStyleName("pad-text"); simple.getBody().addClassName("pad-text"); simple.add(getPanel(htmlReport)); simple.addButton(new TextButton(UIMessages.INSTANCE.download(), new SelectHandler() { @Override public void onSelect(SelectEvent event) { FileExporter.saveAs(htmlReport.getHTML(), project.getTitle() + ".html"); } })); simple.show(); }
From source file:org.sonar.plugins.core.clouds.client.widget.ClassCloudsWidget.java
License:Open Source License
private void createClouds(List<CloudElement> cloudElements, Metric colorMetric) { for (CloudElement tag : cloudElements) { HTML className = new HTML("<span style=\"font-size:" + Integer.toString(sizeCalculator.getFontSizePercent(tag.getFontSize())) + "%; color:" + colorCalculator.getFontColor(tag.getFontColor()) + "\" >" + tag.getResource().getName() + "</span>\n"); className.setStyleName("inline"); Hyperlink link = createLink(tag, colorMetric); link.setHTML(className.getHTML()); main.add(link);//from ww w . ja v a 2s .c o m } }
From source file:org.talend.mdm.webapp.browserecords.client.widget.BreadCrumb.java
License:Open Source License
public void appendBreadCrumb(String concept, String label, String ids, String pkInfo) { if (pWidget != null) { String title;/* w w w . j a v a 2 s . c o m*/ if (label != null) { if (ids != null) { title = label + " " + ids; //$NON-NLS-1$ } else { title = label; } } else { title = ids; } HTML tmph = new HTML( " > <a>" + title + "</a><input value=\"" + concept + "\"' type=\"hidden\">");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (pWidget.getWidget(pWidget.getWidgetCount() - 1).getElement().getInnerHTML() .equals(tmph.getHTML())) { return; } HTML h = initBreadCrumb(concept, label, ids, pkInfo, true, false); pWidget.add(h); } }
From source file:org.uberfire.ext.widgets.common.client.tables.popup.NewFilterPopup.java
License:Apache License
public void init() { horizontalForm.clear();/* w w w . j a va 2s . co m*/ filterControlGroups.clear(); FormGroup controlGroup = new FormGroup(); FormLabel controlLabel = new FormLabel(); controlLabel.setTitle(CommonConstants.INSTANCE.Filter_Name()); HTML lab = new HTML("<span style=\"color:red\"> * </span>" + "<span style=\"margin-right:10px\">" + CommonConstants.INSTANCE.Filter_Name() + "</span>"); controlLabel.setHTML(lab.getHTML()); TextBox fieldTextBox = new TextBox(); fieldTextBox.setName(FILTER_NAME_PARAM); controlGroup.add(controlLabel); controlGroup.add(fieldTextBox); filterControlGroups.add(controlGroup); horizontalForm.add(controlGroup); existingFiltersPanel.clear(); existingFiltersPanel.add(existingFiltersGrid); existingFiltersGrid.loadPageSizePreferences(); existingFiltersGrid.setColumnPickerButtonVisible(false); existingFiltersGrid.setEmptyTableCaption(CommonConstants.INSTANCE.NoCustomFilterAvailable()); }