Search in sources :

Example 1 with JDateChooser

use of com.toedter.calendar.JDateChooser in project processdash by dtuma.

the class TeamMemberListTable method showCustomizationWindow.

/**
     * Display a dialog window, allowing the user to customize aspects of the
     * team schedule. If they click OK, apply the changes they have made.
     */
private void showCustomizationWindow() {
    TeamMemberList tml = getTeamMemberList();
    boolean readOnly = tml.isReadOnly() || tml.getOnlyEditableFor() != null;
    int currentDOW = tml.getStartOnDayOfWeek();
    JComboBox weekSelector = new JComboBox();
    String selectedDayName = null;
    String[] dayNames = new DateFormatSymbols().getWeekdays();
    for (int i = 0; i < DAYS_OF_THE_WEEK.length; i++) {
        int dow = DAYS_OF_THE_WEEK[i];
        weekSelector.addItem(dayNames[dow]);
        if (dow == currentDOW)
            weekSelector.setSelectedItem(selectedDayName = dayNames[dow]);
    }
    Box wb = Box.createHorizontalBox();
    wb.add(Box.createHorizontalStrut(25));
    wb.add(readOnly ? new JLabel(selectedDayName) : weekSelector);
    Object[] contents = new Object[] { resources.getString("Customize.Start_Day"), wb };
    if (readOnly) {
        JOptionPane.showMessageDialog(this, contents, //
        resources.getString("Customize.Title_Read_Only"), JOptionPane.PLAIN_MESSAGE);
        return;
    }
    JDateChooser newStartDate = new JDateChooser((Date) null);
    contents = new Object[] { contents, BoxUtils.vbox(5), resources.getString("Customize.Move_Dates"), BoxUtils.hbox(25, newStartDate) };
    if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(this, contents, resources.getString("Customize.Title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE)) {
        Object selectedDay = weekSelector.getSelectedItem();
        for (int i = 0; i < dayNames.length; i++) {
            if (selectedDay.equals(dayNames[i]))
                tml.setStartOnDayOfWeek(i);
        }
        if (newStartDate.getDate() != null)
            tml.moveAllStartDates(newStartDate.getDate());
        updateCustomizationHyperlinkText();
        getTableHeader().repaint();
    }
}
Also used : JDateChooser(com.toedter.calendar.JDateChooser) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) DateFormatSymbols(java.text.DateFormatSymbols) JComboBox(javax.swing.JComboBox) Box(javax.swing.Box) Point(java.awt.Point)

Example 2 with JDateChooser

use of com.toedter.calendar.JDateChooser in project processdash by dtuma.

the class TimeLogEditor method addDateField.

private JDateChooser addDateField(JPanel retPanel, String labelKey) {
    JLabel label = new JLabel(getResource(labelKey) + " ");
    retPanel.add(label);
    retPanel.add(Box.createHorizontalStrut(5));
    JDateChooser result = new JDateChooser(null, DATE_FORMAT);
    result.setPreferredSize(new Dimension(DATE_CHOOSER_WIDTH, result.getPreferredSize().height));
    label.setLabelFor(result);
    result.setMaximumSize(result.getPreferredSize());
    retPanel.add(result);
    retPanel.add(Box.createHorizontalStrut(5));
    return result;
}
Also used : JDateChooser(com.toedter.calendar.JDateChooser) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension)

Aggregations

JDateChooser (com.toedter.calendar.JDateChooser)2 JLabel (javax.swing.JLabel)2 Dimension (java.awt.Dimension)1 Point (java.awt.Point)1 DateFormatSymbols (java.text.DateFormatSymbols)1 Box (javax.swing.Box)1 JComboBox (javax.swing.JComboBox)1