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

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

Introduction

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

Prototype

public CheckBox() 

Source Link

Document

Creates a check box with no label.

Usage

From source file:org.datacleaner.monitor.dashboard.widgets.ColumnParameterizedMetricPresenter.java

License:Open Source License

private Widget createMetricWidget(final MetricIdentifier metric) {
    final MetricIdentifier activeMetric = isActiveMetric(metric);
    final MetricIdentifier metricToReturn;
    if (activeMetric == null) {
        metricToReturn = metric;/*  w ww  . ja v  a2  s.  c  o  m*/
    } else {
        metricToReturn = activeMetric;
    }

    final CheckBox checkBox = new CheckBox();
    checkBox.setTitle(metric.getDisplayName());
    checkBox.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (checkBox.getValue().booleanValue()) {
                _selectedMetrics.add(metricToReturn);
            } else {
                _selectedMetrics.remove(metricToReturn);
            }
        }
    });

    if (activeMetric == null) {
        checkBox.setValue(false);
    } else {
        checkBox.setValue(true);
        _selectedMetrics.add(metricToReturn);
    }
    return checkBox;
}

From source file:org.datacleaner.monitor.dashboard.widgets.FormulaMetricPresenter.java

License:Open Source License

public FormulaMetricPresenter(TenantIdentifier tenantIdentifier, JobMetrics jobMetrics,
        MetricIdentifier metric) {/*  ww w .j  a  v  a 2 s  . c  o  m*/
    _checkBox = new CheckBox();
    _checkBox.setValue(true);
    _anchor = new MetricAnchor(tenantIdentifier, jobMetrics, metric);
}

From source file:org.dataconservancy.dcs.access.client.presenter.AdminPresenter.java

License:Apache License

@Override
public void bind() {

    userService = GWT.create(UserService.class);
    registryService = GWT.create(RegistryService.class);
    saveButton = this.display.getSaveButton();
    approvedList = new ArrayList<CheckBox>();

    AsyncCallback<List<Role>> cbGetRoles = new AsyncCallback<List<Role>>() {

        @Override/*from  w  w w.  jav a  2s.  co  m*/
        public void onFailure(Throwable caught) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onSuccess(final List<Role> roles) {
            userGrid = new Grid(100, roles.size() + 3);
            final HTMLTable.CellFormatter formatter = userGrid.getCellFormatter();
            userGrid.setWidth("100%");

            userGrid.setWidget(0, 0, Util.label("Name", "SubSectionHeader"));
            formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);

            userGrid.setWidget(0, 1, Util.label("Email", "SubSectionHeader"));
            formatter.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);

            int i = 2;
            for (Role role : roles) {
                userGrid.setWidget(0, i, Util.label(role.getName(), "SubSectionHeader"));
                formatter.setHorizontalAlignment(0, i, HasHorizontalAlignment.ALIGN_CENTER);
                i++;
            }
            userGrid.setWidget(0, i, Util.label("Resgitration Status", "SubSectionHeader"));
            formatter.setHorizontalAlignment(0, i, HasHorizontalAlignment.ALIGN_CENTER);

            display.getUsersPanel().add(userGrid);

            final int columnCount = i;

            AsyncCallback<List<Person>> cb = new AsyncCallback<List<Person>>() {

                public void onSuccess(final List<Person> userList) {

                    int i = 1;
                    roleCheckBoxes = new CheckBox[userList.size()][roles.size()];
                    for (Person user : userList) {
                        userGrid.setWidget(i, 0, new Label(user.getFirstName() + " " + user.getLastName()));
                        formatter.setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_CENTER);

                        userGrid.setWidget(i, 1, new Label(user.getEmailAddress()));
                        formatter.setHorizontalAlignment(i, 1, HasHorizontalAlignment.ALIGN_CENTER);

                        //User approval status
                        CheckBox approveCheck = new CheckBox();
                        if (user.getRegistrationStatus() == RegistrationStatus.PENDING) {
                            approveCheck.setValue(false);
                            approveCheck.setText("Approve?");
                            userGrid.setWidget(i, columnCount, approveCheck);

                        } else if (user.getRegistrationStatus() == RegistrationStatus.APPROVED) {
                            approveCheck.setValue(false);
                            userGrid.setWidget(i, columnCount, new Label("Approved"));
                        }
                        formatter.setHorizontalAlignment(i, columnCount, HasHorizontalAlignment.ALIGN_CENTER);
                        approvedList.add(approveCheck);

                        //User Role

                        int j = 2;
                        for (Role role : roles) {
                            CheckBox userCheck = new CheckBox();
                            userCheck.setName(role.getName());

                            if (user.getRole() == role)
                                userCheck.setValue(true);
                            else
                                userCheck.setValue(false);

                            userGrid.setWidget(i, j, userCheck);
                            roleCheckBoxes[i - 1][j - 2] = userCheck;
                            formatter.setHorizontalAlignment(i, j, HasHorizontalAlignment.ALIGN_CENTER);
                            j++;
                        }
                        i++;
                    }

                    userGrid.setWidget(i + 1, 5, saveButton);

                    //add a save button
                    saveButton.addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {
                            final List<Person> sendEmailList = new ArrayList<Person>();
                            final List<Person> updatedUserList = new ArrayList<Person>();
                            for (int i = 0; i < userList.size(); i++) {
                                for (int j = 0; j < roles.size(); j++) {
                                    if (roleCheckBoxes[i][j].getValue()) {//checkbox is set, then that is the role
                                        Person updatedPerson = userList.get(i);
                                        updatedPerson.setRole(roles.get(j));
                                        updatedUserList.add(updatedPerson);
                                        break;
                                    }
                                }
                            }

                            for (int i = 0; i < approvedList.size(); i++) {
                                if (approvedList.get(i).getValue()) {
                                    Person newlyApprovedPerson = updatedUserList.get(i);
                                    newlyApprovedPerson.setRegistrationStatus(RegistrationStatus.APPROVED);
                                    sendEmailList.add(newlyApprovedPerson);
                                    updatedUserList.set(i, newlyApprovedPerson);
                                }
                            }

                            //update all users in the database

                            AsyncCallback<Void> callback = new AsyncCallback<Void>() {

                                @Override
                                public void onFailure(Throwable caught) {
                                    Window.alert("Could not update:" + caught.getMessage());
                                }

                                @Override
                                public void onSuccess(Void result) {
                                    saveButton.setText("Saved");
                                    saveButton.setEnabled(false);
                                }
                            };
                            userService.updateAllUsers(updatedUserList, sendEmailList, SeadApp.registryUrl,
                                    callback);

                        }
                    });
                }

                public void onFailure(Throwable error) {
                    new ErrorPopupPanel("Failed to retrieve users: " + error.getMessage()).show();

                }
            };

            userService.getAllUsers(cb);
        }
    };
    userService.getAllRoles(cbGetRoles);
}

