ProcessToolContext processToolContextFromThread = ProcessToolContext.Util.getThreadProcessToolContext();
final ProcessToolBpmSession bpmSession = activityMainPane.getBpmSession();
final UserData user = bpmSession.getUser(processToolContextFromThread);
final ProcessInstanceFilterDAO processInstanceFilterDAO = processToolContextFromThread.getProcessInstanceFilterDAO();
List<ProcessInstanceFilter> filters = processInstanceFilterDAO.findAllByUserData(user);
for (final ProcessInstanceFilter filter : filters)
{
Button taskName = new Button(filter.getName());
List<BpmTask> tasks = bpmSession.findFilteredTasks(filter, processToolContextFromThread);
taskName.setCaption(taskName.getCaption() + " (" + tasks.size() + ")");
if(tasks.isEmpty())
taskName.addStyleName("v-disabled");
taskName.addStyleName(BaseTheme.BUTTON_LINK);
taskName.addListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
withErrorHandling(getApplication(), new Runnable() {
@Override
public void run() {
ProcessInstanceFilterDAO processInstanceFilterDAO =
ProcessToolContext.Util.getThreadProcessToolContext().getProcessInstanceFilterDAO();
final ProcessInstanceFilter fullFilter = processInstanceFilterDAO.fullLoadById(filter.getId());
activityMainPane.displayFilterPane(fullFilter);
}
});
}
});
filterList.addComponent(taskName);
filterList.setComponentAlignment(taskName, Alignment.MIDDLE_LEFT);
Button taskDelete = new Button(getMessage("activity.filters.delete"));
taskDelete.setStyleName(BaseTheme.BUTTON_LINK);
taskDelete.addListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
withErrorHandling(getApplication(), new Runnable() {
@Override
public void run() {
EventHandler okHandler = new EventHandler() {
@Override
public void onEvent() {
ProcessInstanceFilterDAO processInstanceFilterDAO = ProcessToolContext.Util
.getThreadProcessToolContext().getProcessInstanceFilterDAO();
processInstanceFilterDAO.deleteFilter(filter);
activityMainPane.getBpmSession().getEventBusManager().publish(new FilterChangedEvent());
}
};
VaadinUtility.displayConfirmationWindow(activityMainPane.getApplication(),
activityMainPane.getI18NSource(),