Search in sources :

Example 1 with ICalendarItem

use of org.eclipse.scout.rt.shared.services.common.calendar.ICalendarItem in project scout.rt by eclipse.

the class AbstractCalendarItemProvider method getItems.

@Override
public Set<ICalendarItem> getItems(Date minDate, Date maxDate) {
    ensureItemsLoadedInternal(minDate, maxDate);
    Set<ICalendarItem> allItems = propertySupport.getPropertySet(PROP_ITEMS);
    if (CollectionUtility.hasElements(allItems)) {
        Set<ICalendarItem> list = new HashSet<ICalendarItem>(allItems.size());
        for (ICalendarItem item : allItems) {
            if (item.isIntersecting(minDate, maxDate)) {
                list.add(item);
            }
        }
        return list;
    }
    return CollectionUtility.hashSet();
}
Also used : ICalendarItem(org.eclipse.scout.rt.shared.services.common.calendar.ICalendarItem) HashSet(java.util.HashSet)

Example 2 with ICalendarItem

use of org.eclipse.scout.rt.shared.services.common.calendar.ICalendarItem in project scout.rt by eclipse.

the class AbstractCalendar method updateComponentsInternal.

private void updateComponentsInternal(List<ICalendarItemProvider> changedProviders) {
    Range<Date> d = getViewRange();
    if (d.getFrom() != null && d.getTo() != null) {
        for (ICalendarItemProvider p : changedProviders) {
            LinkedList<CalendarComponent> components = new LinkedList<CalendarComponent>();
            for (ICalendarItem item : p.getItems(d.getFrom(), d.getTo())) {
                components.add(new CalendarComponent(this, p, item));
            }
            m_componentsByProvider.put(p.getClass(), components);
        }
        // filter and resolve item conflicts
        Set<Class<? extends ICalendarItemProvider>> providerTypes = new HashSet<Class<? extends ICalendarItemProvider>>(changedProviders.size());
        for (ICalendarItemProvider provider : changedProviders) {
            providerTypes.add(provider.getClass());
        }
        interceptFilterCalendarItems(providerTypes, m_componentsByProvider);
        // complete list
        TreeMap<CompositeObject, CalendarComponent> sortMap = new TreeMap<CompositeObject, CalendarComponent>();
        int index = 0;
        for (Collection<CalendarComponent> c : m_componentsByProvider.values()) {
            for (CalendarComponent comp : c) {
                sortMap.put(new CompositeObject(comp.getFromDate(), index++), comp);
            }
        }
        propertySupport.setPropertySet(PROP_COMPONENTS, CollectionUtility.hashSet(sortMap.values()));
        // validate selection
        setSelectedComponent(getSelectedComponent());
    }
}
Also used : ICalendarItem(org.eclipse.scout.rt.shared.services.common.calendar.ICalendarItem) ICalendarItemProvider(org.eclipse.scout.rt.client.ui.basic.calendar.provider.ICalendarItemProvider) TreeMap(java.util.TreeMap) Date(java.util.Date) LinkedList(java.util.LinkedList) CompositeObject(org.eclipse.scout.rt.platform.util.CompositeObject) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)2 ICalendarItem (org.eclipse.scout.rt.shared.services.common.calendar.ICalendarItem)2 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1 TreeMap (java.util.TreeMap)1 ICalendarItemProvider (org.eclipse.scout.rt.client.ui.basic.calendar.provider.ICalendarItemProvider)1 CompositeObject (org.eclipse.scout.rt.platform.util.CompositeObject)1