Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Green2011-10-25 23:15:23 +0000
committerDavid Green2011-10-25 23:18:04 +0000
commit312203f74a49e7fe54130fe2631af237a6f44dfd (patch)
tree6f9cc8d1818ecd9331d39c9bc4a4fd0e7e9ced15
parent613e6658f7e144b528b06bcf1be666b56765b06c (diff)
downloadorg.eclipse.mylyn.incubator-312203f74a49e7fe54130fe2631af237a6f44dfd.tar.gz
org.eclipse.mylyn.incubator-312203f74a49e7fe54130fe2631af237a6f44dfd.tar.xz
org.eclipse.mylyn.incubator-312203f74a49e7fe54130fe2631af237a6f44dfd.zip
NEW - bug 191522: Provide full text search functionality over task
comments https://bugs.eclipse.org/bugs/show_bug.cgi?id=191522
-rw-r--r--org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskListIndex.java66
-rw-r--r--org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/IndexSearchHandler.java22
-rw-r--r--org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/Messages.java2
-rw-r--r--org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/messages.properties1
4 files changed, 72 insertions, 19 deletions
diff --git a/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskListIndex.java b/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskListIndex.java
index d7ba3a9d..69a4b4a3 100644
--- a/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskListIndex.java
+++ b/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskListIndex.java
@@ -90,32 +90,35 @@ public class TaskListIndex implements ITaskDataManagerListener, ITaskListChangeL
private static final Object COMMAND_RESET_INDEX = "index:reset"; //$NON-NLS-1$
public static enum IndexField {
- IDENTIFIER(false, null), //
- TASK_KEY(false, null), //
- SUMMARY(true, null), //
- CONTENT(true, null), //
- ASSIGNEE(true, TaskAttribute.USER_ASSIGNED), //
- REPORTER(true, TaskAttribute.USER_REPORTER), //
- PERSON(true, null), //
- COMPONENT(true, TaskAttribute.COMPONENT), //
- COMPLETION_DATE(true, null), //
- CREATION_DATE(true, null), //
- DUE_DATE(true, null), //
- MODIFICATION_DATE(true, null), //
- DESCRIPTION(true, TaskAttribute.DESCRIPTION), //
- KEYWORDS(true, TaskAttribute.KEYWORDS), //
- PRODUCT(true, TaskAttribute.PRODUCT), //
- RESOLUTION(true, TaskAttribute.RESOLUTION), //
- SEVERITY(true, TaskAttribute.SEVERITY), //
- STATUS(true, TaskAttribute.STATUS);
+ IDENTIFIER(false, null, false), //
+ TASK_KEY(false, null, false), //
+ SUMMARY(true, null, false), //
+ CONTENT(true, null, false), //
+ ASSIGNEE(true, TaskAttribute.USER_ASSIGNED, false), //
+ REPORTER(true, TaskAttribute.USER_REPORTER, false), //
+ PERSON(true, null, false), //
+ COMPONENT(true, TaskAttribute.COMPONENT, false), //
+ COMPLETION_DATE(true, null, true), //
+ CREATION_DATE(true, null, true), //
+ DUE_DATE(true, null, true), //
+ MODIFICATION_DATE(true, null, true), //
+ DESCRIPTION(true, TaskAttribute.DESCRIPTION, false), //
+ KEYWORDS(true, TaskAttribute.KEYWORDS, false), //
+ PRODUCT(true, TaskAttribute.PRODUCT, false), //
+ RESOLUTION(true, TaskAttribute.RESOLUTION, false), //
+ SEVERITY(true, TaskAttribute.SEVERITY, false), //
+ STATUS(true, TaskAttribute.STATUS, false);
private final boolean userVisible;
private final String attributeId;
- private IndexField(boolean userVisible, String attributeId) {
+ private final boolean dateTime;
+
+ private IndexField(boolean userVisible, String attributeId, boolean dateTime) {
this.userVisible = userVisible;
this.attributeId = attributeId;
+ this.dateTime = dateTime;
}
public String fieldName() {
@@ -129,10 +132,20 @@ public class TaskListIndex implements ITaskDataManagerListener, ITaskListChangeL
return attributeId;
}
+ /**
+ * indicate if the field should be exposed in the UI
+ */
public boolean isUserVisible() {
return userVisible;
}
+ /**
+ * indicate if the field is a date/time field
+ */
+ public boolean isDateTime() {
+ return dateTime;
+ }
+
public static IndexField fromFieldName(String fieldName) {
try {
return IndexField.valueOf(fieldName.toUpperCase());
@@ -785,4 +798,19 @@ public class TaskListIndex implements ITaskDataManagerListener, ITaskListChangeL
}
+ /**
+ * Computes a query element for a field that must lie in a specified date range.
+ *
+ * @param field
+ * the field
+ * @param lowerBoundInclusive
+ * the date lower bound that the field value must match, inclusive
+ * @param upperBoundInclusive
+ * the date upper bound that the field value must match, inclusive
+ * @return
+ */
+ public String computeQueryFieldDateRange(IndexField field, Date lowerBoundInclusive, Date upperBoundInclusive) {
+ return field.fieldName()
+ + ":[" + DateTools.dateToString(lowerBoundInclusive, Resolution.DAY) + " TO " + DateTools.dateToString(upperBoundInclusive, Resolution.DAY) + "]"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ }
}
diff --git a/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/IndexSearchHandler.java b/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/IndexSearchHandler.java
index 38ea5653..5c1f52be 100644
--- a/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/IndexSearchHandler.java
+++ b/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/IndexSearchHandler.java
@@ -11,7 +11,10 @@
package org.eclipse.mylyn.internal.tasks.index.ui;
import java.util.ArrayList;
+import java.util.Calendar;
import java.util.Collection;
+import java.util.Date;
+import java.util.GregorianCalendar;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
@@ -142,6 +145,9 @@ public class IndexSearchHandler extends AbstractSearchHandler {
}
} else {
+ GregorianCalendar calendar = new GregorianCalendar();
+ final Date now = new Date();
+
// suggest field name prefixes
for (IndexField field : IndexField.values()) {
@@ -164,6 +170,22 @@ public class IndexSearchHandler extends AbstractSearchHandler {
}
proposals.add(new ContentProposal(field.fieldName().substring(prefix.length()) + ":", //$NON-NLS-1$
field.fieldName(), description));
+
+ if (field.isDateTime()) {
+ description = NLS.bind(Messages.IndexSearchHandler_Generic_date_range_search_1_week,
+ field.fieldName());
+
+ calendar.setTime(now);
+ calendar.add(Calendar.DAY_OF_WEEK, 1); // one day in future due to GMT conversion in index
+ Date upperBound = calendar.getTime();
+
+ calendar.setTime(now);
+ calendar.add(Calendar.DAY_OF_WEEK, -7);
+ Date lowerBound = calendar.getTime();
+
+ proposals.add(new ContentProposal(index.computeQueryFieldDateRange(field, lowerBound,
+ upperBound), field.fieldName(), description));
+ }
}
}
}
diff --git a/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/Messages.java b/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/Messages.java
index d0a7b364..d9ab9cf3 100644
--- a/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/Messages.java
+++ b/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/Messages.java
@@ -19,6 +19,8 @@ import org.eclipse.osgi.util.NLS;
class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.tasks.index.ui.messages"; //$NON-NLS-1$
+ public static String IndexSearchHandler_Generic_date_range_search_1_week;
+
public static String IndexSearchHandler_hint_content;
public static String IndexSearchHandler_hint_generic;
diff --git a/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/messages.properties b/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/messages.properties
index de027709..593b5439 100644
--- a/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/messages.properties
+++ b/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/messages.properties
@@ -8,6 +8,7 @@
# Contributors:
# Tasktop Technologies - initial API and implementation
###############################################################################
+IndexSearchHandler_Generic_date_range_search_1_week=Search for tasks where the {0} field value\noccurs in the past week
IndexSearchHandler_hint_content=Search for a term in the summary, description and comments
IndexSearchHandler_hint_generic=Search on a term in the {0} field
IndexSearchHandler_hint_person=Search for a user (reporter, assignee, watcher, commenter)

Back to the top