Esempio n. 1
0
 public void update() {
   listenersEnabled = false;
   try {
     Date startDate = model.getStartDate();
     startDateSelection.setDate(startDate);
     final PeriodModel periodModel = getPeriodModel();
     periodChooser.setPeriodModel(periodModel);
     periodChooser.setDate(startDate);
     Date endDate = model.getEndDate();
     periodPanel.setVisible(periodModel.getSize() > 0);
     endDateSelection.setDate(DateTools.subDay(endDate));
   } finally {
     listenersEnabled = true;
   }
 }
Esempio n. 2
0
  public IntervalChooserPanel(RaplaContext sm, CalendarModel model) throws RaplaException {
    super(sm);
    this.model = model;

    periodChooser = new PeriodChooser(getContext(), PeriodChooser.START_AND_END);
    periodChooser.setWeekOfPeriodVisible(false);

    startDateSelection = createRaplaCalendar();
    endDateSelection = createRaplaCalendar();
    // prevButton.setText("<");
    // nextButton.setText(">");
    double pre = TableLayout.PREFERRED;
    double[][] sizes = {{5, pre, 5, pre, 5, 0.9, 0.02}, {pre}};
    TableLayout tableLayout = new TableLayout(sizes);

    int todayWidth = (int) Math.max(40, startTodayButton.getPreferredSize().getWidth());

    startTodayButton.setPreferredSize(new Dimension(todayWidth, 20));
    endTodayButton.setPreferredSize(new Dimension(todayWidth, 20));

    panel.setLayout(tableLayout);

    JPanel startPanel = new JPanel();
    TitledBorder titleBorder = BorderFactory.createTitledBorder(getString("start_date"));
    startPanel.setBorder(titleBorder);

    startPanel.add(startDateSelection);
    // BJO 00000042
    startPanel.add(startTodayButton);
    startPanel.add(prevStartButton);
    startPanel.add(nextStartButton);
    startTodayButton.addActionListener(listener);
    prevStartButton.addActionListener(listener);
    nextStartButton.addActionListener(listener);
    // BJO 00000042
    panel.add(startPanel, "1,0");

    JPanel endPanel = new JPanel();
    titleBorder = BorderFactory.createTitledBorder(getString("end_date"));
    endPanel.setBorder(titleBorder);
    endPanel.add(endDateSelection);
    // BJO 00000042
    endPanel.add(endTodayButton);
    endPanel.add(prevEndButton);
    endPanel.add(nextEndButton);
    endTodayButton.addActionListener(listener);
    prevEndButton.addActionListener(listener);
    nextEndButton.addActionListener(listener);
    // BJO 00000042
    panel.add(endPanel, "3,0");

    periodPanel = new JPanel(new GridLayout(1, 1));
    titleBorder = BorderFactory.createTitledBorder(getString("period"));
    periodPanel.setBorder(titleBorder);
    periodPanel.add(periodChooser);

    panel.add(periodPanel, "5,0");
    periodChooser.addActionListener(listener);

    startDateSelection.addDateChangeListener(listener);
    endDateSelection.addDateChangeListener(listener);
    update();
  }