NEW - bug 191522: Provide full text search functionality over task
comments
https://bugs.eclipse.org/bugs/show_bug.cgi?id=191522
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 d7ba3a9..69a4b4a 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 @@
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 @@
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 @@
}
+ /**
+ * 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 38ea565..5c1f52b 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 @@
}
} else {
+ GregorianCalendar calendar = new GregorianCalendar();
+ final Date now = new Date();
+
// suggest field name prefixes
for (IndexField field : IndexField.values()) {
@@ -164,6 +170,22 @@
}
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 d0a7b36..d9ab9cf 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 @@
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 de02770..593b543 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)