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.pircbot;
21  
22  import javax.swing.Icon;
23  
24  import org.xnap.gui.XNapFrame;
25  import org.xnap.gui.util.IconHelper;
26  import org.xnap.plugin.AbstractPlugin;
27  
28  /***
29   * Provides an IRC chat plugin based on PircBot.
30   */
31  public class PircBotPlugin extends AbstractPlugin
32  {
33  
34      //--- Constant(s) ---
35  
36      public static String ICON_FILENAME = "socket.png";
37  
38      public static Icon ICON_16
39  		= IconHelper.getIcon(ICON_FILENAME, 16, false);
40      
41      //--- Data Field(s) ---
42  
43      //private static Logger logger = Logger.getLogger(PircBotPlugin.class);
44      private static PircBotPlugin singleton;
45  
46      private PircBotPanel jpPircBot;
47      private PircBotPreferences prefs;
48  
49      //--- Constructor(s) ---
50  
51      public PircBotPlugin()
52      {
53      }
54  
55      //--- Method(s) ---
56  
57      public static PircBotPlugin getInstance()
58      {
59  		return singleton;
60      }
61  
62      public PircBotPreferences getPreferences()
63      {
64  		return prefs;
65      }
66  
67      /***
68       * Starts the plugin.
69       */
70      public void start() 
71      {
72  		singleton = this;
73  		prefs = new PircBotPreferences();
74      }
75  
76      /***
77       * Starts the GUI of the plugin.
78       */
79      public void startGUI()
80      {
81  		jpPircBot = new PircBotPanel();
82  		XNapFrame.getInstance().insertTab
83  			(getInfo().getName(), 
84  			 IconHelper.getListIcon("socket.png"), jpPircBot);
85      }
86  
87      /***
88       * Stops the plugin. Disposes all singletons.
89       */
90      public void stop()
91      {
92  		prefs = null;
93  		singleton = null;
94      }
95  
96      /***
97       * Stops the GUI of the plugin.
98       */
99      public void stopGUI()
100     {
101 		jpPircBot.savePrefs();
102 
103 		XNapFrame.getInstance().removeTab(jpPircBot);
104 		jpPircBot = null;
105     }
106 
107     // --- Inner Class(es) ---
108 
109 }