1 19 20 package org.netbeans.modules.tasklist.usertasks.translators; 21 22 import com.toedter.calendar.JDateChooser; 23 import java.awt.Dimension ; 24 import java.util.Date ; 25 import javax.swing.ComboBoxModel ; 26 import javax.swing.DefaultComboBoxModel ; 27 import org.openide.util.NbBundle; 28 29 34 public class HistoryOptionsPanel extends javax.swing.JPanel { 35 36 public static enum Group {DAILY, WEEKLY, MONTHLY, QUARTERLY, YEARLY}; 37 38 private static final String [] GROUPS = { 39 NbBundle.getMessage(HistoryOptionsPanel.class, 40 "Daily"), NbBundle.getMessage(HistoryOptionsPanel.class, 42 "Weekly"), NbBundle.getMessage(HistoryOptionsPanel.class, 44 "Monthly"), NbBundle.getMessage(HistoryOptionsPanel.class, 46 "Quarterly"), NbBundle.getMessage(HistoryOptionsPanel.class, 48 "Yearly") }; 50 51 private JDateChooser from, to; 52 53 56 public HistoryOptionsPanel() { 57 initComponents(); 58 59 Date now = new Date (); 60 jPanelFrom.add(from = new JDateChooser(now)); 61 jPanelTo.add(to = new JDateChooser(now)); 62 63 Dimension d = from.getPreferredSize(); 64 d.width += 10; 65 from.setPreferredSize(d); 66 to.setPreferredSize(d); 67 68 durationPanel.setDuration(60); 69 } 70 71 76 public Group getGroup() { 77 return Group.values()[jComboBoxGroup.getSelectedIndex()]; 78 } 79 80 85 public Date getFrom() { 86 return from.getDate(); 87 } 88 89 94 public Date getTo() { 95 return to.getDate(); 96 } 97 98 103 public int getMinimumDuration() { 104 return durationPanel.getDuration(); 105 } 106 107 112 private ComboBoxModel createGroupsModel() { 113 return new DefaultComboBoxModel (GROUPS); 114 } 115 116 121 private void initComponents() { 123 jLabel1 = new javax.swing.JLabel (); 124 jLabel2 = new javax.swing.JLabel (); 125 jLabel3 = new javax.swing.JLabel (); 126 jLabel4 = new javax.swing.JLabel (); 127 jPanelFrom = new javax.swing.JPanel (); 128 jPanelTo = new javax.swing.JPanel (); 129 jComboBoxGroup = new javax.swing.JComboBox (); 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 (java.awt.FlowLayout.CENTER, 0, 5)); 143 144 jPanelTo.setLayout(new java.awt.FlowLayout (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 [] {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 } 194 195 private org.netbeans.modules.tasklist.usertasks.DurationPanel durationPanel; 197 private javax.swing.JComboBox jComboBoxGroup; 198 private javax.swing.JLabel jLabel1; 199 private javax.swing.JLabel jLabel2; 200 private javax.swing.JLabel jLabel3; 201 private javax.swing.JLabel jLabel4; 202 private javax.swing.JPanel jPanelFrom; 203 private javax.swing.JPanel jPanelTo; 204 206 } 207 | Popular Tags |