Search in sources :

Example 1 with EventListenerList

use of org.eclipse.scout.rt.platform.util.EventListenerList in project scout.rt by eclipse.

the class VirtualDesktop method removePropertyChangeListener.

@Override
public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
    for (Iterator<EventListenerList> it = m_dataChangeListenerMap.values().iterator(); it.hasNext(); ) {
        EventListenerList list = it.next();
        list.remove(PropertyChangeListener.class, listener);
        if (list.getListenerCount(DataChangeListener.class) == 0) {
            it.remove();
        }
    }
}
Also used : EventListenerList(org.eclipse.scout.rt.platform.util.EventListenerList) DataChangeListener(org.eclipse.scout.rt.client.ui.DataChangeListener)

Example 2 with EventListenerList

use of org.eclipse.scout.rt.platform.util.EventListenerList in project scout.rt by eclipse.

the class VirtualDesktop method removePropertyChangeListener.

@Override
public void removePropertyChangeListener(PropertyChangeListener listener) {
    for (Iterator<EventListenerList> it = m_dataChangeListenerMap.values().iterator(); it.hasNext(); ) {
        EventListenerList list = it.next();
        list.remove(PropertyChangeListener.class, listener);
        if (list.getListenerCount(DataChangeListener.class) == 0) {
            it.remove();
        }
    }
}
Also used : EventListenerList(org.eclipse.scout.rt.platform.util.EventListenerList) DataChangeListener(org.eclipse.scout.rt.client.ui.DataChangeListener)

Example 3 with EventListenerList

use of org.eclipse.scout.rt.platform.util.EventListenerList 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)

Example 4 with EventListenerList

use of org.eclipse.scout.rt.platform.util.EventListenerList in project scout.rt by eclipse.

the class AbstractObservableNotificationHandler method notifyListenersOfAllSessions.

/**
 * Notify all listeners independent of the session in the current {@link RunContext}
 */
protected void notifyListenersOfAllSessions(final T notification) {
    // create copy of m_listeners (EventListenerList is thread-safe)
    Map<IClientSession, EventListenerList> listenerMap;
    synchronized (m_listeners) {
        listenerMap = new HashMap<>(m_listeners);
    }
    // schedule model job per session to handle notifications
    for (Entry<IClientSession, EventListenerList> entry : listenerMap.entrySet()) {
        final IClientSession session = entry.getKey();
        final EventListenerList list = entry.getValue();
        scheduleHandlingNotifications(notification, list, session);
    }
}
Also used : EventListenerList(org.eclipse.scout.rt.platform.util.EventListenerList) IClientSession(org.eclipse.scout.rt.client.IClientSession)

Example 5 with EventListenerList

use of org.eclipse.scout.rt.platform.util.EventListenerList in project scout.rt by eclipse.

the class AbstractObservableNotificationHandler method getListeners.

/**
 * Returns the {@link INotificationListener}s for a given session.
 *
 * @param session
 *          {@link IClientSession}
 * @return {@link INotificationListener}s
 */
public List<INotificationListener<T>> getListeners(IClientSession session) {
    synchronized (m_listeners) {
        List<INotificationListener<T>> res = new ArrayList<>();
        EventListenerList listeners = m_listeners.get(session);
        if (listeners != null) {
            @SuppressWarnings("unchecked") INotificationListener<T>[] notificationListeners = listeners.getListeners(INotificationListener.class);
            if (notificationListeners != null) {
                for (INotificationListener<T> notificationListener : notificationListeners) {
                    res.add(notificationListener);
                }
            }
        }
        return res;
    }
}
Also used : INotificationListener(org.eclipse.scout.rt.shared.notification.INotificationListener) ArrayList(java.util.ArrayList) EventListenerList(org.eclipse.scout.rt.platform.util.EventListenerList)

Aggregations

EventListenerList (org.eclipse.scout.rt.platform.util.EventListenerList)16 DataChangeListener (org.eclipse.scout.rt.client.ui.DataChangeListener)4 EventListener (java.util.EventListener)3 Test (org.junit.Test)3 PropertyChangeListener (java.beans.PropertyChangeListener)2 ArrayList (java.util.ArrayList)2 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)2 OrderedCollection (org.eclipse.scout.rt.platform.util.collection.OrderedCollection)2 INotificationListener (org.eclipse.scout.rt.shared.notification.INotificationListener)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 IOException (java.io.IOException)1 List (java.util.List)1 Map (java.util.Map)1 IClientSession (org.eclipse.scout.rt.client.IClientSession)1 IPlannerContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.IPlannerContextMenu)1 IValueFieldContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.IValueFieldContextMenu)1 PlannerContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.internal.PlannerContextMenu)1 DesktopListener (org.eclipse.scout.rt.client.ui.desktop.DesktopListener)1 PropertyMap (org.eclipse.scout.rt.platform.context.PropertyMap)1 ExceptionHandler (org.eclipse.scout.rt.platform.exception.ExceptionHandler)1