Example usage for com.google.gwt.user.client.ui CheckBox getValue

List of usage examples for com.google.gwt.user.client.ui CheckBox getValue

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui CheckBox getValue.

Prototype

@Override
public Boolean getValue() 

Source Link

Document

Determines whether this check box is currently checked.

Usage

From source file:edu.caltech.ipac.firefly.ui.input.CheckBoxGroupInputField.java

public CheckBoxGroupInputField(EnumFieldDef fieldDef) {
    _fieldDef = fieldDef;//from  w  w w  . j a  v a 2  s  .  c  o  m

    if (fieldDef.getOrientation().equals(EnumFieldDef.Orientation.Vertical)) {
        _panel = new VerticalPanel();
        _fieldWidgetPanel = new VerticalPanel();
    } else {
        _panel = new HorizontalPanel();
        _fieldWidgetPanel = new HorizontalPanel();
    }
    initWidget(_fieldWidgetPanel);
    _panel.setSpacing(5);
    _panel.setTitle(_fieldDef.getShortDesc());

    //list box setup
    _items = ((EnumFieldDef) _fieldDef).getEnumValues();
    _cbs = new ArrayList<CheckBox>(_items.size());
    CheckBox cb;
    int idx = 0;
    for (EnumFieldDef.Item item : _items) {
        cb = new CheckBox(" " + item.getTitle(), true);
        _cbs.add(cb);
        _panel.add(cb);
        if (item.getName().equals(ALL)) {
            _idxOfAll = idx;
        }
        idx++;
    }

    // add warning area
    _warningArea.setWidth("16px");
    _warningArea.setHeight("16px");
    DOM.setStyleAttribute(_warningArea.getElement(), "padding", "3px");
    ErrorHandler eh = new ErrorHandler();
    _warningArea.addFocusHandler(eh);
    _warningArea.addBlurHandler(eh);
    _warningArea.addMouseDownHandler(eh);
    _warningArea.addMouseOverHandler(eh);
    _warningArea.addMouseOutHandler(eh);
    _fieldWidgetPanel.add(_panel);
    _fieldWidgetPanel.add(_warningArea);
    _fieldWidgetPanel.setCellHorizontalAlignment(_warningArea, HasHorizontalAlignment.ALIGN_CENTER);
    _fieldWidgetPanel.setCellVerticalAlignment(_warningArea, HasVerticalAlignment.ALIGN_MIDDLE);

    // add click listeners
    for (idx = 0; idx < _cbs.size(); idx++) {
        final CheckBox current = _cbs.get(idx);
        final int currentIdx = idx;
        current.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent ev) {
                if ((currentIdx == _idxOfAll) && current.getValue()) {
                    //uncheck all other
                    for (int i = 0; i < _cbs.size(); i++) {
                        if (i != _idxOfAll) {
                            _cbs.get(i).setValue(true);
                        }
                    }
                } else if ((currentIdx == _idxOfAll) && !current.getValue()) {
                    //all is unchecked so uncheck all that were checked
                    for (int i = 0; i < _cbs.size(); i++) {
                        if (i != _idxOfAll) {
                            _cbs.get(i).setValue(false);
                        }
                    }
                } else if (_idxOfAll >= 0) {
                    // uncheck _all_ unless all other checkboxes are checked
                    CheckBox all = null;
                    int nChecked = 0;
                    for (int i = 0; i < _cbs.size(); i++) {
                        if (i == _idxOfAll) {
                            all = _cbs.get(i);
                        } else {
                            if (_cbs.get(i).getValue()) {
                                nChecked++;
                            }
                        }
                    }

                    assert (all != null);
                    // all checkboxes are checked
                    if (nChecked == _cbs.size() - 1) {
                        all.setValue(true);
                        for (int i = 0; i < _cbs.size(); i++) {
                            if (i != _idxOfAll) {
                                _cbs.get(i).setValue(true);
                            }
                        }
                    } else {
                        all.setValue(false);
                    }
                }
                ValueChangeEvent.fire(CheckBoxGroupInputField.this, getValue());
            }
        });

    }
    reset();

    addValueChangeHandler(new ValueChangeHandler<String>() {
        public void onValueChange(ValueChangeEvent valueChangeEvent) {
            if (validate()) {

            }
        }
    });

    // label setup
}

