Search in sources :

Example 1 with AddRemoteWizard

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);
        }
    }
}
Also used : URIish(org.eclipse.jgit.transport.URIish) StoredConfig(org.eclipse.jgit.lib.StoredConfig) RefSpec(org.eclipse.jgit.transport.RefSpec) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) RemoteConfig(org.eclipse.jgit.transport.RemoteConfig) WizardDialog(org.eclipse.jface.wizard.WizardDialog) AddRemoteWizard(org.eclipse.egit.ui.internal.push.AddRemoteWizard)

Aggregations

IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 AddRemoteWizard (org.eclipse.egit.ui.internal.push.AddRemoteWizard)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 StoredConfig (org.eclipse.jgit.lib.StoredConfig)1 RefSpec (org.eclipse.jgit.transport.RefSpec)1 RemoteConfig (org.eclipse.jgit.transport.RemoteConfig)1 URIish (org.eclipse.jgit.transport.URIish)1