summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-04-13 11:39:46 (EDT)
committerChris Aniszczyk2011-04-13 21:45:53 (EDT)
commitd18bdab77d43f36efd037f6830f78c4c5d4a0735 (patch)
tree8cc0357cbd5b9205f35437a90e02076de607a577
parentb6814f985fb41471cd3200f38f03ccc76e9fc9ab (diff)
downloadegit-github-d18bdab77d43f36efd037f6830f78c4c5d4a0735.zip
egit-github-d18bdab77d43f36efd037f6830f78c4c5d4a0735.tar.gz
egit-github-d18bdab77d43f36efd037f6830f78c4c5d4a0735.tar.bz2
Add custom part for editing labels and milestonesrefs/changes/94/3094/3
Change-Id: If39d11d146601c863aebc1ac1aed42513e19a620 Signed-off-by: Kevin Sawicki <kevin@github.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-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.java4
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/IssueAttributePart.java38
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/IssueSummaryPart.java29
4 files changed, 49 insertions, 87 deletions
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
deleted file mode 100644
index f91b663..0000000
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/GitHubIssueLabelPart.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * 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.custom.CLabel;
-import org.eclipse.swt.widgets.Composite;
-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.
- */
-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) {
- CLabel labelControl = new CLabel(displayArea, SWT.NONE);
- labelControl.setText(labels.getMetaData().getLabel());;
- labelControl.setImage(GitHubImages.get(GitHubImages.GITHUB_ISSUE_LABEL_OBJ));
- toolkit.adapt(labelControl, false, false);
- 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 0d6b098..b95068c 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
@@ -56,10 +56,10 @@ public class GitHubTaskEditorPage extends AbstractTaskEditorPage {
return new IssueSummaryPart();
}
}.setPath(PATH_HEADER));
- partDescriptors.add(new TaskEditorPartDescriptor("labels") {
+ partDescriptors.add(new TaskEditorPartDescriptor(ID_PART_ATTRIBUTES) {
public AbstractTaskEditorPart createPart() {
- return new GitHubIssueLabelPart();
+ return new IssueAttributePart();
}
}.setPath(PATH_ATTRIBUTES));
return partDescriptors;
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/IssueAttributePart.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/IssueAttributePart.java
new file mode 100644
index 0000000..f06977b
--- /dev/null
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/IssueAttributePart.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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.mylyn.github.internal.GitHubTaskAttributes;
+import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorAttributePart;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
+
+/**
+ * GitHub issue task editor attribute part that display labels and milestone
+ * attribute editors.
+ */
+public class IssueAttributePart extends TaskEditorAttributePart {
+
+ /**
+ * @see org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart#createAttributeEditor(org.eclipse.mylyn.tasks.core.data.TaskAttribute)
+ */
+ protected AbstractAttributeEditor createAttributeEditor(
+ TaskAttribute attribute) {
+ if (GitHubTaskAttributes.LABELS.getId().equals(attribute.getId())) {
+ return new IssueLabelAttributeEditor(getModel(), attribute);
+ } else if (GitHubTaskAttributes.MILESTONE.getId().equals(
+ attribute.getId())) {
+ return super.createAttributeEditor(attribute);
+ }
+ return null;
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/IssueSummaryPart.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/IssueSummaryPart.java
index 9a0ca9d..a184806 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/IssueSummaryPart.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/IssueSummaryPart.java
@@ -18,7 +18,6 @@ import org.eclipse.mylyn.internal.tasks.ui.editors.EditorUtil;
import org.eclipse.mylyn.internal.tasks.ui.editors.RichTextAttributeEditor;
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorSummaryPart;
import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
-import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
@@ -191,26 +190,16 @@ public class IssueSummaryPart extends AbstractTaskEditorPart {
GridDataFactory.fillDefaults().grab(true, false)
.applyTo(headerComposite);
- TaskAttribute statusAtribute = getTaskData().getRoot()
- .getMappedAttribute(TaskAttribute.STATUS);
- addAttribute(headerComposite, toolkit, statusAtribute, 0);
-
- ITaskMapping mapping = getTaskEditorPage().getConnector()
- .getTaskMapping(getTaskData());
- if (mapping != null && mapping.getResolution() != null
- && mapping.getResolution().length() > 0) {
- TaskAttribute resolutionAtribute = getTaskData().getRoot()
- .getMappedAttribute(TaskAttribute.RESOLUTION);
- addAttribute(headerComposite, toolkit, resolutionAtribute, 0, false);
- }
+ TaskAttribute root = getTaskData().getRoot();
+
+ addAttribute(headerComposite, toolkit,
+ root.getMappedAttribute(TaskAttribute.STATUS), 0);
- TaskAttribute dateCreation = getTaskData().getRoot()
- .getMappedAttribute(TaskAttribute.DATE_CREATION);
- addAttribute(headerComposite, toolkit, dateCreation);
+ addAttribute(headerComposite, toolkit,
+ root.getMappedAttribute(TaskAttribute.DATE_CREATION));
- TaskAttribute dateModified = getTaskData().getRoot()
- .getMappedAttribute(TaskAttribute.DATE_MODIFICATION);
- addAttribute(headerComposite, toolkit, dateModified);
+ addAttribute(headerComposite, toolkit,
+ root.getMappedAttribute(TaskAttribute.DATE_MODIFICATION));
// ensure layout does not wrap
layout.numColumns = headerComposite.getChildren().length;
@@ -234,4 +223,4 @@ public class IssueSummaryPart extends AbstractTaskEditorPart {
if (summaryEditor != null)
summaryEditor.getControl().setFocus();
}
-}
+} \ No newline at end of file