* {@inheritDoc}
*/
@Override
protected void apply(Map<Review, Review> items) throws ConfigurationException
{
ReviewManager reviewManager = project.getComponent(ReviewManager.class);
List<Review> originalReviews = getOriginalItems();
// Manage existing reviews
List<String> projectReviewFiles = new ArrayList<String>();
List<String> workspaceReviewFiles = new ArrayList<String>();
for (Map.Entry<Review, Review> entry : items.entrySet())
{
Review editedReview = entry.getKey();
Review originalReview = entry.getValue();
if (editedReview.isEmbedded())
{
continue;
}
String reviewFilePath = RevuVfsUtils.buildRelativePath(project, editedReview.getFile());
if (editedReview.isShared())
{
projectReviewFiles.add(reviewFilePath);
}
else
{
workspaceReviewFiles.add(reviewFilePath);
}
// No change
if ((originalReview != null) && (originalReview.equals(editedReview)))
{
continue;
}
// Change original review to avoid handling an obsolete instance
if (originalReview == null)
{
originalReview = editedReview;
}
else
{
originalReview.copyFromTemplate(editedReview);
}
try
{
reviewManager.save(originalReview);
}
catch (Exception e)
{
LOGGER.warn(e);
final String details = ((e.getLocalizedMessage() == null) ? e.toString() : e.getLocalizedMessage());
throw new ConfigurationException(
RevuBundle.message("projectSettings.error.save.title.text", originalReview.getName(), details),
RevuBundle.message("general.plugin.title"));
}
}
// Delete obsolete reviews
for (Review review : originalReviews)
{
if (!items.containsValue(review))
{
reviewManager.removeReview(review);
}
}
RevuProjectSettingsComponent projectSettingsComponent =
project.getComponent(RevuProjectSettingsComponent.class);