KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > usertasks > translators > HistoryOptionsPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.tasklist.usertasks.translators;
21
22 import com.toedter.calendar.JDateChooser;
23 import java.awt.Dimension JavaDoc;
24 import java.util.Date JavaDoc;
25 import javax.swing.ComboBoxModel JavaDoc;
26 import javax.swing.DefaultComboBoxModel JavaDoc;
27 import org.openide.util.NbBundle;
28
29 /**
30  * Some export options for the "Export Spent Times" wizard.
31  *
32  * @author tl
33  */

34 public class HistoryOptionsPanel extends javax.swing.JPanel JavaDoc {
35     /** Group spent times by ... */
36     public static enum Group {DAILY, WEEKLY, MONTHLY, QUARTERLY, YEARLY};
37     
38     private static final String JavaDoc[] GROUPS = {
39         NbBundle.getMessage(HistoryOptionsPanel.class,
40                 "Daily"), // NOI18N
41
NbBundle.getMessage(HistoryOptionsPanel.class,
42                 "Weekly"), // NOI18N
43
NbBundle.getMessage(HistoryOptionsPanel.class,
44                 "Monthly"), // NOI18N
45
NbBundle.getMessage(HistoryOptionsPanel.class,
46                 "Quarterly"), // NOI18N
47
NbBundle.getMessage(HistoryOptionsPanel.class,
48                 "Yearly") // NOI18N
49
};
50     
51     private JDateChooser from, to;
52             
53     /**
54      * Creates new form HistoryOptionsPanel
55      */

56     public HistoryOptionsPanel() {
57         initComponents();
58         
59         Date JavaDoc now = new Date JavaDoc();
60         jPanelFrom.add(from = new JDateChooser(now));
61         jPanelTo.add(to = new JDateChooser(now));
62         
63         Dimension JavaDoc d = from.getPreferredSize();
64         d.width += 10;
65         from.setPreferredSize(d);
66         to.setPreferredSize(d);
67         
68         durationPanel.setDuration(60);
69     }
70     
71     /**
72      * Returns the selected group.
73      *
74      * @return group.
75      */

76     public Group getGroup() {
77         return Group.values()[jComboBoxGroup.getSelectedIndex()];
78     }
79     
80     /**
81      * Start date.
82      *
83      * @return start date
84      */

85     public Date JavaDoc getFrom() {
86         return from.getDate();
87     }
88     
89     /**
90      * End date.
91      *
92      * @return end date
93      */

94     public Date JavaDoc getTo() {
95         return to.getDate();
96     }
97             
98     /**
99      * Returns the minimum task duration in minutes.
100      *
101      * @return task duration in minutes.
102      */

103     public int getMinimumDuration() {
104         return durationPanel.getDuration();
105     }
106     
107     /**
108      * Creates a ComboBoxModel for the group combobox.
109      *
110      * @return created model.
111      */

112     private ComboBoxModel JavaDoc createGroupsModel() {
113         return new DefaultComboBoxModel JavaDoc(GROUPS);
114     }
115     
116     /** This method is called from within the constructor to
117      * initialize the form.
118      * WARNING: Do NOT modify this code. The content of this method is
119      * always regenerated by the Form Editor.
120      */

121     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
122
private void initComponents() {
123         jLabel1 = new javax.swing.JLabel JavaDoc();
124         jLabel2 = new javax.swing.JLabel JavaDoc();
125         jLabel3 = new javax.swing.JLabel JavaDoc();
126         jLabel4 = new javax.swing.JLabel JavaDoc();
127         jPanelFrom = new javax.swing.JPanel JavaDoc();
128         jPanelTo = new javax.swing.JPanel JavaDoc();
129         jComboBoxGroup = new javax.swing.JComboBox JavaDoc();
130         durationPanel = new org.netbeans.modules.tasklist.usertasks.DurationPanel();
131
132         org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(HistoryOptionsPanel.class, "From"));
133
134         org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(HistoryOptionsPanel.class, "To"));
135
136         jLabel3.setLabelFor(jComboBoxGroup);
137         org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(HistoryOptionsPanel.class, "Group"));
138
139         jLabel4.setLabelFor(durationPanel);
140         org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(HistoryOptionsPanel.class, "MinimumDuration"));
141
142         jPanelFrom.setLayout(new java.awt.FlowLayout JavaDoc(java.awt.FlowLayout.CENTER, 0, 5));
143
144         jPanelTo.setLayout(new java.awt.FlowLayout JavaDoc(java.awt.FlowLayout.CENTER, 0, 5));
145
146         jComboBoxGroup.setModel(createGroupsModel());
147
148         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
149         this.setLayout(layout);
150         layout.setHorizontalGroup(
151             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
152             .add(layout.createSequentialGroup()
153                 .addContainerGap()
154                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
155                     .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
156                         .add(jLabel2)
157                         .add(jLabel1)
158                         .add(jLabel3))
159                     .add(jLabel4))
160                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
161                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
162                     .add(jPanelTo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
163                     .add(jPanelFrom, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
164                     .add(jComboBoxGroup, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
165                     .add(durationPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 467, Short.MAX_VALUE))
166                 .addContainerGap())
167         );
168
169         layout.linkSize(new java.awt.Component JavaDoc[] {jLabel1, jLabel2, jLabel3, jLabel4}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
170
171         layout.setVerticalGroup(
172             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
173             .add(layout.createSequentialGroup()
174                 .addContainerGap()
175                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
176                     .add(jPanelFrom, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
177                     .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
178                 .add(11, 11, 11)
179                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
180                     .add(jPanelTo, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
181                     .add(jLabel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
182                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
183                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
184                     .add(jLabel3)
185                     .add(jComboBoxGroup, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
186                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
187                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
188                     .add(jLabel4)
189                     .add(durationPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
190                 .add(166, 166, 166))
191         );
192     }// </editor-fold>//GEN-END:initComponents
193

194     
195     // Variables declaration - do not modify//GEN-BEGIN:variables
196
private org.netbeans.modules.tasklist.usertasks.DurationPanel durationPanel;
197     private javax.swing.JComboBox JavaDoc jComboBoxGroup;
198     private javax.swing.JLabel JavaDoc jLabel1;
199     private javax.swing.JLabel JavaDoc jLabel2;
200     private javax.swing.JLabel JavaDoc jLabel3;
201     private javax.swing.JLabel JavaDoc jLabel4;
202     private javax.swing.JPanel JavaDoc jPanelFrom;
203     private javax.swing.JPanel JavaDoc jPanelTo;
204     // End of variables declaration//GEN-END:variables
205

206 }
207
Popular Tags