Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 00000000..2e50ca15
--- /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 a4891754..5975768d 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 edaefa5a..50e71924 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 7dd660ce..543399f8 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:

Back to the top