Пример #1
0
  private Component getGrid() {
    TableLayout layout =
        new TableLayout(
            new double[][] {
              {TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED},
              {TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}
            });
    layout.setHGap(5);
    layout.setVGap(5);

    WebPanel content = new WebPanel(layout);
    content.setOpaque(false);

    txtHoursOfRest24Hrs = new WebTextField(5);
    txtHoursOfWork24Hrs = new WebTextField(5);

    txtHoursOfRest24Hrs.setText(Float.toString(timeSheet.getTotalRest()));
    txtHoursOfWork24Hrs.setText(Float.toString(timeSheet.getTotalWork()));

    txtHoursOfRest24Hrs.setEnabled(false);
    txtHoursOfWork24Hrs.setEnabled(false);

    content.add(new WebLabel("Hours of rest in 24 hours period"), "0,1");
    content.add(txtHoursOfRest24Hrs, "1,1");

    content.add(new WebLabel("Hours of work in 24 hours period"), "0,2");
    content.add(txtHoursOfWork24Hrs, "1,2");

    return content;
  }
Пример #2
0
  public void draw(List<DetailsDecoration> details) {

    WebPanel container = getContainer();
    container.removeAll();

    int maxValueLength = convertToCharacters(getWidth() - 15) - maxValueLength(details) - 5;
    maxValueLength = (maxValueLength < 8 ? 8 : maxValueLength);

    int bottomPanelsAmount = (bottomPanels != null) ? bottomPanels.size() : 0;

    double columns[] = {5, TableLayout.PREFERRED, 3, TableLayout.FILL, 5};
    double rows[] = new double[3 + (details.size() + bottomPanelsAmount - 1) * 2];
    rows[0] = 2;
    rows[1] = 2;
    for (int i = 2; i < rows.length - 1; i += 2) {
      rows[i] = TableLayout.PREFERRED;
      rows[i + 1] = 2;
    }
    rows[rows.length - 1] = DEFAULT_MARGIN;

    TableLayout boxLayout = new TableLayout(new double[][] {columns, rows});

    boxLayout.setHGap(4);
    boxLayout.setVGap(4);

    container.setLayout(boxLayout);
    container.validate();

    container.add(createVerticalSeparator(), "2,1,2," + (rows.length - 2));

    int nextDetail = 1;
    for (DetailsDecoration detail : details) {
      int nextRow = nextDetail * 2;
      container.add(createHorizontalSeparator(), "0," + (nextRow - 1) + ",4," + (nextRow - 1));
      container.add(createNameLabel(detail), "1," + nextRow);
      container.add(createValueLabel(detail, maxValueLength), "3," + nextRow);
      nextDetail++;

      if (nextDetail > details.size()) {
        container.add(createHorizontalSeparator(), "0," + (nextRow + 1) + ",4," + (nextRow + 1));
      }
    }

    if (bottomPanels != null) {

      for (JPanel panel : bottomPanels) {
        int nextRow = nextDetail * 2;
        container.add(panel, "1, " + (nextRow) + ", 4, " + (nextRow));
        nextDetail++;
      }
    }

    container.repaint();
  }
Пример #3
0
 /**
  * Creates and returns month panel.
  *
  * @return created month panel
  */
 protected WebPanel createMonthPanel() {
   final WebPanel monthDays = new WebPanel();
   monthDays.setOpaque(false);
   monthDays.setMargin(
       StyleConstants.shadeWidth - 1,
       StyleConstants.shadeWidth - 1,
       StyleConstants.shadeWidth - 1,
       StyleConstants.shadeWidth - 1);
   final TableLayout layout =
       new TableLayout(
           new double[][] {
             {
               TableLayout.FILL,
               TableLayout.PREFERRED,
               TableLayout.FILL,
               TableLayout.PREFERRED,
               TableLayout.FILL,
               TableLayout.PREFERRED,
               TableLayout.FILL,
               TableLayout.PREFERRED,
               TableLayout.FILL,
               TableLayout.PREFERRED,
               TableLayout.FILL,
               TableLayout.PREFERRED,
               TableLayout.FILL
             },
             {
               TableLayout.FILL,
               TableLayout.FILL,
               TableLayout.FILL,
               TableLayout.FILL,
               TableLayout.FILL,
               TableLayout.FILL
             }
           });
   layout.setHGap(0);
   layout.setVGap(0);
   monthDays.setLayout(layout);
   return monthDays;
 }
Пример #4
0
  public WebFilePlate(File file, boolean decorated) {
    super(decorated);

    this.file = file;

    // setDrawFocus ( true );
    setMargin(0, 3, 0, 0);

    TableLayout tableLayout =
        new TableLayout(
            new double[][] {{TableLayout.FILL, TableLayout.PREFERRED}, {TableLayout.PREFERRED}});
    tableLayout.setHGap(0);
    tableLayout.setVGap(0);
    setLayout(tableLayout);

    // Displayed file name
    fileName = new WebLabel();
    fileName.setMargin(0, 0, 0, showRemoveButton ? 1 : 0);
    add(fileName, "0,0");

    // Updating current file name
    updateFileName();

    // Adding remove button if needed
    if (showRemoveButton) {
      add(getRemoveButton(), "1,0");
    }

    // Adding appear listener
    addAncestorListener(
        new AncestorAdapter() {
          @Override
          public void ancestorAdded(AncestorEvent event) {
            if (animator != null && animator.isRunning()) {
              animator.stop();
            }
            if (animate) {
              animator =
                  new WebTimer(
                      "WebFilePlate.fadeInTimer",
                      StyleConstants.animationDelay,
                      new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                          opacity += 0.1f;
                          if (opacity < 1f) {
                            WebFilePlate.this.repaint();
                          } else {
                            opacity = 1f;
                            WebFilePlate.this.repaint();
                            animator.stop();
                          }
                        }
                      });
              animator.start();
            } else {
              opacity = 1f;
              WebFilePlate.this.repaint();
            }
          }
        });
  }