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

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

Introduction

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

Prototype

@Override
    public String getName() 

Source Link

Usage

From source file:eu.riscoss.client.riskconfs.NewModelDialog.java

License:Apache License

public void show(String rcName) {

    //         this.callback = cb;
    this.selectedRC = rcName;

    RiscossJsonClient.listModels(new JsonCallback() {
        @Override/*  www  . ja v a  2s . c  om*/
        public void onFailure(Method method, Throwable exception) {
            Window.alert(exception.getMessage());
        }

        @Override
        public void onSuccess(Method method, JSONValue response) {
            JsonModelList list = new JsonModelList(response);
            dialog = new DialogBox(true, true); //, new HtmlCaption( "Add model" ) );
            Grid grid = new Grid();
            grid.resize(list.getModelCount(), 1);
            for (int i = 0; i < list.getModelCount(); i++) {
                ModelInfo info = list.getModelInfo(i);
                CheckBox chk = new CheckBox(info.getName());
                chk.setName(info.getName());
                chk.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        CheckBox chk = (CheckBox) event.getSource();
                        boolean value = chk.getValue();
                        if (value == true) {
                            selection.add(chk.getName());
                        } else {
                            selection.remove(chk.getName());
                        }
                    }
                });
                grid.setWidget(i, 0, chk);
            }
            DockPanel dock = new DockPanel();
            dock.add(grid, DockPanel.CENTER);
            dock.add(new Button("Ok", new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    //                     SimpleRiskCconf rc = new SimpleRiskCconf( selection );
                    //                     RiscossJsonClient.setRCContent( selectedRC, rc, new JsonCallback() {
                    //                        
                    //                        @Override
                    //                        public void onSuccess(Method method, JSONValue response) {
                    //                           dialog.hide();
                    ////                           if( callback != null ) {
                    ////                              callback.onDone( null );
                    ////                           }
                    //                        }
                    //                        
                    //                        @Override
                    //                        public void onFailure(Method method, Throwable exception) {
                    //                           Window.alert( exception.getMessage() );
                    //                        }
                    //                     });
                }
            }), DockPanel.SOUTH);
            dialog.add(dock);
            dialog.show();
        }
    });
}

From source file:org.ednovo.gooru.client.mvp.gsearch.SearchAbstractView.java

License:Open Source License

/**
 * Set filter value for search with separator
 * @param filterFlowPanel instance of {@link DisclosurePanelUc} which has filter values
 * @param checkedValues selected filter value
 * @param separator concatenation of the filter value by separator
 *//*  w  w  w.  j  a v a 2s.co  m*/
private void setSelectedFilter(PPanel filterHtmlPanel, String checkedValues, String separator) {
    List<String> items = null;
    if (checkedValues != null) {
        items = Arrays.asList(checkedValues.split("\\s*" + separator + "\\s*"));
    }

    if (items != null) {
        //if(resourceSearch){
        for (int i = 0; i < filterHtmlPanel.getWidgetCount(); i++) {
            Widget filterWidget = filterHtmlPanel.getWidget(i);
            if (filterWidget instanceof CheckBox) {
                CheckBox filterCheckBox = (CheckBox) filterWidget;
                filterCheckBox.setValue(false);
                for (String item : items) {
                    if ((filterCheckBox.getName().equals(item))) {
                        filterCheckBox.setValue(true);
                    }
                }
            }
        }
    }

}

From source file:org.ednovo.gooru.client.mvp.gsearch.SearchAbstractView.java

License:Open Source License

/**
  * Remove the selected search filter and search results when user click on 'X'.
  * @param filterNamePanel {@link HTMLPanel}
  * @param filterName {@link String} grade/subject search filter name
  *///w ww  .j av a  2 s  .  c  o m
private void removeSelectedFilter(PPanel filterNamePanel, String filterName) {
    for (int i = 0; i < filterNamePanel.getWidgetCount(); i++) {
        Widget filterWidget = filterNamePanel.getWidget(i);
        if (filterWidget instanceof CheckBox) {
            CheckBox filterCheckBox = (CheckBox) filterWidget;
            if ((filterCheckBox.getName().equals(filterName))) {
                filterCheckBox.setValue(false);
            }
        }
    }
    callSearch();
}

