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.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("  "));
        hp.add(new SmallLabel(Constants.INSTANCE.Metadata1()));
        attributeConfigWidget.add(hp);// ww  w .j  a va 2 s  .com
    }
    for (MetadataCol52 atc : model.getMetadataCols()) {
        HorizontalPanel hp = new HorizontalPanel();
        hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
        hp.add(new HTML("    "));
        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("  "));
        hp.add(hide);

        attributeConfigWidget.add(hp);
    }
    if (model.getAttributeCols().size() > 0) {
        HorizontalPanel hp = new HorizontalPanel();
        hp.add(new HTML("  "));
        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("    "));
        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("  "));
            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("  "));
        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("  "));
        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);
    if (at.getValue() == null) {
        box.setValue(true);/*from   ww w.  j  a v a2  s .  c  om*/
        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 ww  .  java 2  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.onesocialweb.gwt.client.ui.widget.ListSelector.java

License:Apache License

public void addCheckbox(String list, Boolean value) {

    final CheckBox checkbox = new CheckBox(list);
    StyledFlowPanel fix = new StyledFlowPanel("fix");
    checkbox.addStyleName("checkbox");

    // manage checks and unchecks
    checkbox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override// w ww.  j av a2s .c  om
        public void onValueChange(ValueChangeEvent<Boolean> event) {

            // is the item is checked?
            if (event.getValue() == true && !listed.contains(checkbox.getText()) && checkbox.getText() != null
                    && checkbox.getText().length() != 0) {
                // set the values
                listed.add(checkbox.getText());
                rosterItem.setGroups(listed);
                // disable during processing
                checkbox.setEnabled(false);

                // show task
                final DefaultTaskInfo task = new DefaultTaskInfo("Adding person to the list", false);
                TaskMonitor.getInstance().addTask(task);

                // save new state
                rosterItem.save(new RequestCallback<RosterItem>() {

                    @Override
                    public void onFailure() {
                        // return to original state and notify user
                        checkbox.setEnabled(true);
                        checkbox.setValue(true);
                        task.complete("Could not add person to list.", Status.failure);
                    }

                    @Override
                    public void onSuccess(RosterItem result) {
                        // enable the checkbox again
                        checkbox.setEnabled(true);
                        task.complete("", Status.succes);
                    }

                });
            } else if (event.getValue() == false && listed.contains(checkbox.getText())) {
                // set the values
                listed.remove(checkbox.getText());
                rosterItem.setGroups(listed);
                // disable during processing
                checkbox.setEnabled(false);

                // show task
                final DefaultTaskInfo task = new DefaultTaskInfo("Removing person from the list", false);
                TaskMonitor.getInstance().addTask(task);

                // save new state
                rosterItem.save(new RequestCallback<RosterItem>() {

                    @Override
                    public void onFailure() {
                        // return to original state and notify user
                        checkbox.setEnabled(true);
                        checkbox.setValue(true);
                        task.complete("Could not remove person from the list.", Status.failure);
                    }

                    @Override
                    public void onSuccess(RosterItem result) {
                        // enable the checkbox again
                        checkbox.setEnabled(true);
                        task.complete("", Status.succes);
                    }

                });
            }
        }

    });

    // if this person is already on the list make sure the checkbox is
    // checked
    if (listed != null && list.length() > 0 && listed.contains(list)) {
        checkbox.setValue(true);
    } else if (value == true) {
        // if a new checkbox is added automatically check it and fire a
        // change event
        checkbox.setValue(true);
        checkbox.fireEvent(new ValueChangeEvent<Boolean>(true) {
        });
    }
    if (checkbox.getText() != null && checkbox.getText().length() != 0) {
        wrapper.add(checkbox);
        wrapper.add(fix);
    }

}

From source file:org.openxdata.sharedlib.client.view.FormRunnerView.java

/**
 * @see org.openxdata.sharedlib.client.controller.QuestionChangeListener#onEnabledChanged(QuestionDef, boolean)
 *///from w ww.j a v  a2 s.c  om
public void onEnabledChanged(QuestionDef sender, boolean enabled) {
    List<CheckBox> list = checkBoxGroupMap.get(sender);
    if (list == null)
        return;

    for (CheckBox checkBox : list) {
        checkBox.setEnabled(enabled);
        if (!enabled)
            checkBox.setValue(false);
    }
}

From source file:org.openxdata.sharedlib.client.widget.RuntimeGroupWidget.java

