Пример #1
0
 public boolean accept(GroupedSummaryItem gsi) {
   return gsi.getName().equals(name);
 }
Пример #2
0
  public void layout() {

    // clear any backgrounded processes.
    for (Timer t : bgList) {
      t.cancel();
    }

    table = new FlexTable();
    mainPanel.clear();
    if (!StringUtils.isEmpty(name) || !StringUtils.isEmpty(helpId)) {

      String n = StringUtils.isEmpty(name) ? "" : name.trim();
      HorizontalPanel h = new HorizontalPanel();
      h.setWidth("100%");
      HTML lname = new HTML("<b>" + n + "</b>");
      if (shortDesc != null) {
        lname.setTitle(shortDesc);
      }
      GwtUtil.setStyles(lname, "textAlign", "center");
      h.add(lname);
      h.setCellWidth(lname, "100%");

      if (!StringUtils.isEmpty(helpId)) {
        final Widget helpIcon = HelpManager.makeHelpIcon(helpId);
        h.add(helpIcon);
        GwtUtil.setStyles(helpIcon, "marginRight", "11px");
      }
      mainPanel.addNorth(h, 20);
    }

    // setup group by selection
    if (groupByCols != null && groupByCols.size() > 1) {
      EnumFieldDef gb = new EnumFieldDef("groupBy");
      gb.setLabel("Group By");
      gb.setDesc("Select a group by column to update the data table");
      gb.setPreferWidth(200);
      gb.setDefaultValue(curGroupByName);
      for (TableDataView.Column item : headers) {
        if (groupByCols.contains(item.getName())) {
          gb.addItem(item.getName(), item.getTitle());
        }
      }
      final SimpleInputField sif = SimpleInputField.createByDef(gb);
      mainPanel.addNorth(sif, 28);
      sif.getField()
          .addValueChangeHandler(
              new ValueChangeHandler() {
                public void onValueChange(ValueChangeEvent ve) {
                  curGroupByName = sif.getValue();
                  layout();
                }
              });
    }

    ScrollPanel sp = new ScrollPanel();
    sp.add(table);

    mainPanel.add(sp);

    table.setStyleName("firefly-summary-table");
    table.setSize("100%", "100%");
    iconColIdx = headers.size();
    String titleCol = null;

    // render headers
    int colIdx = 0;
    for (int i = 0; i < headers.size(); i++) {
      TableDataView.Column col = headers.get(i);
      if (curGroupByName == null || !curGroupByName.equals(col.getName())) {
        table.setText(0, colIdx, col.getTitle());
        table.getCellFormatter().setStyleName(0, colIdx, "title-bar");
        colIdx++;
        if (titleCol == null) {
          titleCol = col.getName();
        }
      }
    }
    table.setText(0, headers.size(), "");
    table.getCellFormatter().setWidth(0, headers.size(), "100%");

    ArrayList<SearchSummaryItem> itemList = searchItems;

    if (!StringUtils.isEmpty(curGroupByName)) {
      itemList = new ArrayList<SearchSummaryItem>();

      GroupFinder finder = new GroupFinder("");
      List<GroupedSummaryItem> groupList = new ArrayList<GroupedSummaryItem>();
      for (int i = 0; i < searchItems.size(); i++) {
        SearchSummaryItem dsi = searchItems.get(i);
        String cGroupValue = dsi.getValue(curGroupByName);
        GroupedSummaryItem cGroup =
            CollectionUtil.findFirst(groupList, finder.setName(cGroupValue));
        if (cGroup == null) {
          cGroup = new GroupedSummaryItem(cGroupValue);
          groupList.add(cGroup);
          itemList.add(cGroup);
        }
        cGroup.addChild(dsi);
      }
    }

    for (SearchSummaryItem ssi : itemList) {
      ssi.setTitleCol(titleCol);
      layout(ssi, 0);
    }
  }