Example #1
0
 /**
  * Create a default filename given the current date selection. If custom dates are selected, use
  * those dates; otherwise, use year and week numbers.
  *
  * @return The default filename.
  */
 private String getDefaultFilename() {
   if (yearCB.getSelectedIndex() == 0 || weekCB.getSelectedIndex() == 0)
     return "timesheet-"
         + dateFormat.format(fromDate.getDate()).replaceAll("/", "")
         + "-"
         + dateFormat.format(toDate.getDate()).replaceAll("/", "")
         + ".txt";
   return "timesheet-" + yearCB.getSelectedItem() + "wk" + weekCB.getSelectedItem() + ".txt";
 }
Example #2
0
 /**
  * Set calendar to this week's Monday; set year and week combo boxes to the currently set date;
  * set the date labels appropriately; and, refresh the review table.
  */
 private void updateYearWeekDates() {
   yearWeekCalendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
   yearWeekCalendar.set(Calendar.HOUR_OF_DAY, 0);
   yearWeekCalendar.set(Calendar.MINUTE, 0);
   yearWeekCalendar.set(Calendar.SECOND, 0);
   yearWeekCalendar.set(Calendar.MILLISECOND, 0);
   yearCB.setSelectedItem(yearWeekCalendar.get(Calendar.YEAR));
   weekCB.setSelectedItem(yearWeekCalendar.get(Calendar.WEEK_OF_YEAR));
   fromDate.setDate(yearWeekCalendar);
   yearWeekCalendar.add(Calendar.DAY_OF_MONTH, 7);
   toDate.setDate(yearWeekCalendar);
   yearWeekCalendar.add(Calendar.DAY_OF_MONTH, -7);
   refreshReviewTable();
 }
Example #3
0
 /**
  * Returns the unique ID of a week prefixed with the year.
  *
  * @return Selected week's ID.
  */
 String getSelectedWeekID() {
   String weekNo = weekCB.getSelectedItem().toString();
   if (weekNo.length() == 1) weekNo = "0" + weekNo;
   return yearCB.getSelectedItem() + "wk" + weekNo;
 }
Example #4
0
 /**
  * Checks whether the interval has been set using the date chooser.
  *
  * @return True if custom.
  */
 boolean isIntervalCustom() {
   return yearCB.getSelectedIndex() == 0 || weekCB.getSelectedIndex() == 0;
 }
Example #5
0
 /** Set both year and week combo boxes to field "Custom". */
 private void resetYearWeekComboBoxes() {
   yearCB.setSelectedIndex(0);
   weekCB.setSelectedIndex(0);
 }