[sip-comm-cvs] CVS update: /sip-communicator/src/net/java/sip/communicator/gui/imp/

emcho at dev.java.net emcho at dev.java.net
Wed May 26 11:08:58 CEST 2004


User: emcho   
Date: 04/05/26 02:08:58

Modified:
 /sip-communicator/src/net/java/sip/communicator/gui/imp/
  ContactListFrame.java, ContactListModel.java, ContactsTree.java, MenuBar.java

Log:
 Ongoing work on simple

File Changes:

Directory: /sip-communicator/src/net/java/sip/communicator/gui/imp/
===================================================================

File [changed]: ContactListFrame.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/gui/imp/ContactListFrame.java?r1=1.3&r2=1.4
Delta lines:  +136 -6
---------------------
--- ContactListFrame.java	13 Apr 2004 00:53:36 -0000	1.3
+++ ContactListFrame.java	26 May 2004 09:08:55 -0000	1.4
@@ -61,10 +61,7 @@
 import java.awt.*;
 import net.java.sip.communicator.common.*;
 import javax.swing.tree.*;
-import java.util.*;
 import java.awt.event.*;
-import java.beans.*;
-import net.java.sip.communicator.sip.simple.event.*;
 
 /**
  * <p>Title: SIP Communicator</p>
@@ -75,7 +72,9 @@
  * @version 1.0
  */
 
-public class ContactListFrame extends JFrame
+public class ContactListFrame
+    extends JFrame
+    implements MouseListener
 {
     private static final Console console = Console.getConsole(ContactListFrame.class);
     JPanel contentPane = new JPanel();
@@ -85,11 +84,15 @@
     JScrollPane treeScrollPane = new JScrollPane();
     BorderLayout borderLayout2 = new BorderLayout();
     JComboBox statusComboBox   = new JComboBox();
-    JMenuBar  menuBar          = new MenuBar();
+
+    // The following two are filled in by the
+    public MenuBar              menuBar          = new MenuBar();
+    public ContactListPopupMenu popupMenu        = new ContactListPopupMenu();
 
     private static final int DEFAULT_WIDTH = 150;
     private static final int DEFAULT_HEIGHT = 500;
 
+    private ContactListActions contactListActions = new ContactListActions();
 
 
     public ContactListFrame()
@@ -109,6 +112,12 @@
     private void initComponents()
     {
         addWindowListener(new FrameSizeSaver());
+        addMouseListener(this);
+        treeScrollPane.addMouseListener(this);
+
+        popupMenu.setContactListActions(contactListActions);
+        contactListActions.setApplicationFrame(this);
+
         int x = -1;
         int y = -1;
 
@@ -168,7 +177,6 @@
 
     private void expandContactsTree()
     {
-        TreeModel model = contactsTree.getModel();
         for(int i = 0; i < contactsTree.getRowCount(); i++)
             contactsTree.expandRow(i);
     }
@@ -191,6 +199,7 @@
         contactsTree = new ContactsTree();
         contactsTree.setModel(model);
         contactsTree.setCellRenderer(model);
+        contactsTree.addMouseListener(this);
         treeScrollPane.setViewportView(contactsTree);
         treeScrollPane.updateUI();
         expandContactsTree();
@@ -222,5 +231,126 @@
 
 
     }
+
+    /**
+     * Invoked when the mouse button has been clicked (pressed and released) on a
+     * component.
+     *
+     * @param e MouseEvent
+     */
+    public void mouseClicked(MouseEvent e)
+    {
+        maybeShowPopup(e);
+    }
+
+    /**
+     * Invoked when a mouse button has been pressed on a component.
+     *
+     * @param e MouseEvent
+     */
+    public void mousePressed(MouseEvent e)
+    {
+        maybeShowPopup(e);
+    }
+
+    /**
+     * Invoked when a mouse button has been released on a component.
+     *
+     * @param e MouseEvent
+     */
+    public void mouseReleased(MouseEvent e)
+    {
+        maybeShowPopup(e);
+    }
+
+    /**
+     * Invoked when the mouse enters a component.
+     *
+     * @param e MouseEvent
+     */
+    public void mouseEntered(MouseEvent e)
+    {
+        maybeShowPopup(e);
+    }
+
+    /**
+     * Invoked when the mouse exits a component.
+     *
+     * @param e MouseEvent
+     */
+    public void mouseExited(MouseEvent e)
+    {
+        maybeShowPopup(e);
+    }
+
+    private void maybeShowPopup(MouseEvent e)
+    {
+        if(e.isPopupTrigger())
+        {
+            //select the node the user clicked upon
+            Component invoker = (Component)e.getSource();
+            if (invoker instanceof ContactsTree) {
+                ContactsTree tree = (ContactsTree) invoker;
+                TreePath path = tree.getPathForLocation(e.getX(), e.getY());
+                if (path != null
+                    && path.getPathCount() > 0) {
+                    tree.setSelectionPath(path);
+                }
+            }
+
+            //tell all contact list actions about the newly selected node
+
+
+            popupMenu.show(invoker, e.getX(), e.getY());
+        }
+    }
+
+    /**
+     * Returns the path to the first currently selected node.
+     * @return an array of objects representing the path to the first currently
+     * selected node.
+     */
+    Object[] getSelectedPath()
+    {
+        return contactsTree.getSelectionPath().getPath();
+    }
+
+    /**
+     * Returns a path containing all parents of the currently selected node
+     * except the node itself.
+     * @return an array of objects containing all parents of the currently
+     * selected node except the node itself.
+     */
+    Object[] getSelectedParentPath()
+    {
+        return contactsTree.getSelectionPath().getParentPath().getPath();
+    }
+
+    /**
+     * Transmits the given request to the contacts tree module.
+     * @param request the request describing the contact that the user requested
+     * to add.
+     */
+    void requestContactAddition(ContactAdditionRequest request)
+    {
+        ((ContactListModel)this.contactsTree.getModel()).requestContactAddition(request);
+    }
+
+
+
+
+
+
+    /**
+     * Transmits the given request to the contacts tree module.
+     * @param request the request describing the contact that the user requested
+     * to remove.
+     */
+    void requestContactRemoval(ContactRemovalRequest request)
+    {
+        ( (ContactListModel)this.contactsTree.getModel()).
+            requestContactRemoval(request);
+    }
+
 }
 

