List of usage examples for com.google.gwt.user.client.ui HasValue setValue
void setValue(T value);
From source file:com.google.api.explorer.client.parameter.schema.FieldsEditor.java
License:Apache License
/** * Sets this field's checked value, and all of its childrens' if it has any. */// w w w .ja v a 2 s .c om @Override public void setValue(Boolean value) { for (HasValue<Boolean> hasValue : children.values()) { hasValue.setValue(value); } this.root.setValue(value); }
From source file:com.square.composant.tarificateur.square.client.presenter.devis.DevisPresenter.java
License:Open Source License
/** * Affiche les evenements sur une ligne de devis. * @param ligneDevisView ligneDevisView/*from w w w.j ava 2s . co m*/ * @param ligne ligne * @param idLignePrincipale idLignePrincipale * @param ligneLiee ligneLiee */ private void ajouterEvenementsLigne(final LigneDevisView ligneDevisView, final LigneDevisModel ligne, final Long idLignePrincipale, final boolean ligneLiee) { // on rcupre le critre optionnel ou pas du produit boolean isProduitOptionnel = true; if (ligneLiee && ligne.getProduitOptionnel() != null) { isProduitOptionnel = ligne.getProduitOptionnel().booleanValue(); } final HasValue<Boolean> cbLigne = ligneDevisView.getMapCbImprimerLigne().get(ligne.getIdentifiant()); if (ligneLiee && isProduitOptionnel) { cbLigne.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { final HasValue<Boolean> cbPrincipale = ligneDevisView.getMapCbImprimerLigne() .get(idLignePrincipale); if (event.getValue() && !cbPrincipale.getValue() && compteurLignePrincSelectionne == 2) { cbLigne.setValue(false); ligneDevisView.afficherPopupErreurSelectionImpression(); view.activerBtnImprimerDevis(false); view.activerBtnEnvoiEmailDevis(false); } else if (event.getValue() && !cbPrincipale.getValue()) { compteurLignePrincSelectionne++; cbPrincipale.setValue(true); view.activerBtnImprimerDevis(true); view.activerBtnEnvoiEmailDevis(true); } repercuteModifsLignesLiees(ligneDevisView, ligne); } }); } else if (!ligneLiee) { cbLigne.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue() && compteurLignePrincSelectionne == 2) { cbLigne.setValue(false); ligneDevisView.afficherPopupErreurSelectionImpression(); } else if (event.getValue()) { compteurLignePrincSelectionne++; view.activerBtnImprimerDevis(true); view.activerBtnEnvoiEmailDevis(true); } else if (!event.getValue()) { compteurLignePrincSelectionne--; if (compteurLignePrincSelectionne == 0) { view.activerBtnImprimerDevis(false); view.activerBtnEnvoiEmailDevis(false); } } repercuteModifsLignesLiees(ligneDevisView, ligne); } }); } }
From source file:gwt.material.design.client.ui.MaterialCollectionItem.java
License:Apache License
public void setType(CollectionType type) { switch (type) { case AVATAR:/* w w w . java2 s . co m*/ addStyleName(type.getCssName()); break; case CHECKBOX: if (getWidgetCount() > 0) { getWidget(0).getElement().getStyle().setProperty("display", "inline"); } if (handlerReg != null) { handlerReg.removeHandler(); } handlerReg = addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { for (Widget w : MaterialCollectionItem.this) { if (w instanceof MaterialCollectionSecondary) { for (Widget a : (MaterialCollectionSecondary) w) { if (a instanceof HasValue) { try { @SuppressWarnings("unchecked") HasValue<Boolean> cb = (HasValue<Boolean>) a; if (cb.getValue()) { cb.setValue(false); } else { cb.setValue(true); } } catch (ClassCastException ex) { // Ignore non-boolean has value handlers. } } } } } } }); break; default: break; } }
From source file:org.cruxframework.crux.widgets.client.grid.Row.java
License:Apache License
@SuppressWarnings("unchecked") public void setSelected(boolean selected) { if (hasSelectionCell) { HasValue<Boolean> selector = (HasValue<Boolean>) getCell(0).getCellWidget(); selector.setValue(selected); }/*from w ww. j a va 2s . c o m*/ if (selected) { addStyleDependentName("selected"); } else { removeStyleDependentName("selected"); } this.selected = selected; }
From source file:org.jboss.errai.databinding.client.BindableProxyAgent.java
License:Apache License
/** * Updates all bound widgets and fires the corresponding {@link PropertyChangeEvent}. * /*from w ww . jav a2 s.c o m*/ * @param <P> * The property type of the changed property. * @param property * The name of the property that changed. * @param oldValue * The old value of the property. * @param newValue * The new value of the property. * @param excluding * A widget reference that does not need to be updated (the origin of the value change * event). */ private <P> void updateWidgetsAndFireEvent(final String property, final P oldValue, final P newValue, final Widget excluding) { for (Binding binding : bindings.get(property)) { Widget widget = binding.getWidget(); Converter converter = binding.getConverter(); if (widget == excluding) continue; if (widget instanceof HasValue) { HasValue hv = (HasValue) widget; Object widgetValue = Convert.toWidgetValue(widget, propertyTypes.get(property).getType(), newValue, converter); hv.setValue(widgetValue); } else if (widget instanceof HasText) { HasText ht = (HasText) widget; Object widgetValue = Convert.toWidgetValue(String.class, propertyTypes.get(property).getType(), newValue, converter); ht.setText((String) widgetValue); } } firePropertyChangeEvent(property, oldValue, newValue); }
From source file:org.kuali.student.common.ui.client.configurable.mvc.binding.HasValueBinding.java
License:Educational Community License
@Override public void setWidgetValue(HasValue object, DataModel model, String path) { QueryPath qPath = QueryPath.parse(path); Object value = model.get(qPath); if (value != null && object != null) { object.setValue(value); } else if (object != null) { try {/*from w ww . java 2 s . c o m*/ if (object instanceof KSCheckBox) { object.setValue(false); } else { object.setValue(""); } } catch (RuntimeException e) { GWT.log("Warning: Ignoring error attempting to setValue for " + object.getClass().getName(), e); } } }
From source file:org.nuxeo.opensocial.container.client.presenter.PreferencesPresenter.java
License:Open Source License
private void addUserPref(UserPref pref) { String value = pref.getActualValue(); if (value == null) { value = pref.getDefaultValue();//w w w . ja va 2 s . c o m } switch (pref.getDataType()) { case STRING: // TODO Work only for PictureBook ! Has to be improved for any type // of document if (pref.getName().startsWith("NXID_")) { final NXIDTextBox idBox = display.addNXIDUserPref(pref.getName(), pref.getDisplayName()); if (value != null && !("").equals(value)) { NXIDPreference evaluatedNXIDPref = evaluateNXIDPref(value); idBox.setValue(evaluatedNXIDPref.getNXName()); idBox.setHiddenValue(evaluatedNXIDPref.getNXId()); } idBox.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { FolderPickerModel folderPickerModel = new FolderPickerModel(data.getId(), idBox.getHiddenValue()); FolderPickerWidget folderPickerWidget = new FolderPickerWidget(); FolderPickerPresenter folderPicker = new FolderPickerPresenter(folderPickerWidget, eventBus, folderPickerModel); folderPicker.bind(); folderPicker.getDisplay().showPicker(); } }); prefsValues.add((Widget) idBox); eventBus.addHandler(FolderChosenEvent.TYPE, new FolderChosenEventHandler() { public void onFolderChosen(FolderChosenEvent event) { idBox.setValue(event.getFolderName()); idBox.setHiddenValue(event.getFolderId()); } }); } else { HasValue<String> text = display.addStringUserPref(pref.getName(), pref.getDisplayName()); text.setValue(value); prefsValues.add((Widget) text); } break; case BOOL: HasValue<Boolean> bool = display.addBooleanUserPref(pref.getName(), pref.getDisplayName()); bool.setValue(Boolean.parseBoolean(value)); prefsValues.add((Widget) bool); break; case ENUM: if (pref.getName().startsWith("COLOR_")) { HasValue<String> color = display.addColorsUserPref(pref.getName(), pref.getDisplayName()); color.setValue(value); prefsValues.add((Widget) color); } else { HasMultipleValue<String> list = display.addEnumUserPref(pref.getName(), pref.getDisplayName()); // Populate the list with the enum values for (Entry<String, String> enumValues : pref.getEnumValues().entrySet()) { list.addValue(enumValues.getKey(), enumValues.getValue()); // Select the actual value. If null, select the default // value if (value.equals(enumValues.getValue())) { list.setItemSelected(list.getItemCount() - 1); } } prefsValues.add((Widget) list); } break; } }
From source file:org.obiba.opal.web.gwt.app.client.validator.RequiredTextValidator.java
License:Open Source License
public RequiredTextValidator(final HasValue<String> hasValue, String errorMessageKey) { this(new HasText() { @Override//from w w w .j ava 2s .c o m public String getText() { return hasValue.getValue(); } @Override public void setText(String text) { hasValue.setValue(text); } }, errorMessageKey); }
From source file:org.rstudio.studio.client.workbench.views.source.editors.text.findreplace.FindReplace.java
License:Open Source License
public FindReplace(AceEditor editor, Display display, GlobalDisplay globalDisplay, boolean showingReplace) { editor_ = editor;//from w w w. j av a 2 s. c o m display_ = display; globalDisplay_ = globalDisplay; errorCaption_ = showingReplace ? "Find/Replace" : "Find"; HasValue<Boolean> caseSensitive = display_.getCaseSensitive(); caseSensitive.setValue(defaultCaseSensitive_); caseSensitive.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { defaultCaseSensitive_ = event.getValue(); } }); HasValue<Boolean> wholeWord = display_.getWholeWord(); wholeWord.setValue(defaultWholeWord_); wholeWord.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { defaultWholeWord_ = event.getValue(); } }); HasValue<Boolean> regex = display_.getRegex(); regex.setValue(defaultRegex_); regex.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { defaultRegex_ = event.getValue(); } }); HasValue<Boolean> wrapSearch = display_.getWrapSearch(); wrapSearch.setValue(defaultWrapSearch_); wrapSearch.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { defaultWrapSearch_ = event.getValue(); } }); HasValue<Boolean> inSelection = display_.getInSelection(); inSelection.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { resetTargetSelection(); display_.focusFindField(true); } else clearTargetSelection(); } }); addClickHandler(display.getReplaceAll(), new ClickHandler() { public void onClick(ClickEvent event) { replaceAll(); } }); display_.addFindKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { // bail on navigational keys if (event.getNativeKeyCode() == KeyCodes.KEY_TAB || event.getNativeKeyCode() == KeyCodes.KEY_ENTER || event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE || event.getNativeKeyCode() == KeyCodes.KEY_HOME || event.getNativeKeyCode() == KeyCodes.KEY_END || event.getNativeKeyCode() == KeyCodes.KEY_RIGHT || event.getNativeKeyCode() == KeyCodes.KEY_LEFT) { return; } // bail on control characters if (event.getNativeKeyCode() < 32) return; // perform incremental search find(defaultForward_ ? FindType.Forward : FindType.Reverse, true); } }); }
From source file:org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget.java
License:Open Source License
private void withChooseEncoding(final String defaultEncoding, final CommandWithArg<String> command) { view_.ensureVisible();//from ww w . ja v a 2 s. c o m ; server_.iconvlist(new SimpleRequestCallback<IconvListResult>() { @Override public void onResponseReceived(IconvListResult response) { // Stupid compiler. Use this Value shim to make the dialog available // in its own handler. final HasValue<ChooseEncodingDialog> d = new Value<ChooseEncodingDialog>(null); d.setValue(new ChooseEncodingDialog(response.getCommon(), response.getAll(), defaultEncoding, false, true, new OperationWithInput<String>() { public void execute(String newEncoding) { if (newEncoding == null) return; if (d.getValue().isSaveAsDefault()) { prefs_.defaultEncoding().setGlobalValue(newEncoding); prefs_.writeUIPrefs(); } command.execute(newEncoding); } })); d.getValue().showModal(); } }); }