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;
21  
22  import org.xnap.gui.theme.Theme;
23  import org.xnap.gui.theme.ThemeManager;
24  
25  /***
26   * Provides the default implementation for theme plugin classes.
27   */
28  public abstract class AbstractThemePlugin extends AbstractPlugin
29  {
30  
31      //--- Constant(s) ---
32      
33      //--- Data Field(s) ---
34  
35  	private Theme theme;
36  
37      //--- Constructor(s) ---
38  
39  	public AbstractThemePlugin()
40  	{
41  	}
42  
43      //--- Method(s) ---
44  
45  	/***
46  	 * Creates and returns the theme.
47  	 */
48  	protected abstract Theme createTheme();
49  
50  	public Theme getTheme()
51  	{
52  		return theme;
53  	}
54  
55      /***
56  	 * Registers the theme. We need to do this before the gui is
57  	 * started (except for the SplashWindow).
58  	 *
59       * @see Plugin#start()
60       */
61      public void start()
62      {
63  		theme = createTheme();
64  		ThemeManager.addTheme(theme);
65      }
66  
67      /***
68  	 * Does nothing.
69  	 *
70       * @see Plugin#startGUI()
71       */
72      public void startGUI()
73      {
74      }
75  
76      /***
77  	 * Unregisters the theme
78  	 *
79       * @see Plugin#stop()
80       */
81      public void stop()
82      {
83  		ThemeManager.removeTheme(theme);
84  		theme = null;
85      }
86  
87      /***
88  	 * Does nothing.
89  	 *
90       * @see Plugin#stopGUI()
91       */
92      public void stopGUI()
93      {
94      }
95  
96  }