Rev 52 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
/*
* Mylyn Connector for Serena Business Mashups
* Copyright 2010 Brian Rosenberger (Brutex Network)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Serena, TeamTrack and Serena Business Mashup are
* registered trademarks of SERENA Software Inc.
*/
package net.brutex.mylyn.sbmconnector.ui;
import net.brutex.mylyn.sbmconnector.SBMConnectorPlugin;
import net.brutex.mylyn.sbmconnector.core.SBMClient;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage;
import org.eclipse.swt.widgets.Composite;
public class SBMRepositorySettingsPage extends AbstractRepositorySettingsPage {
public SBMRepositorySettingsPage(String title, String description,
TaskRepository taskRepository) {
super(title, description, taskRepository);
// TODO Auto-generated constructor stub
}
@Override
protected void createAdditionalControls(Composite parent) {
// TODO Auto-generated method stub
}
@Override
public String getConnectorKind() {
return SBMConnectorPlugin.CONNECTOR_KIND;
}
@Override
protected Validator getValidator(TaskRepository repository) {
return new SBMConnectionValidator(repository);
}
@Override
protected boolean isValidUrl(String url) {
if(url.contains("<server>")) return false;
return true;
}
@Override
protected void applyValidatorResult(Validator validator) {
if (((SBMConnectionValidator) validator).getResult() != null) {
getContainer().updateButtons();
}
super.applyValidatorResult(validator);
}
protected class SBMConnectionValidator extends Validator {
private TaskRepository repository;
private String result = null;
protected SBMConnectionValidator(TaskRepository repository) {
this.repository = repository;
}
@Override
public void run(IProgressMonitor monitor) throws CoreException {
monitor.beginTask("Prüfe Verbindung", IProgressMonitor.UNKNOWN);
SBMClient client = new SBMClient(repository);
if(!client.canAuthenticate()) {
result = "Verbindung fehlgeschlagen";
}
result = "Verbindung erfolgreich";
monitor.done();
}
public String getResult() { return result; }
}
}