final JideMenu addToSessionItem = new JideMenu("Add to");
final JMenuItem createContextItem = new JMenuItem(ActionRegistry.getAction(CreateNewJNDIContextAction.class));
final JMenuItem renameBindingItem = new JMenuItem(ActionRegistry.getAction(RenameJNDIBindingAction.class));
final JMenuItem unbindItem = new JMenuItem(ActionRegistry.getAction(JNDIUnbindAction.class));
contextTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener()
{
public void valueChanged(TreeSelectionEvent e)
{
if (e.getNewLeadSelectionPath() == null)
{
addToSessionItem.setEnabled(false);
}
else
{
final TreeNode node = (TreeNode) e.getNewLeadSelectionPath().getLastPathComponent();
addToSessionItem.setEnabled(node instanceof QueueTreeNode || node instanceof TopicTreeNode || node instanceof QueueTopicTreeNode);
}
}
});
addToSessionItem.addMouseListener(new MouseAdapter()
{
public void mouseEntered(MouseEvent e)
{
addToSessionItem.removeAll();
for (final String sessionId : HermesBrowser.getBrowser().getBrowserTree().getAllHermesIds())
{
final JMenuItem menuItem = new JMenuItem(sessionId);
// Cascade the enabled state down to the menu items from the
// addToSessionItem...
addToSessionItem.addPropertyChangeListener("enabled", new PropertyChangeListener()
{
public void propertyChange(PropertyChangeEvent evt)
{
menuItem.setEnabled((Boolean) evt.getNewValue());
}
});
addToSessionItem.add(menuItem);
menuItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
HermesBrowser.getBrowser().getBrowserTree().doTransfer(
new JMSAdministeredObjectTransferable(new HermesConfigGroup(sessionId, contextTree.getSelectedDestinations(), contextTree
.getSelectedConnectionFactories())), TransferHandler.COPY);
}
});
contextTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener()
{
public void valueChanged(TreeSelectionEvent e)
{
if (e.getNewLeadSelectionPath() != null)
{