Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2008-04-29 21:06:10 +0000
committerspingel2008-04-29 21:06:10 +0000
commita552fc950c125fc4c940aa9e6122f1c289c6bfe6 (patch)
tree758c160ff078d1082488318a58f3df47ba8c11dc
parenta77268ff6b98120ee5d547a0f92b1bcd6818b7ca (diff)
downloadorg.eclipse.mylyn.tasks-a552fc950c125fc4c940aa9e6122f1c289c6bfe6.tar.gz
org.eclipse.mylyn.tasks-a552fc950c125fc4c940aa9e6122f1c289c6bfe6.tar.xz
org.eclipse.mylyn.tasks-a552fc950c125fc4c940aa9e6122f1c289c6bfe6.zip
REOPENED - bug 221039: task searches wipes out results of the previous task searches
https://bugs.eclipse.org/bugs/show_bug.cgi?id=221039
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java15
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultTreeContentProvider.java58
2 files changed, 23 insertions, 50 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java
index 807470461..f47248638 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java
@@ -38,6 +38,7 @@ import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
import org.eclipse.search.internal.ui.SearchMessages;
import org.eclipse.search.ui.IContextMenuConstants;
+import org.eclipse.search.ui.ISearchResult;
import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
import org.eclipse.search.ui.text.Match;
import org.eclipse.swt.SWT;
@@ -91,6 +92,7 @@ public class RepositorySearchResultView extends AbstractTextSearchViewPage imple
contentProvider.setSelectedGroup(groupBy);
setChecked(true);
}
+ getViewer().refresh();
}
}
@@ -156,6 +158,7 @@ public class RepositorySearchResultView extends AbstractTextSearchViewPage imple
protected void elementsChanged(Object[] objects) {
if (searchResultProvider != null) {
searchResultProvider.elementsChanged(objects);
+ getViewer().refresh();
}
}
@@ -163,6 +166,7 @@ public class RepositorySearchResultView extends AbstractTextSearchViewPage imple
protected void clear() {
if (searchResultProvider != null) {
searchResultProvider.clear();
+ getViewer().refresh();
}
}
@@ -175,8 +179,8 @@ public class RepositorySearchResultView extends AbstractTextSearchViewPage imple
@Override
protected void configureTreeViewer(TreeViewer viewer) {
viewer.setUseHashlookup(true);
- viewer.setContentProvider(new SearchResultTreeContentProvider(this));
- searchResultProvider = (SearchResultContentProvider) viewer.getContentProvider();
+ searchResultProvider = new SearchResultTreeContentProvider();
+ viewer.setContentProvider(searchResultProvider);
DecoratingLabelProvider labelProvider = new DecoratingLabelProvider(new SearchResultsLabelProvider(
searchResultProvider), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator());
@@ -260,7 +264,7 @@ public class RepositorySearchResultView extends AbstractTextSearchViewPage imple
* Sets the new sorting category, and reorders all of the tasks.
*
* @param sortOrder
- * The new category to sort by
+ * The new category to sort by
*/
public void setSortOrder(int sortOrder) {
StructuredViewer viewer = getViewer();
@@ -378,4 +382,9 @@ public class RepositorySearchResultView extends AbstractTextSearchViewPage imple
}
}
+ @Override
+ public void setInput(ISearchResult newSearch, Object viewState) {
+ super.setInput(newSearch, viewState);
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultTreeContentProvider.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultTreeContentProvider.java
index f18f47a85..17571b8b2 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultTreeContentProvider.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultTreeContentProvider.java
@@ -9,7 +9,6 @@
package org.eclipse.mylyn.internal.tasks.ui.search;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -18,6 +17,7 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.mylyn.internal.tasks.core.Person;
import org.eclipse.mylyn.internal.tasks.core.TaskGroup;
import org.eclipse.mylyn.tasks.core.AbstractTask;
+import org.eclipse.mylyn.tasks.core.AbstractTaskContainer;
import org.eclipse.mylyn.tasks.ui.search.RepositorySearchResult;
/**
@@ -30,9 +30,6 @@ import org.eclipse.mylyn.tasks.ui.search.RepositorySearchResult;
*/
public class SearchResultTreeContentProvider extends SearchResultContentProvider {
- /** The page the Bugzilla search results are displayed in */
- private final RepositorySearchResultView searchResultsPage;
-
private final List<Object> elements = new ArrayList<Object>();
private final Map<String, Person> owners = new HashMap<String, Person>();
@@ -45,8 +42,7 @@ public class SearchResultTreeContentProvider extends SearchResultContentProvider
private GroupBy selectedGroup;
- public SearchResultTreeContentProvider(RepositorySearchResultView page) {
- searchResultsPage = page;
+ public SearchResultTreeContentProvider() {
}
@Override
@@ -62,7 +58,7 @@ public class SearchResultTreeContentProvider extends SearchResultContentProvider
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/
public Object[] getElements(Object inputElement) {
- if (inputElement instanceof RepositorySearchResult) {
+ if (inputElement == searchResult) {
if (selectedGroup == GroupBy.OWNER) {
return owners.values().toArray();
} else if (selectedGroup == GroupBy.COMPLETION) {
@@ -76,20 +72,8 @@ public class SearchResultTreeContentProvider extends SearchResultContentProvider
}
public Object[] getChildren(Object parentElement) {
- if (selectedGroup == GroupBy.OWNER && parentElement instanceof Person) {
- Collection<AbstractTask> children = ((Person) parentElement).getChildren();
- if (children != null) {
- return children.toArray();
- } else {
- return EMPTY_ARR;
- }
- } else if (selectedGroup == GroupBy.COMPLETION && parentElement instanceof TaskGroup) {
- Collection<AbstractTask> children = ((TaskGroup) parentElement).getChildren();
- if (children != null) {
- return children.toArray();
- } else {
- return EMPTY_ARR;
- }
+ if (parentElement instanceof AbstractTaskContainer) {
+ return ((AbstractTaskContainer) parentElement).getChildren().toArray();
} else {
return EMPTY_ARR;
}
@@ -100,13 +84,8 @@ public class SearchResultTreeContentProvider extends SearchResultContentProvider
}
public boolean hasChildren(Object element) {
- if (selectedGroup == GroupBy.OWNER && element instanceof String) {
- Collection<AbstractTask> children = ((Person) element).getChildren();
- if (children != null) {
- return !children.isEmpty();
- } else {
- return false;
- }
+ if (element instanceof AbstractTaskContainer) {
+ return !((AbstractTaskContainer) element).getChildren().isEmpty();
} else {
return !(element instanceof AbstractTask);
}
@@ -121,7 +100,7 @@ public class SearchResultTreeContentProvider extends SearchResultContentProvider
AbstractTask task = ((AbstractTask) object);
String owner = task.getOwner();
if (owner == null) {
- owner = "UNKNOWN";
+ owner = "<unknown>";
}
Person person = owners.get(owner);
if (person == null) {
@@ -129,9 +108,9 @@ public class SearchResultTreeContentProvider extends SearchResultContentProvider
owners.put(owner, person);
}
person.internalAddChild(task);
- boolean completed = task.isCompleted();
+
TaskGroup completeIncomplete = null;
- if (completed) {
+ if (task.isCompleted()) {
completeIncomplete = completeState.get("Complete");
if (completeIncomplete == null) {
completeIncomplete = new TaskGroup("group-complete", "Complete", GroupBy.COMPLETION.name());
@@ -147,20 +126,6 @@ public class SearchResultTreeContentProvider extends SearchResultContentProvider
completeIncomplete.internalAddChild(task);
}
}
-
- searchResultsPage.getViewer().refresh();
-//// boolean tableLimited = SearchPreferencePage.isTableLimited();
-// for (int i = 0; i < updatedElements.length; i++) {
-// if (searchResult.getMatchCount(updatedElements[i]) > 0) {
-// if (viewer.testFindItem(updatedElements[i]) != null)
-// viewer.update(updatedElements[i], null);
-// else {
-//// if (!tableLimited || viewer.getTable().getItemCount() < SearchPreferencePage.getTableLimit())
-// viewer.add(updatedElements[i]);
-// }
-// } else
-// viewer.remove(updatedElements[i]);
-// }
}
@Override
@@ -168,7 +133,6 @@ public class SearchResultTreeContentProvider extends SearchResultContentProvider
elements.clear();
owners.clear();
completeState.clear();
- searchResultsPage.getViewer().refresh();
}
public GroupBy getSelectedGroup() {
@@ -177,6 +141,6 @@ public class SearchResultTreeContentProvider extends SearchResultContentProvider
public void setSelectedGroup(GroupBy selectedGroup) {
this.selectedGroup = selectedGroup;
- searchResultsPage.getViewer().setInput(searchResultsPage.getViewer().getInput());
}
+
}

Back to the top