summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-04-08 13:56:08 (EDT)
committerChris Aniszczyk2011-04-10 14:09:08 (EDT)
commitccaf4c9baf049ac55745df76c77a82c45cc51cf5 (patch)
tree2da2d55bc32ecf3f661abb5002bfdbb79a82d1b7
parentca6bf1817ac5a15d998395ea28a19aa4fc1f07bd (diff)
downloadegit-github-ccaf4c9baf049ac55745df76c77a82c45cc51cf5.zip
egit-github-ccaf4c9baf049ac55745df76c77a82c45cc51cf5.tar.gz
egit-github-ccaf4c9baf049ac55745df76c77a82c45cc51cf5.tar.bz2
Add support for displaying an issue's labelsrefs/changes/28/3028/3
Change-Id: I97b56c9fbd4f6c0962a0275c451554786e13e03b Signed-off-by: Kevin Sawicki <kevin@github.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubIssue.java22
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskAttributes.java3
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskDataHandler.java30
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubIssueLabelPart.java65
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubTaskEditorPage.java7
5 files changed, 119 insertions, 8 deletions
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubIssue.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubIssue.java
index f6914b0..05ac5a0 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubIssue.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubIssue.java
@@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.mylyn.github.internal;
+import java.util.List;
+
/**
* GitHub Issue object to hold all the properties of an individual issue.
@@ -30,6 +32,8 @@ public class GitHubIssue {
private int comments;
+ private List<String> labels;
+
/**
* open, closed
*/
@@ -202,4 +206,22 @@ public class GitHubIssue {
this.comments = comments;
}
+ /**
+ * Get labels applied to issue
+ *
+ * @return labels
+ */
+ public List<String> getLabels() {
+ return this.labels;
+ }
+
+ /**
+ * Set labels applied to issue
+ *
+ * @param labels
+ */
+ public void setLabels(List<String> labels) {
+ this.labels = labels;
+ }
+
}
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskAttributes.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskAttributes.java
index c582778..ca0ead3 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskAttributes.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskAttributes.java
@@ -26,7 +26,8 @@ public enum GitHubTaskAttributes {
STATUS("Status:",TaskAttribute.STATUS,TaskAttribute.TYPE_SHORT_TEXT,true,false,true),
REPORTER("Reporter:", TaskAttribute.USER_REPORTER, TaskAttribute.TYPE_PERSON, true, true, false),
- COMMENT_NEW("Comment:", TaskAttribute.COMMENT_NEW, TaskAttribute.TYPE_LONG_RICH_TEXT, false, false, false)
+ COMMENT_NEW("Comment:", TaskAttribute.COMMENT_NEW, TaskAttribute.TYPE_LONG_RICH_TEXT, false, false, false),
+ LABELS("Labels:", "github.issue.labels", TaskAttribute.TYPE_MULTI_SELECT, true, true, false)
;
private final String id;
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskDataHandler.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskDataHandler.java
index 3a54748..c762d59 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskDataHandler.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/GitHubTaskDataHandler.java
@@ -15,6 +15,7 @@ package org.eclipse.mylyn.github.internal;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Set;
@@ -77,6 +78,7 @@ public class GitHubTaskDataHandler extends AbstractTaskDataHandler {
createAttribute(data, GitHubTaskAttributes.CLOSED_DATE, toLocalDate(issue.getClosed_at()));
createAttribute(data, GitHubTaskAttributes.REPORTER, issue.getUser());
createAttribute(data, GitHubTaskAttributes.COMMENT_NEW, "");
+ createAttribute(data, GitHubTaskAttributes.LABELS, issue.getLabels());
if (isPartial(data)) {
data.setPartial(true);
@@ -208,20 +210,34 @@ public class GitHubTaskDataHandler extends AbstractTaskDataHandler {
return attribute==null?null:attribute.getValue();
}
- private void createAttribute(TaskData data, GitHubTaskAttributes attribute, String value) {
+ private TaskAttribute createAttribute(TaskData data,
+ GitHubTaskAttributes attribute) {
TaskAttribute attr = data.getRoot().createAttribute(attribute.getId());
TaskAttributeMetaData metaData = attr.getMetaData();
- metaData.defaults()
- .setType(attribute.getType())
- .setKind(attribute.getKind())
- .setLabel(attribute.getLabel())
- .setReadOnly(attribute.isReadOnly());
+ metaData.defaults().setType(attribute.getType())
+ .setKind(attribute.getKind()).setLabel(attribute.getLabel())
+ .setReadOnly(attribute.isReadOnly());
+ return attr;
+ }
+ private void createAttribute(TaskData data, GitHubTaskAttributes attribute,
+ String value) {
+ TaskAttribute attr = createAttribute(data, attribute);
if (value != null) {
attr.addValue(value);
}
}
+ private void createAttribute(TaskData data, GitHubTaskAttributes attribute,
+ Collection<String> values) {
+ TaskAttribute attr = createAttribute(data, attribute);
+ if (values != null) {
+ for (String value : values) {
+ attr.addValue(value);
+ }
+ }
+ }
+
@Override
public boolean initializeTaskData(TaskRepository repository, TaskData data,
ITaskMapping initializationData, IProgressMonitor monitor)
@@ -231,7 +247,7 @@ public class GitHubTaskDataHandler extends AbstractTaskDataHandler {
for (GitHubTaskAttributes attr: GitHubTaskAttributes.values()) {
if (attr.isInitTask()) {
- createAttribute(data, attr,null);
+ createAttribute(data, attr, (String) null);
}
}
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubIssueLabelPart.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubIssueLabelPart.java
new file mode 100644
index 0000000..81a6f23
--- /dev/null
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubIssueLabelPart.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * 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:
+ * Kevin Sawicki (GitHub Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.github.ui.internal;
+
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.mylyn.github.internal.GitHubTaskAttributes;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.IFormColors;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * Editor part for viewing a issue's labels.
+ *
+ * @author Kevin Sawicki (kevin@github.com)
+ */
+public class GitHubIssueLabelPart extends AbstractTaskEditorPart {
+
+ /**
+ * @see org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart#createControl(org.eclipse.swt.widgets.Composite,
+ * org.eclipse.ui.forms.widgets.FormToolkit)
+ */
+ public void createControl(Composite parent, FormToolkit toolkit) {
+ Composite displayArea = toolkit.createComposite(parent);
+ GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 5)
+ .spacing(0, 0).numColumns(2).applyTo(displayArea);
+
+ TaskAttribute labels = getTaskData().getRoot().getAttribute(
+ GitHubTaskAttributes.LABELS.getId());
+ if (labels != null) {
+ Label labelControl = toolkit.createLabel(displayArea, labels
+ .getMetaData().getLabel());
+ labelControl.setForeground(toolkit.getColors().getColor(
+ IFormColors.TITLE));
+
+ StringBuilder labelsValue = new StringBuilder();
+ for (String value : labels.getValues()) {
+ labelsValue.append(' ').append(value).append(',');
+ }
+ if (labelsValue.length() > 0) {
+ labelsValue.deleteCharAt(labelsValue.length() - 1);
+ }
+
+ Text labelsText = toolkit.createText(displayArea,
+ labelsValue.toString(), SWT.WRAP | SWT.READ_ONLY);
+ GridDataFactory.swtDefaults().indent(5, 0).grab(true, false)
+ .applyTo(labelsText);
+ }
+
+ setControl(displayArea);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubTaskEditorPage.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubTaskEditorPage.java
index 993012e..7aefa4b 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubTaskEditorPage.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubTaskEditorPage.java
@@ -19,6 +19,7 @@ import org.eclipse.mylyn.github.internal.GitHub;
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.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorFactory;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorPartDescriptor;
@@ -50,6 +51,12 @@ public class GitHubTaskEditorPage extends AbstractTaskEditorPage {
descriptorIt.remove();
}
}
+ partDescriptors.add(new TaskEditorPartDescriptor("labels") {
+
+ public AbstractTaskEditorPart createPart() {
+ return new GitHubIssueLabelPart();
+ }
+ }.setPath(PATH_ATTRIBUTES));
return partDescriptors;
}