KickJava   Java API By Example, From Geeks To Geeks.

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


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 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
32 public class RemoteCommand extends HFrame implements ActionListener
33 {
34     private HTextField text;
35     private HButton ok = new HButton("Execute");
36
37     public RemoteCommand()
38     {
39         //setSize(400, 80);
40
setTitle("Choose command...");
41         setLocation(150, 150);
42         getContentPane().setLayout(new FlowLayout());
43
44         text = new HTextField("Command:", "SITE CHMOD 755 file", 30);
45         getContentPane().add(text);
46         getContentPane().add(ok);
47         ok.addActionListener(this);
48         text.text.addActionListener(this);
49
50         pack();
51         setVisible(true);
52     }
53
54     public void actionPerformed(ActionEvent e)
55     {
56         if((e.getSource() == ok) || (e.getSource() == text.text))
57         {
58             setVisible(false);
59
60             String JavaDoc cmd = text.getText();
61             Log.debug("-> " + cmd);
62             JFtp.remoteDir.getCon().sendRawCommand(cmd);
63
64             if(cmd.toUpperCase().trim().startsWith("QUIT"))
65             {
66                 JFtp.statusP.jftp.safeDisconnect();
67
68                 return;
69             }
70
71             JDialog j = new JDialog();
72             j.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
73             j.setTitle("Command response");
74             j.setLocation(150, 150);
75
76             JTextArea t = new JTextArea();
77             JScrollPane logSp = new JScrollPane(t);
78             logSp.setMinimumSize(new Dimension(300, 200));
79
80             t.setText(Log.getCache());
81             j.getContentPane().setLayout(new BorderLayout(5, 5));
82             j.getContentPane().add("Center", t);
83             j.setSize(new Dimension(400, 300));
84             j.pack();
85             j.setVisible(true);
86
87             JFtp.remoteUpdate();
88         }
89     }
90 }
91
Popular Tags