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

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

Introduction

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

Prototype

@Override
    public void setName(String name) 

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   www. jav a 2  s. c  om
    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:ca.upei.ic.timetable.client.DepartmentModelView.java

License:Apache License

public void loadJSON(JSONValue value) {
    JSONArray array = (JSONArray) value;

    // iterate all json results
    for (int i = 0; i < array.size(); i++) {
        JSONString s = (JSONString) array.get(i);
        CheckBox box = new CheckBox(s.stringValue());
        box.setName(s.stringValue());
        // add the click listener
        box.addClickListener(new ClickListener() {

            public void onClick(Widget sender) {
                final CheckBox box = (CheckBox) sender;
                final String name = box.getName();
                controller_.setDepartmentCriteria(name, box.isChecked());
            }// w  ww. jav  a  2s . c  om

        });
        panel_.add(box);
    }
}

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

License:Apache License

public void loadJSON(JSONValue value) {
    JSONArray array = (JSONArray) value;
    // load the values
    for (int i = 0; i < array.size(); i++) {
        // set value and name
        JSONString s = (JSONString) array.get(i);
        CheckBox box = new CheckBox("Level " + s.stringValue());
        box.setName(s.stringValue()); // to store the value
        box.setChecked(true);/*from  w w w . j a  v  a 2  s.  c om*/
        controller_.setLevelCriteria(s.stringValue(), true);

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

            public void onClick(Widget sender) {
                final CheckBox box = (CheckBox) sender;
                final String name = box.getName();
                controller_.setLevelCriteria(name, box.isChecked());
            }

        });

        panel_.add(box);
    }
}

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

License:Apache License

public void loadJSON(JSONValue value) {
    JSONArray array = (JSONArray) value;

    // get the current month
    int month = new Date().getMonth() + 1;

    // iterate all json results
    for (int i = 0; i < array.size(); i++) {
        JSONString s = (JSONString) array.get(i);
        String name = s.stringValue();

        CheckBox box = new CheckBox(name);
        box.setName(name);
        if (name.equals("First Semester") && month > 6 && month < 11) {
            box.setChecked(true);/*  www  . j  av a 2s  . com*/
            controller_.setSemesterCriteria(name, true);
        }
        if (name.equals("Second Semester") && (month > 10 || month < 4)) {
            box.setChecked(true);
            controller_.setSemesterCriteria(name, true);
        }
        // add the click listener
        box.addClickListener(new ClickListener() {

            public void onClick(Widget sender) {
                final CheckBox box = (CheckBox) sender;
                final String name = box.getName();
                controller_.setSemesterCriteria(name, box.isChecked());
            }

        });
        panel_.add(box);
    }
}

From source file:client.argon.panel.ArgonInternalLinkListPanel.java

License:Open Source License

/**
 * @param result/*from  w w  w. j av a 2 s.  c  o  m*/
 *            the list of links
 */
@Override
public final void onData(final Object result) {

    final InternalLinkList links = (InternalLinkList) result;
    RudListener.getInstance().getChecked().clear();

    this.reset();

    for (int i = 0; i < links.getLinks().size(); ++i) {

        final TableRow row = new TableRow();
        final InternalLink l = ((InternalLink) links.getLinks().get(i));

        // TODO: make more generic
        this.fillTable(row, l);

        // the checkbox to delete a link
        final CheckBox deleteBox = new CheckBox();
        // Router can be identified by their LoopBackAddress
        deleteBox.setName(l.getUniqueLabel());
        deleteBox.addClickListener(RudListener.getInstance());
        row.addField(deleteBox);

        if (null != l.getPopup()) {
            row.setDialog(new InfoDialog("Info", l.getPopup()));
        }

        this.addRow(row);

    }

    if (0 == links.getLinks().size()) {
        this.addDummyRow("Nothing found...");
    }

    this.flush();

    // notify listeners (i.e. button and gif from ReservationAdmin)
}

From source file:client.template.panel.LinkListPanel.java

License:Open Source License

/**
 * @param result//from  ww  w  .  j  a va  2s .c  o m
 *            the list of links
 */
