{
private ReviewFileChooser fileChooser;
public void actionPerformed(AnActionEvent e)
{
Project project = e.getData(PlatformDataKeys.PROJECT);
if (project == null)
{
return;
}
if (fileChooser == null)
{
fileChooser = new ReviewFileChooser(project);
}
VirtualFile vFile = fileChooser.selectFileToOpen(
RevuVfsUtils.findFile(RevuUtils.getWorkspaceSettings(project).getLastSelectedReviewDir()));
if (vFile != null)
{
ReviewManager reviewManager = project.getComponent(ReviewManager.class);
Review review = reviewManager.getReviewByFile(new File(vFile.getPath()));
if (review != null)
{
Messages.showWarningDialog(project,
RevuBundle.message("projectSettings.review.import.fileAlreadyExists.text", review.getName()),
RevuBundle.message("projectSettings.review.import.error.title"));
return;
}
//@TODO check path outside from project
review = new Review();
review.setFile(new File(vFile.getPath()));
if (!reviewManager.load(review, false))
{
return;
}
if (reviewManager.getReviewByName(review.getName()) != null)
{
Messages.showWarningDialog(project,
RevuBundle.message("projectSettings.review.import.nameAlreadyExists.text", review.getName()),
RevuBundle.message("projectSettings.review.import.error.title"));
return;
}
final RevuProjectSettingsForm form = project.getComponent(RevuProjectSettingsForm.class);
form.addItem(review);
}
}