KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > zirc > msg > MSGquit


1 package zirc.msg ;
2
3 import java.util.* ;
4
5 import zirc.base.* ;
6 import zirc.gui.* ;
7
8 //zIrc, irc client.
9
// Copyright (C) 2004 CoolBytes(Stephane claret, Andre Aymon, Alban Zumofen) coolbytes@hotmail.com
10
//
11
// This program is free software; you can redistribute it and/or
12
// modify it under the terms of the GNU General Public License
13
// as published by the Free Software Foundation; either version 2
14
// of the License, or (at your option) any later version.
15
//
16
// This program is distributed in the hope that it will be useful,
17
// but WITHOUT ANY WARRANTY; without even the implied warranty of
18
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
// GNU General Public License for more details.
20

21 /**
22  * <p>Title: MSGquit</p>
23  * <p>Description: </p>
24  * <p>Copyright: Copyright (c) 2004</p>
25  * <p>Company: CoolBytes(Stephane Claret, Andre Aymon, Alban Zumofen) coolbytes@hotmail.com</p>
26  * @version 1.0
27  */

28
29
30 public class MSGquit extends AbstractMessage
31 {
32
33   private String JavaDoc user ;
34   private ArrayList tmp ;
35   private ChanUser chanUser ;
36   private IRCconnexion IRCchan ;
37   private String JavaDoc msg ;
38
39   public MSGquit(IRCconnexion _IRCchan, String JavaDoc _name, String JavaDoc _line)
40   {
41     IRCchan = _IRCchan ;
42     //
43
//extraire le nom de User
44
//
45
int ind = _name.indexOf("!") ;
46
47     if (ind > -1)
48     {
49       user = _name.substring(1, ind) ;
50     }
51     else
52     {
53       user = "" ;
54     }
55     chanUser = new ChanUser(user, ChanUser.NORM) ;
56
57     //ici on garde le messaeg de quit
58
msg = _line.substring(_line.lastIndexOf(":"), _line.length()) ;
59   }
60
61   //juste rajoute le paragraph
62
protected void setColor(StringBuffer JavaDoc _htmlMsg)
63   {
64     _htmlMsg.insert(0, "<font color=" + vectColors[4] + ">") ; //en rouge
65
_htmlMsg.append("</font>") ;
66   }
67
68   public void reagit()
69   {
70     try
71     {
72       tmp = IRCchan.getAllChatFrames() ;
73       for (int i = 0 ; i < tmp.size() ; i++)
74       {
75         int index = Arrays.binarySearch(((ChatFrame)(tmp.get(i))).getListModel().toArray(), chanUser) ;
76         if (index > 0)
77         {
78           StringBuffer JavaDoc txt = new StringBuffer JavaDoc(chanUser.getNameSansRank() + " s'est deconnecte" + msg) ;
79           ((ChatFrame)(tmp.get(i))).removeUserFromChan(chanUser.getNameAvecRank()) ;
80           try
81           {
82             txt = super.toHtml(txt.toString()) ;
83             setColor(txt) ;
84             ((ChatFrame)(tmp.get(i))).displayTxt(txt, txt.length(), false) ;
85           }
86           catch (Exception JavaDoc ex)
87           {
88           }
89         }
90       }
91     }
92     catch (NullPointerException JavaDoc ex)
93     {ex.printStackTrace() ;
94     }
95   }
96
97 }
98
Popular Tags