summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiles Parker2012-12-06 18:17:23 (EST)
committer Miles Parker2012-12-19 15:23:07 (EST)
commit421745025f4468d6c2db32623f1ce11892f41e45 (patch)
tree5fab72ee9ce18dba13f53a74779a67961e12f98c
parentfd14cd8aa6ccd27569fd32079c8133ca36f45153 (diff)
downloadorg.eclipse.mylyn.reviews-421745025f4468d6c2db32623f1ce11892f41e45.zip
org.eclipse.mylyn.reviews-421745025f4468d6c2db32623f1ce11892f41e45.tar.gz
org.eclipse.mylyn.reviews-421745025f4468d6c2db32623f1ce11892f41e45.tar.bz2
344108: support replying to review commentsrefs/changes/89/9089/7
•Add new comment part to editor •Copy comment part to publish comments dialog •Clear comment part following successful publish •Clear outgoing state following successful publish •Migrate existing reviews to support comments •Added size hint to publish dialog message editor Change-Id: Ib07d5c7b190baab34f2eb2ef38141cda25dc41e0 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=344108
-rw-r--r--org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritTaskDataHandler.java9
-rw-r--r--org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritTaskSchema.java1
-rw-r--r--org.eclipse.mylyn.gerrit.ui/src/org/eclipse/mylyn/internal/gerrit/ui/editor/PatchSetSection.java20
-rw-r--r--org.eclipse.mylyn.gerrit.ui/src/org/eclipse/mylyn/internal/gerrit/ui/operations/PublishDialog.java10
4 files changed, 37 insertions, 3 deletions
diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritTaskDataHandler.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritTaskDataHandler.java
index fa06197..e3e810a 100644
--- a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritTaskDataHandler.java
+++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritTaskDataHandler.java
@@ -188,6 +188,15 @@ public class GerritTaskDataHandler extends AbstractTaskDataHandler {
setAttributeValue(data, schema.CAN_PUBLISH, Boolean.toString(canPublish));
}
+ @Override
+ public void migrateTaskData(TaskRepository repository, TaskData taskData) {
+ super.migrateTaskData(repository, taskData);
+ //Support 1.1.0 commenting capability see https://bugs.eclipse.org/bugs/show_bug.cgi?id=344108
+ if (taskData.getRoot().getAttribute(GerritTaskSchema.getDefault().NEW_COMMENT.getKey()) == null) {
+ taskData.getRoot().createAttribute(GerritTaskSchema.getDefault().NEW_COMMENT.getKey());
+ }
+ }
+
public void updateTaskData(TaskRepository repository, TaskData data, GerritQueryResult changeInfo) {
GerritQueryResultSchema schema = GerritQueryResultSchema.getDefault();
setAttributeValue(data, schema.KEY, changeInfo.getId().substring(0, Math.min(9, changeInfo.getId().length())));
diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritTaskSchema.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritTaskSchema.java
index fc38355..203a3bf 100644
--- a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritTaskSchema.java
+++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritTaskSchema.java
@@ -41,4 +41,5 @@ public class GerritTaskSchema extends GerritQueryResultSchema {
public final Field CAN_PUBLISH = createField("org.eclipse.gerrit.CanPublish", "Publish", TaskAttribute.TYPE_BOOLEAN);
+ public final Field NEW_COMMENT = inheritFrom(parent.NEW_COMMENT).create();
}
diff --git a/org.eclipse.mylyn.gerrit.ui/src/org/eclipse/mylyn/internal/gerrit/ui/editor/PatchSetSection.java b/org.eclipse.mylyn.gerrit.ui/src/org/eclipse/mylyn/internal/gerrit/ui/editor/PatchSetSection.java
index bacead7..54522f4 100644
--- a/org.eclipse.mylyn.gerrit.ui/src/org/eclipse/mylyn/internal/gerrit/ui/editor/PatchSetSection.java
+++ b/org.eclipse.mylyn.gerrit.ui/src/org/eclipse/mylyn/internal/gerrit/ui/editor/PatchSetSection.java
@@ -21,7 +21,9 @@ import java.util.List;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.CompareUI;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
@@ -64,10 +66,13 @@ import org.eclipse.mylyn.internal.gerrit.ui.operations.RestoreDialog;
import org.eclipse.mylyn.internal.gerrit.ui.operations.SubmitDialog;
import org.eclipse.mylyn.internal.reviews.ui.compare.FileItemCompareEditorInput;
import org.eclipse.mylyn.internal.tasks.ui.editors.EditorUtil;
+import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.reviews.core.model.IFileItem;
import org.eclipse.mylyn.reviews.core.model.IReviewItem;
import org.eclipse.mylyn.reviews.core.model.IReviewItemSet;
import org.eclipse.mylyn.reviews.internal.core.model.ReviewsPackage;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
@@ -406,8 +411,21 @@ public class PatchSetSection extends AbstractGerritSection {
}
protected void doPublish(PatchSetPublishDetail publishDetail) {
- PublishDialog dialog = new PublishDialog(getShell(), getTask(), publishDetail, addedDrafts);
+ TaskAttribute comment = getTaskData().getRoot().getAttribute(TaskAttribute.COMMENT_NEW);
+ String editorCommentText = comment != null ? comment.getValue() : "";
+ PublishDialog dialog = new PublishDialog(getShell(), getTask(), publishDetail, addedDrafts, editorCommentText);
openOperationDialog(dialog);
+ if (dialog.getReturnCode() == Window.OK && comment != null) {
+ comment.clearValues();
+ getTaskEditorPage().doSave(new NullProgressMonitor());
+ try {
+ TasksUi.getTaskDataManager().discardEdits(getTask());
+ } catch (CoreException e) {
+ Status status = new Status(IStatus.ERROR, GerritUiPlugin.PLUGIN_ID,
+ "Error while clearing task status.", e);
+ TasksUiInternal.displayStatus("Clear outgoing task status failed", status);
+ }
+ }
}
protected void doFetch(ChangeDetail changeDetail, PatchSetDetail patchSetDetail) {
diff --git a/org.eclipse.mylyn.gerrit.ui/src/org/eclipse/mylyn/internal/gerrit/ui/operations/PublishDialog.java b/org.eclipse.mylyn.gerrit.ui/src/org/eclipse/mylyn/internal/gerrit/ui/operations/PublishDialog.java
index 6a5c8e4..8cba481 100644
--- a/org.eclipse.mylyn.gerrit.ui/src/org/eclipse/mylyn/internal/gerrit/ui/operations/PublishDialog.java
+++ b/org.eclipse.mylyn.gerrit.ui/src/org/eclipse/mylyn/internal/gerrit/ui/operations/PublishDialog.java
@@ -61,10 +61,14 @@ public class PublishDialog extends GerritOperationDialog {
private final int addedDrafts;
- public PublishDialog(Shell parentShell, ITask task, PatchSetPublishDetail publishDetail, int addedDrafts) {
+ private final String editorCommentText;
+
+ public PublishDialog(Shell parentShell, ITask task, PatchSetPublishDetail publishDetail, int addedDrafts,
+ String editorCommentText) {
super(parentShell, task);
this.publishDetail = publishDetail;
this.addedDrafts = addedDrafts;
+ this.editorCommentText = editorCommentText;
this.approvalButtons = new ArrayList<Button>();
setNeedsConfig(true);
}
@@ -105,7 +109,9 @@ public class PublishDialog extends GerritOperationDialog {
approvalComposite.setLayout(layout);
messageEditor = createRichTextEditor(composite, "");
- GridDataFactory.fillDefaults().grab(true, true).minSize(400, 150).applyTo(messageEditor.getControl());
+ GridDataFactory.fillDefaults().grab(true, true).hint(600, 200).applyTo(messageEditor.getControl());
+ messageEditor.setText(editorCommentText);
+ messageEditor.getViewer().setSelectedRange(editorCommentText.length(), 0);
messageEditor.getControl().setFocus();
statusLabel = new Label(composite, SWT.NONE);