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:org.kie.guvnor.guided.dtable.client.widget.ConditionPopup.java

License:Apache License

protected void showNewPatternDialog() {
    final FormStylePopup pop = new FormStylePopup();
    pop.setTitle(Constants.INSTANCE.CreateANewFactPattern());
    final ListBox types = new ListBox();
    for (int i = 0; i < oracle.getFactTypes().length; i++) {
        types.addItem(oracle.getFactTypes()[i]);
    }/*  ww w  .j a  v a2  s  .com*/
    pop.addAttribute(Constants.INSTANCE.FactType(), types);
    final TextBox binding = new BindingTextBox();
    binding.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {
            binding.setText(binding.getText().replace(" ", ""));
        }
    });
    pop.addAttribute(Constants.INSTANCE.Binding(), binding);

    //Patterns can be negated, i.e. "not Pattern(...)"
    final CheckBox chkNegated = new CheckBox();
    chkNegated.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            boolean isPatternNegated = chkNegated.getValue();
            binding.setEnabled(!isPatternNegated);
        }

    });
    pop.addAttribute(Constants.INSTANCE.negatePattern(), chkNegated);

    Button ok = new Button(Constants.INSTANCE.OK());
    ok.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent w) {

            boolean isPatternNegated = chkNegated.getValue();
            String ft = types.getItemText(types.getSelectedIndex());
            String fn = isPatternNegated ? "" : binding.getText();
            if (!isPatternNegated) {
                if (fn.equals("")) {
                    Window.alert(Constants.INSTANCE.PleaseEnterANameForFact());
                    return;
                } else if (fn.equals(ft)) {
                    Window.alert(Constants.INSTANCE.PleaseEnterANameThatIsNotTheSameAsTheFactType());
                    return;
                } else if (!isBindingUnique(fn)) {
                    Window.alert(Constants.INSTANCE.PleaseEnterANameThatIsNotAlreadyUsedByAnotherPattern());
                    return;
                }
            }

            //Create new pattern
            editingPattern = new Pattern52();
            editingPattern.setFactType(ft);
            editingPattern.setBoundName(fn);
            editingPattern.setNegated(isPatternNegated);

            //Clear Field and Operator when pattern changes
            editingCol.setFactField(null);
            editingCol.setOperator(null);

            //Set-up UI
            entryPointName.setText(editingPattern.getEntryPointName());
            cwo.selectItem(editingPattern.getWindow().getOperator());
            makeLimitedValueWidget();
            makeDefaultValueWidget();
            displayCEPOperators();
            doPatternLabel();
            doValueList();
            doCalculationType();
            doOperatorLabel();

            pop.hide();
        }
    });
    pop.addAttribute("", ok);

    pop.show();

}

From source file:org.kie.guvnor.guided.dtable.client.widget.GuidedDecisionTableWidget.java

License:Apache License

