Exemplo n.º 1
0
 public void drawUpdating() {
   WebPanel container = getContainer();
   container.removeAll();
   container.setLayout(new HorizontalLayout());
   container.add(updatingPanel);
   container.repaint();
 }
Exemplo n.º 2
0
    AddUserDialog() {
      this.setTitle(Tr.tr("Add New Contact"));
      // this.setSize(400, 280);
      this.setResizable(false);
      this.setModal(true);

      GroupPanel groupPanel = new GroupPanel(10, false);
      groupPanel.setMargin(5);

      // editable fields
      WebPanel namePanel = new WebPanel();
      namePanel.setLayout(new BorderLayout(10, 5));
      namePanel.add(new WebLabel(Tr.tr("Display Name:")), BorderLayout.WEST);
      mNameField = new WebTextField();
      namePanel.add(mNameField, BorderLayout.CENTER);
      groupPanel.add(namePanel);
      groupPanel.add(new WebSeparator(true, true));

      mEncryptionBox = new WebCheckBox(Tr.tr("Encryption"));
      mEncryptionBox.setAnimated(false);
      mEncryptionBox.setSelected(true);
      groupPanel.add(mEncryptionBox);
      groupPanel.add(new WebSeparator(true, true));

      groupPanel.add(new WebLabel("JID:"));
      mJIDField = new WebTextField(38);
      groupPanel.add(mJIDField);
      groupPanel.add(new WebSeparator(true, true));

      this.add(groupPanel, BorderLayout.CENTER);

      // buttons
      WebButton cancelButton = new WebButton(Tr.tr("Cancel"));
      cancelButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              AddUserDialog.this.dispose();
            }
          });
      final WebButton saveButton = new WebButton(Tr.tr("Save"));
      saveButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              AddUserDialog.this.saveUser();
              AddUserDialog.this.dispose();
            }
          });

      GroupPanel buttonPanel = new GroupPanel(2, cancelButton, saveButton);
      buttonPanel.setLayout(new FlowLayout(FlowLayout.TRAILING));
      this.add(buttonPanel, BorderLayout.SOUTH);

      this.pack();
    }
Exemplo n.º 3
0
 /** Creates the status bar. */
 public StatusBar() {
   setLayout(new BorderLayout());
   setPreferredSize(new Dimension(100, 20));
   panel = new WebPanel();
   BoxLayout boxLayout = new BoxLayout(panel, BoxLayout.LINE_AXIS);
   panel.setLayout(boxLayout);
   panel.add(Box.createHorizontalGlue());
   add(panel, BorderLayout.CENTER);
   setVisible(false);
 }
Exemplo n.º 4
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();
  }
Exemplo n.º 5
0
  private static Component createPreview(WebLookAndFeelDemo owner, Example example) {
    WebPanel previewPanel = new WebPanel();
    previewPanel.setOpaque(false);
    previewPanel.setLayout(
        new TableLayout(
            new double[][] {
              {example.isFillWidth() ? TableLayout.FILL : TableLayout.PREFERRED},
              {TableLayout.FILL, TableLayout.PREFERRED, TableLayout.FILL}
            }));

    previewPanel.add(example.getPreview(owner), "0,1");

    return previewPanel;
  }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
0
  public static Component createGroupView(WebLookAndFeelDemo owner, ExampleGroup group) {
    // Creating group view
    Component exampleView;
    List<Example> examples = group.getGroupExamples();
    if (group.isSingleExample() && examples.size() == 1) {
      Example example = examples.get(0);
      exampleView = example.getPreview(owner);
    } else {
      final List<Component> preview = new ArrayList<Component>();

      final WebPanel groupPanel =
          new WebPanel() {
            @Override
            public void setEnabled(boolean enabled) {
              for (Component previewComponent : preview) {
                SwingUtils.setEnabledRecursively(previewComponent, enabled);
              }
              super.setEnabled(enabled);
            }
          };
      groupPanel.putClientProperty(SwingUtils.HANDLES_ENABLE_STATE, true);
      groupPanel.setOpaque(false);
      exampleView = groupPanel;

      int rowsAmount = examples.size() > 1 ? examples.size() * 2 - 1 : 1;
      double[] rows = new double[6 + rowsAmount];
      rows[0] = TableLayout.FILL;
      rows[1] = 20;
      rows[2] = TableLayout.PREFERRED;
      for (int i = 3; i < rows.length - 3; i++) {
        rows[i] = TableLayout.PREFERRED;
      }
      rows[rows.length - 3] = TableLayout.PREFERRED;
      rows[rows.length - 2] = 20;
      rows[rows.length - 1] = TableLayout.FILL;

      double[] columns = {
        20,
        1f - group.getContentPartSize(),
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        group.getContentPartSize(),
        20
      };

      TableLayout groupLayout = new TableLayout(new double[][] {columns, rows});
      groupLayout.setHGap(4);
      groupLayout.setVGap(4);
      groupPanel.setLayout(groupLayout);

      groupPanel.add(
          group.modifySeparator(createVerticalSeparator()), "2,0,2," + (rows.length - 1));
      groupPanel.add(
          group.modifySeparator(createVerticalSeparator()), "4,0,4," + (rows.length - 1));
      groupPanel.add(
          group.modifySeparator(createVerticalSeparator()), "6,0,6," + (rows.length - 1));
      groupPanel.add(
          group.modifySeparator(createVerticalSeparator()), "8,0,8," + (rows.length - 1));

      groupPanel.add(
          group.modifySeparator(createHorizontalSeparator()), "0,2," + (columns.length - 1) + ",2");
      groupPanel.add(
          group.modifySeparator(createHorizontalSeparator()),
          "0," + (rows.length - 3) + "," + (columns.length - 1) + "," + (rows.length - 3));

      int row = 3;
      for (Example example : examples) {
        // Title & description
        groupPanel.add(createDescription(example, group), "1," + row);

        // Marks
        Component mark = createMark(owner, example);
        groupPanel.add(mark, "3," + row);

        // Source code
        Component source = createSourceButton(owner, example);
        groupPanel.add(source, "5," + row);

        // More usage examples
        Component usage = createPresentationButton(example);
        groupPanel.add(usage, "7," + row);

        SwingUtils.equalizeComponentsSize(mark, source, usage);

        // Preview
        Component previewComponent = createPreview(owner, example);
        groupPanel.add(previewComponent, "9," + row);
        preview.add(previewComponent);

        // Rows separator
        if (row > 3) {
          groupPanel.add(
              group.modifySeparator(createHorizontalSeparator()),
              "0," + (row - 1) + "," + (columns.length - 1) + "," + (row - 1),
              0);
        }

        row += 2;
      }
    }

    if (group.isShowWatermark()) {
      WebImage linkImage = new WebImage(logoIcon);
      linkImage.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

      TooltipManager.setTooltip(linkImage, linkIcon, "Library site", TooltipWay.trailing);

      linkImage.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
              WebUtils.browseSiteSafely(WebLookAndFeelDemo.WEBLAF_SITE);
            }
          });

      WebOverlay linkOverlay =
          new WebOverlay(exampleView, linkImage, WebOverlay.LEADING, WebOverlay.BOTTOM);
      linkOverlay.setOverlayMargin(15, 15, 15, 15);
      linkOverlay.setOpaque(false);

      exampleView = linkOverlay;
    }

    return exampleView;
  }
