List of usage examples for com.google.gwt.user.client.ui CheckBox setHTML
@Override public void setHTML(@IsSafeHtml String html)
From source file:com.google.api.explorer.client.auth.AuthView.java
License:Apache License
/** * Rebuild the popup from scratch with all of the scopes that we have from the last time we were * presented.//from w w w . ja va2 s. c o m */ private void buildScopePopup() { scopePanel.clear(); additionalScopePanel.clear(); Set<TextBox> oldEditors = Sets.newLinkedHashSet(freeFormEditors); freeFormEditors.clear(); // Hide the service scopes label if there aren't any. hasScopesText.setVisible(!scopesFromDiscovery.isEmpty()); noScopesText.setVisible(scopesFromDiscovery.isEmpty()); // Show different text on the free-form scopes section when there are discovery scopes. optionalAdditionalScopes.setVisible(!scopesFromDiscovery.isEmpty()); for (final Map.Entry<String, AuthScope> scope : scopesFromDiscovery.entrySet()) { // Add the check box to the table. CheckBox scopeToggle = new CheckBox(); SafeHtmlBuilder safeHtml = new SafeHtmlBuilder(); safeHtml.appendEscaped(scope.getKey()).appendHtmlConstant("<br><span>") .appendEscaped(scope.getValue().getDescription()).appendHtmlConstant("</span>"); scopeToggle.setHTML(safeHtml.toSafeHtml()); scopeToggle.addStyleName(style.discoveryScopeSelector()); scopePanel.add(scopeToggle); // When the box is checked, add our scope to the selected list. scopeToggle.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { CheckBox checkBox = (CheckBox) event.getSource(); if (checkBox.getValue()) { selectedScopes.add(scope.getKey()); } else { selectedScopes.remove(scope.getKey()); } } }); // Enable the check box if the scope is selected. scopeToggle.setValue(selectedScopes.contains(scope.getKey())); } // Process any scopes that are extra. for (TextBox editor : oldEditors) { if (!editor.getValue().trim().isEmpty()) { addFreeFormEditorRow(editor.getValue(), true); } } // There should always be one empty editor. addFreeFormEditorRow("", false); }
From source file:com.vaadin.client.ui.VOptionGroup.java
License:Apache License
@Override public void buildOptions(UIDL uidl) { /*/*from w ww. ja va 2 s. c o m*/ * In order to retain focus, we need to update values rather than * recreate panel from scratch (#10451). However, the panel will be * rebuilt (losing focus) if number of elements or their order is * changed. */ HashMap<String, CheckBox> keysToOptions = new HashMap<String, CheckBox>(); for (Map.Entry<CheckBox, String> entry : optionsToKeys.entrySet()) { keysToOptions.put(entry.getValue(), entry.getKey()); } ArrayList<Widget> existingwidgets = new ArrayList<Widget>(); ArrayList<Widget> newwidgets = new ArrayList<Widget>(); // Get current order of elements for (Widget wid : panel) { existingwidgets.add(wid); } optionsEnabled.clear(); if (isMultiselect()) { Roles.getGroupRole().set(getElement()); } else { Roles.getRadiogroupRole().set(getElement()); } for (final Iterator<?> it = uidl.getChildIterator(); it.hasNext();) { final UIDL opUidl = (UIDL) it.next(); String itemHtml = opUidl.getStringAttribute("caption"); if (!htmlContentAllowed) { itemHtml = WidgetUtil.escapeHTML(itemHtml); } String iconUrl = opUidl.getStringAttribute("icon"); if (iconUrl != null && iconUrl.length() != 0) { Icon icon = client.getIcon(iconUrl); itemHtml = icon.getElement().getString() + itemHtml; } String key = opUidl.getStringAttribute("key"); CheckBox op = keysToOptions.get(key); // Need to recreate object if isMultiselect is changed (#10451) // OR if htmlContentAllowed changed due to Safari 5 issue if ((op == null) || (htmlContentAllowed != wasHtmlContentAllowed) || (isMultiselect() != wasMultiselect)) { // Create a new element if (isMultiselect()) { op = new VCheckBox(); } else { op = new RadioButton(paintableId); op.setStyleName("v-radiobutton"); } if (iconUrl != null && iconUrl.length() != 0) { WidgetUtil.sinkOnloadForImages(op.getElement()); op.addHandler(iconLoadHandler, LoadEvent.getType()); } op.addStyleName(CLASSNAME_OPTION); op.addClickHandler(this); optionsToKeys.put(op, key); } op.setHTML(itemHtml); op.setValue(opUidl.getBooleanAttribute("selected")); boolean optionEnabled = !opUidl.getBooleanAttribute(OptionGroupConstants.ATTRIBUTE_OPTION_DISABLED); boolean enabled = optionEnabled && !isReadonly() && isEnabled(); op.setEnabled(enabled); optionsEnabled.put(op, optionEnabled); setStyleName(op.getElement(), StyleConstants.DISABLED, !(optionEnabled && isEnabled())); newwidgets.add(op); } if (!newwidgets.equals(existingwidgets)) { // Rebuild the panel, losing focus panel.clear(); for (Widget wid : newwidgets) { panel.add(wid); } } wasHtmlContentAllowed = htmlContentAllowed; wasMultiselect = isMultiselect(); }
From source file:com.vaadin.terminal.gwt.client.ui.VOptionGroup.java
License:Open Source License
@Override protected void buildOptions(UIDL uidl) { panel.clear();/*from w ww . j a v a 2 s .co m*/ for (final Iterator<?> it = uidl.getChildIterator(); it.hasNext();) { final UIDL opUidl = (UIDL) it.next(); CheckBox op; String itemHtml = opUidl.getStringAttribute("caption"); if (!htmlContentAllowed) { itemHtml = Util.escapeHTML(itemHtml); } String icon = opUidl.getStringAttribute("icon"); if (icon != null && icon.length() != 0) { String iconUrl = client.translateVaadinUri(icon); itemHtml = "<img src=\"" + iconUrl + "\" class=\"" + Icon.CLASSNAME + "\" alt=\"\" />" + itemHtml; } if (isMultiselect()) { op = new VCheckBox(); op.setHTML(itemHtml); } else { op = new RadioButton(id, itemHtml, true); op.setStyleName("v-radiobutton"); } if (icon != null && icon.length() != 0) { Util.sinkOnloadForImages(op.getElement()); op.addHandler(iconLoadHandler, LoadEvent.getType()); } op.addStyleName(CLASSNAME_OPTION); op.setValue(opUidl.getBooleanAttribute("selected")); boolean enabled = !opUidl.getBooleanAttribute("disabled") && !isReadonly() && !isDisabled(); op.setEnabled(enabled); setStyleName(op.getElement(), ApplicationConnection.DISABLED_CLASSNAME, !enabled); op.addClickHandler(this); optionsToKeys.put(op, opUidl.getStringAttribute("key")); panel.add(op); } }
From source file:com.vaadin.v7.client.ui.VOptionGroup.java
License:Apache License
@Override public void buildOptions(UIDL uidl) { /*/*from w w w .j a v a 2s . com*/ * In order to retain focus, we need to update values rather than * recreate panel from scratch (#10451). However, the panel will be * rebuilt (losing focus) if number of elements or their order is * changed. */ HashMap<String, CheckBox> keysToOptions = new HashMap<>(); for (Map.Entry<CheckBox, String> entry : optionsToKeys.entrySet()) { keysToOptions.put(entry.getValue(), entry.getKey()); } ArrayList<Widget> existingwidgets = new ArrayList<>(); ArrayList<Widget> newwidgets = new ArrayList<>(); // Get current order of elements for (Widget wid : panel) { existingwidgets.add(wid); } optionsEnabled.clear(); if (isMultiselect()) { Roles.getGroupRole().set(getElement()); } else { Roles.getRadiogroupRole().set(getElement()); } for (final Iterator<?> it = uidl.getChildIterator(); it.hasNext();) { final UIDL opUidl = (UIDL) it.next(); String itemHtml = opUidl.getStringAttribute("caption"); if (!isHtmlContentAllowed()) { itemHtml = WidgetUtil.escapeHTML(itemHtml); } String iconUrl = opUidl.getStringAttribute("icon"); if (iconUrl != null && iconUrl.length() != 0) { Icon icon = client.getIcon(iconUrl); itemHtml = icon.getElement().getString() + itemHtml; } String key = opUidl.getStringAttribute("key"); CheckBox op = keysToOptions.get(key); // Need to recreate object if isMultiselect is changed (#10451) // OR if htmlContentAllowed changed due to Safari 5 issue if ((op == null) || (isHtmlContentAllowed() != wasHtmlContentAllowed) || (isMultiselect() != wasMultiselect)) { // Create a new element if (isMultiselect()) { op = new VCheckBox(); } else { op = new RadioButton(paintableId); op.setStyleName("v-radiobutton"); } if (iconUrl != null && iconUrl.length() != 0) { WidgetUtil.sinkOnloadForImages(op.getElement()); op.addHandler(iconLoadHandler, LoadEvent.getType()); } op.addStyleName(CLASSNAME_OPTION); op.addClickHandler(this); optionsToKeys.put(op, key); } op.setHTML(itemHtml); op.setValue(opUidl.getBooleanAttribute("selected")); boolean optionEnabled = !opUidl.getBooleanAttribute(OptionGroupConstants.ATTRIBUTE_OPTION_DISABLED); boolean enabled = optionEnabled && !isReadonly() && isEnabled(); op.setEnabled(enabled); optionsEnabled.put(op, optionEnabled); setStyleName(op.getElement(), StyleConstants.DISABLED, !(optionEnabled && isEnabled())); newwidgets.add(op); } if (!newwidgets.equals(existingwidgets)) { // Rebuild the panel, losing focus panel.clear(); for (Widget wid : newwidgets) { panel.add(wid); } } wasHtmlContentAllowed = isHtmlContentAllowed(); wasMultiselect = isMultiselect(); }
From source file:com.xpn.xwiki.watch.client.ui.filterbar.StateSelectorsWidget.java
License:Open Source License
private Widget getCheckBoxPanel(CheckBox checkBox, String name, boolean checked, ClickListener clickListener) { FlowPanel p = new FlowPanel(); p.setStyleName(watch.getStyleName("filter", "seeonly-" + name)); if (checked)/*from w w w .j a v a 2s.c om*/ checkBox.setChecked(true); checkBox.setHTML(watch.getTranslation("filter.seeonly." + name)); checkBox.addClickListener(clickListener); p.add(checkBox); return p; }
From source file:edu.caltech.ipac.firefly.ui.GwtUtil.java
public static CheckBox makeCheckBox(String text, String tip, boolean selected, boolean forceNowrap) { CheckBox cb = new CheckBox(); cb.addStyleName("gwtutil-checkbox"); cb.setValue(selected);/* ww w. j a v a 2 s. c o m*/ cb.setHTML(text); cb.setTitle(tip); if (forceNowrap) { setStyle(cb, "whiteSpace", "nowrap"); } return cb; }
From source file:edu.caltech.ipac.firefly.visualize.ui.WebLayerControlPopup.java
private void addLayer(final WebLayerItem item) { if (lastBottomWidget != null) { GwtUtil.setStyles(lastBottomWidget, "borderBottom", "1px solid rgba(0,0,0,.3)", "marginBottom", "7px"); }/*from w w w .ja va 2 s. c om*/ int activeRow = _layerTable.getRowCount(); _panel.showWidget(LAYERS); String name = _prop.getName("on") + " " + item.getTitle(); String tip = _prop.getTip("on") + " " + item.getTitle(); final CheckBox cb = GwtUtil.makeCheckBox(name, tip, true); DOM.setStyleAttribute(cb.getElement(), "paddingRight", "15px"); cb.setValue(item.isVisible()); cb.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> ev) { item.setVisible(cb.getValue()); } }); item.addValueChangeHandler(new ValueChangeHandler<String>() { public void onValueChange(ValueChangeEvent<String> ev) { cb.setHTML(_prop.getName("on") + " " + item.getTitle()); } }); item.getPlotView().addListener(Name.LAYER_ITEM_VISIBLE, new WebEventListener() { public void eventNotify(WebEvent ev) { if (ev.getSource() == item) { boolean v = (Boolean) ev.getData(); if (v != cb.getValue()) cb.setValue(v); } } }); Label colorFeedback = new Label(); _layerTable.setWidget(activeRow, ON_COL, cb); if (item.getHasColorSetting()) { _layerTable.setWidget(activeRow, COLOR_FEEDBACK, colorFeedback); _layerTable.setWidget(activeRow, COLOR_COL, makeChangeColorLink(colorFeedback, item)); } Widget userDefined = item.makeUserDefinedColUI(); if (userDefined != null) { _layerTable.setWidget(activeRow, USER_DEFINED_COL, userDefined); } if (item.getHasDelete()) { // int column= item.getHasColorSetting() ? DELETE_COL : COLOR_COL; _layerTable.setWidget(activeRow, DELETE_COL, makeDeleteLink(item)); } if (item.getHasDetails()) { _layerTable.setWidget(activeRow, DETAILS_COL, makeDetailsLink(item)); } // _layerTable.setWidget(rowCnt,HELP_COL,makeHelpLink(item)); activeRow++; Widget extra = item.makeExtraUI(); if (extra != null) { SimplePanel panel = new SimplePanel(); panel.setWidget(extra); DOM.setStyleAttribute(panel.getElement(), "padding", "0 0 0 25px"); _layerTable.setWidget(activeRow, 0, panel); _layerTable.getFlexCellFormatter().setColSpan(activeRow, 0, 4); activeRow++; } if (item.isUsingSubgroups()) { SimplePanel panel = new SimplePanel(); DOM.setStyleAttribute(panel.getElement(), "padding", "0 0 0 25px"); _layerTable.setWidget(activeRow, 0, panel); SimpleInputField field = GwtUtil.createRadioBox("Overlay", sgOps, getCheckBoxValue(item.getSubgroupVisibility()), true); panel.setWidget(field); _layerTable.getFlexCellFormatter().setColSpan(activeRow, 0, 4); activeRow++; field.getField().addValueChangeHandler(new ValueChangeHandler<String>() { public void onValueChange(ValueChangeEvent<String> ev) { item.setVisible(getLevel(ev.getValue())); } }); } String helpStr = item.getHelp(); if (helpStr == null) helpStr = ""; // Label help= new Label(); HTML help = new HTML(); help.setHTML(helpStr); DOM.setStyleAttribute(help.getElement(), "padding", "2px 0 2px 25px"); DOM.setStyleAttribute(help.getElement(), "fontSize", "90%"); help.addStyleName(_ffCss.fadedText()); _layerTable.setWidget(activeRow, 0, help); _layerTable.getFlexCellFormatter().setColSpan(activeRow, 0, 3); lastBottomWidget = help; _layerMap.put(cb, item); }
From source file:org.restlet.example.book.restlet.ch09.client.Tasks_BinderImpl.java
License:Open Source License
public com.google.gwt.user.client.ui.Widget createAndBindUi( final org.restlet.example.book.restlet.ch09.client.Tasks owner) { org.restlet.example.book.restlet.ch09.client.Tasks_BinderImpl_GenBundle clientBundleFieldNameUnlikelyToCollideWithUserSpecifiedFieldOkay = (org.restlet.example.book.restlet.ch09.client.Tasks_BinderImpl_GenBundle) GWT .create(org.restlet.example.book.restlet.ch09.client.Tasks_BinderImpl_GenBundle.class); org.restlet.example.book.restlet.ch09.client.Tasks_BinderImpl_GenCss_style style = clientBundleFieldNameUnlikelyToCollideWithUserSpecifiedFieldOkay .style();/*from www . j a va2s .c om*/ com.google.gwt.user.client.ui.CheckBox f_CheckBox2 = (com.google.gwt.user.client.ui.CheckBox) GWT .create(com.google.gwt.user.client.ui.CheckBox.class); com.google.gwt.user.client.ui.CheckBox f_CheckBox3 = (com.google.gwt.user.client.ui.CheckBox) GWT .create(com.google.gwt.user.client.ui.CheckBox.class); com.google.gwt.user.client.ui.CheckBox f_CheckBox4 = (com.google.gwt.user.client.ui.CheckBox) GWT .create(com.google.gwt.user.client.ui.CheckBox.class); com.google.gwt.user.client.ui.CheckBox f_CheckBox5 = (com.google.gwt.user.client.ui.CheckBox) GWT .create(com.google.gwt.user.client.ui.CheckBox.class); com.google.gwt.user.client.ui.CheckBox f_CheckBox6 = (com.google.gwt.user.client.ui.CheckBox) GWT .create(com.google.gwt.user.client.ui.CheckBox.class); com.google.gwt.user.client.ui.CheckBox f_CheckBox7 = (com.google.gwt.user.client.ui.CheckBox) GWT .create(com.google.gwt.user.client.ui.CheckBox.class); com.google.gwt.user.client.ui.FlowPanel f_FlowPanel1 = (com.google.gwt.user.client.ui.FlowPanel) GWT .create(com.google.gwt.user.client.ui.FlowPanel.class); f_CheckBox2.setHTML(template.html1().asString()); f_CheckBox2.setStyleName("" + style.item() + ""); f_FlowPanel1.add(f_CheckBox2); f_CheckBox3.setHTML(template.html2().asString()); f_CheckBox3.setStyleName("" + style.item() + ""); f_FlowPanel1.add(f_CheckBox3); f_CheckBox4.setHTML(template.html3().asString()); f_CheckBox4.setStyleName("" + style.item() + ""); f_FlowPanel1.add(f_CheckBox4); f_CheckBox5.setHTML(template.html4().asString()); f_CheckBox5.setStyleName("" + style.item() + ""); f_FlowPanel1.add(f_CheckBox5); f_CheckBox6.setHTML(template.html5().asString()); f_CheckBox6.setStyleName("" + style.item() + ""); f_FlowPanel1.add(f_CheckBox6); f_CheckBox7.setHTML(template.html6().asString()); f_CheckBox7.setStyleName("" + style.item() + ""); f_FlowPanel1.add(f_CheckBox7); f_FlowPanel1.setStyleName("" + style.tasks() + ""); clientBundleFieldNameUnlikelyToCollideWithUserSpecifiedFieldOkay.style().ensureInjected(); return f_FlowPanel1; }