use of io.jmix.dashboardsui.dashboard.assistant.DashboardViewAssistant in project jmix by jmix-framework.
the class PersistentDashboardEdit method getAssistanceBeanNames.
public List<String> getAssistanceBeanNames() {
Map<String, DashboardViewAssistant> assistantBeanMap = applicationContext.getBeansOfType(DashboardViewAssistant.class);
BeanFactory bf = ((AbstractApplicationContext) applicationContext).getBeanFactory();
return assistantBeanMap.keySet().stream().filter(bf::isPrototype).collect(toList());
}
use of io.jmix.dashboardsui.dashboard.assistant.DashboardViewAssistant in project jmix by jmix-framework.
the class DashboardImpl method initAssistant.
private void initAssistant(Dashboard dashboard) {
String assistantBeanName = StringUtils.isEmpty(getAssistantBeanName()) ? this.dashboardModel.getAssistantBeanName() : getAssistantBeanName();
if (StringUtils.isNotEmpty(assistantBeanName)) {
DashboardViewAssistant assistantBean = applicationContext.getBean(assistantBeanName, DashboardViewAssistant.class);
BeanFactory bf = ((AbstractApplicationContext) applicationContext).getBeanFactory();
if (assistantBean != null && bf.isPrototype(assistantBeanName)) {
assistantBean.init(dashboard);
dashboardViewAssistant = assistantBean;
}
}
}
use of io.jmix.dashboardsui.dashboard.assistant.DashboardViewAssistant 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