void setMonthLabelText() { String str = getFormattedDate("MMMM", cdt.getCalendarTime()); // $NON-NLS-1$ GC gc = new GC(getDisplay()); int width = monthButton.getClientArea().width; if (width > 0 && gc.stringExtent(str).x >= width) { str = getFormattedDate("MMM", cdt.getCalendarTime()); // $NON-NLS-1$ } gc.dispose(); monthButton.setText(str); }
void updateView() { updateHeader(); if (dayPanel != null) { setDays(cdt.getCalendarTime(), true); updateDays(); } updateMonths(); updateYears(); if (timePanel != null) { timePanel.updateView(); } updateFooter(); }
/** * set / update the text of the header - <code>monthLabel</code>, <code>yearLabel</code>, and the * <code>monthLabel</code> context menu. */ private void updateHeader() { if (header != null) { Calendar selected = cdt.getCalendarInstance(); if (monthButton != null) { setMonthLabelText(); } if (monthItems != null) { Calendar tmpcal = cdt.getCalendarInstance(); for (int i = 0; i < 12; i++) { tmpcal.set(Calendar.MONTH, i); monthItems[i].setText(getFormattedDate("MMMM", tmpcal.getTime())); // $NON-NLS-1$ monthItems[i].setData("Month", new Integer(tmpcal.get(Calendar.MONTH))); // $NON-NLS-1$ if (selected.get(Calendar.MONDAY) == tmpcal.get(Calendar.MONTH)) { monthItems[i].setImage(Resources.getIconBullet()); } else { monthItems[i].setImage(null); } } } if (yearButton != null) { yearButton.setText(getFormattedDate("yyyy", cdt.getCalendarTime())); // $NON-NLS-1$ } if (yearItems != null) { Calendar tmpcal = cdt.getCalendarInstance(); tmpcal.add(Calendar.YEAR, -5); for (int i = 0; i < 11; i++) { yearItems[i].setText(getFormattedDate("yyyy", tmpcal.getTime())); // $NON-NLS-1$ if (selected.get(Calendar.YEAR) == tmpcal.get(Calendar.YEAR)) { yearItems[i].setImage(Resources.getIconBullet()); } else { yearItems[i].setImage(null); } tmpcal.add(Calendar.YEAR, 1); } } header.layout(); } }