Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Folk2015-01-21 14:25:06 -0500
committerSam Davis2015-01-22 16:43:07 -0500
commit45462fb49ff763dc604eccfb22b79dec75070726 (patch)
treeec8dbdda0933cdcfba75e6ed8527fe98c8362262 /org.eclipse.mylyn.reviews.ui/src
parenta77d15f6db542c7c4d1cf9599e5f630a408199b6 (diff)
downloadorg.eclipse.mylyn.reviews-45462fb49ff763dc604eccfb22b79dec75070726.tar.gz
org.eclipse.mylyn.reviews-45462fb49ff763dc604eccfb22b79dec75070726.tar.xz
org.eclipse.mylyn.reviews-45462fb49ff763dc604eccfb22b79dec75070726.zip
393788: show parent commit of each patch set in review editor
Change-Id: I375bce95079c4eae6fbb21e26bc83dcd01fb85bf Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=393788 Signed-off-by: Nicholas Folk <Nicholas.folk@tasktop.com>
Diffstat (limited to 'org.eclipse.mylyn.reviews.ui/src')
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/Messages.java2
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/ReviewSetContentSection.java84
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/messages.properties1
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/factories/AbstractReviewItemSetUiFactoryProvider.java4
4 files changed, 80 insertions, 11 deletions
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/Messages.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/Messages.java
index bfa81cc0..105965d1 100644
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/Messages.java
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/Messages.java
@@ -42,6 +42,8 @@ public class Messages extends NLS {
public static String ReviewSetContentSection_Committer;
+ public static String ReviewSetContentSection_Parents;
+
public static String ReviewSetContentSection_Ref;
public static String ReviewSetContentSection_Unspecified;
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/ReviewSetContentSection.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/ReviewSetContentSection.java
index fb8e407c..87821cb3 100644
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/ReviewSetContentSection.java
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/ReviewSetContentSection.java
@@ -13,12 +13,14 @@
package org.eclipse.mylyn.reviews.ui.spi.editor;
import java.text.DateFormat;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.layout.LayoutConstants;
import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
import org.eclipse.jface.viewers.IOpenListener;
@@ -32,6 +34,7 @@ import org.eclipse.mylyn.commons.ui.compatibility.CommonColors;
import org.eclipse.mylyn.commons.workbench.forms.ScalingHyperlink;
import org.eclipse.mylyn.internal.reviews.ui.providers.ReviewsLabelProvider;
import org.eclipse.mylyn.internal.tasks.ui.editors.EditorUtil;
+import org.eclipse.mylyn.reviews.core.model.ICommit;
import org.eclipse.mylyn.reviews.core.model.IFileItem;
import org.eclipse.mylyn.reviews.core.model.IRepository;
import org.eclipse.mylyn.reviews.core.model.IReview;
@@ -172,11 +175,35 @@ public class ReviewSetContentSection {
void createMainSection() {
Composite composite = parentSection.getToolkit().createComposite(section);
- GridLayoutFactory.fillDefaults().numColumns(2).applyTo(composite);
+ GridLayoutFactory.fillDefaults().numColumns(2).spacing(60, LayoutConstants.getSpacing().y).applyTo(composite);
+ Composite leftColumn = parentSection.getToolkit().createComposite(composite);
+ GridLayoutFactory.fillDefaults().numColumns(2).applyTo(leftColumn);
+ Composite rightColumn = parentSection.getToolkit().createComposite(composite);
+ GridLayoutFactory.fillDefaults().numColumns(2).applyTo(rightColumn);
section.setClient(composite);
+ FormColors colors = parentSection.getToolkit().getColors();
+
+ createAuthorLabel(leftColumn, colors);
+ createCommitterLabel(leftColumn, colors);
+ createCommitLink(rightColumn, colors);
+ createRefLabel(rightColumn, colors);
+ createParentsLinks(composite, colors);
+
+ tableContainer = new Composite(composite, SWT.NONE);
+ tableContainer.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY));
+ GridDataFactory.fillDefaults().span(4, 1).grab(true, true).applyTo(tableContainer);
+ GridLayoutFactory.fillDefaults().numColumns(2).applyTo(tableContainer);
+
+ actionContainer = new Composite(composite, SWT.NONE);
+ GridDataFactory.fillDefaults().span(4, 1).grab(true, true).applyTo(actionContainer);
+ GridLayoutFactory.fillDefaults().numColumns(4).applyTo(actionContainer);
+ createButtons();
+ parentSection.getTaskEditorPage().reflow();
+ }
+
+ private void createAuthorLabel(Composite composite, FormColors colors) {
Label authorLabel = new Label(composite, SWT.NONE);
- FormColors colors = parentSection.getToolkit().getColors();
authorLabel.setForeground(colors.getColor(IFormColors.TITLE));
authorLabel.setText(Messages.ReviewSetContentSection_Author);
@@ -186,7 +213,9 @@ public class ReviewSetContentSection {
} else {
authorText.setText(Messages.ReviewSetContentSection_Unspecified);
}
+ }
+ private void createCommitterLabel(Composite composite, FormColors colors) {
Label committerLabel = new Label(composite, SWT.NONE);
committerLabel.setForeground(colors.getColor(IFormColors.TITLE));
committerLabel.setText(Messages.ReviewSetContentSection_Committer);
@@ -197,7 +226,9 @@ public class ReviewSetContentSection {
} else {
committerText.setText(Messages.ReviewSetContentSection_Unspecified);
}
+ }
+ private void createCommitLink(Composite composite, FormColors colors) {
Label commitLabel = new Label(composite, SWT.NONE);
commitLabel.setForeground(colors.getColor(IFormColors.TITLE));
commitLabel.setText(Messages.ReviewSetContentSection_Commit);
@@ -214,25 +245,56 @@ public class ReviewSetContentSection {
.execute();
}
});
+ }
+ private void createRefLabel(Composite composite, FormColors colors) {
Label refLabel = new Label(composite, SWT.NONE);
refLabel.setForeground(colors.getColor(IFormColors.TITLE));
refLabel.setText(Messages.ReviewSetContentSection_Ref);
Text refText = new Text(composite, SWT.READ_ONLY);
refText.setText(set.getReference());
+ }
- tableContainer = new Composite(composite, SWT.NONE);
- tableContainer.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY));
- GridDataFactory.fillDefaults().span(2, 1).grab(true, true).applyTo(tableContainer);
- GridLayoutFactory.fillDefaults().numColumns(2).applyTo(tableContainer);
+ private void createParentsLinks(Composite composite, FormColors colors) {
+ if (set.getParentCommits().isEmpty()) {
+ return;// for Gerrit versions earlier than 2.8 we don't support getting the parents
+ }
+ Composite parentsComposite = new Composite(composite, SWT.NONE);
+ GridLayoutFactory.fillDefaults().numColumns(3).applyTo(parentsComposite);
+ GridDataFactory.fillDefaults().span(2, 1).applyTo(parentsComposite);
+ Label parentsLabel = new Label(parentsComposite, SWT.NONE);
+ parentsLabel.setForeground(colors.getColor(IFormColors.TITLE));
+ parentsLabel.setText(Messages.ReviewSetContentSection_Parents);
+
+ final List<String> parentCommitIds = new ArrayList<String>();
+ for (ICommit commit : set.getParentCommits()) {
+ parentCommitIds.add(commit.getId());
+ }
- actionContainer = new Composite(composite, SWT.NONE);
- GridDataFactory.fillDefaults().span(2, 1).grab(true, true).applyTo(actionContainer);
- GridLayoutFactory.fillDefaults().numColumns(1).applyTo(actionContainer);
- createButtons();
+ ScalingHyperlink parentOne = new ScalingHyperlink(parentsComposite, SWT.READ_ONLY);
+ if (parentCommitIds.size() > 0) {
+ addParentCommitHyperlink(parentOne, parentCommitIds.get(0));
+ }
- parentSection.getTaskEditorPage().reflow();
+ if (parentCommitIds.size() == 2 && parentCommitIds.get(1) != null) {
+ ScalingHyperlink parentTwo = new ScalingHyperlink(parentsComposite, SWT.READ_ONLY);
+ addParentCommitHyperlink(parentTwo, parentCommitIds.get(1));
+ }
+ }
+
+ private void addParentCommitHyperlink(ScalingHyperlink commit, final String commitId) {
+ commit.setText(commitId);
+ commit.setForeground(CommonColors.HYPERLINK_WIDGET);
+ commit.registerMouseTrackListener();
+ commit.addHyperlinkListener(new HyperlinkAdapter() {
+ @Override
+ public void linkActivated(HyperlinkEvent event) {
+ getParentSection().getUiFactoryProvider()
+ .getOpenParentCommitFactory(ReviewSetContentSection.this.getParentSection(), set, commitId)
+ .execute();
+ }
+ });
}
public void createItemSetTable() {
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/messages.properties b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/messages.properties
index fdcc2d7d..562e96c6 100644
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/messages.properties
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/messages.properties
@@ -21,6 +21,7 @@ Reviews_UpdateFailure_X=Retrieval problem: {0}
ReviewSetContentSection_Author=Author
ReviewSetContentSection_Commit=Commit
ReviewSetContentSection_Committer=Committer
+ReviewSetContentSection_Parents=Parent(s)
ReviewSetContentSection_Ref=Ref
ReviewSetContentSection_Unspecified=Unspecified
ReviewSetContentSection_X_comma_Y_Comments={0}, {1} Comments
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/factories/AbstractReviewItemSetUiFactoryProvider.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/factories/AbstractReviewItemSetUiFactoryProvider.java
index 526d265e..f4dba7ea 100644
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/factories/AbstractReviewItemSetUiFactoryProvider.java
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/factories/AbstractReviewItemSetUiFactoryProvider.java
@@ -25,4 +25,8 @@ public abstract class AbstractReviewItemSetUiFactoryProvider extends AbstractUiF
IFileItem item);
public abstract AbstractUiFactory<IReviewItemSet> getOpenCommitFactory(IUiContext context, IReviewItemSet set);
+
+ public abstract AbstractUiFactory<IReviewItemSet> getOpenParentCommitFactory(IUiContext context,
+ IReviewItemSet set, String commitId);
+
}

Back to the top