blob: b14eeecda4d0949d9d01737e1ebe161228e6c2d9 (
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
|
/******************************************************************************
* 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;
import java.io.IOException;
import java.net.URL;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.mylyn.internal.github.core.GitHub;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage;
/**
* Base HTTP-based task repository settings page
*/
public abstract class HttpRepositorySettingsPage extends
AbstractRepositorySettingsPage {
/**
* Create repository settings page
*
* @param title
* @param description
* @param taskRepository
* - Object to populate
*/
public HttpRepositorySettingsPage(final String title,
final String description, final TaskRepository taskRepository) {
super(title, description, taskRepository);
setHttpAuth(false);
setNeedsAdvanced(false);
setNeedsAnonymousLogin(true);
setNeedsTimeZone(false);
setNeedsHttpAuth(false);
}
@Override
protected boolean isValidUrl(final String url) {
if (url.startsWith("http://") || url.startsWith("https://")) //$NON-NLS-1$ //$NON-NLS-2$
try {
new URL(url);
return GitHub.getRepository(url) != null;
} catch (IOException e) {
return false;
}
return false;
}
/**
* @see org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage#canValidate()
*/
public boolean canValidate() {
return isPageComplete()
&& (getMessage() == null || getMessageType() != IMessageProvider.ERROR);
}
}
|