001: /*
002: * This program is free software; you can redistribute it and/or
003: * modify it under the terms of the GNU General Public License
004: * as published by the Free Software Foundation; either version 2
005: * of the License, or (at your option) any later version.
006: *
007: * This program is distributed in the hope that it will be useful,
008: * but WITHOUT ANY WARRANTY; without even the implied warranty of
009: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
010: * GNU General Public License for more details.
011:
012: * You should have received a copy of the GNU General Public License
013: * along with this program; if not, write to the Free Software
014: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
015: */
016: package net.sf.jftp.gui.tasks;
017:
018: import net.sf.jftp.*;
019:
020: //***
021: import net.sf.jftp.config.*;
022: import net.sf.jftp.gui.framework.*;
023: import net.sf.jftp.net.*;
024:
025: import java.awt.*;
026: import java.awt.event.*;
027:
028: import javax.swing.*;
029:
030: //***
031: public class AdvancedOptions extends HPanel implements ActionListener {
032: //used this to see if it needs to look up file value
033: public static boolean listOptionSet = false;
034: private HTextField listCommand = new HTextField(
035: "FTP LIST command:", FtpConnection.LIST, 15);
036: private JButton setListCommand = new JButton("Set");
037:
038: //***
039: private JButton saveCommand = new JButton("Set and Save");
040:
041: //***
042: //*** should it really be set up so that the original message here on top
043: //*** is cleared out when events such as changing settings occurs
044: //*** (the text area which contains instructions at first has these
045: //*** instructions cleared out when some events occur.)
046: //*** So maybe should have a text box at the bottom? And a label at top
047: //*** with the instruction text?
048: //***this line may be deprecated
049: private JLabel text = new JLabel();
050: //private JLabel note = new JLabel();
051:
052: //***
053: private JLabel statusText = new JLabel();
054: private String listOptionText = new String(); //what the text in the box initially is
055:
056: //***
057: public AdvancedOptions() {
058: setLayout(new BorderLayout(5, 5));
059:
060: //text.setText("You can override the default values here, but note that " +
061: // "the values are not saved\n and lost after closing the application.");
062: text
063: .setText("Default values for commands can be overidden here.");
064: statusText
065: .setText("Note: The FTP LIST command should be \"LIST\" when connecting to an OS/2 server.");
066:
067: text.setPreferredSize(new Dimension(400, 30));
068:
069: //text.setLineWrap(true);
070: //***
071: statusText.setPreferredSize(new Dimension(400, 30));
072:
073: //statusText.setLineWrap(true);
074: //***
075: //load initial advanced options here
076: //JUST FOR NOW: We just know that value 0 is the FTP LIST command
077: if (listOptionSet) {
078: listOptionText = FtpConnection.LIST;
079: } else {
080: //AND NEED TO CHECK IF FILE DOESN'T EXIST (if not, create it
081: //and set the file and settings to the default
082: if (LoadSet.loadSet(Settings.adv_settings) != null) {
083: listOptionText = LoadSet.loadSet(Settings.adv_settings)[0];
084: } else {
085: listOptionText = FtpConnection.LIST_DEFAULT;
086:
087: SaveSet s = new SaveSet(Settings.adv_settings,
088: FtpConnection.LIST_DEFAULT);
089: }
090: }
091:
092: listCommand.setText(listOptionText);
093:
094: HPanel content = new HPanel();
095: HPanel panel = new HPanel();
096: panel.add(listCommand);
097: panel.add(setListCommand);
098:
099: //***
100: panel.add(saveCommand);
101:
102: //***
103: content.add(panel);
104:
105: add("North", text);
106: add("Center", content);
107:
108: add("South", statusText);
109:
110: setListCommand.addActionListener(this );
111: saveCommand.addActionListener(this );
112: }
113:
114: public void actionPerformed(ActionEvent e) {
115: if (e.getSource() == setListCommand) {
116: FtpConnection.LIST = listCommand.getText().trim();
117:
118: //text.setText("LIST command set.");
119: //***
120: statusText.setText("LIST command set.");
121: listOptionSet = true;
122:
123: //***
124: }
125:
126: //if(e.getSource() == saveCommand)
127: else {
128: //isn't the following line redundant? So I commented it out
129: //it would be redundant if the LIST command is read in by LoadSet each time
130: //FtpConnection.LIST = listCommand.getText().trim();
131: FtpConnection.LIST = listCommand.getText().trim();
132:
133: listOptionSet = true;
134:
135: //text.setText("LIST command set and saved");
136: //statusText.setText("LIST command set and saved.");
137: SaveSet s = new SaveSet(Settings.adv_settings, listCommand
138: .getText().trim());
139:
140: //***
141: //text.setText("LIST command set and saved");
142: statusText.setText("LIST command set and saved.");
143:
144: //***
145: }
146: }
147:
148: public Insets getInsets() {
149: return new Insets(super .getInsets().top + 5,
150: super .getInsets().left + 5,
151: super .getInsets().bottom + 5,
152: super .getInsets().right + 5);
153: }
154: }
|