Search in sources :

Example 6 with TaskManager

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();
    }
}
Also used : TaskManager(com.intellij.tasks.TaskManager) TaskManagerImpl(com.intellij.tasks.impl.TaskManagerImpl)

Example 7 with TaskManager

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);
    }
}
Also used : TaskSettings(com.intellij.tasks.config.TaskSettings) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) TaskManagerImpl(com.intellij.tasks.impl.TaskManagerImpl) ContainerUtil(com.intellij.util.containers.ContainerUtil) ArrayList(java.util.ArrayList) ActionCommand(com.intellij.openapi.ui.playback.commands.ActionCommand) Comparing(com.intellij.openapi.util.Comparing) Disposer(com.intellij.openapi.util.Disposer) Project(com.intellij.openapi.project.Project) Messages(com.intellij.openapi.ui.Messages) LocalTask(com.intellij.tasks.LocalTask) ComboBoxAction(com.intellij.openapi.actionSystem.ex.ComboBoxAction) DumbAware(com.intellij.openapi.project.DumbAware) DataManager(com.intellij.ide.DataManager) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) StringUtil(com.intellij.openapi.util.text.StringUtil) SimpleActionGroup(com.intellij.tools.SimpleActionGroup) NullableFunction(com.intellij.util.NullableFunction) com.intellij.openapi.ui.popup(com.intellij.openapi.ui.popup) KeyEvent(java.awt.event.KeyEvent) ActionEvent(java.awt.event.ActionEvent) Disposable(com.intellij.openapi.Disposable) java.awt(java.awt) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) LocalTaskImpl(com.intellij.tasks.impl.LocalTaskImpl) ChangeListInfo(com.intellij.tasks.ChangeListInfo) NotNull(org.jetbrains.annotations.NotNull) Ref(com.intellij.openapi.util.Ref) ListPopupImpl(com.intellij.ui.popup.list.ListPopupImpl) Collections(java.util.Collections) TaskManager(com.intellij.tasks.TaskManager) javax.swing(javax.swing) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ChangeListInfo(com.intellij.tasks.ChangeListInfo)

Example 8 with TaskManager

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;
}
Also used : TaskManager(com.intellij.tasks.TaskManager) ArrayList(java.util.ArrayList) LocalTask(com.intellij.tasks.LocalTask) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with TaskManager

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;
}
Also used : Task(com.intellij.tasks.Task) LocalTask(com.intellij.tasks.LocalTask) TaskManager(com.intellij.tasks.TaskManager) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) LocalTask(com.intellij.tasks.LocalTask) TaskPsiElement(com.intellij.tasks.doc.TaskPsiElement) SimpleColoredComponent(com.intellij.ui.SimpleColoredComponent)

Example 10 with TaskManager

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);
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) TaskManager(com.intellij.tasks.TaskManager) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ChangeList(com.intellij.openapi.vcs.changes.ChangeList) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList)

Aggregations

TaskManager (com.intellij.tasks.TaskManager)12 LocalTask (com.intellij.tasks.LocalTask)7 Project (com.intellij.openapi.project.Project)5 LocalChangeList (com.intellij.openapi.vcs.changes.LocalChangeList)3 Task (com.intellij.tasks.Task)3 ActionEvent (java.awt.event.ActionEvent)3 ChangeList (com.intellij.openapi.vcs.changes.ChangeList)2 TaskPsiElement (com.intellij.tasks.doc.TaskPsiElement)2 LocalTaskImpl (com.intellij.tasks.impl.LocalTaskImpl)2 TaskManagerImpl (com.intellij.tasks.impl.TaskManagerImpl)2 SimpleActionGroup (com.intellij.tools.SimpleActionGroup)2 ListPopupImpl (com.intellij.ui.popup.list.ListPopupImpl)2 NullableFunction (com.intellij.util.NullableFunction)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 NotNull (org.jetbrains.annotations.NotNull)2 DataManager (com.intellij.ide.DataManager)1 Disposable (com.intellij.openapi.Disposable)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 Presentation (com.intellij.openapi.actionSystem.Presentation)1