List of usage examples for com.google.gwt.user.client.ui CheckBox setValue
@Override public void setValue(Boolean value)
From source file:com.square.composant.fusion.square.client.composants.BlocChampsPersonneFusion.java
License:Open Source License
/** * Change la slection des champs pour la fusion (tous ou aucun). * @param isSelectionne true si tous les champs doivent tre slectionns, false si aucun. *///from w w w . j ava 2 s .c om public void modifierSelectionFusion(boolean isSelectionne) { // Mise jour champs slectionns if (personneSourceEnCours.getNro().getDifferent() != null && personneSourceEnCours.getNro().getDifferent()) { personneSourceEnCours.getNro().setAFusionner(isSelectionne); } if (personneSourceEnCours.getCivilite().getDifferent() != null && personneSourceEnCours.getCivilite().getDifferent()) { personneSourceEnCours.getCivilite().setAFusionner(isSelectionne); } if (personneSourceEnCours.getNom().getDifferent() != null && personneSourceEnCours.getNom().getDifferent()) { personneSourceEnCours.getNom().setAFusionner(isSelectionne); } if (personneSourceEnCours.getNomJeuneFille().getDifferent() != null && personneSourceEnCours.getNomJeuneFille().getDifferent()) { personneSourceEnCours.getNomJeuneFille().setAFusionner(isSelectionne); } if (personneSourceEnCours.getPrenom().getDifferent() != null && personneSourceEnCours.getPrenom().getDifferent()) { personneSourceEnCours.getPrenom().setAFusionner(isSelectionne); } if (personneSourceEnCours.getDateNaissance().getDifferent() != null && personneSourceEnCours.getDateNaissance().getDifferent()) { personneSourceEnCours.getDateNaissance().setAFusionner(isSelectionne); } if (personneSourceEnCours.getDateDeces().getDifferent() != null && personneSourceEnCours.getDateDeces().getDifferent()) { personneSourceEnCours.getDateDeces().setAFusionner(isSelectionne); } if (personneSourceEnCours.getDecede().getDifferent() != null && personneSourceEnCours.getDecede().getDifferent()) { personneSourceEnCours.getDecede().setAFusionner(isSelectionne); } if (personneSourceEnCours.getSitFam().getDifferent() != null && personneSourceEnCours.getSitFam().getDifferent()) { personneSourceEnCours.getSitFam().setAFusionner(isSelectionne); } if (personneSourceEnCours.getProfession().getDifferent() != null && personneSourceEnCours.getProfession().getDifferent()) { personneSourceEnCours.getProfession().setAFusionner(isSelectionne); } if (personneSourceEnCours.getNaturePersonne().getDifferent() != null && personneSourceEnCours.getNaturePersonne().getDifferent() && personneSourceEnCours.getNaturePersonne().getIsSelectionnable() != null && personneSourceEnCours.getNaturePersonne().getIsSelectionnable()) { personneSourceEnCours.getNaturePersonne().setAFusionner(isSelectionne); } if (personneSourceEnCours.getStatut().getDifferent() && personneSourceEnCours.getStatut().getDifferent()) { personneSourceEnCours.getStatut().setAFusionner(isSelectionne); } if (personneSourceEnCours.getCaisse().getDifferent() != null && personneSourceEnCours.getCaisse().getDifferent()) { personneSourceEnCours.getCaisse().setAFusionner(isSelectionne); } if (personneSourceEnCours.getCaisseRegime().getDifferent() != null && personneSourceEnCours.getCaisseRegime().getDifferent()) { personneSourceEnCours.getCaisseRegime().setAFusionner(isSelectionne); } if (personneSourceEnCours.getCsp().getDifferent() != null && personneSourceEnCours.getCsp().getDifferent()) { personneSourceEnCours.getCsp().setAFusionner(isSelectionne); } if (personneSourceEnCours.getSegment().getDifferent() != null && personneSourceEnCours.getSegment().getDifferent()) { personneSourceEnCours.getSegment().setAFusionner(isSelectionne); } if (personneSourceEnCours.getReseauVente().getDifferent() != null && personneSourceEnCours.getReseauVente().getDifferent()) { personneSourceEnCours.getReseauVente().setAFusionner(isSelectionne); } if (personneSourceEnCours.getCommercial().getDifferent() != null && personneSourceEnCours.getCommercial().getDifferent()) { personneSourceEnCours.getCommercial().setAFusionner(isSelectionne); } if (personneSourceEnCours.getAgence().getDifferent() != null && personneSourceEnCours.getAgence().getDifferent()) { personneSourceEnCours.getAgence().setAFusionner(isSelectionne); } if (personneSourceEnCours.getAdressePrincipale().getDifferent() != null && personneSourceEnCours.getAdressePrincipale().getDifferent()) { personneSourceEnCours.getAdressePrincipale().setAFusionner(isSelectionne); } if (personneSourceEnCours.getListeTelephones() != null && !"".equals(personneSourceEnCours.getListeTelephones().size() > 0)) { for (ProprieteFusionnableTelephoneModel telephone : personneSourceEnCours.getListeTelephones()) { if (telephone.getDifferent() != null && telephone.getDifferent()) { telephone.setAFusionner(isSelectionne); } } } if (personneSourceEnCours.getListeEmails() != null && !"".equals(personneSourceEnCours.getListeEmails().size() > 0)) { for (ProprieteFusionnableEmailModel email : personneSourceEnCours.getListeEmails()) { if (email.getDifferent()) { email.setAFusionner(isSelectionne); } } } // Mise jour des CheckBox correspondantes for (int i = 1; i < ftProprietes.getRowCount(); i++) { if (ftProprietes.getWidget(i, 2) != null) { final CheckBox cb = (CheckBox) ftProprietes.getWidget(i, 2); cb.setValue(isSelectionne); } } // Mise jour du texte sur le bouton de slection if (isSelectionne) { btnSelection.setText(composantConstants.btnRienSelectionner()); } else { btnSelection.setText(composantConstants.btnToutSelectionner()); } }
From source file:com.square.composant.fusion.square.client.view.selection.doublon.SelectionDoublonViewImpl.java
License:Open Source License
/** Construit le tableau de slection de doublons. */ private void construireTableauSelectionDoublon() { remotePagingTableDoublons = new RemotePagingTable<RechercheDoublonResultatModel, RechercheDoublonCritereModel>( SelectionDoublonViewImplConstants.NB_ELEMENT_PAR_PAGE, true) { @Override/* www . j av a 2 s .c om*/ public void setDataProvider(RemotePagingCriteriasGwt<RechercheDoublonCritereModel> params, AsyncCallback<RemotePagingResultsGwt<RechercheDoublonResultatModel>> callback) { remotePagingHandlerManager.fireEvent( new SetDataProviderEvent<RechercheDoublonCritereModel, RechercheDoublonResultatModel>( params, callback)); } @Override public int setDefaultSortAsc() { return RemotePagingSortGwt.REMOTE_PAGING_SORT_ASC; } @Override public String setDefaultSortField() { return constantes.getProprietePersonneNom(); } @Override public Column[] setHeader() { return new Column[] { new Column(viewConstants.headerNumClient(), constantes.getProprietePersonneNumeroClient()), new Column(viewConstants.headerDateCreation(), constantes.getProprietePersonneDateCreation()), new Column(viewConstants.headerNom(), constantes.getProprietePersonneNom()), new Column(viewConstants.headerPrenom(), constantes.getProprietePersonnePrenom()), new Column(viewConstants.headerDateNaissance(), constantes.getProprietePersonneDateNaissance()), new Column(viewConstants.headerNature(), constantes.getProprietePersonneNature()), new Column(viewConstants.headerCodePostal(), constantes.getProprietePersonneCodePostal()), new Column(viewConstants.headerCommune(), constantes.getProprietePersonneCommune()), new Column(viewConstants.headerSelectionne()) }; } @Override public void setRow(int row, final RechercheDoublonResultatModel doublon) { setWidget(row, 0, new Label(doublon.getNumeroClient())); setWidget(row, 1, new Label(doublon.getDateCreation())); setWidget(row, 2, new Label(doublon.getNom())); setWidget(row, 3, new Label(doublon.getPrenom())); setWidget(row, 4, new Label(doublon.getDateNaissance())); setWidget(row, 5, new Label(doublon.getNature())); setWidget(row, 6, new Label(doublon.getCodePostal())); setWidget(row, 7, new Label(doublon.getCommune())); final CheckBox cb = new CheckBox(); cb.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (cb.getValue()) { mapCBSelectionnees.put(doublon.getId(), cb); } else { mapCBSelectionnees.remove(doublon.getId()); } // Mise jour de l'autorisation sur les CheckBoxs majCBTableau(); // Mise jour de l'tat des boutons mAJEtatsBtnsSelection(); } }); if (doublon.getId().equals(idPersonneSelectionnee)) { // On pr-selectionne la ligne correspondant l'identifiant de la personne spficie cb.setValue(true); mapCBSelectionnees.put(doublon.getId(), cb); } setWidget(row, 8, cb); getFlexCellFormatter().setHorizontalAlignment(row, 8, HasAlignment.ALIGN_CENTER); } @Override public void setCellClicked(RechercheDoublonResultatModel doublon) { } }; remotePagingHandlerManager = new HandlerManager(remotePagingTableDoublons); remotePagingTableDoublons.setWidth(ComposantFusionPresenterConstants.POURCENT_100); conteneur.add(remotePagingTableDoublons); }
From source file:com.square.composant.fusion.square.client.view.selection.doublon.SelectionDoublonViewImpl.java
License:Open Source License
@Override public void viderSelection() { mapCBSelectionnees.clear();/*from w ww . j a va2s . c om*/ for (int i = 1; i < remotePagingTableDoublons.getFtResultats().getRowCount(); i++) { if (remotePagingTableDoublons.getFtResultats().getCellCount(i) > 8) { final CheckBox cb = (CheckBox) remotePagingTableDoublons.getFtResultats().getWidget(i, 8); cb.setEnabled(true); cb.setValue(false); } } btnValider.setEnabled(false); btnViderSelection.setEnabled(false); }
From source file:com.square.composant.tarificateur.square.client.view.ligne.devis.LigneDevisViewImpl.java
License:Open Source License
/** * Affiche les informations d'une ligne de devis. *///from w w w.ja v a 2 s. c o m private void afficherInfosLigneDevis(LigneDevisModel ligneDevis, final boolean ligneLiee, boolean isLectureSeule, int numLigne) { // on rcupre la finalit final Long idFinalite = ligneDevis.getFinalite().getIdentifiant() != null ? ligneDevis.getFinalite().getIdentifiant() : constantesApp.getIdFinaliteEnCours(); // on rcupre le critre optionnel ou pas du produit boolean isProduitOptionnel = true; if (ligneLiee && ligneDevis.getProduitOptionnel() != null) { isProduitOptionnel = ligneDevis.getProduitOptionnel().booleanValue(); } // calcul du montant mensuel final float montantLigneMensuel = calculMontantMensuelLigne(ligneDevis.getMontantTtc().floatValue(), ligneDevis.getIdentifiantModePaiement()); float montantLigneMensuelRemise = 0f; if (ligneDevis.getMontantRemise() != null) { montantLigneMensuelRemise = calculMontantMensuelLigne(ligneDevis.getMontantRemise().floatValue(), ligneDevis.getIdentifiantModePaiement()); } // ajout du montant de la ligne au total sauf si ligne lie obligatoire if ((!ligneLiee || isProduitOptionnel) && montantLigneMensuelRemise != montantLigneMensuel) { montantTotalLignesGroupees += montantLigneMensuel; montantTotalLignesGroupeesRemise += montantLigneMensuelRemise; } final RadioButton rbLigneAdhesion = new RadioButton(ligneDevis.getIdentifiant() + "-" + numLigne); final RadioButton rbLigneRefus = new RadioButton(ligneDevis.getIdentifiant() + "-" + numLigne); final RadioButton rbLigneEnCours = new RadioButton(ligneDevis.getIdentifiant() + "-" + numLigne); final RadioButton rbLigneCorbeille = new RadioButton(ligneDevis.getIdentifiant() + "-" + numLigne); rbLigneAdhesion.setTitle(viewConstants.titreRadioAccepte()); rbLigneRefus.setTitle(viewConstants.titreRadioRefuse()); rbLigneEnCours.setTitle(viewConstants.titreRadioEnCours()); rbLigneCorbeille.setTitle(viewConstants.titreRadioCorbeille()); rbLigneAdhesion.setEnabled(!isLectureSeule); rbLigneRefus.setEnabled(!isLectureSeule); rbLigneEnCours.setEnabled(!isLectureSeule); rbLigneCorbeille.setEnabled(!isLectureSeule); // on coche la finalite suivant le cas if (idFinalite.equals(constantesApp.getIdFinaliteAcceptee())) { rbLigneAdhesion.setValue(Boolean.TRUE); } else if (idFinalite.equals(constantesApp.getIdFinaliteRefusee())) { rbLigneRefus.setValue(Boolean.TRUE); } else if (idFinalite.equals(constantesApp.getIdFinaliteEnCours())) { rbLigneEnCours.setValue(Boolean.TRUE); } else if (idFinalite.equals(constantesApp.getIdFinaliteCorbeille())) { rbLigneCorbeille.setValue(Boolean.TRUE); } final CheckBox cbImprimerLigne = new CheckBox(); cbImprimerLigne.setTitle(viewConstants.titreCheckboxSelection()); mapRbLigneAdhesion.put(ligneDevis.getIdentifiant(), rbLigneAdhesion); mapRbLigneRefus.put(ligneDevis.getIdentifiant(), rbLigneRefus); mapRbLigneEnAttente.put(ligneDevis.getIdentifiant(), rbLigneEnCours); mapRbLigneCorbeille.put(ligneDevis.getIdentifiant(), rbLigneCorbeille); mapCbImprimerLigne.put(ligneDevis.getIdentifiant(), cbImprimerLigne); if (ligneLiee && !isProduitOptionnel) { // produit obligatoire non coch et non dcochable (non affich de toute faon) cbImprimerLigne.setValue(Boolean.FALSE); cbImprimerLigne.setEnabled(Boolean.FALSE); } else if (ligneLiee && isProduitOptionnel) { // On slectionne pour impression les produits bonus if (ligneDevis.getIdentifiantFamille().equals(constantesApp.getIdentifiantFamilleBonus1()) || ligneDevis.getIdentifiantFamille().equals(constantesApp.getIdentifiantFamilleBonus2())) { cbImprimerLigne.setValue(Boolean.TRUE); } else { // produit optionnel dcochable cbImprimerLigne.setValue(ligneDevis.getSelectionnePourImpression() != null ? ligneDevis.getSelectionnePourImpression() : Boolean.FALSE); } cbImprimerLigne.setEnabled(Boolean.TRUE); } else if (!ligneLiee) { // produit principal dcochable cbImprimerLigne.setValue(ligneDevis.getSelectionnePourImpression() != null && ligneDevis.getSelectionnePourImpression().booleanValue()); cbImprimerLigne.setEnabled(Boolean.TRUE); } String libelleMontant = ""; if (montantLigneMensuelRemise != montantLigneMensuel) { libelleMontant = numberFormat.format((double) montantLigneMensuel) + ComposantTarificateurConstants.ESPACE + viewConstants.symboleMonnaie(); } else if (montantLigneMensuel != 0f && (ligneDevis.getNAAucunTarif() == null || !ligneDevis.getNAAucunTarif())) { libelleMontant = viewConstants.libelleOffert(); } final Label lProduit = new Label(); final Label lPrenomNomBeneficiaire = new Label(); final HTML lCriteresProduit = new HTML(); final Label lDateEffet = new Label(); final Label lMontant = new Label(); lDateEffet.setWordWrap(false); lMontant.setWordWrap(false); final String libelleProduit = ligneDevis.getLibelleProduit(); lProduit.setText(libelleProduit); //limite le nombre de caractres final String nomPrenom = ligneDevis.getPrenomNomBeneficiaire(); String nomPrenomLimite = nomPrenom; if (nomPrenom.length() > viewConstants.nbMaxCaracteresNomPrenom()) { //limite si superieur a la constante nomPrenomLimite = nomPrenomLimite.substring(0, viewConstants.nbMaxCaracteresNomPrenom()) + "..."; } lPrenomNomBeneficiaire.setText(nomPrenomLimite); lPrenomNomBeneficiaire.setTitle(nomPrenom); lCriteresProduit.setHTML(getLibelleCriteresProduit(ligneDevis)); lDateEffet.setText(ligneDevis.getDateEffet()); lMontant.setText(libelleMontant); tableauLignesDevis.setWidget(numLigne, 0, lProduit); tableauLignesDevis.setWidget(numLigne, 1, lPrenomNomBeneficiaire); tableauLignesDevis.setWidget(numLigne, 2, lCriteresProduit); tableauLignesDevis.setWidget(numLigne, 3, lDateEffet); tableauLignesDevis.setWidget(numLigne, 4, lMontant); tableauLignesDevis.setWidget(numLigne, 5, rbLigneAdhesion); tableauLignesDevis.setWidget(numLigne, 6, rbLigneRefus); tableauLignesDevis.setWidget(numLigne, 7, rbLigneCorbeille); tableauLignesDevis.setWidget(numLigne, 8, rbLigneEnCours); tableauLignesDevis.setWidget(numLigne, 9, cbImprimerLigne); // mise en forme du tableau tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 0, HasAlignment.ALIGN_LEFT); tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 1, HasAlignment.ALIGN_LEFT); tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 2, HasAlignment.ALIGN_LEFT); tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 3, HasAlignment.ALIGN_LEFT); tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 4, HasAlignment.ALIGN_RIGHT); tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 5, HasAlignment.ALIGN_CENTER); tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 6, HasAlignment.ALIGN_CENTER); tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 7, HasAlignment.ALIGN_CENTER); tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 8, HasAlignment.ALIGN_CENTER); tableauLignesDevis.getCellFormatter().setHorizontalAlignment(numLigne, 9, HasAlignment.ALIGN_CENTER); tableauLignesDevis.getRowFormatter().setVerticalAlign(numLigne, HasAlignment.ALIGN_TOP); tableauLignesDevis.getCellFormatter().addStyleName(numLigne, 0, ComposantTarificateur.RESOURCES.css().important()); tableauLignesDevis.getCellFormatter().addStyleName(numLigne, 1, ComposantTarificateur.RESOURCES.css().important()); tableauLignesDevis.getCellFormatter().addStyleName(numLigne, 3, ComposantTarificateur.RESOURCES.css().important()); tableauLignesDevis.getCellFormatter().addStyleName(numLigne, 4, ComposantTarificateur.RESOURCES.css().important()); // Mise en forme spciale pour les lignes associes des produits sans tarifs if (ligneDevis.getNAAucunTarif() != null && ligneDevis.getNAAucunTarif().booleanValue()) { tableauLignesDevis.getRowFormatter().addStyleName(numLigne, ComposantTarificateur.RESOURCES.css().produitSansTarif()); } // si c'est une ligne liee dont le produit est obligatoire, ou si il s'agit d'un produit bonus if ((ligneLiee && !isProduitOptionnel) || ligneDevis.getIdentifiantFamille().equals(constantesApp.getIdentifiantFamilleBonus1()) || ligneDevis.getIdentifiantFamille().equals(constantesApp.getIdentifiantFamilleBonus2())) { rbLigneAdhesion.setEnabled(false); rbLigneRefus.setEnabled(false); rbLigneEnCours.setEnabled(false); rbLigneCorbeille.setEnabled(false); // on cache la ligne tableauLignesDevis.getRowFormatter().setVisible(numLigne, false); } }
From source file:com.tasktop.c2c.server.profile.web.ui.client.presenter.components.TeamMemberPresenter.java
License:Open Source License
@Override public void onClick(ClickEvent event) { Object source = event.getSource(); if (source == view.rolesAnchor) { PopupPanel panel = WidgetUtil.createPopupPanel(view.rolesAnchor); panel.addAutoHidePartner(view.rolesAnchor.getElement()); VerticalPanel content = new VerticalPanel(); for (final ProjectRole role : ProjectRole.values()) { CheckBox checkbox = new CheckBox( projectRoleMessageSelector.getInternationalizedMessage(role, commonProfileMessages)); checkbox.setValue(member.getRoles().contains(role)); boolean enableChanges = true; if (role.equals(ProjectRole.MEMBER) || (role.equals(ProjectRole.OWNER) && self)) { enableChanges = false;// ww w . j a v a2s . c o m } checkbox.setEnabled(enableChanges); if (enableChanges) { checkbox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { member.getRoles().add(role); } else { member.getRoles().remove(role); } updateRoles(); } }); } content.add(checkbox); } panel.add(content); if (panel.isShowing()) { panel.showRelativeTo(view.rolesAnchor); } else { panel.hide(); } } else if (source == view.removeButton) { removeMember(); } }
From source file:com.tasktop.c2c.server.tasks.client.widgets.CustomFieldEditor.java
License:Open Source License
private Widget createWidget(FieldDescriptor field, String fieldValue) { switch (field.getFieldType()) { case MULTI_SELECT: case SINGLE_SELECT: boolean isMultipleSelect = field.getFieldType() == FieldType.MULTI_SELECT; ListBox listBox = new ListBox(isMultipleSelect); int index = 0; Set<String> values = new HashSet<String>(); if (fieldValue != null) { if (isMultipleSelect) { values.addAll(Arrays.asList(fieldValue.split("\\s*,\\s*"))); } else { values.add(fieldValue);//w w w .j a v a 2 s. c o m } } for (String value : field.getValueStrings()) { listBox.addItem(value, value); if (values.contains(value)) { listBox.setItemSelected(index, true); } ++index; } return listBox; case TASK_REFERENCE: // FIXME: provide a better way case TEXT: TextBox textBox = new TextBox(); textBox.setText(fieldValue); return textBox; case TIMESTAMP: DateBox dateBox = new DateBox(); if (fieldValue != null && fieldValue.trim().length() > 0) { try { dateBox.setValue(new Date(Long.parseLong(fieldValue.trim()))); } catch (NumberFormatException e) { // fall-back TextBox newTextBox = new TextBox(); newTextBox.setText(fieldValue); return newTextBox; } } return dateBox; case CHECKBOX: CheckBox checkBox = new CheckBox(); Boolean cbValue = fieldValue != null && Boolean.parseBoolean(fieldValue); checkBox.setValue(cbValue); return checkBox; } return new Label(fieldValue); }
From source file:com.tractionsoftware.gwt.demo.utcdatebox.client.UTCDateBoxDemo.java
License:Apache License
@Override public void onModuleLoad() { eventListBox = new ListBox(true); eventListBox.setVisibleItemCount(20); eventListBox.setWidth("800px"); RootPanel.get("eventlog").add(eventListBox); datebox = new DateBox(new DatePicker(), null, new DateBox.DefaultFormat(DateTimeFormat.getFormat("MMM dd, yyyy"))); datebox.addValueChangeHandler(new ValueChangeHandler<Date>() { @Override//from w ww. j a v a2s.com public void onValueChange(ValueChangeEvent<Date> event) { addEvent("DateBox", event.getValue(), event.getValue().getTime()); } }); RootPanel.get("datebox").add(datebox); utcdatebox = new UTCDateBox(); utcdatebox.addValueChangeHandler(new ValueChangeHandler<Long>() { @Override public void onValueChange(ValueChangeEvent<Long> event) { addEvent("UTCDateBox", new Date(event.getValue()), event.getValue()); } }); RootPanel.get("utcdatebox").add(utcdatebox); CheckBox enabled = new CheckBox("Enabled"); enabled.setValue(true); RootPanel.get("utcdatebox-enabled").add(enabled); enabled.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { utcdatebox.setEnabled(event.getValue()); } }); }
From source file:com.tractionsoftware.gwt.demo.utctimebox.client.UTCTimeBoxDemo.java
License:Apache License
@Override public void onModuleLoad() { eventListBox = new ListBox(true); eventListBox.setVisibleItemCount(20); eventListBox.setWidth("800px"); RootPanel.get("eventlog").add(eventListBox); timebox = new UTCTimeBox(DateTimeFormat.getFormat("hh:mm a")); timebox.addValueChangeHandler(new ValueChangeHandler<Long>() { @Override//from ww w. ja v a 2s. c o m public void onValueChange(ValueChangeEvent<Long> event) { addEvent("UTCTimeBox", event.getValue()); } }); timebox.setValue(UTCTimeBox.getValueForNextHour()); RootPanel.get("utctimebox").add(timebox); CheckBox enabled = new CheckBox("Enabled"); enabled.setValue(true); RootPanel.get("utctimebox-enabled").add(enabled); enabled.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { timebox.setEnabled(event.getValue()); } }); }
From source file:com.vaadin.client.renderers.CheckBoxRenderer.java
License:Apache License
@Override public void render(RendererCellReference cell, Boolean data, CheckBox widget) { widget.setValue(data); }
From source file:com.vaadin.client.ui.VOptionGroup.java
License:Apache License
@Override public void buildOptions(UIDL uidl) { /*//from w w w. jav a 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(); }