Example #1
0
  private FieldSet wrapField(
      final Field field, final MetaField metaField, final LayoutContainer container) {
    FieldSet fs = new FieldSet();
    fs.setLayout(new FitLayout());
    fs.setHeading(metaField.getLabel());
    fs.setCheckboxToggle(true);
    fs.addListener(
        Events.Expand,
        new Listener<BaseEvent>() {
          public void handleEvent(BaseEvent be) {
            enabledFields.put(metaField.getName(), field);
          }
        });
    fs.addListener(
        Events.Collapse,
        new Listener<BaseEvent>() {
          public void handleEvent(BaseEvent be) {
            enabledFields.remove(metaField.getName());
          }
        });
    fs.add(field);
    fs.setExpanded(false);

    return fs;
  }
  private void initialize() {
    FieldSet responseFieldSet = new FieldSet();
    responseFieldSet.setHeading("District Comparisons");
    responseFieldSet.setCheckboxToggle(false);

    FormLayout layout = new FormLayout();
    layout.setLabelWidth(75);
    responseFieldSet.setLayout(layout);

    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
    //		configs.add(new ColumnConfig("district", "District", 100));
    configs.add(new ColumnConfig("subcounty", "Subcounty", 200));
    configs.add(new ColumnConfig("bh", "Boreholes", 200));
    configs.add(new ColumnConfig("sw", "Shallow Wells", 200));
    configs.add(new ColumnConfig("yt", "Public Taps", 100));
    configs.add(new ColumnConfig("ps", "Protected Springs", 100));
    configs.add(new ColumnConfig("total", "Total", 100));
    store = new ListStore<DistrictComparisonSummary>();
    cm = new ColumnModel(configs);
    setBodyBorder(true);
    setHeading("District Comparisons");
    setButtonAlign(HorizontalAlignment.CENTER);
    setLayout(new FitLayout());
    setSize(600, 300);
    grid = new Grid<DistrictComparisonSummary>(store, cm);
    grid.setStyleAttribute("borderTop", "none");
    grid.setAutoWidth(true);
    grid.setBorders(false);
    grid.setStripeRows(true);
    grid.setColumnLines(true);
    grid.setColumnReordering(true);
    grid.addListener(
        Events.RowDoubleClick,
        new Listener<GridEvent<BeanModel>>() {

          @Override
          public void handleEvent(GridEvent<BeanModel> be) {
            DistrictComparisonSummary summary = grid.getSelectionModel().getSelectedItem();
          }
        });
    grid.getAriaSupport().setLabelledBy(getHeader().getId() + "-label");
    responseFieldSet.add(grid);
    add(grid);
    setLayout(new FitLayout());
  }