Ejemplo n.º 1
0
    public void actionPerformed(ActionEvent ae) {
      updatePanel();

      Message message = messagePanel.getMessage();
      if (message != null) {
        JTextPane textPane = messagePanel.getTextPane();
        int pos = textPane.getCaretPosition();
        Message.Element element = message.findElement(pos);
        if (logger.isInfoEnabled()) logger.info("Complete element {}.", element);

        boolean showPopup = false;
        if (element.getType() == Message.Element.Type.HashTag) {
          populateHashTags(element);
          showPopup = true;
        } else if (element.getType() == Message.Element.Type.Recipient) {
          populateRecipients(element);
          showPopup = true;
        }
        if (showPopup) {
          try {
            Rectangle viewPos = textPane.modelToView(pos);
            int x = viewPos.x;
            int y = viewPos.y + viewPos.height;

            popup.show(textPane, x, y);
          } catch (BadLocationException e) {
            e
                .printStackTrace(); // To change body of catch statement use File | Settings | File
                                    // Templates.
          }
        }
      }
    }
Ejemplo n.º 2
0
 public void actionPerformed(ActionEvent actionEvent) {
   Message message = messagePanel.getMessage();
   if (message != null) {
     JTextPane textPane = messagePanel.getTextPane();
     if (logger.isInfoEnabled()) logger.info("Complete element {}.", element);
     StyledDocument doc = textPane.getStyledDocument();
     try {
       doc.remove(element.getOffset(), element.getText().length());
       doc.insertString(element.getOffset(), text, null);
     } catch (BadLocationException e) {
       e
           .printStackTrace(); // To change body of catch statement use File | Settings | File
                               // Templates.
     }
   }
 }