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

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

Introduction

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

Prototype

@Deprecated
public boolean isChecked() 

Source Link

Document

Determines whether this check box is currently checked.

Usage

From source file:com.gwtmodel.table.view.grid.GridView.java

License:Apache License

@Override
public Object getCell(int row, int c) {
    Widget w = getW(row, c);//from   ww  w.  j a  va 2  s  .  co m
    switch (gType.getgType()) {
    case BOOLEAN:
        CheckBox ce = (CheckBox) w;
        boolean b = ce.isChecked();
        return b;
    case DECIMAL:
        NumerW nw = (NumerW) w;
        IFormLineView i = nw.iF;
        BigDecimal bi = (BigDecimal) i.getValObj();
        return bi;
    }
    return null;
}

From source file:com.objetdirect.tatami.demo.client.GfxDemo.java

License:Open Source License

/**
 * Shows a popup to select a color for the background or the stroke.
 * The popup contains a TabPanel with 3 tab, a <code>ColorChooser</code>,
 *  a <code>Slider</code> to change the opacity of the <code>Color</code>,
 *  some <code>Pattern</code> to apply
 *///  w w w  .  j  a  v a  2s .co m
private void showPopupColor(Widget sender) {

    final PopupPanel popupColor = new PopupPanel(true);
    popupColor.addStyleName("GfxDemo-popupColor");
    TabPanel tabPanel = new TabPanel();
    FlowPanel colPanel = new FlowPanel();

    final CheckBox checkFill = new CheckBox("Background");
    checkFill.setChecked(true);
    colPanel.add(checkFill);

    final ColorChooser colorChooser = new ColorChooser();

    colPanel.add(colorChooser);

    tabPanel.add(colPanel, new Label("Color"));

    ChangeListener colorChange = new ChangeListener() {
        public void onChange(Widget sender) {
            String color = colorChooser.getColor();
            Color colorSelected = Color.getColor(color);
            if (checkFill.isChecked()) {
                currentFillColor = colorSelected;
                DOM.setStyleAttribute(fill.getElement(), "backgroundColor", color);
                //currentFillColor.setAlpha(opacity.getValue());
                if (current != null) {
                    current.setFillColor(currentFillColor);
                }
            } else {
                currentStrokeColor = colorSelected;
                lastStrokeColor = currentStrokeColor;
                DOM.setStyleAttribute(fill.getElement(), "borderColor", color);
                if (current != null) {

                    current.setStroke(currentStrokeColor, 1);
                }
            }
        }
    };
    colorChooser.addChangeListener(colorChange);

    FlowPanel patternContainer = new FlowPanel();

    patternContainer.add(createImagePattern("gfx/none.gif"));
    patternContainer.add(createImagePattern("littleNero.png"));
    patternContainer.add(createImagePattern("littleTrajan.png"));
    patternContainer.add(createImagePattern("cubic.jpg"));
    patternContainer.add(createImagePattern("logo_ft.gif"));
    patternContainer.add(createImagePattern("od-logo.jpg"));
    tabPanel.add(patternContainer, new Label("Pattern"));
    tabPanel.add(this.opacity, new Label("Opacity"));

    tabPanel.selectTab(0);
    popupColor.add(tabPanel);
    popupColor.setPopupPosition(sender.getAbsoluteLeft(), sender.getAbsoluteTop());
    popupColor.show();
}

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

License:Open Source License

public void doChange(final boolean all) {
    selected = new ArrayList<String>();
    for (CheckBox cb : checks) {
        if (cb.isChecked()) {
            selected.add(cb.getName());//w w w  .jav a  2s.  co m
        }
    }

    VizServiceAsync service = GWTMainEntryPoint.getVizService();
    final AsyncCallback callback = new AsyncCallback() {
        public void onSuccess(Object result) {
            doChange2(all);
        }

        public void onFailure(Throwable caught) {
            VizUI.alert("Communication failed: " + caught.getMessage());
        }
    };

    service.setRepSelectedLogNames(all ? null : idStr, selected, callback);
}

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

License:Open Source License

protected void doSave() {
    ArrayList<String> list = new ArrayList<String>();
    for (CheckBox check : checks) {
        if (check.isChecked()) {
            list.add(check.getName());/*from ww  w  .j av a2  s .c  om*/
        }
    }
    Util.setStatDisplayCodes(list);
}

