KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > planetamessenger > mos > ui > JContactTree


1 /*
2     =========================================================================
3     Package ui - Implements user interface components
4  
5     This module is developed and maintained by PlanetaMessenger.org.
6     Specs, New and updated versions can be found in
7     http://www.planetamessenger.org
8     If you want contact the Team please send a email to Project Manager
9     Leidson Campos Alves Ferreira at leidson@planetamessenger.org
10
11     Copyright (C) since 2001 by PlanetaMessenger.org
12
13     This program is free software; you can redistribute it and/or modify
14     it under the terms of the GNU General Public License as published by
15     the Free Software Foundation; either version 2 of the License, or
16     (at your option) any later version.
17
18     This program is distributed in the hope that it will be useful,
19     but WITHOUT ANY WARRANTY; without even the implied warranty of
20     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21     GNU General Public License for more details.
22
23     You should have received a copy of the GNU General Public License
24     along with this program; if not, write to the Free Software
25     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26  
27     =========================================================================
28  */

29 /**
30  *
31  * $Id: JContactTree.java,v 1.2 2007/01/28 17:39:20 popolony2k Exp $
32  * $Author: popolony2k $
33  * $Name: $
34  * $Revision: 1.2 $
35  * $State: Exp $
36  *
37  */

38
39 package org.planetamessenger.mos.ui;
40
41 import java.awt.event.ActionEvent JavaDoc;
42 import java.awt.event.MouseEvent JavaDoc;
43
44 import javax.swing.JTree JavaDoc;
45 import javax.swing.tree.DefaultMutableTreeNode JavaDoc;
46 import javax.swing.tree.DefaultTreeModel JavaDoc;
47
48 import org.planetamessenger.mos.engine.JSharedObjects;
49 import org.planetamessenger.plugin.JPlugin;
50
51
52 /**
53  * This class represent the tree struture for the contact list.
54  * Real author Doug Ly
55  */

56 public class JContactTree extends JTree JavaDoc implements JContactListInterface, java.awt.event.MouseListener JavaDoc, java.awt.event.ActionListener JavaDoc {
57   
58   public JContactTree() {
59     
60     addMouseListener( this );
61     
62     /*// testing with the dummy tree
63     DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
64     DefaultMutableTreeNode child1 = new DefaultMutableTreeNode("Child 1");
65     root.add(child1);
66     DefaultMutableTreeNode child2 = new DefaultMutableTreeNode("Child 2");
67     root.add(child2);
68     setModel(new DefaultTreeModel(root));*/

69
70     DefaultMutableTreeNode JavaDoc root = new DefaultMutableTreeNode JavaDoc( "Root" );
71     
72     this.setRootVisible( false );
73     setModel( new DefaultTreeModel JavaDoc( root ) );
74     
75     /*
76     String[] plugins = null;
77     try {
78       plugins = getAllPluginNames();
79     }
80     catch( Exception e ) {
81       e.printStackTrace();
82     }
83     
84     if( plugins != null ) {
85       for( int i = 0; i < plugins.length; i++ ) {
86         DefaultMutableTreeNode node = new DefaultMutableTreeNode( plugins[i] );
87         root.add( node );
88       }
89     }
90      */

91   }
92   
93   /**
94    * Method to get all the pluggin names to populate the tree.
95    * @return Array of strings of pluggin name
96    */

97   private String JavaDoc[] getAllPluginNames() throws Exception JavaDoc {
98     
99     JPlugin[] plugins = JSharedObjects.getPluginEngine().toArray();
100     String JavaDoc[] names = null;
101     
102     
103     if( plugins != null ) {
104       names = new String JavaDoc[plugins.length];
105       for( int i = 0; i < plugins.length; i++ ) {
106         names[i] = plugins[i].toString();
107       }
108     }
109
110     return names;
111   }
112
113   // JContactListInterface implementation
114
/**
115     * Adds a item to the contact list.
116     * @param item The Item to add;
117     */

118   public boolean addItem( org.planetamessenger.plugin.JContactListItem item ) {
119
120     return true;
121   }
122   
123   /**
124     * Returns the item specified by parameter.
125     * @param nPluginId The Plugin id;
126     * @param strItemId The id of Item to retrieve;
127     */

128   public org.planetamessenger.plugin.JContactListItem getItem( int nPluginId, java.lang.String JavaDoc strItemId ) {
129     
130     return null;
131   }
132   
133   /**
134     * Removes the item specified by parameter from Contact list.
135     * @param item The Item to remove;
136     */

137   public boolean removeItem( org.planetamessenger.plugin.JContactListItem item ) {
138     
139     return true;
140   }
141
142   /**
143     * Removes all items from specified plugin.
144     * @param nPluginId The plugin id that whose plugins will be removed;
145     */

146   public boolean removePluginItems( int nPluginId ) {
147     
148     return true;
149   }
150
151   /**
152     * Removes the selected item from Contact list.
153     */

154   public boolean removeSelectedItem() {
155     
156     return true;
157   }
158
159   /**
160     * Restore the last status of a contact list item.
161     * @param item The Item key to set the status;
162     */

163   public void restoreItemStatus( org.planetamessenger.plugin.JContactListItem item ) {
164     
165   }
166
167   /**
168     * Set the status from all items of specified plugin.
169     * @param nPluginId The plugin id to set the new status
170     * for users;
171     * @nNewStatus The new status to set;
172     */

173   public boolean setAllItemsStatus( int nPluginId, int nNewStatus ) {
174     
175     return true;
176   }
177
178   /**
179     * Sets a new status of contact list item specified by parameter.
180     * @param item The Item key to set the status;
181     * @param nNewStatus The new item status;
182     */

183   public boolean setItemStatus( org.planetamessenger.plugin.JContactListItem item, int nNewStatus ) {
184     
185     return true;
186   }
187  
188   /**
189     * Called when user choose change the default language
190     **/

191   public void updateLanguage() {
192     
193   }
194
195  // ActionListener implementation
196
/**
197     * Implements the actionPerformed event handler
198     * for the popup menu items;
199     * @param actionEvent The event generated;
200     */

201   public void actionPerformed( ActionEvent JavaDoc e ) {
202   }
203   
204   // MouseListener implementation
205
/**
206    * Implements the mouseClicked event handler
207    * for this ContactList class.
208    * @param mouseEvent The Mouse event generated;
209    */

210   public void mouseClicked( MouseEvent JavaDoc e ) {
211   }
212   
213   /**
214     * Implements the mouseEntered event handler
215     * for this ContactList class.
216     * @param mouseEvent The Mouse event generated;
217     * Do nothing in this implementation
218     */

219   public void mouseEntered( MouseEvent JavaDoc e ) {
220   }
221
222   /**
223     * Implements the mouseExited event handler
224     * for this contact list class.
225     * @param mouseEvent The Mouse event generated;
226     * Do nothing in this implementation
227     */

228   public void mouseExited( MouseEvent JavaDoc e ) {
229   }
230
231   /**
232     * Implements the mousePressed event handler
233     * for this contact list class.
234     * @param mouseEvent The Mouse event generated;
235     * Do nothing in this implementation
236     */

237   public void mousePressed( MouseEvent JavaDoc e ) {
238   }
239
240   /**
241     * Implements the mouseReleased event handler
242     * for this contact list class.
243     * @param mouseEvent The Mouse event generated;
244     * Do nothing in this implementation
245     */

246   public void mouseReleased( MouseEvent JavaDoc e ) {
247   }
248 }
249
250 // JContractTree class
251
Popular Tags