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.gui.wizard;
21  
22  import java.awt.BorderLayout;
23  
24  import javax.swing.Icon;
25  
26  import org.xnap.XNap;
27  import org.xnap.gui.AbstractSettingsPanel;
28  import org.xnap.gui.plugin.PluginInstallerDialog;
29  import org.xnap.gui.plugin.PluginPanel;
30  import org.xnap.gui.util.IconHelper;
31  
32  	/***
33   * Assumes that no plugins have been enabled prior to execution of this class.
34   */
35  public class PluginWizardPanel extends AbstractSettingsPanel {
36      
37      //--- Data field(s) ---
38  
39  	private PluginPanel panel;
40  	private boolean firstTime = true;
41  
42      //--- Constructor(s) ---
43  
44      public PluginWizardPanel()
45      {
46  		setLayout(new BorderLayout());
47  
48  		panel = new PluginPanel(false);
49  		add(panel, BorderLayout.CENTER);
50      }
51  
52  	//--- Method(s) ---
53  
54      public void apply() 
55      {
56  		panel.apply();
57  		if (!PluginInstallerDialog.commit(this)) {
58  			throw new IllegalArgumentException(XNap.tr("It looks like the package file is incomplete. Deselect a plugin and try again plugin."));
59  		}
60      }
61  
62      public String getDescription()
63      {
64  		return XNap.tr("Selects the plugins you want to install. You can always install more plugins from the plugins dialog later.");
65      }
66  
67      public Icon getIcon()
68      {
69  		return IconHelper.getWizardIcon("package.png");
70      }
71  
72      public String getTitle()
73      {
74  		return XNap.tr("Plugins");
75      }
76  
77  	public void shown()
78  	{
79  		if (firstTime) {
80  			firstTime = false;
81  			panel.updatePackageManager();
82  		}
83  	}
84  
85  }