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();
}
}
}
}
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());
}
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));
}
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));
}
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();
}
Aggregations