org.opencms.widgets
Class CmsCalendarWidget

java.lang.Object
  extended by org.opencms.widgets.A_CmsWidget
      extended by org.opencms.widgets.CmsCalendarWidget
All Implemented Interfaces:
I_CmsWidget

public class CmsCalendarWidget
extends A_CmsWidget

Provides a DHTML calendar widget, for use on a widget dialog.

Since:
6.0.0
Version:
$Revision: 1.20 $
Author:
Alexander Kandzior

Field Summary
 
Fields inherited from class org.opencms.widgets.A_CmsWidget
HELP_POSTFIX, LABEL_PREFIX
 
Constructor Summary
CmsCalendarWidget()
          Creates a new calendar widget.
CmsCalendarWidget(java.lang.String configuration)
          Creates a new calendar widget with the given configuration.
 
Method Summary
static java.lang.String calendarIncludes(java.util.Locale locale)
          Creates the HTML JavaScript and stylesheet includes required by the calendar for the head of the page.
static java.lang.String calendarIncludes(java.util.Locale locale, java.lang.String style)
          Creates the HTML JavaScript and stylesheet includes required by the calendar for the head of the page.
static java.lang.String calendarInit(CmsMessages messages, java.lang.String inputFieldId, java.lang.String triggerButtonId, java.lang.String align, boolean singleClick, boolean weekNumbers, boolean mondayFirst, java.lang.String dateStatusFunc, boolean showTime)
          Generates the HTML to initialize the JavaScript calendar element on the end of a page.
static long getCalendarDate(CmsMessages messages, java.lang.String dateString, boolean useTime)
          Creates the time in milliseconds from the given parameter.
static java.lang.String getCalendarJavaDateFormat(java.lang.String dateFormat)
          Parses the JavaScript calendar date format to the java patterns of SimpleDateFormat.
static java.lang.String getCalendarLocalizedTime(java.util.Locale locale, CmsMessages messages, long timestamp)
          Returns the given timestamp as String formatted in a localized pattern.
 java.lang.String getDialogIncludes(CmsObject cms, I_CmsWidgetDialog widgetDialog)
          Generates the necessary JavaScript inclusion code for this widget.
 java.lang.String getDialogWidget(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param)
          Generates the widget HTML for the provided widget parameter.
 java.lang.String getWidgetStringValue(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param)
          Returns the I_CmsWidgetParameter.getStringValue(CmsObject) processed according to the output rules of this widget and the given widget dialog.
 I_CmsWidget newInstance()
          Creates a duplicate of this widget instance.
 void setEditorValue(CmsObject cms, java.util.Map formParameters, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param)
          Sets the value of in the given widget parameter by reading the "right" value from the offered map of parameters.
 
Methods inherited from class org.opencms.widgets.A_CmsWidget
equals, getConfiguration, getDialogHtmlEnd, getDialogInitCall, getDialogInitMethod, getHelpBubble, getHelpKey, getHelpText, getJsHelpMouseHandler, getJSIncludeFile, getLabelKey, hashCode, setConfiguration
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmsCalendarWidget

public CmsCalendarWidget()
Creates a new calendar widget.


CmsCalendarWidget

public CmsCalendarWidget(java.lang.String configuration)
Creates a new calendar widget with the given configuration.

Parameters:
configuration - the configuration to use
Method Detail

calendarIncludes

public static java.lang.String calendarIncludes(java.util.Locale locale)
Creates the HTML JavaScript and stylesheet includes required by the calendar for the head of the page.

The default "opencms" style is used.

Parameters:
locale - the locale to use for the calendar
Returns:
the necessary HTML code for the js and stylesheet includes
See Also:
calendarIncludes(Locale, String)

calendarIncludes

public static java.lang.String calendarIncludes(java.util.Locale locale,
                                                java.lang.String style)
Creates the HTML JavaScript and stylesheet includes required by the calendar for the head of the page.

Parameters:
locale - the locale to use for the calendar
style - the name of the used calendar style, e.g. "system", "blue"
Returns:
the necessary HTML code for the js and stylesheet includes

calendarInit

public static java.lang.String calendarInit(CmsMessages messages,
                                            java.lang.String inputFieldId,
                                            java.lang.String triggerButtonId,
                                            java.lang.String align,
                                            boolean singleClick,
                                            boolean weekNumbers,
                                            boolean mondayFirst,
                                            java.lang.String dateStatusFunc,
                                            boolean showTime)
Generates the HTML to initialize the JavaScript calendar element on the end of a page.

This method must be called at the end of a HTML page, e.g. before the closing <body> tag.

