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

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

Introduction

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

Prototype

@Override
    public void setEnabled(boolean enabled) 

Source Link

Usage

From source file:org.cruxframework.crux.widgets.client.grid.Grid.java

License:Apache License

/**
 * Enables edit mode for given row/*from   www.  j  a v  a 2s  .c  o  m*/
 * @param row
 * @param focusCell
 */
public void makeEditable(DataRow row, Cell focusCell) {
    if (!row.isEditMode()) {
        if (currentEditingRow != null) {
            currentEditingRow.setEditMode(false);
        }

        deselectAllRows();
        row.setSelected(true);
        originalRecord = getDataSource().cloneDTO(row.getDataSourceRecord());
        swapCurrentEditingRow(row);
        CheckBox selector = (CheckBox) row.getCell(0).getCellWidget();
        selector.setEnabled(false);

        String focusCellKey = null;

        if (focusCell != null) {
            FastList<ColumnDefinition> defs = getColumnDefinitions().getDefinitions();
            for (int i = 0; i < defs.size(); i++) {
                ColumnDefinition def = defs.get(i);
                String key = def.getKey();
                Cell cell = row.getCell(key);
                if (focusCell.equals(cell)) {
                    focusCellKey = key;
                    break;
                }
            }
        }

        row.setEditMode(true);
        fireBeforeRowEditEvent(row);
        disableRows();
        renderRow(row, row.getDataSourceRecord(), row.isEditMode(), focusCellKey);

        //If event was cancelled
        if (!row.isEditMode()) {
            enableRows();
        } else if (showEditorButtons) {
            startEditingButtons(row);
            fireRowEditingEvent(row);
        }
    }
}

From source file:org.cruxframework.crux.widgets.client.grid.Row.java

License:Apache License

/**
 * @param enabled the enabled to set//  w w w  . j a  v  a  2s.c o m
 */
public void setEnabled(boolean enabled) {
    if (hasSelectionCell) {
        CheckBox selector = (CheckBox) getCell(0).getCellWidget();
        selector.setEnabled(enabled);
    }

    if (showRowDetailsIcon) {
        Button button = (Button) getCell(hasSelectionCell ? 1 : 0).getCellWidget();
        button.setEnabled(enabled);
    }

    if (!enabled) {
        addStyleDependentName("disabled");
    } else {
        removeStyleDependentName("disabled");
    }

    this.enabled = enabled;
}

From source file:org.cruxframework.crux.widgets.client.grid.Row.java

License:Apache License

public void setRowSelectorEnabled(boolean enabled) {
    if (hasSelectionCell) {
        CheckBox selector = (CheckBox) getCell(0).getCellWidget();
        selector.setEnabled(enabled);
    }//from   ww  w  .j  a  v a  2s.co m

    removeStyleDependentName("disabled");
}

From source file:org.drools.guvnor.client.decisiontable.ActionInsertFactPopup.java

License:Apache License

private Widget doInsertLogical() {
    HorizontalPanel hp = new HorizontalPanel();

    final CheckBox cb = new CheckBox();
    cb.setValue(editingCol.isInsertLogical());
    cb.setText("");
    cb.setEnabled(!isReadOnly);
    if (!isReadOnly) {
        cb.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent arg0) {
                if (sce.isGlobalVariable(editingCol.getBoundName())) {
                    cb.setEnabled(false);
                    editingCol.setInsertLogical(false);
                } else {
                    editingCol.setInsertLogical(cb.getValue());
                }//from   w  ww .  j  a  va 2 s .c om
            }
        });
    }
    hp.add(cb);
    hp.add(new InfoPopup(Constants.INSTANCE.LogicallyInsertANewFact(),
            Constants.INSTANCE.LogicallyAssertAFactTheFactWillBeRetractedWhenTheSupportingEvidenceIsRemoved()));
    return hp;
}

From source file:org.drools.guvnor.client.decisiontable.ActionSetFieldPopup.java

License:Apache License

private Widget doUpdate() {
    HorizontalPanel hp = new HorizontalPanel();

    final CheckBox cb = new CheckBox();
    cb.setValue(editingCol.isUpdate());//from   w w  w  . java2  s  .  co  m
    cb.setText("");
    cb.setEnabled(!isReadOnly);
    if (!isReadOnly) {
        cb.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent arg0) {
                if (sce.isGlobalVariable(editingCol.getBoundName())) {
                    cb.setEnabled(false);
                    editingCol.setUpdate(false);
                } else {
                    editingCol.setUpdate(cb.getValue());
                }
            }
        });
    }
    hp.add(cb);
    hp.add(new InfoPopup(Constants.INSTANCE.UpdateFact(), Constants.INSTANCE.UpdateDescription()));
    return hp;
}

