Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVaughan Hilts2015-11-09 23:38:41 -0500
committerGerrit Code Review @ Eclipse.org2015-11-25 21:02:47 -0500
commitf653f7f0ce4a5fb7b84c0e99fa9634ef28bbc260 (patch)
tree1fcd6c65d268453f071947fb6f0081980c968470
parent87ae1b0d5411a18b8c69f41fe992bbaaa114860b (diff)
downloadorg.eclipse.mylyn.tasks-f653f7f0ce4a5fb7b84c0e99fa9634ef28bbc260.tar.gz
org.eclipse.mylyn.tasks-f653f7f0ce4a5fb7b84c0e99fa9634ef28bbc260.tar.xz
org.eclipse.mylyn.tasks-f653f7f0ce4a5fb7b84c0e99fa9634ef28bbc260.zip
481168: [UCOSP] Add task list filter for review artifacts
Change-Id: I19f370a52cdf83ce800fea8d621c6db9d9b5abff Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=481168 Signed-off-by: Vaughan Hilts <hilts.vaughan@gmail.com>
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/internal/tasks/ui/ArtifactFilterTest.java68
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskReviewArtifactFilter.java35
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java43
4 files changed, 131 insertions, 19 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java
index df19e6501..2aba1c959 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java
@@ -65,6 +65,8 @@ public interface ITasksCoreConstants {
public static final String ATTRIBUTE_TASK_SUPPRESS_INCOMING = "task.common.suppress.incoming"; //$NON-NLS-1$
+ public static final String ATTRIBUTE_ARTIFACT = "org.eclipse.mylyn.is.artifact"; //$NON-NLS-1$
+
/**
* @deprecated Since Mylyn 3.11, all TaskRepositories store their credentials in the secure store.
*/
@@ -94,7 +96,7 @@ public interface ITasksCoreConstants {
/**
* The parent of all scheduling rules that modify task data.
- *
+ *
* @see ITasksCoreConstants#ROOT_SCHEDULING_RULE
*/
public static class RootSchedulingRule implements ISchedulingRule {
diff --git a/org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/internal/tasks/ui/ArtifactFilterTest.java b/org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/internal/tasks/ui/ArtifactFilterTest.java
new file mode 100644
index 000000000..fd8be1ef9
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/internal/tasks/ui/ArtifactFilterTest.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Vaughan Hilts and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vaughan Hilts - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.junit.Test;
+
+/**
+ * @author Vaughan Hilts
+ */
+@SuppressWarnings("restriction")
+public class ArtifactFilterTest {
+
+ @Test
+ public void testReviewArtifactIsFiltered() {
+ ITask task = mock(ITask.class);
+ when(task.getAttribute(ITasksCoreConstants.ATTRIBUTE_ARTIFACT)).thenReturn("true");
+ TaskReviewArtifactFilter filter = new TaskReviewArtifactFilter();
+
+ boolean wasFiltered = !filter.select(null, task);
+ assertTrue(wasFiltered);
+ }
+
+ @Test
+ public void testNonReviewArtifactIsntFiltered() {
+ ITask task = mock(ITask.class);
+ when(task.getAttribute(ITasksCoreConstants.ATTRIBUTE_ARTIFACT)).thenReturn("false");
+ TaskReviewArtifactFilter filter = new TaskReviewArtifactFilter();
+
+ boolean wasFiltered = !filter.select(null, task);
+ assertFalse(wasFiltered);
+ }
+
+ @Test
+ public void testUnclassifiedReviewArtifactIsntFiltered() {
+ // If a task is yet to be determined, we should not filter it
+ ITask task = mock(ITask.class);
+ TaskReviewArtifactFilter filter = new TaskReviewArtifactFilter();
+
+ boolean wasFiltered = !filter.select(null, task);
+ assertFalse(wasFiltered);
+ }
+
+ @Test
+ public void testArbitaryElementsAreNotFiltered() {
+ Object element = new Object();
+
+ TaskReviewArtifactFilter filter = new TaskReviewArtifactFilter();
+ boolean wasFiltered = !filter.select(null, element);
+ assertFalse(wasFiltered);
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskReviewArtifactFilter.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskReviewArtifactFilter.java
new file mode 100644
index 000000000..5e47e7ce8
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskReviewArtifactFilter.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Vaughan Hilts and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vaughan Hilts - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui;
+
+import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
+import org.eclipse.mylyn.tasks.core.ITask;
+
+/**
+ * This class provides a way to filter out review artifacts, since we do not want to see them in the list. As an
+ * important note, this filter is not intended to have an action button on the UI, as the way it filters is ultimately
+ * handled on a per repository basis.
+ *
+ * @author Vaughan Hilts
+ */
+public class TaskReviewArtifactFilter extends AbstractTaskListFilter {
+ @Override
+ public boolean select(Object parent, Object element) {
+ if (element instanceof ITask) {
+ ITask task = (ITask) element;
+ String artifactStateAttribute = task.getAttribute(ITasksCoreConstants.ATTRIBUTE_ARTIFACT);
+ return !Boolean.parseBoolean(artifactStateAttribute);
+ } else {
+ return true;
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java
index 41a5be8a7..60cb32adf 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java
@@ -71,6 +71,7 @@ import org.eclipse.mylyn.internal.tasks.ui.TaskArchiveFilter;
import org.eclipse.mylyn.internal.tasks.ui.TaskCompletionFilter;
import org.eclipse.mylyn.internal.tasks.ui.TaskPriorityFilter;
import org.eclipse.mylyn.internal.tasks.ui.TaskRepositoryUtil;
+import org.eclipse.mylyn.internal.tasks.ui.TaskReviewArtifactFilter;
import org.eclipse.mylyn.internal.tasks.ui.TaskWorkingSetFilter;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.actions.CollapseAllAction;
@@ -281,6 +282,8 @@ public class TaskListView extends AbstractTaskListView implements IPropertyChang
private final TaskArchiveFilter filterArchive = new TaskArchiveFilter();
+ private final TaskReviewArtifactFilter filterArtifact = new TaskReviewArtifactFilter();
+
private final PresentationFilter filterPresentation = PresentationFilter.getInstance();
private final MyTasksFilter filterMyTasks = new MyTasksFilter();
@@ -386,9 +389,8 @@ public class TaskListView extends AbstractTaskListView implements IPropertyChang
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(IThemeManager.CHANGE_CURRENT_THEME)
|| CommonThemes.isCommonTheme(event.getProperty())) {
- taskListTableLabelProvider.setCategoryBackgroundColor(themeManager.getCurrentTheme()
- .getColorRegistry()
- .get(CommonThemes.COLOR_CATEGORY));
+ taskListTableLabelProvider.setCategoryBackgroundColor(
+ themeManager.getCurrentTheme().getColorRegistry().get(CommonThemes.COLOR_CATEGORY));
getViewer().refresh();
}
}
@@ -548,14 +550,19 @@ public class TaskListView extends AbstractTaskListView implements IPropertyChang
filteredTree.setWorkingSetFilter(filterWorkingSet);
addFilter(filterWorkingSet);
addFilter(filterPriority);
- if (TasksUiPlugin.getDefault().getPreferenceStore().contains(ITasksUiPreferenceConstants.FILTER_COMPLETE_MODE)) {
+ if (TasksUiPlugin.getDefault()
+ .getPreferenceStore()
+ .contains(ITasksUiPreferenceConstants.FILTER_COMPLETE_MODE)) {
addFilter(filterComplete);
}
- if (TasksUiPlugin.getDefault().getPreferenceStore().contains(ITasksUiPreferenceConstants.FILTER_MY_TASKS_MODE)) {
+ if (TasksUiPlugin.getDefault()
+ .getPreferenceStore()
+ .contains(ITasksUiPreferenceConstants.FILTER_MY_TASKS_MODE)) {
addFilter(filterMyTasks);
}
addFilter(filterPresentation);
addFilter(filterArchive);
+ addFilter(filterArtifact);
// Restore "link with editor" value; by default true
boolean linkValue = true;
@@ -643,8 +650,8 @@ public class TaskListView extends AbstractTaskListView implements IPropertyChang
layout.numColumns = 1;
body.setLayout(layout);
- IWorkbenchSiteProgressService progress = (IWorkbenchSiteProgressService) getSite().getAdapter(
- IWorkbenchSiteProgressService.class);
+ IWorkbenchSiteProgressService progress = (IWorkbenchSiteProgressService) getSite()
+ .getAdapter(IWorkbenchSiteProgressService.class);
if (progress != null) {
// show indicator for all running query synchronizations
progress.showBusyForFamily(ITasksCoreConstants.JOB_FAMILY_SYNCHRONIZATION);
@@ -658,8 +665,9 @@ public class TaskListView extends AbstractTaskListView implements IPropertyChang
searchHandler = SearchUtil.createSearchHandler();
- filteredTree = new TaskListFilteredTree(body, SWT.MULTI | SWT.VERTICAL | /* SWT.H_SCROLL | */SWT.V_SCROLL
- | SWT.NO_SCROLL | SWT.FULL_SELECTION, searchHandler, getViewSite().getWorkbenchWindow());
+ filteredTree = new TaskListFilteredTree(body,
+ SWT.MULTI | SWT.VERTICAL | /* SWT.H_SCROLL | */SWT.V_SCROLL | SWT.NO_SCROLL | SWT.FULL_SELECTION,
+ searchHandler, getViewSite().getWorkbenchWindow());
// need to do initialize tooltip early for native tooltip disablement to take effect
taskListToolTip = new TaskListToolTip(getViewer().getControl());
@@ -729,7 +737,7 @@ public class TaskListView extends AbstractTaskListView implements IPropertyChang
getViewer().getTree().addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent event) {
- // avoid activation in case the event was actually triggered as a side-effect of a tree expansion
+ // avoid activation in case the event was actually triggered as a side-effect of a tree expansion
long currentTime = System.currentTimeMillis();
if (currentTime - lastExpansionTime < 150 && currentTime >= lastExpansionTime) {
return;
@@ -852,9 +860,8 @@ public class TaskListView extends AbstractTaskListView implements IPropertyChang
message.setTitle(Messages.TaskListView_Welcome_Message_Title);
message.setImage(Dialog.DLG_IMG_MESSAGE_INFO);
serviceMessageControl.setMessage(message);
- TasksUiPlugin.getDefault()
- .getPreferenceStore()
- .setValue(ITasksUiPreferenceConstants.WELCOME_MESSAGE, Boolean.toString(true));
+ TasksUiPlugin.getDefault().getPreferenceStore().setValue(ITasksUiPreferenceConstants.WELCOME_MESSAGE,
+ Boolean.toString(true));
}
TasksUiPlugin.getDefault().getServiceMessageManager().addServiceMessageListener(serviceMessageControl);
@@ -1341,9 +1348,9 @@ public class TaskListView extends AbstractTaskListView implements IPropertyChang
itemNotFoundExceptionLogged = true;
// It's probably not worth displaying this to the user since the item
// is not there in this case, so consider removing.
- StatusHandler.log(new Status(IStatus.WARNING, TasksUiPlugin.ID_PLUGIN,
- "Could not link Task List with editor", //$NON-NLS-1$
- e));
+ StatusHandler.log(
+ new Status(IStatus.WARNING, TasksUiPlugin.ID_PLUGIN, "Could not link Task List with editor", //$NON-NLS-1$
+ e));
}
}
}
@@ -1611,8 +1618,8 @@ public class TaskListView extends AbstractTaskListView implements IPropertyChang
int preferredResult) {
if (width) {
if (getViewSite().getActionBars().getToolBarManager() instanceof ToolBarManager) {
- Point size = ((ToolBarManager) getViewSite().getActionBars().getToolBarManager()).getControl()
- .computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ Point size = ((ToolBarManager) getViewSite().getActionBars().getToolBarManager())
+ .getControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
// leave some room for the view menu drop-down
return size.x + PlatformUiUtil.getViewMenuWidth();
}

Back to the top