Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Ritchie2016-08-11 19:46:34 -0400
committerGerrit Code Review @ Eclipse.org2016-08-12 17:37:03 -0400
commit4b77d3f2081127abd2ee27500d84b7bd94d8ff70 (patch)
treebb78c02569f8d7617638cdfc0435bdfeddaae8d4
parent87d261761bc06e87322fdd61d94b264f451c4518 (diff)
downloadorg.eclipse.mylyn.tasks-4b77d3f2081127abd2ee27500d84b7bd94d8ff70.tar.gz
org.eclipse.mylyn.tasks-4b77d3f2081127abd2ee27500d84b7bd94d8ff70.tar.xz
org.eclipse.mylyn.tasks-4b77d3f2081127abd2ee27500d84b7bd94d8ff70.zip
499581: Task Image is different when the task is owned by the user
Introduce the "Golden Clipboard" for tasks owned by the active user. Change-Id: I4fed0b3dccf3b2e1199e792881ca369f9490903e Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=499581
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnectorUi.java9
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/AbstractRepositoryConnectorUiTest.java56
-rw-r--r--org.eclipse.mylyn.tasks.ui/icons/etool16/task-owned.gifbin0 -> 961 bytes
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi.java40
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiImages.java5
5 files changed, 90 insertions, 20 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnectorUi.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnectorUi.java
index e18e6e4e7..7424fd259 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnectorUi.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnectorUi.java
@@ -19,6 +19,7 @@ import java.util.regex.Pattern;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.TaskRepository;
@@ -34,6 +35,14 @@ public class MockRepositoryConnectorUi extends AbstractRepositoryConnectorUi {
private static Pattern HYPERLINK_PATTERN = Pattern.compile("(\\d+)");
+ public MockRepositoryConnectorUi() {
+ super();
+ }
+
+ public MockRepositoryConnectorUi(AbstractRepositoryConnector connector) {
+ super(connector);
+ }
+
@Override
public String getConnectorKind() {
return "mock";
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/AbstractRepositoryConnectorUiTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/AbstractRepositoryConnectorUiTest.java
index fb75222ee..8083794b8 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/AbstractRepositoryConnectorUiTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/AbstractRepositoryConnectorUiTest.java
@@ -11,10 +11,13 @@
package org.eclipse.mylyn.tasks.tests.ui;
-import junit.framework.TestCase;
-
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
+import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.internal.tasks.core.TaskComment;
import org.eclipse.mylyn.internal.tasks.core.TaskTask;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskComment;
import org.eclipse.mylyn.tasks.core.TaskRepository;
@@ -25,6 +28,9 @@ import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnectorUi;
import org.eclipse.mylyn.tasks.tests.connector.MockTask;
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
+import org.eclipse.mylyn.tasks.ui.TasksUiImages;
+
+import junit.framework.TestCase;
/**
* @author Benjamin Muskalla
@@ -41,7 +47,8 @@ public class AbstractRepositoryConnectorUiTest extends TestCase {
@Override
protected void setUp() throws Exception {
- connectorUi = new MockRepositoryConnectorUi();
+ AbstractRepositoryConnector connector = new MockRepositoryConnector();
+ connectorUi = new MockRepositoryConnectorUi(connector);
repository = new TaskRepository(MockRepositoryConnector.CONNECTOR_KIND, MockRepositoryConnector.REPOSITORY_URL);
task = new MockTask("1");
TaskAttributeMapper mapper = new TaskAttributeMapper(repository);
@@ -77,4 +84,47 @@ public class AbstractRepositoryConnectorUiTest extends TestCase {
String replyText = connectorUi.getReplyText(null, task, taskComment, true);
assertEquals("(In reply to 1 comment #13)", replyText);
}
+
+ public void testGetImageDescriptor() {
+ ITask task = new TaskTask(MockRepositoryConnector.CONNECTOR_KIND, "http://connector.url", "1");
+ task.setOwner("TaskOwner");
+
+ ImageDescriptor desc = connectorUi.getImageDescriptor(task);
+ assertNotNull(desc);
+ assertEquals(TasksUiImages.TASK, desc);
+ }
+
+ public void testGetImageDescriptorOwnedByMe() {
+ TaskRepository repository = new TaskRepository(MockRepositoryConnector.CONNECTOR_KIND, "http://connector.url");
+ repository.setCredentials(AuthenticationType.REPOSITORY,
+ new AuthenticationCredentials("RepoUser", "SecretPassword"), false);
+ try {
+ TasksUiPlugin.getRepositoryManager().addRepository(repository);
+ ITask task = new TaskTask(MockRepositoryConnector.CONNECTOR_KIND, "http://connector.url", "1");
+ task.setOwner("RepoUser");
+
+ ImageDescriptor desc = connectorUi.getImageDescriptor(task);
+ assertNotNull(desc);
+ assertEquals(TasksUiImages.TASK_OWNED, desc);
+ } finally {
+ TasksUiPlugin.getRepositoryManager().removeRepository(repository);
+ }
+ }
+
+ public void testGetImageDescriptorOwnedNotByMe() {
+ TaskRepository repository = new TaskRepository(MockRepositoryConnector.CONNECTOR_KIND, "http://connector.url");
+ repository.setCredentials(AuthenticationType.REPOSITORY,
+ new AuthenticationCredentials("RepoUser", "SecretPassword"), false);
+ try {
+ TasksUiPlugin.getRepositoryManager().addRepository(repository);
+ ITask task = new TaskTask(MockRepositoryConnector.CONNECTOR_KIND, "http://connector.url", "1");
+ task.setOwner("AnotherRepoUser");
+
+ ImageDescriptor desc = connectorUi.getImageDescriptor(task);
+ assertNotNull(desc);
+ assertEquals(TasksUiImages.TASK, desc);
+ } finally {
+ TasksUiPlugin.getRepositoryManager().removeRepository(repository);
+ }
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/icons/etool16/task-owned.gif b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-owned.gif
new file mode 100644
index 000000000..b32982724
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-owned.gif
Binary files differ
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi.java
index 5cb813243..b387f6316 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi.java
@@ -26,6 +26,7 @@ import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
import org.eclipse.mylyn.internal.tasks.ui.Messages;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
@@ -44,7 +45,7 @@ import org.eclipse.ui.IEditorInput;
/**
* Extend to provide connector-specific UI extensions. TODO: consider refactoring into extension points
- *
+ *
* @author Mik Kersten
* @since 2.0
*/
@@ -59,7 +60,7 @@ public abstract class AbstractRepositoryConnectorUi {
/**
* Connectors should provide a one-argument constructor that can be used to pass the connector into the connector UI
* in tests. Connectors must provide a default constructor so that they can be created via extension point.
- *
+ *
* @param connector
* the task repository connector
* @noreference This method is not intended to be referenced by clients.
@@ -103,7 +104,7 @@ public abstract class AbstractRepositoryConnectorUi {
/**
* Connectors can implement this method if they need to open a wizard dialog before opening a new subtask editor.
- *
+ *
* @since 3.18
*/
@Nullable
@@ -115,7 +116,7 @@ public abstract class AbstractRepositoryConnectorUi {
* Override to return a custom task editor ID. If overriding this method the connector becomes responsible for
* showing the additional pages handled by the default task editor. As of Mylyn 2.0M2 these are the Planning and
* Context pages.
- *
+ *
* @since 3.0
*/
@NonNull
@@ -128,7 +129,7 @@ public abstract class AbstractRepositoryConnectorUi {
* this method to return a custom task editor input. The connector author must ensure the corresponding editor is
* capable of opening this editor input and will likely need to override
* AbstractRepositoryConnectorUi.getTaskEditorId() as well.
- *
+ *
* @param repository
* - task repository for which to construct an editor
* @param task
@@ -144,7 +145,7 @@ public abstract class AbstractRepositoryConnectorUi {
/**
* Contributions to the UI legend.
- *
+ *
* @deprecated use {@link #getLegendElements()} instead
*/
@Deprecated
@@ -155,7 +156,7 @@ public abstract class AbstractRepositoryConnectorUi {
/**
* Contributions to the UI legend.
- *
+ *
* @since 3.0
*/
@NonNull
@@ -177,7 +178,7 @@ public abstract class AbstractRepositoryConnectorUi {
* Connector-specific task icons. Not recommended to override unless providing custom icons and kind overlays. For
* connectors that have a decorator that they want to reuse, the connector can maintain a reference to the label
* provider and get the descriptor from the images it returns.
- *
+ *
* @since 3.0
*/
@Nullable
@@ -185,6 +186,11 @@ public abstract class AbstractRepositoryConnectorUi {
if (element instanceof RepositoryQuery) {
return ((RepositoryQuery) element).getAutoUpdate() ? TasksUiImages.QUERY : TasksUiImages.QUERY_OFFLINE;
} else if (element instanceof ITask) {
+ ITask task = (ITask) element;
+ TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(task.getRepositoryUrl());
+ if (repository != null && connector != null && connector.isOwnedByUser(repository, task)) {
+ return TasksUiImages.TASK_OWNED;
+ }
return TasksUiImages.TASK;
} else {
return null;
@@ -193,7 +199,7 @@ public abstract class AbstractRepositoryConnectorUi {
/**
* Task kind overlay, recommended to override with connector-specific overlay.
- *
+ *
* @since 3.0
*/
@Nullable
@@ -204,7 +210,7 @@ public abstract class AbstractRepositoryConnectorUi {
/**
* Connector-specific priority icons. Not recommended to override since priority icons are used elsewhere in the
* Task List UI (e.g. filter selection in view menu).
- *
+ *
* @since 3.0
*/
@NonNull
@@ -214,7 +220,7 @@ public abstract class AbstractRepositoryConnectorUi {
/**
* This method is not used anymore.
- *
+ *
* @return returns null
*/
@Deprecated
@@ -233,7 +239,7 @@ public abstract class AbstractRepositoryConnectorUi {
/**
* Override to return a URL that provides the user with an account creation page for the repository
- *
+ *
* @param taskRepository
* TODO
*/
@@ -244,7 +250,7 @@ public abstract class AbstractRepositoryConnectorUi {
/**
* Override to return a URL that provides the user with an account management page for the repository
- *
+ *
* @param taskRepository
* TODO
*/
@@ -255,7 +261,7 @@ public abstract class AbstractRepositoryConnectorUi {
/**
* Override to return a URL that provides the user with a history page for the task.
- *
+ *
* @return a url of a page for the history of the task; null, if no history url is available
* @since 3.0
*/
@@ -268,7 +274,7 @@ public abstract class AbstractRepositoryConnectorUi {
* Override to return a specific textual reference to a comment, e.g. by default this method returns
* <code>In reply to comment #12</code> for a reply to comment 12. This text is used when generating replies to
* comments.
- *
+ *
* @return the reply text with a reference to <code>taskComment</code>; null, if no reference is available
* @since 3.0
*/
@@ -290,7 +296,7 @@ public abstract class AbstractRepositoryConnectorUi {
* Returns an array of hyperlinks that link to tasks within <code>text</code>. If <code>index</code> is != -1
* clients may limit the results to hyperlinks found at <code>index</code>. It is legal for clients to always return
* all results.
- *
+ *
* @param repository
* the task repository, never <code>null</code>
* @param text
@@ -337,7 +343,7 @@ public abstract class AbstractRepositoryConnectorUi {
* Returns an array of hyperlinks that link to tasks within <code>text</code>. If <code>index</code> is != -1
* clients may limit the results to hyperlinks found at <code>index</code>. It is legal for clients to always return
* all results.
- *
+ *
* @param repository
* the task repository, never <code>null</code>
* @param task
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiImages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiImages.java
index 8bb4950bb..cbf27a1b4 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiImages.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiImages.java
@@ -70,6 +70,11 @@ public class TasksUiImages {
public static final ImageDescriptor TASK_ATTACHMENT_PATCH = create(OBJ, "attachment-patch.gif"); //$NON-NLS-1$
/**
+ * @since 3.21
+ */
+ public static final ImageDescriptor TASK_OWNED = create(TOOL, "task-owned.gif"); //$NON-NLS-1$
+
+ /**
* @since 3.7
*/
public static final ImageDescriptor FILTER_OBSOLETE_SMALL = create(TOOL_SMALL, "file-delete-line-12x12.png"); //$NON-NLS-1$

Back to the top