Search in sources :

Example 1 with TaskRepository

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

the class TaskCheckinHandlerFactory method findTaskInRepositories.

@Nullable
private static Task findTaskInRepositories(String message, TaskManager manager) {
    TaskRepository[] repositories = manager.getAllRepositories();
    for (TaskRepository repository : repositories) {
        String id = repository.extractId(message);
        if (id == null)
            continue;
        LocalTask localTask = manager.findTask(id);
        if (localTask != null)
            return localTask;
        try {
            Task task = repository.findTask(id);
            if (task != null) {
                return task;
            }
        } catch (Exception ignore) {
        }
    }
    return null;
}
Also used : Task(com.intellij.tasks.Task) LocalTask(com.intellij.tasks.LocalTask) TaskRepository(com.intellij.tasks.TaskRepository) LocalTask(com.intellij.tasks.LocalTask) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with TaskRepository

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

the class TaskProjectConfiguration method getState.

public TaskProjectConfiguration getState() {
    LinkedHashSet<SharedServer> set = new LinkedHashSet<>(this.servers);
    for (TaskRepository repository : myManager.getAllRepositories()) {
        if (repository.isShared()) {
            SharedServer server = new SharedServer();
            server.type = repository.getRepositoryType().getName();
            server.url = repository.getUrl();
            set.add(server);
        }
    }
    servers.clear();
    servers.addAll(set);
    return this;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) TaskRepository(com.intellij.tasks.TaskRepository)

Example 3 with TaskRepository

use of com.intellij.tasks.TaskRepository 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 4 with TaskRepository

use of com.intellij.tasks.TaskRepository 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 TaskRepository

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

the class TaskRepositoriesConfigurable method reset.

public void reset() {
    myRepoNames.clear();
    myRepositoryEditor.removeAll();
    myRepositoryEditor.add(myEmptyPanel, EMPTY_PANEL);
    //    ((CardLayout)myRepositoryEditor.getLayout()).show(myRepositoryEditor, );
    myRepositories.clear();
    CollectionListModel listModel = new CollectionListModel(new ArrayList());
    for (TaskRepository repository : myManager.getAllRepositories()) {
        TaskRepository clone = repository.clone();
        assert clone.equals(repository) : repository.getClass().getName();
        myRepositories.add(clone);
        listModel.add(clone);
    }
    myRepositoriesList.setModel(listModel);
    for (TaskRepository clone : myRepositories) {
        addRepositoryEditor(clone);
    }
    if (!myRepositories.isEmpty()) {
        myRepositoriesList.setSelectedValue(myRepositories.get(0), true);
    }
}
Also used : TaskRepository(com.intellij.tasks.TaskRepository) ArrayList(java.util.ArrayList)

Aggregations

TaskRepository (com.intellij.tasks.TaskRepository)5 CustomTaskState (com.intellij.tasks.CustomTaskState)2 LocalTask (com.intellij.tasks.LocalTask)2 Nullable (org.jetbrains.annotations.Nullable)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Project (com.intellij.openapi.project.Project)1 Task (com.intellij.tasks.Task)1 TaskManagerImpl (com.intellij.tasks.impl.TaskManagerImpl)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 NotNull (org.jetbrains.annotations.NotNull)1