private Widget newColumn() {
    AddButton addButton = new AddButton();
    addButton.setText(Constants.INSTANCE.NewColumn());
    addButton.setTitle(Constants.INSTANCE.AddNewColumn());

    addButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent w) {
            final FormStylePopup pop = new FormStylePopup();
            pop.setModal(false);/* w ww.j ava 2s . c  o  m*/

            //List of basic column types
            final ListBox choice = new ListBox();
            choice.setVisibleItemCount(NewColumnTypes.values().length);

            choice.addItem(Constants.INSTANCE.AddNewMetadataOrAttributeColumn(),
                    NewColumnTypes.METADATA_ATTRIBUTE.name());
            choice.addItem(SECTION_SEPARATOR);
            choice.addItem(Constants.INSTANCE.AddNewConditionSimpleColumn(),
                    NewColumnTypes.CONDITION_SIMPLE.name());
            choice.addItem(SECTION_SEPARATOR);
            choice.addItem(Constants.INSTANCE.SetTheValueOfAField(),
                    NewColumnTypes.ACTION_UPDATE_FACT_FIELD.name());
            choice.addItem(Constants.INSTANCE.SetTheValueOfAFieldOnANewFact(),
                    NewColumnTypes.ACTION_INSERT_FACT_FIELD.name());
            choice.addItem(Constants.INSTANCE.RetractAnExistingFact(),
                    NewColumnTypes.ACTION_RETRACT_FACT.name());

            //Checkbox to include Advanced Action types
            final CheckBox chkIncludeAdvancedOptions = new CheckBox(
                    SafeHtmlUtils.fromString(Constants.INSTANCE.IncludeAdvancedOptions()));
            chkIncludeAdvancedOptions.setValue(false);
            chkIncludeAdvancedOptions.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    if (chkIncludeAdvancedOptions.getValue()) {
                        addItem(3, Constants.INSTANCE.AddNewConditionBRLFragment(),
                                NewColumnTypes.CONDITION_BRL_FRAGMENT.name());
                        addItem(Constants.INSTANCE.WorkItemAction(), NewColumnTypes.ACTION_WORKITEM.name());
                        addItem(Constants.INSTANCE.WorkItemActionSetField(),
                                NewColumnTypes.ACTION_WORKITEM_UPDATE_FACT_FIELD.name());
                        addItem(Constants.INSTANCE.WorkItemActionInsertFact(),
                                NewColumnTypes.ACTION_WORKITEM_INSERT_FACT_FIELD.name());
                        addItem(Constants.INSTANCE.AddNewActionBRLFragment(),
                                NewColumnTypes.ACTION_BRL_FRAGMENT.name());
                    } else {
                        removeItem(NewColumnTypes.CONDITION_BRL_FRAGMENT.name());
                        removeItem(NewColumnTypes.ACTION_WORKITEM.name());
                        removeItem(NewColumnTypes.ACTION_WORKITEM_UPDATE_FACT_FIELD.name());
                        removeItem(NewColumnTypes.ACTION_WORKITEM_INSERT_FACT_FIELD.name());
                        removeItem(NewColumnTypes.ACTION_BRL_FRAGMENT.name());
                    }
                    pop.center();
                }

                private void addItem(int index, String item, String value) {
                    for (int itemIndex = 0; itemIndex < choice.getItemCount(); itemIndex++) {
                        if (choice.getValue(itemIndex).equals(value)) {
                            return;
                        }
                    }
                    choice.insertItem(item, value, index);
                }

                private void addItem(String item, String value) {
                    for (int itemIndex = 0; itemIndex < choice.getItemCount(); itemIndex++) {
                        if (choice.getValue(itemIndex).equals(value)) {
                            return;
                        }
                    }
                    choice.addItem(item, value);
                }

                private void removeItem(String value) {
                    for (int itemIndex = 0; itemIndex < choice.getItemCount(); itemIndex++) {
                        if (choice.getValue(itemIndex).equals(value)) {
                            choice.removeItem(itemIndex);
                            break;
                        }
                    }
                }

            });

            //OK button to create column
            final Button ok = new Button(Constants.INSTANCE.OK());
            ok.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent w) {
                    String s = choice.getValue(choice.getSelectedIndex());
                    if (s.equals(NewColumnTypes.METADATA_ATTRIBUTE.name())) {
                        showMetaDataAndAttribute();
                    } else if (s.equals(NewColumnTypes.CONDITION_SIMPLE.name())) {
                        showConditionSimple();
                    } else if (s.equals(NewColumnTypes.CONDITION_BRL_FRAGMENT.name())) {
                        showConditionBRLFragment();
                    } else if (s.equals(NewColumnTypes.ACTION_UPDATE_FACT_FIELD.name())) {
                        showActionSet();
                    } else if (s.equals(NewColumnTypes.ACTION_INSERT_FACT_FIELD.name())) {
                        showActionInsert();
                    } else if (s.equals(NewColumnTypes.ACTION_RETRACT_FACT.name())) {
                        showActionRetract();
                    } else if (s.equals(NewColumnTypes.ACTION_WORKITEM.name())) {
                        showActionWorkItemAction();
                    } else if (s.equals(NewColumnTypes.ACTION_WORKITEM_UPDATE_FACT_FIELD.name())) {
                        showActionWorkItemActionSet();
                    } else if (s.equals(NewColumnTypes.ACTION_WORKITEM_INSERT_FACT_FIELD.name())) {
                        showActionWorkItemActionInsert();
                    } else if (s.equals(NewColumnTypes.ACTION_BRL_FRAGMENT.name())) {
                        showActionBRLFragment();
                    }
                    pop.hide();
                }

                private void showMetaDataAndAttribute() {
                    // show choice of attributes
                    final Image image = ImageResources508.INSTANCE.Config();
                    final FormStylePopup pop = new FormStylePopup(image,
                            Constants.INSTANCE.AddAnOptionToTheRule());
                    final ListBox list = RuleAttributeWidget.getAttributeList();

                    //This attribute is only used for Decision Tables
                    list.addItem(GuidedDecisionTable52.NEGATE_RULE_ATTR);

                    // Remove any attributes already added
                    for (AttributeCol52 col : model.getAttributeCols()) {
                        for (int iItem = 0; iItem < list.getItemCount(); iItem++) {
                            if (list.getItemText(iItem).equals(col.getAttribute())) {
                                list.removeItem(iItem);
                                break;
                            }
                        }
                    }

                    final Image addbutton = ImageResources508.INSTANCE.NewItem();
                    final TextBox box = new TextBox();
                    box.setVisibleLength(15);

                    list.setSelectedIndex(0);

                    list.addChangeHandler(new ChangeHandler() {
                        public void onChange(ChangeEvent event) {
                            AttributeCol52 attr = new AttributeCol52();
                            attr.setAttribute(list.getItemText(list.getSelectedIndex()));
                            dtable.addColumn(attr);
                            refreshAttributeWidget();
                            pop.hide();
                        }
                    });

                    addbutton.setTitle(Constants.INSTANCE.AddMetadataToTheRule());

                    addbutton.addClickHandler(new ClickHandler() {
                        public void onClick(ClickEvent w) {

                            String metadata = box.getText();
                            if (!isUnique(metadata)) {
                                Window.alert(
                                        Constants.INSTANCE.ThatColumnNameIsAlreadyInUsePleasePickAnother());
                                return;
                            }
                            MetadataCol52 met = new MetadataCol52();
                            met.setHideColumn(true);
                            met.setMetadata(metadata);
                            dtable.addColumn(met);
                            refreshAttributeWidget();
                            pop.hide();
                        }

                        private boolean isUnique(String metadata) {
                            for (MetadataCol52 mc : model.getMetadataCols()) {
                                if (metadata.equals(mc.getMetadata())) {
                                    return false;
                                }
                            }
                            return true;
                        }

                    });
                    DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
                    horiz.add(box);
                    horiz.add(addbutton);

                    pop.addAttribute(Constants.INSTANCE.Metadata1(), horiz);
                    pop.addAttribute(Constants.INSTANCE.Attribute(), list);
                    pop.show();
                }

                private void showConditionSimple() {
                    final ConditionCol52 column = makeNewConditionColumn();
                    ConditionPopup dialog = new ConditionPopup(oracle, model, new ConditionColumnCommand() {
                        public void execute(Pattern52 pattern, ConditionCol52 column) {

                            //Update UI
                            dtable.addColumn(pattern, column);
                            refreshConditionsWidget();
                        }
                    }, column, true, isReadOnly);
                    dialog.show();
                }

                private void showConditionBRLFragment() {
                    final BRLConditionColumn column = makeNewConditionBRLFragment();
                    switch (model.getTableFormat()) {
                    case EXTENDED_ENTRY:
                        BRLConditionColumnViewImpl popup = new BRLConditionColumnViewImpl(path, oracle, model,
                                column, eventBus, true, isReadOnly);
                        popup.setPresenter(BRL_CONDITION_PRESENTER);
                        popup.show();
                        break;
                    case LIMITED_ENTRY:
                        LimitedEntryBRLConditionColumnViewImpl limtedEntryPopup = new LimitedEntryBRLConditionColumnViewImpl(
                                path, oracle, model, (LimitedEntryBRLConditionColumn) column, eventBus, true,
                                isReadOnly);
                        limtedEntryPopup.setPresenter(LIMITED_ENTRY_BRL_CONDITION_PRESENTER);
                        limtedEntryPopup.show();
                        break;
                    }
                }

                private void showActionInsert() {
                    final ActionInsertFactCol52 afc = makeNewActionInsertColumn();
                    ActionInsertFactPopup ins = new ActionInsertFactPopup(oracle, model,
                            new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, afc, true, isReadOnly);
                    ins.show();
                }

                private void showActionSet() {
                    final ActionSetFieldCol52 afc = makeNewActionSetColumn();
                    ActionSetFieldPopup set = new ActionSetFieldPopup(oracle, model,
                            new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, afc, true, isReadOnly);
                    set.show();
                }

                private void showActionRetract() {
                    final ActionRetractFactCol52 arf = makeNewActionRetractFact();
                    ActionRetractFactPopup popup = new ActionRetractFactPopup(model,
                            new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, arf, true, isReadOnly);
                    popup.show();
                }

                private void showActionWorkItemAction() {
                    final ActionWorkItemCol52 awi = makeNewActionWorkItem();
                    ActionWorkItemPopup popup = new ActionWorkItemPopup(path, model,
                            GuidedDecisionTableWidget.this, new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, awi, true, isReadOnly);
                    popup.show();
                }

                private void showActionWorkItemActionSet() {
                    final ActionWorkItemSetFieldCol52 awisf = makeNewActionWorkItemSetField();
                    ActionWorkItemSetFieldPopup popup = new ActionWorkItemSetFieldPopup(oracle, model,
                            new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, awisf, true, isReadOnly);
                    popup.show();
                }

                private void showActionWorkItemActionInsert() {
                    final ActionWorkItemInsertFactCol52 awiif = makeNewActionWorkItemInsertFact();
                    ActionWorkItemInsertFactPopup popup = new ActionWorkItemInsertFactPopup(oracle, model,
                            new GenericColumnCommand() {
                                public void execute(DTColumnConfig52 column) {
                                    newActionAdded((ActionCol52) column);
                                }
                            }, awiif, true, isReadOnly);
                    popup.show();
                }

                private void showActionBRLFragment() {
                    final BRLActionColumn column = makeNewActionBRLFragment();
                    switch (model.getTableFormat()) {
                    case EXTENDED_ENTRY:
                        BRLActionColumnViewImpl popup = new BRLActionColumnViewImpl(path, oracle, model, column,
                                eventBus, true, isReadOnly);
                        popup.setPresenter(BRL_ACTION_PRESENTER);
                        popup.show();
                        break;
                    case LIMITED_ENTRY:
                        LimitedEntryBRLActionColumnViewImpl limtedEntryPopup = new LimitedEntryBRLActionColumnViewImpl(
                                path, oracle, model, (LimitedEntryBRLActionColumn) column, eventBus, true,
                                isReadOnly);
                        limtedEntryPopup.setPresenter(LIMITED_ENTRY_BRL_ACTION_PRESENTER);
                        limtedEntryPopup.show();
                        break;
                    }

                }

                private void newActionAdded(ActionCol52 column) {
                    dtable.addColumn(column);
                    refreshActionsWidget();
                }
            });

            //If a separator is clicked disable OK button
            choice.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    int itemIndex = choice.getSelectedIndex();
                    if (itemIndex < 0) {
                        return;
                    }
                    ok.setEnabled(!choice.getValue(itemIndex).equals(SECTION_SEPARATOR));
                }

            });

            pop.setTitle(Constants.INSTANCE.AddNewColumn());
            pop.addAttribute(Constants.INSTANCE.TypeOfColumn(), choice);
            pop.addAttribute("", chkIncludeAdvancedOptions);
            pop.addAttribute("", ok);
            pop.show();
        }

        private ConditionCol52 makeNewConditionColumn() {
            switch (model.getTableFormat()) {
            case LIMITED_ENTRY:
                return new LimitedEntryConditionCol52();
            default:
                return new ConditionCol52();
            }
        }

        private ActionInsertFactCol52 makeNewActionInsertColumn() {
            switch (model.getTableFormat()) {
            case LIMITED_ENTRY:
                return new LimitedEntryActionInsertFactCol52();
            default:
                return new ActionInsertFactCol52();
            }
        }

        private ActionSetFieldCol52 makeNewActionSetColumn() {
            switch (model.getTableFormat()) {
            case LIMITED_ENTRY:
                return new LimitedEntryActionSetFieldCol52();
            default:
                return new ActionSetFieldCol52();
            }
        }

        private ActionRetractFactCol52 makeNewActionRetractFact() {
            switch (model.getTableFormat()) {
            case LIMITED_ENTRY:
                LimitedEntryActionRetractFactCol52 ler = new LimitedEntryActionRetractFactCol52();
                ler.setValue(new DTCellValue52(""));
                return ler;
            default:
                return new ActionRetractFactCol52();
            }
        }

        private ActionWorkItemCol52 makeNewActionWorkItem() {
            //WorkItems are defined within the column and always boolean (i.e. Limited Entry) in the table
            return new ActionWorkItemCol52();
        }

        private ActionWorkItemSetFieldCol52 makeNewActionWorkItemSetField() {
            //Actions setting Field Values from Work Item Result Parameters are always boolean (i.e. Limited Entry) in the table
            return new ActionWorkItemSetFieldCol52();
        }

        private ActionWorkItemInsertFactCol52 makeNewActionWorkItemInsertFact() {
            //Actions setting Field Values from Work Item Result Parameters are always boolean (i.e. Limited Entry) in the table
            return new ActionWorkItemInsertFactCol52();
        }

        private BRLActionColumn makeNewActionBRLFragment() {
            switch (model.getTableFormat()) {
            case LIMITED_ENTRY:
                return new LimitedEntryBRLActionColumn();
            default:
                return new BRLActionColumn();
            }
        }

        private BRLConditionColumn makeNewConditionBRLFragment() {
            switch (model.getTableFormat()) {
            case LIMITED_ENTRY:
                return new LimitedEntryBRLConditionColumn();
            default:
                return new BRLConditionColumn();
            }
        }

    });

    return addButton;
}

