/** * Creates the list of widgets for this dialog.<p> */ @Override protected void defineWidgets() { setKeyPrefix(KEY_PREFIX); // default value is 30 minutes ago setTime("" + (System.currentTimeMillis() - (30 * 60 * 1000L))); // widgets to display addWidget(new CmsWidgetDialogParameter(this, "time", PAGES[0], new CmsCalendarWidget())); }
/** * Creates the HTML JavaScript and stylesheet includes required by the calendar for the head of the page.<p> * * The default <code>"opencms"</code> style is used.<p> * * @param locale the locale to use for the calendar * * @return the necessary HTML code for the js and stylesheet includes * * @see #calendarIncludes(Locale, String) */ public static String calendarIncludes(Locale locale) { return calendarIncludes(locale, "opencms"); }
boolean showTime) { return CmsCalendarWidget.calendarInit( getMessages(), inputFieldId,
/** * @see org.opencms.widgets.I_CmsWidget#newInstance() */ public I_CmsWidget newInstance() { return new CmsCalendarWidget(getConfiguration()); }
/** * Returns the current date and time as String formatted in localized pattern.<p> * * @return the current date and time as String formatted in localized pattern */ public String getCurrentDateTime() { // get the current date & time return CmsCalendarWidget.getCalendarLocalizedTime(getLocale(), getMessages(), System.currentTimeMillis()); }
/** * Sets the "user timewparp" setting.<p> * * To delete a timewarp setting for the current user, provide <code>"-"</code> as value.<p> * * @param value a String representation of an date in the formate as required by * {@link CmsCalendarWidget#getCalendarDate(org.opencms.i18n.CmsMessages, String, boolean)} */ public void setParamTabWpTimeWarp(String value) { long datetimestamp = CmsContextInfo.CURRENT_TIME; // check for "delete value" if (CmsStringUtil.isNotEmpty(value) && !"-".equals(value)) { try { datetimestamp = CmsCalendarWidget.getCalendarDate(getMessages(), value, true); } catch (Exception e) { // reset timewarp setting in case of exception } } m_userSettings.setTimeWarp(datetimestamp); }
String dateTimeValue = getWidgetStringValue(cms, widgetDialog, param); result.append(dateTimeValue); String id = param.getId(); calendarInit(widgetDialog.getMessages(), id, id + ".calendar", "cR", false, false, true, null, true));
/** * Returns the given timestamp as String formatted in a localized pattern.<p> * * @param locale the locale for the time format * @param messages the messages that contain the time format definitions * @param timestamp the time to format * * @return the given timestamp as String formatted in a localized pattern */ public static String getCalendarLocalizedTime(Locale locale, CmsMessages messages, long timestamp) { // get the current date & time TimeZone zone = TimeZone.getDefault(); GregorianCalendar cal = new GregorianCalendar(zone, locale); cal.setTimeInMillis(timestamp); // format it nicely according to the localized pattern DateFormat df = new SimpleDateFormat( CmsCalendarWidget.getCalendarJavaDateFormat(messages.key(org.opencms.workplace.Messages.GUI_CALENDAR_DATE_FORMAT_0) + " " + messages.key(org.opencms.workplace.Messages.GUI_CALENDAR_TIME_FORMAT_0))); return df.format(cal.getTime()); }
/** * @see org.opencms.widgets.I_CmsADEWidget#getConfiguration(org.opencms.file.CmsObject, org.opencms.xml.types.A_CmsXmlContentValue, org.opencms.i18n.CmsMessages, org.opencms.file.CmsResource, java.util.Locale) */ public String getConfiguration( CmsObject cms, A_CmsXmlContentValue schemaType, CmsMessages messages, CmsResource resource, Locale contentLocale) { return getConfiguration(); }
/** * @see org.opencms.widgets.I_CmsWidget#newInstance() */ public I_CmsWidget newInstance() { return new CmsCalendarWidget(getConfiguration()); }
/** * Returns the current date and time as String formatted in localized pattern.<p> * * @return the current date and time as String formatted in localized pattern */ public String getCurrentDateTime() { // get the current date & time return CmsCalendarWidget.getCalendarLocalizedTime(getLocale(), getMessages(), System.currentTimeMillis()); }
/** * Sets the "user timewparp" setting.<p> * * To delete a timewarp setting for the current user, provide <code>"-"</code> as value.<p> * * @param value a String representation of an date in the formate as required by * {@link CmsCalendarWidget#getCalendarDate(org.opencms.i18n.CmsMessages, String, boolean)} */ public void setParamTabWpTimeWarp(String value) { long datetimestamp = CmsContextInfo.CURRENT_TIME; // check for "delete value" if (CmsStringUtil.isNotEmpty(value) && !"-".equals(value)) { try { datetimestamp = CmsCalendarWidget.getCalendarDate(getMessages(), value, true); } catch (Exception e) { // reset timewarp setting in case of exception } } m_userSettings.setTimeWarp(datetimestamp); }
String dateTimeValue = getWidgetStringValue(cms, widgetDialog, param); result.append(dateTimeValue); String id = param.getId(); result.append("</td></tr></table>"); result.append(calendarInit( widgetDialog.getMessages(), id,
/** * Returns the given timestamp as String formatted in a localized pattern.<p> * * @param locale the locale for the time format * @param messages the messages that contain the time format definitions * @param timestamp the time to format * * @return the given timestamp as String formatted in a localized pattern */ public static String getCalendarLocalizedTime(Locale locale, CmsMessages messages, long timestamp) { // get the current date & time TimeZone zone = TimeZone.getDefault(); GregorianCalendar cal = new GregorianCalendar(zone, locale); cal.setTimeInMillis(timestamp); // format it nicely according to the localized pattern DateFormat df = new SimpleDateFormat( CmsCalendarWidget.getCalendarJavaDateFormat( messages.key(org.opencms.workplace.Messages.GUI_CALENDAR_DATE_FORMAT_0) + " " + messages.key(org.opencms.workplace.Messages.GUI_CALENDAR_TIME_FORMAT_0))); return df.format(cal.getTime()); }
/** * @see org.opencms.workplace.CmsWidgetDialog#defineWidgets() */ @Override protected void defineWidgets() { initParams(); addWidget(new CmsWidgetDialogParameter( this, "settings.userSettings.workplaceSearchIndexName", PAGES[0], new CmsDisplayWidget())); addWidget(new CmsWidgetDialogParameter(m_search, "query", PAGES[0], new CmsInputWidget())); addWidget(new CmsWidgetDialogParameter(m_search, "sortOrder", PAGES[0], new CmsSelectWidget(getSortNamesConf()))); addWidget(new CmsWidgetDialogParameter(m_search, "restrictSearch", PAGES[0], new CmsCheckboxWidget())); addWidget(new CmsWidgetDialogParameter(m_search, "minDateCreated", PAGES[0], new CmsCalendarWidget())); addWidget(new CmsWidgetDialogParameter(m_search, "maxDateCreated", PAGES[0], new CmsCalendarWidget())); addWidget(new CmsWidgetDialogParameter(m_search, "minDateLastModified", PAGES[0], new CmsCalendarWidget())); addWidget(new CmsWidgetDialogParameter(m_search, "maxDateLastModified", PAGES[0], new CmsCalendarWidget())); addWidget(new CmsWidgetDialogParameter(m_search, "fields", PAGES[0], new CmsMultiSelectWidget( getFieldList(), true))); }
/** * Returns the current date and time as String formatted in localized pattern.<p> * * @return the current date and time as String formatted in localized pattern */ public String getCurrentDateTime() { // get the current date & time return CmsCalendarWidget.getCalendarLocalizedTime(getLocale(), getMessages(), System.currentTimeMillis()); }
dateTime = getCalendarDate(widgetDialog.getMessages(), dateTimeValue, true); } catch (ParseException e) {
/** * Creates the HTML JavaScript and stylesheet includes required by the calendar for the head of the page.<p> * * The default <code>"opencms"</code> style is used.<p> * * @param locale the locale to use for the calendar * * @return the necessary HTML code for the js and stylesheet includes * * @see #calendarIncludes(Locale, String) */ public static String calendarIncludes(Locale locale) { return calendarIncludes(locale, "opencms"); }
boolean showTime) { return CmsCalendarWidget.calendarInit( getMessages(), inputFieldId,
/** * Creates the time in milliseconds from the given parameter.<p> * * @param messages the messages that contain the time format definitions * @param dateString the String representation of the date * @param useTime true if the time should be parsed, too, otherwise false * * @return the time in milliseconds * * @throws ParseException if something goes wrong */ public static long getCalendarDate(CmsMessages messages, String dateString, boolean useTime) throws ParseException { long dateLong = 0; // substitute some chars because calendar syntax != DateFormat syntax String dateFormat = messages.key(org.opencms.workplace.Messages.GUI_CALENDAR_DATE_FORMAT_0); if (useTime) { dateFormat += " " + messages.key(org.opencms.workplace.Messages.GUI_CALENDAR_TIME_FORMAT_0); } dateFormat = CmsCalendarWidget.getCalendarJavaDateFormat(dateFormat); SimpleDateFormat df = new SimpleDateFormat(dateFormat); dateLong = df.parse(dateString).getTime(); return dateLong; }