{
public void actionPerformed(AnActionEvent e)
{
JList liReviews = (JList) e.getData(PlatformDataKeys.CONTEXT_COMPONENT);
DefaultListModel model = (DefaultListModel) liReviews.getModel();
Review selectedReview = (Review) liReviews.getSelectedValue();
// Check afferent link
List<Review> afferentReviews = new ArrayList<Review>();
for (int i=0; i<model.getSize(); i++)
{
Review review = (Review) model.get(i);
if (selectedReview.equals(review.getExtendedReview()))
{
afferentReviews.add(review);
}
}
String msgKey = afferentReviews.isEmpty()
? "projectSettings.confirmRemoveReview.text"
: "projectSettings.confirmRemoveReviewWithAfferentLink.text";
int result = Messages.showOkCancelDialog(liReviews,
RevuBundle.message(msgKey, selectedReview.getName()),
RevuBundle.message("projectSettings.confirmRemoveReview.title"),
Messages.getWarningIcon());
if (result == DialogWrapper.OK_EXIT_CODE)
{
model.removeElement(selectedReview);
for (Review review : afferentReviews)
{
review.setExtendedReview(null);
}
liReviews.setSelectedIndex(0);
}
}