org.bidib.wizard.nodes.client.view.AspectMappingTableMenu Maven / Gradle / Ivy
package org.bidib.wizard.nodes.client.view;
import java.awt.event.ActionEvent;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import org.bidib.wizard.api.locale.Resources;
import org.bidib.wizard.nodes.client.model.AspectRow;
public class AspectMappingTableMenu extends JPopupMenu {
private static final long serialVersionUID = 1L;
private JMenuItem addMappingItem;
private JMenuItem deleteMappingItem;
private final NodesClientView nodesClientView;
public AspectMappingTableMenu(final NodesClientView nodesClientView) {
this.nodesClientView = nodesClientView;
addMappingItem = new JMenuItem(Resources.getString(AspectMappingTableMenu.class, "addMapping"));
addMappingItem.addActionListener(e -> fireAddMapping(e));
deleteMappingItem = new JMenuItem(Resources.getString(AspectMappingTableMenu.class, "deleteMapping"));
deleteMappingItem.addActionListener(e -> fireDeleteMapping(e));
}
public JMenuItem getAddMappingItem(final AspectRow row) {
this.addMappingItem.putClientProperty("row", row);
return this.addMappingItem;
}
public JMenuItem getDeleteMappingItem(final AspectRow row) {
this.deleteMappingItem.putClientProperty("row", row);
return this.deleteMappingItem;
}
private void fireAddMapping(ActionEvent e) {
nodesClientView.addMapping((AspectRow) addMappingItem.getClientProperty("row"));
}
private void fireDeleteMapping(ActionEvent e) {
nodesClientView.deleteMapping((AspectRow) deleteMappingItem.getClientProperty("row"));
}
}