use of com.intellij.tasks.Task in project intellij-community by JetBrains.
the class RegExResponseHandler method parseIssues.
@NotNull
@Override
public Task[] parseIssues(@NotNull String response, int max) throws Exception {
final List<String> placeholders = getPlaceholders(myTaskRegex);
if (!placeholders.contains(ID_PLACEHOLDER) || !placeholders.contains(SUMMARY_PLACEHOLDER)) {
throw new Exception("Incorrect Task Pattern");
}
final String taskPatternWithoutPlaceholders = myTaskRegex.replaceAll("\\{.+?\\}", "");
Matcher matcher = Pattern.compile(taskPatternWithoutPlaceholders, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL | Pattern.UNICODE_CASE | Pattern.CANON_EQ).matcher(response);
List<Task> tasks = new ArrayList<>();
for (int i = 0; i < max && matcher.find(); i++) {
String id = matcher.group(placeholders.indexOf(ID_PLACEHOLDER) + 1);
String summary = matcher.group(placeholders.indexOf(SUMMARY_PLACEHOLDER) + 1);
// temporary workaround to make AssemblaIntegrationTestPass
final String finalSummary = summary;
summary = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
XmlElementFactory factory = XmlElementFactory.getInstance(ProjectManager.getInstance().getDefaultProject());
XmlTag text = factory.createTagFromText("<a>" + finalSummary + "</a>");
String trimmedText = text.getValue().getTrimmedText();
return XmlUtil.decode(trimmedText);
}
});
tasks.add(new GenericTask(id, summary, myRepository));
}
return tasks.toArray(new Task[tasks.size()]);
}
use of com.intellij.tasks.Task in project intellij-community by JetBrains.
the class TaskCheckinHandlerFactory method createHandler.
@NotNull
@Override
public CheckinHandler createHandler(@NotNull final CheckinProjectPanel panel, @NotNull final CommitContext commitContext) {
return new CheckinHandler() {
@Override
public void checkinSuccessful() {
final String message = panel.getCommitMessage();
final Project project = panel.getProject();
final TaskManagerImpl manager = (TaskManagerImpl) TaskManager.getManager(project);
if (manager.getState().saveContextOnCommit) {
Task task = findTaskInRepositories(message, manager);
if (task == null) {
task = manager.createLocalTask(message);
}
final LocalTask localTask = manager.addTask(task);
localTask.setUpdated(new Date());
ApplicationManager.getApplication().invokeLater(() -> WorkingContextManager.getInstance(project).saveContext(localTask), project.getDisposed());
}
}
};
}
use of com.intellij.tasks.Task 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.Task 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);
}
use of com.intellij.tasks.Task in project intellij-community by JetBrains.
the class TracRepository method getIssues.
private Task[] getIssues(@Nullable String query, int max, final Transport transport) throws Exception {
final XmlRpcClient client = getRpcClient();
Vector<Object> result = null;
String search = myDefaultSearch + "&max=" + max;
if (myMaxSupported == null) {
try {
myMaxSupported = true;
result = runQuery(query, transport, client, search);
} catch (XmlRpcException e) {
if (e.getMessage().contains("t.max")) {
myMaxSupported = false;
} else
throw e;
}
}
if (!myMaxSupported) {
search = myDefaultSearch;
}
if (result == null) {
result = runQuery(query, transport, client, search);
}
if (result == null)
throw new Exception("Cannot connect to " + getUrl());
ArrayList<Task> tasks = new ArrayList<>(max);
int min = Math.min(max, result.size());
for (int i = 0; i < min; i++) {
Task task = getTask((Integer) result.get(i), client, transport);
ContainerUtil.addIfNotNull(tasks, task);
}
return tasks.toArray(new Task[tasks.size()]);
}
Aggregations