From source file:edu.caltech.ipac.firefly.ui.table.TableOptions.java

private void applyChanges() {
    ensureSelectAllCB();/*from w  w  w.  j  a  v  a  2 s  . co m*/
    DefaultTableDefinition<TableData.Row> tdef = (DefaultTableDefinition<TableData.Row>) table.getTable()
            .getTableDefinition();
    boolean reloadNeeded = false;

    for (ColDef col : checkBoxes.keySet()) {
        CheckBox cb = checkBoxes.get(col);
        if (tdef.isColumnVisible(col) != cb.getValue()) {
            col.getColumn().setVisible(cb.getValue());
            tdef.setColumnVisible(col, cb.getValue());
            reloadNeeded = true;
        }
    }

    if (reloadNeeded) {
        String vcols = getVisibleColStr(table.getTable());
        if (vcols.equals(defVisibleCols)) {
            Preferences.set(table.getName() + VISI_COL_PREF, null);
        } else {
            Preferences.set(table.getName() + VISI_COL_PREF, vcols);
        }
        //            table.getTable().clearHiddenFilters();
        table.redrawTable();
    }
}

From source file:edu.caltech.ipac.firefly.visualize.graph.XYPlotBasicWidget.java

private Widget createLegend() {
    int nCurves = _mainCurves.size();
    int nPoints = _specificPoints.size();
    if (_data == null || (nCurves < 2 && nPoints < 1))
        return null;
    Grid result = new Grid(nCurves + (nPoints > 0 ? (nPoints + 1) : 0), 1);
    int cIdx = 0;
    if (nCurves > 1) {
        for (final GChart.Curve c : _mainCurves) {
            c.getSymbol().getBorderColor();
            final CheckBox ch = GwtUtil.makeCheckBox(c.getLegendLabel(), "Deselect to hide", true);
            ch.getElement().getStyle().setProperty("color", c.getSymbol().getBackgroundColor());
            ch.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    boolean visible = ch.getValue();
                    c.setVisible(visible);
                    // 2 error curves are added for each main curve
                    // error curves are added before main curves
                    if (_meta.plotError() && _data.hasError()) {
                        int cIdx = _mainCurves.indexOf(c);
                        XYPlotData.Curve current = _data.getCurveData().get(cIdx);
                        int lowerErrIdx = current.getErrorLowerCurveIdx();
                        int upperErrIdx = current.getErrorUpperCurveIdx();

                        try {
                            for (int i = lowerErrIdx; i <= upperErrIdx; i++) {
                                _chart.getCurve(i).setVisible(visible);
                            }/*from   w w w. jav a 2s .c  o m*/
                        } catch (Exception e) {
                            _meta.setPlotError(false);
                        }
                    }
                    _chart.update();
                }
            });
            result.setWidget(cIdx, 0, ch);
            cIdx++;
        }
    }
    int pIdx = 0;

    if (_meta.plotSpecificPoints() && nPoints > 0) {
        Label desc = new HTML(
                cIdx > 0 ? "<br>" : "" + "<b>" + specificPointsDesc.replaceAll(" ", "<br>") + "</b>");
        result.setWidget(cIdx, 0, desc); //"&nbsp;"

        for (final SpecificPointUI pointUI : _specificPoints) {
            final CheckBox ch = GwtUtil.makeCheckBox(pointUI.p.getLabel(), "Deselect to hide", true);
            ch.getElement().getStyle().setProperty("color", pointUI.spCurve.getSymbol().getBackgroundColor());
            ch.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    pointUI.setVisible(ch.getValue());
                    _chart.update();
                }
            });
            result.setWidget(cIdx + pIdx + 1, 0, ch);
            pIdx++;
        }
    }
    return result;
}

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 v  a 2  s  . c  o m
    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:edu.colorado.csdms.wmt.client.ui.menu.LabelsOpenModelMenu.java

License:Open Source License

/**
 * Makes an ArrayList of label ids that are selected in the labelPanel.
 * //  w w  w .  j a v a2s. c om
 * Note: If the "public" or username labels are not selected, then clear the
 * list of ids, regardless of whether other labels are selected; i.e., either
 * the "public" or username label must be selected.
 */
private void makeSelectedLabelIdsList() {
    selectedLabelIds.clear();
    Boolean isPublicOrUserLabelSelected = false;
    for (int i = 0; i < labelPanel.getWidgetCount(); i++) {
        CheckBox labelBox = (CheckBox) labelPanel.getWidget(i);
        if (labelBox.getValue()) {
            if (labelBox.getText().matches("public")
                    || labelBox.getText().matches(data.security.getWmtUsername())) {
                isPublicOrUserLabelSelected = true;
            }
            LabelJSO jso = data.modelLabels.get(labelBox.getText());
            selectedLabelIds.add(jso.getId());
        }
    }
    if (!isPublicOrUserLabelSelected) {
        selectedLabelIds.clear();
    }
}

From source file:edu.cudenver.bios.glimmpse.client.panels.matrix.OptionsConfidenceIntervalsPanel.java

License:Open Source License

private HorizontalPanel createDisablePanel() {
    HorizontalPanel panel = new HorizontalPanel();

    // add callbacks
    noCICheckbox.addClickHandler(new ClickHandler() {
        @Override/*from   w w w . j a v  a  2s  . c  om*/
        public void onClick(ClickEvent event) {
            CheckBox cb = (CheckBox) event.getSource();
            enableConfidenceIntervalOptions(!cb.getValue());
            checkComplete();
            // notify listeners
            for (ConfidenceIntervalListener listener : listeners)
                listener.onHasConfidenceInterval(!cb.getValue());
        }
    });

    panel.add(noCICheckbox);
    panel.add(new HTML(Glimmpse.constants.confidenceIntervalOptionsNone()));

    // set style
    panel.setStyleName(GlimmpseConstants.STYLE_WIZARD_PARAGRAPH);

    return panel;
}

From source file:edu.cudenver.bios.glimmpse.client.panels.OptionsDisplayPanel.java

License:Open Source License

private HorizontalPanel createDisablePanel() {
    HorizontalPanel panel = new HorizontalPanel();

    // add callbacks
    disableCheckbox.addClickHandler(new ClickHandler() {
        @Override/*from  w  w  w  .  ja v a2s.  c  o m*/
        public void onClick(ClickEvent event) {
            CheckBox cb = (CheckBox) event.getSource();
            enableOptions(!cb.getValue());
        }
    });
    disableCheckbox.setValue(true);
    panel.add(disableCheckbox);
    panel.add(new HTML(Glimmpse.constants.curveOptionsNone()));

    // set style
    panel.setStyleName(GlimmpseConstants.STYLE_WIZARD_PARAGRAPH);

    return panel;
}

From source file:edu.ucdenver.bios.glimmpseweb.client.guided.GaussianCovariateCovariancePanel.java

License:Open Source License

/**
 * Constructor/*  ww  w. j av  a  2s . c o  m*/
 * @param context study design context object
 */