From source file:org.dataconservancy.dcs.access.client.view.MediciIngestView.java

License:Apache License

public MediciIngestView() {
    mainContentPanel = new VerticalPanel();
    mainContentPanel.setStyleName("VerticalPanel");
    mainContentPanel.add(Util.label("Data Publish in SEAD", "GreenHeader"));

    Panel coverLeftPanel = new FlowPanel();
    coverRightPanel = new FlowPanel();

    getPub = new Button("View Collections to Publish");
    ingestButton = new Button("Ingest Dataset");
    //getPub.setStyleName("ButtonPosition");

    int height = Window.getClientHeight();
    final int width = Window.getClientHeight();
    //System.out.println(height +" px\n");

    leftPanel = new ScrollPanel();
    leftPanel.setStyleName("LeftPanel");
    leftPanel.setHeight((height / 2 - 50) + "px");
    leftPanel.setWidth((width / 2.5 - 5) + "px");

    datasetLbl = Util.label("Dataset Collections", "BoxHeader");
    coverLeftPanel.setStyleName("CollectionBorder");
    coverLeftPanel.add(datasetLbl);/*from   w w w. jav  a 2 s.c  o  m*/
    coverLeftPanel.add(leftPanel);
    coverLeftPanel.setHeight(height / 2 + "px");
    coverLeftPanel.setWidth((width / 2.5) + "px");

    rightPanel = new ScrollPanel();
    rightPanel.setStyleName("RightPanel");
    rightPanel.setHeight((height / 2 - 50) + "px");
    rightPanel.setWidth((width - 5) + "px");

    fileLbl = Util.label("", "BoxHeader");
    coverRightPanel.setStyleName("FileBorder");
    coverRightPanel.add(fileLbl);
    coverRightPanel.add(rightPanel);
    coverRightPanel.setHeight(height / 2 + "px");
    coverRightPanel.setWidth((width) + "px");

    content = new HorizontalPanel();

    content.setStyleName("HorizontalPanel2");

    content.add(coverLeftPanel);
    content.add(coverRightPanel);

    final Panel buttonPanel = new HorizontalPanel();

    final Grid buttonTable = new Grid(2, 2);

    ir = new ListBox();
    ir.setStyleName("droplist");

    /*
    tag:cet.ncsa.uiuc.edu,2008:/bean/Collection/c6fa1779-296a-41ba-9a62-3342be9f58a2, Experimental Study of Delta Erosion Due to Dam Removal
    tag:cet.ncsa.uiuc.edu,2008:/bean/Collection/9248d474-7100-4fac-ba7d-4b1519354d22, Eel River Quads
    tag:cet.ncsa.uiuc.edu,2008:/bean/Collection/82f12ed4-a6ba-41ce-9dd9-27f10fb68152, Eel River Steelhead Study
    tag:cet.ncsa.uiuc.edu,2008:/bean/Collection/35ffbd8f-c3fc-465f-b437-1588b9d028c0, Eel River Flipchart
    tag:cet.ncsa.uiuc.edu,2008:/bean/Collection/d6d250ba-e54d-4ae0-937d-c23d5e8b5de8, Church and Rood Alluvial River Channel Regime Data
    */

    restrictCopy = new CheckBox();

    restrictCopy.setText("Restrict Access to Data Collection");
    restrictCopy.setValue(false);
    restrictCopy.setEnabled(false);
    restrictCopy.setStyleName("greyFont");

    ingestButton.setEnabled(false);
    ingestButton.setStyleName("ButtonPosition");
    ingestButton.setStyleName("greyFont");

    getPub.setStyleName("greenFont");
    getPub.setEnabled(false);

    buttonTable.setWidget(0, 0, ir);
    //buttonTable.setWidget(1,0,cloudCopy);
    //  buttonTable.setStyleName("TableBorder");
    buttonTable.setWidget(0, 1, getPub);
    Panel tempPanel2 = new FlowPanel();
    tempPanel2.setWidth((width / 10) + "px");
    buttonPanel.add(tempPanel2);
    //    buttonTable.setStyleName("Center");
    buttonPanel.add(buttonTable);
    buttonTable.setStyleName("topPadding");

    //   buttonPanel.add(fgdcFileLabel);
    //              buttonPanel.add();
    Grid grid = new Grid(2, 2);

    grid.setWidget(0, 0, restrictCopy);
    uploadMetadata = new CheckBox();

    uploadMetadata.setText("Upload Metadata");
    uploadMetadata.setValue(false);
    uploadMetadata.setEnabled(false);
    uploadMetadata.setStyleName("greyFont");
    //   buttonPanel.add(cloudCopy);
    grid.setWidget(1, 0, uploadMetadata);
    grid.setWidget(0, 1, ingestButton);
    //  grid.setStyleName("Center");
    Panel tempPanel3 = new FlowPanel();
    tempPanel3.setWidth((width / 10) + "px");
    buttonPanel.add(tempPanel3);

    buttonPanel.add(grid);

    // Add a button to upload the file
    uploadMetadata.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            new UploadFgdcDialog(SeadApp.deposit_endpoint + "file");

        }
    });
    //   buttonPanel.add(new HTML("<br>"));
    //    buttonPanel.add(uploadButton);

    Panel tempPanel = new FlowPanel();
    tempPanel.setWidth((width / 2.5) + "px");
    buttonPanel.add(tempPanel);
    buttonPanel.setStyleName("HorizontalPanel");

    buttonPanel.setHeight("15%");
    //ir.setEnabled(false);
    mainContentPanel.add(content);
    mainContentPanel.add(buttonPanel);

}