@Override
public void onData(final Object result) {

    // enable buttons again, this should be somewhere else TODO

    final EndpointList links = (EndpointList) result;
    RudListener.getInstance().getChecked().clear();

    this.reset();

    for (int i = 0; i < links.getLinks().size(); ++i) {

        final TableRow row = new TableRow();
        final Endpoint l = ((Endpoint) links.getLinks().get(i));

        // TODO: make more generic
        this.fillTable(row, l);

        // the checkbox to delete a link
        final CheckBox deleteBox = new CheckBox();
        // Router can be identified by their LoopBackAddress
        deleteBox.setName(l.getUniqueLabel());
        deleteBox.addClickListener(RudListener.getInstance());
        row.addField(deleteBox);

        if (null != l.getPopup()) {
            row.setDialog(new InfoDialog("Info", l.getPopup()));
        }

        this.addRow(row);

    }

    if (0 == links.getLinks().size()) {
        this.addDummyRow("Nothing found...");
    }

    this.flush();

    // notify listeners (i.e. button and gif from ReservationAdmin)
}

From source file:client.template.panel.ReservationListPanel.java

License:Open Source License

/**
 *
 *//*from w ww . j  a va  2s . c  om*/
@Override
public final void onData(final Object result) {

    // enable buttons again, this should be somewhere else TODO

    final ReservationList reservations = (ReservationList) result;
    RudListener.getInstance().getChecked().clear();

    this.reset();

    for (int i = 0; i < reservations.getReservations().size(); ++i) {

        final TableRow row = new TableRow();
        final Reservation res = ((Reservation) reservations.getReservations().get(i));

        row.addField("" + res.getId());
        row.addField("-");
        row.addField("-");

        final CheckBox box = new CheckBox();
        box.setName("" + res.getId());
        box.addClickListener(RudListener.getInstance());
        row.addField(box);

        row.setDialog(this.getPopUp(res));

        for (int j = 0; j < res.getServices().size(); j++) {
            final Service service = (Service) res.getServices().get(j);

            // Take details from first service...
            if (0 == j) {
                final Vector<TableField> rowData = row.getFields();
                rowData.set(1, new TableField(service.getStartTime().toString()));
                rowData.set(2, new TableField(service.getDuration() + ""));
                if (this.isActive(service, service.getStartTime(), service.getDuration())) {
                    row.setSyle("list-Now");
                }
            }

            final TableRow detailRow = new TableRow();
            detailRow.addField(service.getId() + "");
            detailRow.addField(service.getStartTime().toString());
            detailRow.addField(service.getDuration() + "");
            detailRow.addField(" ");
            detailRow.setSyle("list-Detail");

            row.addDetail(detailRow);
        }

        this.addRow(row);
    }

    if (0 == reservations.getReservations().size()) {
        this.addDummyRow("Nothing found...");
    }

    this.flush();

    // notify listeners (i.e. button and gif from ReservationAdmin)
}

From source file:client.template.panel.RouterListPanel.java

License:Open Source License

/**
 * @param result/*from   w  ww .  j ava2s  . com*/
 *            the data to be filled in the table
 */
@Override
public final void onData(final Object result) {

    // enable buttons again, this should be somewhere else TODO

    final RouterList router = (RouterList) result;
    RudListener.getInstance().getChecked().clear();

    this.reset();

    for (int i = 0; i < router.getRouter().size(); ++i) {

        final TableRow row = new TableRow();
        final Router r = ((Router) router.getRouter().get(i));

        // TODO: more generic
        this.fillTable(row, r);

        final CheckBox box = new CheckBox();
        // Router can be identified by their LoopBackAddress
        box.setName(r.getLoopBackAddress());
        box.addClickListener(RudListener.getInstance());
        row.addField(box);

        if (null != r.getPopup()) {
            row.setDialog(new InfoDialog("Info", r.getPopup()));
        }

        this.addRow(row);

    }

    if (0 == router.getRouter().size()) {
        this.addDummyRow("Nothing found...");
    }
    this.flush();

    // notify listeners (i.e. button and gif from ReservationAdmin)
}

From source file:com.edgenius.wiki.gwt.client.user.ContactPanel.java

License:Open Source License

