Search in sources :

Example 16 with CvsHandler

use of com.intellij.cvsSupport2.cvshandlers.CvsHandler 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 17 with CvsHandler

use of com.intellij.cvsSupport2.cvshandlers.CvsHandler in project intellij-community by JetBrains.

the class CommandCvsHandler method createAddFilesHandler.

public static CvsHandler createAddFilesHandler(final Project project, Collection<AddedFileInfo> addedRoots) {
    final AddFilesOperation operation = new AddFilesOperation();
    final ArrayList<AddedFileInfo> addedFileInfo = new ArrayList<>();
    for (final AddedFileInfo info : addedRoots) {
        info.clearAllCvsAdminDirectoriesInIncludedDirectories();
        addedFileInfo.addAll(info.collectAllIncludedFiles());
    }
    final ArrayList<VirtualFile> addedFiles = new ArrayList<>();
    for (AddedFileInfo info : addedFileInfo) {
        addedFiles.add(info.getFile());
        operation.addFile(info.getFile(), info.getKeywordSubstitution());
    }
    return new CommandCvsHandler(CvsBundle.message("action.name.add"), operation, FileSetToBeUpdated.selectedFiles(VfsUtilCore.toVirtualFileArray(addedFiles)), VcsConfiguration.getInstance(project).getAddRemoveOption());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AddedFileInfo(com.intellij.cvsSupport2.cvsoperations.cvsAdd.AddedFileInfo) AddFilesOperation(com.intellij.cvsSupport2.cvsoperations.cvsAdd.AddFilesOperation)

Example 18 with CvsHandler

use of com.intellij.cvsSupport2.cvshandlers.CvsHandler in project intellij-community by JetBrains.

the class CommandCvsHandler method createTagHandler.

public static CvsHandler createTagHandler(FilePath[] selectedFiles, String tagName, boolean switchToThisTag, boolean overrideExisting, boolean makeNewFilesReadOnly, Project project) {
    final CompositeOperation operation = new CompositeOperation();
    operation.addOperation(new TagOperation(selectedFiles, tagName, false, overrideExisting));
    if (switchToThisTag) {
        operation.addOperation(new UpdateOperation(selectedFiles, tagName, makeNewFilesReadOnly, project));
    }
    return new CommandCvsHandler(CvsBundle.message("operation.name.create.tag"), operation, FileSetToBeUpdated.selectedFiles(selectedFiles));
}
Also used : TagOperation(com.intellij.cvsSupport2.cvsoperations.cvsTagOrBranch.TagOperation) UpdateOperation(com.intellij.cvsSupport2.cvsoperations.cvsUpdate.UpdateOperation)

Example 19 with CvsHandler

use of com.intellij.cvsSupport2.cvshandlers.CvsHandler in project intellij-community by JetBrains.

the class CommandCvsHandler method createBranchHandler.

public static CvsHandler createBranchHandler(FilePath[] selectedFiles, String branchName, boolean switchToThisBranch, boolean overrideExisting, boolean makeNewFilesReadOnly, Project project) {
    final CompositeOperation operation = new CompositeOperation();
    operation.addOperation(new BranchOperation(selectedFiles, branchName, overrideExisting));
    if (switchToThisBranch) {
        operation.addOperation(new UpdateOperation(selectedFiles, branchName, makeNewFilesReadOnly, project));
    }
    return new CommandCvsHandler(CvsBundle.message("operation.name.create.branch"), operation, FileSetToBeUpdated.selectedFiles(selectedFiles));
}
Also used : BranchOperation(com.intellij.cvsSupport2.cvsoperations.cvsTagOrBranch.BranchOperation) UpdateOperation(com.intellij.cvsSupport2.cvsoperations.cvsUpdate.UpdateOperation)

Example 20 with CvsHandler

use of com.intellij.cvsSupport2.cvshandlers.CvsHandler in project intellij-community by JetBrains.

the class CvsUpdateEnvironment method invokeManualMerging.

private static List<VirtualFile> invokeManualMerging(Collection<String> paths, Project project) {
    final List<VirtualFile> readOnlyFiles = new ArrayList<>();
    final List<VirtualFile> files = new ArrayList<>();
    for (final String path : paths) {
        final VirtualFile virtualFile = CvsVfsUtil.findFileByIoFile(new File(path));
        if (virtualFile != null) {
            files.add(virtualFile);
            if (!virtualFile.isWritable()) {
                readOnlyFiles.add(virtualFile);
            }
        }
    }
    if (readOnlyFiles.size() > 0) {
        final CvsHandler editHandler = CommandCvsHandler.createEditHandler(VfsUtil.toVirtualFileArray(readOnlyFiles), CvsConfiguration.getInstance(project).RESERVED_EDIT);
        new CvsOperationExecutor(true, project, ModalityState.current()).performActionSync(editHandler, CvsOperationExecutorCallback.EMPTY);
        ApplicationManager.getApplication().runWriteAction(() -> {
            for (VirtualFile file : readOnlyFiles) {
                file.refresh(false, false);
            }
        });
    }
    if (!files.isEmpty()) {
        return AbstractVcsHelper.getInstance(project).showMergeDialog(files, new CvsMergeProvider());
    }
    return Collections.emptyList();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CommandCvsHandler(com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler) CvsHandler(com.intellij.cvsSupport2.cvshandlers.CvsHandler) CvsOperationExecutor(com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor) ArrayList(java.util.ArrayList) CvsMergeProvider(com.intellij.cvsSupport2.actions.merge.CvsMergeProvider) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Aggregations

VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 CommandCvsHandler (com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler)10 CvsHandler (com.intellij.cvsSupport2.cvshandlers.CvsHandler)10 CvsOperationExecutor (com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor)9 Project (com.intellij.openapi.project.Project)9 FilePath (com.intellij.openapi.vcs.FilePath)9 File (java.io.File)7 CvsLightweightFile (com.intellij.cvsSupport2.actions.cvsContext.CvsLightweightFile)4 CvsTabbedWindow (com.intellij.cvsSupport2.ui.CvsTabbedWindow)4 CvsContext (com.intellij.cvsSupport2.actions.cvsContext.CvsContext)3 CvsConfiguration (com.intellij.cvsSupport2.config.CvsConfiguration)3 SelectCvsConfigurationDialog (com.intellij.cvsSupport2.config.ui.SelectCvsConfigurationDialog)2 TagOperation (com.intellij.cvsSupport2.cvsoperations.cvsTagOrBranch.TagOperation)2 CreateTagDialog (com.intellij.cvsSupport2.cvsoperations.cvsTagOrBranch.ui.CreateTagDialog)2 UpdateOperation (com.intellij.cvsSupport2.cvsoperations.cvsUpdate.UpdateOperation)2 WatchOperation (com.intellij.cvsSupport2.cvsoperations.cvsWatch.WatchOperation)2 CheckoutWizard (com.intellij.cvsSupport2.ui.experts.checkout.CheckoutWizard)2 VcsException (com.intellij.openapi.vcs.VcsException)2 VcsContext (com.intellij.openapi.vcs.actions.VcsContext)2 ArrayList (java.util.ArrayList)2