File [changed]: ContactListModel.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/gui/imp/ContactListModel.java?r1=1.2&r2=1.3
Delta lines:  +17 -0
--------------------
--- ContactListModel.java	13 Apr 2004 00:53:37 -0000	1.2
+++ ContactListModel.java	26 May 2004 09:08:55 -0000	1.3
@@ -347,4 +347,21 @@
         return label;
     }
 
+    /**
+     * Notifies the communications part of of the application that the user
+     * wishes to add the contact described by <code>request</code> to their
+     * contact list.
+     * @param the request that contains details about the contact the the user
+     * wishes to add to their contact list.
+     */
+    public abstract void requestContactAddition(ContactAdditionRequest request);
+
+    /**
+     * Notifies the communications part of of the application that the user
+     * wishes to remove <code>contact</code> from their contact list.
+     * @param the request that contains details about the contact the user
+     * wishes to remove from their contact list.
+     */
+    public abstract void requestContactRemoval(ContactRemovalRequest request);
+
 }

File [changed]: ContactsTree.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/gui/imp/ContactsTree.java?r1=1.1&r2=1.2
Delta lines:  +49 -0
--------------------
--- ContactsTree.java	2 Apr 2004 08:09:25 -0000	1.1
+++ ContactsTree.java	26 May 2004 09:08:55 -0000	1.2
@@ -71,6 +71,7 @@
  */
 
 public class ContactsTree extends JTree
+    implements TreeModelListener
 {
     public ContactsTree()
     {
@@ -79,6 +80,54 @@
         setRootVisible(false);
     }
 
+    public void setModel(ContactListModel model)
+    {
+        super.setModel(model);
+
+        model.addTreeModelListener(this);
+    }
+
+    /**
+     * <p>Invoked after a node (or a set of siblings) has changed in some way.
+     *
+     * @param e TreeModelEvent
+     */
+    public void treeNodesChanged(TreeModelEvent e)
+    {
+        updateUI();
+    }
+
+    /**
+     * <p>Invoked after nodes have been inserted into the tree.</p>
+     *
+     * <p>Use <code>e.getPath()</code> to get the parent of the new node(s).
+     *
+     * @param e TreeModelEvent
+     */
+    public void treeNodesInserted(TreeModelEvent e)
+    {
+        updateUI();
+    }
 
+    /**
+     * <p>Invoked after nodes have been removed from the tree.
+     *
+     * @param e TreeModelEvent
+     */
+    public void treeNodesRemoved(TreeModelEvent e)
+    {
+        updateUI();
+    }
+
+    /**
+     * <p>Invoked after the tree has drastically changed structure from a given
+     * node down.
+     *
+     * @param e TreeModelEvent
+     */
+    public void treeStructureChanged(TreeModelEvent e)
+    {
+        updateUI();
+    }
 
 }

