Fix Previous/Next buttons states on receiving new messages.

cusax-fix
Damian Minkov 18 years ago
parent d2df560e62
commit c86f5769eb

@ -175,12 +175,18 @@ public void run()
*
* @param escapedMessageID The id of the message that should be ignored.
*/
public void loadHistory(String escapedMessageID)
public void loadHistory(final String escapedMessageID)
{
// Load the history period, which initializes the
// firstMessageTimestamp and the lastMessageTimeStamp variables.
// Used to disable/enable history flash buttons in the chat
// window tool bar.
loadHistoryPeriod();
Collection historyList = msgHistory.findLast(
metaContact, Constants.CHAT_HISTORY_SIZE);
processHistory(historyList, escapedMessageID);
processHistory(historyList, escapedMessageID);
}
/**

@ -302,66 +302,6 @@ else if (buttonText.equalsIgnoreCase("font")) {
}
}
/**
* Returns the button used to show the list of smilies.
*
* @return the button used to show the list of smilies.
*/
public SmiliesSelectorBox getSmiliesSelectorBox()
{
return smiliesBox;
}
/**
* Returns TRUE if there are selected menus in this toolbar, otherwise
* returns FALSE.
* @return TRUE if there are selected menus in this toolbar, otherwise
* returns FALSE
*/
public boolean hasSelectedMenus()
{
if(smiliesBox.isMenuSelected())
return true;
return false;
}
/**
* Disables/Enables history arrow buttons depending on whether the
* current page is the first, the last page or a middle page.
*/
public void changeHistoryButtonsState(ChatPanel chatPanel)
{
ChatConversationPanel convPanel = chatPanel.getChatConversationPanel();
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(firstMsgInHistory.compareTo(firstMsgInPage) < 0)
previousButton.setEnabled(true);
else
previousButton.setEnabled(false);
if(lastMsgInPage.getTime() > 0
&& (lastMsgInHistory.compareTo(lastMsgInPage) > 0))
{
nextButton.setEnabled(true);
}
else
{
nextButton.setEnabled(false);
}
}
private void initPluginComponents()
{
Iterator pluginComponents = GuiActivator.getUIService()
@ -417,39 +357,6 @@ private void initPluginComponents()
GuiActivator.getUIService().addPluginComponentListener(this);
}
/**
* Implements the <code>PluginComponentListener.pluginComponentAdded</code>
* method.
*/
public void pluginComponentAdded(PluginComponentEvent event)
{
PluginComponent c = event.getPluginComponent();
if(c.getContainer().equals(Container.CONTAINER_CHAT_TOOL_BAR))
{
this.addSeparator();
this.add((Component) c.getComponent());
this.revalidate();
this.repaint();
}
}
/**
* Implements the <code>PluginComponentListener.pluginComponentRemoved</code>
* method.
*/
public void pluginComponentRemoved(PluginComponentEvent event)
{
PluginComponent c = event.getPluginComponent();
if(c.getContainer().equals(Container.CONTAINER_CHAT_TOOL_BAR))
{
this.remove((Component) c.getComponent());
}
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);

@ -340,6 +340,12 @@ else if(eventType == MessageReceivedEvent.SMS_MESSAGE_RECEIVED)
chatPanel.processMessage(protocolContact.getDisplayName(), date,
messageType, message.getContent(),
message.getContentType());
// A bug Fix for Previous/Next buttons .
// Must update buttons state after message is processed
// otherwise states are not proper
chatPanel.getChatWindow().getMainToolBar().
changeHistoryButtonsState(chatPanel);
// Opens the chat panel with the new message in the UI thread.
SwingUtilities.invokeLater(new Runnable()
@ -386,7 +392,6 @@ public void messageDelivered(MessageDeliveredEvent evt)
Message msg = evt.getSourceMessage();
ChatWindowManager chatWindowManager = mainFrame.getChatWindowManager();
MetaContactChatPanel chatPanel = null;
if(chatWindowManager.isChatOpenedForContact(metaContact))

Loading…
Cancel
Save