Class DatePicker
- java.lang.Object
-
- org.eclipse.nebula.cwt.v.VControl
-
- org.eclipse.nebula.cwt.v.VPanel
-
- org.eclipse.nebula.widgets.cdatetime.DatePicker
-
class DatePicker extends VPanel
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.nebula.cwt.v.VControl
VControl.Type
-
-
Field Summary
Fields Modifier and Type Field Description private VPanelbodyprivate VPanel[]bodyPanelsprivate CDateTimecdt(package private) VButtonclear(package private) VButtondateNow(package private) VButton[]dayButtons(package private) VLabel[]dayLabelsprivate org.eclipse.swt.widgets.ListenerdayListenerprivate VPaneldayPanelprivate static intDAYS_IN_WEEK(package private) booleaneditYearprivate VPanelfooterprivate VPanelheaderprivate java.lang.StringlastPattern(package private) VButtonmonthButton(package private) VButton[]monthButtons(package private) org.eclipse.swt.widgets.MenuItem[]monthItems(package private) VButtonmonthNext(package private) VPanelmonthPanel(package private) VButtonmonthPrevprivate static intNUM_ROWSprivate VPanelpickerprivate booleanscrollableprivate java.text.SimpleDateFormatsdf(package private) org.eclipse.swt.widgets.MenuItemshowSelMenuItem(package private) VButtontimeButton(package private) AnalogTimePickertimePanel(package private) VButtontoday(package private) org.eclipse.swt.widgets.MenuItemtodayMenuItem(package private) VButtonyearButton(package private) VButton[]yearButtons(package private) org.eclipse.swt.widgets.MenuItem[]yearItems(package private) VButtonyearNext(package private) VPanelyearPanel(package private) VButtonyearPrev-
Fields inherited from class org.eclipse.nebula.cwt.v.VControl
carbon, gtk, STATE_ACTIVE, STATE_ENABLED, STATE_MOUSE_DOWN, STATE_SELECTED, win32
-
-
Constructor Summary
Constructors Constructor Description DatePicker(CDateTime parent)Constructs a new instance of this class given its parent, a style value describing its behavior and appearance, a date to which the initial selection will be set, and the locale to use.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddBodyPanel()private voidadjustDays(int field, int amount)Modifies the given Calendar field by the given amount for every dayButton.
calendar.add(CalendarField, amount)private voidcolorButtons(VButton button)private voidcreateBody()create the Calendar's body, which contains the dayLabels and dayButtonsprotected voidcreateContents()private voidcreateDays(Body b)private voidcreateFooter()create the footer (footerButton) for the Calendar part of this CDateTime
there is currently no footer for the Clock part - should there be? or should this footer span both parts?private voidcreateHeader()create the header for the Calendar part of this CDateTime
there is no equivalent for the Clock partprivate voidcreateMonths(Body b)private voidcreateTime(Body b)private voidcreateYears(Body b)int[]getFields()private intgetFocusDayButton()private java.lang.StringgetFormattedDate(java.lang.String pattern, java.util.Date date)private voidhandleHeaderSelection(VButton button)private voidinit(int style)private booleanisValidDate(java.util.Calendar selectedDay)(package private) static booleanisValidDate(java.util.Calendar selectedDay, java.util.Calendar min, java.util.Calendar max)private voidscrollCalendar(int keycode)perform the scroll by making a call toadjustDays(int, int)with thefieldset to Calendar.DATE and theamountcorresponding to the keycode.private voidsetButtonFocus(int index)private voidsetCDTSelection(java.util.Date selection)private voidsetDays(java.util.Date firstDate, boolean alignMonth)Set the date for each dayButton by starting with the givenfirstDateand iterating over all the dayButtons, adding 1 day to the date with each iteration.
The date is stored in the dayButton with: setData(CDT.Key.Date, date).
IfalignMonthis true, then the actual first date used will be modified to be the first date of the visible calendar which includes the givenfirstDatevoidsetEditable(boolean editable)voidsetFields(int[] calendarFields)booleansetFocus()protected booleansetFocus(boolean focus)private booleansetFocusToSelection()(package private) voidsetMonthLabelText()voidsetScrollable(boolean scrollable)private voidsetSelectionFromButton(VButton button, int stateMask)private voidsetSelectionFromFocusButton(org.eclipse.swt.widgets.Event event)(package private) voidtraverseSelection(int keyCode)Traverse the selection programmatically just as a user would with the keyboard.voidupdateColorsAndFont()private voidupdateDays()set / update the text and font color of thedayButtons.private voidupdateDaysOfWeek()set / update the text of the displayLabels.private voidupdateFooter()set / update the text of thefooterButton.private voidupdateHeader()set / update the text of the header -monthLabel,yearLabel, and themonthLabelcontext menu.protected voidupdateLabels()private voidupdateLocale()set / update, or calls methods to set / update, all components affected by thelocaleprivate voidupdateMonths()(package private) voidupdateView()private voidupdateYears()-
Methods inherited from class org.eclipse.nebula.cwt.v.VPanel
computeSize, dispose, getBorderWidth, getChildren, getControl, getControl, getLayout, getLayout, getType, getWidget, layout, layout, redrawOnActivate, redrawOnDeactivate, setActivatable, setBounds, setEnabled, setLayout, setLayoutData, setSize, setVisibility, setVisible, setWidget, sort
-
Methods inherited from class org.eclipse.nebula.cwt.v.VControl
addListener, computeSize, containsControl, createMenu, filterEvent, getBackground, getBounds, getClientArea, getClientSize, getComposite, getControl, getData, getData, getData, getData, getDisplay, getEnabled, getFont, getForeground, getImage, getLayoutData, getListeners, getLocation, getMargins, getMenu, getParent, getShell, getSize, getState, getStyle, getText, getToolTipText, getVisibility, getVisible, hasState, hasStyle, isActivatable, isDisposed, isEnabled, isSameWidgetAs, isSameWidgetAs, isSquare, isVisible, moveAbove, moveBelow, notifyListeners, notifyListeners, paintControl, redraw, removeListener, setActiveCursor, setAlignment, setAlpha, setAlpha, setBackground, setBounds, setCursor, setData, setData, setFill, setFont, setForeground, setImage, setImage, setInactiveCursor, setLocation, setLocation, setMargins, setMargins, setMargins, setOval, setOval, setPainter, setParent, setPolygon, setPolygon, setScaleImage, setSquare, setState, setStyle, setStyle, setText, setToolTipText, setVisible, setVisible, toControl, toControl, toDisplay, toDisplay, toString, update
-
-
-
-
Field Detail
-
DAYS_IN_WEEK
private static final int DAYS_IN_WEEK
- See Also:
- Constant Field Values
-
NUM_ROWS
private static final int NUM_ROWS
- See Also:
- Constant Field Values
-
dayListener
private org.eclipse.swt.widgets.Listener dayListener
-
header
private VPanel header
-
body
private VPanel body
-
bodyPanels
private VPanel[] bodyPanels
-
footer
private VPanel footer
-
dayPanel
private VPanel dayPanel
-
monthButton
VButton monthButton
-
monthPrev
VButton monthPrev
-
dateNow
VButton dateNow
-
monthNext
VButton monthNext
-
yearButton
VButton yearButton
-
yearPrev
VButton yearPrev
-
yearNext
VButton yearNext
-
timeButton
VButton timeButton
-
dayLabels
VLabel[] dayLabels
-
dayButtons
VButton[] dayButtons
-
today
VButton today
-
clear
VButton clear
-
todayMenuItem
org.eclipse.swt.widgets.MenuItem todayMenuItem
-
showSelMenuItem
org.eclipse.swt.widgets.MenuItem showSelMenuItem
-
monthItems
org.eclipse.swt.widgets.MenuItem[] monthItems
-
yearItems
org.eclipse.swt.widgets.MenuItem[] yearItems
-
editYear
boolean editYear
-
scrollable
private boolean scrollable
-
monthPanel
VPanel monthPanel
-
monthButtons
VButton[] monthButtons
-
yearPanel
VPanel yearPanel
-
yearButtons
VButton[] yearButtons
-
timePanel
AnalogTimePicker timePanel
-
cdt
private CDateTime cdt
-
sdf
private java.text.SimpleDateFormat sdf
-
lastPattern
private java.lang.String lastPattern
-
picker
private VPanel picker
-
-
Constructor Detail
-
DatePicker
public DatePicker(CDateTime parent)
Constructs a new instance of this class given its parent, a style value describing its behavior and appearance, a date to which the initial selection will be set, and the locale to use.- Parameters:
parent- a widget which will be the parent of the new instance (cannot be null)
-
-
Method Detail
-
addBodyPanel
private void addBodyPanel()
-
adjustDays
private void adjustDays(int field, int amount)Modifies the given Calendar field by the given amount for every dayButton.
calendar.add(CalendarField, amount)- Parameters:
field- Calendar Fieldamount- adjustment to be added
-
createBody
private void createBody()
create the Calendar's body, which contains the dayLabels and dayButtons
-
createContents
protected void createContents()
-
createDays
private void createDays(Body b)
-
colorButtons
private void colorButtons(VButton button)
-
createFooter
private void createFooter()
create the footer (footerButton) for the Calendar part of this CDateTime
there is currently no footer for the Clock part - should there be? or should this footer span both parts?
-
createHeader
private void createHeader()
create the header for the Calendar part of this CDateTime
there is no equivalent for the Clock part
-
createMonths
private void createMonths(Body b)
-
createTime
private void createTime(Body b)
-
createYears
private void createYears(Body b)
-
getFields
public int[] getFields()
-
getFocusDayButton
private int getFocusDayButton()
-
getFormattedDate
private java.lang.String getFormattedDate(java.lang.String pattern, java.util.Date date)
-
handleHeaderSelection
private void handleHeaderSelection(VButton button)
-
init
private void init(int style)
-
scrollCalendar
private void scrollCalendar(int keycode)
perform the scroll by making a call toadjustDays(int, int)with thefieldset to Calendar.DATE and theamountcorresponding to the keycode.
-
setButtonFocus
private void setButtonFocus(int index)
-
setDays
private void setDays(java.util.Date firstDate, boolean alignMonth)Set the date for each dayButton by starting with the givenfirstDateand iterating over all the dayButtons, adding 1 day to the date with each iteration.
The date is stored in the dayButton with: setData(CDT.Key.Date, date).
IfalignMonthis true, then the actual first date used will be modified to be the first date of the visible calendar which includes the givenfirstDate- Parameters:
firstDate- the first date of the dayButtonsalignMonth- whether or not to align the month
-
setEditable
public void setEditable(boolean editable)
-
setFields
public void setFields(int[] calendarFields)
-
setFocusToSelection
private boolean setFocusToSelection()
-
setMonthLabelText
void setMonthLabelText()
-
setScrollable
public void setScrollable(boolean scrollable)
-
setSelectionFromButton
private void setSelectionFromButton(VButton button, int stateMask)
-
setSelectionFromFocusButton
private void setSelectionFromFocusButton(org.eclipse.swt.widgets.Event event)
-
traverseSelection
void traverseSelection(int keyCode)
Traverse the selection programmatically just as a user would with the keyboard.- Valid Keys:
- SWT.ARROW_UP, SWT.ARROW_DOWN, SWT.ARROW_LEFT, SWT.ARROW_RIGHT
- Parameters:
keyCode- a SWT traversal keycode- See Also:
scrollCalendar(int)
-
updateDays
private void updateDays()
set / update the text and font color of thedayButtons.
-
updateDaysOfWeek
private void updateDaysOfWeek()
set / update the text of the displayLabels. these are the Week column headers above the days on the Calendar part of theCDateTime.
-
updateFooter
private void updateFooter()
set / update the text of thefooterButton.
-
updateHeader
private void updateHeader()
set / update the text of the header -monthLabel,yearLabel, and themonthLabelcontext menu.
-
updateLabels
protected void updateLabels()
-
updateLocale
private void updateLocale()
set / update, or calls methods to set / update, all components affected by thelocale- See Also:
updateHeader(),#updateDayLabels,updateDays(),updateFooter()
-
updateMonths
private void updateMonths()
-
updateView
void updateView()
-
updateYears
private void updateYears()
-
setCDTSelection
private void setCDTSelection(java.util.Date selection)
-
isValidDate
private boolean isValidDate(java.util.Calendar selectedDay)
-
isValidDate
static boolean isValidDate(java.util.Calendar selectedDay, java.util.Calendar min, java.util.Calendar max)
-
updateColorsAndFont
public void updateColorsAndFont()
- Overrides:
updateColorsAndFontin classVPanel
-
-