}
public static JidePopupMenu createBrowserTreePopup(final BrowserTree tree)
{
final JidePopupMenu popupMenu = new JidePopupMenu();
final JideMenu watchMenu = new JideMenu("Watch");
final JideMenu newMenu = new JideMenu("New");
final JideMenu recordMenu = new JideMenu("Record to");
final JMenuItem browseItem = new JMenuItem(ActionRegistry.getAction(BrowseDestinationOrContextAction.class));
final JMenuItem browseWithSelectorItem = new JMenuItem(ActionRegistry.getAction(BrowseDestinationWithSelectorAction.class)) ;
final JMenuItem searchItem = new JMenuItem(ActionRegistry.getAction(SearchDestinationOrContextAction.class));
final JMenuItem truncateItem = new JMenuItem(ActionRegistry.getAction(TruncateAction.class));
final JMenuItem editItem = new JMenuItem(ActionRegistry.getAction(EditObjectAction.class));
final JMenuItem unsubscribe = new JMenuItem(ActionRegistry.getAction(DurableUnsubscribeAction.class));
final JMenuItem addSession = new JMenuItem(ActionRegistry.getAction(CreateNewSessionAction.class));
final JMenuItem addContext = new JMenuItem(ActionRegistry.getAction(CreateNewContextAction.class));
final JMenuItem addStore = new JMenuItem(ActionRegistry.getAction(CreateNewMessageStoreAction.class));
final JMenuItem copySession = new JMenuItem(ActionRegistry.getAction(CopyBrowserNodeAction.class));
final JMenuItem addQueue = new JMenuItem(ActionRegistry.getAction(AddQueueAction.class));
final JMenuItem addTopic = new JMenuItem(ActionRegistry.getAction(AddTopicAction.class));
final JMenuItem addDurableTopic = new JMenuItem(ActionRegistry.getAction(AddDurableTopicAction.class));
final JMenuItem delete = new JMenuItem(ActionRegistry.getAction(DeleteBrowserTreeNodeAction.class));
final JMenuItem discover = new JMenuItem(ActionRegistry.getAction(DiscoverDestinationsAction.class));
final JMenuItem statistics = new JMenuItem(ActionRegistry.getAction(GetDestinationStatisticsAction.class));
final JMenuItem newWatch = new JMenuItem(ActionRegistry.getAction(CreateNewWatchAction.class));
watchMenu.setIcon(IconCache.getIcon("hermes.watch"));
watchMenu.setEnabled(false);
newMenu.add(new JMenuItem(ActionRegistry.getAction(SendNewMessageAction.class))) ;
newMenu.add(addSession);
newMenu.add(addContext);
newMenu.add(addQueue);
newMenu.add(addTopic);
newMenu.add(addDurableTopic) ;
// newMenu.add(new JMenuItem(ActionRegistry.getAction(CreateNewJDBCAction.class))) ;
newMenu.add(addStore);
newWatch.addPropertyChangeListener("enabled", new PropertyChangeListener()
{
public void propertyChange(PropertyChangeEvent evt)
{
watchMenu.setEnabled((Boolean) evt.getNewValue());
}
});
popupMenu.add(newMenu);
popupMenu.add(editItem);
popupMenu.add(statistics);
popupMenu.add(copySession);
popupMenu.add(discover);
popupMenu.add(delete);
popupMenu.addSeparator() ;
popupMenu.add(browseItem);
popupMenu.add(browseWithSelectorItem) ;
popupMenu.add(searchItem);
popupMenu.add(truncateItem);
popupMenu.add(watchMenu);
popupMenu.add(recordMenu);
popupMenu.add(new JMenuItem(ActionRegistry.getAction(SaveAllMessagesAsXMLAction.class))) ;
popupMenu.add(ActionRegistry.getAction(ReplayAction.class));
popupMenu.add(unsubscribe);
popupMenu.addSeparator() ;
popupMenu.add(new CascadeBrowserTreeAction(tree)) ;
popupMenu.add(new ExpandBrowserTreeAction(tree)) ;
popupMenu.add(new CollapseBrowserTreeAction(tree)) ;
recordMenu.addMouseListener(new MouseAdapter()
{
@Override
public void mouseEntered(MouseEvent e)
{
recordMenu.removeAll();
final Collection<MessageStore> stores = HermesBrowser.getBrowser().getBrowserTree().getMessageStores();
final boolean isEnabled = tree.getSelectionPath() != null && tree.getSelectionPath().getLastPathComponent() instanceof DestinationConfigTreeNode ;
if (stores.size() > 0)
{
for (final MessageStore store : stores)
{
final JMenuItem item = new JMenuItem(store.getId());
item.setEnabled(isEnabled);
item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
final Hermes hermes = HermesBrowser.getBrowser().getBrowserTree().getSelectedHermesNode().getHermes();
final DestinationConfigTreeNode node = HermesBrowser.getBrowser().getBrowserTree().getFirstSelectedDestinationNode();
if (node != null)
{
HermesBrowser.getBrowser().getThreadPool().invokeLater(new RecordDestinationTask(hermes, node, store));
}
}
});
recordMenu.add(item);
}
}
else
{
recordMenu.add(new JMenuItem("<no stores>"));
}
}
});