From source file:org.drools.guvnor.client.decisiontable.GuidedDecisionTableWidget.java

License:Apache License

private void refreshAttributeWidget() {
    this.attributeConfigWidget.clear();
    if (guidedDecisionTable.getMetadataCols().size() > 0) {
        HorizontalPanel hp = new HorizontalPanel();
        hp.add(new HTML("&nbsp;&nbsp;"));
        hp.add(new SmallLabel(Constants.INSTANCE.Metadata1()));
        attributeConfigWidget.add(hp);/*from w w  w . ja  v  a  2s  .  c  o  m*/
    }
    for (MetadataCol52 atc : guidedDecisionTable.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 (guidedDecisionTable.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 : guidedDecisionTable.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.drools.guvnor.client.ruleeditor.MetaDataWidget.java

License:Apache License

/**
 * This binds a field, and returns a check box editor for it.
 *
 * @param bind Interface to bind to./* www. j  ava 2 s. co m*/
 * @param toolTip tool tip.
 * @return
 */
private Widget editableBoolean(final FieldBooleanBinding bind, String toolTip) {
    if (!readOnly) {
        final CheckBox box = new CheckBox();
        box.setTitle(toolTip);
        box.setChecked(bind.getValue());
        ClickListener listener = new ClickListener() {
            public void onClick(Widget w) {
                boolean b = box.isChecked();
                bind.setValue(b);
            }
        };
        box.addClickListener(listener);
        return box;
    } else {
        final CheckBox box = new CheckBox();

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

        return box;
    }
}

From source file:org.drools.guvnor.client.ruleeditor.MetaDataWidgetNew.java

License:Apache License

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

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

        return box;
    }
}

From source file:org.ebayopensource.turmeric.policy.adminui.client.view.policy.RLPolicyCreateView.java

License:Open Source License

protected void initializeExtraFields() {
    rlExtraFields = PolicyExtraFieldsUtil.getRLExtraFields();

    extraFieldsGrid = new Grid(rlExtraFields.size() + 1, 3);

    for (ExtraField extraField : rlExtraFields) {

        extraFieldsGrid.setWidget(extraField.getOrder(), 0, new Label(extraField.getLabelName()));

        if (extraField.getFieldType() != null && "CheckBox".equalsIgnoreCase(extraField.getFieldType())) {
            CheckBox chBox = new CheckBox();
            chBox.setEnabled(true);
            extraField.setCheckBox(chBox);
            extraFieldsGrid.setWidget(extraField.getOrder(), 1, extraField.getCheckBox());

        } else if (extraField.getFieldType() != null && "TextBox".equalsIgnoreCase(extraField.getFieldType())) {
            TextBox txBox = new TextBox();
            txBox.setText("");
            txBox.setWidth(extraField.getLenghtBox());
            extraField.setTextBox(txBox);
            extraFieldsGrid.setWidget(extraField.getOrder(), 1, extraField.getTextBox());

        } else if (extraField.getFieldType() != null
                && "TextArea".equalsIgnoreCase(extraField.getFieldType())) {
            TextArea txArea = new TextArea();
            txArea.setText("");
            txArea.setWidth(extraField.getLenghtBox());
            //            txArea.setEnabled(false);
            extraField.setTextArea(txArea);
            extraFieldsGrid.setWidget(extraField.getOrder(), 1, extraField.getTextArea());

        } else if (extraField.getFieldType() != null && "ListBox".equalsIgnoreCase(extraField.getFieldType())) {
            ListBox lsBox = new ListBox();
            for (int i = 0; i < extraField.getListBox().getItemCount(); i++) {
                lsBox.addItem(extraField.getListBox().getItemText(i));
            }/*  www  . j a  v  a 2 s. co m*/
            extraField.setListBox(lsBox);
            extraFieldsGrid.setWidget(extraField.getOrder(), 1, extraField.getListBox());

        }
    }
}

From source file:org.ednovo.gooru.client.mvp.home.SearchHomeFilterVc.java

License:Open Source License

/**
 * set enabled or disabled for for filters
 * @param filterFlowPanel selected filter panel
 * @param checkedValues selected filter values 
 *//* w w  w  . j  a v a2s. com*/
private void setSelectedFilter(FlowPanel filterFlowPanel, String checkedValues) {
    List<String> items = Arrays.asList(checkedValues.split("\\s*,\\s*"));
    for (Widget filterWidget : filterFlowPanel) {
        if (filterWidget instanceof CheckBox) {
            CheckBox filterCheckBox = (CheckBox) filterWidget;
            for (String item : items) {
                if (filterCheckBox != null && (filterCheckBox.getValue().equals(item))) {
                    filterCheckBox.setEnabled(true);
                }
            }
        }
    }
}