for (InternalPluginProxyIf internalProxy : InternalPluginProxyList.getInstance().getAvailableProxys()) {
if (internalProxy instanceof ProgramReceiveIf) {
final ProgramReceiveIf receiveProxy = (ProgramReceiveIf) internalProxy;
if(receiveProxy.canReceiveProgramsWithTarget() && o != internalProxy) {
final ProgramReceiveTarget target = receiveProxy.getProgramReceiveTargets()[0];
JMenuItem item = new JMenuItem(target.getTargetName());
item.setFont(MenuUtil.CONTEXT_MENU_PLAINFONT);
item.setIcon(internalProxy.getIcon());
menu.add(item);
item.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
Program[] programs = collectProgramsFromNode(node);
if ((programs != null) &&(programs.length > 0)) {
receiveProxy.receivePrograms(programs, target);
}
}
});
}
}
}
PluginProxy[] plugins = PluginProxyManager.getInstance().getActivatedPlugins();
for (final PluginProxy plugin : plugins) {
if ((plugin.canReceiveProgramsWithTarget())
&& plugin.getProgramReceiveTargets() != null
&& plugin.getProgramReceiveTargets().length > 0) {
if ((currentPlugin == null) || (!currentPlugin.getId().equals(plugin.getId()))) {
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) {
if (o == null || !o.equals(target)) {
JMenuItem item = new JMenuItem(target.toString());
item.setFont(MenuUtil.CONTEXT_MENU_PLAINFONT);
subMenu.add(item);
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {