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");
}
}
}
}
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);
}
}
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();
}
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;
}
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;
}
Aggregations