From source file:org.drools.brms.client.modeldriven.ui.RuleAttributeWidget.java

License:Apache License

private Widget checkBoxEditor(final RuleAttribute at) {
    final CheckBox box = new CheckBox();
    if (at.value == null) {
        box.setChecked(true);//  w  w w . j a v a  2 s . co  m
        at.value = "true";
    } else {
        box.setChecked((at.value.equals("true") ? true : false));
    }

    box.addClickListener(new ClickListener() {
        public void onClick(Widget w) {
            at.value = (box.isChecked()) ? "true" : "false";
        }
    });
    return box;
}

From source file:org.drools.guvnor.client.admin.RepoConfigManager.java

License:Apache License

public DecoratorPanel getDbTypePanel() {
    FlexTable layoutA = new FlexTable();
    layoutA.setCellSpacing(6);/*ww w  .  j  a  v  a2 s  .c  om*/
    FlexCellFormatter cellFormatter = layoutA.getFlexCellFormatter();

    // Add a title to the form
    layoutA.setHTML(0, 0, "RDBMS Info");
    cellFormatter.setColSpan(0, 0, 2);
    cellFormatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);

    layoutA.setHTML(1, 0, constants.SelectRdbmsType());
    final ListBox databaseList = getDatabaseList();
    databaseList.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            ListBox listBox = (ListBox) event.getSource();
            int index = listBox.getSelectedIndex();
            rdbmsConf.setDbType(listBox.getItemText(index));
            layoutB.setHTML(0, 0, listBox.getItemText(index) + " Info");
            layoutC.setHTML(0, 0, listBox.getItemText(index) + " Info");
            repoDisplayArea.setVisible(false);
            saveRepoConfigForm.setVisible(false);
        }
    });
    if (rdbmsConf.getDbType() == null || rdbmsConf.getDbType().length() < 1) {
        databaseList.setSelectedIndex(0);
    } else {
        for (int i = 0; i < databaseList.getItemCount(); i++) {
            if (rdbmsConf.getDbType().equals(databaseList.getItemText(i))) {
                databaseList.setSelectedIndex(i);
                break;
            }
        }
    }
    databaseList.addChangeHandler(new ChangeHandler() {
        public void onChange(ChangeEvent event) {
            rdbmsConf.setDbType(databaseList.getValue(databaseList.getSelectedIndex()));
        }
    });
    layoutA.setWidget(1, 1, databaseList);

    layoutA.setHTML(2, 0, constants.UseJndi());

    final CheckBox useJndi = new CheckBox();
    useJndi.setValue(rdbmsConf.isJndi());
    useJndi.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent w) {
            rdbmsConf.setJndi(useJndi.isEnabled());
            if (useJndi.isEnabled()) {
                noJndiInfo.setVisible(false);
                jndiInfo.setVisible(true);
            } else {
                noJndiInfo.setVisible(true);
                jndiInfo.setVisible(false);
            }
            repoDisplayArea.setVisible(false);
            saveRepoConfigForm.setVisible(false);
        }
    });
    layoutA.setWidget(2, 1, useJndi);

    Button continueButton = new Button("Continue");
    continueButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent w) {
            if (databaseList.getSelectedIndex() == 0) {
                Window.alert(constants.PleaseSelectRdbmsType());
                return;
            }
            if (!useJndi.isEnabled()) {
                jndiInfo.setVisible(false);
            }
            vPanel2.setVisible(true);
        }
    });

    layoutA.setWidget(3, 1, continueButton);
    DecoratorPanel decPanel = new DecoratorPanel();
    decPanel.setWidget(layoutA);
    return decPanel;
}

