use of com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutorCallback in project intellij-community by JetBrains.
the class CvsOperationExecutor method performActionSync.
public void performActionSync(final CvsHandler handler, final CvsOperationExecutorCallback callback) {
final CvsTabbedWindow tabbedWindow = myIsQuietOperation ? null : openTabbedWindow(handler);
final Runnable finish = () -> {
try {
myResult.addAllErrors(handler.getErrorsExceptAborted());
handler.finish();
if (myProject == null || !myProject.isDisposed()) {
showErrors(handler, tabbedWindow);
}
} finally {
try {
if (myResult.finishedUnsuccessfully(handler)) {
callback.executionFinished(false);
} else {
if (handler.getErrors().isEmpty())
callback.executionFinishedSuccessfully();
callback.executionFinished(true);
}
} finally {
if (myProject != null && handler != CvsHandler.NULL) {
ApplicationManager.getApplication().invokeLater(() -> StatusBar.Info.set(getStatusMessage(handler), myProject));
}
}
}
};
final Runnable cvsAction = () -> {
try {
if (handler == CvsHandler.NULL)
return;
setText(CvsBundle.message("progress.text.preparing.for.login"));
handler.beforeLogin();
if (myResult.finishedUnsuccessfully(handler))
return;
setText(CvsBundle.message("progress.text.preparing.for.action", handler.getTitle()));
handler.run(myProject, myExecutor);
if (myResult.finishedUnsuccessfully(handler))
return;
} catch (ProcessCanceledException ex) {
myResult.setIsCanceled();
} finally {
callback.executeInProgressAfterAction(myExecutor);
}
};
if (doNotShowProgress()) {
cvsAction.run();
if (myIsQuietOperation) {
finish.run();
} else {
myExecutor.runInDispatchThread(finish, myProject);
}
} else {
final PerformInBackgroundOption backgroundOption = handler.getBackgroundOption(myProject);
if (backgroundOption != null) {
final Task.Backgroundable task = new Task.Backgroundable(myProject, handler.getTitle(), handler.canBeCanceled(), backgroundOption) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
cvsAction.run();
}
@Override
public void onSuccess() {
finish.run();
}
};
ProgressManager.getInstance().run(task);
} else {
if (ProgressManager.getInstance().runProcessWithProgressSynchronously(cvsAction, handler.getTitle(), handler.canBeCanceled(), myProject)) {
finish.run();
}
}
}
}
use of com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutorCallback in project intellij-community by JetBrains.
the class CvsCheckoutProvider method doCheckout.
public void doCheckout(@NotNull final Project project, final CheckoutProvider.Listener listener) {
final CheckoutWizard checkoutWizard = new CheckoutWizard(project);
if (!checkoutWizard.showAndGet()) {
return;
}
final boolean useAlternateCheckoutPath = checkoutWizard.useAlternativeCheckoutLocation();
final File checkoutDirectory = checkoutWizard.getCheckoutDirectory();
final CvsElement[] selectedElements = checkoutWizard.getSelectedElements();
final CvsHandler checkoutHandler = CommandCvsHandler.createCheckoutHandler(checkoutWizard.getConfigurationWithDateOrRevisionSettings(), collectCheckoutPaths(selectedElements), checkoutDirectory, useAlternateCheckoutPath, CvsApplicationLevelConfiguration.getInstance().MAKE_CHECKED_OUT_FILES_READONLY, VcsConfiguration.getInstance(project).getCheckoutOption());
final CvsOperationExecutor executor = new CvsOperationExecutor(null);
executor.performActionSync(checkoutHandler, new CvsOperationExecutorCallback() {
public void executionFinished(boolean successfully) {
if (!executor.hasNoErrors()) {
Messages.showErrorDialog(CvsBundle.message("message.error.checkout", executor.getResult().composeError().getLocalizedMessage()), CvsBundle.message("operation.name.check.out.project"));
}
refreshAfterCheckout(listener, selectedElements, checkoutDirectory, useAlternateCheckoutPath);
}
public void executionFinishedSuccessfully() {
}
public void executeInProgressAfterAction(ModalityContext modaityContext) {
}
});
}
Aggregations