summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-04-21 17:38:44 (EDT)
committer Kevin Sawicki2011-04-21 17:38:44 (EDT)
commit5fb60993022fddcab35489ea36adc75151ec88b5 (patch)
tree5b9a47334992d983a210d44d8d23d96a5803d595
parent7f25cd5bf4c06cbc2a60caf037c7899e40ba9de3 (diff)
downloadegit-github-5fb60993022fddcab35489ea36adc75151ec88b5.zip
egit-github-5fb60993022fddcab35489ea36adc75151ec88b5.tar.gz
egit-github-5fb60993022fddcab35489ea36adc75151ec88b5.tar.bz2
Add gist attachment wizard page.refs/changes/10/3210/1
This page replaces the default task attachment page and contains only the fields needed for gist file attachments. Change-Id: I32be60f9485bdb24b5e5a0348e37397f80939529 Signed-off-by: Kevin Sawicki <kevin@github.com>
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistAttachmentPage.java105
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistConnectorUi.java9
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/Messages.java12
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/messages.properties4
4 files changed, 130 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistAttachmentPage.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistAttachmentPage.java
new file mode 100644
index 0000000..2e50ca1
--- /dev/null
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistAttachmentPage.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * 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.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.mylyn.tasks.core.data.TaskAttachmentMapper;
+import org.eclipse.mylyn.tasks.core.data.TaskAttachmentModel;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Gist attachment wizard page class.
+ *
+ * @author Kevin Sawicki (kevin@github.com)
+ */
+public class GistAttachmentPage extends WizardPage {
+
+ private TaskAttachmentMapper mapper;
+ private TaskAttachmentModel model;
+
+ private Text nameText;
+
+ /**
+ * Create page for task attachment model
+ *
+ * @param model
+ */
+ protected GistAttachmentPage(TaskAttachmentModel model) {
+ super("gistAttachmentPage"); //$NON-NLS-1$
+ setTitle(Messages.GistAttachmentPage_Title);
+ setDescription(Messages.GistAttachmentPage_Description);
+ model.setAttachContext(false);
+ mapper = TaskAttachmentMapper.createFrom(model.getAttribute());
+ this.model = model;
+ }
+
+ /**
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite displayArea = new Composite(parent, SWT.NONE);
+ GridLayoutFactory.swtDefaults().numColumns(2).applyTo(displayArea);
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(displayArea);
+
+ new Label(displayArea, SWT.NONE).setText(Messages.GistAttachmentPage_LabelFile);
+
+ nameText = new Text(displayArea, SWT.BORDER | SWT.SINGLE);
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText);
+ nameText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ updateFilename();
+ }
+ });
+
+ Label binaryLabel = new Label(displayArea, SWT.WRAP);
+ binaryLabel
+ .setText(Messages.GistAttachmentPage_LabelBinaryWarning);
+ GridDataFactory.fillDefaults().grab(true, false).span(2, 1)
+ .applyTo(binaryLabel);
+
+ setControl(displayArea);
+ }
+
+ private void updateFilename() {
+ mapper.setFileName(nameText.getText().trim());
+ mapper.applyTo(model.getAttribute());
+ validate();
+ }
+
+ /**
+ * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
+ */
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ if (visible) {
+ String current = mapper.getFileName();
+ if (current == null)
+ current = model.getSource().getName();
+ if (current != null)
+ nameText.setText(current);
+ nameText.selectAll();
+ nameText.setFocus();
+ updateFilename();
+ }
+ }
+
+ private void validate() {
+ setPageComplete(!"".equals(nameText.getText().trim())); //$NON-NLS-1$
+ }
+}
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistConnectorUi.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistConnectorUi.java
index a489175..5975768 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistConnectorUi.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistConnectorUi.java
@@ -12,11 +12,13 @@ package org.eclipse.mylyn.internal.github.ui.gist;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.mylyn.internal.github.core.gist.GistConnector;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.TaskAttachmentModel;
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.mylyn.tasks.ui.wizards.ITaskRepositoryPage;
@@ -96,4 +98,11 @@ public class GistConnectorUi extends AbstractRepositoryConnectorUi {
return new GistRepositoryQueryPage(repository, null);
}
+ /**
+ * @see org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi#getTaskAttachmentPage(org.eclipse.mylyn.tasks.core.data.TaskAttachmentModel)
+ */
+ public IWizardPage getTaskAttachmentPage(TaskAttachmentModel model) {
+ return new GistAttachmentPage(model);
+ }
+
}
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 edaefa5..50e7192 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
@@ -20,6 +20,18 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.github.ui.gist.messages"; //$NON-NLS-1$
/** */
+ public static String GistAttachmentPage_Description;
+
+ /** */
+ public static String GistAttachmentPage_LabelBinaryWarning;
+
+ /** */
+ public static String GistAttachmentPage_LabelFile;
+
+ /** */
+ public static String GistAttachmentPage_Title;
+
+ /** */
public static String GistAttachmentPart_PartName;
/** */
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 7dd660c..543399f 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
@@ -1,3 +1,7 @@
+GistAttachmentPage_Description=Enter file name
+GistAttachmentPage_LabelBinaryWarning=Note: Binary content in Gist attachments is not supported
+GistAttachmentPage_LabelFile=File:
+GistAttachmentPage_Title=File Settings
GistAttachmentPart_PartName=Files
GistConnectorUi_LabelTaskKind=Gist
GistRepositoryQueryPage_LabelTitle=Title: