blob: 418eb673d82467bee8d1cc2808b4620a0e5b37ed (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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);
}
}
|