From source file:org.ednovo.gooru.client.mvp.gsearch.SearchAbstractView.java

License:Open Source License

/**
 * Get filters for search/*from w ww.  j a  va  2 s .  c  om*/
 * @param filterPanel instance of {@link DisclosurePanelUc} which has filters widget
 * @param separator concatenation of the filters with separator
 * @return concatenation of selected filters
 */
private String getSelectedFilter(PPanel filterPanel, String separator) {
    String selectedFilter = "";
    for (int i = 0; i < filterPanel.getWidgetCount(); i++) {
        Widget filterWidget = filterPanel.getWidget(i);
        if (filterWidget instanceof CheckBox) {
            CheckBox filterCheckBox = (CheckBox) filterWidget;
            if (filterCheckBox != null && filterCheckBox.getValue()) {
                if (!selectedFilter.isEmpty()) {
                    selectedFilter += separator;
                }
                selectedFilter += filterCheckBox.getName();
                MixpanelUtil.mixpanelEvent("search_" + selectedFilter + "_filter_selected");
            }
        }
    }
    return selectedFilter;
}

From source file:org.ednovo.gooru.client.mvp.search.SearchFilterVc.java

License:Open Source License

/**
 * Get filters for search/*from ww w .j  av  a2  s. c  o m*/
 * @param filterDisclosurePanell instance of {@link DisclosurePanelUc} which has filters widget
 * @param separator concatenation of the filters with separator
 * @return concatenation of selected filters
 */
private String getSelectedFilter(DisclosurePanelUc filterDisclosurePanell, String separator) {
    String selectedFilter = "";
    for (Widget filterWidget : filterDisclosurePanell.getContent()) {
        if (filterWidget instanceof CheckBox) {
            CheckBox filterCheckBox = (CheckBox) filterWidget;
            if (filterCheckBox != null && filterCheckBox.getValue()) {
                if (!selectedFilter.isEmpty()) {
                    selectedFilter += separator;
                }
                selectedFilter += filterCheckBox.getName();
                MixpanelUtil.mixpanelEvent("search_" + selectedFilter + "_filter_selected");
            }
        }
    }

    return selectedFilter;
}

From source file:org.ednovo.gooru.client.mvp.search.SearchFilterVc.java

License:Open Source License

/**
 * Set filter value for search with separator
 * @param filterFlowPanel instance of {@link DisclosurePanelUc} which has filter values
 * @param checkedValues selected filter value
 * @param separator concatenation of the filter value by separator 
 */// ww  w .  j  ava2  s.  c  o m
private void setSelectedFilter(DisclosurePanelUc filterFlowPanel, String checkedValues, String separator) {
    List<String> items = null;
    if (checkedValues != null) {
        items = Arrays.asList(checkedValues.split("\\s*" + separator + "\\s*"));
    }

    if (items != null) {
        //if(resourceSearch){
        for (Widget filterWidget : filterFlowPanel.getContent()) {
            if (filterWidget instanceof CheckBox) {
                CheckBox filterCheckBox = (CheckBox) filterWidget;
                filterCheckBox.setValue(false);
                for (String item : items) {
                    if ((filterCheckBox.getName().equals(item))) {
                        filterCheckBox.setValue(true);
                    }
                }
            }
        }
        //}
        /*         else{
                    boolean isRadioButtonSelected=false;
                    for (Widget filterWidget : filterFlowPanel.getContent()) {
                       if (filterWidget instanceof QuestionTypeFilter) {
          QuestionTypeFilter questionTypeFilter = (QuestionTypeFilter) filterWidget;
          //filterCheckBox.setValue(false);
          questionTypeFilter.radioButton.setStyleName(SearchMoreInfoVcCBundle.INSTANCE.css().questionRadioButton());
          questionTypeFilter.hiddenRadioButton.setValue(false);
          for (String item : items) {
             if ((questionTypeFilter.hiddenRadioButton.getText().equals(item))) {
                questionTypeFilter.hiddenRadioButton.setValue(true);
                isRadioButtonSelected=true;
                questionTypeFilter.radioButton.setStyleName(SearchMoreInfoVcCBundle.INSTANCE.css().questionRadioButtonSelected());
             }
          }
                       }
                    }
        //            if(!isRadioButtonSelected){
        //               QuestionTypeFilter questionTypeFilter = (QuestionTypeFilter)filterFlowPanel.getContent().getWidget(2);
        //               questionTypeFilter.hiddenRadioButton.setValue(true);
        //               questionTypeFilter.radioButton.setStyleName(SearchMoreInfoVcCBundle.INSTANCE.css().questionRadioButtonSelected());
        //            }
                            
                 }*/

    }

}

