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

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

Introduction

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

Prototype

@Override
    public void setText(String text) 

Source Link

Usage

From source file:ca.upei.ic.timetable.client.CourseModelView.java

License:Apache License

public void addCourse(final int id, final JSONObject value, boolean selected) {
    final CheckBox box = new CheckBox();
    String name = ((JSONString) value.get("name")).stringValue();
    String title = ((JSONString) value.get("title")).stringValue();
    String time = ((JSONString) value.get("time")).stringValue();
    box.setText(name + " " + title);
    box.setName(Integer.toString(id));
    box.setChecked(selected);/*from  w  ww  . j a  va2s .  com*/
    box.setEnabled(time.matches(".*\\d{1,2}:\\d{2,2}\\s*-\\s*\\d{1,2}:\\d{2,2}.*"));

    // add click listener
    box.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {
            final CheckBox box = (CheckBox) sender;
            if (box.isChecked()) {
                controller_.select(id, value);
            } else {
                controller_.unselect(id);
            }
        }

    });

    FocusPanel focus = PanelUtils.focusPanel(box, null, null, null, new MouseListener() {

        public void onMouseDown(Widget sender, int x, int y) {
        }

        public void onMouseEnter(Widget sender) {
            controller_.showCourseDetail(id);
        }

        public void onMouseLeave(Widget sender) {
            controller_.hideCourseDetail();
        }

        public void onMouseMove(Widget sender, int x, int y) {
        }

        public void onMouseUp(Widget sender, int x, int y) {
            //                  box.setChecked( !box.isChecked() );
        }
    });
    panel_.add(focus);
}

From source file:com.ephesoft.dcma.gwt.admin.bm.client.view.batch.ImportBatchClassView.java

License:Open Source License

/**
 * This method creates tree view of batch class configuration for selected batch class.
 * /*from  w  w w.j av a  2  s.co m*/
 * @param uiConfigList List<Node>
 */
public void getbatchFolderListView(List<Node> uiConfigList) {
    batchClassFolderView.removeItems();
    if (uncFolderList.getItemCount() > 0) {
        importBatchClassUserOptionDTO.setUncFolder(uncFolderList.getValue(0));
    }
    if (uiConfigList != null && !uiConfigList.isEmpty()) {
        importBatchClassUserOptionDTO.getUiConfigRoot().getChildren().clear();

        for (Node rootNode : uiConfigList) {
            Node node = new Node();
            node.getLabel().setDisplayName(rootNode.getLabel().getDisplayName());
            node.getLabel().setKey(rootNode.getLabel().getKey());
            node.setParent(rootNode.getParent());
            CheckBox checkBox = new CheckBox();
            checkBox.setText(rootNode.getLabel().getDisplayName().trim());
            TreeItem treeItem = new TreeItem(checkBox);
            createUI(rootNode.getLabel().isMandatory(), checkBox, node, treeItem);
            node.setParent(importBatchClassUserOptionDTO.getUiConfigRoot());
            importBatchClassUserOptionDTO.getUiConfigRoot().getChildren().add(node);
            if (rootNode.getChildren() != null && !rootNode.getChildren().isEmpty()) {
                setImportFolderUI(treeItem, rootNode, node);
            }
            batchClassFolderView.addItem(treeItem);
            treeItem.setState(Boolean.TRUE);
        }

    }
}

From source file:com.ephesoft.dcma.gwt.admin.bm.client.view.batch.ImportBatchClassView.java

License:Open Source License

private void setImportFolderUI(final TreeItem treeItem, final Node rootNode, final Node newRootNode) {
    for (Node childNode : rootNode.getChildren()) {
        if (rootNode != null && rootNode.getLabel() != null && rootNode.getLabel().getDisplayName() != null
                && !rootNode.getLabel().getDisplayName().trim().isEmpty()) {
            Node node = new Node();
            node.getLabel().setDisplayName(childNode.getLabel().getDisplayName());
            node.getLabel().setKey(childNode.getLabel().getKey());
            node.setParent(childNode.getParent());
            CheckBox checkBox = new CheckBox();
            checkBox.setText(childNode.getLabel().getDisplayName().trim());
            TreeItem childTree = new TreeItem(checkBox);
            treeItem.addItem(childTree);
            createUI(childNode.getLabel().isMandatory(), checkBox, node, childTree);
            node.setParent(newRootNode);
            newRootNode.getChildren().add(node);
            if (childNode.getChildren() != null && !childNode.getChildren().isEmpty()) {
                setImportFolderUI(childTree, childNode, node);
            }/* www  .  j av  a 2 s.  co  m*/
        }
    }
}

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);
    b.setEnabled(lv.permitted.contains((short) 1));
    if (self != null && self.value() == 1) {
        b.setValue(true);//  w w  w.ja  v  a  2 s . co m
    }
    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.mobile.trippy.web.client.view.AddItemPopUpView.java

