コード例 #1
0
ファイル: BrowserTree.java プロジェクト: colincrist/hermesjms
  /**
   * 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());
    }
  }
コード例 #2
0
ファイル: BrowserTree.java プロジェクト: colincrist/hermesjms
  private boolean doBytesMessageTransfer(Collection<byte[]> messages) {
    List<DestinationConfigTreeNode> nodes = getSelectedDestinationNodes();

    lastDndAction = TransferHandler.COPY;

    if (nodes.size() > 0 && messages.size() > 0) {
      final DestinationConfigTreeNode destinationNode = nodes.get(0);
      final HermesTreeNode hermesNode = getSelectedHermesNode();

      if (hermesNode != null && destinationNode != null) {
        HermesBrowser.getBrowser()
            .getActionFactory()
            .createMessageCopyAction(
                hermesNode.getHermes(),
                destinationNode.getDestinationName(),
                destinationNode.getDomain(),
                messages,
                true,
                true);
      }
    }

    return true;
  }
コード例 #3
0
ファイル: BrowserTree.java プロジェクト: colincrist/hermesjms
  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;
  }