From source file:org.jboss.ci.tracker.client.widgets.CustomWidgets.java

License:Open Source License

public static DialogBox filterDialogBox(final ResultList resultList, List<CategorizationDto> categorizations,
        List<CategoryDto> categories, List<PossibleResultDto> possibleResults, FilterDto oldFilter) {
    final DialogBox box = new DialogBox();
    final VerticalPanel panel = new VerticalPanel();

    panel.setSize("20em", "20em");

    box.setText("Filter results");

    // ----------------------- Possible results
    final Label resultsLabel = new Label("Results");
    panel.add(resultsLabel);/*www. ja  va2 s . c o m*/

    for (PossibleResultDto possibleResult : possibleResults) {
        final CheckBox checkBox = new CheckBox(possibleResult.getName());
        checkBox.setName(POSSIBLE_RESULT_SEPARATOR_PREFIX + possibleResult.getId().toString());
        panel.add(checkBox);
    }

    // ----------------------- Categorizations and categories
    for (CategorizationDto categorization : categorizations) {
        final Label categorizationLabel = new Label(categorization.getName());
        panel.add(categorizationLabel);

        for (CategoryDto category : categories) {
            if (category.getCategorizationId().equals(categorization.getId())) {
                final CheckBox checkBox = new CheckBox(category.getName());
                checkBox.setName(CATEGORY_SEPARATOR_PREFIX + category.getId().toString());
                panel.add(checkBox);
            }
        }

    }

    // ----------------------- Date from
    final DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat("d.M.yyyy");
    final DateBox dateBoxFrom = new DateBox();
    dateBoxFrom.setFormat(new DateBox.DefaultFormat(dateTimeFormat));
    dateBoxFrom.getDatePicker().setYearArrowsVisible(true);

    panel.add(new Label("From"));
    dateBoxFrom.setTitle("Midnight of the day, i.e. time 00:00");
    panel.add(dateBoxFrom);

    // ----------------------- Date to
    final DateBox dateBoxTo = new DateBox();
    dateBoxTo.setFormat(new DateBox.DefaultFormat(dateTimeFormat));
    dateBoxTo.getDatePicker().setYearArrowsVisible(true);

    panel.add(new Label("To"));
    dateBoxTo.setTitle("Midnight of the day, i.e. time 00:00");
    panel.add(dateBoxTo);

    // ----------------------- Set widgets according to filter
    setWidgetValues(panel, oldFilter, dateBoxFrom, dateBoxTo);

    // ----------------------- Filter button
    final Button buttonFilter = new Button("OK", new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {

            FilterDto filter = new FilterDto();

            Iterator<Widget> arrayOfWidgets = panel.iterator();
            while (arrayOfWidgets.hasNext()) {
                Widget widget = arrayOfWidgets.next();

                if (widget instanceof CheckBox) {
                    CheckBox checkBox = (CheckBox) widget;
                    if (checkBox.getValue()) {
                        if (checkBox.getName().startsWith(CATEGORY_SEPARATOR_PREFIX)) {
                            filter.addCategoryId(Integer.parseInt(
                                    checkBox.getName().substring(CATEGORY_SEPARATOR_PREFIX.length())));
                        } else if (checkBox.getName().startsWith(POSSIBLE_RESULT_SEPARATOR_PREFIX)) {
                            filter.addPossibleResultId(Integer.parseInt(
                                    checkBox.getName().substring(POSSIBLE_RESULT_SEPARATOR_PREFIX.length())));
                        }
                    }
                }
            }

            filter.setDateFrom(dateBoxFrom.getValue());
            filter.setDateTo(dateBoxTo.getValue());

            resultList.filterResults(filter);
            box.hide();

        }
    });

    buttonFilter.setWidth("5em");
    panel.add(buttonFilter);
    panel.setCellHorizontalAlignment(buttonFilter, HasAlignment.ALIGN_RIGHT);

    // ----------------------- Show all results button
    final Button buttonShowAll = new Button("Clear", new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            resultList.filterResults(null);
            box.hide();
        }
    });

    buttonShowAll.setWidth("5em");
    panel.add(buttonShowAll);
    panel.setCellHorizontalAlignment(buttonShowAll, HasAlignment.ALIGN_RIGHT);

    // ----------------------- Cancel button
    final Button buttonCancel = new Button("Cancel", new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            box.hide();
        }
    });

    buttonCancel.setWidth("5em");
    panel.add(buttonCancel);
    panel.setCellHorizontalAlignment(buttonCancel, HasAlignment.ALIGN_RIGHT);

    box.add(panel);
    return box;
}

