* @return A {@link JPopupMenu} that allows for changing value mappings.
*/
private JPopupMenu setUpPopupMenu(final int itemIndex) {
JPopupMenu m = new JPopupMenu();
final ICACellRenderer cr = getCACellRenderer();
final List<ICAValueMapper> mappers = cr.getMappers();
for (ICAValueMapper vm : mappers) {
vm.addMappingChangedListener(this);
}
for (int i = 0; i < cr.getInputs().size(); i++) {
Class<?> c = cr.getInputs().get(i);
final int j = i;
final ICAValueMapperEditor editor =
CAValueMapperEditorManager.getValueMapperEditorFor(c);
JMenuItem mi =
new JMenuItem("Edit " + cr.getInputName(i) + " for "
+ getModel().getElementAt(itemIndex) + " ...");
if (editor == null) {
mi.setEnabled(false);
} else {
mi.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
editor.editMappingFor(cr.getInputName(j), itemIndex, mappers.get(j));
}
});
}
m.add(mi);