From 1be8dd417b2779709c4e6e262bb1ec7590aa671f Mon Sep 17 00:00:00 2001 From: loki Date: Mon, 16 Jun 2003 04:11:38 +0000 Subject: [PATCH] i broke down and added buttons to the debug window to allow copying of the various xml output window contents to the system clipboard so they could be pasted into things like email for more accurate debugging and blah blah. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1957 b35dd754-fafc-0310-a699-88a17e54d16e --- .../jivesoftware/smack/XMPPConnection.java | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/source/org/jivesoftware/smack/XMPPConnection.java b/source/org/jivesoftware/smack/XMPPConnection.java index fc2d20eb1..98a560621 100644 --- a/source/org/jivesoftware/smack/XMPPConnection.java +++ b/source/org/jivesoftware/smack/XMPPConnection.java @@ -58,6 +58,10 @@ import org.jivesoftware.smack.filter.*; import javax.swing.*; import java.net.*; import java.io.*; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Clipboard; import java.awt.*; /** @@ -586,7 +590,55 @@ public class XMPPConnection { allPane.add(new JScrollPane(interpretedText1)); tabbedPane.add("Interpreted Packets", new JScrollPane(interpretedText2)); - debugFrame.getContentPane().add(tabbedPane); + JPanel cPane = new JPanel(); + cPane.setLayout(new BoxLayout(cPane, BoxLayout.Y_AXIS)); + cPane.add(tabbedPane); + + JPanel buttonPane = new JPanel(); + Dimension rigidSpaceDim = new Dimension(15, 1); + buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS)); + JButton jb = new JButton("client->clipboard"); + jb.addActionListener(new ActionListener() { + public void actionPerformed (ActionEvent ae) { + Clipboard clipboard + = debugFrame.getToolkit().getSystemClipboard(); + StringSelection ss = new StringSelection(sentText1.getText()); + + clipboard.setContents(ss, ss); + } + }); + buttonPane.add(jb); + jb = new JButton("server->clipboard"); + jb.addActionListener(new ActionListener() { + public void actionPerformed (ActionEvent ae) { + Clipboard clipboard + = debugFrame.getToolkit().getSystemClipboard(); + StringSelection ss + = new StringSelection(receivedText1.getText()); + + clipboard.setContents(ss, ss); + } + }); + buttonPane.add(Box.createRigidArea(rigidSpaceDim)); + buttonPane.add(jb); + jb = new JButton("interpreted->clipboard"); + jb.addActionListener(new ActionListener() { + public void actionPerformed (ActionEvent ae) { + Clipboard clipboard + = debugFrame.getToolkit().getSystemClipboard(); + StringSelection ss + = new StringSelection(interpretedText1.getText()); + + clipboard.setContents(ss, ss); + } + }); + buttonPane.add(Box.createRigidArea(rigidSpaceDim)); + buttonPane.add(jb); + + cPane.add(buttonPane); + + debugFrame.getContentPane().add(cPane); + debugFrame.pack(); debugFrame.setSize(550, 400); debugFrame.setVisible(true);