Logo Search packages:      
Sourcecode: pcalendar version File versions  Download package

void net::sf::linuxorg::pcal::MainWindow::jumpToDate ( Date  new_date,
boolean  force_refresh 
) [inline, private]

This method refresh the main window components according to the curerntly selected date. This include: 1. Regenerate calendar grid as needed. 2. Update the current day summary panel 3. Update toolbar month/year labels 4. Select/unselect date notes as needed.

Parameters:
new_date- if null - today date will be used

Definition at line 936 of file MainWindow.java.

References net::sf::linuxorg::pcal::PCalDayInfo::day_num, net::sf::linuxorg::pcal::PCalDayInfo::estimate, net::sf::linuxorg::pcal::engine::Engine::getPredictedBirthDay(), refreshCalendar(), and selectDateNote().

Referenced by createAndShowGUI(), and refreshAll().

                                                                    {

            if(new_date==null) new_date = new Date();
            Calendar calendar = new GregorianCalendar();
            // normalize to 00:00
            Calendar temp_calendar = new GregorianCalendar();
            temp_calendar.setTime(new_date);
            calendar.clear();
            calendar.set(temp_calendar.get(Calendar.YEAR), temp_calendar.get(Calendar.MONTH), temp_calendar.get(Calendar.DAY_OF_MONTH));
            new_date = calendar.getTime();

            boolean need_to_rebuild = false;
            target_day_pos = 0; 

            if(force_refresh) {
                  need_to_rebuild = true;
            } else {
                  if(calCurrentDate==null) {
                        need_to_rebuild = true;
                  } else {
                        Calendar old_calendar = new GregorianCalendar();
                        old_calendar.setTime(calCurrentDate);
                        need_to_rebuild = (calendar.get(Calendar.MONTH) != old_calendar.get(Calendar.MONTH))||
                        (calendar.get(Calendar.YEAR) != old_calendar.get(Calendar.YEAR));
                  }
            }

            //refresh the calendar for the current date
            PCalDayInfo target_day_info = refreshCalendar(new_date, calendar, need_to_rebuild);

            //fill the toolbar labels
            toolbarMonthLabel.setText(monthNames[calendar.get(Calendar.MONTH)]);
            toolbarYearLabel.setText(new Integer(calendar.get(Calendar.YEAR)).toString());

            DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.SHORT);
            dayInfoLabelDate.setText(dateFormatter.format(new_date));

            for(JLabel label : dayInfoLabels) {
                  label.setText("");  //$NON-NLS-1$
            }

            if((target_day_info == null)) {
                  predictionLabel.setText(Messages.getString("MainWindow.38")); //$NON-NLS-1$
                  actionAddMenstruation.setEnabled(true);
                  actionAddOvulation.setEnabled(true);
                  actionRecordPregnancy.setEnabled(true);
                  actionRecordPregInt.setEnabled(true);
                  actionRecordBirth.setEnabled(true);
                  actionDeleteRecord.setEnabled(false);
            } else {
                  if(target_day_info.birth) {
                        dayInfoLabels[0].setText(Messages.getString("MainWindow.39")); //$NON-NLS-1$
                  } else
                        if(target_day_info.pregnancy_interruption) {
                              dayInfoLabels[0].setText(Messages.getString("MainWindow.11")); //$NON-NLS-1$
                        }
                        else
                              if(target_day_info.pregnancy) {
                                    dayInfoLabels[0].setText(Messages.getString("MainWindow.40")); //$NON-NLS-1$
                                    if(target_day_info.day_num==-1) {
                                          dayInfoLabels[1].setText(Messages.getString("MainWindow.20")); //$NON-NLS-1$
                                    } else {
                                          dayInfoLabels[1].setText(String.valueOf(target_day_info.day_num/7+1));
                                          // calculate the estimated birthday
                                          Date bdate = PCalendar.engine.getPredictedBirthDay(new_date, target_day_info.day_num);                      
                                          dayInfoLabels[3].setText(dateFormatter.format(bdate));
                                    }
                                    dayInfoLabels[2].setText(Messages.getString("MainWindow.41")); //$NON-NLS-1$
                              } else { 
                                    // this is a regular day
                                    dayInfoLabels[0].setText(Messages.getString("MainWindow.42")); //$NON-NLS-1$
                                    if(target_day_info.day_num!=-1) {
                                          dayInfoLabels[1].setText(String.valueOf(target_day_info.day_num+1));
                                          dayInfoLabels[4].setText(Messages.getString("MainWindow.46")); //$NON-NLS-1$
                                          dayInfoLabels[5].setText(target_day_info.badFeel?Messages.getString("MainWindow.47"):Messages.getString("MainWindow.48")); //$NON-NLS-1$ //$NON-NLS-2$
                                    } else {
                                          dayInfoLabels[1].setText(Messages.getString("MainWindow.21")); //$NON-NLS-1$
                                    }
                                    dayInfoLabels[2].setText(Messages.getString("MainWindow.43")); //$NON-NLS-1$
                                    if(target_day_info.ovulation) {
                                          dayInfoLabels[3].setText(Messages.getString("MainWindow.34")); //$NON-NLS-1$
                                    } else {                      
                                          dayInfoLabels[3].setText(target_day_info.fertile?Messages.getString("MainWindow.44"):Messages.getString("MainWindow.45")); //$NON-NLS-1$ //$NON-NLS-2$
                                    }
                              }
                  predictionLabel.setText(target_day_info.estimate?
                              Messages.getString("MainWindow.49"):"");   //$NON-NLS-1$ //$NON-NLS-2$

                  boolean recordActionsEnabled = ((target_day_info.day_num != 0) &&
                              !target_day_info.birth &&
                              !target_day_info.pregnancy_interruption &&
                              !target_day_info.ovulation)
                              || target_day_info.estimate;
                  actionAddMenstruation.setEnabled(recordActionsEnabled);
                  actionAddOvulation.setEnabled(recordActionsEnabled);
                  actionRecordPregnancy.setEnabled(recordActionsEnabled);
                  actionRecordBirth.setEnabled(recordActionsEnabled);
                  actionRecordPregInt.setEnabled(recordActionsEnabled);
                  actionDeleteRecord.setEnabled(!recordActionsEnabled);
            }

            calCurrentDate = new_date;
            ((AbstractTableModel) calendarTable.getModel()).fireTableDataChanged();
            jumping = true;

            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                        calendarTable.changeSelection(target_day_pos/7, target_day_pos%7, false, false);
                        jumping = false;
                        selectDateNote(calCurrentDate);
                  }
            });

            frame.validate();
      }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index