final Bundle[] bl = Activator.getBundles();
Bundle[] selbl = Activator.desktop.getSelectedBundles();
if(selbl != null && selbl.length > 0) {
int mask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
Bundle b = selbl[0];
JMenuItem item = makeBundleItem(b, "#" + b.getBundleId() + " " + Util.getBundleName(b));
menu.add(item);
menu.add(new JPopupMenu.Separator());
}
{
JMenuItem item = new JMenuItem("New window");
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
addWindow();
}
});
menu.add(item);
menu.add(new JPopupMenu.Separator());
}
menu.add(new JMenuItem(Activator.desktop.actionStopBundles));
menu.add(new JMenuItem(Activator.desktop.actionStartBundles));
menu.add(new JMenuItem(Activator.desktop.actionUpdateBundles));
menu.add(new JMenuItem(Activator.desktop.actionUninstallBundles));
menu.add(new JMenuItem(Activator.desktop.actionRefreshBundles));
menu.add(new JPopupMenu.Separator());
autorefreshCB = new JCheckBoxMenuItem("Automatic view refresh", true);
autorefreshCB.setModel(autorefreshModel);
JMenuItem refreshItem = new JMenuItem("Refresh view");
refreshItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
if(Activator.desktop != null &&
Activator.desktop.pm != null) {
Activator.desktop.pm.refresh();
for(Iterator it = views.iterator(); it.hasNext(); ) {
JSoftGraphBundle view = (JSoftGraphBundle)it.next();
view.startFade();
}
}
}
});
menu.add(autorefreshCB);
menu.add(refreshItem);
menu.add(new JPopupMenu.Separator());
for(int i = 0; bl != null && i < bl.length; i++) {
bundles.put(new Long(bl[i].getBundleId()), bl[i]);
}
Map buckets = Activator.desktop.makeBundleBuckets();
for(Iterator it = buckets.keySet().iterator(); it.hasNext(); ) {
Object key = it.next();
Object val = buckets.get(key);
if(val instanceof Collection) {
Collection bucket = (Collection)val;
JMenu subMenu = new JMenu(key.toString());
for(Iterator it2 = bucket.iterator(); it2.hasNext(); ) {
Bundle bundle = (Bundle)it2.next();
JMenuItem item = makeBundleItem(bundle, null);
subMenu.add(item);
}
menu.add(subMenu);
} else if(val instanceof Bundle) {
Bundle bundle = (Bundle)val;
JMenuItem item = makeBundleItem(bundle, null);
menu.add(item);
} else {
throw new RuntimeException("Unknown object=" + val);
}