Search in sources :

Example 1 with IPlannerContextMenu

use of org.eclipse.scout.rt.client.ui.action.menu.root.IPlannerContextMenu in project scout.rt by eclipse.

the class AbstractPlanner method initConfig.

protected void initConfig() {
    m_listenerList = new EventListenerList();
    m_activityMapUIFacade = createUIFacade();
    // 
    setLabel(getConfiguredLabel());
    setAvailableDisplayModes(getConfiguredAvailableDisplayModes());
    setDisplayMode(getConfiguredDisplayMode());
    setDisplayModeOptions(new HashMap<Integer, DisplayModeOptions>());
    initDisplayModeOptions();
    setHeaderVisible(getConfiguredHeaderVisible());
    setSelectionMode(getConfiguredSelectionMode());
    setActivitySelectable(getConfiguredActivitySelectable());
    setMinimumActivityDuration(getConfiguredMinimumActivityDuration());
    // 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);
    }
    m_contributionHolder = new ContributionComposite(this);
    List<IMenu> contributedMenus = m_contributionHolder.getContributionsByClass(IMenu.class);
    menus.addAllOrdered(contributedMenus);
    try {
        injectMenusInternal(menus);
    } catch (Exception e) {
        LOG.error("error occured while dynamically contributing menus.", e);
    }
    new MoveActionNodesHandler<IMenu>(menus).moveModelObjects();
    IPlannerContextMenu contextMenu = new PlannerContextMenu(this, menus.getOrderedList());
    setContextMenu(contextMenu);
    // local property observer
    addPlannerListener(new PlannerAdapter() {

        @Override
        @SuppressWarnings("unchecked")
        public void plannerChanged(PlannerEvent e) {
            if (e.getType() == PlannerEvent.TYPE_RESOURCES_SELECTED) {
                List<Resource<RI>> resources = (List<Resource<RI>>) e.getResources();
                try {
                    interceptResourcesSelected(resources);
                } catch (Exception t) {
                    BEANS.get(ExceptionHandler.class).handle(t);
                }
            }
        }
    });
    addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        @SuppressWarnings("unchecked")
        public void propertyChange(PropertyChangeEvent e) {
            if (e.getPropertyName().equals(PROP_DISPLAY_MODE)) {
                try {
                    interceptDisplayModeChanged((int) e.getNewValue());
                } catch (Exception t) {
                    BEANS.get(ExceptionHandler.class).handle(t);
                }
            } else if (e.getPropertyName().equals(PROP_VIEW_RANGE)) {
                try {
                    interceptViewRangeChanged((Range) e.getNewValue());
                } catch (Exception t) {
                    BEANS.get(ExceptionHandler.class).handle(t);
                }
            } else if (e.getPropertyName().equals(PROP_SELECTION_RANGE)) {
                try {
                    interceptSelectionRangeChanged((Range) e.getNewValue());
                } catch (Exception t) {
                    BEANS.get(ExceptionHandler.class).handle(t);
                }
            } else if (e.getPropertyName().equals(PROP_SELECTED_ACTIVITY)) {
                Activity<RI, AI> cell = (Activity<RI, AI>) e.getNewValue();
                if (cell != null) {
                    try {
                        interceptActivitySelected(cell);
                    } catch (Exception t) {
                        BEANS.get(ExceptionHandler.class).handle(t);
                    }
                }
            }
        }
    });
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) ExceptionHandler(org.eclipse.scout.rt.platform.exception.ExceptionHandler) EventListenerList(org.eclipse.scout.rt.platform.util.EventListenerList) ArrayList(java.util.ArrayList) EventListenerList(org.eclipse.scout.rt.platform.util.EventListenerList) List(java.util.List) IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) PropertyChangeEvent(java.beans.PropertyChangeEvent) IPlannerContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.IPlannerContextMenu) ContributionComposite(org.eclipse.scout.rt.shared.extension.ContributionComposite) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) Range(org.eclipse.scout.rt.platform.util.Range) PlannerContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.internal.PlannerContextMenu) IPlannerContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.IPlannerContextMenu)

Aggregations

PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)1 IPlannerContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.IPlannerContextMenu)1 PlannerContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.internal.PlannerContextMenu)1 ExceptionHandler (org.eclipse.scout.rt.platform.exception.ExceptionHandler)1 EventListenerList (org.eclipse.scout.rt.platform.util.EventListenerList)1 Range (org.eclipse.scout.rt.platform.util.Range)1 OrderedCollection (org.eclipse.scout.rt.platform.util.collection.OrderedCollection)1 ContributionComposite (org.eclipse.scout.rt.shared.extension.ContributionComposite)1