From source file:org.kie.guvnor.guided.dtable.client.widget.GuidedDecisionTableWidget.java

License:Apache License

private void refreshAttributeWidget() {
    this.attributeConfigWidget.clear();
    if (model.getMetadataCols().size() > 0) {
        HorizontalPanel hp = new HorizontalPanel();
        hp.add(new HTML("&nbsp;&nbsp;"));
        hp.add(new SmallLabel(Constants.INSTANCE.Metadata1()));
        attributeConfigWidget.add(hp);/*from www  . ja va  2  s.  c om*/
    }
    for (MetadataCol52 atc : model.getMetadataCols()) {
        HorizontalPanel hp = new HorizontalPanel();
        hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
        hp.add(new HTML("&nbsp;&nbsp;&nbsp;&nbsp;"));
        if (!isReadOnly) {
            hp.add(removeMeta(atc));
        }
        final SmallLabel label = makeColumnLabel(atc);
        hp.add(label);

        final MetadataCol52 at = atc;
        final CheckBox hide = new CheckBox(Constants.INSTANCE.HideThisColumn());
        hide.setStyleName("form-field");
        hide.setValue(atc.isHideColumn());
        hide.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent sender) {
                at.setHideColumn(hide.getValue());
                dtable.setColumnVisibility(at, !at.isHideColumn());
                setColumnLabelStyleWhenHidden(label, hide.getValue());
            }
        });
        hp.add(new HTML("&nbsp;&nbsp;"));
        hp.add(hide);

        attributeConfigWidget.add(hp);
    }
    if (model.getAttributeCols().size() > 0) {
        HorizontalPanel hp = new HorizontalPanel();
        hp.add(new HTML("&nbsp;&nbsp;"));
        hp.add(new SmallLabel(Constants.INSTANCE.Attributes()));
        attributeConfigWidget.add(hp);
    }

    for (AttributeCol52 atc : model.getAttributeCols()) {
        final AttributeCol52 at = atc;
        HorizontalPanel hp = new HorizontalPanel();
        hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

        hp.add(new HTML("&nbsp;&nbsp;&nbsp;&nbsp;"));
        if (!isReadOnly) {
            hp.add(removeAttr(at));
        }
        final SmallLabel label = makeColumnLabel(atc);
        hp.add(label);

        final TextBox defaultValue = new TextBox();
        final DTCellValue52 dcv = at.getDefaultValue();
        defaultValue.setStyleName("form-field");
        defaultValue.setText((dcv == null ? "" : dcv.getStringValue()));
        defaultValue.setEnabled(!isReadOnly);
        defaultValue.addChangeHandler(new ChangeHandler() {
            public void onChange(ChangeEvent event) {
                at.setDefaultValue(new DTCellValue52(defaultValue.getText()));
            }
        });

        if (at.getAttribute().equals(RuleAttributeWidget.SALIENCE_ATTR)) {
            hp.add(new HTML("&nbsp;&nbsp;"));
            final CheckBox useRowNumber = new CheckBox(Constants.INSTANCE.UseRowNumber());
            useRowNumber.setStyleName("form-field");
            useRowNumber.setValue(at.isUseRowNumber());
            useRowNumber.setEnabled(!isReadOnly);
            hp.add(useRowNumber);

            hp.add(new SmallLabel("("));
            final CheckBox reverseOrder = new CheckBox(Constants.INSTANCE.ReverseOrder());
            reverseOrder.setStyleName("form-field");
            reverseOrder.setValue(at.isReverseOrder());
            reverseOrder.setEnabled(at.isUseRowNumber() && !isReadOnly);

            useRowNumber.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent sender) {
                    at.setUseRowNumber(useRowNumber.getValue());
                    reverseOrder.setEnabled(useRowNumber.getValue());
                    dtable.updateSystemControlledColumnValues();
                }
            });

            reverseOrder.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent sender) {
                    at.setReverseOrder(reverseOrder.getValue());
                    dtable.updateSystemControlledColumnValues();
                }
            });
            hp.add(reverseOrder);
            hp.add(new SmallLabel(")"));
        }
        hp.add(new HTML("&nbsp;&nbsp;"));
        hp.add(new SmallLabel(Constants.INSTANCE.DefaultValue()));
        hp.add(defaultValue);

        final CheckBox hide = new CheckBox(Constants.INSTANCE.HideThisColumn());
        hide.setStyleName("form-field");
        hide.setValue(at.isHideColumn());
        hide.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent sender) {
                at.setHideColumn(hide.getValue());
                dtable.setColumnVisibility(at, !at.isHideColumn());
                setColumnLabelStyleWhenHidden(label, hide.getValue());
            }
        });
        hp.add(new HTML("&nbsp;&nbsp;"));
        hp.add(hide);

        attributeConfigWidget.add(hp);
        setupColumnsNote();
    }

}