From source file:com.xpn.xwiki.watch.client.ui.filterbar.StateSelectorsWidget.java

License:Open Source License

public StateSelectorsWidget(Watch w) {
    super(w);//from w w w. j a  v a 2 s . c  o m
    setPanel(new FlowPanel());
    initWidget(panel);
    init();
    panel.setStyleName(watch.getStyleName("filter", "filter"));
    panel.add(getSeeOnlyTitlePanel());
    this.flaggedCheckBox = new CheckBox();
    panel.add(getCheckBoxPanel(this.flaggedCheckBox, "flagged", (watch.getFilterStatus().getFlagged() == 1),
            new ClickListener() {
                public void onClick(Widget widget) {
                    if (((CheckBox) widget).isChecked()) {
                        watch.refreshOnShowOnlyFlaggedArticles();
                        // Uncheck the trashed checkbox
                        CheckBox trashedCheckBox = getTrashedCheckBox();
                        if (trashedCheckBox.isChecked()) {
                            trashedCheckBox.setChecked(false);
                        }
                    } else {
                        watch.refreshOnNotShowOnlyFlaggedArticles();
                    }
                }
            }));
    this.readCheckBox = new CheckBox();
    panel.add(getCheckBoxPanel(this.readCheckBox, "read", (watch.getFilterStatus().getRead() == 1),
            new ClickListener() {
                public void onClick(Widget widget) {
                    if (((CheckBox) widget).isChecked()) {
                        watch.refreshOnShowOnlyReadArticles();
                        // Uncheck the unread checkbox
                        CheckBox unreadCheckBox = getUnreadCheckBox();
                        if (unreadCheckBox.isChecked()) {
                            unreadCheckBox.setChecked(false);
                        }
                    } else {
                        watch.refreshOnNotShowOnlyReadArticles();
                    }
                }
            }));
    this.unreadCheckBox = new CheckBox();
    panel.add(getCheckBoxPanel(this.unreadCheckBox, "unread", (watch.getFilterStatus().getRead() == -1),
            new ClickListener() {
                public void onClick(Widget widget) {
                    if (((CheckBox) widget).isChecked()) {
                        watch.refreshOnShowOnlyUnReadArticles();
                        // Uncheck the read articles checkbox
                        CheckBox readCheckBox = getReadCheckBox();
                        if (readCheckBox.isChecked()) {
                            readCheckBox.setChecked(false);
                        }
                    } else {
                        watch.refreshOnNotShowOnlyUnReadArticles();
                    }
                }
            }));
    this.trashedCheckBox = new CheckBox();
    panel.add(getCheckBoxPanel(this.trashedCheckBox, "trashed", (watch.getFilterStatus().getTrashed() == 1),
            new ClickListener() {
                public void onClick(Widget widget) {
                    if (((CheckBox) widget).isChecked()) {
                        watch.refreshOnShowOnlyTrashedArticles();
                        // Uncheck the flagged checkbox
                        CheckBox flaggedCheckBox = getFlaggedCheckBox();
                        if (flaggedCheckBox.isChecked()) {
                            flaggedCheckBox.setChecked(false);
                        }
                    } else {
                        watch.refreshOnNotShowOnlyTrashedArticles();
                    }
                }
            }));
}

From source file:edu.ucsb.eucalyptus.admin.client.EucalyptusWebInterface.java

License:Open Source License

