mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-30 07:52:06 +01:00
Limited number of rows to show in the table and append text to text area (raw tabs) only when visible. SMACK-95
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2977 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
52eb5a1049
commit
581c07eff7
1 changed files with 120 additions and 84 deletions
|
@ -326,6 +326,12 @@ public class EnhancedDebugger implements SmackDebugger {
|
||||||
ObservableReader debugReader = new ObservableReader(reader);
|
ObservableReader debugReader = new ObservableReader(reader);
|
||||||
readerListener = new ReaderListener() {
|
readerListener = new ReaderListener() {
|
||||||
public void read(String str) {
|
public void read(String str) {
|
||||||
|
if (EnhancedDebuggerWindow.PERSISTED_DEBUGGER &&
|
||||||
|
!EnhancedDebuggerWindow.getInstance().isVisible()) {
|
||||||
|
// Do not add content if the parent is not visible
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int index = str.lastIndexOf(">");
|
int index = str.lastIndexOf(">");
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
receivedText.append(str.substring(0, index + 1));
|
receivedText.append(str.substring(0, index + 1));
|
||||||
|
@ -345,6 +351,12 @@ public class EnhancedDebugger implements SmackDebugger {
|
||||||
ObservableWriter debugWriter = new ObservableWriter(writer);
|
ObservableWriter debugWriter = new ObservableWriter(writer);
|
||||||
writerListener = new WriterListener() {
|
writerListener = new WriterListener() {
|
||||||
public void write(String str) {
|
public void write(String str) {
|
||||||
|
if (EnhancedDebuggerWindow.PERSISTED_DEBUGGER &&
|
||||||
|
!EnhancedDebuggerWindow.getInstance().isVisible()) {
|
||||||
|
// Do not add content if the parent is not visible
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sentText.append(str);
|
sentText.append(str);
|
||||||
if (str.endsWith(">")) {
|
if (str.endsWith(">")) {
|
||||||
sentText.append(NEWLINE);
|
sentText.append(NEWLINE);
|
||||||
|
@ -627,7 +639,9 @@ public class EnhancedDebugger implements SmackDebugger {
|
||||||
* @param dateFormatter the SimpleDateFormat to use to format Dates
|
* @param dateFormatter the SimpleDateFormat to use to format Dates
|
||||||
* @param packet the read packet to add to the table
|
* @param packet the read packet to add to the table
|
||||||
*/
|
*/
|
||||||
private void addReadPacketToTable(SimpleDateFormat dateFormatter, Packet packet) {
|
private void addReadPacketToTable(final SimpleDateFormat dateFormatter, final Packet packet) {
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
String messageType = null;
|
String messageType = null;
|
||||||
String from = packet.getFrom();
|
String from = packet.getFrom();
|
||||||
String type = "";
|
String type = "";
|
||||||
|
@ -657,6 +671,14 @@ public class EnhancedDebugger implements SmackDebugger {
|
||||||
receivedOtherPackets++;
|
receivedOtherPackets++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if we need to remove old rows from the table to keep memory consumption low
|
||||||
|
if (EnhancedDebuggerWindow.PERSISTED_DEBUGGER) {
|
||||||
|
if (EnhancedDebuggerWindow.MAX_TABLE_ROWS > 0 &&
|
||||||
|
messagesTable.getRowCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS) {
|
||||||
|
messagesTable.removeRow(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
messagesTable.addRow(
|
messagesTable.addRow(
|
||||||
new Object[] {
|
new Object[] {
|
||||||
formatXML(packet.toXML()),
|
formatXML(packet.toXML()),
|
||||||
|
@ -671,6 +693,8 @@ public class EnhancedDebugger implements SmackDebugger {
|
||||||
// Update the statistics table
|
// Update the statistics table
|
||||||
updateStatistics();
|
updateStatistics();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the sent packet detail to the messages table.
|
* Adds the sent packet detail to the messages table.
|
||||||
|
@ -678,7 +702,9 @@ public class EnhancedDebugger implements SmackDebugger {
|
||||||
* @param dateFormatter the SimpleDateFormat to use to format Dates
|
* @param dateFormatter the SimpleDateFormat to use to format Dates
|
||||||
* @param packet the sent packet to add to the table
|
* @param packet the sent packet to add to the table
|
||||||
*/
|
*/
|
||||||
private void addSentPacketToTable(SimpleDateFormat dateFormatter, Packet packet) {
|
private void addSentPacketToTable(final SimpleDateFormat dateFormatter, final Packet packet) {
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
String messageType = null;
|
String messageType = null;
|
||||||
String to = packet.getTo();
|
String to = packet.getTo();
|
||||||
String type = "";
|
String type = "";
|
||||||
|
@ -708,6 +734,14 @@ public class EnhancedDebugger implements SmackDebugger {
|
||||||
sentOtherPackets++;
|
sentOtherPackets++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if we need to remove old rows from the table to keep memory consumption low
|
||||||
|
if (EnhancedDebuggerWindow.PERSISTED_DEBUGGER) {
|
||||||
|
if (EnhancedDebuggerWindow.MAX_TABLE_ROWS > 0 &&
|
||||||
|
messagesTable.getRowCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS) {
|
||||||
|
messagesTable.removeRow(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
messagesTable.addRow(
|
messagesTable.addRow(
|
||||||
new Object[] {
|
new Object[] {
|
||||||
formatXML(packet.toXML()),
|
formatXML(packet.toXML()),
|
||||||
|
@ -723,6 +757,8 @@ public class EnhancedDebugger implements SmackDebugger {
|
||||||
// Update the statistics table
|
// Update the statistics table
|
||||||
updateStatistics();
|
updateStatistics();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private String formatXML(String str) {
|
private String formatXML(String str) {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue