From ad6ff6c78c4fc86727cbe37b1a8a8f61057e33cb Mon Sep 17 00:00:00 2001 From: Derek DeMoro Date: Tue, 2 Oct 2007 20:36:24 +0000 Subject: [PATCH] Memory work. git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@9265 b35dd754-fafc-0310-a699-88a17e54d16e --- .../org/jivesoftware/spark/ui/ChatInputEditor.java | 12 +++++++++--- src/java/org/jivesoftware/spark/ui/ChatRoom.java | 5 ++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/java/org/jivesoftware/spark/ui/ChatInputEditor.java b/src/java/org/jivesoftware/spark/ui/ChatInputEditor.java index 8960e687..c84210ef 100644 --- a/src/java/org/jivesoftware/spark/ui/ChatInputEditor.java +++ b/src/java/org/jivesoftware/spark/ui/ChatInputEditor.java @@ -29,12 +29,15 @@ import javax.swing.undo.UndoManager; */ public class ChatInputEditor extends ChatArea implements DocumentListener { - private final UndoManager undoManager = new UndoManager(); + private final UndoManager undoManager; + private KeyStroke keyStroke; /** * Creates a new Default ChatSendField. */ public ChatInputEditor() { + undoManager = new UndoManager(); + this.setDragEnabled(true); this.getDocument().addUndoableEditListener(undoManager); Action undo = new AbstractAction() { @@ -43,12 +46,14 @@ public class ChatInputEditor extends ChatArea implements DocumentListener { } }; - this.getInputMap().put(KeyStroke.getKeyStroke('z', ActionEvent.CTRL_MASK), "undo"); + keyStroke = KeyStroke.getKeyStroke('z', ActionEvent.CTRL_MASK); + this.getInputMap().put(keyStroke, "undo"); + this.registerKeyboardAction(undo, KeyStroke.getKeyStroke(KeyEvent.VK_Z, KeyEvent.CTRL_MASK), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); this.getDocument().addDocumentListener(this); - addMouseListener(this); + this.addMouseListener(this); } public void insertUpdate(DocumentEvent e) { @@ -73,6 +78,7 @@ public class ChatInputEditor extends ChatArea implements DocumentListener { this.getDocument().removeDocumentListener(this); this.getDocument().removeUndoableEditListener(undoManager); this.removeMouseListener(this); + this.getInputMap().remove(keyStroke); } /** diff --git a/src/java/org/jivesoftware/spark/ui/ChatRoom.java b/src/java/org/jivesoftware/spark/ui/ChatRoom.java index 38a703c1..2d607f2e 100644 --- a/src/java/org/jivesoftware/spark/ui/ChatRoom.java +++ b/src/java/org/jivesoftware/spark/ui/ChatRoom.java @@ -133,7 +133,8 @@ public abstract class ChatRoom extends BackgroundPanel implements ActionListener transcriptWindow.addMouseListener(transcriptWindowMouseListener); - chatAreaButton = new ChatAreaSendField(SparkRes.getString(SparkRes.SEND)) { + chatAreaButton = new ChatAreaSendField(SparkRes.getString(SparkRes.SEND)); + /*{ public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); @@ -146,6 +147,7 @@ public abstract class ChatRoom extends BackgroundPanel implements ActionListener return dim; } }; + */ textScroller = new JScrollPane(transcriptWindow); @@ -621,6 +623,7 @@ public abstract class ChatRoom extends BackgroundPanel implements ActionListener getChatInputEditor().getActionMap().remove("closeTheRoom"); chatAreaButton.getButton().removeActionListener(this); + bottomPanel.remove(chatAreaButton); } /**