summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-04-14 16:50:00 (EDT)
committerChris Aniszczyk2011-04-14 16:56:16 (EDT)
commit47548208a571625df8ae14167d0922f91b0aebbb (patch)
treeb116f969b1d09afe1589a08e28c52c1d45036fcf
parent3f40d71894a835288525f30b7222968d011e270d (diff)
downloadegit-github-47548208a571625df8ae14167d0922f91b0aebbb.zip
egit-github-47548208a571625df8ae14167d0922f91b0aebbb.tar.gz
egit-github-47548208a571625df8ae14167d0922f91b0aebbb.tar.bz2
Add gist task editor page and factoryrefs/changes/23/3123/2
Change-Id: Ib58545d2355e0f132c38202d1f094dc24170d46b 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/GitHubTaskEditorPage.java5
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/github/ui/internal/IssueSummaryPart.java23
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistTaskEditorPage.java62
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistTaskEditorPageFactory.java73
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/Messages.java3
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/messages.properties1
6 files changed, 159 insertions, 8 deletions
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 b95068c..d9a686f 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
@@ -16,6 +16,7 @@ import java.util.Iterator;
import java.util.Set;
import org.eclipse.mylyn.github.internal.GitHub;
+import org.eclipse.mylyn.github.internal.GitHubTaskAttributes;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
@@ -53,7 +54,9 @@ public class GitHubTaskEditorPage extends AbstractTaskEditorPage {
partDescriptors.add(new TaskEditorPartDescriptor(ID_PART_SUMMARY) {
public AbstractTaskEditorPart createPart() {
- return new IssueSummaryPart();
+ return new IssueSummaryPart(
+ GitHubTaskAttributes.REPORTER_GRAVATAR.getId(),
+ GitHubTaskAttributes.ASSIGNEE_GRAVATAR.getId());
}
}.setPath(PATH_HEADER));
partDescriptors.add(new TaskEditorPartDescriptor(ID_PART_ATTRIBUTES) {
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 a184806..b446215 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
@@ -39,11 +39,20 @@ public class IssueSummaryPart extends AbstractTaskEditorPart {
private AbstractAttributeEditor summaryEditor;
+ private String reporterAvatarId;
+
+ private String assigneeAvatarId;
+
/**
* Create issue summary part
+ *
+ * @param reporterAvatarId
+ * @param assigneeAvatarId
*/
- public IssueSummaryPart() {
+ public IssueSummaryPart(String reporterAvatarId, String assigneeAvatarId) {
setPartName("Summary"); //$NON-NLS-1$
+ this.reporterAvatarId = reporterAvatarId;
+ this.assigneeAvatarId = assigneeAvatarId;
}
private void addAttribute(Composite composite, FormToolkit toolkit,
@@ -155,9 +164,9 @@ public class IssueSummaryPart extends AbstractTaskEditorPart {
if (reporter != null) {
IRepositoryPerson person = getTaskData().getAttributeMapper()
.getRepositoryPerson(reporter);
- if (addAvatarPart(composite, toolkit,
- getAttribute(GitHubTaskAttributes.REPORTER_GRAVATAR),
- person))
+ if (this.reporterAvatarId != null
+ && addAvatarPart(composite, toolkit,
+ getAttribute(this.reporterAvatarId), person))
layout.numColumns++;
}
addSummaryText(composite, toolkit);
@@ -166,9 +175,9 @@ public class IssueSummaryPart extends AbstractTaskEditorPart {
if (assignee != null) {
IRepositoryPerson person = getTaskData().getAttributeMapper()
.getRepositoryPerson(assignee);
- if (addAvatarPart(composite, toolkit,
- getAttribute(GitHubTaskAttributes.ASSIGNEE_GRAVATAR),
- person))
+ if (this.assigneeAvatarId != null
+ && addAvatarPart(composite, toolkit,
+ getAttribute(this.assigneeAvatarId), person))
layout.numColumns++;
}
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistTaskEditorPage.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistTaskEditorPage.java
new file mode 100644
index 0000000..53a03dc
--- /dev/null
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistTaskEditorPage.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.internal.github.ui.gist;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.mylyn.github.ui.internal.IssueSummaryPart;
+import org.eclipse.mylyn.internal.github.core.gist.GistAttribute;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
+import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
+import org.eclipse.mylyn.tasks.ui.editors.TaskEditorPartDescriptor;
+
+/**
+ * Gist task editor page class
+ */
+public class GistTaskEditorPage extends AbstractTaskEditorPage {
+
+ /**
+ * @param editor
+ * @param connectorKind
+ */
+ public GistTaskEditorPage(TaskEditor editor, String connectorKind) {
+ super(editor, connectorKind);
+ setNeedsPrivateSection(true);
+ setNeedsSubmitButton(true);
+ }
+
+ /**
+ * @see org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage#createPartDescriptors()
+ */
+ protected Set<TaskEditorPartDescriptor> createPartDescriptors() {
+ Set<TaskEditorPartDescriptor> partDescriptors = super
+ .createPartDescriptors();
+ Iterator<TaskEditorPartDescriptor> descriptorIt = partDescriptors
+ .iterator();
+ while (descriptorIt.hasNext()) {
+ TaskEditorPartDescriptor partDescriptor = descriptorIt.next();
+ String id = partDescriptor.getId();
+ if (id.equals(ID_PART_ATTRIBUTES) || id.equals(ID_PART_SUMMARY))
+ descriptorIt.remove();
+ }
+ if (!getModel().getTaskData().isNew())
+ partDescriptors.add(new TaskEditorPartDescriptor(ID_PART_SUMMARY) {
+
+ public AbstractTaskEditorPart createPart() {
+ return new IssueSummaryPart(GistAttribute.AUTHOR_GRAVATAR
+ .getId(), null);
+ }
+ }.setPath(PATH_HEADER));
+ return partDescriptors;
+ }
+}
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistTaskEditorPageFactory.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistTaskEditorPageFactory.java
new file mode 100644
index 0000000..d1a212a
--- /dev/null
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistTaskEditorPageFactory.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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.internal.github.ui.gist;
+
+import org.eclipse.mylyn.github.ui.internal.GitHubImages;
+import org.eclipse.mylyn.internal.github.core.gist.GistConnector;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.ui.ITasksUiConstants;
+import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPageFactory;
+import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
+import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.forms.editor.IFormPage;
+
+/**
+ * Gist task editor page factory class
+ */
+public class GistTaskEditorPageFactory extends AbstractTaskEditorPageFactory {
+
+ /**
+ * @see org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPageFactory#canCreatePageFor(org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput)
+ */
+ public boolean canCreatePageFor(TaskEditorInput input) {
+ ITask task = input.getTask();
+ return GistConnector.KIND.equals(task.getConnectorKind())
+ || TasksUiUtil.isOutgoingNewTask(task, GistConnector.KIND);
+ }
+
+ /**
+ * @see org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPageFactory#createPage(org.eclipse.mylyn.tasks.ui.editors.TaskEditor)
+ */
+ public IFormPage createPage(TaskEditor parentEditor) {
+ return new GistTaskEditorPage(parentEditor, GistConnector.KIND);
+ }
+
+ /**
+ * @see org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPageFactory#getPageImage()
+ */
+ public Image getPageImage() {
+ return GitHubImages.get(GitHubImages.GITHUB_LOGO_OBJ);
+ }
+
+ /**
+ * @see org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPageFactory#getPageText()
+ */
+ public String getPageText() {
+ return Messages.GistTaskEditorPageFactory_PageText;
+ }
+
+ /**
+ * @see org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPageFactory#getPriority()
+ */
+ public int getPriority() {
+ return PRIORITY_TASK;
+ }
+
+ /**
+ * @see org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPageFactory#getConflictingIds(org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput)
+ */
+ public String[] getConflictingIds(TaskEditorInput input) {
+ return new String[] { ITasksUiConstants.ID_PAGE_PLANNING };
+ }
+
+}
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/Messages.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/Messages.java
index 72efe13..98e6178 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/Messages.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/Messages.java
@@ -34,6 +34,9 @@ public class Messages extends NLS {
/** */
public static String GistRepositorySettingsPage_Title;
+ /** */
+ public static String GistTaskEditorPageFactory_PageText;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/messages.properties b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/messages.properties
index d849051..6b883af 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/messages.properties
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/messages.properties
@@ -3,3 +3,4 @@ GistRepositoryQueryPage_LabelTitle=Title:
GistRepositoryQueryPage_LabelUser=User:
GistRepositorySettingsPage_Description=Enter repository settings
GistRepositorySettingsPage_Title=Gist repository settings
+GistTaskEditorPageFactory_PageText=Gist