private void maybeRefocusDocument(TreeNode treeNode) { DocumentComponent found = null; if (treeNode instanceof DestinationConfigTreeNode) { final DestinationConfigTreeNode node = (DestinationConfigTreeNode) treeNode; found = HermesBrowser.getBrowser().getOpenQueueBrowser(node.getConfig()); } else if (treeNode instanceof MessageStoreTreeNode) { final MessageStoreTreeNode node = (MessageStoreTreeNode) treeNode; found = HermesBrowser.getBrowser().getOpenStoreBrowser(node.getMessageStore()); } if (found != null) { HermesBrowser.getBrowser().getDocumentPane().setActiveDocument(found.getName()); } }
/** * Called whenever the value of the selection changes, we watch this to cache whenever * HermesTreeNode is in the selection path and to change the components tooltip text. */ public void valueChanged(TreeSelectionEvent e) { final TreePath treePath = e.getNewLeadSelectionPath(); try { if (treePath != null) { for (int i = 0; i < treePath.getPathCount(); i++) { if (treePath.getPathComponent(i) instanceof HermesTreeNode) { final HermesTreeNode node = (HermesTreeNode) treePath.getPathComponent(i); lastSelectedHermesTreeNode = node; setToolTipText(node.getHermes().getMetaData().getToolTipText()); } else if (treePath.getPathComponent(i) instanceof DestinationConfigTreeNode) { final DestinationConfigTreeNode node = (DestinationConfigTreeNode) treePath.getPathComponent(i); setToolTipText(node.getDestinationName()); maybeRefocusDocument(node); } else if (treePath.getPathComponent(i) instanceof RepositoryTreeNode) { final RepositoryTreeNode node = (RepositoryTreeNode) treePath.getPathComponent(i); setToolTipText(node.getRepository().getId()); } else if (treePath.getPathComponent(i) instanceof MessageStoreTreeNode) { final MessageStoreTreeNode node = (MessageStoreTreeNode) treePath.getPathComponent(i); setToolTipText(node.getMessageStore().getTooltipText()); maybeRefocusDocument(node); } else if (treePath.getPathComponent(i) instanceof MessageStoreURLTreeNode) { final MessageStoreURLTreeNode node = (MessageStoreURLTreeNode) treePath.getPathComponent(i); setToolTipText(node.getURL()); } } } } catch (JMSException ex) { Hermes.ui.getDefaultMessageSink().add(ex.getMessage()); } }
private boolean doMessagesTransfer(MessageGroup messages, int action) { List<DestinationConfigTreeNode> nodes = getSelectedDestinationNodes(); if (nodes.size() > 0) { final DestinationConfigTreeNode destinationNode = nodes.get(0); final HermesTreeNode hermesNode = getSelectedHermesNode(); if (hermesNode != null && destinationNode != null) { Collection<Message> selected = messages.getSelectedMessages(); Message[] messagesArray = messages.getSelectedMessages().toArray(new Message[selected.size()]); if (selected.size() == 1 && action == TransferHandler.COPY && MessageEditorDialog.canEdit(messagesArray[0])) { try { Message message = selected.iterator().next(); MessageEditorDialog dialog = new MessageEditorDialog( message, destinationNode.getDestinationName(), destinationNode.getDomain(), new AbstractEditedMessageHandler(hermesNode.getHermes()) { @Override public void onMessage(Message message) { HermesBrowser.getBrowser() .getActionFactory() .createMessageCopyAction( hermesNode.getHermes(), destinationNode.getDestinationName(), destinationNode.getDomain(), new ArrayList(Arrays.asList(message)), false, true); } }); dialog.setLocationRelativeTo(HermesBrowser.getBrowser()); dialog.setVisible(true); } catch (JMSException ex) { HermesBrowser.getBrowser().showErrorDialog(ex); } } else { if (action == TransferHandler.COPY) { HermesBrowser.getBrowser() .getActionFactory() .createMessageCopyAction( hermesNode.getHermes(), destinationNode.getDestinationName(), destinationNode.getDomain(), selected, true, true); } else { HermesBrowser.getBrowser() .getActionFactory() .createMessageMoveAction( hermesNode.getHermes(), destinationNode.getDestinationName(), destinationNode.getDomain(), selected); } } } } else { if (getSelectionPath() != null) { if (getSelectionPath().getLastPathComponent() instanceof RepositoryTreeNode) { final RepositoryTreeNode node = (RepositoryTreeNode) getSelectionPath().getLastPathComponent(); try { node.getRepository().addMessages(messages.getHermes(), messages.getSelectedMessages()); } catch (JMSException e) { throw new HermesRuntimeException(e); } } else if (getSelectionPath().getLastPathComponent() instanceof MessageStoreTreeNode) { final MessageStoreTreeNode node = (MessageStoreTreeNode) getSelectionPath().getLastPathComponent(); HermesBrowser.getBrowser() .getThreadPool() .invokeLater( new AddToMessageStoreTask( node.getMessageStore(), messages.getSelectedMessages())); } } else { HermesBrowser.getBrowser().showErrorDialog("No session/destination selected for copy"); } } return true; }
public void remove(MessageStoreTreeNode node) { MutableTreeNode parent = (MutableTreeNode) node.getParent(); node.close(); parent.remove(node); getBrowserModel().nodeStructureChanged(parent); }