use of org.eclipse.scout.rt.client.ui.action.menu.root.ICalendarContextMenu 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();
}
}
});
}
}
Aggregations