Parameters:
messages - the messages to use (for date and time formats)
inputFieldId - the ID of the input field where the date is pasted to
triggerButtonId - the ID of the button which triggers the calendar
align - initial position of the calendar popup element
singleClick - if true, a single click selects a date and closes the calendar, otherwise calendar is closed by doubleclick
weekNumbers - show the week numbers in the calendar or not
mondayFirst - show monday as first day of week
dateStatusFunc - name of the function which determines if/how a date should be disabled
showTime - true if the time selector should be shown, otherwise false
Returns:
the HTML code to initialize a calendar poup element

getCalendarDate

public static long getCalendarDate(CmsMessages messages,
                                   java.lang.String dateString,
                                   boolean useTime)
                            throws java.text.ParseException
Creates the time in milliseconds from the given parameter.

Parameters:
messages - the messages that contain the time format definitions
dateString - the String representation of the date
useTime - true if the time should be parsed, too, otherwise false
Returns:
the time in milliseconds
Throws:
java.text.ParseException - if something goes wrong

getCalendarJavaDateFormat

public static java.lang.String getCalendarJavaDateFormat(java.lang.String dateFormat)
Parses the JavaScript calendar date format to the java patterns of SimpleDateFormat.

Parameters:
dateFormat - the dateformat String of the JS calendar
Returns:
the parsed SimpleDateFormat pattern String

getCalendarLocalizedTime

public static java.lang.String getCalendarLocalizedTime(java.util.Locale locale,
                                                        CmsMessages messages,
                                                        long timestamp)
Returns the given timestamp as String formatted in a localized pattern.

Parameters:
locale - the locale for the time format
messages - the messages that contain the time format definitions
timestamp - the time to format
Returns:
the given timestamp as String formatted in a localized pattern

getDialogIncludes

public java.lang.String getDialogIncludes(CmsObject cms,
                                          I_CmsWidgetDialog widgetDialog)
Description copied from interface: I_CmsWidget
Generates the necessary JavaScript inclusion code for this widget.

Specified by:
getDialogIncludes in interface I_CmsWidget
Overrides:
getDialogIncludes in class A_CmsWidget
Parameters:
cms - the current users OpenCms context
widgetDialog - the dialog where the widget is used on
Returns:
the JavaScript inclusion code
See Also:
I_CmsWidget.getDialogIncludes(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog)

getDialogWidget

public java.lang.String getDialogWidget(CmsObject cms,
                                        I_CmsWidgetDialog widgetDialog,
                                        I_CmsWidgetParameter param)
Description copied from interface: I_CmsWidget
Generates the widget HTML for the provided widget parameter.

Parameters:
cms - an initialized instance of a CmsObject
widgetDialog - the dialog where the widget is used on
param - the widget parameter to generate the widget for
Returns:
the widget HTML for the provided widget parameter
See Also:
I_CmsWidget.getDialogWidget(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter)

getWidgetStringValue

public java.lang.String getWidgetStringValue(CmsObject cms,
                                             I_CmsWidgetDialog widgetDialog,
                                             I_CmsWidgetParameter param)
Description copied from interface: I_CmsWidget
Returns the I_CmsWidgetParameter.getStringValue(CmsObject) processed according to the output rules of this widget and the given widget dialog.

Specified by:
getWidgetStringValue in interface I_CmsWidget
Overrides:
getWidgetStringValue in class A_CmsWidget
Parameters:
cms - the current users OpenCms context
widgetDialog - the dialog where the widget is used on
param - the widget parameter to generate the widget for
Returns:
the I_CmsWidgetParameter.getStringValue(CmsObject) processed according to the output rules of this widget
See Also:
A_CmsWidget.getWidgetStringValue(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter)

newInstance

public I_CmsWidget newInstance()
Description copied from interface: I_CmsWidget
Creates a duplicate of this widget instance.

Returns:
a duplicate of this widget instance
See Also:
I_CmsWidget.newInstance()

setEditorValue

public void setEditorValue(CmsObject cms,
                           java.util.Map formParameters,
                           I_CmsWidgetDialog widgetDialog,
                           I_CmsWidgetParameter param)
Description copied from interface: I_CmsWidget
Sets the value of in the given widget parameter by reading the "right" value from the offered map of parameters.

Specified by:
setEditorValue in interface I_CmsWidget
Overrides:
setEditorValue in class A_CmsWidget
Parameters:
cms - the current users OpenCms context
formParameters - the map of parameters to get the value from
widgetDialog - the dialog where the widget is used on
param - the widget parameter to generate the widget for
See Also:
I_CmsWidget.setEditorValue(org.opencms.file.CmsObject, java.util.Map, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter)