View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  package org.xnap.plugin.joscar;
21  
22  import javax.swing.Icon;
23  
24  import org.apache.log4j.Logger;
25  import org.xnap.event.StateEvent;
26  import org.xnap.event.StateListener;
27  import org.xnap.gui.StatusPanel;
28  import org.xnap.gui.util.IconHelper;
29  import org.xnap.util.State;
30  
31  public class JOscarStatusPanel extends StatusPanel implements StateListener
32  {
33  	//--- Constant(s) ---
34  
35  	private static final Icon offline  =
36  		IconHelper.getIcon("licq-offline.png", 16, false);
37  
38  	//--- Data field(s) ---
39  
40      private static Logger logger = Logger.getLogger(JOscarStatusPanel.class);
41  	
42  	//--- Constructor(s) ---
43  	
44      public JOscarStatusPanel()
45  	{
46  		super(JOscarPlugin.ICON_16);
47  		stateChanged(null);
48  	}
49  
50      //--- Method(s) ---
51  
52  	public void stateChanged(StateEvent event)
53  	{
54  		State s = JOscarPlugin.getInstance().getConnection().getState();
55  		setStatus(s.getDescription());
56  		if (s == State.DISCONNECTED) {
57  			setIcon(offline);
58  		}
59  		if (s == State.CONNECTED) {
60  			setIcon(JOscarPlugin.ICON_16);
61  		}
62  	}
63  }