From source file:org.jboss.ci.tracker.client.widgets.CustomWidgets.java

License:Open Source License

private static void setWidgetValues(VerticalPanel panel, FilterDto filter, DateBox dateBoxFrom,
        DateBox dateBoxTo) {/* w w  w  . j ava  2s  .  c  o m*/
    if (filter == null) {
        return;
    }

    Iterator<Widget> arrayOfWidgets = panel.iterator();
    while (arrayOfWidgets.hasNext()) {
        Widget widget = arrayOfWidgets.next();

        if (widget instanceof CheckBox) {
            CheckBox checkBox = (CheckBox) widget;

            if (checkBox.getName().startsWith(CATEGORY_SEPARATOR_PREFIX)) {
                checkBox.setValue(filter.getCategoryIds().contains(
                        Long.parseLong(checkBox.getName().substring(CATEGORY_SEPARATOR_PREFIX.length()))));
            } else if (checkBox.getName().startsWith(POSSIBLE_RESULT_SEPARATOR_PREFIX)) {
                checkBox.setValue(filter.getPossibleResultIds().contains(Long
                        .parseLong(checkBox.getName().substring(POSSIBLE_RESULT_SEPARATOR_PREFIX.length()))));
            }

        }
    }

    dateBoxFrom.setValue(filter.getDateFrom());
    dateBoxTo.setValue(filter.getDateTo());

}

From source file:org.otalo.ao.client.search.AuthorFilterCriteria.java

License:Apache License

@Override
public void onClick(ClickEvent event) {
    CheckBox sender = (CheckBox) event.getSource();
    if (AoAPI.SearchConstants.AuthorConstants.ANY.equalsIgnoreCase(sender.getName())) {
        //if its any then first disable all others and removing all of them from selected status queue
        setResetAny();/*w  w w  .ja  v a2  s .  c  o m*/
        selectedFieldsQuery.clear();
    } else {
        if (sender.getValue())
            selectedFieldsQuery.add(sender.getName());
        else
            selectedFieldsQuery.remove(sender.getName());
    }
}

From source file:org.otalo.ao.client.search.MsgStatusFilterCriteria.java

License:Apache License

@Override
public void onClick(ClickEvent event) {
    CheckBox sender = (CheckBox) event.getSource();
    if (AoAPI.SearchConstants.StausConstants.STATUS_ANY.equalsIgnoreCase(sender.getName())) {
        //if its any then first disable all others and removing all of them from selected status queue
        setResetAny();//  ww w .jav a 2  s. c o m
        selectedStatusQuery.clear();
    } else {
        if (sender.getValue())
            selectedStatusQuery.add(sender.getName());
        else
            selectedStatusQuery.remove(sender.getName());
    }
}