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:com.google.api.explorer.client.auth.AuthView.java

License:Apache License

/**
 * Rebuild the popup from scratch with all of the scopes that we have from the last time we were
 * presented./*from  w  w  w .  j  a  v a2  s . c  o  m*/
 */
private void buildScopePopup() {

    scopePanel.clear();
    additionalScopePanel.clear();

    Set<TextBox> oldEditors = Sets.newLinkedHashSet(freeFormEditors);
    freeFormEditors.clear();

    // Hide the service scopes label if there aren't any.
    hasScopesText.setVisible(!scopesFromDiscovery.isEmpty());
    noScopesText.setVisible(scopesFromDiscovery.isEmpty());

    // Show different text on the free-form scopes section when there are discovery scopes.
    optionalAdditionalScopes.setVisible(!scopesFromDiscovery.isEmpty());

    for (final Map.Entry<String, AuthScope> scope : scopesFromDiscovery.entrySet()) {
        // Add the check box to the table.
        CheckBox scopeToggle = new CheckBox();

        SafeHtmlBuilder safeHtml = new SafeHtmlBuilder();
        safeHtml.appendEscaped(scope.getKey()).appendHtmlConstant("<br><span>")
                .appendEscaped(scope.getValue().getDescription()).appendHtmlConstant("</span>");
        scopeToggle.setHTML(safeHtml.toSafeHtml());

        scopeToggle.addStyleName(style.discoveryScopeSelector());
        scopePanel.add(scopeToggle);

        // When the box is checked, add our scope to the selected list.
        scopeToggle.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                CheckBox checkBox = (CheckBox) event.getSource();
                if (checkBox.getValue()) {
                    selectedScopes.add(scope.getKey());
                } else {
                    selectedScopes.remove(scope.getKey());
                }
            }
        });

        // Enable the check box if the scope is selected.
        scopeToggle.setValue(selectedScopes.contains(scope.getKey()));
    }

    // Process any scopes that are extra.
    for (TextBox editor : oldEditors) {
        if (!editor.getValue().trim().isEmpty()) {
            addFreeFormEditorRow(editor.getValue(), true);
        }
    }

    // There should always be one empty editor.
    addFreeFormEditorRow("", false);
}

From source file:com.google.appinventor.client.editor.simple.components.MockCheckBox.java

License:Open Source License

/**
 * Creates a new MockCheckbox component.
 *
 * @param editor  editor of source file the component belongs to
 *//*  w  w w .ja v a2  s .c o  m*/
public MockCheckBox(SimpleEditor editor) {
    super(editor, TYPE, images.checkbox());

    // Initialize mock checkbox UI
    checkboxWidget = new CheckBox();
    initWrapper(checkboxWidget);
}

From source file:com.google.appinventor.client.explorer.youngandroid.ReportList.java

License:Open Source License

/**
 * Creates a new ProjectList//from w w  w .  ja  v  a  2 s.c o m
 */
public ReportList() {
    galleryClient = GalleryClient.getInstance();
    // Initialize UI
    panel = new VerticalPanel();
    panel.setWidth("100%");

    HorizontalPanel checkBoxPanel = new HorizontalPanel();
    checkBoxPanel.addStyleName("all-reports");
    checkBox = new CheckBox();
    checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            boolean isChecked = event.getValue(); // auto-unbox from Boolean to boolean
            //reset start position
            reportAllRecentCounter = 0;
            reportRecentCounter = 0;
            buttonNext.setVisible(true);
            if (isChecked) {
                initializeAllReports();
            } else {
                initializeReports();
            }
        }
    });
    checkBoxPanel.add(checkBox);
    Label checkBoxText = new Label(MESSAGES.moderationShowResolvedReports());
    checkBoxPanel.add(checkBoxText);
    panel.add(checkBoxPanel);

    selectedGalleryAppReports = new ArrayList<GalleryAppReport>();
    ReportWidgets = new HashMap<GalleryAppReport, ReportWidgets>();

    table = new Grid(1, 9); // The table initially contains just the header row.
    table.addStyleName("ode-ModerationTable");
    table.setWidth("100%");
    table.setCellSpacing(0);

    buttonNext = new Label();
    buttonNext.setText(MESSAGES.galleryMoreReports());

    buttonNext.addClickHandler(new ClickHandler() {
        //  @Override
        public void onClick(ClickEvent event) {
            final OdeAsyncCallback<GalleryReportListResult> callback = new OdeAsyncCallback<GalleryReportListResult>(
                    // failure message
                    MESSAGES.galleryError()) {
                @Override
                public void onSuccess(GalleryReportListResult reportListResult) {
                    List<GalleryAppReport> reportList = reportListResult.getReports();
                    reports.addAll(reportList);
                    for (GalleryAppReport report : reportList) {
                        ReportWidgets.put(report, new ReportWidgets(report));
                    }
                    refreshTable(reportListResult, false);
                }
            };
            if (checkBox.isChecked()) {
                reportAllRecentCounter += NUMREPORTSSHOW;
                Ode.getInstance().getGalleryService().getAllAppReports(reportAllRecentCounter, NUMREPORTSSHOW,
                        callback);
            } else {
                reportRecentCounter += NUMREPORTSSHOW;
                Ode.getInstance().getGalleryService().getRecentReports(reportRecentCounter, NUMREPORTSSHOW,
                        callback);
            }
        }
    });

    setHeaderRow();

    panel.add(table);
    FlowPanel next = new FlowPanel();
    buttonNext.addStyleName("active");
    next.add(buttonNext);
    next.addStyleName("gallery-report-next");
    panel.add(next);
    initWidget(panel);

    initializeReports();

}

