use of com.intellij.tasks.LocalTask 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;
}
use of com.intellij.tasks.LocalTask in project intellij-community by JetBrains.
the class SwitchTaskAction method createActionsStep.
private static ActionGroup createActionsStep(final List<TaskListItem> tasks, final Project project, final Ref<Boolean> shiftPressed) {
SimpleActionGroup group = new SimpleActionGroup();
final TaskManager manager = TaskManager.getManager(project);
final LocalTask task = tasks.get(0).getTask();
if (tasks.size() == 1 && task != null) {
group.add(new AnAction("&Switch to") {
public void actionPerformed(AnActionEvent e) {
manager.activateTask(task, !shiftPressed.get());
}
});
group.add(new AnAction("&Edit") {
@Override
public void actionPerformed(AnActionEvent e) {
EditTaskDialog.editTask((LocalTaskImpl) task, project);
}
});
}
final AnAction remove = new AnAction("&Remove") {
@Override
public void actionPerformed(AnActionEvent e) {
for (TaskListItem item : tasks) {
LocalTask itemTask = item.getTask();
if (itemTask != null) {
removeTask(project, itemTask, manager);
}
}
}
};
remove.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)), null);
group.add(remove);
return group;
}
use of com.intellij.tasks.LocalTask in project intellij-community by JetBrains.
the class SwitchTaskAction method update.
@Override
public void update(AnActionEvent e) {
Presentation presentation = e.getPresentation();
Project project = e.getData(CommonDataKeys.PROJECT);
if (project == null || project.isDefault() || project.isDisposed()) {
presentation.setEnabled(false);
presentation.setText("");
presentation.setIcon(null);
} else {
TaskManager taskManager = TaskManager.getManager(project);
LocalTask activeTask = taskManager.getActiveTask();
presentation.setVisible(true);
presentation.setEnabled(true);
if (isImplicit(activeTask) && taskManager.getAllRepositories().length == 0 && !TaskSettings.getInstance().ALWAYS_DISPLAY_COMBO) {
presentation.setVisible(false);
} else {
String s = getText(activeTask);
presentation.setText(s);
presentation.setIcon(activeTask.getIcon());
presentation.setDescription(activeTask.getSummary());
}
}
}
use of com.intellij.tasks.LocalTask 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.LocalTask in project intellij-community by JetBrains.
the class GotoTaskAction method perform.
void perform(final Project project) {
final Ref<Boolean> shiftPressed = Ref.create(false);
final ChooseByNamePopup popup = createPopup(project, new GotoTaskPopupModel(project), new TaskItemProvider(project));
popup.setShowListForEmptyPattern(true);
popup.setSearchInAnyPlace(true);
popup.setAlwaysHasMore(true);
popup.setAdText("<html>Press SHIFT to merge with current context<br/>" + "Pressing " + KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_QUICK_JAVADOC)) + " would show task description and comments</html>");
popup.registerAction("shiftPressed", KeyStroke.getKeyStroke("shift pressed SHIFT"), new AbstractAction() {
public void actionPerformed(ActionEvent e) {
shiftPressed.set(true);
}
});
popup.registerAction("shiftReleased", KeyStroke.getKeyStroke("released SHIFT"), new AbstractAction() {
public void actionPerformed(ActionEvent e) {
shiftPressed.set(false);
}
});
final DefaultActionGroup group = new DefaultActionGroup(new ConfigureServersAction() {
@Override
protected void serversChanged() {
popup.rebuildList(true);
}
});
final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
actionToolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
actionToolbar.updateActionsImmediately();
actionToolbar.getComponent().setFocusable(false);
actionToolbar.getComponent().setBorder(null);
popup.setToolArea(actionToolbar.getComponent());
popup.setMaximumListSizeLimit(PAGE_SIZE);
popup.setListSizeIncreasing(PAGE_SIZE);
showNavigationPopup(new GotoActionCallback<Object>() {
@Override
public void elementChosen(ChooseByNamePopup popup, Object element) {
TaskManager taskManager = TaskManager.getManager(project);
if (element instanceof TaskPsiElement) {
Task task = ((TaskPsiElement) element).getTask();
LocalTask localTask = taskManager.findTask(task.getId());
if (localTask != null) {
taskManager.activateTask(localTask, !shiftPressed.get());
} else {
showOpenTaskDialog(project, task);
}
} else if (element == CREATE_NEW_TASK_ACTION) {
LocalTask localTask = taskManager.createLocalTask(CREATE_NEW_TASK_ACTION.getTaskName());
showOpenTaskDialog(project, localTask);
}
}
}, null, popup);
}
Aggregations