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 javax.swing.Icon;
23  import javax.swing.JCheckBox;
24  
25  import java.awt.GridBagLayout;
26  
27  import org.xnap.XNap;
28  import org.xnap.gui.AbstractSettingsPanel;
29  import org.xnap.gui.Messages;
30  import org.xnap.gui.component.DirectoryList;
31  import org.xnap.gui.component.DirectoryPanel;
32  import org.xnap.gui.component.MultiLineLabel;
33  import org.xnap.gui.util.GUIHelper;
34  import org.xnap.gui.util.GridBagHelper;
35  import org.xnap.gui.util.IconHelper;
36  
37  public class FilesWizardPanel extends AbstractSettingsPanel {
38      
39      //--- Data field(s) ---
40  
41      private DirectoryPanel jteDownloadDir;
42      private DirectoryList dlUploadDirs;
43      private JCheckBox jcUseOpenFileAction;
44  
45      //--- Constructor(s) ---
46  
47      public FilesWizardPanel()
48      {
49  		setLayout(new GridBagLayout());
50  
51  		// download directory
52  		GridBagHelper.add
53  			(this, GUIHelper.createHeader(XNap.tr("Download Directory")));
54  
55  		GridBagHelper.add
56  			(this, new MultiLineLabel(Messages.DOWNLOAD_DIRECTORY));
57  
58          jteDownloadDir = new DirectoryPanel(prefs.getDownloadDir(), 20);
59  		GridBagHelper.add(this, jteDownloadDir);
60  
61  		// upload directory list
62  		GridBagHelper.add
63  			(this, GUIHelper.createHeader(XNap.tr("Shared Directories")));
64  		GridBagHelper.add
65  			(this, new MultiLineLabel(Messages.RECURSIVE_SHARE));
66  
67  		dlUploadDirs = new DirectoryList(prefs.getUploadDirs(), 20, 3);
68          GridBagHelper.add(this, dlUploadDirs);
69  
70  		GridBagHelper.addVerticalSpacer(this);
71      }
72  
73      public void apply() 
74      {
75  		prefs.setDownloadDir(jteDownloadDir.getDirectory());
76  		prefs.setIncompleteDir(prefs.getDownloadDir() + "incomplete");
77  		prefs.setUploadDirs(dlUploadDirs.getDirectories());
78      }
79  
80      public String getDescription()
81      {
82  		return XNap.tr("Setup your file locations.The downlad directory will be created if not already existent.");
83      }
84  
85      public Icon getIcon()
86      {
87  		return IconHelper.getWizardIcon("folder.png");
88      }
89  
90      public String getTitle()
91      {
92  		return XNap.tr("File Settings");
93      }
94  
95  }