From source file:com.google.appinventor.client.widgets.properties.BooleanPropertyEditor.java

License:Open Source License

/**
 * Creates a new property editor for boolean values.
 *
 * @param trueValue  spelling of true value
 * @param falseValue  spelling of false value
 */// www.j  a  v a2  s . c om
public BooleanPropertyEditor(String trueValue, String falseValue) {
    this.trueValue = trueValue;
    this.falseValue = falseValue;

    checkbox = new CheckBox();
    checkbox.addValueChangeHandler(this);

    initWidget(checkbox);
}

From source file:com.google.gerrit.client.account.MyWatchesTable.java

License:Apache License

protected void populate(final int row, final AccountProjectWatchInfo info) {
    final FlowPanel fp = new FlowPanel();
    fp.add(new ProjectLink(info.getProject().getNameKey(), Status.NEW));
    if (info.getWatch().getFilter() != null) {
        Label filter = new Label(info.getWatch().getFilter());
        filter.setStyleName(Gerrit.RESOURCES.css().watchedProjectFilter());
        fp.add(filter);/*  w w  w .ja  va2  s  .  c om*/
    }

    table.setWidget(row, 1, new CheckBox());
    table.setWidget(row, 2, fp);

    addNotifyButton(AccountProjectWatch.NotifyType.NEW_CHANGES, info, row, 3);
    addNotifyButton(AccountProjectWatch.NotifyType.NEW_PATCHSETS, info, row, 4);
    addNotifyButton(AccountProjectWatch.NotifyType.ALL_COMMENTS, info, row, 5);
    addNotifyButton(AccountProjectWatch.NotifyType.SUBMITTED_CHANGES, info, row, 6);
    addNotifyButton(AccountProjectWatch.NotifyType.ABANDONED_CHANGES, info, row, 7);

    final FlexCellFormatter fmt = table.getFlexCellFormatter();
    fmt.addStyleName(row, 1, Gerrit.RESOURCES.css().iconCell());
    fmt.addStyleName(row, 2, Gerrit.RESOURCES.css().dataCell());
    fmt.addStyleName(row, 3, Gerrit.RESOURCES.css().dataCell());
    fmt.addStyleName(row, 4, Gerrit.RESOURCES.css().dataCell());
    fmt.addStyleName(row, 5, Gerrit.RESOURCES.css().dataCell());
    fmt.addStyleName(row, 6, Gerrit.RESOURCES.css().dataCell());
    fmt.addStyleName(row, 7, Gerrit.RESOURCES.css().dataCell());

    setRowItem(row, info);
}

From source file:com.google.gerrit.client.account.MyWatchesTable.java

License:Apache License

protected void addNotifyButton(final AccountProjectWatch.NotifyType type, final AccountProjectWatchInfo info,
        final int row, final int col) {
    final CheckBox cbox = new CheckBox();

    cbox.addClickHandler(new ClickHandler() {
        @Override// w  w w . j a  v a2  s.c  o  m
        public void onClick(final ClickEvent event) {
            final boolean oldVal = info.getWatch().isNotify(type);
            info.getWatch().setNotify(type, cbox.getValue());
            cbox.setEnabled(false);
            Util.ACCOUNT_SVC.updateProjectWatch(info.getWatch(), new GerritCallback<VoidResult>() {
                public void onSuccess(final VoidResult result) {
                    cbox.setEnabled(true);
                }

                @Override
                public void onFailure(final Throwable caught) {
                    cbox.setEnabled(true);
                    info.getWatch().setNotify(type, oldVal);
                    cbox.setValue(oldVal);
                    super.onFailure(caught);
                }
            });
        }
    });

    cbox.setValue(info.getWatch().isNotify(type));
    table.setWidget(row, col, cbox);
}

From source file:com.google.gerrit.client.change.ReplyBox.java

License:Apache License