Exemplo n.º 8
0
  /**
   * Constructs new calendar with the specified selected date.
   *
   * @param date selected date
   */
  public WebCalendar(final Date date) {
    super(true);

    this.date = date != null ? new Date(date.getTime()) : null;
    this.shownDate = date != null ? new Date(date.getTime()) : new Date();

    setDrawFocus(true);
    setRound(StyleConstants.smallRound);
    setLayout(new BorderLayout(0, 0));
    putClientProperty(SwingUtils.HANDLES_ENABLE_STATE, true);

    // Main layout
    final WebPanel centerPanel = new WebPanel();
    centerPanel.setOpaque(false);
    add(centerPanel, BorderLayout.CENTER);

    // Header panel
    final WebPanel header = new WebPanel();
    header.setOpaque(false);
    add(header, BorderLayout.NORTH);

    previousSkip = WebButton.createIconWebButton(previousSkipIcon, StyleConstants.smallRound, true);
    previousSkip.setDrawFocus(false);
    previousSkip.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            changeYear(-1);
          }
        });

    previous = WebButton.createIconWebButton(previousIcon, StyleConstants.smallRound, true);
    previous.setDrawFocus(false);
    previous.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            changeMonth(-1);
          }
        });

    final WebPanel leftHeader = new WebPanel(new BorderLayout());
    leftHeader.setOpaque(false);
    leftHeader.add(previousSkip, BorderLayout.WEST);
    leftHeader.add(previous, BorderLayout.EAST);
    header.add(leftHeader, BorderLayout.WEST);

    titlePanel = new ComponentTransition(createTitleLabel());
    titlePanel.setOpaque(false);
    titlePanel.setTransitionEffect(new FadeTransitionEffect());
    titlePanel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(final MouseEvent e) {
            if (SwingUtilities.isLeftMouseButton(e)) {
              setShownDate(new Date());
            }
          }
        });
    header.add(titlePanel, BorderLayout.CENTER);

    next = WebButton.createIconWebButton(nextIcon, StyleConstants.smallRound, true);
    next.setDrawFocus(false);
    next.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            changeMonth(1);
          }
        });

    nextSkip = WebButton.createIconWebButton(nextSkipIcon, StyleConstants.smallRound, true);
    nextSkip.setDrawFocus(false);
    nextSkip.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            changeYear(1);
          }
        });

    final WebPanel rightHeader = new WebPanel(new BorderLayout());
    rightHeader.setOpaque(false);
    rightHeader.add(next, BorderLayout.WEST);
    rightHeader.add(nextSkip, BorderLayout.EAST);
    header.add(rightHeader, BorderLayout.EAST);

    // Week days
    weekHeaders = new WebPanel();
    weekHeaders.setUndecorated(false);
    weekHeaders.setDrawSides(true, false, true, false);
    weekHeaders.setShadeWidth(0);
    weekHeaders.setOpaque(false);
    weekHeaders.setMargin(
        StyleConstants.shadeWidth,
        StyleConstants.shadeWidth - 1,
        StyleConstants.shadeWidth + 1,
        StyleConstants.shadeWidth - 1);
    weekHeaders.setLayout(
        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.PREFERRED}
            }));
    centerPanel.add(weekHeaders, BorderLayout.NORTH);
    updateWeekHeaders();

    // Month days
    monthDays = createMonthPanel();
    updateMonth(monthDays);
    monthDaysTransition = new ComponentTransition(monthDays);
    monthDaysTransition.setOpaque(false);
    monthDaysTransition.addTransitionListener(
        new TransitionAdapter() {
          @Override
          public void transitionFinished() {
            requestFocusToSelected();
          }
        });
    centerPanel.add(monthDaysTransition, BorderLayout.CENTER);
  }