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 VPanel
body
private VPanel[]
bodyPanels
private CDateTime
cdt
(package private) VButton
clear
(package private) VButton
dateNow
(package private) VButton[]
dayButtons
(package private) VLabel[]
dayLabels
private org.eclipse.swt.widgets.Listener
dayListener
private VPanel
dayPanel
private static int
DAYS_IN_WEEK
(package private) boolean
editYear
private VPanel
footer
private VPanel
header
private java.lang.String
lastPattern
(package private) VButton
monthButton
(package private) VButton[]
monthButtons
(package private) org.eclipse.swt.widgets.MenuItem[]
monthItems
(package private) VButton
monthNext
(package private) VPanel
monthPanel
(package private) VButton
monthPrev
private static int
NUM_ROWS
private VPanel
picker
private boolean
scrollable
private java.text.SimpleDateFormat
sdf
(package private) org.eclipse.swt.widgets.MenuItem
showSelMenuItem
(package private) VButton
timeButton
(package private) AnalogTimePicker
timePanel
(package private) VButton
today
(package private) org.eclipse.swt.widgets.MenuItem
todayMenuItem
(package private) VButton
yearButton
(package private) VButton[]
yearButtons
(package private) org.eclipse.swt.widgets.MenuItem[]
yearItems
(package private) VButton
yearNext
(package private) VPanel
yearPanel
(package private) VButton
yearPrev
-
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 void
addBodyPanel()
private void
adjustDays(int field, int amount)
Modifies the given Calendar field by the given amount for every dayButton.
calendar.add(CalendarField, amount)private void
colorButtons(VButton button)
private void
createBody()
create the Calendar's body, which contains the dayLabels and dayButtonsprotected void
createContents()
private void
createDays(Body b)
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?private void
createHeader()
create the header for the Calendar part of this CDateTime
there is no equivalent for the Clock partprivate void
createMonths(Body b)
private void
createTime(Body b)
private void
createYears(Body b)
int[]
getFields()
private int
getFocusDayButton()
private java.lang.String
getFormattedDate(java.lang.String pattern, java.util.Date date)
private void
handleHeaderSelection(VButton button)
private void
init(int style)
private boolean
isValidDate(java.util.Calendar selectedDay)
(package private) static boolean
isValidDate(java.util.Calendar selectedDay, java.util.Calendar min, java.util.Calendar max)
private void
scrollCalendar(int keycode)
perform the scroll by making a call toadjustDays(int, int)
with thefield
set to Calendar.DATE and theamount
corresponding to the keycode.private void
setButtonFocus(int index)
private void
setCDTSelection(java.util.Date selection)
private void
setDays(java.util.Date firstDate, boolean alignMonth)
Set the date for each dayButton by starting with the givenfirstDate
and 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).
IfalignMonth
is true, then the actual first date used will be modified to be the first date of the visible calendar which includes the givenfirstDate
void
setEditable(boolean editable)
void
setFields(int[] calendarFields)
boolean
setFocus()
protected boolean
setFocus(boolean focus)
private boolean
setFocusToSelection()
(package private) void
setMonthLabelText()
void
setScrollable(boolean scrollable)
private void
setSelectionFromButton(VButton button, int stateMask)
private void
setSelectionFromFocusButton(org.eclipse.swt.widgets.Event event)
(package private) void
traverseSelection(int keyCode)
Traverse the selection programmatically just as a user would with the keyboard.void
updateColorsAndFont()
private void
updateDays()
set / update the text and font color of thedayButton
s.private void
updateDaysOfWeek()
set / update the text of the displayLabels.private void
updateFooter()
set / update the text of thefooterButton
.private void
updateHeader()
set / update the text of the header -monthLabel
,yearLabel
, and themonthLabel
context menu.protected void
updateLabels()
private void
updateLocale()
set / update, or calls methods to set / update, all components affected by thelocale
private void
updateMonths()
(package private) void
updateView()
private void
updateYears()
-
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 thefield
set to Calendar.DATE and theamount
corresponding 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 givenfirstDate
and 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).
IfalignMonth
is 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 thedayButton
s.
-
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 themonthLabel
context 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:
updateColorsAndFont
in classVPanel
-
-