use of org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider in project egit by eclipse.
the class PushOperationUI method start.
/**
* Starts the operation asynchronously.
*/
public void start() {
final Repository repo = repository;
if (repo == null) {
return;
}
try {
createPushOperation();
} catch (CoreException e) {
Activator.showErrorStatus(e.getLocalizedMessage(), e.getStatus());
return;
}
if (credentialsProvider != null) {
op.setCredentialsProvider(credentialsProvider);
} else {
op.setCredentialsProvider(new EGitCredentialsProvider());
}
Job job = new PushJob(NLS.bind(UIText.PushOperationUI_PushJobName, destinationString), repo, op, expectedResult, destinationString, showConfigureButton, pushMode);
job.setUser(true);
job.schedule();
}
use of org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider in project egit by eclipse.
the class FetchWizard method performFinish.
@Override
public boolean performFinish() {
boolean calledFromRepoPage = false;
if (getContainer().getCurrentPage() == repoPage)
calledFromRepoPage = true;
if (repoPage.getSelection().isConfigSelected() && refSpecPage.isSaveRequested())
saveConfig();
if (repoPage.getStoreInSecureStore()) {
if (!SecureStoreUtils.storeCredentials(repoPage.getCredentials(), repoPage.getSelection().getURI()))
return false;
}
final FetchOperationUI op;
int timeout = Activator.getDefault().getPreferenceStore().getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);
final RepositorySelection repoSelection = repoPage.getSelection();
if (calledFromRepoPage)
op = new FetchOperationUI(localDb, repoSelection.getConfig(), timeout, false);
else if (repoSelection.isConfigSelected())
op = new FetchOperationUI(localDb, repoSelection.getConfig().getURIs().get(0), refSpecPage.getRefSpecs(), timeout, false);
else
op = new FetchOperationUI(localDb, repoSelection.getURI(false), refSpecPage.getRefSpecs(), timeout, false);
UserPasswordCredentials credentials = repoPage.getCredentials();
if (credentials != null)
op.setCredentialsProvider(new EGitCredentialsProvider(credentials.getUser(), credentials.getPassword()));
// add the RefSpecs from the RefSpec page into the FetchOperation
if (!calledFromRepoPage)
op.setTagOpt(refSpecPage.getTagOpt());
op.start();
repoPage.saveUriInPrefs();
return true;
}
use of org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider in project egit by eclipse.
the class PushAction method runPushOperation.
private void runPushOperation() {
GitSynchronizeDataSet gsds = (GitSynchronizeDataSet) getConfiguration().getProperty(SYNCHRONIZATION_DATA);
for (GitSynchronizeData gsd : gsds) {
String remoteName = gsd.getDstRemoteName();
if (remoteName == null)
continue;
RemoteConfig rc;
Repository repo = gsd.getRepository();
StoredConfig config = repo.getConfig();
try {
rc = new RemoteConfig(config, remoteName);
} catch (URISyntaxException e) {
Activator.logError("Unable to create RemoteConfiguration for remote: " + remoteName, // $NON-NLS-1$
e);
continue;
}
if (rc.getPushRefSpecs().isEmpty())
// $NON-NLS-1$
rc.addPushRefSpec(new RefSpec(HEAD + ":" + gsd.getDstMerge()));
PushOperationUI push = new PushOperationUI(repo, rc, false);
push.setCredentialsProvider(new EGitCredentialsProvider());
push.start();
}
}
use of org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider in project egit by eclipse.
the class ConfirmationPage method revalidateImpl.
private void revalidateImpl() {
if (getControl().isDisposed() || !isCurrentPage())
return;
final List<RefSpec> fetchSpecs;
if (displayedRepoSelection.isConfigSelected())
fetchSpecs = displayedRepoSelection.getConfig().getFetchRefSpecs();
else
fetchSpecs = null;
final PushOperation operation;
try {
final Collection<RemoteRefUpdate> updates = Transport.findRemoteRefUpdatesFor(local, displayedRefSpecs, fetchSpecs);
if (updates.isEmpty()) {
// It can happen only when local refs changed in the mean time.
setErrorMessage(UIText.ConfirmationPage_errorRefsChangedNoMatch);
setPageComplete(false);
return;
}
final PushOperationSpecification spec = new PushOperationSpecification();
for (final URIish uri : displayedRepoSelection.getPushURIs()) spec.addURIRefUpdates(uri, copyUpdates(updates));
int timeout = Activator.getDefault().getPreferenceStore().getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);
operation = new PushOperation(local, spec, true, timeout);
if (credentials != null)
operation.setCredentialsProvider(new EGitCredentialsProvider(credentials.getUser(), credentials.getPassword()));
getContainer().run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
operation.run(monitor);
}
});
} catch (final IOException e) {
setErrorMessage(NLS.bind(UIText.ConfirmationPage_errorCantResolveSpecs, e.getMessage()));
return;
} catch (final InvocationTargetException e) {
setErrorMessage(NLS.bind(UIText.ConfirmationPage_errorUnexpected, e.getCause().getMessage()));
return;
} catch (final InterruptedException e) {
setErrorMessage(UIText.ConfirmationPage_errorInterrupted);
setPageComplete(true);
displayedRefSpecs = null;
displayedRepoSelection = null;
return;
}
final PushOperationResult result = operation.getOperationResult();
resultPanel.setData(local, result);
if (result.isSuccessfulConnectionForAnyURI()) {
setPageComplete(true);
confirmedResult = result;
} else {
final String message = NLS.bind(UIText.ConfirmationPage_cantConnectToAny, result.getErrorStringForAllURis());
setErrorMessage(message);
ErrorDialog.openError(getShell(), UIText.ConfirmationPage_cantConnectToAnyTitle, null, new Status(IStatus.ERROR, Activator.getPluginId(), message));
}
}
use of org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider in project egit by eclipse.
the class PushWizard method performFinish.
@Override
public boolean performFinish() {
boolean calledFromRepoPage = false;
if (getContainer().getCurrentPage() == repoPage)
calledFromRepoPage = true;
if (repoPage.getSelection().isConfigSelected() && refSpecPage.isSaveRequested()) {
saveRefSpecs();
}
if (repoPage.getStoreInSecureStore()) {
if (!SecureStoreUtils.storeCredentials(repoPage.getCredentials(), repoPage.getSelection().getURI()))
return false;
}
final PushOperation operation = createPushOperation(calledFromRepoPage);
if (operation == null)
return false;
UserPasswordCredentials credentials = repoPage.getCredentials();
if (credentials != null)
operation.setCredentialsProvider(new EGitCredentialsProvider(credentials.getUser(), credentials.getPassword()));
final PushOperationResult resultToCompare;
if (confirmPage.isShowOnlyIfChangedSelected()) {
resultToCompare = confirmPage.getConfirmedResult();
} else {
resultToCompare = null;
}
final Job job = new PushJob(NLS.bind(UIText.PushWizard_jobName, getURIsString(operation.getSpecification().getURIs())), localDb, operation, resultToCompare, getDestinationString(repoPage.getSelection()), true, PushMode.UPSTREAM);
job.setUser(true);
job.schedule();
repoPage.saveUriInPrefs();
return true;
}
Aggregations