Search in sources :

Example 1 with CustomTaskState

use of com.intellij.tasks.CustomTaskState in project intellij-community by JetBrains.

the class CloseTaskAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    Project project = e.getProject();
    assert project != null;
    TaskManagerImpl taskManager = (TaskManagerImpl) TaskManager.getManager(project);
    LocalTask task = taskManager.getActiveTask();
    CloseTaskDialog dialog = new CloseTaskDialog(project, task);
    if (dialog.showAndGet()) {
        final CustomTaskState taskState = dialog.getCloseIssueState();
        if (taskState != null) {
            try {
                TaskRepository repository = task.getRepository();
                assert repository != null;
                repository.setTaskState(task, taskState);
                repository.setPreferredCloseTaskState(taskState);
            } catch (Exception e1) {
                Messages.showErrorDialog(project, e1.getMessage(), "Cannot Set State For Issue");
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) TaskRepository(com.intellij.tasks.TaskRepository) TaskManagerImpl(com.intellij.tasks.impl.TaskManagerImpl) LocalTask(com.intellij.tasks.LocalTask) CustomTaskState(com.intellij.tasks.CustomTaskState)

Example 2 with CustomTaskState

use of com.intellij.tasks.CustomTaskState in project intellij-community by JetBrains.

the class BugzillaIntegrationTest method testCustomTaskStates.

public void testCustomTaskStates() throws Exception {
    final Task task = myRepository.findTask(BUG_FOR_CUSTOM_STATES_ID);
    assertNotNull(task);
    try {
        assertEquals(TaskState.OPEN, task.getState());
        Set<CustomTaskState> states = myRepository.getAvailableTaskStates(task);
        List<String> stateNames = ContainerUtil.map(states, state -> state.getPresentableName());
        assertContainsElements(stateNames, "IN_PROGRESS");
        assertDoesntContain(stateNames, "CONFIRMED");
        // Confirmed -> In Progress
        setStateAndCheckResult(task, IN_PROGRESS_STATE, TaskState.IN_PROGRESS);
        states = myRepository.getAvailableTaskStates(task);
        stateNames = ContainerUtil.map(states, state -> state.getPresentableName());
        assertContainsElements(stateNames, "CONFIRMED");
        assertDoesntContain(stateNames, "IN_PROGRESS");
    } finally {
        // In Progress -> Confirmed (always attempt to return to original state)
        setStateAndCheckResult(task, CONFIRMED_STATE, TaskState.OPEN);
    }
}
Also used : TaskState(com.intellij.tasks.TaskState) List(java.util.List) TaskManagerTestCase(com.intellij.tasks.TaskManagerTestCase) BugzillaRepositoryType(com.intellij.tasks.bugzilla.BugzillaRepositoryType) BugzillaRepository(com.intellij.tasks.bugzilla.BugzillaRepository) Function(com.intellij.util.Function) Set(java.util.Set) ContainerUtil(com.intellij.util.containers.ContainerUtil) NotNull(org.jetbrains.annotations.NotNull) CustomTaskState(com.intellij.tasks.CustomTaskState) Task(com.intellij.tasks.Task) Task(com.intellij.tasks.Task) CustomTaskState(com.intellij.tasks.CustomTaskState)

Example 3 with CustomTaskState

use of com.intellij.tasks.CustomTaskState in project intellij-community by JetBrains.

the class TrelloRepository method getAvailableTaskStates.

@NotNull
@Override
public Set<CustomTaskState> getAvailableTaskStates(@NotNull Task task) throws Exception {
    final TrelloCard card = fetchCardById(task.getId());
    if (card != null) {
        final List<TrelloList> lists = fetchBoardLists(card.getIdBoard());
        final Set<CustomTaskState> result = new HashSet<>();
        for (TrelloList list : lists) {
            if (!list.getId().equals(card.getIdList())) {
                result.add(new CustomTaskState(list.getId(), list.getName()));
            }
        }
        return result;
    }
    return Collections.emptySet();
}
Also used : TrelloList(com.intellij.tasks.trello.model.TrelloList) TrelloCard(com.intellij.tasks.trello.model.TrelloCard) HashSet(java.util.HashSet) CustomTaskState(com.intellij.tasks.CustomTaskState) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with CustomTaskState

use of com.intellij.tasks.CustomTaskState in project intellij-community by JetBrains.

the class TaskStateCombo method scheduleUpdateOnce.

/**
   * One-shot method. Update combo box items only once.
   *
   * @return whether update was actually scheduled
   */
public boolean scheduleUpdateOnce() {
    if (myProject != null && stateUpdatesSupportedFor(myTask) && myKindCombo.getComboBox().getItemCount() == 0) {
        final JComboBox comboBox = myKindCombo.getComboBox();
        final TaskRepository repository = myTask.getRepository();
        assert repository != null;
        new ComboBoxUpdater<CustomStateTrinityAdapter>(myProject, "Fetching available task states...", comboBox) {

            @NotNull
            @Override
            protected List<CustomStateTrinityAdapter> fetch(@NotNull ProgressIndicator indicator) throws Exception {
                return CustomStateTrinityAdapter.wrapList(repository.getAvailableTaskStates(myTask));
            }

            @Nullable
            @Override
            public CustomStateTrinityAdapter getSelectedItem() {
                final CustomTaskState state = getPreferredState(repository, CustomStateTrinityAdapter.unwrapList(myResult));
                return state != null ? new CustomStateTrinityAdapter(state) : null;
            }
        }.queue();
        return true;
    }
    return false;
}
Also used : ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) TaskRepository(com.intellij.tasks.TaskRepository) List(java.util.List) NotNull(org.jetbrains.annotations.NotNull) Nullable(org.jetbrains.annotations.Nullable) CustomTaskState(com.intellij.tasks.CustomTaskState)

Example 5 with CustomTaskState

use of com.intellij.tasks.CustomTaskState in project intellij-community by JetBrains.

the class JiraRestApi20Alpha1 method getAvailableTaskStates.

@NotNull
@Override
public Set<CustomTaskState> getAvailableTaskStates(@NotNull Task task) throws Exception {
    // REST API of JIRA 4.x for retrieving possible transitions is very limited: we can't fetch possible resolutions and
    // names of transition destinations. So we have no other options than to hardcode them.
    final HashSet<CustomTaskState> result = new HashSet<>();
    result.add(new CustomTaskState("4", "In Progress"));
    result.add(new CustomTaskState("5", "Resolved (Fixed)"));
    result.add(new CustomTaskState("3", "Reopened"));
    return result;
}
Also used : HashSet(java.util.HashSet) CustomTaskState(com.intellij.tasks.CustomTaskState) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

CustomTaskState (com.intellij.tasks.CustomTaskState)7 NotNull (org.jetbrains.annotations.NotNull)4 Task (com.intellij.tasks.Task)2 TaskRepository (com.intellij.tasks.TaskRepository)2 HashSet (java.util.HashSet)2 List (java.util.List)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Project (com.intellij.openapi.project.Project)1 LocalTask (com.intellij.tasks.LocalTask)1 TaskManagerTestCase (com.intellij.tasks.TaskManagerTestCase)1 TaskState (com.intellij.tasks.TaskState)1 BugzillaRepository (com.intellij.tasks.bugzilla.BugzillaRepository)1 BugzillaRepositoryType (com.intellij.tasks.bugzilla.BugzillaRepositoryType)1 TaskManagerImpl (com.intellij.tasks.impl.TaskManagerImpl)1 TrelloTask (com.intellij.tasks.trello.TrelloTask)1 TrelloCard (com.intellij.tasks.trello.model.TrelloCard)1 TrelloList (com.intellij.tasks.trello.model.TrelloList)1 Function (com.intellij.util.Function)1 ContainerUtil (com.intellij.util.containers.ContainerUtil)1 Set (java.util.Set)1