public void displayUserRecordPage(Panel parent, UserInfoWeb userToEdit) {
    final String oldPassword;
    final boolean admin;
    final boolean newUser;
    final boolean showSkipConfirmed;
    boolean isAdminChecked = false; // not admin by default
    boolean skipConfirmationChecked = previousSkipConfirmation;

    if (loggedInUser != null && (loggedInUser.isAdministrator() != null && loggedInUser.isAdministrator())) {
        admin = true;/*w ww  . ja  v a2  s .  c o  m*/
    } else {
        admin = false;
    }
    if (userToEdit == null) {
        newUser = true;
        showSkipConfirmed = true;
        userToEdit = new UserInfoWeb();
        oldPassword = "";
        if (admin) {
            label_box.setText("Please, fill out the form to add a user");
        } else {
            label_box.setText(signup_greeting); // Please, fill out the form:
        }
    } else {
        newUser = false;
        oldPassword = userToEdit.getPassword();
        isAdminChecked = userToEdit.isAdministrator() != null && userToEdit.isAdministrator();
        showSkipConfirmed = userToEdit.isConfirmed() == null || !userToEdit.isConfirmed();
        skipConfirmationChecked = userToEdit.isConfirmed() != null && userToEdit.isConfirmed();

        String status;
        if (userToEdit.isApproved() == null || !userToEdit.isApproved()) {
            status = "unapproved";
        } else if (userToEdit.isEnabled() == null || !userToEdit.isEnabled()) {
            status = "disabled";
        } else if (userToEdit.isConfirmed() == null || !userToEdit.isConfirmed()) {
            status = "unconfirmed";
        } else {
            status = "active";
        }
        if (userToEdit.isAdministrator() != null && userToEdit.isAdministrator()) {
            status += " & admin";
        }
        label_box.setText("Editing information for user '" + userToEdit.getUserName() + "' (" + status + ")");
    }
    label_box.setStyleName("euca-greeting-normal");

    int rowsMandatory = 5;
    if (admin) {
        rowsMandatory++; // for admin checkbox
        if (showSkipConfirmed) {
            rowsMandatory++; // for skip confirmation checkbox
        }
    }
    final Grid g1 = new Grid(rowsMandatory, 3);
    g1.getColumnFormatter().setWidth(0, "180");
    g1.getColumnFormatter().setWidth(1, "180");
    g1.getColumnFormatter().setWidth(2, "180");
    int i = 0;

    final Label label_mandatory = new Label("Mandatory fields:");
    label_mandatory.setStyleName("euca-section-header");

    final int userName_row = i;
    g1.setWidget(i, 0, new Label("Username:"));
    g1.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    final TextBox userName_box = new TextBox();
    userName_box.setText(userToEdit.getUserName());
    userName_box.setWidth("180");
    if (!newUser) {
        userName_box.setEnabled(false);
    }
    g1.setWidget(i++, 1, userName_box);

    // optional row
    final CheckBox userIsAdmin = new CheckBox("Administrator");
    userIsAdmin.setChecked(isAdminChecked);
    userIsAdmin.setStyleName("euca-remember-text");
    if (admin) {
        g1.setWidget(i++, 1, userIsAdmin);
    }

    final int password1_row = i;
    g1.setWidget(i, 0, new Label("Password:"));
    g1.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    final PasswordTextBox cleartextPassword1_box = new PasswordTextBox();
    cleartextPassword1_box.setText(userToEdit.getPassword());
    cleartextPassword1_box.setWidth("180");
    if ((!admin && !newUser)
            || (userToEdit.isAdministrator() != null && userToEdit.isAdministrator().booleanValue())) {
        cleartextPassword1_box.setEnabled(false);
    }
    g1.setWidget(i++, 1, cleartextPassword1_box);

    final int password2_row = i;
    g1.setWidget(i, 0, new Label("Password, again:"));
    g1.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    final PasswordTextBox cleartextPassword2_box = new PasswordTextBox();
    cleartextPassword2_box.setText(userToEdit.getPassword());
    cleartextPassword2_box.setWidth("180");
    if ((!admin && !newUser)
            || (userToEdit.isAdministrator() != null && userToEdit.isAdministrator().booleanValue())) {
        cleartextPassword2_box.setEnabled(false);
    }
    g1.setWidget(i++, 1, cleartextPassword2_box);

    final int realName_row = i;
    g1.setWidget(i, 0, new Label("Full Name:"));
    g1.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    final TextBox realName_box = new TextBox();
    realName_box.setText(userToEdit.getRealName());
    realName_box.setWidth("180");
    g1.setWidget(i++, 1, realName_box);

    final int emailAddress_row = i;
    g1.setWidget(i, 0, new Label("Email address:"));
    g1.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    final TextBox emailAddress_box = new TextBox();
    emailAddress_box.setText(userToEdit.getEmail());
    emailAddress_box.setWidth("180");
    g1.setWidget(i++, 1, emailAddress_box);

    // optional row
    final CheckBox skipConfirmation = new CheckBox("Skip email confirmation");
    skipConfirmation.setChecked(skipConfirmationChecked);
    skipConfirmation.setStyleName("euca-remember-text");
    if (admin && showSkipConfirmed) {
        g1.setWidget(i++, 1, skipConfirmation);
    }

    /* these widgets are allocated, but not necessarily used */
    final Grid g2 = new Grid();
    final Label label_optional = new Label("Optional fields:");
    label_optional.setStyleName("euca-section-header");
    final TextBox telephoneNumber_box = new TextBox();
    final TextBox projectPIName_box = new TextBox();
    final TextBox affiliation_box = new TextBox();
    final TextArea projectDescription_box = new TextArea();

    int extra_fields = 0;
    if (request_telephone) {
        extra_fields++;
    }
    if (request_project_leader) {
        extra_fields++;
    }
    if (request_affiliation) {
        extra_fields++;
    }
    if (request_project_description) {
        extra_fields++;
    }

    if (extra_fields > 0) {
        g2.resize(extra_fields, 2);
        g2.getColumnFormatter().setWidth(0, "180");
        g2.getColumnFormatter().setWidth(1, "360");
        i = 0;

        if (request_telephone) {
            g2.setWidget(i, 0, new Label("Telephone Number:"));
            g2.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
            telephoneNumber_box.setWidth("180");
            telephoneNumber_box.setText(userToEdit.getTelephoneNumber());
            g2.setWidget(i++, 1, telephoneNumber_box);
        }

        if (request_project_leader) {
            g2.setWidget(i, 0, new Label("Project Leader:"));
            g2.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
            projectPIName_box.setText(userToEdit.getProjectPIName());
            projectPIName_box.setWidth("180");
            g2.setWidget(i++, 1, projectPIName_box);
        }

        if (request_affiliation) {
            g2.setWidget(i, 0, new Label("Affiliation:"));
            g2.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
            affiliation_box.setText(userToEdit.getAffiliation());
            affiliation_box.setWidth("360");
            g2.setWidget(i++, 1, affiliation_box);
        }

        if (request_project_description) {
            g2.setWidget(i, 0, new Label("Project Description:"));
            g2.getCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_RIGHT);
            projectDescription_box.setText(userToEdit.getProjectDescription());
            projectDescription_box.setWidth("360");
            projectDescription_box.setHeight("50");
            g2.setWidget(i++, 1, projectDescription_box);
        }
    }

    ClickListener SignupButtonListener = new ClickListener() {
        public void onClick(Widget sender) {
            boolean formOk = true;

            for (int j = 0; j < 4; j++) {
                g1.clearCell(j, 2); /* clear previous right-hand-side annotations */
            }

            // perform checks
            if (userName_box.getText().length() < 1) {
                Label l = new Label("Username is empty!");
                l.setStyleName("euca-error-hint");
                g1.setWidget(userName_row, 2, l);
                formOk = false;
            } else {
                // do this in the else-clause so the empty username doesn't match here
                if (cleartextPassword1_box.getText().toLowerCase()
                        .matches(".*" + userName_box.getText().toLowerCase() + ".*")) {
                    Label l = new Label("Password may not contain the username!");
                    l.setStyleName("euca-error-hint");
                    g1.setWidget(password1_row, 2, l);
                    formOk = false;
                }
            }

            if (userName_box.getText().matches(".*[^\\w\\-\\.@]+.*")) {
                Label l = new Label("Invalid characters in the username!");
                l.setStyleName("euca-error-hint");
                g1.setWidget(userName_row, 2, l);
                formOk = false;
            }

            if (userName_box.getText().length() > 30) {
                Label l = new Label("Username is too long, sorry!");
                l.setStyleName("euca-error-hint");
                g1.setWidget(userName_row, 2, l);
                formOk = false;
            }

            if (cleartextPassword1_box.getText().length() < minPasswordLength) {
                Label l = new Label("Password must be at least " + minPasswordLength + " characters long!");
                l.setStyleName("euca-error-hint");
                g1.setWidget(password1_row, 2, l);
                formOk = false;
            }
            if (!cleartextPassword1_box.getText().equals(cleartextPassword2_box.getText())) {
                Label l = new Label("Passwords do not match!");
                l.setStyleName("euca-error-hint");
                g1.setWidget(password2_row, 2, l);
                formOk = false;
            }
            if (realName_box.getText().equalsIgnoreCase(cleartextPassword1_box.getText())
                    || userName_box.getText().equalsIgnoreCase(cleartextPassword1_box.getText())) {
                Label l = new Label("Password may not be your name or username!");
                l.setStyleName("euca-error-hint");
                g1.setWidget(password1_row, 2, l);
                formOk = false;
            }

            if (realName_box.getText().length() < 1) {
                Label l = new Label("Name is empty!");
                l.setStyleName("euca-error-hint");
                g1.setWidget(realName_row, 2, l);
                formOk = false;
            }
            if (emailAddress_box.getText().length() < 1) {
                Label l = new Label("Email address is empty!");
                l.setStyleName("euca-error-hint");
                g1.setWidget(emailAddress_row, 2, l);
                formOk = false;
            }

            if (formOk) {
                label_box.setText("Checking with the server...");
                label_box.setStyleName("euca-greeting-pending");
                String enteredPassword = cleartextPassword1_box.getText();
                String encryptedPassword = GWTUtils.md5(enteredPassword);
                if (enteredPassword.equals(oldPassword)) {
                    encryptedPassword = enteredPassword; // it was not changed in the edit
                }
                final UserInfoWeb userToSave = new UserInfoWeb(userName_box.getText(), realName_box.getText(),
                        emailAddress_box.getText(), encryptedPassword);
                if (admin) {
                    userToSave.setAdministrator(userIsAdmin.isChecked());
                    if (showSkipConfirmed) {
                        previousSkipConfirmation = skipConfirmation.isChecked(); // remember value for the future
                        userToSave.setConfirmed(previousSkipConfirmation);
                    }
                }
                if (telephoneNumber_box.getText().length() > 0) {
                    userToSave.setTelephoneNumber(telephoneNumber_box.getText());
                }
                if (affiliation_box.getText().length() > 0) {
                    userToSave.setAffiliation(affiliation_box.getText());
                }
                if (projectDescription_box.getText().length() > 0) {
                    userToSave.setProjectDescription(projectDescription_box.getText());
                }
                if (projectPIName_box.getText().length() > 0) {
                    userToSave.setProjectPIName(projectPIName_box.getText());
                }
                if (newUser) {
                    EucalyptusWebBackend.App.getInstance().addUserRecord(
                            sessionId, /* will be null if anonymous user signs up */
                            userToSave, new AsyncCallback() {
                                public void onSuccess(Object result) {
                                    displayDialog("Thank you!", (String) result);
                                }

                                public void onFailure(Throwable caught) {
                                    String m = caught.getMessage();
                                    if (m.equals("User already exists")) {
                                        g1.setWidget(userName_row, 2, new Label("Username is taken!"));
                                        label_box.setText("Please, fix the error and resubmit:");
                                        label_box.setStyleName("euca-greeting-warning");
                                    } else {
                                        displayErrorPage(m);
                                    }
                                }
                            });
                } else {
                    EucalyptusWebBackend.App.getInstance().updateUserRecord(sessionId, userToSave,
                            new AsyncCallback() {
                                public void onSuccess(Object result) {
                                    if (loggedInUser.getUserName().equals(userToSave.getUserName())) {
                                        loggedInUser.setRealName(userToSave.getRealName());
                                        loggedInUser.setEmail(userToSave.getEmail());
                                        loggedInUser.setPassword(userToSave.getPassword());
                                        loggedInUser.setTelephoneNumber(userToSave.getTelephoneNumber());
                                        loggedInUser.setAffiliation(userToSave.getAffiliation());
                                        loggedInUser.setProjectDescription(userToSave.getProjectDescription());
                                        loggedInUser.setProjectPIName(userToSave.getProjectPIName());
                                        displayDialog("", (String) result);

                                    } else { // admin updating a user
                                        displayBarAndTabs("");
                                        statusMessage.setText((String) result);
                                    }
                                }

                                public void onFailure(Throwable caught) {
                                    String m = caught.getMessage();
                                    displayErrorPage(m);
                                }
                            });
                }
            } else {
                label_box.setText("Please, fix the errors and resubmit:");
                label_box.setStyleName("euca-greeting-warning");
            }
        }
    };

    Button submit_button;
    if (newUser) {
        if (admin) {
            submit_button = new Button("Add user", SignupButtonListener);
        } else {
            submit_button = new Button("Sign up", SignupButtonListener);
        }
    } else {
        submit_button = new Button("Update Record", SignupButtonListener);
    }

    Button cancel_button = new Button("Cancel", DefaultPageButtonListener);
    VerticalPanel mpanel = new VerticalPanel();
    mpanel.add(label_mandatory);
    mpanel.add(g1);

    VerticalPanel opanel = new VerticalPanel();
    if (extra_fields > 0) {
        opanel.add(label_optional);
        opanel.add(g2);
    }

    HorizontalPanel bpanel = new HorizontalPanel();
    bpanel.add(submit_button);
    bpanel.add(new HTML("&nbsp;&nbsp;or&nbsp;&nbsp;"));
    bpanel.add(cancel_button);

    VerticalPanel vpanel = new VerticalPanel();
    vpanel.setSpacing(15);
    vpanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    vpanel.add(new HTML("<br/>"));
    if (logo != null) {
        addLogoWithText(vpanel);
        vpanel.add(new HTML("<br/>"));
    }
    ;
    vpanel.add(label_box);
    vpanel.add(mpanel);
    vpanel.add(opanel);
    vpanel.add(bpanel);

    VerticalPanel wrapper = new VerticalPanel();
    wrapper.add(vpanel);
    wrapper.setSize("100%", "100%");
    wrapper.setCellHorizontalAlignment(vpanel, VerticalPanel.ALIGN_CENTER);
    //        wrapper.setCellVerticalAlignment(vpanel, VerticalPanel.ALIGN_MIDDLE);

    parent.clear();
    parent.add(wrapper);
}

