Search in sources :

Example 1 with AbstractCalendar

use of org.eclipse.scout.rt.client.ui.basic.calendar.AbstractCalendar in project scout.rt by eclipse.

the class AbstractCalendarField method initConfig.

@Override
@SuppressWarnings("unchecked")
protected void initConfig() {
    super.initConfig();
    List<ICalendar> contributedCalendars = m_contributionHolder.getContributionsByClass(ICalendar.class);
    m_calendar = (T) CollectionUtility.firstElement(contributedCalendars);
    if (m_calendar == null) {
        Class<? extends ICalendar> configuredCalendar = getConfiguredCalendar();
        m_calendar = (T) ConfigurationUtility.newInnerInstance(this, configuredCalendar);
    }
    if (m_calendar != null) {
        if (m_calendar instanceof AbstractCalendar) {
            ((AbstractCalendar) m_calendar).setContainerInternal(this);
        }
        // restore calendar settings
        ClientUIPreferences env = ClientUIPreferences.getInstance();
        m_calendar.setDisplayMode(env.getCalendarDisplayMode(ICalendarDisplayMode.MONTH));
        m_calendar.setDisplayCondensed(env.getCalendarDisplayCondensed(true));
        /*
       * add observer for: - selected date sync - persistence of calendar
       * settings
       */
        m_calendar.addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent e) {
                if (e.getPropertyName().equals(ICalendar.PROP_SELECTED_DATE)) {
                    syncCalendarToCalendarField();
                }
            }
        });
        syncCalendarToCalendarField();
    } else {
        LOG.warn("there is no inner class of type ICalendar in {}", getClass().getName());
    }
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ClientUIPreferences(org.eclipse.scout.rt.client.ui.ClientUIPreferences) ICalendar(org.eclipse.scout.rt.client.ui.basic.calendar.ICalendar) AbstractCalendar(org.eclipse.scout.rt.client.ui.basic.calendar.AbstractCalendar)

Aggregations

PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 ClientUIPreferences (org.eclipse.scout.rt.client.ui.ClientUIPreferences)1 AbstractCalendar (org.eclipse.scout.rt.client.ui.basic.calendar.AbstractCalendar)1 ICalendar (org.eclipse.scout.rt.client.ui.basic.calendar.ICalendar)1