bugs concerning the state of history arrow buttons fixed

cusax-fix
Yana Stamcheva 19 years ago
parent 445992ece4
commit ad68448c6b

@ -78,7 +78,7 @@ public class ChatConversationPanel
private Date lastIncomingMsgTimestamp = new Date(0);
private Date pageFirstMsgTimestamp = new Date(System.currentTimeMillis());
private Date pageFirstMsgTimestamp = new Date(Long.MAX_VALUE);
private Date pageLastMsgTimestamp = new Date(0);

@ -127,7 +127,6 @@ public void run(){
loadHistoryPeriod();
}
}.start();
}
/**
@ -383,17 +382,12 @@ public void componentShown(ComponentEvent e) {
JTabbedPane tabbedPane = (JTabbedPane) parent;
if (tabbedPane.getSelectedComponent() == component) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
getChatWindow().setTitle(
getMetaContact().getDisplayName());
public void run() {
chatWindow.setCurrentChatPanel(ChatPanel.this);
chatWindow.getMainToolBar().changeHistoryButtonsSate(
ChatPanel.this);
writeMessagePanel.getEditorPane()
.requestFocus();
.requestFocus();
}
});
}
@ -788,6 +782,8 @@ else if(o1 instanceof MessageReceivedEvent) {
this.lastHistoryMsgTimestamp = evt.getTimestamp();
}
}
this.chatWindow.getMainToolBar().changeHistoryButtonsState(this);
}
public Date getFirstHistoryMsgTimestamp()

@ -186,7 +186,6 @@ public MainToolBar getMainToolBar()
public ChatPanel createChat(MetaContact contact, PresenceStatus status,
Contact protocolContact)
{
ChatPanel chatPanel = new ChatPanel(this, contact, protocolContact);
this.contactChats.put(contact.getMetaUID(), chatPanel);
@ -418,6 +417,10 @@ public ChatPanel getCurrentChatPanel()
public void setCurrentChatPanel(ChatPanel currentChatPanel)
{
this.currentChatPanel = currentChatPanel;
this.setTitle(currentChatPanel.getMetaContact().getDisplayName());
this.getMainToolBar().changeHistoryButtonsState(currentChatPanel);
}
/**

@ -92,7 +92,8 @@ public MainToolBar(ChatWindow messageWindow) {
this.setBorder(BorderFactory.createEmptyBorder(2, 2, 5, 2));
this.nextButton.setEnabled(false);
this.previousButton.setEnabled(false);
this.add(saveButton);
this.add(printButton);
@ -374,7 +375,7 @@ public void run()
conversationPanel.setDefaultContent();
changeHistoryButtonsSate(chatPanel);
changeHistoryButtonsState(chatPanel);
}
}
@ -382,23 +383,30 @@ public void run()
* Disables/Enables history arrow buttons depending on whether the
* current page is the first, the last page or a middle page.
*/
public void changeHistoryButtonsSate(ChatPanel chatPanel)
{
public void changeHistoryButtonsState(ChatPanel chatPanel)
{
ChatConversationPanel convPanel = chatPanel.getChatConversationPanel();
if(chatPanel.getFirstHistoryMsgTimestamp() == null)
Date firstMsgInHistory = chatPanel.getFirstHistoryMsgTimestamp();
Date lastMsgInHistory = chatPanel.getLastHistoryMsgTimestamp();
Date firstMsgInPage = convPanel.getPageFirstMsgTimestamp();
Date lastMsgInPage = convPanel.getPageLastMsgTimestamp();
if(firstMsgInHistory == null || lastMsgInHistory == null) {
previousButton.setEnabled(false);
nextButton.setEnabled(false);
return;
}
if(chatPanel.getFirstHistoryMsgTimestamp()
.compareTo(convPanel.getPageFirstMsgTimestamp()) < 0) {
if(firstMsgInHistory.compareTo(firstMsgInPage) < 0) {
previousButton.setEnabled(true);
}
else {
previousButton.setEnabled(false);
}
if(chatPanel.getLastHistoryMsgTimestamp()
.compareTo(convPanel.getPageLastMsgTimestamp()) > 0) {
if(lastMsgInPage.getTime() > 0
&& (lastMsgInHistory.compareTo(lastMsgInPage) > 0)) {
nextButton.setEnabled(true);
}
else {

Loading…
Cancel
Save