diff options
| author | Kevin Sawicki | 2011-04-14 20:50:00 +0000 |
|---|---|---|
| committer | Chris Aniszczyk | 2011-04-14 20:56:16 +0000 |
| commit | 47548208a571625df8ae14167d0922f91b0aebbb (patch) | |
| tree | b116f969b1d09afe1589a08e28c52c1d45036fcf | |
| parent | 3f40d71894a835288525f30b7222968d011e270d (diff) | |
| download | egit-github-47548208a571625df8ae14167d0922f91b0aebbb.tar.gz egit-github-47548208a571625df8ae14167d0922f91b0aebbb.tar.xz egit-github-47548208a571625df8ae14167d0922f91b0aebbb.zip | |
Add gist task editor page and factory
Change-Id: Ib58545d2355e0f132c38202d1f094dc24170d46b
Signed-off-by: Kevin Sawicki <kevin@github.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
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 b95068cc..d9a686f2 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 a184806f..b4462152 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 00000000..53a03dc0 --- /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 00000000..d1a212a7 --- /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 72efe13b..98e6178d 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 d8490512..6b883af4 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 |
