diff options
| author | Kevin Sawicki | 2011-04-14 17:08:54 +0000 |
|---|---|---|
| committer | Chris Aniszczyk | 2011-04-14 20:42:03 +0000 |
| commit | 6cfe5ac660a4fcb89b310ade1342d0234af77a37 (patch) | |
| tree | eea398f1f341e03a87f299b72ea0f6de3a63b11e | |
| parent | fd567a5be8f8a43e80bf5b4bafa33a054642a5e7 (diff) | |
| download | egit-github-6cfe5ac660a4fcb89b310ade1342d0234af77a37.tar.gz egit-github-6cfe5ac660a4fcb89b310ade1342d0234af77a37.tar.xz egit-github-6cfe5ac660a4fcb89b310ade1342d0234af77a37.zip | |
Add initial gist repository settings page
Change-Id: Ifb8f31e280e1bdf4706de94ac3520cdbdae18113
Signed-off-by: Kevin Sawicki <kevin@github.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
3 files changed, 102 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistRepositorySettingsPage.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistRepositorySettingsPage.java new file mode 100644 index 00000000..418eb673 --- /dev/null +++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/GistRepositorySettingsPage.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * 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.io.IOException; +import java.net.URL; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.mylyn.internal.github.core.gist.GistConnector; +import org.eclipse.mylyn.internal.tasks.core.IRepositoryConstants; +import org.eclipse.mylyn.tasks.core.TaskRepository; +import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage; +import org.eclipse.swt.widgets.Composite; + +/** + * Gist repository settings page class. + * + * @author Kevin Sawicki (kevin@github.com) + */ +public class GistRepositorySettingsPage extends AbstractRepositorySettingsPage { + + /** + * @param taskRepository + */ + public GistRepositorySettingsPage(TaskRepository taskRepository) { + super(Messages.GistRepositorySettingsPage_Title, + Messages.GistRepositorySettingsPage_Description, taskRepository); + setNeedsAnonymousLogin(false); + } + + /** + * @see org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage#getConnectorKind() + */ + public String getConnectorKind() { + return GistConnector.KIND; + } + + /** + * @see org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage#createAdditionalControls(org.eclipse.swt.widgets.Composite) + */ + protected void createAdditionalControls(Composite parent) { + if (repository == null) { + setUrl("https://gist.github.com"); //$NON-NLS-1$ + repositoryLabelEditor.setStringValue("Gists"); //$NON-NLS-1$ + } + } + + /** + * @see org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage#isValidUrl(java.lang.String) + */ + protected boolean isValidUrl(String url) { + if (url.startsWith("http://") || url.startsWith("https://")) { //$NON-NLS-1$ //$NON-NLS-2$ + try { + new URL(url); + return true; + } catch (IOException e) { + return false; + } + } + return false; + + } + + /** + * @see org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage#getValidator(org.eclipse.mylyn.tasks.core.TaskRepository) + */ + protected Validator getValidator(TaskRepository repository) { + return new Validator() { + + public void run(IProgressMonitor monitor) throws CoreException { + + } + }; + } + + /** + * @see org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage#applyTo(org.eclipse.mylyn.tasks.core.TaskRepository) + */ + public void applyTo(TaskRepository repository) { + repository.setProperty(IRepositoryConstants.PROPERTY_CATEGORY, + IRepositoryConstants.CATEGORY_REVIEW); + super.applyTo(repository); + } + +} 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 d0a128ff..6d376fe7 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 @@ -25,6 +25,12 @@ public class Messages extends NLS { /** */ public static String GistRepositoryQueryPage_LabelUser; + /** */ + public static String GistRepositorySettingsPage_Description; + + /** */ + public static String GistRepositorySettingsPage_Title; + 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 fddd667a..e513ffeb 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,2 +1,4 @@ GistRepositoryQueryPage_LabelTitle=Title: GistRepositoryQueryPage_LabelUser=User: +GistRepositorySettingsPage_Description=Enter repository settings +GistRepositorySettingsPage_Title=Gist repository settings |
