Search in sources :

Example 1 with ICalendarItemProvider

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

the class AbstractCalendar method setSelectedComponent.

@Override
public void setSelectedComponent(CalendarComponent comp) {
    comp = resolveComponent(comp);
    // update temporarily added menus of current content provider
    ICalendarItemProvider provider = null;
    if (comp != null) {
        provider = comp.getProvider();
    }
    updateContentProviderMenus(provider);
    propertySupport.setProperty(PROP_SELECTED_COMPONENT, comp);
}
Also used : ICalendarItemProvider(org.eclipse.scout.rt.client.ui.basic.calendar.provider.ICalendarItemProvider)

Example 2 with ICalendarItemProvider

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

the class AbstractCalendar method updateLoadInProgressInternal.

private void updateLoadInProgressInternal() {
    boolean b = false;
    for (ICalendarItemProvider p : m_providers) {
        if (p.isLoadInProgress()) {
            b = true;
            break;
        }
    }
    setLoadInProgress(b);
}
Also used : ICalendarItemProvider(org.eclipse.scout.rt.client.ui.basic.calendar.provider.ICalendarItemProvider)

Example 3 with ICalendarItemProvider

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

the class AbstractCalendar method initConfig.

protected void initConfig() {
    m_uiFacade = BEANS.get(ModelContextProxy.class).newProxy(new P_UIFacade(), ModelContext.copyCurrent());
    m_contributionHolder = new ContributionComposite(this);
    setTitle(getConfiguredTitle());
    setSelectedDate(new Date());
    setStartHour(getConfiguredStartHour());
    setEndHour(getConfiguredEndHour());
    setUseOverflowCells(getConfiguredUseOverflowCells());
    setShowDisplayModeSelection(getConfiguredShowDisplayModeSelection());
    setMarkNoonHour(getConfiguredMarkNoonHour());
    setMarkOutOfMonthDays(getConfiguredMarkOutOfMonthDays());
    // menus
    List<Class<? extends IMenu>> declaredMenus = getDeclaredMenus();
    OrderedCollection<IMenu> menus = new OrderedCollection<IMenu>();
    for (Class<? extends IMenu> menuClazz : declaredMenus) {
        IMenu menu = ConfigurationUtility.newInnerInstance(this, menuClazz);
        menus.addOrdered(menu);
    }
    List<IMenu> contributedMenus = m_contributionHolder.getContributionsByClass(IMenu.class);
    menus.addAllOrdered(contributedMenus);
    // producers
    List<Class<? extends ICalendarItemProvider>> configuredProducers = getConfiguredProducers();
    List<ICalendarItemProvider> contributedProducers = m_contributionHolder.getContributionsByClass(ICalendarItemProvider.class);
    List<ICalendarItemProvider> producerList = new ArrayList<ICalendarItemProvider>(configuredProducers.size() + contributedProducers.size());
    for (Class<? extends ICalendarItemProvider> itemProviderClazz : configuredProducers) {
        try {
            ICalendarItemProvider provider = ConfigurationUtility.newInnerInstance(this, itemProviderClazz);
            producerList.add(provider);
            // add empty space menus to the context menu
            menus.addAllOrdered(ActionUtility.getActions(provider.getMenus(), ActionUtility.createMenuFilterMenuTypes(CollectionUtility.hashSet(CalendarMenuType.EmptySpace), false)));
        } catch (Exception e) {
            BEANS.get(ExceptionHandler.class).handle(new ProcessingException("error creating instance of class '" + itemProviderClazz.getName() + "'.", e));
        }
    }
    producerList.addAll(contributedProducers);
    m_providers = producerList;
    try {
        injectMenusInternal(menus);
    } catch (Exception e) {
        LOG.error("error occured while dynamically contributing menus.", e);
    }
    new MoveActionNodesHandler<IMenu>(menus).moveModelObjects();
    ICalendarContextMenu contextMenu = new CalendarContextMenu(this, menus.getOrderedList());
    setContextMenu(contextMenu);
    // attach change listener for item updates
    for (final ICalendarItemProvider p : m_providers) {
        p.addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent e) {
                if (e.getPropertyName().equals(ICalendarItemProvider.PROP_ITEMS)) {
                    List<ICalendarItemProvider> modified = new ArrayList<ICalendarItemProvider>(1);
                    modified.add(p);
                    updateComponentsInternal(modified);
                } else if (e.getPropertyName().equals(ICalendarItemProvider.PROP_LOAD_IN_PROGRESS)) {
                    updateLoadInProgressInternal();
                }
            }
        });
    }
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) ArrayList(java.util.ArrayList) EventListenerList(org.eclipse.scout.rt.platform.util.EventListenerList) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) PropertyChangeEvent(java.beans.PropertyChangeEvent) ContributionComposite(org.eclipse.scout.rt.shared.extension.ContributionComposite) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) ICalendarItemProvider(org.eclipse.scout.rt.client.ui.basic.calendar.provider.ICalendarItemProvider) ICalendarContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.ICalendarContextMenu) Date(java.util.Date) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) CalendarContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.internal.CalendarContextMenu) ICalendarContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.ICalendarContextMenu)

Example 4 with ICalendarItemProvider

use of org.eclipse.scout.rt.client.ui.basic.calendar.provider.ICalendarItemProvider 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

ICalendarItemProvider (org.eclipse.scout.rt.client.ui.basic.calendar.provider.ICalendarItemProvider)4 Date (java.util.Date)2 LinkedList (java.util.LinkedList)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 TreeMap (java.util.TreeMap)1 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)1 ICalendarContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.ICalendarContextMenu)1 CalendarContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.internal.CalendarContextMenu)1 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)1 CompositeObject (org.eclipse.scout.rt.platform.util.CompositeObject)1 EventListenerList (org.eclipse.scout.rt.platform.util.EventListenerList)1 OrderedCollection (org.eclipse.scout.rt.platform.util.collection.OrderedCollection)1 ContributionComposite (org.eclipse.scout.rt.shared.extension.ContributionComposite)1 ICalendarItem (org.eclipse.scout.rt.shared.services.common.calendar.ICalendarItem)1