use of com.intellij.tasks.LocalTask in project intellij-community by JetBrains.
the class SwitchTaskAction method createPopupActionGroup.
@NotNull
private static List<TaskListItem> createPopupActionGroup(@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);
}
});
final TaskManager manager = TaskManager.getManager(project);
LocalTask activeTask = manager.getActiveTask();
List<LocalTask> localTasks = manager.getLocalTasks();
Collections.sort(localTasks, TaskManagerImpl.TASK_UPDATE_COMPARATOR);
ArrayList<LocalTask> temp = new ArrayList<>();
for (final LocalTask task : localTasks) {
if (task == activeTask) {
continue;
}
if (manager.isLocallyClosed(task)) {
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 ? "Recently Closed Tasks" : null, true) {
@Override
void select() {
manager.activateTask(task, !shiftPressed.get());
}
});
}
}
return group;
}
use of com.intellij.tasks.LocalTask in project intellij-community by JetBrains.
the class TaskCellRenderer method getListCellRendererComponent.
public Component getListCellRendererComponent(JList list, Object value, int index, boolean sel, boolean focus) {
final JPanel panel = new JPanel(new BorderLayout());
panel.setBackground(UIUtil.getListBackground(sel));
panel.setForeground(UIUtil.getListForeground(sel));
if (value instanceof TaskPsiElement) {
final Task task = ((TaskPsiElement) value).getTask();
final SimpleColoredComponent c = new SimpleColoredComponent();
final TaskManager taskManager = TaskManager.getManager(myProject);
final boolean isLocalTask = taskManager.findTask(task.getId()) != null;
final boolean isClosed = task.isClosed() || (task instanceof LocalTask && taskManager.isLocallyClosed((LocalTask) task));
final Color bg = sel ? UIUtil.getListSelectionBackground() : isLocalTask ? UIUtil.getListBackground() : UIUtil.getDecoratedRowColor();
panel.setBackground(bg);
SimpleTextAttributes attr = getAttributes(sel, isClosed);
c.setIcon(isClosed ? IconLoader.getTransparentIcon(task.getIcon()) : task.getIcon());
SpeedSearchUtil.appendColoredFragmentForMatcher(task.getPresentableName(), c, attr, MatcherHolder.getAssociatedMatcher(list), bg, sel);
panel.add(c, BorderLayout.CENTER);
} else if ("...".equals(value)) {
final SimpleColoredComponent c = new SimpleColoredComponent();
c.setIcon(EmptyIcon.ICON_16);
c.append((String) value);
panel.add(c, BorderLayout.CENTER);
} else if (GotoTaskAction.CREATE_NEW_TASK_ACTION == value) {
final SimpleColoredComponent c = new SimpleColoredComponent();
c.setIcon(LayeredIcon.create(TasksIcons.Unknown, AllIcons.Actions.New));
c.append(GotoTaskAction.CREATE_NEW_TASK_ACTION.getActionText());
panel.add(c, BorderLayout.CENTER);
} else if (ChooseByNameBase.NON_PREFIX_SEPARATOR == value) {
return ChooseByNameBase.renderNonPrefixSeparatorComponent(UIUtil.getListBackground());
}
return panel;
}
use of com.intellij.tasks.LocalTask in project intellij-community by JetBrains.
the class AnalyzeTaskStacktraceAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
final LocalTask activeTask = getActiveTask(e);
final Project project = getProject(e);
assert activeTask != null;
assert project != null;
analyzeStacktrace(activeTask, project);
}
use of com.intellij.tasks.LocalTask in project intellij-community by JetBrains.
the class CreateChangelistAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
TaskManagerImpl manager = (TaskManagerImpl) getTaskManager(e);
assert manager != null;
LocalTask activeTask = manager.getActiveTask();
String name = Messages.showInputDialog(getProject(e), "Changelist name:", "Create Changelist", null, manager.getChangelistName(activeTask), null);
if (name != null) {
manager.createChangeList(activeTask, name);
}
}
Aggregations