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