use of io.jmix.dashboardsui.event.DashboardEvent in project jmix by jmix-framework.
the class DashboardImpl method dashboardEventListener.
@SuppressWarnings("unchecked")
@EventListener
public void dashboardEventListener(DashboardEvent dashboardEvent) throws InvocationTargetException, IllegalAccessException {
refreshWidgets(dashboardEvent);
if (dashboardViewAssistant == null) {
return;
}
Class eventClass = dashboardEvent.getClass();
Method[] methods = ReflectionUtils.getUniqueDeclaredMethods(dashboardViewAssistant.getClass());
List<Method> eventListenerMethods = Arrays.stream(methods).filter(m -> m.getAnnotation(EventListener.class) != null).filter(m -> m.getParameterCount() == 1).collect(Collectors.toList());
for (Method method : eventListenerMethods) {
java.lang.reflect.Parameter[] parameters = method.getParameters();
java.lang.reflect.Parameter parameter = parameters[0];
Class methodEventTypeArg = parameter.getType();
if (methodEventTypeArg.isAssignableFrom(eventClass)) {
method.invoke(dashboardViewAssistant, dashboardEvent);
}
}
}
Aggregations