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);
}
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);
}
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();
}
}
});
}
}
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());
}
}
Aggregations