Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2008-03-06 03:51:16 -0500
committerspingel2008-03-06 03:51:16 -0500
commit43dd0a958bf214c26eb7329c9605d48ce3164bc1 (patch)
treec944cdf0eb3d7e017aa13887591924b5c9186126
parent2726a94027816740ed4a817c594ff2a301070917 (diff)
downloadorg.eclipse.mylyn.tasks-43dd0a958bf214c26eb7329c9605d48ce3164bc1.tar.gz
org.eclipse.mylyn.tasks-43dd0a958bf214c26eb7329c9605d48ce3164bc1.tar.xz
org.eclipse.mylyn.tasks-43dd0a958bf214c26eb7329c9605d48ce3164bc1.zip
NEW - bug 152232: [patch] add task content assist proposals
https://bugs.eclipse.org/bugs/show_bug.cgi?id=152232
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryCompletionProcessor.java46
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryTextViewerConfiguration.java16
2 files changed, 33 insertions, 29 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryCompletionProcessor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryCompletionProcessor.java
index 15f74277a..396982177 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryCompletionProcessor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryCompletionProcessor.java
@@ -14,7 +14,6 @@ import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
@@ -28,6 +27,7 @@ import org.eclipse.mylyn.internal.tasks.ui.views.TaskActivationHistory;
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.AbstractTask;
+import org.eclipse.mylyn.tasks.core.TaskList;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
@@ -39,13 +39,8 @@ public class RepositoryCompletionProcessor implements IContentAssistProcessor {
private final TaskRepository taskRepository;
- private final AbstractRepositoryConnector connector;
-
public RepositoryCompletionProcessor(TaskRepository taskRepository) {
- Assert.isNotNull(taskRepository);
-
this.taskRepository = taskRepository;
- this.connector = TasksUiPlugin.getConnector(taskRepository.getConnectorKind());
}
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
@@ -56,34 +51,41 @@ public class RepositoryCompletionProcessor implements IContentAssistProcessor {
}
String prefix = extractPrefix(viewer, offset);
+ List<CompletionProposal> resultList = new ArrayList<CompletionProposal>();
TaskActivationHistory taskHistory = TasksUiPlugin.getTaskListManager().getTaskActivationHistory();
List<AbstractTask> tasks = new ArrayList<AbstractTask>(
taskHistory.getPreviousTasks(TaskListView.getActiveWorkingSets()));
- for (Iterator<AbstractTask> it = tasks.iterator(); it.hasNext();) {
- if (!it.next().getRepositoryUrl().equals(taskRepository.getUrl())) {
- it.remove();
- }
- }
+ filterTasks(tasks);
Collections.reverse(tasks);
-
- List<CompletionProposal> resultList = new ArrayList<CompletionProposal>(tasks.size());
addTasks(resultList, tasks, prefix, offset);
- List<AbstractTask> repositoryTasks = new ArrayList<AbstractTask>(TasksUiPlugin.getTaskListManager()
- .getTaskList()
- .getRepositoryTasks(taskRepository.getUrl()));
- Collections.sort(repositoryTasks, new Comparator<AbstractTask>() {
+
+ TaskList taskList = TasksUiPlugin.getTaskListManager().getTaskList();
+ tasks = new ArrayList<AbstractTask>(taskList.getAllTasks());
+ filterTasks(tasks);
+ Collections.sort(tasks, new Comparator<AbstractTask>() {
public int compare(AbstractTask o1, AbstractTask o2) {
return o1.getTaskKey().compareTo(o2.getTaskKey());
}
});
- addTasks(resultList, repositoryTasks, prefix, offset);
+ addTasks(resultList, tasks, prefix, offset);
+
return resultList.toArray(new ICompletionProposal[resultList.size()]);
}
+ private void filterTasks(List<AbstractTask> tasks) {
+ for (Iterator<AbstractTask> it = tasks.iterator(); it.hasNext();) {
+ AbstractTask task = it.next();
+ if (task.getTaskKey() == null || taskRepository != null
+ && !task.getRepositoryUrl().equals(taskRepository.getUrl())) {
+ it.remove();
+ }
+ }
+ }
+
private void addTasks(List<CompletionProposal> resultList, List<AbstractTask> tasks, String prefix, int offset) {
for (AbstractTask task : tasks) {
- String replacement = getTaskPrefix() + task.getTaskKey();
+ String replacement = getTaskPrefix(task) + task.getTaskKey();
if (replacement.startsWith(prefix)) {
String displayString = replacement + ": " + task.getSummary();
replacement = replacement.substring(prefix.length());
@@ -101,9 +103,9 @@ public class RepositoryCompletionProcessor implements IContentAssistProcessor {
}
}
- private String getTaskPrefix() {
+ private String getTaskPrefix(AbstractTask task) {
+ AbstractRepositoryConnector connector = TasksUiPlugin.getConnector(task.getConnectorKind());
String prefix = connector.getTaskIdPrefix();
-
// FIXME work around for Trac "#" prefix
return (prefix.length() > 1) ? prefix + " " : prefix;
}
@@ -150,7 +152,7 @@ public class RepositoryCompletionProcessor implements IContentAssistProcessor {
return document.get(i, offset - i);
} catch (BadLocationException e) {
- return ""; //$NON-NLS-1$
+ return "";
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryTextViewerConfiguration.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryTextViewerConfiguration.java
index 2d2972985..3ef2d7e55 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryTextViewerConfiguration.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RepositoryTextViewerConfiguration.java
@@ -59,16 +59,18 @@ public class RepositoryTextViewerConfiguration extends TextSourceViewerConfigura
private static final String ID_CONTEXT_EDITOR_TEXT = "org.eclipse.ui.DefaultTextEditor";
- private RepositoryTextScanner scanner = null;
+ private RepositoryTextScanner scanner;
- private boolean spellcheck = false;
+ private final boolean spellCheck;
private final TaskRepository taskRepository;
- public RepositoryTextViewerConfiguration(TaskRepository taskRepository, boolean spellchecking) {
+ public RepositoryTextViewerConfiguration(TaskRepository taskRepository, boolean spellCheck) {
super(EditorsUI.getPreferenceStore());
+ // API 3.0 add this check
+ //Assert.isNotNull(taskRepository);
this.taskRepository = taskRepository;
- this.spellcheck = spellchecking;
+ this.spellCheck = spellCheck;
}
@Override
@@ -125,7 +127,7 @@ public class RepositoryTextViewerConfiguration extends TextSourceViewerConfigura
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
- if (spellcheck) {
+ if (spellCheck) {
return super.getReconciler(sourceViewer);
} else {
return null;
@@ -245,8 +247,8 @@ public class RepositoryTextViewerConfiguration extends TextSourceViewerConfigura
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
ContentAssistant assistant = new ContentAssistant();
- assistant.setContentAssistProcessor(new RepositoryCompletionProcessor(getTaskRepository()),
- IDocument.DEFAULT_CONTENT_TYPE);
+ RepositoryCompletionProcessor processor = new RepositoryCompletionProcessor(taskRepository);
+ assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
return assistant;
}

Back to the top