public void onEnabledChanged(QuestionDef sender, boolean enabled) {
    List<CheckBox> list = checkBoxGroupMap.get(sender);
    if (list == null)
        return;//from w w w  . j  a  v  a  2 s  .  c o  m

    for (CheckBox checkBox : list) {
        checkBox.setEnabled(enabled);
        if (!enabled)
            checkBox.setValue(false);
    }
}

From source file:org.pentaho.mantle.client.dialogs.ImportDialog.java

License:Open Source License

/**
 * @param repositoryFile/*www .ja  va2  s. c  o m*/
 */
public ImportDialog(RepositoryFile repositoryFile, boolean allowAdvancedDialog) {
    super(Messages.getString("import"), Messages.getString("ok"), Messages.getString("cancel"), false, true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    form = new FormPanel();
    form.addSubmitHandler(new SubmitHandler() {
        @Override
        public void onSubmit(SubmitEvent se) {
            // if no file is selected then do not proceed
            okButton.setEnabled(false);
            cancelButton.setEnabled(false);
            MantleApplication.showBusyIndicator(Messages.getString("pleaseWait"),
                    Messages.getString("importInProgress"));
        }
    });
    form.addSubmitCompleteHandler(new SubmitCompleteHandler() {
        @Override
        public void onSubmitComplete(SubmitCompleteEvent sce) {
            MantleApplication.hideBusyIndicator();
            okButton.setEnabled(false);
            cancelButton.setEnabled(true);
            ImportDialog.this.hide();
            String result = sce.getResults();
            if (result.length() > 5) {
                HTML messageTextBox = null;
                if (result.contains("INVALID_MIME_TYPE") == true) {
                    messageTextBox = new HTML(Messages.getString("uploadInvalidFileTypeQuestion", result));
                } else {
                    logWindow(result, Messages.getString("importLogWindowTitle"));
                }

                if (messageTextBox != null) {
                    PromptDialogBox dialogBox = new PromptDialogBox(Messages.getString("uploadUnsuccessful"),
                            Messages.getString("close"), null, true, true);
                    dialogBox.setContent(messageTextBox);
                    dialogBox.center();
                }
            }

            // if mantle_isBrowseRepoDirty=true: do getChildren call
            // if mantle_isBrowseRepoDirty=false: use stored fileBrowserModel in myself.get("cachedData")
            setBrowseRepoDirty(Boolean.TRUE);

            // BISERVER-9319 Refresh browse perspective after import
            final GenericEvent event = new GenericEvent();
            event.setEventSubType("ImportDialogEvent");
            EventBusUtil.EVENT_BUS.fireEvent(event);
        }
    });

    VerticalPanel rootPanel = new VerticalPanel();

    VerticalPanel spacer = new VerticalPanel();
    spacer.setHeight("10px");
    rootPanel.add(spacer);

    Label fileLabel = new Label(Messages.getString("file") + ":");
    final TextBox importDir = new TextBox();
    rootPanel.add(fileLabel);

    okButton.setEnabled(false);

    final TextBox fileTextBox = new TextBox();
    fileTextBox.setEnabled(false);

    //We use an fileNameOverride because FileUpload can only handle US character set reliably.
    final Hidden fileNameOverride = new Hidden("fileNameOverride");

    final FileUpload upload = new FileUpload();
    upload.setName("fileUpload");
    ChangeHandler fileUploadHandler = new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            fileTextBox.setText(upload.getFilename());
            if (!"".equals(importDir.getValue())) {
                //Set the fileNameOverride because the fileUpload object can only reliably transmit US-ASCII
                //character set.  See RFC283 section 2.3 for details
                String fileNameValue = upload.getFilename().replaceAll("\\\\", "/");
                fileNameValue = fileNameValue.substring(fileNameValue.lastIndexOf("/") + 1);
                fileNameOverride.setValue(fileNameValue);
                okButton.setEnabled(true);
            } else {
                okButton.setEnabled(false);
            }
        }
    };
    upload.addChangeHandler(fileUploadHandler);
    upload.setVisible(false);

    HorizontalPanel fileUploadPanel = new HorizontalPanel();
    fileUploadPanel.add(fileTextBox);
    fileUploadPanel.add(new HTML("&nbsp;"));

    Button browseButton = new Button(Messages.getString("browse") + "...");
    browseButton.setStyleName("pentaho-button");
    fileUploadPanel.add(browseButton);
    browseButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            setRetainOwnershipState();
            jsClickUpload(upload.getElement());
        }
    });

    rootPanel.add(fileUploadPanel);
    rootPanel.add(upload);

    applyAclPermissions.setName("applyAclPermissions");
    applyAclPermissions.setValue(Boolean.FALSE);
    applyAclPermissions.setFormValue("false");
    applyAclPermissions.setEnabled(true);
    applyAclPermissions.setVisible(false);

    final CheckBox overwriteAclPermissions = new CheckBox(Messages.getString("overwriteAclPermissions"), true);
    overwriteAclPermissions.setName("overwriteAclPermissions");
    applyAclPermissions.setValue(Boolean.FALSE);
    applyAclPermissions.setFormValue("false");
    overwriteAclPermissions.setEnabled(true);
    overwriteAclPermissions.setVisible(false);

    final Hidden overwriteFile = new Hidden("overwriteFile");
    overwriteFile.setValue("true");

    final Hidden logLevel = new Hidden("logLevel");
    logLevel.setValue("ERROR");

    final Hidden retainOwnership = new Hidden("retainOwnership");
    retainOwnership.setValue("true");

    rootPanel.add(applyAclPermissions);
    rootPanel.add(overwriteAclPermissions);
    rootPanel.add(overwriteFile);
    rootPanel.add(logLevel);
    rootPanel.add(retainOwnership);
    rootPanel.add(fileNameOverride);

    spacer = new VerticalPanel();
    spacer.setHeight("4px");
    rootPanel.add(spacer);

    DisclosurePanel disclosurePanel = new DisclosurePanel(Messages.getString("advancedOptions"));
    disclosurePanel.getHeader().setStyleName("gwt-Label");
    disclosurePanel.setVisible(allowAdvancedDialog);
    HorizontalPanel mainPanel = new HorizontalPanel();
    mainPanel.add(new HTML("&nbsp;"));
    VerticalPanel disclosureContent = new VerticalPanel();

    HTML replaceLabel = new HTML(Messages.getString("fileExists"));
    replaceLabel.setStyleName("gwt-Label");
    disclosureContent.add(replaceLabel);

    final CustomListBox overwriteFileDropDown = new CustomListBox();
    final CustomListBox filePermissionsDropDown = new CustomListBox();

    DefaultListItem replaceListItem = new DefaultListItem(Messages.getString("replaceFile"));
    replaceListItem.setValue("true");
    overwriteFileDropDown.addItem(replaceListItem);
    DefaultListItem doNotImportListItem = new DefaultListItem(Messages.getString("doNotImport"));
    doNotImportListItem.setValue("false");
    overwriteFileDropDown.addItem(doNotImportListItem);
    overwriteFileDropDown.setVisibleRowCount(1);
    disclosureContent.add(overwriteFileDropDown);

    spacer = new VerticalPanel();
    spacer.setHeight("4px");
    disclosureContent.add(spacer);

    HTML filePermissionsLabel = new HTML(Messages.getString("filePermissions"));
    filePermissionsLabel.setStyleName("gwt-Label");
    disclosureContent.add(filePermissionsLabel);

    DefaultListItem usePermissionsListItem = new DefaultListItem(Messages.getString("usePermissions"));
    usePermissionsListItem.setValue("false");
    filePermissionsDropDown.addItem(usePermissionsListItem); // If selected set "overwriteAclPermissions" to
    // false.
    DefaultListItem retainPermissionsListItem = new DefaultListItem(Messages.getString("retainPermissions"));
    retainPermissionsListItem.setValue("true");
    filePermissionsDropDown.addItem(retainPermissionsListItem); // If selected set "overwriteAclPermissions" to
    // true.

    final ChangeListener filePermissionsHandler = new ChangeListener() {
        @Override
        public void onChange(Widget sender) {
            String value = filePermissionsDropDown.getSelectedItem().getValue().toString();

            applyAclPermissions.setValue(Boolean.valueOf(value));
            applyAclPermissions.setFormValue(value);
            overwriteAclPermissions.setFormValue(value);
            overwriteAclPermissions.setValue(Boolean.valueOf(value));
            setRetainOwnershipState();
        }
    };
    filePermissionsDropDown.addChangeListener(filePermissionsHandler);
    filePermissionsDropDown.setVisibleRowCount(1);
    disclosureContent.add(filePermissionsDropDown);

    spacer = new VerticalPanel();
    spacer.setHeight("4px");
    disclosureContent.add(spacer);

    HTML fileOwnershipLabel = new HTML(Messages.getString("fileOwnership"));
    fileOwnershipLabel.setStyleName("gwt-Label");
    disclosureContent.add(fileOwnershipLabel);

    retainOwnershipDropDown.addChangeListener(new ChangeListener() {
        @Override
        public void onChange(Widget sender) {
            String value = retainOwnershipDropDown.getSelectedItem().getValue().toString();
            retainOwnership.setValue(value);
        }
    });
    DefaultListItem keepOwnershipListItem = new DefaultListItem(Messages.getString("keepOwnership"));
    keepOwnershipListItem.setValue("true");
    retainOwnershipDropDown.addItem(keepOwnershipListItem);
    DefaultListItem assignOwnershipListItem = new DefaultListItem(Messages.getString("assignOwnership"));
    assignOwnershipListItem.setValue("false");
    retainOwnershipDropDown.addItem(assignOwnershipListItem);

    retainOwnershipDropDown.setVisibleRowCount(1);
    disclosureContent.add(retainOwnershipDropDown);

    spacer = new VerticalPanel();
    spacer.setHeight("4px");
    disclosureContent.add(spacer);

    ChangeListener overwriteFileHandler = new ChangeListener() {
        @Override
        public void onChange(Widget sender) {
            String value = overwriteFileDropDown.getSelectedItem().getValue().toString();
            overwriteFile.setValue(value);
        }
    };
    overwriteFileDropDown.addChangeListener(overwriteFileHandler);

    HTML loggingLabel = new HTML(Messages.getString("logging"));
    loggingLabel.setStyleName("gwt-Label");
    disclosureContent.add(loggingLabel);

    final CustomListBox loggingDropDown = new CustomListBox();
    loggingDropDown.addChangeListener(new ChangeListener() {
        public void onChange(Widget sender) {
            String value = loggingDropDown.getSelectedItem().getValue().toString();
            logLevel.setValue(value);
        }
    });
    DefaultListItem noneListItem = new DefaultListItem(Messages.getString("none"));
    noneListItem.setValue("ERROR");
    loggingDropDown.addItem(noneListItem);
    DefaultListItem shortListItem = new DefaultListItem(Messages.getString("short"));
    shortListItem.setValue("WARN");
    loggingDropDown.addItem(shortListItem);
    DefaultListItem debugListItem = new DefaultListItem(Messages.getString("verbose"));
    debugListItem.setValue("TRACE");
    loggingDropDown.addItem(debugListItem);
    loggingDropDown.setVisibleRowCount(1);
    disclosureContent.add(loggingDropDown);

    mainPanel.add(disclosureContent);
    disclosurePanel.setContent(mainPanel);
    rootPanel.add(disclosurePanel);

    importDir.setName("importDir");
    importDir.setText(repositoryFile.getPath());
    importDir.setVisible(false);

    rootPanel.add(importDir);

    form.setEncoding(FormPanel.ENCODING_MULTIPART);
    form.setMethod(FormPanel.METHOD_POST);

    setFormAction();

    form.add(rootPanel);

    setContent(form);
}

