Temporary fix for chat conversation area line wrap problem.

cusax-fix
Yana Stamcheva 16 years ago
parent 03bba9c46c
commit e5592501c5

@ -150,17 +150,6 @@ public class ChatConversationPanel
*/
private boolean scrollToBottomIsPending = false;
/**
* The label showing current typing notification.
*/
private JLabel typingNotificationLabel;
/**
* The typing notification icon.
*/
private final Icon typingIcon = GuiActivator.getResources()
.getImage("service.gui.icons.TYPING");
/**
* The implementation of the routine which scrolls {@link #chatTextPane} to its
* bottom.
@ -214,10 +203,9 @@ public ChatConversationPanel(ChatConversationContainer chatContainer)
this.setWheelScrollingEnabled(true);
JPanel viewportView = new TransparentPanel(new BorderLayout());
viewportView.add(chatTextPane);
this.setViewportView(chatTextPane);
this.setViewportView(viewportView);
this.setBorder(null);
this.setHorizontalScrollBarPolicy(
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
@ -293,7 +281,7 @@ public void componentResized(ComponentEvent e)
}
}
};
viewportView.addComponentListener(componentListener);
chatTextPane.addComponentListener(componentListener);
getViewport().addComponentListener(componentListener);
}
@ -1394,55 +1382,6 @@ public void addComponent(ChatConversationComponent component)
}
}
/**
* Adds a typing notification message to the conversation panel.
*
* @param typingNotification the typing notification to show
*/
public void addTypingNotification(String typingNotification)
{
if (typingNotificationLabel == null)
{
typingNotificationLabel
= new JLabel( typingNotification,
typingIcon,
SwingConstants.CENTER);
typingNotificationLabel.setForeground(Color.GRAY);
typingNotificationLabel.setFont(
typingNotificationLabel.getFont().deriveFont(11f));
typingNotificationLabel.setVerticalTextPosition(JLabel.BOTTOM);
typingNotificationLabel.setHorizontalTextPosition(JLabel.LEFT);
typingNotificationLabel.setIconTextGap(0);
((JComponent) getViewport().getView()).add(
typingNotificationLabel, BorderLayout.SOUTH);
}
else
{
typingNotificationLabel.setText(typingNotification);
if (typingNotification != null && typingNotification.length() > 0)
typingNotificationLabel.setIcon(typingIcon);
else
typingNotificationLabel.setIcon(null);
}
synchronized (scrollToBottomRunnable)
{
scrollToBottomIsPending = true;
}
revalidate();
repaint();
}
/**
* Removes the typing notification message from the conversation panel.
*/
public void removeTypingNotification()
{
addTypingNotification("");
}
/**
* Returns the date string to show for the given date.
*

@ -65,6 +65,8 @@ public class ChatPanel
private JSplitPane topSplitPane;
private final JPanel topPanel = new JPanel(new BorderLayout());
private final ChatConversationPanel conversationPanel;
private final ChatWritePanel writeMessagePanel;
@ -77,6 +79,17 @@ public class ChatPanel
public int unreadMessageNumber = 0;
/**
* The label showing current typing notification.
*/
private JLabel typingNotificationLabel;
/**
* The typing notification icon.
*/
private final Icon typingIcon = GuiActivator.getResources()
.getImage("service.gui.icons.TYPING");
/**
* Indicates that a typing notification event is successfully sent.
*/
@ -135,6 +148,10 @@ public ChatPanel(ChatContainer chatContainer)
this.conversationPanel.getChatTextPane()
.setTransferHandler(new ChatTransferHandler(this));
topPanel.setBackground(Color.WHITE);
topPanel.setBorder(
BorderFactory.createMatteBorder(1, 0, 1, 0, Color.GRAY));
this.writeMessagePanel = new ChatWritePanel(this);
this.messagePane.setBorder(null);
@ -146,6 +163,8 @@ public ChatPanel(ChatContainer chatContainer)
this.messagePane.setResizeWeight(1.0D);
this.messagePane.setBottomComponent(writeMessagePanel);
this.messagePane.setTopComponent(topPanel);
this.add(messagePane, BorderLayout.CENTER);
if (OSUtils.IS_MAC)
@ -170,7 +189,7 @@ public void setChatSession(ChatSession chatSession)
if ((this.chatSession != null)
&& this.chatSession.isContactListSupported())
{
messagePane.remove(conversationPanel);
topPanel.remove(conversationPanel);
TransparentPanel rightPanel
= new TransparentPanel(new BorderLayout(5, 5));
@ -202,7 +221,7 @@ public void setChatSession(ChatSession chatSession)
topSplitPane.setLeftComponent(conversationPanel);
topSplitPane.setRightComponent(rightPanel);
messagePane.setTopComponent(topSplitPane);
topPanel.add(topSplitPane);
}
else
{
@ -218,7 +237,7 @@ public void setChatSession(ChatSession chatSession)
topSplitPane = null;
}
this.messagePane.setTopComponent(conversationPanel);
topPanel.add(conversationPanel);
}
if (chatSession instanceof MetaContactChatSession)
@ -324,11 +343,38 @@ public Window getConversationContainerWindow()
/**
* Adds a typing notification message to the conversation panel.
*
* @param typingNotification the typing notification string
* @param typingNotification the typing notification to show
*/
public void addTypingNotification(String typingNotification)
{
conversationPanel.addTypingNotification(typingNotification);
if (typingNotificationLabel == null)
{
typingNotificationLabel
= new JLabel( typingNotification,
typingIcon,
SwingConstants.CENTER);
typingNotificationLabel.setPreferredSize(new Dimension(500, 20));
typingNotificationLabel.setForeground(Color.GRAY);
typingNotificationLabel.setFont(
typingNotificationLabel.getFont().deriveFont(11f));
typingNotificationLabel.setVerticalTextPosition(JLabel.BOTTOM);
typingNotificationLabel.setHorizontalTextPosition(JLabel.LEFT);
typingNotificationLabel.setIconTextGap(0);
topPanel.add(typingNotificationLabel, BorderLayout.SOUTH);
}
else
{
typingNotificationLabel.setText(typingNotification);
if (typingNotification != null && !typingNotification.equals(" "))
typingNotificationLabel.setIcon(typingIcon);
else
typingNotificationLabel.setIcon(null);
}
revalidate();
repaint();
}
/**
@ -336,9 +382,10 @@ public void addTypingNotification(String typingNotification)
*/
public void removeTypingNotification()
{
conversationPanel.removeTypingNotification();
addTypingNotification(" ");
}
/**
* Returns the conversation panel, contained in this chat panel.
*
@ -2060,8 +2107,8 @@ public void propertyChange(PropertyChangeEvent evt)
// We store the divider location only when the user drags the
// divider and not when we've set it programatically.
if (dividerLocation != autoDividerLocation)
{
// if (dividerLocation != autoDividerLocation)
// {
int writeAreaSize
= messagePane.getHeight() - dividerLocation
- messagePane.getDividerSize();
@ -2069,12 +2116,12 @@ public void propertyChange(PropertyChangeEvent evt)
ConfigurationManager
.setChatWriteAreaSize(writeAreaSize);
writeMessagePanel.setPreferredSize(
new Dimension(
(int) writeMessagePanel.getPreferredSize()
.getWidth(),
writeAreaSize));
}
// writeMessagePanel.setPreferredSize(
// new Dimension(
// (int) writeMessagePanel.getPreferredSize()
// .getWidth(),
// writeAreaSize));
// }
}
}
}

Loading…
Cancel
Save