diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java
index f44cf781a..d2961363b 100755
--- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java
@@ -1081,9 +1081,61 @@ private void ensureDocumentSize()
{
logger.error("Error removing messages from chat: ", e);
}
+
+ if(firstMsgElement.getName().equals("table"))
+ {
+ // as we have removed a header for maybe several messages,
+ // delete all messages without header
+ deleteAllMessagesWithoutHeader();
+ }
}
}
+ /**
+ * Deletes all messages "div"s that are missing their header the table tag.
+ * The method calls itself recursively.
+ */
+ private void deleteAllMessagesWithoutHeader()
+ {
+ String[] ids = new String[]
+ {ChatHtmlUtils.MESSAGE_TEXT_ID,
+ "statusMessage",
+ "systemMessage",
+ "actionMessage"};
+
+ Element firstMsgElement = findElement(Attribute.ID, ids);
+
+ if(firstMsgElement == null
+ || !firstMsgElement.getName().equals("div"))
+ {
+ return;
+ }
+
+ int startIndex = firstMsgElement.getStartOffset();
+ int endIndex = firstMsgElement.getEndOffset();
+
+ try
+ {
+ // Remove the message.
+ if(endIndex - startIndex < document.getLength())
+ this.document.remove(startIndex, endIndex - startIndex);
+ else
+ {
+ // currently there is a problem of deleting the last message
+ // if it is the last message on the view
+ return;
+ }
+ }
+ catch (BadLocationException e)
+ {
+ logger.error("Error removing messages from chat: ", e);
+
+ return;
+ }
+
+ deleteAllMessagesWithoutHeader();
+ }
+
/**
* Highlights keywords searched in the history.
*
@@ -2189,5 +2241,16 @@ public void removeUpdate(DocumentEvent e)
@Override
public void changedUpdate(DocumentEvent e)
{}
+
+ /**
+ * For debugging purposes, prints the content of the document
+ * in the console.
+ */
+ public void debug()
+ {
+ try {
+ write(System.out, document, 0, document.getLength());
+ } catch(Throwable t){}
+ }
}
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatHtmlUtils.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatHtmlUtils.java
index f75a84b08..c335b9667 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatHtmlUtils.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatHtmlUtils.java
@@ -39,7 +39,7 @@ public class ChatHtmlUtils
/**
* The message header identifier attribute.
*/
- public final static String MESSAGE_HEADER_ID = "messageHeader";
+ public final static String MESSAGE_HEADER_ID = "dateHeader";
/**
* The message identifier attribute.
@@ -256,7 +256,8 @@ private static String createSimpleIncomingMessageTag(
messageBuff.append("