From source file:org.drools.guvnor.client.admin.RuleVerifierManager.java

License:Apache License

public RuleVerifierManager() {

    PrettyFormLayout form = new PrettyFormLayout();
    form.addHeader(images.ruleVerification(), new HTML(constants.EditRulesVerificationConfiguration()));
    form.startSection(constants.AutomaticVerification());

    final CheckBox enableOnlineValidator = new CheckBox();
    enableOnlineValidator.setValue(WorkingSetManager.getInstance().isAutoVerifierEnabled());
    form.addAttribute(constants.Enabled(), enableOnlineValidator);

    HorizontalPanel actions = new HorizontalPanel();

    form.addAttribute("", actions);

    Button btnSave = new Button(constants.SaveChanges());
    btnSave.setTitle(constants.SaveAllChanges());
    btnSave.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            WorkingSetManager.getInstance().setAutoVerifierEnabled(enableOnlineValidator.getValue());
            Window.alert(constants.AllChangesHaveBeenSaved());
        }//from  w ww  .  ja v a 2s.  co m
    });

    actions.add(btnSave);

    form.endSection();

    initWidget(form);

}

From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.RuleAttributeWidget.java

License:Apache License

private Widget checkBoxEditor(final RuleAttribute at) {
    final CheckBox box = new CheckBox();
    if (at.value == null) {
        box.setValue(true);/*from www.j a v a 2 s  .  c o m*/
        at.value = TRUE_VALUE;
    } else {
        box.setValue((at.value.equals(TRUE_VALUE)));
    }

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

From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.RuleModellerActionSelectorPopup.java

License:Apache License

@Override
public Widget getContent() {
    if (position == null) {
        positionCbo.addItem(Constants.INSTANCE.Bottom(), String.valueOf(this.model.rhs.length));
        positionCbo.addItem(Constants.INSTANCE.Top(), "0");
        for (int i = 1; i < model.rhs.length; i++) {
            positionCbo.addItem(Constants.INSTANCE.Line0(i), String.valueOf(i));
        }//from ww w . ja  va  2s .  c  om
    } else {
        //if position is fixed, we just add one element to the drop down.
        positionCbo.addItem(String.valueOf(position));
        positionCbo.setSelectedIndex(0);
    }

    if (completions.getDSLConditions().length == 0 && completions.getFactTypes().length == 0) {
        layoutPanel.addRow(new HTML("<div class='highlight'>" + Constants.INSTANCE.NoModelTip() + "</div>"));
    }

    //only show the drop down if we are not using fixed position.
    if (position == null) {
        HorizontalPanel hp0 = new HorizontalPanel();
        hp0.add(new HTML(Constants.INSTANCE.PositionColon()));
        hp0.add(positionCbo);
        hp0.add(new InfoPopup(Constants.INSTANCE.PositionColon(),
                Constants.INSTANCE.ActionPositionExplanation()));
        layoutPanel.addRow(hp0);
    }

    choices = makeChoicesListBox();
    choicesPanel.add(choices);
    layoutPanel.addRow(choicesPanel);

    HorizontalPanel hp = new HorizontalPanel();
    Button ok = new Button(Constants.INSTANCE.OK());
    hp.add(ok);
    ok.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            selectSomething();
        }
    });

    Button cancel = new Button(Constants.INSTANCE.Cancel());
    hp.add(cancel);
    cancel.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            hide();
        }
    });

    CheckBox chkOnlyDisplayDSLConditions = new CheckBox();
    chkOnlyDisplayDSLConditions.setText(Constants.INSTANCE.OnlyDisplayDSLActions());
    chkOnlyDisplayDSLConditions.setValue(bOnlyShowDSLConditions);
    chkOnlyDisplayDSLConditions.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        public void onValueChange(ValueChangeEvent<Boolean> event) {
            bOnlyShowDSLConditions = event.getValue();
            choicesPanel.setWidget(makeChoicesListBox());
        }

    });

    layoutPanel.addRow(chkOnlyDisplayDSLConditions);

    layoutPanel.addRow(hp);

    this.setAfterShow(new Command() {

        public void execute() {
            choices.setFocus(true);
        }
    });

    return layoutPanel;
}

