use of org.eclipse.egit.ui.internal.push.AddRemoteWizard in project egit by eclipse.
the class PullWizardPage method showNewRemoteDialog.
private void showNewRemoteDialog() {
AddRemoteWizard wizard = new AddRemoteWizard(repository);
WizardDialog dialog = new WizardDialog(getShell(), wizard);
int result = dialog.open();
if (result == Window.OK) {
URIish uri = wizard.getUri();
String remoteName = wizard.getRemoteName();
try {
StoredConfig repoConfig = repository.getConfig();
RemoteConfig newRemoteConfig = new RemoteConfig(repoConfig, remoteName);
newRemoteConfig.addURI(uri);
RefSpec defaultFetchSpec = new RefSpec().setForceUpdate(true).setSourceDestination(// $NON-NLS-1$
Constants.R_HEADS + "*", // $NON-NLS-1$
Constants.R_REMOTES + remoteName + "/*");
newRemoteConfig.addFetchRefSpec(defaultFetchSpec);
newRemoteConfig.update(repoConfig);
repoConfig.save();
List<RemoteConfig> allRemoteConfigs = RemoteConfig.getAllRemoteConfigs(repository.getConfig());
remoteSelectionCombo.setItems(allRemoteConfigs);
// isn't what's stored and returned by getAllRemoteConfigs
for (RemoteConfig current : allRemoteConfigs) {
if (newRemoteConfig.getName().equals(current.getName())) {
setSelectedRemote(current);
}
}
} catch (URISyntaxException ex) {
Activator.logError(ex.getMessage(), ex);
} catch (IOException ex) {
Activator.logError(ex.getMessage(), ex);
}
}
}
Aggregations