private void renderCheckBox(int row, LabelAndValues lv) {
    ApprovalInfo self = Gerrit.isSignedIn() ? lv.info.forUser(Gerrit.getUserAccount().getId().get()) : null;

    final String id = lv.info.name();
    final CheckBox b = new CheckBox();
    b.setText(id);//from   w w  w.  j a  v  a  2 s  .c  o m
    b.setEnabled(lv.permitted.contains((short) 1));
    if (self != null && self.value() == 1) {
        b.setValue(true);
    }
    b.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            in.label(id, event.getValue() ? (short) 1 : (short) 0);
        }
    });
    b.setStyleName(style.label_name());
    labelsTable.setWidget(row, 0, b);

    CellFormatter fmt = labelsTable.getCellFormatter();
    fmt.setStyleName(row, labelHelpColumn, style.label_help());
    labelsTable.setText(row, labelHelpColumn, lv.info.valueText("+1"));
}

From source file:com.google.gwt.gadgets.sample.mealpreferences.client.MealPreferencesGadget.java

License:Apache License

@Override
protected void init(MealPreferences preferences) {
    initDishes(preferences);//from   w ww.  j a v a  2 s.  c  o  m

    // Create a table with a checklist of all available dishes based on the
    // user's dietary preferences.
    Panel p = new DockLayoutPanel(Unit.PX);
    p.setWidth("100%");

    FlexTable ft = new FlexTable();

    int index = 0;
    for (String dish : dishes) {
        CheckBox cb = new CheckBox();
        final String dishCopy = dish;
        cb.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                Window.alert("Your order of " + dishCopy + " will be right up.");
            }
        });
        ft.setWidget(index, 0, cb);
        ft.setHTML(index, 1, dish);
        index++;
    }
    p.add(ft);
    RootLayoutPanel.get().add(p);
}

From source file:com.google.gwt.gen2.demo.scrolltable.client.ScrollTableDemo.java

License:Apache License

/**
 * @return the new header table// w  w  w  .ja v  a2 s .co m
 */
private FixedWidthFlexTable createHeaderTable() {
    FixedWidthFlexTable headerTable = new FixedWidthFlexTable();

    // Level 1 headers
    FlexCellFormatter headerFormatter = headerTable.getFlexCellFormatter();
    headerTable.setHTML(0, 0, "User Information");
    headerFormatter.setColSpan(0, 0, 13);

    // Create the select all checkbox
    final CheckBox selectAll = new CheckBox();
    selectAll.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (selectAll.getValue()) {
                getDataTable().selectAllRows();
            } else {
                getDataTable().deselectAllRows();
            }
        }
    });

    // Level 2 headers
    headerTable.setWidget(1, 0, selectAll);
    headerFormatter.setRowSpan(1, 0, 2);
    headerFormatter.setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
    headerTable.setHTML(1, 1, "First and Last Name");
    headerFormatter.setColSpan(1, 1, 2);
    headerFormatter.setRowSpan(1, 1, 2);
    headerTable.setHTML(1, 2, "General Info");
    headerFormatter.setColSpan(1, 2, 3);
    headerTable.setHTML(1, 3, "Favorite Color");
    headerFormatter.setColSpan(1, 3, 1);
    headerFormatter.setRowSpan(1, 3, 2);
    headerTable.setHTML(1, 4, "Preferred Sport");
    headerFormatter.setColSpan(1, 4, 1);
    headerFormatter.setRowSpan(1, 4, 2);
    headerTable.setHTML(1, 5, "School Info");
    headerFormatter.setColSpan(1, 5, 3);
    headerTable.setHTML(1, 6, "Login Info");
    headerFormatter.setColSpan(1, 6, 2);

    // Level 3 headers
    headerTable.setHTML(2, 0, "Age");
    headerTable.setHTML(2, 1, "Gender");
    headerTable.setHTML(2, 2, "Race");
    headerTable.setHTML(2, 3, "College");
    headerTable.setHTML(2, 4, "Year");
    headerTable.setHTML(2, 5, "GPA");
    headerTable.setHTML(2, 6, "ID");
    headerTable.setHTML(2, 7, "Pin");

    return headerTable;
}

From source file:com.google.gwt.maps.testing.client.maps.CustomControlsMapWidget.java

License:Apache License

private void drawControls() {
    Button button = new Button("B1");
    button.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Button 1 Clicked");
        }//w  w  w .  j  a va  2 s. co  m
    });

    Button button2 = new Button("B2");
    button2.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Button 2 Clicked ");
        }
    });

    final CheckBox cb = new CheckBox();
    cb.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            GWT.log("Button 2 Clicked");
            Window.alert("CheckBox is " + cb.getValue());
        }
    });

    FlowPanel widget = new FlowPanel();
    widget.add(button);
    widget.add(new HTML("Custom Controls"));
    widget.add(button);
    widget.add(button2);
    widget.add(cb);
    widget.addStyleName("TestControls");

    // TODO I'm not able to get the stylesheet to work, but this works below
    DOM.setStyleAttribute(widget.getElement(), "background", "white");
    DOM.setStyleAttribute(widget.getElement(), "padding", "5px");
    DOM.setStyleAttribute(widget.getElement(), "margin", "3px");
    DOM.setStyleAttribute(widget.getElement(), "border", "3px solid #FF0000");

    mapWidget.setControls(ControlPosition.RIGHT_CENTER, widget);
}