예제 #1
0
  protected void layoutCalendar() {
    calendarGrid.clear();
    calendarGrid.setCellSpacing(0);
    for (int i = 0, row = -2, col = 0; i < simpleDatePickers.size(); i++) {
      if ((i % monthColumns) == 0) {
        col = 0;
        row += 2;
      } else if (i > 0) {
        calendarGrid.setHTML(row, col, "&nbsp;");
        calendarGrid.setHTML(row + 1, col, "&nbsp;");
        calendarGrid.getCellFormatter().addStyleName(row, col, StyleMonthSeparator);
        calendarGrid.getCellFormatter().addStyleName(row + 1, col, StyleMonthSeparator);
        col += 1;
      }

      if (monthSelectorHeader.getParent() == null || simpleDatePickers.size() > 1) {
        if (i == 0 || (i % monthColumns) == 0) {
          calendarGrid.getRowFormatter().addStyleName(row, StyleMonthLabels);
          calendarGrid.getRowFormatter().addStyleName(row + 1, StyleMonthCell);
        }
        Widget w = null;
        if (i == 0 && monthSelectorHeader.getElement().getParentElement() == null)
          w = monthSelectorHeader;
        // calendarGrid.setWidget(row, col, monthSelectorHeader);
        else w = monthHeaders.get(i);
        // calendarGrid.setWidget(row, col, monthHeaders.get(i));

        DockPanel p = null;
        if (leftButtons.iterator().hasNext() && leftButtons.getParent() == null && col == 0) {
          p = leftButtons;
          p.add(w, DockPanel.WEST);
          p.setCellWidth(w, "100%");
          w = p;
          if (simpleDatePickers.size() == 1) {
            Iterator<Widget> it = p.iterator();
            while (it.hasNext()) {
              p.add(it.next(), DockPanel.WEST);
            }
          }
        }
        if (rightButtons.iterator().hasNext()
            && rightButtons.getParent() == null
            && ((i + 1) % monthColumns) == 0) {
          p = rightButtons;
          p.add(w, DockPanel.WEST);
          p.setCellWidth(w, "100%");
          w = p;
        }
        calendarGrid.setWidget(row, col, w);
      }

      calendarGrid.setWidget(row + 1, col, simpleDatePickers.get(i));
      calendarGrid.getColumnFormatter().addStyleName(i, "Month-" + i);
      simpleDatePickers.get(i).addValueChangeHandler(onDaySelected);
      col++;
    }
  }
예제 #2
0
  protected void layoutButtons(String distribution) {
    navButtonsBottom.clear();
    navButtonsTop.clear();
    DockPanel[] panels = {
      topButtonsRow0,
      topButtonsRow1,
      topButtonsRow2,
      bottomButtonsRow0,
      bottomButtonsRow1,
      bottomButtonsRow2,
      leftButtons,
      rightButtons
    };
    String s[] = distribution.split("[;:,]");

    Widget w = null, m = null;
    for (int i = 0; i < panels.length && i < s.length; i++) {
      DockPanel p = panels[i];
      p.clear();

      if (s[i].length() == 0) continue;

      for (int j = 0; j < s[i].length(); j++) {
        if ((w = getButton(s[i], j)) != null) {
          p.add(w, p != rightButtons ? DockPanel.WEST : DockPanel.EAST);
        }
        if (j == s[i].length() / 2) m = w;
      }

      if (!p.iterator().hasNext()) continue;

      p.setWidth("100%");
      if (p != leftButtons && p != rightButtons) {
        if (m != null) {
          p.setCellWidth(m, "100%");
          m.setWidth("100%");
        }
      }
      if (i < 3) navButtonsTop.add(p, DockPanel.NORTH);
      else if (i < 6) navButtonsBottom.add(p, DockPanel.NORTH);

      if (i < 6) p.addStyleName(StyleCButtonsRow + (i % 3));
    }
  }