From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.RuleModellerConditionSelectorPopup.java

License:Apache License

@Override
public Widget getContent() {
    if (position == null) {
        positionCbo.addItem(Constants.INSTANCE.Bottom(), String.valueOf(this.model.lhs.length));
        positionCbo.addItem(Constants.INSTANCE.Top(), "0");
        for (int i = 1; i < model.lhs.length; i++) {
            positionCbo.addItem(Constants.INSTANCE.Line0(i), String.valueOf(i));
        }/*from ww  w  . ja  v  a2s  .c  o  m*/
    } else {
        //if position is fixed, we just add one element to the drop down.
        positionCbo.addItem(String.valueOf(position));
        positionCbo.setSelectedIndex(0);
    }

    if (completions.getDSLConditions().length == 0 && completions.getFactTypes().length == 0) {
        layoutPanel.addRow(new HTML("<div class='highlight'>" + Constants.INSTANCE.NoModelTip() + "</div>"));
    }

    //only show the drop down if we are not using fixed position.
    if (position == null) {
        HorizontalPanel hp0 = new HorizontalPanel();
        hp0.add(new HTML(Constants.INSTANCE.PositionColon()));
        hp0.add(positionCbo);
        hp0.add(new InfoPopup(Constants.INSTANCE.PositionColon(),
                Constants.INSTANCE.ConditionPositionExplanation()));
        layoutPanel.addRow(hp0);
    }

    choices = makeChoicesListBox();
    choicesPanel.add(choices);
    layoutPanel.addRow(choicesPanel);

    HorizontalPanel hp = new HorizontalPanel();
    Button ok = new Button(Constants.INSTANCE.OK());
    hp.add(ok);
    ok.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            selectSomething();
        }
    });

    Button cancel = new Button(Constants.INSTANCE.Cancel());
    hp.add(cancel);
    cancel.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            hide();
        }
    });

    CheckBox chkOnlyDisplayDSLConditions = new CheckBox();
    chkOnlyDisplayDSLConditions.setText(Constants.INSTANCE.OnlyDisplayDSLConditions());
    chkOnlyDisplayDSLConditions.setValue(bOnlyShowDSLConditions);
    chkOnlyDisplayDSLConditions.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        public void onValueChange(ValueChangeEvent<Boolean> event) {
            bOnlyShowDSLConditions = event.getValue();
            choicesPanel.setWidget(makeChoicesListBox());
        }

    });

    layoutPanel.addRow(chkOnlyDisplayDSLConditions);

    layoutPanel.addRow(hp);

    this.setAfterShow(new Command() {

        public void execute() {
            choices.setFocus(true);
        }
    });

    return layoutPanel;
}