From source file:org.pentaho.reporting.platform.plugin.gwt.client.CheckBoxParameterUI.java

License:Open Source License

public void setEnabled(final boolean enabled) {
    for (int i = 0; i < buttons.size(); i++) {
        final CheckBox checkBox = buttons.get(i);
        checkBox.setEnabled(enabled);
    }/*from w  w  w  . j av a2s.  c  o  m*/
}

From source file:org.roda.wui.client.ingest.process.PluginParameterPanel.java

private void createBooleanLayout() {
    CheckBox checkBox = new CheckBox(parameter.getName());
    checkBox.setValue("true".equals(parameter.getDefaultValue()));
    value = "true".equals(parameter.getDefaultValue()) ? "true" : "false";
    checkBox.setEnabled(!parameter.isReadonly());
    checkBox.getElement().setTitle("checkbox");

    layout.add(checkBox);// w ww  .  j ava2 s .  c om
    addHelp();

    checkBox.addStyleName("form-checkbox");

    checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            value = event.getValue() ? "true" : "false";
        }
    });
}

From source file:org.roda.wui.client.ingest.process.ShowJob.java

private void createBooleanLayout(PluginParameter parameter) {
    CheckBox checkBox = new CheckBox(parameter.getName());
    String value = job.getPluginParameters().get(parameter.getId());
    if (value == null) {
        value = parameter.getDefaultValue();
    }//  w  ww  .  ja v  a 2  s.co  m
    checkBox.setValue("true".equals(value));
    checkBox.setEnabled(false);

    pluginOptions.add(checkBox);
    addHelp(parameter.getDescription());

    checkBox.addStyleName("form-checkbox");
}