/** * Adds the sent packet detail to the messages table. * * @param dateFormatter the SimpleDateFormat to use to format Dates * @param packet the sent packet to add to the table */ private void addSentPacketToTable(final SimpleDateFormat dateFormatter, final Packet packet) { SwingUtilities.invokeLater( new Runnable() { public void run() { String messageType; String to = packet.getTo(); String type = ""; Icon packetTypeIcon; sentPackets++; if (packet instanceof IQ) { packetTypeIcon = iqPacketIcon; messageType = "IQ Sent (class=" + packet.getClass().getName() + ")"; type = ((IQ) packet).getType().toString(); sentIQPackets++; } else if (packet instanceof Message) { packetTypeIcon = messagePacketIcon; messageType = "Message Sent"; type = ((Message) packet).getType().toString(); sentMessagePackets++; } else if (packet instanceof Presence) { packetTypeIcon = presencePacketIcon; messageType = "Presence Sent"; type = ((Presence) packet).getType().toString(); sentPresencePackets++; } else { packetTypeIcon = unknownPacketTypeIcon; messageType = packet.getClass().getName() + " Sent"; sentOtherPackets++; } // Check if we need to remove old rows from the table to keep memory consumption low if (EnhancedDebuggerWindow.MAX_TABLE_ROWS > 0 && messagesTable.getRowCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS) { messagesTable.removeRow(0); } messagesTable.addRow( new Object[] { formatXML(packet.toXML()), dateFormatter.format(new Date()), packetSentIcon, packetTypeIcon, messageType, packet.getPacketID(), type, to, "" }); // Update the statistics table updateStatistics(); } }); }
public void userHasLogged(final String user) { final EnhancedDebugger debugger = this; SwingUtilities.invokeLater( new Runnable() { public void run() { userField.setText(user); EnhancedDebuggerWindow.userHasLogged(debugger, user); // Add the connection listener to the connection so that the debugger can be notified // whenever the connection is closed. connection.addConnectionListener(connListener); } }); }