File [changed]: MenuBar.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/src/net/java/sip/communicator/gui/imp/MenuBar.java?r1=1.1&r2=1.2
Delta lines:  +93 -10
---------------------
--- MenuBar.java	2 Apr 2004 08:09:36 -0000	1.1
+++ MenuBar.java	26 May 2004 09:08:55 -0000	1.2
@@ -2,6 +2,7 @@
 
 import javax.swing.JMenuBar;
 import javax.swing.*;
+import java.awt.event.*;
 
 /**
  * <p>Title: SIP Communicator</p>
@@ -12,22 +13,104 @@
  * @version 1.0
  */
 
-class MenuBar extends JMenuBar
+public class MenuBar extends JMenuBar
 {
+    private JMenu menu         = new JMenu("Menu");
+    private JMenu settingsMenu = new JMenu("Settings");
+    private JMenu helpMenu     = new JMenu("Help");
+
     public MenuBar()
     {
-        JMenu menu = new JMenu("Menu");
-        JMenu view = new JMenu("View");
-        JMenu tools = new JMenu("Tools");
-        JMenu help = new JMenu("Help");
-        JMenuItem exitItem = new JMenuItem("Exit");
-        menu.add(exitItem);
+        menu.setMnemonic('M');
+        settingsMenu.setMnemonic('S');
+        helpMenu.setMnemonic('H');
+
+        menu.add(settingsMenu);
+        menu.add(helpMenu);
+
         add(menu);
-        menu.add(view);
-        menu.add(tools);
-        menu.add(help);
 
         setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
     }
+
+    /**
+     * Creates a JMenuItem using the specified <code>action</code> sets X as
+     * its mnemonic character and adds it together with a separator to the main
+     * menu.
+     * @param action the exit action
+     */
+    public void addExitAction(Action action)
+    {
+        menu.addSeparator();
+
+        JMenuItem menuItem = new JMenuItem(action);
+        menuItem.setMnemonic('X');
+
+        menu.add(menuItem);
+    }
+
+    /**
+     * Creates a JMenuItem using the specified <code>action</code> sets C as
+     * its mnemonic character and adds it to the settings menu.
+     * @param action the config action
+     */
+    public void addConfigAction(Action action)
+    {
+        JMenuItem config = new JMenuItem(action);
+        config.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0));
+        config.setMnemonic('C');
+
+        settingsMenu.add(config);
+    }
+
+
+
+
+
+
+
+
+    /**
+     * Creates a JMenuItem using the specified <code>action</code> sets M as
+     * its mnemonic character and adds it to the settings menu.
+     * @param action the configMedia action
+     */
+    public void addConfigMediaAction(Action action)
+    {
+        JMenuItem mItem = new JMenuItem(action);
+        mItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M,
+            KeyEvent.CTRL_MASK | KeyEvent.ALT_MASK));
+        mItem.setMnemonic('M');
+        settingsMenu.add(mItem);
+    }
+
+    /**
+     * Creates a JMenuItem using the specified <code>action</code> sets M as
+     * its mnemonic character and adds it to the settings menu.
+     * @param action the configMedia action
+     */
+    public void addSetupWizardAction(Action action)
+    {
+        JMenuItem mItem = new JMenuItem(action);
+        mItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U,
+            KeyEvent.CTRL_MASK | KeyEvent.ALT_MASK));
+        mItem.setMnemonic('S');
+        settingsMenu.addSeparator();
+        settingsMenu.add(mItem);
+    }
+
+    /**
+     * Creates a JMenuItem using the specified <code>action</code> sets A as
+     * its mnemonic character and adds it to the settings menu.
+     * @param action the about action
+     */
+    public void addAboutAction(Action action)
+    {
+        JMenuItem mItem = new JMenuItem(action);
+        mItem.setMnemonic('A');
+        helpMenu.addSeparator();
+        helpMenu.add(mItem);
+    }
+
 
 }




---------------------------------------------------------------------
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