From source file:org.kie.guvnor.guided.rule.client.editor.RuleAttributeWidget.java

License:Apache License

private Widget checkBoxEditor(final RuleAttribute at, final boolean isReadOnly) {
    final CheckBox box = new CheckBox();
    box.setEnabled(!isReadOnly);/*ww  w .j a  v  a  2  s.  c o  m*/
    if (at.getValue() == null) {
        box.setValue(true);
        at.setValue(TRUE_VALUE);
    } else {
        box.setValue((at.getValue().equals(TRUE_VALUE)));
    }

    box.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            at.setValue((box.getValue()) ? TRUE_VALUE : FALSE_VALUE);
        }
    });
    return box;
}

From source file:org.kie.guvnor.metadata.client.widget.MetadataWidget.java

License:Apache License

/**
 * This binds a field, and returns a check box editor for it.
 * @param bind Interface to bind to./*w  w w. j a va2 s.  c  o  m*/
 * @param toolTip tool tip.
 * @return
 */
private Widget editableBoolean(final FieldBooleanBinding bind, final String toolTip) {
    if (!readOnly) {
        final CheckBox box = new CheckBox();
        box.setTitle(toolTip);
        box.setValue(bind.getValue());
        box.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent w) {
                boolean b = box.getValue();
                bind.setValue(b);
            }
        });
        return box;
    } else {
        final CheckBox box = new CheckBox();

        box.setValue(bind.getValue());
        box.setEnabled(false);

        return box;
    }
}

