List<TaskListItem> (@NotNull final Project project, final Ref<Boolean> shiftPressed, final Component contextComponent) { List<TaskListItem> group = new ArrayList<>(); final AnAction action = ActionManager.getInstance().getAction(GotoTaskAction.ID); assert action instanceof GotoTaskAction; final GotoTaskAction gotoTaskAction = (GotoTaskAction)action; group.add(new TaskListItem(gotoTaskAction.getTemplatePresentation().getText(), gotoTaskAction.getTemplatePresentation().getIcon()) { @Override void select() { ActionManager.getInstance().tryToExecute(gotoTaskAction, ActionCommand.getInputEvent(GotoTaskAction.ID), contextComponent, ActionPlaces.UNKNOWN, false); } @Override public ShortcutSet getShortcut() { return gotoTaskAction.getShortcutSet(); } }); final TaskManager manager = TaskManager.getManager(project); LocalTask activeTask = manager.getActiveTask(); List<LocalTask> localTasks = manager.getLocalTasks(); localTasks.sort(TaskManagerImpl.TASK_UPDATE_COMPARATOR); ArrayList<LocalTask> temp = new ArrayList<>(); for (final LocalTask task : localTasks) { if (task == activeTask) { continue; } if (task.isClosed()) { temp.add(task); continue; } group.add(new TaskListItem(task, group.size() == 1 ? "" : null, false) { @Override void select() { manager.activateTask(task, !shiftPressed.get()); } }); } if (!temp.isEmpty()) { for (int i = 0, tempSize = temp.size(); i < Math.min(tempSize, 15); i++) { final LocalTask task = temp.get(i); group.add(new TaskListItem(task, i == 0 ? TaskBundle.message("separator.recently.closed.tasks") : null, true) { @Override void select() { manager.activateTask(task, !shiftPressed.get()); } }); } } return group; }