Fix file transfer layout.

cusax-fix
Yana Stamcheva 17 years ago
parent 772fdc3493
commit 0cadd75995

@ -152,7 +152,7 @@ service.gui.FILE_RECEIVING_FROM=Receiving file from {0}.
service.gui.FILE_SEND_COMPLETED=File has been successfully sent to {0}.
service.gui.FILE_RECEIVE_COMPLETED=File has been received from {0}.
service.gui.FILE_TRANSFER_CANCELED=File transfer has been canceled.
service.gui.FILE_SEND_REFUSED=File has been {0} has refused this file.
service.gui.FILE_SEND_REFUSED={0} has refused this file.
service.gui.FILE_TRANSFER_REFUSED=File transfer has been rejected.
service.gui.FILE_RECEIVE_REFUSED=You have refused the file from {0}.
service.gui.FILE_TRANSFER_PREPARING=Preparing file transfer with {0}. Please wait...

@ -22,14 +22,16 @@ public class StyledHTMLEditorPane
private final Logger logger = Logger.getLogger(StyledHTMLEditorPane.class);
private final HTMLEditorKit editorKit = new SIPCommHTMLEditorKit();
private final HTMLEditorKit editorKit;
private final HTMLDocument document;
public StyledHTMLEditorPane()
{
editorKit = new SIPCommHTMLEditorKit(this);
this.document = (HTMLDocument) editorKit.createDefaultDocument();
this.setContentType("text/html");
this.setEditorKitForContentType("text/html", editorKit);
this.setEditorKit(editorKit);

@ -46,8 +46,6 @@ public abstract class ChatConversationComponent
protected static final ResourceManagementService resources
= GuiActivator.getResources();
private Date date;
/**
* Creates a <tt>ChatConversationComponent</tt>.
*/

@ -46,7 +46,7 @@ public class ChatConversationPanel
private final JTextPane chatTextPane = new MyTextPane();
private final HTMLEditorKit editorKit = new SIPCommHTMLEditorKit();
private final HTMLEditorKit editorKit;
private HTMLDocument document;
@ -77,6 +77,8 @@ public class ChatConversationPanel
*/
public ChatConversationPanel(ChatConversationContainer chatContainer)
{
editorKit = new SIPCommHTMLEditorKit(this);
this.chatContainer = chatContainer;
isHistory = (chatContainer instanceof HistoryWindow);
@ -1157,13 +1159,6 @@ public void addComponent(ChatConversationComponent component)
{
document.insertString( document.getLength(),
"ignored text", style);
// Add an enter after the component in order to fix incorrect layout
// of components.
String processedMessage
= this.processBrTags(" \n ", TEXT_CONTENT_TYPE);
this.appendMessageToEnd(processedMessage);
}
catch (BadLocationException e)
{

@ -76,7 +76,7 @@ public ChatWritePanel(ChatPanel panel)
JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
this.editorPane.setCaretPosition(0);
this.editorPane.setEditorKit(new SIPCommHTMLEditorKit());
this.editorPane.setEditorKit(new SIPCommHTMLEditorKit(this));
this.editorPane.getDocument().addUndoableEditListener(this);
this.editorPane.addKeyListener(this);
this.editorPane.addMouseListener(this);

@ -7,6 +7,8 @@
package net.java.sip.communicator.impl.gui.utils;
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.text.html.*;
@ -20,6 +22,13 @@
*/
public class SIPCommHTMLEditorKit extends HTMLEditorKit
{
private final JComponent container;
public SIPCommHTMLEditorKit(JComponent container)
{
this.container = container;
}
/**
* Returns the extended <tt>HTMLFactory</tt> defined here.
*/
@ -33,7 +42,7 @@ public ViewFactory getViewFactory()
* to represent images and the <tt>ParagraphViewX</tt> to represent
* paragraphs.
*/
static class HTMLFactoryX extends HTMLFactory
private class HTMLFactoryX extends HTMLFactory
implements ViewFactory
{
public View create(Element elem)
@ -44,11 +53,96 @@ public View create(Element elem)
{
return new ParagraphViewX(elem);
}
else if (view instanceof ComponentView)
{
return new MyComponentView(elem);
}
return view;
}
}
private class MyComponentView extends ComponentView
{
/**
* Creates a new ComponentView object.
*
* @param elem the element to decorate
*/
public MyComponentView(Element elem)
{
super(elem);
}
/**
* Determines the preferred span for this view along an
* axis. This is implemented to return the value
* returned by Component.getPreferredSize along the
* axis of interest.
*
* @param axis may be either View.X_AXIS or View.Y_AXIS
* @return the span the view would like to be rendered into >= 0.
* Typically the view is told to render into the span
* that is returned, although there is no guarantee.
* The parent may choose to resize or break the view.
* @exception IllegalArgumentException for an invalid axis
*/
public float getPreferredSpan(int axis)
{
if ((axis != X_AXIS) && (axis != Y_AXIS))
{
throw new IllegalArgumentException("Invalid axis: " + axis);
}
if (getComponent() != null)
{
Dimension size = getComponent().getPreferredSize();
if (axis == View.X_AXIS)
{
return container.getWidth();
}
else
{
return size.height;
}
}
return 0;
}
/**
* Determines the maximum span for this view along an
* axis. This is implemented to return the value
* returned by Component.getMaximumSize along the
* axis of interest.
*
* @param axis may be either View.X_AXIS or View.Y_AXIS
* @return the span the view would like to be rendered into >= 0.
* Typically the view is told to render into the span
* that is returned, although there is no guarantee.
* The parent may choose to resize or break the view.
* @exception IllegalArgumentException for an invalid axis
*/
public float getMaximumSpan(int axis)
{
if ((axis != X_AXIS) && (axis != Y_AXIS))
{
throw new IllegalArgumentException("Invalid axis: " + axis);
}
if (getComponent() != null)
{
Dimension size = getComponent().getMaximumSize();
if (axis == View.X_AXIS)
{
return container.getWidth();
}
else
{
return size.height;
}
}
return 0;
}
}
/**
* The <tt>ParagraphViewX</tt> is created in order to solve the following
* problem (Bug ID: 4855207):

Loading…
Cancel
Save