Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Ross2015-09-19 14:06:52 -0400
committerSam Davis2015-12-09 00:58:39 -0500
commit625b620692d84e60d6645dcc2a1c2efb709cec66 (patch)
treefd9e8d466a8d58f59082735f1885097f297288f2 /org.eclipse.mylyn.reviews.ui/src
parente0013a13afdb92c00776bdd85794caccf8c7eae7 (diff)
downloadorg.eclipse.mylyn.reviews-625b620692d84e60d6645dcc2a1c2efb709cec66.tar.gz
org.eclipse.mylyn.reviews-625b620692d84e60d6645dcc2a1c2efb709cec66.tar.xz
org.eclipse.mylyn.reviews-625b620692d84e60d6645dcc2a1c2efb709cec66.zip
479800: [UCOSP] create a BuildStatusAttributeEditor and use it to show
build status Change-Id: I07dcde5bd907cf22d1521301c68c0d04c2277883 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=479800 Signed-off-by: Kyle Ross <kross11@ubishops.ca>
Diffstat (limited to 'org.eclipse.mylyn.reviews.ui/src')
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/ReviewsImages.java2
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/BuildStatusAttributeEditor.java129
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/ReviewSetContentSection.java102
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/ReviewSetSection.java2
4 files changed, 160 insertions, 75 deletions
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/ReviewsImages.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/ReviewsImages.java
index 49e5b844..e224e31a 100644
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/ReviewsImages.java
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/ReviewsImages.java
@@ -51,6 +51,8 @@ public class ReviewsImages {
public static final ImageDescriptor UNKNOWN = create("obj12/unknown.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor UNSTABLE = create("obj12/unstable.png"); //$NON-NLS-1$
+
public static final ImageDescriptor BLANK = create("obj12/blank.gif"); //$NON-NLS-1$
public static final ImageDescriptor NEXT_COMMENT = create("elcl16/nxtanmly_menu.png"); //$NON-NLS-1$
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/BuildStatusAttributeEditor.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/BuildStatusAttributeEditor.java
new file mode 100644
index 00000000..56f77792
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/BuildStatusAttributeEditor.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Tasktop Technologies 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:
+ * Kyle Ross - Initial implementation
+ * Vaughan Hilts - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.reviews.ui.spi.editor;
+
+import org.eclipse.jface.action.LegacyActionTools;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.layout.LayoutConstants;
+import org.eclipse.mylyn.commons.ui.CommonImages;
+import org.eclipse.mylyn.commons.ui.compatibility.CommonColors;
+import org.eclipse.mylyn.commons.workbench.browser.BrowserUtil;
+import org.eclipse.mylyn.commons.workbench.forms.ScalingHyperlink;
+import org.eclipse.mylyn.internal.reviews.ui.ReviewsImages;
+import org.eclipse.mylyn.reviews.internal.core.BuildResult;
+import org.eclipse.mylyn.reviews.internal.core.TaskBuildStatusMapper;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.events.HyperlinkAdapter;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class BuildStatusAttributeEditor extends AbstractAttributeEditor {
+
+ public BuildStatusAttributeEditor(TaskDataModel dataModel, TaskAttribute taskAttribute) {
+ super(dataModel, taskAttribute);
+ }
+
+ @Override
+ public void createControl(Composite parent, FormToolkit toolkit) {
+
+ Composite layoutComposite = toolkit.createComposite(parent);
+ GridLayoutFactory.fillDefaults()
+ .spacing(LayoutConstants.getSpacing().x, 0)
+ .numColumns(2)
+ .applyTo(layoutComposite);
+ GridDataFactory.fillDefaults().indent(28, 0).applyTo(layoutComposite);
+
+ TaskAttribute buildAttribute = getTaskAttribute();
+ int numberOfBuilds = buildAttribute.getAttributes().size();
+
+ for (int i = 0; i < numberOfBuilds; i++) {
+ String buildKey = TaskBuildStatusMapper.ATTR_ID_BUILD_RESULT + i;
+
+ TaskAttribute currentBuildAttribute = buildAttribute.getAttribute(buildKey);
+ if (currentBuildAttribute == null) {
+ return;
+ }
+
+ TaskAttribute statusAttribute = currentBuildAttribute.getAttribute(TaskBuildStatusMapper.STATUS_ATTRIBUTE_KEY);
+ TaskAttribute urlAttribute = currentBuildAttribute.getAttribute(TaskBuildStatusMapper.URL_ATTRIBUTE_KEY);
+ if (statusAttribute == null || urlAttribute == null) {
+ return;
+ }
+ String statusValue = statusAttribute.getValue();
+ final String urlValue = urlAttribute.getValue();
+
+ ScalingHyperlink buildLink = new ScalingHyperlink(layoutComposite, SWT.READ_ONLY);
+ buildLink.setText(urlValue);
+ buildLink.setForeground(CommonColors.HYPERLINK_WIDGET);
+
+ buildLink.registerMouseTrackListener();
+ buildLink.addHyperlinkListener(new HyperlinkAdapter() {
+ @Override
+ public void linkActivated(HyperlinkEvent event) {
+ BrowserUtil.openUrl(urlValue);
+ }
+ });
+
+ CLabel buildText = new CLabel(layoutComposite, SWT.NONE);
+ setControl(layoutComposite);
+
+ buildText.setText(statusValue);
+ buildText.setImage(getImageForBuildStatus(statusValue));
+ }
+ }
+
+ @Override
+ public void decorateIncoming(Color color) {
+ TaskAttribute buildAttribute = getTaskAttribute();
+ int numberOfBuilds = getTaskAttribute().getAttributes().size();
+
+ for (int i = 0; i < numberOfBuilds; i++) {
+ String buildKey = TaskBuildStatusMapper.ATTR_ID_BUILD_RESULT + i;
+ TaskAttribute currentBuildAttribute = buildAttribute.getAttribute(buildKey);
+ if (currentBuildAttribute == null) {
+ return;
+ }
+ Composite layoutComposite = (Composite) getControl();
+
+ if (this.getModel().hasIncomingChanges(currentBuildAttribute)) {
+ layoutComposite.getChildren()[2 * i].setBackground(color);
+ layoutComposite.getChildren()[2 * i + 1].setBackground(color);
+ }
+ }
+ }
+
+ @Override
+ public String getLabel() {
+ String label = Messages.ReviewSet_BuildHeader;
+ return (label != null) ? LegacyActionTools.escapeMnemonics(label) : ""; //$NON-NLS-1$
+ }
+
+ private Image getImageForBuildStatus(String status) {
+ if (status.equals(BuildResult.BuildStatus.SUCCESS.toString())) {
+ return CommonImages.getImage(ReviewsImages.APPROVED);
+ } else if (status.equals(BuildResult.BuildStatus.STARTED.toString())) {
+ return CommonImages.getImage(ReviewsImages.UNKNOWN);
+ } else if (status.equals(BuildResult.BuildStatus.UNSTABLE.toString())) {
+ return CommonImages.getImage(ReviewsImages.UNSTABLE);
+ }
+ return CommonImages.getImage(ReviewsImages.REJECTED);
+ }
+}
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 e7665140..fd215375 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
@@ -17,7 +17,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
-import java.util.Map.Entry;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
@@ -31,11 +30,8 @@ import org.eclipse.jface.viewers.OpenEvent;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.ToolTip;
-import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.commons.ui.compatibility.CommonColors;
-import org.eclipse.mylyn.commons.workbench.browser.BrowserUtil;
import org.eclipse.mylyn.commons.workbench.forms.ScalingHyperlink;
-import org.eclipse.mylyn.internal.reviews.ui.ReviewsImages;
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;
@@ -45,12 +41,12 @@ import org.eclipse.mylyn.reviews.core.model.IReview;
import org.eclipse.mylyn.reviews.core.model.IReviewItemSet;
import org.eclipse.mylyn.reviews.core.spi.remote.emf.RemoteEmfConsumer;
import org.eclipse.mylyn.reviews.core.spi.remote.emf.RemoteEmfObserver;
-import org.eclipse.mylyn.reviews.internal.core.BuildResult.BuildStatus;
+import org.eclipse.mylyn.reviews.internal.core.TaskBuildStatusMapper;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
@@ -106,9 +102,12 @@ public class ReviewSetContentSection {
private final RemoteEmfObserver<IRepository, IReview, String, Date> reviewObserver;
- public ReviewSetContentSection(ReviewSetSection parentSection, final IReviewItemSet set) {
+ private final AbstractTaskEditorPage page;
+
+ public ReviewSetContentSection(ReviewSetSection parentSection, final IReviewItemSet set, AbstractTaskEditorPage page) {
this.parentSection = parentSection;
this.set = set;
+ this.page = page;
int style = ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT
| ExpandableComposite.LEFT_TEXT_CLIENT_ALIGNMENT;
section = parentSection.getToolkit().createSection(parentSection.getComposite(), style);
@@ -117,15 +116,15 @@ public class ReviewSetContentSection {
section.setTitleBarForeground(parentSection.getToolkit().getColors().getColor(IFormColors.TITLE));
parentSection.addTextClient(parentSection.getToolkit(), section, "", false); //$NON-NLS-1$
- final RemoteEmfConsumer<IReviewItemSet, List<IFileItem>, String, ?, ?, Long> itemSetConsumer = getParentSection()
- .getReviewEditorPage()
+ final RemoteEmfConsumer<IReviewItemSet, List<IFileItem>, String, ?, ?, Long> itemSetConsumer = getParentSection().getReviewEditorPage()
.getFactoryProvider()
.getReviewItemSetContentFactory()
.getConsumerForLocalKey(set, set.getId());
itemListObserver.setConsumer(itemSetConsumer);
- final RemoteEmfConsumer<IRepository, IReview, String, ?, ?, Date> reviewConsumer = getParentSection()
- .getReviewEditorPage().getFactoryProvider().getReviewFactory().getConsumerForModel(
- set.getReview().getRepository(), set.getReview());
+ final RemoteEmfConsumer<IRepository, IReview, String, ?, ?, Date> reviewConsumer = getParentSection().getReviewEditorPage()
+ .getFactoryProvider()
+ .getReviewFactory()
+ .getConsumerForModel(set.getReview().getRepository(), set.getReview());
reviewObserver = new RemoteEmfObserver<IRepository, IReview, String, Date>() {
@Override
public void updated(boolean modified) {
@@ -173,8 +172,9 @@ public class ReviewSetContentSection {
message += " " + Messages.Reviews_RetrievingContents; //$NON-NLS-1$
}
} else {
- message = NLS.bind(Messages.Reviews_UpdateFailure_X,
- itemListObserver.getConsumer().getStatus().getMessage());
+ message = NLS.bind(Messages.Reviews_UpdateFailure_X, itemListObserver.getConsumer()
+ .getStatus()
+ .getMessage());
}
AbstractReviewSection.appendMessage(getSection(), message);
@@ -200,10 +200,17 @@ public class ReviewSetContentSection {
GridDataFactory.fillDefaults().span(4, 1).grab(true, true).applyTo(fullWidth);
GridLayoutFactory.fillDefaults().numColumns(2).applyTo(fullWidth);
- // We should only show the build labels in the case where there are any for this patch set
- if (getPatchSetBuildAttribute() != null) {
- createTitleLabel(fullWidth, colors, Messages.ReviewSet_BuildHeader, SWT.NONE);
- createBuildLabels(composite, colors);
+ TaskAttribute buildAttribute = parentSection.getTaskData().getRoot().getAttribute("PATCH_SET-" + set.getId()); //$NON-NLS-1$
+ if (buildAttribute != null) {
+ Composite buildComposite = parentSection.getToolkit().createComposite(composite);
+ GridLayoutFactory.fillDefaults().numColumns(2).applyTo(buildComposite);
+ GridDataFactory.fillDefaults().span(2, 1).applyTo(buildComposite);
+ AbstractAttributeEditor editor = parentSection.getTaskEditorPage()
+ .getAttributeEditorFactory()
+ .createEditor(TaskBuildStatusMapper.BUILD_RESULT_TYPE, buildAttribute);
+ editor.createLabelControl(buildComposite, parentSection.getToolkit());
+ editor.createControl(buildComposite, parentSection.getToolkit());
+ getTaskEditorPage().getAttributeEditorToolkit().adapt(editor);
}
tableContainer = new Composite(composite, SWT.NONE);
@@ -219,51 +226,8 @@ public class ReviewSetContentSection {
parentSection.getTaskEditorPage().reflow();
}
- private void createBuildLabels(Composite composite, FormColors colors) {
- TaskAttribute buildAttribute = getPatchSetBuildAttribute();
- if (buildAttribute == null) {
- return;
- }
-
- int numberOfBuilds = buildAttribute.getAttributes().size();
-
- for (Entry<String, TaskAttribute> buildEntry : buildAttribute.getAttributes().entrySet()) {
-
- TaskAttribute currentBuildAttribute = buildEntry.getValue();
-
- String statusValue = currentBuildAttribute.getAttribute("STATUS").getValue(); //$NON-NLS-1$
- final String urlValue = currentBuildAttribute.getAttribute("URL").getValue(); //$NON-NLS-1$
-
- if (statusValue == null | urlValue == null) {
- continue;
- }
-
- ScalingHyperlink buildLink = new ScalingHyperlink(composite, SWT.READ_ONLY);
- buildLink.setText(urlValue);
- buildLink.setForeground(CommonColors.HYPERLINK_WIDGET);
-
- buildLink.registerMouseTrackListener();
- buildLink.addHyperlinkListener(new HyperlinkAdapter() {
- @Override
- public void linkActivated(HyperlinkEvent event) {
- BrowserUtil.openUrl(urlValue);
- }
- });
-
- CLabel buildText = new CLabel(composite, SWT.RIGHT_TO_LEFT);
- buildText.setText(statusValue);
- buildText.setImage(this.getImageForBuildStatus(statusValue));
-
- }
-
- }
-
- private TaskAttribute getPatchSetBuildAttribute() {
- String patchSetId = this.set.getId();
- TaskAttribute buildAttribute = this.parentSection.getTaskData()
- .getRoot()
- .getAttribute("PATCH_SET-" + patchSetId); //$NON-NLS-1$
- return buildAttribute;
+ private AbstractTaskEditorPage getTaskEditorPage() {
+ return page;
}
private void createAuthorLabel(Composite composite, FormColors colors) {
@@ -437,16 +401,6 @@ public class ReviewSetContentSection {
}
}
- private Image getImageForBuildStatus(String status) {
- if (status.equals(BuildStatus.SUCCESS.toString())) {
- return CommonImages.getImage(ReviewsImages.APPROVED);
- } else if (status.equals(BuildStatus.STARTED.toString())) {
- return CommonImages.getImage(ReviewsImages.UNKNOWN);
- }
-
- return CommonImages.getImage(ReviewsImages.REJECTED);
- }
-
public void createButtons() {
if (!actionContainer.isDisposed()) {
for (Control oldActionControl : actionContainer.getChildren()) {
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/ReviewSetSection.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/ReviewSetSection.java
index 09496399..985bb7bb 100644
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/ReviewSetSection.java
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/spi/editor/ReviewSetSection.java
@@ -65,7 +65,7 @@ public abstract class ReviewSetSection extends AbstractReviewSection {
for (IReviewItem item : getReview().getSets()) {
if (item instanceof IReviewItemSet) {
IReviewItemSet set = (IReviewItemSet) item;
- ReviewSetContentSection subSection = new ReviewSetContentSection(this, set);
+ ReviewSetContentSection subSection = new ReviewSetContentSection(this, set, getTaskEditorPage());
reviewSetSections.add(subSection);
}
}

Back to the top