Exemplo n.º 1
0
  private void layout(final SearchSummaryItem ssi, final int depth) {

    final int row = table.getRowCount();
    final Image loading = new Image(GwtUtil.LOADING_ICON_URL);
    ssi.checkUpdate();

    table.setWidget(row, iconColIdx, loading);

    if (ssi.isLoaded()) {
      ssi.renderItem(table, row, curGroupByName);
      GwtUtil.setStyles(loading, "visibility", "hidden");
    } else {
      ssi.checkUpdate();
      table.setWidget(row, iconColIdx, loading);
      Timer timer =
          new Timer() {
            public void run() {
              ssi.checkUpdate();
              ssi.renderItem(table, row, curGroupByName);
              if (ssi.isLoaded()) {
                cancel();
                GwtUtil.setStyles(loading, "visibility", "hidden");
              }
            }
          };
      bgList.add(timer);
      timer.scheduleRepeating(1000);
    }

    if (ssi.getChildren() != null && ssi.getChildren().size() > 0) {
      for (SearchSummaryItem child : ssi.getChildren()) {
        layout(child, depth + 1);
      }
    }
  }
Exemplo n.º 2
0
    public CmdButton(String name, Widget icon, Command cmd, String label, String desc) {
      this.name = name;
      this.command = cmd;
      this.name = name;
      String htmlstr = label == null ? name : label;
      html = new HTML(htmlstr);
      if (desc != null) {
        html.setTitle(desc);
      }
      this.command = cmd;
      html.setWordWrap(false);
      if (command instanceof GeneralCommand) {
        addListeners();
        setButtonEnabled(((GeneralCommand) command).isEnabled());
      }

      GwtUtil.setStyles(iconHolderLeft, "padding", "none", "marginRight", "3px");
      GwtUtil.setStyle(html, "padding", "6px 0");
      container = GwtUtil.makeHoriPanel(null, null, iconHolderLeft, html, iconHolderRight);
      container.setCellVerticalAlignment(iconHolderLeft, VerticalPanel.ALIGN_MIDDLE);
      container.setCellVerticalAlignment(iconHolderRight, VerticalPanel.ALIGN_MIDDLE);
      setIconLeft(icon);
      setIconRight(null);
      GwtUtil.setStyle(container, "margin", "0px auto");
      initWidget(new SimplePanel(container));
    }
Exemplo n.º 3
0
 public void setIconRight(Widget w) {
   iconHolderRight.setWidget(w);
   iconHolderRight.setVisible(w != null);
   if (w != null) {
     w.setSize("20px", "20px");
     GwtUtil.setStyles(w, "verticalAlign", "middle", "margin", "0");
   }
 }
Exemplo n.º 4
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);
    }
  }