public void setUser(UserModel model) {
    //clean table first
    this.removeAllRows();

    int row = 0;// w w w .  ja  va 2  s .  c om
    this.getColumnFormatter().setStyleName(0, Css.NOWRAP);
    this.getColumnFormatter().setWidth(0, "1%");
    this.getColumnFormatter().setWidth(1, "98%");
    this.getColumnFormatter().setWidth(2, "1%");
    this.setCellPadding(3);
    this.setWidth("100%");

    if (editing) {
        textboxList = new ArrayList<FormTextBox>();
        checkboxList = new ArrayList<CheckBox>();
        userUid = model.getUid();

        fullname = new FormTextBox();
        fullname.setName("user.fullname");
        fullname.valid(Msg.consts.full_name(), true, 0, PersonalProfile.LOGIN_FULLNAME_LEN, null);
        fullname.setStyleName(Css.FORM_INPUT);
        fullname.setText(model.getFullname());

        Label fullnameLabel = new Label(Msg.consts.full_name());
        fullnameLabel.setStyleName(Css.FORM_LABEL);
        this.setWidget(row, 0, fullnameLabel);
        this.setWidget(row, 1, fullname);
        row++;
    }

    for (Entry<String, LinkedHashMap<String, String>> entry : model.getContacts().entrySet()) {
        LinkedHashMap<String, String> values = entry.getValue();
        if (values == null || values.size() == 0) {
            //E.g., if user public profile page, "Contact" group is hidden, so its title won't display as well.
            continue;
        }
        Label cTitle = new Label(entry.getKey());
        cTitle.setStyleName(Css.HEADING2);
        cTitle.addStyleName(Css.UNDERLINE);
        this.setWidget(row, 0, cTitle);
        this.getFlexCellFormatter().setColSpan(row, 0, editing ? 2 : 3);
        row++;

        //get linked flag - although we know only Twitter has linked attribute so far, we still use this common way for future.
        //see comments on UserUtil.copyUserContactToModel();
        Map<String, Boolean> linked = new HashMap<String, Boolean>();
        for (String key : values.keySet()) {
            if (key.endsWith("_linked")) {
                String name = key.substring(0, key.length() - 7);
                linked.put(name, BooleanUtil.toBoolean(values.get(key)));
            }
        }

        for (Entry<String, String> contact : values.entrySet()) {
            String name = contact.getKey();
            if (name.endsWith("_linked")) {
                continue;
            }
            Label lb = new Label(name);
            lb.setStyleName(Css.FORM_LABEL);
            this.setWidget(row, 0, lb);

            if (editing) {
                //email
                FormTextBox text = new FormTextBox();
                if (SharedConstants.USERSETTING_PROP_NAME_EMAIL.equalsIgnoreCase(name)) {
                    email = text;
                    text.valid(Msg.consts.email(), true, 0, PersonalProfile.LOGIN_EMAIL_LEN, this);
                } else {
                    textboxList.add(text);
                }
                text.setName(name);
                text.setText(contact.getValue());

                text.setStyleName(Css.FORM_INPUT);
                this.setWidget(row, 1, text);

                if (linked.containsKey(name)) {
                    row++;
                    CheckBox box = new CheckBox(Msg.consts.linked());
                    box.setName(name + "_linked");
                    box.setValue(linked.get(name));
                    this.setWidget(row, 1, box);
                    checkboxList.add(box);
                }
            } else {
                if (contact.getValue() != null) {
                    Label info = new Label(contact.getValue());
                    this.setWidget(row, 1, info);
                } else {
                    //just a placeholder
                    this.setWidget(row, 1, new Label(" "));
                }
                if (linked.containsKey(name) && linked.get(name)) {
                    //show linked image
                    Image linkedImg = new Image(IconBundle.I.get().connect());
                    linkedImg.setTitle(Msg.consts.linked());
                    this.setWidget(row, 2, linkedImg);
                } else {
                    //just a placeholder
                    this.setWidget(row, 2, new Label(" "));
                }
            }
            row++;
        }
    }

}

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

License:Open Source License

/**
 * To get batch Folder List View./*w ww.  ja  v  a2  s  .  c om*/
 * 
 * @param propertyMap Map<String, String>
 */
public void getbatchFolderListView(Map<String, String> propertyMap) {
    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.addStyleName("width100");

    CheckBox checkBox = new CheckBox(propertyMap.get(BatchFolderListDTO.FOLDER_NAME));
    checkBox.setName(propertyMap.get(BatchFolderListDTO.FOLDER_NAME));
    checkBox.setFormValue(propertyMap.get(BatchFolderListDTO.FOLDER_NAME));
    checkBox.setEnabled(Boolean.parseBoolean(propertyMap.get(BatchFolderListDTO.ENABLED)));
    checkBox.setChecked(Boolean.parseBoolean(propertyMap.get(BatchFolderListDTO.CHECKED)));
    horizontalPanel.add(checkBox);
    exportBatchClassViewPanel.add(horizontalPanel);
}