[sip-comm-cvs] CVS update: /sip-communicator/src/net/java/sip/communicator/impl/gui/main/MainFrame.java

yanas at dev.java.net yanas at dev.java.net
Thu Apr 12 17:31:49 CEST 2007


User: yanas   
Date: 2007-04-12 15:31:49+0000
Log:
 fix ActionMap sharing in the main frame (this was causing the Bug 347)

File Changes:

Directory: /sip-communicator/src/net/java/sip/communicator/impl/gui/main/
=========================================================================

File [changed]: MainFrame.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/impl/gui/main/MainFrame.java?r1=1.91&r2=1.92
Delta lines:  +38 -0
--------------------
--- MainFrame.java	2007-03-20 11:53:56+0000	1.91
+++ MainFrame.java	2007-04-12 15:31:46+0000	1.92
@@ -23,6 +23,7 @@
 import net.java.sip.communicator.impl.gui.main.chat.conference.*;
 import net.java.sip.communicator.impl.gui.main.chatroomslist.*;
 import net.java.sip.communicator.impl.gui.main.contactlist.*;
+import net.java.sip.communicator.impl.gui.main.contactlist.ContactListPanel.*;
 import net.java.sip.communicator.impl.gui.main.login.*;
 import net.java.sip.communicator.impl.gui.main.menus.*;
 import net.java.sip.communicator.impl.gui.main.presence.*;
@@ -129,6 +130,14 @@
         this.mainPanel.add(contactListPanel, BorderLayout.CENTER);
         this.mainPanel.add(statusPanel, BorderLayout.SOUTH);
         
+        this.mainPanel.getActionMap().put("runChat",
+                new RunMessageWindowAction());
+
+        InputMap imap = this.getRootPane().getInputMap(
+                JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+
+        imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "runChat");
+        
         this.getContentPane().add(mainPanel);
     }
 
@@ -1128,4 +1137,33 @@
     {
         return chatWindowManager;
     }
+    
+    /**
+     * Opens chat window when the selected value is a MetaContact and opens a
+     * group when the selected value is a MetaContactGroup.
+     */
+    private class RunMessageWindowAction extends AbstractAction
+    {
+        public void actionPerformed(ActionEvent e)
+        {
+            ContactList clist = getContactListPanel().getContactList();
+            Object selectedValue = clist.getSelectedValue();
+            
+            if (selectedValue instanceof MetaContact) {
+                MetaContact contact = (MetaContact) selectedValue;
+
+                SwingUtilities.invokeLater(
+                        getContactListPanel().new RunMessageWindow(contact));
+            }
+            else if (selectedValue instanceof MetaContactGroup) {
+                MetaContactGroup group = (MetaContactGroup) selectedValue;
+
+                ContactListModel model = (ContactListModel) clist.getModel();
+
+                if (model.isGroupClosed(group)) {
+                    model.openGroup(group);
+                }
+            }
+        }
+    };
 }




---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe at sip-communicator.dev.java.net
For additional commands, e-mail: cvs-help at sip-communicator.dev.java.net





More information about the commits mailing list