From source file:org.onebusaway.webapp.gwt.oba_application.view.ResultsFilterPresenter.java

License:Apache License

private void buildMinimizedWidget() {
    _widget.add(new SpanWidget("Categories:", "ResultsFilter-Label"));

    for (int i = 0; i < Math.min(3, _categories.size()); i++) {
        SpanPanel panel = new SpanPanel();

        final String categoryName = _categories.get(i);

        final CheckBox box = new CheckBox();
        box.addStyleName(_css.ResultsFilterButton());
        box.setText(categoryName);/*from   w ww.  j a  v a  2s .c  o m*/
        box.setValue(_activeCategories.contains(categoryName));
        box.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent arg0) {

                boolean update = false;

                if (box.getValue())
                    update = _activeCategories.add(categoryName);
                else
                    update = _activeCategories.remove(categoryName);

                if (update) {
                    refreshFilter();
                }
            }

        });
        panel.add(box);

        _widget.add(panel);
    }
}

From source file:org.onebusaway.webapp.gwt.oba_application.view.ResultsFilterPresenter.java

License:Apache License

private void buildMaxmizedWidget() {
    _widget.add(new SpanWidget("Categories:", "ResultsFilter-Label"));

    for (int i = 0; i < Math.min(3, _categories.size()); i++) {
        SpanPanel panel = new SpanPanel();

        final String categoryName = _categories.get(i);

        final CheckBox box = new CheckBox();
        box.addStyleName(_css.ResultsFilterButton());
        box.setText(categoryName);/*from w  w w.  j a v  a  2s.c  o  m*/
        box.setValue(_activeCategories.contains(categoryName));
        box.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent arg0) {

                boolean update = false;
                if (box.getValue())
                    update = _activeCategories.add(categoryName);
                else
                    update = _activeCategories.remove(categoryName);

                if (update) {
                    refreshFilter();
                }
            }

        });
        panel.add(box);

        _widget.add(panel);
    }
}

