IAction removeAllLabels = new Action("Remove All Labels") {
@Override
public void run() {
Collection<ILabel> labels = DynamicDAO.loadAll(ILabel.class);
new LabelAction(labels, (IStructuredSelection) fResultViewer.getSelection(), false).run();
}
};
removeAllLabels.setEnabled(!labels.isEmpty());
labelMenu.add(removeAllLabels);
labelMenu.add(new Separator());
for (final ILabel label : labels) {
IAction labelAction = new Action(label.getName(), IAction.AS_CHECK_BOX) {
@Override
public void run() {
Set<ILabel> labels = new HashSet<ILabel>(1);
labels.add(label);
new LabelAction(labels, (IStructuredSelection) fResultViewer.getSelection(), isChecked()).run();
}
};
labelAction.setChecked(selectedLabels.contains(label));
labelMenu.add(labelAction);