From source file:gov.nih.nci.ncicb.tcgaportal.level4.gwt.anomalysearch.client.results.ResultsTable.java

protected String makeListFromCheckedRows() {
    StringBuilder ret = new StringBuilder();
    for (int irow = 0, max = results.getActualRowCount(); irow < max; irow++) {
        Widget w = getWidget(irow + 1, 0);
        if (w instanceof CheckBox) {
            CheckBox tableItem = (CheckBox) w;
            if (tableItem.isChecked()) {
                if (ret.length() != 0) {
                    ret.append(", ");
                }/*from  w w w  . ja  va2  s. c  o m*/
                ret.append(tableItem.getText());
                tableItem.setChecked(false);
            }
        }
    }
    //and the top check box
    Widget w = getWidget(0, 0);
    if (w instanceof SortingLinkWithCheckbox) {
        ((SortingLinkWithCheckbox) w).setChecked(false);
    }
    return ret.toString();
}

From source file:net.europa13.taikai.web.client.ui.PlayerTournamentsList.java

License:Open Source License

private void addTournamentConnection(TournamentProxy selectedTournament) {

    Logger.trace("entering addTournamentConnection(TournamentProxy) in PlayerTournamentList");

    if (tournaments == null) {
        Logger.debug("addTournamentConnection in PlayerTournamentList: tournaments is null");
    }//from   ww  w.jav  a2 s. c  o  m
    final int nbrTournaments = sizeConsitencyCheck();

    TournamentSelector tournamentControl = new TournamentSelector();
    setTournamentControlData(tournamentControl, selectedTournament);
    tournamentControls.add(tournamentControl);

    final CheckBox activateSeedControl = new CheckBox("Seeda");

    activateSeedControls.add(activateSeedControl);

    final SeedSelector seedControl = new SeedSelector();
    Logger.debug("seedControl.setTournament");
    seedControl.setData(tournamentControl.getSelectedTournament(), player);
    seedControls.add(seedControl);

    activateSeedControl.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {
            //                CheckBox cb = (CheckBox)sender;
            seedControl.setEnabled(activateSeedControl.isChecked());
        }
    });

    if (player != null && player.getPlayerSeedInTournament(selectedTournament) > -1) {
        activateSeedControl.setChecked(true);
        seedControl.setEnabled(true);
    } else {
        seedControl.setEnabled(false);
    }

    //        tournamentControl.addChangeListener(new TournamentChangeListener(seedControl));
    tournamentControl.addChangeListener(new ChangeListener() {

        public void onChange(Widget sender) {
            TournamentSelector tournamentSelector = (TournamentSelector) sender;
            seedControl.setData(tournamentSelector.getSelectedTournament(), player);

            activateSeedControl.setChecked(false);
            seedControl.setEnabled(false);
        }
    });

    activateSeedControl.addClickListener(new ClickListener() {
        //            private int row = nbrTournaments;
        public void onClick(Widget checkBox) {
            Logger.debug("Klickade p checkBox");
            int rowToChange = -1;
            for (int i = 0; i < getRowCount(); i++) {
                if (checkBox.equals(getWidget(i, 1))) {
                    rowToChange = i;
                    break;
                }
            }
            Logger.debug("rowToChange=" + rowToChange);
            if (rowToChange >= 0) {
                Widget w = getWidget(rowToChange, 2);
                if (w instanceof ListBox) {
                    Logger.debug("ndrar Enabled p rad " + rowToChange + " kolumn 2");
                    ((CheckBox) w).setVisible(false);
                }
            }
            //                removeTournamentConnection(row);
        }
    });

    //        if (nbrTournaments > 0) {
    Button drbtn = new Button("Ta bort");
    drbtn.addClickListener(new ClickListener() {
        //            private int row = nbrTournaments;
        public void onClick(Widget button) {
            int rowToRemove = -1;
            for (int i = 0; i < getRowCount(); i++) {
                if (button.equals(getWidget(i, 3))) {
                    rowToRemove = i;
                    break;
                }
            }
            if (rowToRemove >= 0) {
                removeTournamentConnection(rowToRemove);
            }
            //                removeTournamentConnection(row);
        }
    });
    //        }

    setWidget(nbrTournaments, 0, tournamentControl);
    setWidget(nbrTournaments, 1, activateSeedControl);
    setWidget(nbrTournaments, 2, seedControl);
    setWidget(nbrTournaments, 3, drbtn);
    setWidget(nbrTournaments + 1, 0, btnAddTournamentConnection);
    getFlexCellFormatter().setColSpan(nbrTournaments + 1, 0, 2);

    Logger.trace("exiting addTournamentConnection(TournamentProxy) in PlayerTournamentList");

}

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);/*from  ww w  .j a v  a 2s. c  o 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.BackupManager.java

License:Apache License

private Widget newImportPackageWidget(final CheckBox overWriteCheckBox) {

    final FormPanel uploadFormPanel = new FormPanel();
    uploadFormPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
    uploadFormPanel.setMethod(FormPanel.METHOD_POST);

    HorizontalPanel panel = new HorizontalPanel();
    uploadFormPanel.setWidget(panel);//  w  ww  . j  ava 2s  .  c  o  m

    final FileUpload upload = new FileUpload();
    upload.setName(HTMLFileManagerFields.FILE_UPLOAD_FIELD_NAME_IMPORT);
    panel.add(upload);

    panel.add(new Label("import:"));
    ImageButton ok = new ImageButton("images/upload.gif");
    ok.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            uploadFormPanel.setAction(GWT.getModuleBaseURL() + "backup?packageImport=true&importAsNew="
                    + !overWriteCheckBox.isChecked());
            doImportFile(uploadFormPanel);
        }

        private void doImportFile(final FormPanel uploadFormPanel) {
            if ((overWriteCheckBox.isChecked() && Window.confirm(
                    "Are you sure you want to import? This will erase any content in the package currently?"))
                    || !overWriteCheckBox.isChecked()) {
                LoadingPopup.showMessage(
                        "Importing package to repository, please wait, as this could take some time...");
                uploadFormPanel.submit();
            }
        }
    });

    panel.add(ok);

    uploadFormPanel.addFormHandler(new FormHandler() {
        public void onSubmitComplete(FormSubmitCompleteEvent event) {
            if (event.getResults().indexOf("OK") > -1) {
                Window.alert(
                        "Rules package imported successfully. Please refresh your browser (F5) to show the new content. ");
            } else {
                ErrorPopup.showMessage(
                        "Unable to import into the repository. Consult the server logs for error messages.");
            }
            LoadingPopup.close();
        }

        public void onSubmit(FormSubmitEvent event) {
            if (upload.getFilename().length() == 0) {
                Window.alert("You did not specify an exported repository package filename !");
                event.setCancelled(true);
            } else if (!upload.getFilename().endsWith(".xml")) {
                Window.alert("Please specify a valid repository package xml file.");
                event.setCancelled(true);
            }

        }
    });

    return uploadFormPanel;
}