List of usage examples for com.google.gwt.user.client.ui CheckBox addValueChangeHandler
@Override
public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Boolean> handler)
From source file:gov.nist.spectrumbrowser.client.SensorInfoDisplay.java
License:Open Source License
/** * Show the sensor summary information in the side of the map. * // w ww . j a v a 2s . c o m */ void buildSummary() { logger.finer("SensorInfoDisplay: buildSummary " + getId()); try { info = sensorInfo.getSensorDescriptionNoBands(); sensorDescriptionPanel.add(info); for (final String bandName : sensorInfo.getBandNames()) { final BandInfo bandInfo = sensorInfo.getBandInfo(bandName); if (bandInfo != null) { VerticalPanel bandDescriptionPanel = new VerticalPanel(); HTML bandDescription = sensorInfo.getBandDescription(bandName); bandDescriptionPanel.add(bandDescription); if (sensorInfo.getMeasurementType().equals(Defines.SWEPT_FREQUENCY)) { HorizontalPanel showAdvancedPanel = new HorizontalPanel(); showAdvancedPanel.add(new Label("Advanced ")); CheckBox advancedCheckBox = new CheckBox(); advancedCheckBox.setValue(false); showAdvancedPanel.add(advancedCheckBox); bandDescriptionPanel.add(showAdvancedPanel); final VerticalPanel advancedPanel = new VerticalPanel(); advancedPanel.add(new Label("Specify Sub-band :")); Grid grid = new Grid(2, 2); grid.setText(0, 0, "Min Freq (MHz):"); minFreqBox = new TextBox(); minFreqBox.setText(Double.toString(bandInfo.getSelectedMinFreq() / 1E6)); minFreqBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { try { double newFreq = Double.parseDouble(event.getValue()); if (!bandInfo.setSelectedMinFreq((long) (newFreq * 1E6))) { Window.alert("Illegal value entered"); minFreqBox.setText(Double.toString(bandInfo.getSelectedMinFreq() / 1E6)); } } catch (NumberFormatException ex) { Window.alert("Illegal Entry"); minFreqBox.setText(Double.toString(bandInfo.getMinFreq() / 1E6)); } } }); minFreqBox.setTitle("Enter value >= " + bandInfo.getMinFreq() / 1E6); grid.setWidget(0, 1, minFreqBox); grid.setText(1, 0, "Max Freq (MHz):"); maxFreqBox = new TextBox(); maxFreqBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { try { double newFreq = Double.parseDouble(event.getValue()); if (!bandInfo.setSelectedMaxFreq((long) (newFreq * 1E6))) { Window.alert("Illegal value entered"); maxFreqBox.setText(Double.toString(bandInfo.getSelectedMaxFreq() / 1E6)); } } catch (NumberFormatException ex) { Window.alert("Illegal Entry"); maxFreqBox.setText(Double.toString(bandInfo.getSelectedMaxFreq() / 1E6)); } } }); maxFreqBox.setText(Double.toString(bandInfo.getSelectedMaxFreq() / 1E6)); maxFreqBox.setTitle("Enter value <= " + bandInfo.getMaxFreq() / 1E6); grid.setWidget(1, 1, maxFreqBox); advancedPanel.add(grid); advancedPanel.add(new Label("Changing to non-default values increases compute time")); Grid updateGrid = new Grid(1, 2); Button changeButton = new Button("Change"); updateGrid.setWidget(0, 0, changeButton); final Label label = new Label(); updateGrid.setWidget(0, 1, label); changeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { double minFreq = Double.parseDouble(minFreqBox.getText()); double maxFreq = Double.parseDouble(maxFreqBox.getText()); if (!bandInfo.setSelectedMaxFreq((long) (maxFreq * 1E6)) || !bandInfo.setSelectedMinFreq((long) (minFreq * 1E6))) { Window.alert("Illegal value entered"); minFreqBox.setText(Double.toString(bandInfo.getMinFreq() / 1E6)); maxFreqBox.setText(Double.toString(bandInfo.getSelectedMaxFreq() / 1E6)); } else { updateAcquistionCount(); label.setText("Changes Updated"); Timer timer = new Timer() { @Override public void run() { label.setText(null); } }; timer.schedule(2000); } } }); advancedPanel.add(updateGrid); bandDescriptionPanel.add(advancedPanel); advancedPanel.setVisible(false); advancedCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { advancedPanel.setVisible(true); } else { advancedPanel.setVisible(false); } } }); } final Label bandSelectionButton = new Label(bandInfo.getFreqRange().toString()); bandSelectionButton.getElement().getStyle().setCursor(Cursor.POINTER); if (bandInfo.isActive()) { bandSelectionButton.setStyleName("activeBandSelectionButton"); bandSelectionButton.setTitle("Enabled for data collection"); } else { bandSelectionButton.setTitle("Disabled for data collection"); bandSelectionButton.setStyleName("bandSelectionButton"); } sensorDescriptionPanel.add(bandSelectionButton); sensorDescriptionPanel.add(bandDescriptionPanel); bandDescriptionPanel.setVisible(false); selectionButtons.add(bandSelectionButton); bandInfo.setSelectionButton(bandSelectionButton); bandDescriptionPanels.add(bandDescriptionPanel); bandSelectionButton.addClickHandler( new SelectBandClickHandler(bandDescriptionPanel, bandSelectionButton, bandInfo)); } } } catch (Exception ex) { logger.log(Level.SEVERE, "Error in updating data summary ", ex); ex.printStackTrace(); } finally { } }
From source file:ilarkesto.gwt.client.desktop.fields.AEditableMultiSelectionField.java
License:Open Source License
private IsWidget createCheckboxesEditorWidget(Collection<String> optionKeys) { checkboxes = new LinkedHashMap<String, CheckBox>(); boolean horizontal = isHorizontal(); Panel panel = horizontal ? new FlowPanel() : new VerticalPanel(); Collection<String> selectedKeys = getSelectedOptionKeys(); int inRow = 0; for (String key : optionKeys) { String label = getTextForOption(getValueForKey(key)); CheckBox checkBox = new CheckBox(label); checkBox.getElement().setId(getId() + "_checkbox_" + key); checkBox.setValue(selectedKeys.contains(key)); if (getEditVetoMessage() == null) { } else {// w w w . j a v a 2s .co m checkBox.setEnabled(false); checkBox.setTitle(getEditVetoMessage()); } updateStyle(checkBox); checkBox.addValueChangeHandler(new CheckboxChangeHandler(checkBox)); if (horizontal) { Style style = checkBox.getElement().getStyle(); style.setProperty("minWidth", "100px"); style.setDisplay(Display.BLOCK); style.setFloat(com.google.gwt.dom.client.Style.Float.LEFT); style.setWidth(220, Unit.PX); style.setMarginRight(Widgets.defaultSpacing, Unit.PX); } checkboxes.put(key, checkBox); panel.add(checkBox); inRow++; if (horizontal && inRow >= 3) { panel.add(new HTML("<br>")); inRow = 0; } } if (horizontal) { panel.add(Widgets.clear()); } if (optionKeys.size() >= 10) { panel.add(new ActionButton(new SelectAllCheckboxesAction())); panel.add(new ActionButton(new DeselectAllCheckboxesAction())); } return panel; }
From source file:io.apiman.manager.ui.client.local.pages.service.ImportServicesTable.java
License:Apache License
/** * Adds a row to the table./*from w w w . j a v a 2 s. c o m*/ * @param rowIdx * @param bean */ private void addRow(int rowIdx, final ServiceVersionBean bean) { CheckBox checkbox = new CheckBox(); checkbox.setValue(Boolean.TRUE); checkboxes.add(checkbox); add(rowIdx, 0, checkbox); checkbox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { boolean selected = event.getValue(); if (selected) { selectedServices.add(bean); } else { selectedServices.remove(bean); } fireChangeEvent(); } }); final TextBox serviceName = new TextBox(); serviceName.getElement().getStyle().setWidth(200, Unit.PX); serviceName.setValue(bean.getService().getName()); names.add(serviceName); add(rowIdx, 1, serviceName); serviceName.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { bean.getService().setName(serviceName.getValue()); fireChangeEvent(); } }); final TextBox initialVersion = new TextBox(); initialVersion.getElement().getStyle().setWidth(75, Unit.PX); initialVersion.setValue(bean.getVersion()); versions.add(initialVersion); add(rowIdx, 2, initialVersion); initialVersion.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { bean.setVersion(initialVersion.getValue()); fireChangeEvent(); } }); InlineLabel endpoint = new InlineLabel(bean.getEndpoint()); add(rowIdx, 3, endpoint); }
From source file:main.client.ui.RowLayoutPortlet.java
License:Open Source License
public RowLayoutPortlet() { LayoutPanel panel = new LayoutPanel(); initWidget(panel);/*from www . j a v a 2s . c o m*/ final CheckBox column = new CheckBox("Column"); column.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { getTargetLayout().setColumn(column.getValue()); target.layout(); } }); final TextBox spacing = new TextBox(); spacing.setVisibleLength(4); spacing.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { try { getTargetLayout().setSpacing(Integer.parseInt(spacing.getText())); } catch (NumberFormatException e) { // ignore } target.layout(); } }); final Label bounds = new Label(); target.addLayoutHandler(new LayoutHandler() { public void onLayoutUpdated(LayoutEvent layoutEvent) { bounds.setText(LDOM.getBounds(target).toString()); column.setValue(getTargetLayout().isColumn()); spacing.setText(Integer.toString(getTargetLayout().getSpacing())); } }); demoList.addItem("Buttons & Body"); demoList.addItem("Sidebar & Margin"); demoList.addItem("Border Layout"); demoList.setSelectedIndex(0); Button add = new CssButton("Add Widget", new ClickHandler() { public void onClick(ClickEvent event) { target.add(new Thing("Widget-" + (target.getWidgetCount() + 1))); target.layout(); } }, "Add a new widget to the layout"); final Button go = new CssButton("Go", new ClickHandler() { public void onClick(ClickEvent event) { go(); } }, "Reset the layout to the selected state"); demoList.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { go.click(); } }); FormBuilder b = new FormBuilder(); b.add(add).label("Spacing").field(spacing).field(column).add("").field(bounds).wrap().width("100%") .add(demoList).add(go).endRow(); panel.add(b.getForm(), 22); panel.add(target, LayoutConstraints.HIDDEN); go(); }
From source file:net.randomhacks.wave.voting.approval.client.ChoicesTable.java
License:Apache License
private void insertChoiceRow(int i, final Choice choice) { Log.debug("Inserting row " + Integer.toString(i) + ": " + choice.key); knownChoices.add(i, choice.key);/*from w w w. ja v a2 s .com*/ int row = rowForChoiceIndex(i); insertRow(row); final CheckBox checkBox = new CheckBox(choice.name); setWidget(row, 0, checkBox); checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { model.setChosen(choice.name, event.getValue()); } }); }
From source file:net.scran24.admin.client.NewSurvey.java
License:Apache License
public NewSurvey() { contents = new FlowPanel(); final Grid surveyParametersGrid = new Grid(7, 2); surveyParametersGrid.setCellPadding(5); contents.add(surveyParametersGrid);/*w w w.j a va 2 s . co m*/ final Label idLabel = new Label("Survey identifier: "); final TextBox idTextBox = new TextBox(); surveyParametersGrid.setWidget(0, 0, idLabel); surveyParametersGrid.setWidget(0, 1, idTextBox); final Label schemeBoxLabel = new Label("Survey scheme: "); final ListBox schemeBox = new ListBox(); schemeBox.setMultipleSelect(false); final Label localeLabel = new Label("Locale: "); final ListBox localeBox = new ListBox(); localeBox.setMultipleSelect(false); localeBox.addItem("English (UK)", "en_GB"); localeBox.addItem("English (New Zealand)", "en_NZ"); localeBox.addItem("Portuguese (Portugal)", "pt_PT"); localeBox.addItem("Danish (Denmark)", "da_DK"); localeBox.addItem("Arabic (UAE)", "ar_AE"); for (SurveySchemeReference s : SurveySchemes.allSchemes) schemeBox.addItem(s.description(), s.id()); schemeBox.setSelectedIndex(0); surveyParametersGrid.setWidget(1, 0, schemeBoxLabel); surveyParametersGrid.setWidget(1, 1, schemeBox); surveyParametersGrid.setWidget(2, 0, localeLabel); surveyParametersGrid.setWidget(2, 1, localeBox); final Label genUserLabel = new Label("Allow auto login: "); final CheckBox genCheckBox = new CheckBox(); surveyParametersGrid.setWidget(3, 0, genUserLabel); surveyParametersGrid.setWidget(3, 1, genCheckBox); final Label forwardToSurveyMonkey = new Label("SurveyMonkey support:"); final CheckBox smCheckBox = new CheckBox(); surveyParametersGrid.setWidget(4, 0, forwardToSurveyMonkey); surveyParametersGrid.setWidget(4, 1, smCheckBox); final Label surveyMonkeyUrl = new Label("SurveyMonkey link:"); final TextBox smUrlTextBox = new TextBox(); surveyParametersGrid.setWidget(5, 0, surveyMonkeyUrl); surveyParametersGrid.setWidget(5, 1, smUrlTextBox); smUrlTextBox.setEnabled(false); final Label supportEmailLabel = new Label("Support e-mail:"); final TextBox supportEmailTextBox = new TextBox(); surveyParametersGrid.setWidget(6, 0, supportEmailLabel); surveyParametersGrid.setWidget(6, 1, supportEmailTextBox); smCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) { smUrlTextBox.setEnabled(valueChangeEvent.getValue()); } }); final FlowPanel errorDiv = new FlowPanel(); errorDiv.getElement().addClassName("scran24-admin-survey-id-error-message"); contents.add(errorDiv); final Button createButton = WidgetFactory.createButton("Create survey"); createButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { createButton.setEnabled(false); final String id = idTextBox.getText(); errorDiv.clear(); String smUrlText = smUrlTextBox.getText(); Option<String> smUrl; if (smCheckBox.getValue()) smUrl = smUrlText.isEmpty() ? Option.<String>none() : Option.some(smUrlText); else smUrl = Option.<String>none(); if (smCheckBox.getValue() && smUrlText.isEmpty()) { errorDiv.add(new Label("Please paste the SurveyMonkey link!")); createButton.setEnabled(true); return; } else if (smCheckBox.getValue() && !smUrlText.contains("intake24_username=[intake24_username_value]")) { errorDiv.add(new Label("Invalid SurveyMonkey link: intake24_username variable missing!")); createButton.setEnabled(true); return; } service.createSurvey(id, schemeBox.getValue(schemeBox.getSelectedIndex()), localeBox.getValue(localeBox.getSelectedIndex()), genCheckBox.getValue(), smUrl, supportEmailTextBox.getValue(), new AsyncCallback<Option<String>>() { @Override public void onSuccess(Option<String> result) { result.accept(new Option.SideEffectVisitor<String>() { @Override public void visitSome(String error) { errorDiv.add(new Label(error)); createButton.setEnabled(true); } @Override public void visitNone() { contents.clear(); contents.add(new HTMLPanel(SafeHtmlUtils.fromSafeConstant( "<h2>Survey created!</h2><p>Please go to <strong>Survey management</strong> and upload the staff accounts for the new survey.</p>"))); } }); } @Override public void onFailure(Throwable caught) { createButton.setEnabled(true); errorDiv.add( new Label("Server error (" + SafeHtmlUtils.htmlEscape(caught.getMessage()) + "), please check server logs")); } }); } }); createButton.getElement().addClassName("scran24-admin-button"); VerticalPanel buttonsPanel = new VerticalPanel(); buttonsPanel.add(createButton); contents.add(buttonsPanel); initWidget(contents); }
From source file:org.activityinfo.ui.client.component.form.field.CheckBoxFieldWidget.java
License:Open Source License
public CheckBoxFieldWidget(ReferenceType type, List<FormInstance> range, final ValueUpdater valueUpdater) { panel = new FlowPanel(); controls = new ArrayList<>(); this.range = range; ValueChangeHandler<Boolean> changeHandler = new ValueChangeHandler<Boolean>() { @Override/* w ww . j av a 2 s. c o m*/ public void onValueChange(ValueChangeEvent<Boolean> event) { valueUpdater.update(updatedValue()); } }; String groupId = Long.toString(new Date().getTime()); for (final FormInstance instance : range) { CheckBox checkBox = createControl(groupId, instance, type.getCardinality()); checkBox.addValueChangeHandler(changeHandler); panel.add(checkBox); controls.add(checkBox); } }
From source file:org.bonitasoft.forms.client.view.widget.CheckboxGroupWidget.java
License:Open Source License
private CheckBox createCheckbox(final boolean allowHTML, final ReducedFormFieldAvailableValue availableValue) { final CheckBox checkBox = new CheckBox(availableValue.getLabel(), allowHTML); checkBox.addClickHandler(this); checkBox.addValueChangeHandler(this); checkBox.setFormValue(availableValue.getValue()); checkBox.setStyleName("bonita_form_radio"); return checkBox; }
From source file:org.bonitasoft.forms.client.view.widget.FormFieldWidget.java
License:Open Source License
/** * Create a {@link CheckBox} widget//from ww w .j a v a 2 s . c o m * * @param widgetData * the widget data object * @param fieldValue * the widget value * @return a {@link CheckBox} */ @SuppressWarnings("unchecked") protected CheckBox createCheckBox(final ReducedFormWidget widgetData, final FormFieldValue fieldValue) { final CheckBox checkBox = new CheckBox(); checkBox.addClickHandler(this); checkBox.addValueChangeHandler(this); try { checkBox.setValue((Boolean) fieldValue.getValue()); } catch (final Exception e) { Window.alert("initial value for checkbox " + widgetData.getId() + " should be a boolean."); checkBox.setValue(false, false); } checkBox.setEnabled(!widgetData.isReadOnly()); return checkBox; }
From source file:org.calontir.marshallate.falcon.client.ui.fighterform.AuthorizationsField.java
public AuthorizationsField(final Fighter fighter, final boolean edit) { Panel dataBody = new FlowPanel(); dataBody.setStyleName("dataBody"); if (edit) {//w w w . j a va 2s . c o m for (AuthType at : lookupController.getAuthType()) { final CheckBox cb = new CheckBox(at.getCode()); cb.setFormValue(at.getCode()); cb.setName("authorization"); if (fighter.getAuthorization() != null) { for (Authorization a : fighter.getAuthorization()) { if (a.getCode().equals(at.getCode())) { cb.setValue(true); break; } } } cb.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { List<Authorization> auths = fighter.getAuthorization(); if (auths == null) { auths = new ArrayList<Authorization>(); fighter.setAuthorization(auths); } Authorization a = new Authorization(); a.setCode(cb.getFormValue()); if (auths.contains(a)) { if (event.getValue()) { auths.add(a); } else { auths.remove(a); } } else { if (event.getValue()) { auths.add(a); } } } }); dataBody.add(cb); } } else { Label auths = new Label(); auths.setText(getAuthsAsString(fighter.getAuthorization())); dataBody.add(auths); } initWidget(dataBody); }