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