Search in sources :

Example 1 with MigrateRootDialog

use of com.intellij.cvsSupport2.ui.MigrateRootDialog in project intellij-community by JetBrains.

the class MigrateCvsRootAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent event) {
    final VcsContext context = CvsContextWrapper.createInstance(event);
    final VirtualFile selectedFile = context.getSelectedFile();
    final Project project = context.getProject();
    final MigrateRootDialog dialog = new MigrateRootDialog(project, selectedFile);
    if (!dialog.showAndGet()) {
        return;
    }
    final File directory = dialog.getSelectedDirectory();
    final boolean shouldReplaceAllRoots = dialog.shouldReplaceAllRoots();
    final List<File> rootFiles = new ArrayList<>();
    try {
        if (shouldReplaceAllRoots) {
            collectRootFiles(directory, null, rootFiles);
        } else {
            collectRootFiles(directory, dialog.getCvsRoot(), rootFiles);
        }
    } catch (IOException e) {
        LOG.error(e);
        return;
    }
    final CvsRootConfiguration cvsConfiguration = dialog.getSelectedCvsConfiguration();
    final String cvsRoot = cvsConfiguration.getCvsRootAsString();
    for (final File file : rootFiles) {
        try {
            FileUtils.writeLine(file, cvsRoot);
        } catch (IOException e) {
            LOG.error(e);
            break;
        }
    }
    final AccessToken token = ApplicationManager.getApplication().acquireReadActionLock();
    try {
        for (File file : rootFiles) {
            CvsVfsUtil.findFileByIoFile(file).refresh(true, false);
        }
    } finally {
        token.finish();
    }
    StatusBar.Info.set("Finished migrating CVS root to " + cvsRoot, project);
}
Also used : VcsContext(com.intellij.openapi.vcs.actions.VcsContext) VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) AccessToken(com.intellij.openapi.application.AccessToken) ArrayList(java.util.ArrayList) MigrateRootDialog(com.intellij.cvsSupport2.ui.MigrateRootDialog) IOException(java.io.IOException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) CvsRootConfiguration(com.intellij.cvsSupport2.config.CvsRootConfiguration)

Aggregations

CvsRootConfiguration (com.intellij.cvsSupport2.config.CvsRootConfiguration)1 MigrateRootDialog (com.intellij.cvsSupport2.ui.MigrateRootDialog)1 AccessToken (com.intellij.openapi.application.AccessToken)1 Project (com.intellij.openapi.project.Project)1 VcsContext (com.intellij.openapi.vcs.actions.VcsContext)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1