KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > planetamessenger > mos > forms > JContactListEvents


1 /*
2     =========================================================================
3     Package forms - Implements the user interface MOS module
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: JContactListEvents.java,v 1.12 2007/01/28 17:39:20 popolony2k Exp $
32  * $Author: popolony2k $
33  * $Name: $
34  * $Revision: 1.12 $
35  * $State: Exp $
36  *
37  */

38
39 package org.planetamessenger.mos.forms;
40
41 import org.planetamessenger.plugin.*;
42 import org.planetamessenger.mos.engine.*;
43
44
45 class JContactListEvents implements org.planetamessenger.mos.ui.JMenuListener {
46   
47   /**
48    * Constructor. Initializes all class data.
49    */

50   public JContactListEvents() {
51   
52   }
53
54   /**
55    * Implements the onMessage event handler
56    * for this JList class.
57    * @param item The contact selected;
58    */

59   public void onMessage( org.planetamessenger.plugin.JContactListItem item ) {
60
61     onNewTab( item );
62   }
63
64   /**
65    * Implements the onNewTab event handler
66    * for this JList class.
67    * @param item The contact selected;
68    */

69   public void onNewTab( org.planetamessenger.plugin.JContactListItem item ) {
70
71     JMOSSendMessageDlg msgDlg = JSharedObjects.getPluginEngine().getMessageWindow( item.getPluginId() );
72     String JavaDoc strMsg = JSharedObjects.getContactListManager().getContactMessages( item );
73
74
75     msgDlg.setTitle( ( ( JPlugin ) JSharedObjects.getPluginEngine().get( item.getPluginId() ) ).getPluginProperties().getName() );
76     
77     if( !msgDlg.contains( item ) )
78       msgDlg.newTab( item );
79
80     msgDlg.setMessage( item, ( strMsg == null ? "" : strMsg ) );
81     msgDlg.setVisible( true );
82
83     if( strMsg != null )
84       JSharedObjects.getMainWindow().getContactList().restoreItemStatus( item );
85   }
86
87   /**
88    * Implements the hook to get state of
89    * new tab menu item.
90    * @param item The contact selected;
91    */

92   public boolean isNewTabEnabled( org.planetamessenger.plugin.JContactListItem item ) {
93
94     JMOSSendMessageDlg msgDlg = JSharedObjects.getPluginEngine().getMessageWindow( item.getPluginId() );
95
96     return ( msgDlg.isVisible() && !msgDlg.contains( item ) );
97   }
98   
99   /**
100    * Implements the hook to get state of
101    * new message menu item.
102    * @param item The contact selected;
103    */

104   public boolean isNewMessageEnabled( org.planetamessenger.plugin.JContactListItem item ) {
105
106     JMOSSendMessageDlg msgDlg = JSharedObjects.getPluginEngine().getMessageWindow( item.getPluginId() );
107
108     return !( msgDlg.isVisible() && msgDlg.isItemActive( item ) );
109   }
110 }
111
112 // JContactListEvents class
Popular Tags