License:Apache License

/**
 * Sets the content of Pop up Panel./*from   w  w  w  .j ava2  s . com*/
 * 
 */
@Override
public void createPopUp(final int daysCount) {
    if (daysPanel == null) {
        daysPanel = new ArrayList<CheckBox>();
    } else {
        daysPanel.clear();
    }
    content.clear();

    selectDaysLabel.setText("Select Day(s)");
    selectDaysLabel.addStyleName(dayStyle.style.titleBaseModified());

    daysMenu.clear();
    daysMenu.setStyleName(dayStyle.style.daysMenu());
    addSelectOptions(daysMenu);

    for (int i = 0; i <= daysCount; i++) {
        final CheckBox dayPanel = new CheckBox(" Day " + i);
        dayPanel.setStyleName(dayStyle.style.dayPanel());
        if (i == 0) {
            final Message messages = GWT.create(Message.class);
            dayPanel.setText(" " + messages.unscheduled());
            dayPanel.setValue(true);
        } else {
            // if any day is selected, make sure we uncheck "unscheduled"
            dayPanel.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    boolean checked = ((CheckBox) event.getSource()).getValue();
                    if (checked) {
                        ((CheckBox) (daysMenu.getWidget(0))).setValue(false);
                    } else {
                        ((CheckBox) (daysMenu.getWidget(0))).setValue(true);
                        for (int i = 1; i < daysMenu.getWidgetCount(); i++) {
                            CheckBox cb = (CheckBox) daysMenu.getWidget(i);
                            if (cb.getValue()) {
                                ((CheckBox) (daysMenu.getWidget(0))).setValue(false);
                            }
                        }
                    }
                }
            });
        }
        daysMenu.add(dayPanel);
        daysPanel.add(dayPanel);
    }
    content.add(daysMenu);
    dayPopUp.hide();
}

From source file:com.qualogy.qafe.gwt.client.component.CellRendererHelper.java

License:Apache License

private static CellRenderer<DataContainerGVO, String> createCheckboxRenderer(final DataGridGVO source,
        final DataGridColumnGVO column, final String uuid, final String parent,
        final HasDataGridMethods uiParent) {
    return new CellRenderer<DataContainerGVO, String>() {
        public void renderRowValue(DataContainerGVO rowValue,
                ColumnDefinition<DataContainerGVO, String> columnDef, AbstractCellView<DataContainerGVO> view) {
            boolean alreadyRendered = false;
            String value = simpleObjectToText(columnDef.getCellValue(rowValue));
            int rowIndex = view.getRowIndex();
            String generatedId = generateIdBasedOnIndex(column, rowIndex);
            CheckBox renderedComponent = (CheckBox) getRenderedComponent(column, generatedId, uuid, parent);
            if (renderedComponent != null) {
                renderedComponent.setText(value);
                alreadyRendered = true;/*from w  w  w. j  a  va  2 s .  c  o  m*/
            } else {
                renderedComponent = new CheckBox(value);
            }

            view.setWidget(renderedComponent);
            CellRendererHelper.addBasicInfoToUIObject(renderedComponent, uuid, parent, source, column, rowValue,
                    rowIndex, null, alreadyRendered);
            handleCellSet(uiParent, columnDef, renderedComponent, rowValue);
        }
    };
}

From source file:com.sun.labs.aura.dbbrowser.client.viz.RepLogDialog.java

License:Open Source License

