KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jftp > gui > tasks > AdvancedOptions


1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  */

16 package net.sf.jftp.gui.tasks;
17
18 import net.sf.jftp.*;
19
20 //***
21
import net.sf.jftp.config.*;
22 import net.sf.jftp.gui.framework.*;
23 import net.sf.jftp.net.*;
24
25 import java.awt.*;
26 import java.awt.event.*;
27
28 import javax.swing.*;
29
30
31 //***
32
public class AdvancedOptions extends HPanel implements ActionListener
33 {
34     //used this to see if it needs to look up file value
35
public static boolean listOptionSet = false;
36     private HTextField listCommand = new HTextField("FTP LIST command:",
37                                                     FtpConnection.LIST, 15);
38     private JButton setListCommand = new JButton("Set");
39
40     //***
41
private JButton saveCommand = new JButton("Set and Save");
42
43     //***
44
//*** should it really be set up so that the original message here on top
45
//*** is cleared out when events such as changing settings occurs
46
//*** (the text area which contains instructions at first has these
47
//*** instructions cleared out when some events occur.)
48
//*** So maybe should have a text box at the bottom? And a label at top
49
//*** with the instruction text?
50
//***this line may be deprecated
51
private JLabel text = new JLabel();
52     //private JLabel note = new JLabel();
53

54     //***
55
private JLabel statusText = new JLabel();
56     private String JavaDoc listOptionText = new String JavaDoc(); //what the text in the box initially is
57

58     //***
59
public AdvancedOptions()
60     {
61         setLayout(new BorderLayout(5, 5));
62
63         //text.setText("You can override the default values here, but note that " +
64
// "the values are not saved\n and lost after closing the application.");
65
text.setText("Default values for commands can be overidden here.");
66         statusText.setText("Note: The FTP LIST command should be \"LIST\" when connecting to an OS/2 server.");
67
68         text.setPreferredSize(new Dimension(400, 30));
69
70         //text.setLineWrap(true);
71
//***
72
statusText.setPreferredSize(new Dimension(400, 30));
73
74         //statusText.setLineWrap(true);
75
//***
76
//load initial advanced options here
77
//JUST FOR NOW: We just know that value 0 is the FTP LIST command
78
if(listOptionSet)
79         {
80             listOptionText = FtpConnection.LIST;
81         }
82         else
83         {
84             //AND NEED TO CHECK IF FILE DOESN'T EXIST (if not, create it
85
//and set the file and settings to the default
86
if(LoadSet.loadSet(Settings.adv_settings) != null)
87             {
88                 listOptionText = LoadSet.loadSet(Settings.adv_settings)[0];
89             }
90             else
91             {
92                 listOptionText = FtpConnection.LIST_DEFAULT;
93
94                 SaveSet s = new SaveSet(Settings.adv_settings,
95                                         FtpConnection.LIST_DEFAULT);
96             }
97         }
98
99         listCommand.setText(listOptionText);
100
101         HPanel content = new HPanel();
102         HPanel panel = new HPanel();
103         panel.add(listCommand);
104         panel.add(setListCommand);
105
106         //***
107
panel.add(saveCommand);
108
109         //***
110
content.add(panel);
111
112         add("North", text);
113         add("Center", content);
114
115         add("South", statusText);
116
117         setListCommand.addActionListener(this);
118         saveCommand.addActionListener(this);
119     }
120
121     public void actionPerformed(ActionEvent e)
122     {
123         if(e.getSource() == setListCommand)
124         {
125             FtpConnection.LIST = listCommand.getText().trim();
126
127             //text.setText("LIST command set.");
128
//***
129
statusText.setText("LIST command set.");
130             listOptionSet = true;
131
132             //***
133
}
134
135         //if(e.getSource() == saveCommand)
136
else
137         {
138             //isn't the following line redundant? So I commented it out
139
//it would be redundant if the LIST command is read in by LoadSet each time
140
//FtpConnection.LIST = listCommand.getText().trim();
141
FtpConnection.LIST = listCommand.getText().trim();
142
143             listOptionSet = true;
144
145             //text.setText("LIST command set and saved");
146
//statusText.setText("LIST command set and saved.");
147
SaveSet s = new SaveSet(Settings.adv_settings,
148                                     listCommand.getText().trim());
149
150             //***
151
//text.setText("LIST command set and saved");
152
statusText.setText("LIST command set and saved.");
153
154             //***
155
}
156     }
157     
158     public Insets getInsets()
159     {
160         return new Insets(super.getInsets().top+5,super.getInsets().left+5,super.getInsets().bottom+5,super.getInsets().right+5);
161     }
162 }
163
Popular Tags