01: /*
02: * This program is free software; you can redistribute it and/or
03: * modify it under the terms of the GNU General Public License
04: * as published by the Free Software Foundation; either version 2
05: * of the License, or (at your option) any later version.
06: *
07: * This program is distributed in the hope that it will be useful,
08: * but WITHOUT ANY WARRANTY; without even the implied warranty of
09: * 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: import net.sf.jftp.gui.framework.*;
20: import net.sf.jftp.net.*;
21: import net.sf.jftp.system.logging.Log;
22: import net.sf.jftp.util.*;
23:
24: import java.awt.*;
25: import java.awt.event.*;
26:
27: import java.io.*;
28:
29: import javax.swing.*;
30:
31: public class RemoteCommand extends HFrame implements ActionListener {
32: private HTextField text;
33: private HButton ok = new HButton("Execute");
34:
35: public RemoteCommand() {
36: //setSize(400, 80);
37: setTitle("Choose command...");
38: setLocation(150, 150);
39: getContentPane().setLayout(new FlowLayout());
40:
41: text = new HTextField("Command:", "SITE CHMOD 755 file", 30);
42: getContentPane().add(text);
43: getContentPane().add(ok);
44: ok.addActionListener(this );
45: text.text.addActionListener(this );
46:
47: pack();
48: setVisible(true);
49: }
50:
51: public void actionPerformed(ActionEvent e) {
52: if ((e.getSource() == ok) || (e.getSource() == text.text)) {
53: setVisible(false);
54:
55: String cmd = text.getText();
56: Log.debug("-> " + cmd);
57: JFtp.remoteDir.getCon().sendRawCommand(cmd);
58:
59: if (cmd.toUpperCase().trim().startsWith("QUIT")) {
60: JFtp.statusP.jftp.safeDisconnect();
61:
62: return;
63: }
64:
65: JDialog j = new JDialog();
66: j.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
67: j.setTitle("Command response");
68: j.setLocation(150, 150);
69:
70: JTextArea t = new JTextArea();
71: JScrollPane logSp = new JScrollPane(t);
72: logSp.setMinimumSize(new Dimension(300, 200));
73:
74: t.setText(Log.getCache());
75: j.getContentPane().setLayout(new BorderLayout(5, 5));
76: j.getContentPane().add("Center", t);
77: j.setSize(new Dimension(400, 300));
78: j.pack();
79: j.setVisible(true);
80:
81: JFtp.remoteUpdate();
82: }
83: }
84: }
|