public RepLogDialog(String idStr, List<String> logNames, List<String> selected, String logLevel) {
    super(false);
    this.idStr = idStr;
    this.logNames = logNames;
    this.selected = selected;
    initialLogLevel = logLevel;//from   www .  ja va2  s.c  o m
    setText("Change Log Settings");

    FlowPanel mainPanel = new FlowPanel();

    //
    // Put in a grid of check boxes for setting what methods are logged
    checks = new ArrayList<CheckBox>();
    int numColumns = logNames.size() / 15;
    if (logNames.size() % 15 > 0) {
        numColumns++;
    }
    Grid grid = new Grid(15, numColumns);
    int currCol = 0;
    int currRow = 0;
    HTMLTable.CellFormatter fmt = grid.getCellFormatter();
    for (String currName : logNames) {
        CheckBox cb = new CheckBox(currName);
        cb.setName(currName);
        String dispName = Util.logCodeToDisplay(currName);
        if (dispName != null) {
            cb.setText(dispName);
        }
        if (selected.contains(currName)) {
            cb.setChecked(true);
        }
        checks.add(cb);
        fmt.setStylePrimaryName(currRow, currCol, "viz-logGridCell");
        grid.setWidget(currRow++, currCol, cb);
        if (currRow >= 15) {
            currRow = 0;
            currCol++;
        }
    }
    mainPanel.add(grid);

    //
    // Add in the pop-up for setting the log level
    levelMenu = new ListBox();
    String[] levels = new String[] { "SEVERE", "WARNING", "INFO", "CONFIG", "FINE", "FINER", "FINEST" };
    for (int i = 0; i < levels.length; i++) {
        levelMenu.addItem(levels[i]);
        if (levels[i].equals(initialLogLevel)) {
            levelMenu.setSelectedIndex(i);
        }
    }
    levelMenu.setVisibleItemCount(1);

    HorizontalPanel selectLevelPanel = new HorizontalPanel();
    selectLevelPanel.add(new Label("Set log level: "));
    selectLevelPanel.add(levelMenu);
    selectLevelPanel.setStylePrimaryName("viz-logLevelSelect");
    mainPanel.add(selectLevelPanel);

    Button cancel = new Button("Cancel");
    cancel.addClickListener(new ClickListener() {
        public void onClick(Widget arg0) {
            hide();
        }
    });
    mainPanel.add(cancel);

    Button changeMe = new Button("Change " + this.idStr);
    changeMe.addClickListener(new ClickListener() {
        public void onClick(Widget w) {
            doChange(false);
        }
    });
    mainPanel.add(changeMe);

    Button changeAll = new Button("Change All");
    changeAll.addClickListener(new ClickListener() {
        public void onClick(Widget w) {
            doChange(true);
        }
    });
    mainPanel.add(changeAll);
    setWidget(mainPanel);
    setPopupPosition(30, 30);
}

From source file:com.sun.labs.aura.dbbrowser.client.viz.SettingsDialog.java

License:Open Source License

public SettingsDialog(List<String> logCodes) {
    super(false);
    this.logCodes = logCodes;
    String[] selectedCodes = Util.getStatDisplayCodes();
    List<String> selected = Arrays.asList(selectedCodes);

    setText("Edit Settings");

    FlowPanel mainPanel = new FlowPanel();
    FlowPanel repStatPanel = new FlowPanel();
    repStatPanel.setStylePrimaryName("viz-settingsGroup");
    repStatPanel.add(new Label("Show these Replicant Stats:"));
    checks = new ArrayList<CheckBox>();
    int numColumns = logCodes.size() / 15;
    if (logCodes.size() % 15 > 0) {
        numColumns++;//from ww w  . jav a2s .  c o  m
    }
    Grid grid = new Grid(15, numColumns);
    int currCol = 0;
    int currRow = 0;
    HTMLTable.CellFormatter fmt = grid.getCellFormatter();
    for (String currName : logCodes) {
        CheckBox cb = new CheckBox(currName);
        cb.setName(currName);
        String dispName = Util.logCodeToDisplay(currName);
        if (dispName != null) {
            cb.setText(dispName);
        }
        if (selected.contains(currName)) {
            cb.setChecked(true);
        }
        checks.add(cb);
        fmt.setStylePrimaryName(currRow, currCol, "viz-logGridCell");
        grid.setWidget(currRow++, currCol, cb);
        if (currRow >= 15) {
            currRow = 0;
            currCol++;
        }
    }
    repStatPanel.add(grid);
    mainPanel.add(repStatPanel);

    Button cancel = new Button("Cancel");
    cancel.addClickListener(new ClickListener() {
        public void onClick(Widget arg0) {
            hide();
        }
    });
    mainPanel.add(cancel);

    Button save = new Button("Save");
    save.addClickListener(new ClickListener() {
        public void onClick(Widget w) {
            doSave();
            hide();
        }
    });
    mainPanel.add(save);

    setWidget(mainPanel);
    setPopupPosition(30, 30);
}

From source file:net.randomhacks.wave.voting.approval.client.ChoicesTable.java

License:Apache License

private void updateChoiceRow(int i, Choice choice, boolean isWritable) {
    Log.debug("Updating row " + Integer.toString(i) + ": " + choice.key);
    CheckBox checkBox = (CheckBox) getWidget(rowForChoiceIndex(i), 0);
    checkBox.setValue(choice.wasChosenByMe);
    String label = choice.name;/*w w w  .j  av  a 2s  .co  m*/
    if (choice.votes > 0)
        label += " (" + Integer.toString(choice.votes) + ")";
    checkBox.setText(label);
    if (choice.isWinner)
        checkBox.addStyleName("winningChoice");
    else
        checkBox.removeStyleName("winningChoice");
    checkBox.setEnabled(isWritable);
}

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//  ww w  . j  a  v a2 s.c  o 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);
}