public GaussianCovariateCovariancePanel(WizardContext context) {
    super(context, GlimmpseWeb.constants.navItemVariabilityGaussianCovariate(), WizardStepPanelState.SKIPPED);
    studyDesignContext = (StudyDesignContext) context;

    VerticalPanel verticalPanel = new VerticalPanel();
    // header text
    HTML header = new HTML(GlimmpseWeb.constants.randomCovariateCovarianceHeader());
    HTML description = new HTML(GlimmpseWeb.constants.randomCovariateCovarianceDescription());

    // add validation to standard deviation box
    standardDeviationTextBox.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            TextBox tb = (TextBox) event.getSource();
            double value = 1;
            try {
                value = TextValidation.parseDouble(tb.getValue(), 0, true);
                TextValidation.displayOkay(stdDevErrorHTML, "");
            } catch (Exception e) {
                TextValidation.displayError(stdDevErrorHTML,
                        GlimmpseWeb.constants.errorInvalidStandardDeviation());
                tb.setText("1");
            }
            notifySigmaG(value);
            checkComplete();
        }
    });

    // add change handler for using the same correlation for all repeated measures
    sameCorrelationCheckBox.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            CheckBox cb = (CheckBox) event.getSource();
            if (cb.getValue()) {
                setEqualCorrelationForRepeatedMeasures();
            } else {
                enableUnequalCorrelationForRepeatedMeasures();
            }
        }
    });

    // layout the repeated measures panel
    rmPanel.add(rmInstructions);
    rmPanel.add(repeatedMeasuresTable);
    rmPanel.add(sameCorrelationCheckBox);
    rmPanel.setVisible(false);

    // layout the overall panel
    verticalPanel.add(header);
    verticalPanel.add(description);
    verticalPanel.add(new HTML(GlimmpseWeb.constants.randomCovariateCovarianceStandardDeviationInstructions()));
    verticalPanel.add(standardDeviationTextBox);
    verticalPanel.add(stdDevErrorHTML);
    verticalPanel.add(new HTML(GlimmpseWeb.constants.randomCovariateCovarianceCorrelationInstructions()));
    verticalPanel.add(sigmaYGTable);
    verticalPanel.add(correlationErrorHTML);
    verticalPanel.add(rmPanel);

    // add style
    verticalPanel.setStyleName(GlimmpseConstants.STYLE_WIZARD_STEP_PANEL);
    header.setStyleName(GlimmpseConstants.STYLE_WIZARD_STEP_HEADER);
    description.setStyleName(GlimmpseConstants.STYLE_WIZARD_STEP_DESCRIPTION);
    sameCorrelationCheckBox.setStyleName(GlimmpseConstants.STYLE_WIZARD_STEP_DESCRIPTION);
    sigmaYGTable.setStyleName(GlimmpseConstants.STYLE_WIZARD_STEP_TABLE);
    stdDevErrorHTML.setStyleName(GlimmpseConstants.STYLE_MESSAGE);
    correlationErrorHTML.setStyleName(GlimmpseConstants.STYLE_MESSAGE);

    initWidget(verticalPanel);

}

From source file:edu.ucdenver.bios.glimmpseweb.client.shared.OptionsConfidenceIntervalsPanel.java

License:Open Source License

/**
 * Create panel which enables or disables confidence intervals
 * @return enable/disable panel/*from  w w  w  . j  ava 2  s. com*/
 */
private HorizontalPanel createDisablePanel() {
    HorizontalPanel panel = new HorizontalPanel();

    // add callbacks
    noCICheckbox.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            CheckBox cb = (CheckBox) event.getSource();
            boolean enabled = !cb.getValue();
            showConfidenceIntervalOptions(enabled);
            if (enabled) {
                addConfidenceIntervalDescription();
            } else {
                removeConfidenceIntervalDescription();
            }
            checkComplete();
        }
    });

    panel.add(noCICheckbox);
    panel.add(new HTML(GlimmpseWeb.constants.confidenceIntervalOptionsNone()));

    // set style
    panel.setStyleName(GlimmpseConstants.STYLE_WIZARD_PARAGRAPH);

    return panel;
}

From source file:edu.ucdenver.bios.glimmpseweb.client.shared.OptionsDisplayPanel.java

License:Open Source License

/**
 * Create panel with checkbox to enable/disable power curves
 * /* w  w w  . j  a  v  a 2 s.  c o m*/
 * @return HorizontalPanel containing the checkbox
 */
private HorizontalPanel createDisablePanel() {
    HorizontalPanel panel = new HorizontalPanel();

    // add callbacks
    disableCheckbox.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            CheckBox cb = (CheckBox) event.getSource();
            enableOptions(!cb.getValue());
            syncPowerCurveDescription();
            checkComplete();
        }
    });
    disableCheckbox.setValue(true);
    panel.add(disableCheckbox);
    panel.add(new HTML(GlimmpseWeb.constants.curveOptionsNone()));

    // set style
    panel.setStyleName(GlimmpseConstants.STYLE_WIZARD_PARAGRAPH);

    return panel;
}