From source file:org.openintents.safecloud.client.view.CategoryListView.java

License:Apache License

@Override
public List<Integer> getSelectedRows() {
    List<Integer> selectedRows = new ArrayList<Integer>();

    for (int i = 0; i < categoriesTable.getRowCount(); ++i) {
        CheckBox checkBox = (CheckBox) categoriesTable.getWidget(i, 0);
        if (checkBox.getValue()) {
            selectedRows.add(i);/*  w w  w  .j  ava2 s .  c o m*/
        }
    }

    return selectedRows;
}

From source file:org.opennms.features.node.list.gwt.client.ErrorDialogBox.java

License:Open Source License

private Widget createWidget() {
    m_errorLabel.setText("hello");
    Button ok = new Button("OK");
    ok.addClickHandler(new ClickHandler() {
        @Override//  ww w .  j  a  v a  2 s.c om
        public void onClick(ClickEvent event) {
            ErrorDialogBox.this.hide();
        }
    });

    final CheckBox check = new CheckBox();
    check.setText("Don't show again for 24hours");
    check.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (check.getValue()) {
                Cookies.setCookie(PageableNodeList.COOKIE, "true", new Date(new Date().getTime() + 86400000));
            }

        }
    });

    m_layoutPanel = new DockLayoutPanel(Unit.EM);
    m_layoutPanel.setWidth("100%");
    m_layoutPanel.setHeight("125px");

    m_caption.getElement().getStyle().setBackgroundColor("#ebebeb");
    m_caption.setText("Error");
    m_layoutPanel.addNorth(m_caption, 2);
    m_layoutPanel.addSouth(ok, 2);
    m_layoutPanel.addSouth(check, 2);

    m_layoutPanel.add(m_errorLabel);
    return m_layoutPanel;
}

From source file:org.opennms.features.poller.remote.gwt.client.DefaultApplicationView.java

License:Open Source License

@Override
public Set<Status> getSelectedStatuses() {

    Set<Status> statuses = new HashSet<Status>();
    for (final Widget w : getStatusesPanel()) {
        if (w instanceof CheckBox) {
            final CheckBox cb = (CheckBox) w;
            if (cb.getValue()) {
                statuses.add(Status.valueOf(cb.getFormValue()));
            }//  ww w . j a  v a2  s.c om
        }
    }
    return statuses;
}