ProgramReceiveTarget[] targets = plugin.getProgramReceiveTargets();
if (!plugin.canReceiveProgramsWithTarget()) {
JMenuItem item = new JMenuItem(plugin.getInfo().getName());
item.setFont(MenuUtil.CONTEXT_MENU_PLAINFONT);
Icon icon = plugin.getPluginIcon();
item.setIcon(icon != null ? icon : null);
menu.add(item);
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Program[] programs = collectProgramsFromNode(node);
if ((programs != null) && (programs.length > 0)) {
plugin.receivePrograms(programs, ProgramReceiveTarget.createDefaultTargetForProgramReceiveIfId(plugin.getId()));
}
}
});
} else if (targets.length == 1 && (!(o instanceof ProgramReceiveTarget) || !o.equals(targets[0]))) {
JMenuItem item = new JMenuItem(targets[0].toString());
item.setFont(MenuUtil.CONTEXT_MENU_PLAINFONT);
Icon icon = plugin.getPluginIcon();
item.setIcon(icon != null ? icon : null);
menu.add(item);
final ProgramReceiveTarget target = targets[0];
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Program[] programs = collectProgramsFromNode(node);
if ((programs != null) && (programs.length > 0)) {
plugin.receivePrograms(programs, target);
}
}
});
} else if (targets.length >= 1) {
JMenu subMenu = new JMenu(plugin.getInfo().getName());
subMenu.setFont(MenuUtil.CONTEXT_MENU_PLAINFONT);
Icon icon = plugin.getPluginIcon();
subMenu.setIcon(icon != null ? icon : null);
menu.add(subMenu);
for (final ProgramReceiveTarget target : targets) {