void () { // make sure that the default task is exist LocalTaskImpl defaultTask = findTask(LocalTaskImpl.DEFAULT_TASK_ID); if (defaultTask == null) { defaultTask = createDefaultTask(); addTask(defaultTask); } // search for active task LocalTaskImpl activeTask = null; final List<LocalTaskImpl> tasks = ContainerUtil.map(ContainerUtil.sorted(getLocalTasks(), TASK_UPDATE_COMPARATOR), task -> (LocalTaskImpl)task); for (LocalTaskImpl task : tasks) { if (activeTask == null) { if (task.isActive()) { activeTask = task; } } else { task.setActive(false); } } if (activeTask == null) { activeTask = defaultTask; } myActiveTask = activeTask; doActivate(myActiveTask, false); myDispatcher.getMulticaster().taskActivated(myActiveTask); }