List of usage examples for com.google.gwt.user.client.ui CheckBox setValue
@Override public void setValue(Boolean value, boolean fireEvents)
From source file:com.nitrous.gwt.earth.client.demo.FetchKmlInteractiveCheckboxes.java
License:Apache License
private void loadKml(final String file) { String kmlUrl = "http://earth-api-samples.googlecode.com/svn/trunk/examples/static/" + file + ".kml"; // fetch the KML final GEPlugin ge = earth.getGEPlugin(); ge.fetchKml(kmlUrl, new KmlLoadCallback() { @Override//from w w w. j av a2 s .c om public void onLoaded(KmlObject kmlObject) { if (kmlObject != null) { // show it on Earth currentKmlObjects.put(file, kmlObject); ge.getFeatures().appendChild(kmlObject); } else { // bad KML currentKmlObjects.remove(file); // defer display of alert to prevent deadlock in some browsers Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { Window.alert("Bad or null KML."); } }); // uncheck the box CheckBox cb = checkBoxes.get(file); if (cb != null) { cb.setValue(false, false); } } } }); }
From source file:com.vaadin.client.connectors.MultiSelectionModelConnector.java
License:Apache License
@OnStateChange("allSelected") void updateSelectAllCheckbox() { if (selectionModel.getSelectionColumnRenderer() != null) { HeaderCell cell = getGrid().getDefaultHeaderRow().getCell(getGrid().getColumn(0)); CheckBox widget = (CheckBox) cell.getWidget(); widget.setValue(getState().allSelected, false); }// w ww . j a v a 2 s. c o m }
From source file:com.vaadin.client.widget.grid.selection.MultiSelectionRenderer.java
License:Apache License
@Override public void render(final RendererCellReference cell, final Boolean data, CheckBox checkBox) { checkBox.setValue(data, false); checkBox.setEnabled(!grid.isEditorActive()); checkBox.getElement().setPropertyInt(LOGICAL_ROW_PROPERTY_INT, cell.getRowIndex()); }
From source file:com.vaadin.v7.client.widget.grid.selection.MultiSelectionRenderer.java
License:Apache License
@Override public void render(final RendererCellReference cell, final Boolean data, CheckBox checkBox) { checkBox.setValue(data, false); checkBox.setEnabled(grid.isEnabled() && !grid.isEditorActive()); }
From source file:eml.studio.client.ui.panel.HistoryPopupPanel.java
License:Open Source License
/** * Control event binding/*from ww w . ja va 2 s . c o m*/ */ public void eventBind() { closeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { HistoryPopupPanel.this.hide(); } }); searchBtn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub if (startTimeBox.getValue() == null || endTimeBox.getValue() == null) { currentPage = 1; initGridData(); } else if (startTimeBox.getValue().after(endTimeBox.getValue())) { Window.alert("The start time is greater than the end time. Please select again! "); } else { startTime = startTimeBox.getValue(); endTime = endTimeBox.getValue(); currentPage = 1; initGridData(); } } }); batchDelBtn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub if (delOozieJobs.size() == 0 && !selectAllChkBox.isVisible()) //If user not select oozie job to delete and the select all checkbox is not visible, then set the select all checkbox visible { selectAllChkBox.setVisible(true); selectAllChkBox.setValue(false, true); for (Map.Entry<String, CheckBox> entry : totalViewChkBox.entrySet()) { CheckBox curBox = entry.getValue(); curBox.setVisible(true); curBox.setValue(false, true); } } else if (delOozieJobs.size() == 0 && selectAllChkBox.isVisible()) //If user not select oozie job to delete and the select all checkbox is visible, then set the select all checkbox imvisible { selectAllChkBox.setVisible(false); for (Map.Entry<String, CheckBox> entry : totalViewChkBox.entrySet()) { CheckBox curBox = entry.getValue(); curBox.setVisible(false); } } else { if (totalPage == 1 && delOozieJobs.size() == curPageRealSize) Window.alert("Can't delete all record, you should keep at least one record!"); else { final DeletePanel deletePanel = new DeletePanel(); deletePanel.setContent(Constants.studioUIMsg.historyDelHint() + delOozieJobs.size() + " ?"); deletePanel.show(); deletePanel.getConfirmBtn().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub deleteBatchOozJob(delOozieJobs); deletePanel.hide(); selectAllChkBox.setValue(false); } }); } } } }); //Select all check box only valid for the current page selectAllChkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { // TODO Auto-generated method stub if (event.getValue()) { for (Map.Entry<String, CheckBox> entry : totalViewChkBox.entrySet()) { CheckBox curBox = entry.getValue(); curBox.setValue(false, true); } for (Map.Entry<String, CheckBox> entry : pageChkBox.entrySet()) { CheckBox curBox = entry.getValue(); curBox.setValue(true, true); } } else { for (Map.Entry<String, CheckBox> entry : totalViewChkBox.entrySet()) { CheckBox curBox = entry.getValue(); curBox.setValue(false, true); } for (Map.Entry<String, CheckBox> entry : pageChkBox.entrySet()) { CheckBox curBox = entry.getValue(); curBox.setValue(false, true); } } } }); pageGrid.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub int index = pageGrid.getCellForEvent(event).getCellIndex(); String pageText = pageGrid.getText(0, index); currentPage = pagination.getCurrentPage(currentPage, pageText, totalPage); pagination.reload(currentPage); pageLoader(currentPage); } }); }
From source file:org.bonitasoft.console.client.view.categories.CategoriesListEditorView.java
License:Open Source License
private Widget buildSelectAllSelector() { final FlowPanel theWrapper = new FlowPanel(); final CheckBox theSelectAllCheckBox = new CheckBox(); theWrapper.add(theSelectAllCheckBox); theSelectAllCheckBox.addClickHandler(new ClickHandler() { public void onClick(ClickEvent aEvent) { if (aEvent.getSource() instanceof CheckBox) { CheckBox theCheckBox = (CheckBox) aEvent.getSource(); selectAllRows(theCheckBox.getValue()); aEvent.stopPropagation(); }/*from ww w . ja v a 2s. co m*/ } }); final CustomMenuBar theSelector = new CustomMenuBar(); theSelector.addItem(theWrapper, new Command() { public void execute() { boolean theNewValue = !theSelectAllCheckBox.getValue(); theSelectAllCheckBox.setValue(theNewValue, true); selectAllRows(theNewValue); } }); return theSelector; }
From source file:org.bonitasoft.console.client.view.identity.GroupsListEditorView.java
License:Open Source License
private Widget buildSelectAllSelector() { final FlowPanel theWrapper = new FlowPanel(); final CheckBox theSelectAllCheckBox = new CheckBox(); theWrapper.add(theSelectAllCheckBox); theSelectAllCheckBox.addClickHandler(new ClickHandler() { public void onClick(ClickEvent aEvent) { if (aEvent.getSource() instanceof CheckBox) { CheckBox theCheckBox = (CheckBox) aEvent.getSource(); selectAllRows(theCheckBox.getValue()); aEvent.stopPropagation(); }// ww w.j a va 2s. c om } }); final CustomMenuBar theSelector = new CustomMenuBar(); theSelector.addItem(theWrapper, new Command() { public void execute() { boolean theNewValue = !theSelectAllCheckBox.getValue(); theSelectAllCheckBox.setValue(theNewValue, true); selectAllRows(theNewValue); } }); return theSelector; }
From source file:org.bonitasoft.console.client.view.identity.RolesListEditorView.java
License:Open Source License
private Widget buildSelectAllSelector() { final CheckBox theSelectAllCheckBox = new CheckBox(); theSelectAllCheckBox.addClickHandler(new ClickHandler() { public void onClick(ClickEvent aEvent) { if (aEvent.getSource() instanceof CheckBox) { CheckBox theCheckBox = (CheckBox) aEvent.getSource(); selectAllRows(theCheckBox.getValue()); aEvent.stopPropagation(); }//w ww. j a v a2 s.c o m } }); final CustomMenuBar theSelector = new CustomMenuBar(); theSelector.addItem(theSelectAllCheckBox, new Command() { public void execute() { boolean theNewValue = !theSelectAllCheckBox.getValue(); theSelectAllCheckBox.setValue(theNewValue, true); selectAllRows(theNewValue); } }); return theSelector; }
From source file:org.bonitasoft.forms.client.view.widget.FormFieldWidget.java
License:Open Source License
/** * Set the value of the widget//from ww w. ja v a 2 s .com * * @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.daxplore.presenter.client.ui.PerspectiveCheckboxPanel.java
License:Open Source License
private PerspectiveCheckboxPanel(DaxploreConfig config, QuestionMetadata questions, UITexts uiTexts, String questionID, List<Integer> checked, boolean checkTotal) { Label header = new Label(uiTexts.pickSelectionAlternativesHeader()); header.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); header.addStyleName("daxplore-PerspectiveCheckboxes-header"); this.add(header); List<String> options = questions.getOptionTexts(questionID); FlexTable grid = new FlexTable(); CellFormatter formatter = grid.getCellFormatter(); for (int i = 0; i < options.size(); i++) { CheckBox chkbox = new CheckBox(options.get(i)); chkbox.addValueChangeHandler(this); chkbox.setFormValue(String.valueOf(i)); chkbox.setValue(checked.contains(i), false); if (!checkTotal && checked.size() == 0 && i < config.defaultSelectedPerspectiveOptions()) { chkbox.setValue(true, false); }/* ww w . ja v a2s. c om*/ checkboxList.add(chkbox); if (options.size() <= 6) { formatter.setWordWrap(i % options.size(), i / options.size(), false); grid.setWidget(i % options.size(), i / options.size(), chkbox); } else { formatter.setWordWrap(i % 7, i / 7, false); grid.setWidget(i % 7, i / 7, chkbox); } } this.add(grid); total = new CheckBox(uiTexts.compareWithAll()); total.addValueChangeHandler(this); total.setFormValue("all"); total.setValue(checkTotal, false); this.add(total); }