diff --git a/resources/languages/resources.properties b/resources/languages/resources.properties index 09eb1b81b..e0d0d8316 100644 --- a/resources/languages/resources.properties +++ b/resources/languages/resources.properties @@ -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... diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/StyledHTMLEditorPane.java b/src/net/java/sip/communicator/impl/gui/customcontrols/StyledHTMLEditorPane.java index a088a3db8..d796b57f4 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/StyledHTMLEditorPane.java +++ b/src/net/java/sip/communicator/impl/gui/customcontrols/StyledHTMLEditorPane.java @@ -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); diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationComponent.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationComponent.java index 798a22c6c..bb39f2469 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationComponent.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationComponent.java @@ -46,8 +46,6 @@ public abstract class ChatConversationComponent protected static final ResourceManagementService resources = GuiActivator.getResources(); - private Date date; - /** * Creates a ChatConversationComponent. */ diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java index c09a97982..05afb700f 100755 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java @@ -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) { diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java index 4a26bbc40..3a29a71a1 100755 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java @@ -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); diff --git a/src/net/java/sip/communicator/impl/gui/utils/SIPCommHTMLEditorKit.java b/src/net/java/sip/communicator/impl/gui/utils/SIPCommHTMLEditorKit.java index 955aba38b..d717548da 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/SIPCommHTMLEditorKit.java +++ b/src/net/java/sip/communicator/impl/gui/utils/SIPCommHTMLEditorKit.java @@ -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 HTMLFactory defined here. */ @@ -33,7 +42,7 @@ public ViewFactory getViewFactory() * to represent images and the ParagraphViewX 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 ParagraphViewX is created in order to solve the following * problem (Bug ID: 4855207):