Exemplo n.º 1
0
  private void addPeriodButtons(JPanel centerPanel, final CustomPeriodPanel customPeriodPanel) {
    centerPanel.add(new JLabel("        " + getString("Choix_periode") + " : "));
    for (final Period myPeriod : Period.values()) {
      final String linkLabel = myPeriod.getLinkLabel();
      final MButton myPeriodButton =
          new MButton(linkLabel, ImageIconCache.getImageIcon(myPeriod.getIconName()));
      myPeriodButton.setToolTipText(
          getFormattedString("Choisir_periode", linkLabel) + " (Alt-" + linkLabel.charAt(0) + ')');
      myPeriodButton.setMnemonic(linkLabel.charAt(0));
      centerPanel.add(myPeriodButton);
      myPeriodButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              actionChangePeriod(myPeriod.getRange());
            }
          });
    }

    final String customPeriodLinkLabel = getString("personnalisee");
    final MButton customPeriodButton =
        new MButton(customPeriodLinkLabel, ImageIconCache.getImageIcon("calendar.png"));
    customPeriodButton.setToolTipText(
        getFormattedString("Choisir_periode", customPeriodLinkLabel)
            + " (Alt-"
            + customPeriodLinkLabel.charAt(0)
            + ')');
    customPeriodButton.setMnemonic(customPeriodLinkLabel.charAt(0));
    centerPanel.add(customPeriodButton);

    customPeriodPanel.setVisible(false);
    customPeriodButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            customPeriodPanel.setVisible(!customPeriodPanel.isVisible());
            if (customPeriodPanel.isVisible()) {
              customPeriodPanel.requestFocusInStartField();
            }
            validate();
          }
        });
  }
Exemplo n.º 2
0
 public static Period getPeriod(double time) {
   time %= 24 * 3600;
   for (Period period : Period.values()) if (period.isPeriod(time)) return period;
   return null;
 }