summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-04-14 13:06:14 (EDT)
committerChris Aniszczyk2011-04-14 16:40:25 (EDT)
commitfd567a5be8f8a43e80bf5b4bafa33a054642a5e7 (patch)
treef6a09d91eaf8ff3b24507f8255a021c295c52b96
parentc839cbb69409cc2d9a3d76fd014211c0d4f3cff9 (diff)
downloadegit-github-fd567a5be8f8a43e80bf5b4bafa33a054642a5e7.zip
egit-github-fd567a5be8f8a43e80bf5b4bafa33a054642a5e7.tar.gz
egit-github-fd567a5be8f8a43e80bf5b4bafa33a054642a5e7.tar.bz2
Add initial gist repository query pagerefs/changes/14/3114/2
Change-Id: Iacd069cdcfbb66cc307f6f0506118f68189561d4 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/internal/github/ui/gist/GistRepositoryQueryPage.java121
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/Messages.java35
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/messages.properties2
3 files changed, 158 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistRepositoryQueryPage.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistRepositoryQueryPage.java
new file mode 100644
index 0000000..1ad9af0
--- /dev/null
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistRepositoryQueryPage.java
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * 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.dialogs.Dialog;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.mylyn.internal.github.core.gist.IGistQueryConstants;
+import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage;
+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 repository query page class.
+ */
+public class GistRepositoryQueryPage extends AbstractRepositoryQueryPage {
+
+ private Text titleText;
+ private Text userText;
+
+ /**
+ * @param taskRepository
+ * @param query
+ */
+ public GistRepositoryQueryPage(TaskRepository taskRepository,
+ IRepositoryQuery query) {
+ this("gistQueryPage", taskRepository, query); //$NON-NLS-1$
+ }
+
+ /**
+ * @param pageName
+ * @param taskRepository
+ * @param query
+ */
+ public GistRepositoryQueryPage(String pageName,
+ TaskRepository taskRepository, IRepositoryQuery query) {
+ super(pageName, taskRepository, query);
+ }
+
+ /**
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite displayArea = new Composite(parent, SWT.NONE);
+ initializeDialogUnits(displayArea);
+
+ GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false)
+ .applyTo(displayArea);
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(displayArea);
+
+ ModifyListener completeListener = new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ setPageComplete(isPageComplete());
+ }
+ };
+
+ new Label(displayArea, SWT.NONE).setText(Messages.GistRepositoryQueryPage_LabelTitle);
+ titleText = new Text(displayArea, SWT.SINGLE | SWT.BORDER);
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(titleText);
+ titleText.addModifyListener(completeListener);
+
+ new Label(displayArea, SWT.NONE).setText(Messages.GistRepositoryQueryPage_LabelUser);
+ userText = new Text(displayArea, SWT.SINGLE | SWT.BORDER);
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(userText);
+ userText.addModifyListener(completeListener);
+
+ IRepositoryQuery query = getQuery();
+ if (query != null) {
+ if (query.getSummary() != null)
+ titleText.setText(query.getSummary());
+
+ if (query.getAttribute(IGistQueryConstants.USER) != null)
+ userText.setText(query.getAttribute(IGistQueryConstants.USER));
+ }
+
+ Dialog.applyDialogFont(displayArea);
+ setControl(displayArea);
+ setPageComplete(isPageComplete());
+ }
+
+ /**
+ * @see org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage#getQueryTitle()
+ */
+ public String getQueryTitle() {
+ return this.titleText.getText();
+ }
+
+ /**
+ * @see org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage#isPageComplete()
+ */
+ public boolean isPageComplete() {
+ boolean complete = super.isPageComplete();
+ if (complete)
+ complete = userText.getText().trim().length() > 0;
+
+ return complete;
+ }
+
+ /**
+ * @see org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage#applyTo(org.eclipse.mylyn.tasks.core.IRepositoryQuery)
+ */
+ public void applyTo(IRepositoryQuery query) {
+ query.setSummary(getQueryTitle());
+ query.setAttribute(IGistQueryConstants.USER, userText.getText().trim());
+ }
+}
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
new file mode 100644
index 0000000..d0a128f
--- /dev/null
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/Messages.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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.osgi.util.NLS;
+
+/**
+ * NLS
+ */
+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 GistRepositoryQueryPage_LabelTitle;
+
+ /** */
+ public static String GistRepositoryQueryPage_LabelUser;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
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
new file mode 100644
index 0000000..fddd667
--- /dev/null
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/messages.properties
@@ -0,0 +1,2 @@
+GistRepositoryQueryPage_LabelTitle=Title:
+GistRepositoryQueryPage_LabelUser=User: