Search in sources :

Example 1 with CvsOperationExecutorCallback

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();
            }
        }
    }
}
Also used : CvsTabbedWindow(com.intellij.cvsSupport2.ui.CvsTabbedWindow) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with CvsOperationExecutorCallback

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) {
        }
    });
}
Also used : CvsHandler(com.intellij.cvsSupport2.cvshandlers.CvsHandler) CommandCvsHandler(com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler) CvsOperationExecutor(com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor) CvsElement(com.intellij.cvsSupport2.cvsBrowser.CvsElement) ModalityContext(com.intellij.cvsSupport2.cvsExecution.ModalityContext) File(java.io.File) CvsOperationExecutorCallback(com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutorCallback) CheckoutWizard(com.intellij.cvsSupport2.ui.experts.checkout.CheckoutWizard)

Aggregations

CvsElement (com.intellij.cvsSupport2.cvsBrowser.CvsElement)1 CvsOperationExecutor (com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor)1 CvsOperationExecutorCallback (com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutorCallback)1 ModalityContext (com.intellij.cvsSupport2.cvsExecution.ModalityContext)1 CommandCvsHandler (com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler)1 CvsHandler (com.intellij.cvsSupport2.cvshandlers.CvsHandler)1 CvsTabbedWindow (com.intellij.cvsSupport2.ui.CvsTabbedWindow)1 CheckoutWizard (com.intellij.cvsSupport2.ui.experts.checkout.CheckoutWizard)1 File (java.io.File)1 NotNull (org.jetbrains.annotations.NotNull)1