use of com.intellij.tasks.TaskManager in project intellij-community by JetBrains.
the class TaskConfigurable method apply.
@Override
public void apply() throws ConfigurationException {
boolean oldUpdateEnabled = getConfig().updateEnabled;
super.apply();
TaskManager manager = TaskManager.getManager(myProject);
if (getConfig().updateEnabled && !oldUpdateEnabled) {
manager.updateIssues(null);
}
TaskSettings.getInstance().ALWAYS_DISPLAY_COMBO = myAlwaysDisplayTaskCombo.isSelected();
int oldConnectionTimeout = TaskSettings.getInstance().CONNECTION_TIMEOUT;
Integer connectionTimeout = Integer.valueOf(myConnectionTimeout.getText());
TaskSettings.getInstance().CONNECTION_TIMEOUT = connectionTimeout;
if (manager instanceof TaskManagerImpl && connectionTimeout != oldConnectionTimeout) {
((TaskManagerImpl) manager).reconfigureRepositoryClients();
}
}
use of com.intellij.tasks.TaskManager in project intellij-community by JetBrains.
the class SwitchTaskAction method removeTask.
public static void removeTask(@NotNull final Project project, LocalTask task, TaskManager manager) {
if (task.isDefault()) {
Messages.showInfoMessage(project, "Default task cannot be removed", "Cannot Remove");
} else {
List<ChangeListInfo> infos = task.getChangeLists();
List<LocalChangeList> lists = ContainerUtil.mapNotNull(infos, (NullableFunction<ChangeListInfo, LocalChangeList>) changeListInfo -> {
LocalChangeList changeList = ChangeListManager.getInstance(project).getChangeList(changeListInfo.id);
return changeList != null && !changeList.isDefault() ? changeList : null;
});
boolean removeIt = true;
l: for (LocalChangeList list : lists) {
if (!list.getChanges().isEmpty()) {
int result = Messages.showYesNoCancelDialog(project, "Changelist associated with '" + task.getSummary() + "' is not empty.\n" + "Do you want to remove it and move the changes to the active changelist?", "Changelist Not Empty", Messages.getWarningIcon());
switch(result) {
case Messages.YES:
break l;
case Messages.NO:
removeIt = false;
break;
default:
return;
}
}
}
if (removeIt) {
for (LocalChangeList list : lists) {
ChangeListManager.getInstance(project).removeChangeList(list);
}
}
manager.removeTask(task);
}
}
use of com.intellij.tasks.TaskManager 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.TaskManager 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.TaskManager in project intellij-community by JetBrains.
the class AssociateWithTaskAction method setSelected.
@Override
public void setSelected(AnActionEvent e, boolean state) {
ChangeList[] lists = e.getData(VcsDataKeys.CHANGE_LISTS);
if (lists == null) {
return;
}
Project project = e.getData(CommonDataKeys.PROJECT);
TaskManager manager = TaskManager.getManager(project);
for (ChangeList list : lists) {
if (list instanceof LocalChangeList) {
manager.trackContext((LocalChangeList) list);
}
}
}
Aggregations