Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaxsun McCarthy Huggan2016-10-27 18:45:03 -0400
committerAlexei Trebounskikh2018-11-30 13:18:57 -0500
commit84dabea847998d58591390db2a4b9b1f9fe82c4f (patch)
treeace8432b049c28e450ede99372924eca93c0f888
parent2c6de7dc0ee5d3b501df7b8c371ffe87d82c9f69 (diff)
downloadorg.eclipse.mylyn.reviews-84dabea847998d58591390db2a4b9b1f9fe82c4f.tar.gz
org.eclipse.mylyn.reviews-84dabea847998d58591390db2a4b9b1f9fe82c4f.tar.xz
org.eclipse.mylyn.reviews-84dabea847998d58591390db2a4b9b1f9fe82c4f.zip
394733: Gerrit task list tooltip shows review CodeReview/Verified status
Change-Id: I7bd44fb5a6abae841391a2bb464bb19132a8c1cc Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=394733 Signed-off-by: Jaxsun McCarthy Huggan <jaxsun.mccarthy@tasktop.com>
-rw-r--r--org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritConnector.java58
-rw-r--r--org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/Messages.java4
-rw-r--r--org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/messages.properties2
3 files changed, 57 insertions, 7 deletions
diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritConnector.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritConnector.java
index b35ad1c2..b4879b34 100644
--- a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritConnector.java
+++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritConnector.java
@@ -48,6 +48,7 @@ import org.eclipse.mylyn.internal.gerrit.core.client.GerritRestClient;
import org.eclipse.mylyn.internal.gerrit.core.client.GerritSystemInfo;
import org.eclipse.mylyn.internal.gerrit.core.client.JSonSupport;
import org.eclipse.mylyn.internal.gerrit.core.client.data.GerritQueryResult;
+import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
import org.eclipse.mylyn.reviews.core.model.ReviewStatus;
import org.eclipse.mylyn.reviews.core.spi.ReviewsConnector;
import org.eclipse.mylyn.reviews.internal.core.ReviewsCoreConstants;
@@ -65,6 +66,7 @@ import org.eclipse.mylyn.tasks.core.data.TaskMapper;
import org.eclipse.mylyn.tasks.core.sync.ISynchronizationSession;
import org.eclipse.osgi.util.NLS;
+import com.google.common.base.Joiner;
import com.google.gwtorm.client.KeyUtil;
import com.google.gwtorm.server.StandardKeyEncoder;
@@ -329,16 +331,58 @@ public class GerritConnector extends ReviewsConnector {
task.setModificationDate(oldModificationDate);
}
- setAttribute(task, TaskAttribute.STATUS, taskData.getRoot().getMappedAttribute(TaskAttribute.STATUS));
- setAttribute(task, ReviewsCoreConstants.CODE_REVIEW,
- taskData.getRoot().getAttribute(GerritTaskSchema.getDefault().REVIEW_STATE.getKey()));
- setAttribute(task, ReviewsCoreConstants.VERIFIED,
- taskData.getRoot().getAttribute(GerritTaskSchema.getDefault().VERIFY_STATE.getKey()));
- setAttribute(task, ReviewsCoreConstants.BRANCH,
- taskData.getRoot().getAttribute(GerritTaskSchema.getDefault().BRANCH.getKey()));
+ TaskAttribute status = taskData.getRoot().getMappedAttribute(TaskAttribute.STATUS);
+ TaskAttribute codeReview = taskData.getRoot().getAttribute(GerritTaskSchema.getDefault().REVIEW_STATE.getKey());
+ TaskAttribute verified = taskData.getRoot().getAttribute(GerritTaskSchema.getDefault().VERIFY_STATE.getKey());
+ TaskAttribute branch = taskData.getRoot().getAttribute(GerritTaskSchema.getDefault().BRANCH.getKey());
+
+ setAttribute(task, TaskAttribute.STATUS, status);
+ setAttribute(task, ReviewsCoreConstants.CODE_REVIEW, codeReview);
+ setAttribute(task, ReviewsCoreConstants.VERIFIED, verified);
+ setAttribute(task, ReviewsCoreConstants.BRANCH, branch);
+
+ addExtendedTooltip(task);
+
super.updateTaskFromTaskData(taskRepository, task, taskData);
}
+ @SuppressWarnings("restriction")
+ private void addExtendedTooltip(ITask task) {
+ String codeReviewValue = task.getAttribute(ReviewsCoreConstants.CODE_REVIEW);
+ String verifiedValue = task.getAttribute(ReviewsCoreConstants.VERIFIED);
+
+ String reviewTooltip = createTooltipText(Messages.GerritConnector_CodeReviewTooltip, codeReviewValue);
+ String verifiedTooltip = createTooltipText(Messages.GerritConnector_VerifiedTooltip, verifiedValue);
+
+ String tooltip = Joiner.on("\n").skipNulls().join(reviewTooltip, verifiedTooltip); //$NON-NLS-1$
+ if (!tooltip.isEmpty()) {
+ task.setAttribute(ITasksCoreConstants.ATTRIBUTE_TASK_EXTENDED_TOOLTIP, tooltip);
+ }
+ }
+
+ private String createTooltipText(String label, String integerString) {
+ int value = tryParseInt(integerString);
+ if (value != 0) {
+ StringBuilder builder = new StringBuilder();
+ builder.append(label);
+ if (value > 0) {
+ builder.append("+"); //$NON-NLS-1$
+ }
+ builder.append(value);
+ return builder.toString();
+ }
+ return null;
+ }
+
+ private int tryParseInt(String integerString) {
+ try {
+ return Integer.parseInt(integerString);
+ } catch (NumberFormatException e) {
+ // ignore
+ }
+ return 0;
+ }
+
private void setAttribute(ITask task, String key, TaskAttribute attribute) {
if (attribute != null) {
task.setAttribute(key, attribute.getValue());
diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/Messages.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/Messages.java
index 78d9848c..21d3cb5e 100644
--- a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/Messages.java
+++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/Messages.java
@@ -17,10 +17,14 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.gerrit.core.messages"; //$NON-NLS-1$
+ public static String GerritConnector_CodeReviewTooltip;
+
public static String GerritConnector_Executing_query;
public static String GerritConnector_Label;
+ public static String GerritConnector_VerifiedTooltip;
+
public static String GerritQueryResultSchema_Branch;
public static String GerritQueryResultSchema_ChangeId;
diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/messages.properties b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/messages.properties
index ab2301ad..aa719e1c 100644
--- a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/messages.properties
+++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/messages.properties
@@ -9,8 +9,10 @@
# Tasktop Technologies - initial API and implementation
# Marc-Andre Laperle (Ericsson) - Add topic
###############################################################################
+GerritConnector_CodeReviewTooltip=Code Review:
GerritConnector_Executing_query=Executing query
GerritConnector_Label=Gerrit Code Review (supports {0} to {1})
+GerritConnector_VerifiedTooltip=Verified:
GerritQueryResultSchema_Branch=Branch
GerritQueryResultSchema_ChangeId=Change-Id
GerritQueryResultSchema_Project=Project

Back to the top