From 1b7723ffa67d407f153f75bfbda2b05d274da352 Mon Sep 17 00:00:00 2001 From: Yana Stamcheva Date: Wed, 17 May 2006 11:59:57 +0000 Subject: [PATCH] Calendar replaced with Date. --- .../main/contactlist/ContactListPanel.java | 17 ++++------- .../main/message/ChatConversationPanel.java | 29 ++++++++++++------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPanel.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPanel.java index f80d7f1c3..c64f8847d 100755 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPanel.java @@ -18,7 +18,6 @@ import java.awt.event.MouseListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -import java.util.Calendar; import java.util.Hashtable; import javax.swing.AbstractAction; @@ -399,10 +398,6 @@ public void run() { * shows the message in the appropriate chat panel. */ public void messageReceived(MessageReceivedEvent evt) { - - Calendar calendar = Calendar.getInstance(); - calendar.setTime(evt.getTimestamp()); - MetaContact metaContact = mainFrame.getContactList() .findMetaContactByContact(evt.getSourceContact()); @@ -426,7 +421,7 @@ public void messageReceived(MessageReceivedEvent evt) { msgWindow.getCurrentChatPanel().getConversationPanel() .processMessage(evt.getSourceContact().getDisplayName(), - calendar, + evt.getTimestamp(), ChatMessage.INCOMING_MESSAGE, evt.getSourceMessage().getContent()); @@ -445,7 +440,7 @@ public void messageReceived(MessageReceivedEvent evt) { msgWindow.getCurrentChatPanel().getConversationPanel() .processMessage(evt.getSourceContact().getDisplayName(), - calendar, ChatMessage.INCOMING_MESSAGE, + evt.getTimestamp(), ChatMessage.INCOMING_MESSAGE, evt.getSourceMessage().getContent()); msgWindow.pack(); @@ -483,7 +478,7 @@ public void windowClosing(WindowEvent e) { chatPanel.getConversationPanel() .processMessage(evt.getSourceContact().getDisplayName(), - calendar, ChatMessage.INCOMING_MESSAGE, + evt.getTimestamp(), ChatMessage.INCOMING_MESSAGE, evt.getSourceMessage().getContent()); tabbedChatWindow.setVisible(true); @@ -492,7 +487,7 @@ public void windowClosing(WindowEvent e) { chatPanel = tabbedChatWindow.getChatPanel(metaContact); chatPanel.getConversationPanel() .processMessage(evt.getSourceContact().getDisplayName(), - calendar, ChatMessage.INCOMING_MESSAGE, + evt.getTimestamp(), ChatMessage.INCOMING_MESSAGE, evt.getSourceMessage().getContent()); tabbedChatWindow.setVisible(true); @@ -521,14 +516,12 @@ public void messageDelivered(MessageDeliveredEvent evt) { JEditorPane messagePane = chatPanel.getWriteMessagePanel() .getEditorPane(); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(evt.getTimestamp()); ProtocolProviderService protocolProvider = evt.getDestinationContact().getProtocolProvider(); chatPanel.getConversationPanel().processMessage( this.mainFrame.getDefaultAccount(protocolProvider), - calendar, + evt.getTimestamp(), ChatMessage.OUTGOING_MESSAGE, msg.getContent()); diff --git a/src/net/java/sip/communicator/impl/gui/main/message/ChatConversationPanel.java b/src/net/java/sip/communicator/impl/gui/main/message/ChatConversationPanel.java index 6fbb5418a..0f08cd149 100755 --- a/src/net/java/sip/communicator/impl/gui/main/message/ChatConversationPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/message/ChatConversationPanel.java @@ -14,6 +14,7 @@ import java.net.URL; import java.util.ArrayList; import java.util.Calendar; +import java.util.Date; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -27,6 +28,7 @@ import javax.swing.text.html.HTMLDocument; import javax.swing.text.html.HTMLEditorKit; +import net.java.sip.communicator.impl.contactlist.MclStorageManager; import net.java.sip.communicator.impl.gui.utils.AntialiasingManager; import net.java.sip.communicator.impl.gui.utils.BrowserLauncher; import net.java.sip.communicator.impl.gui.utils.Constants; @@ -34,6 +36,7 @@ import net.java.sip.communicator.impl.gui.utils.MyHTMLEditorKit; import net.java.sip.communicator.impl.gui.utils.Smily; import net.java.sip.communicator.impl.gui.utils.StringUtils; +import net.java.sip.communicator.util.Logger; /** * This is the panel, where all sent and received @@ -48,7 +51,10 @@ */ public class ChatConversationPanel extends JScrollPane implements HyperlinkListener { - + + private static final Logger logger = + Logger.getLogger(ChatConversationPanel.class.getName()); + private JEditorPane chatEditorPane = new JEditorPane(); private HTMLEditorKit editorKit = new MyHTMLEditorKit(); @@ -112,13 +118,17 @@ private void initEditor(){ * or INCOMING_MESSAGE. * @param message The message text. */ - public void processMessage(String contactName, - Calendar calendar, - String messageType, - String message){ + public void processMessage( String contactName, + Date date, + String messageType, + String message){ String chatString; String endHeaderTag; + + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + if(messageType.equals(ChatMessage.INCOMING_MESSAGE)){ chatString = "

"; endHeaderTag = "

"; @@ -142,13 +152,12 @@ public void processMessage(String contactName, Element root = this.document.getDefaultRootElement(); try { - this.document.insertAfterEnd(root.getElement(root.getElementCount() - 1), chatString); + this.document.insertAfterEnd + (root.getElement(root.getElementCount() - 1), chatString); } catch (BadLocationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.error("Insert in the HTMLDocument failed.", e); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.error("Insert in the HTMLDocument failed.", e); } //Scroll to the last inserted text in the document. this.chatEditorPane.setCaretPosition(this.document.getLength());