KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jftp > gui > base > RemoteDir


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.base;
17
18 import java.awt.BorderLayout JavaDoc;
19 import java.awt.Cursor JavaDoc;
20 import java.awt.FlowLayout JavaDoc;
21 import java.awt.Font JavaDoc;
22 import java.awt.Insets JavaDoc;
23 import java.awt.event.ActionEvent JavaDoc;
24 import java.awt.event.ActionListener JavaDoc;
25 import java.awt.event.KeyEvent JavaDoc;
26 import java.awt.event.KeyListener JavaDoc;
27 import java.awt.event.MouseAdapter JavaDoc;
28 import java.awt.event.MouseEvent JavaDoc;
29 import java.awt.event.MouseListener JavaDoc;
30 import java.io.File JavaDoc;
31 import java.io.FileInputStream JavaDoc;
32 import java.io.FileNotFoundException JavaDoc;
33 import java.io.PrintStream JavaDoc;
34 import java.lang.reflect.Array JavaDoc;
35 import java.util.Date JavaDoc;
36
37 import javax.swing.DefaultListModel JavaDoc;
38 import javax.swing.ImageIcon JavaDoc;
39 import javax.swing.JComboBox JavaDoc;
40 import javax.swing.JEditorPane JavaDoc;
41 import javax.swing.JLabel JavaDoc;
42 import javax.swing.JList JavaDoc;
43 import javax.swing.JMenuItem JavaDoc;
44 import javax.swing.JOptionPane JavaDoc;
45 import javax.swing.JPanel JavaDoc;
46 import javax.swing.JPopupMenu JavaDoc;
47 import javax.swing.JScrollPane JavaDoc;
48 import javax.swing.JTextArea JavaDoc;
49 import javax.swing.JToolBar JavaDoc;
50 import javax.swing.SwingUtilities JavaDoc;
51 import javax.swing.event.ListSelectionListener JavaDoc;
52
53 import net.sf.jftp.JFtp;
54 import net.sf.jftp.config.SaveSet;
55 import net.sf.jftp.config.Settings;
56 import net.sf.jftp.gui.base.dir.DirCanvas;
57 import net.sf.jftp.gui.base.dir.DirCellRenderer;
58 import net.sf.jftp.gui.base.dir.DirComponent;
59 import net.sf.jftp.gui.base.dir.DirEntry;
60 import net.sf.jftp.gui.base.dir.DirLister;
61 import net.sf.jftp.gui.base.dir.DirPanel;
62 import net.sf.jftp.gui.base.dir.TableUtils;
63 import net.sf.jftp.gui.framework.HFrame;
64 import net.sf.jftp.gui.framework.HImage;
65 import net.sf.jftp.gui.framework.HImageButton;
66 import net.sf.jftp.gui.tasks.Creator;
67 import net.sf.jftp.gui.tasks.Displayer;
68 import net.sf.jftp.gui.tasks.PathChanger;
69 import net.sf.jftp.gui.tasks.RemoteCommand;
70 import net.sf.jftp.net.BasicConnection;
71 import net.sf.jftp.net.ConnectionListener;
72 import net.sf.jftp.net.FilesystemConnection;
73 import net.sf.jftp.net.FtpConnection;
74 import net.sf.jftp.net.SftpConnection;
75 import net.sf.jftp.net.SmbConnection;
76 import net.sf.jftp.system.LocalIO;
77 import net.sf.jftp.system.StringUtils;
78 import net.sf.jftp.system.UpdateDaemon;
79 import net.sf.jftp.system.logging.Log;
80 import net.sf.jftp.tools.Shell;
81
82
83 public class RemoteDir extends DirComponent implements ListSelectionListener JavaDoc,
84                                                    ActionListener JavaDoc,
85                                                    ConnectionListener,
86                                                    KeyListener JavaDoc
87 {
88     //HImageButton openButton;
89
static final String JavaDoc deleteString = "rm";
90     static final String JavaDoc mkdirString = "mkdir";
91     static final String JavaDoc refreshString = "fresh";
92     static final String JavaDoc cdString = "cd";
93     static final String JavaDoc cmdString = "cmd";
94     static final String JavaDoc downloadString = "<-";
95     static final String JavaDoc uploadString = "->";
96     static final String JavaDoc queueString = "que";
97     static final String JavaDoc cdUpString = "cdUp";
98     static final String JavaDoc rnString = "rn";
99     HImageButton deleteButton;
100     HImageButton mkdirButton;
101     HImageButton cmdButton;
102     HImageButton refreshButton;
103     HImageButton cdButton;
104     HImageButton uploadButton;
105     HImageButton downloadButton;
106     HImageButton queueButton;
107     HImageButton cdUpButton;
108     HImageButton rnButton;
109
110     //static final String openString = "open";
111
private DirCanvas label = new DirCanvas(this);
112     private boolean pathChanged = true;
113     private boolean firstGui = true;
114     private int pos = 0;
115     private JPanel JavaDoc p = new JPanel JavaDoc();
116     private JToolBar JavaDoc buttonPanel = new JToolBar JavaDoc()
117     {
118         public Insets JavaDoc getInsets()
119         {
120             return new Insets JavaDoc(0, 0, 0, 0);
121         }
122     };
123
124     //private JPanel buttonPanel = new JPanel();
125
private JToolBar JavaDoc currDirPanel = new JToolBar JavaDoc()
126     {
127         public Insets JavaDoc getInsets()
128         {
129             return new Insets JavaDoc(0, 0, 0, 0);
130         }
131     };
132
133     private DefaultListModel JavaDoc jlm;
134     private JScrollPane JavaDoc jsp = new JScrollPane JavaDoc(jl);
135     private int tmpindex = -1;
136     private HImageButton list = new HImageButton(Settings.listImage, "list",
137                                                  "Show remote listing...", this);
138     private HImageButton transferType = new HImageButton(Settings.typeImage,
139                                                          "type",
140                                                          "Toggle transfer type...",
141                                                          this);
142     private JPopupMenu JavaDoc popupMenu = new JPopupMenu JavaDoc();
143     private JMenuItem JavaDoc props = new JMenuItem JavaDoc("Properties");
144     private DirEntry currentPopup = null;
145     private String JavaDoc sortMode = null;
146     String JavaDoc[] sortTypes = new String JavaDoc[] { "Normal", "Reverse", "Size", "Size/Re" };
147     private JComboBox JavaDoc sorter = new JComboBox JavaDoc(sortTypes);
148     private boolean dateEnabled = false;
149
150     /**
151     * RemoteDir constructor.
152     */

153     public RemoteDir()
154     {
155         type = "remote";
156         con = new FilesystemConnection();
157         con.addConnectionListener(this);
158
159         if(!con.chdir("/"))
160         {
161             con.chdir("C:\\");
162         }
163
164         setDate();
165     }
166
167     /**
168     * RemoteDir constructor.
169     */

170     public RemoteDir(String JavaDoc path)
171     {
172         type = "remote";
173         this.path = path;
174         con = new FilesystemConnection();
175         con.addConnectionListener(this);
176         con.chdir(path);
177
178         setDate();
179     }
180
181     /**
182     * Creates the gui and adds the MouseListener etc.
183     */

184     public void gui_init()
185     {
186         setLayout(new BorderLayout JavaDoc());
187         currDirPanel.setFloatable(false);
188         buttonPanel.setFloatable(false);
189
190         FlowLayout JavaDoc f = new FlowLayout JavaDoc(FlowLayout.LEFT);
191         f.setHgap(1);
192         f.setVgap(2);
193
194         buttonPanel.setLayout(f);
195         buttonPanel.setMargin(new Insets JavaDoc(0, 0, 0, 0));
196
197         props.addActionListener(this);
198         popupMenu.add(props);
199
200         rnButton = new HImageButton(Settings.textFileImage, rnString,
201                                     "Rename selected file or directory", this);
202         rnButton.setToolTipText("Rename selected");
203
204         list.setToolTipText("Show remote listing...");
205         transferType.setToolTipText("Toggle transfer type...");
206
207         deleteButton = new HImageButton(Settings.deleteImage, deleteString,
208                                         "Delete selected", this);
209         deleteButton.setToolTipText("Delete selected");
210
211         mkdirButton = new HImageButton(Settings.mkdirImage, mkdirString,
212                                        "Create a new directory", this);
213         mkdirButton.setToolTipText("Create directory");
214
215         refreshButton = new HImageButton(Settings.refreshImage, refreshString,
216                                          "Refresh current directory", this);
217         refreshButton.setToolTipText("Refresh directory");
218         refreshButton.setRolloverIcon(new ImageIcon JavaDoc(HImage.getImage(this, Settings.refreshImage2)));
219         refreshButton.setRolloverEnabled(true);
220
221         cdButton = new HImageButton(Settings.cdImage, cdString,
222                                     "Change directory", this);
223         cdButton.setToolTipText("Change directory");
224
225         cmdButton = new HImageButton(Settings.cmdImage, cmdString,
226                                      "Execute remote command", this);
227         cmdButton.setToolTipText("Execute remote command");
228
229         downloadButton = new HImageButton(Settings.downloadImage,
230                                           downloadString, "Download selected",
231                                           this);
232         downloadButton.setToolTipText("Download selected");
233
234         queueButton = new HImageButton(Settings.downloadImage, queueString,
235                                        "Queue selected", this);
236         queueButton.setToolTipText("Queue selected");
237
238         cdUpButton = new HImageButton(Settings.cdUpImage, cdUpString,
239                                       "Go to Parent Directory", this);
240         cdUpButton.setToolTipText("Go to Parent Directory");
241
242         //openButton = new HImageButton(Settings.openImage,openString,"Connect to server",this);
243
//openButton.setToolTipText("Connect");
244
setLabel();
245         label.setSize(getSize().width - 10, 24);
246         currDirPanel.add(label);
247         currDirPanel.setSize(getSize().width - 10, 32);
248         label.setSize(getSize().width - 20, 24);
249
250         p.setLayout(new BorderLayout JavaDoc());
251         p.add("North", currDirPanel);
252
253         buttonPanel.add(downloadButton);
254
255         //buttonPanel.add(new JLabel(" "));
256
buttonPanel.add(queueButton);
257
258         buttonPanel.add(new JLabel JavaDoc(" "));
259
260         //buttonPanel.add(openButton);
261
//buttonPanel.add(new JLabel(" "));
262
buttonPanel.add(refreshButton);
263         buttonPanel.add(new JLabel JavaDoc(" "));
264         buttonPanel.add(rnButton);
265         buttonPanel.add(mkdirButton);
266         buttonPanel.add(cdButton);
267         buttonPanel.add(deleteButton);
268         buttonPanel.add(cdUpButton);
269         buttonPanel.add(new JLabel JavaDoc(" "));
270
271         buttonPanel.add(cmdButton);
272         buttonPanel.add(list);
273         buttonPanel.add(transferType);
274
275         //buttonPanel.add(new JLabel(" "));
276
buttonPanel.add(sorter);
277
278         buttonPanel.setVisible(true);
279
280         buttonPanel.setSize(getSize().width - 10, 32);
281
282         p.add("West", buttonPanel);
283         add("North", p);
284
285         sorter.addActionListener(this);
286
287         //setDirList(true);
288
jlm = new DefaultListModel JavaDoc();
289         jl = new JList JavaDoc(jlm);
290         jl.setCellRenderer(new DirCellRenderer());
291         jl.setVisibleRowCount(Settings.visibleFileRows);
292         jl.setDropTarget(JFtp.statusP.jftp.dropTarget);
293
294         // add this becaus we need to fetch only doubleclicks
295
MouseListener JavaDoc mouseListener = new MouseAdapter JavaDoc()
296         {
297             public void mousePressed(MouseEvent JavaDoc e)
298             {
299                 if(JFtp.uiBlocked)
300                 {
301                     return;
302                 }
303
304                 if(e.isPopupTrigger() || SwingUtilities.isRightMouseButton(e))
305                 {
306                     int index = jl.getSelectedIndex() - 1;
307
308                     if(index < -1)
309                     {
310                         return;
311                     }
312
313                     String JavaDoc tgt = (String JavaDoc) jl.getSelectedValue().toString();
314
315                     if(index < 0)
316                     {
317                     }
318                     else if((dirEntry == null) || (dirEntry.length < index) ||
319                                 (dirEntry[index] == null))
320                     {
321                         return;
322                     }
323                     else
324                     {
325                         currentPopup = dirEntry[index];
326                         popupMenu.show(e.getComponent(), e.getX(), e.getY());
327                     }
328                 }
329             }
330
331             public void mouseClicked(MouseEvent JavaDoc e)
332             {
333                 if(JFtp.uiBlocked)
334                 {
335                     return;
336                 }
337                 
338                 if(Settings.getUseJTableLayout()) {
339                     TableUtils.copyTableSelectionsToJList(jl, table);
340                 }
341
342                 //System.out.println("DirEntryListener::");
343
if(e.getClickCount() == 2)
344                 {
345                     //System.out.println("2xList selection: "+jl.getSelectedValue().toString());
346
int index = jl.getSelectedIndex() - 1;
347
348                     // mousewheel bugfix
349
if(index < -1)
350                     {
351                         return;
352                     }
353
354                     String JavaDoc tgt = (String JavaDoc) jl.getSelectedValue().toString();
355
356                     if(index < 0)
357                     {
358                         if(JFtp.mainFrame != null)
359                         {
360                             JFtp.mainFrame.setCursor(Cursor.WAIT_CURSOR);
361                         }
362
363                         con.chdir(path + tgt);
364
365                         if(JFtp.mainFrame != null)
366                         {
367                             JFtp.mainFrame.setCursor(Cursor.DEFAULT_CURSOR);
368                         }
369                     }
370                     else if((dirEntry == null) || (dirEntry.length < index) ||
371                                 (dirEntry[index] == null))
372                     {
373                         return;
374                     }
375                     else if(dirEntry[index].isDirectory())
376                     {
377                         con.chdir(path + tgt);
378                     }
379                     else if(dirEntry[index].isLink())
380                     {
381                         if(!con.chdir(path + tgt))
382                         {
383                             showContentWindow(path +
384                                               dirEntry[index].toString(),
385                                               dirEntry[index]);
386
387                             //blockedTransfer(index);
388
}
389                     }
390                     else
391                     {
392                         showContentWindow(path + dirEntry[index].toString(),
393                                           dirEntry[index]);
394
395                         //blockedTransfer(index);
396
}
397                 }
398             }
399         };
400         
401         if(Settings.newTableGui) {
402             jsp = new JScrollPane JavaDoc(table);
403             table.getSelectionModel().addListSelectionListener(this);
404             table.addMouseListener(mouseListener);
405         }
406         else {
407             jsp = new JScrollPane JavaDoc(jl);
408             jl.addListSelectionListener(this);
409             jl.addKeyListener(this);
410             jl.addMouseListener(mouseListener);
411             jl.requestFocus();
412         }
413         
414
415         
416         jsp.setSize(getSize().width - 20, getSize().height - 72);
417         add("Center", jsp);
418         jsp.setVisible(true);
419         
420         TableUtils.tryToEnableRowSorting(table);
421         
422         if(Settings.IS_JAVA_1_6) {
423             //sorter.setVisible(false);
424
buttonPanel.remove(sorter);
425         }
426         
427         setVisible(true);
428     }
429
430     public void setViewPort()
431     {
432     }
433
434     private void setLabel()
435     {
436         if(con instanceof FilesystemConnection)
437         {
438             label.setText("Filesystem: " + StringUtils.cutPath(path));
439         }
440         else if(con instanceof FtpConnection)
441         {
442             label.setText("Ftp: " + StringUtils.cutPath(path));
443         }
444         else if(con instanceof SftpConnection)
445         {
446             label.setText("Sftp: " + StringUtils.cutPath(path));
447         }
448         else
449         {
450             label.setText(StringUtils.cutPath(path));
451         }
452     }
453
454     /**
455     * Part of a gui refresh.
456     * There's no need to call this by hand.
457     */

458     public void gui(boolean fakeInit)
459     {
460         if(firstGui)
461         {
462             gui_init();
463             firstGui = false;
464         }
465
466         setLabel();
467
468         if(con instanceof FtpConnection)
469         {
470             list.show();
471             cmdButton.show();
472             transferType.show();
473         }
474         else
475         {
476             list.hide();
477             cmdButton.hide();
478             transferType.hide();
479         }
480
481         if(!fakeInit)
482         {
483             setDirList(false);
484         }
485
486         //TODO Log.debug("invalidate()");
487
invalidate();
488         validate();
489
490         //TODO .debug("validated.");
491
}
492
493     /**
494     * List directory and create/update the whole file list.
495     * There's no need to call this by hand.
496     */

497     public void setDirList(boolean fakeInit)
498     {
499         jlm = new DefaultListModel JavaDoc();
500
501         DirEntry dwn = new DirEntry("..", this);
502         dwn.setDirectory();
503         jlm.addElement(dwn);
504
505         if(!fakeInit)
506         {
507             if(pathChanged)
508             {
509                 pathChanged = false;
510
511                 //TODO .debug("before DirLister");
512
DirLister dir = new DirLister(con, sortMode);
513
514                 while(!dir.finished)
515                 {
516                     LocalIO.pause(10);
517                 }
518
519                 if(dir.isOk())
520                 {
521                     //TODO .debug("dir is ok");
522
length = dir.getLength();
523                     dirEntry = new DirEntry[length];
524                     files = dir.list();
525
526                     String JavaDoc[] fSize = dir.sList();
527                     int[] perms = dir.getPermissions();
528
529                     // --------- sorting aphabetically ------------
530
// is now in DirLister
531

532                     /*
533                                         if(Settings.sortDir)
534                                         {
535                                             String[] tmpx = new String[length];
536
537                                             //if(fSize != null) System.out.println(":"+length+":"+fSize.length+":"+files.length);
538                                             int pLength = length;
539
540                                             if(perms != null)
541                                             {
542                                                 pLength = perms.length;
543                                             }
544
545                                             //System.out.println(files.length + ":" + fSize.length+":"+ pLength + ":"+ length);
546                                             if((fSize.length != files.length) ||
547                                                    (pLength != files.length) ||
548                                                    (length != files.length))
549                                             {
550                                                 System.out.println("Sort mismatch - hopefully ignoring it...");
551                                             }
552
553                                             for(int x = 0; x < length; x++)
554                                             {
555                                                 if(perms != null)
556                                                 {
557                                                     tmpx[x] = files[x] + "@@@" + fSize[x] + "@@@" +
558                                                               perms[x];
559                                                 }
560                                                 else
561                                                 {
562                                                     Log.out("permissions are skipped");
563                                                     tmpx[x] = files[x] + "@@@" + fSize[x];
564                                                 }
565                                             }
566
567                                             LocalIO.sortStrings(tmpx);
568
569                                             for(int y = 0; y < length; y++)
570                                             {
571                                                 files[y] = tmpx[y].substring(0,
572                                                                              tmpx[y].indexOf("@@@"));
573
574                                                 String tmp = tmpx[y].substring(tmpx[y].indexOf("@@@") +
575                                                                                3);
576
577                                                 if(tmp.indexOf("@@@") > 0)
578                                                 {
579                                                     fSize[y] = tmp.substring(0,
580                                                                              tmp.lastIndexOf("@@@"));
581                                                 }
582                                                 else
583                                                 {
584                                                     fSize[y] = tmp;
585                                                 }
586
587                                                 if(perms != null)
588                                                 {
589                                                     perms[y] = Integer.parseInt(tmpx[y].substring(tmpx[y].lastIndexOf("@@@") +
590                                                                                                   3));
591                                                 }
592                                             }
593                                         }
594                     */

595
596                     // ----------- end sorting --------------------
597
for(int i = 0; i < length; i++)
598                     {
599                         //System.out.println(files[i]);
600
if((files == null) || (files[i] == null))
601                         {
602                             //System.out.println("Critical error, files or files[i] is null!\nPlease report when and how this happened...");
603
System.out.println("skipping setDirList, files or files[i] is null!");
604
605                             return;
606
607                             //System.exit(0);
608
}
609
610                         //Log.debug("adding: " + files[i]);
611
dirEntry[i] = new DirEntry(files[i], this);
612
613                         if(dirEntry[i] == null)
614                         {
615                             System.out.println("\nskipping setDirList, dirEntry[i] is null!");
616
617                             return;
618                         }
619
620                         if(dirEntry[i].file == null)
621                         {
622                             System.out.println("\nskipping setDirList, dirEntry[i].file is null!");
623
624                             return;
625                         }
626
627                         if(perms != null)
628                         {
629                             dirEntry[i].setPermission(perms[i]);
630                         }
631
632                         if(fSize[i].startsWith("@"))
633                         {
634                             fSize[i] = fSize[i].substring(1);
635                         }
636
637                         dirEntry[i].setFileSize(Long.parseLong(fSize[i]));
638
639                         if(dirEntry[i].file.endsWith("/"))
640                         {
641                             dirEntry[i].setDirectory();
642                         }
643                         else
644                         {
645                             dirEntry[i].setFile();
646                         }
647
648                         if(dirEntry[i].file.endsWith("###"))
649                         {
650                             dirEntry[i].setLink();
651                         }
652
653                         //------ date parser -------
654
Object JavaDoc[] d = dir.getDates();
655
656                         if(d != null)
657                         {
658                             dirEntry[i].setDate((Date JavaDoc) d[i]);
659                         }
660
661                         //--------------------------
662
jlm.addElement(dirEntry[i]);
663                     }
664                 }
665                 else
666                 {
667                     Log.debug("Not a directory: " + path);
668                 }
669             }
670
671             //System.out.println("length: "+dirEntry.length);
672
}
673
674         jl.setModel(jlm);
675         jl.grabFocus();
676         jl.setSelectedIndex(0);
677
678         //Log.debug("ListModel set.");
679
//System.out.print("x");
680
//new Exception().printStackTrace();
681
//System.out.println("\n\n\n");
682

683         update();
684     }
685
686     /**
687     * Handles the user events if the ui is unlocked
688     */

689     public void actionPerformed(ActionEvent JavaDoc e)
690     {
691         if(JFtp.uiBlocked)
692         {
693             return;
694         }
695
696         if(e.getActionCommand().equals("rm"))
697         {
698             lock(false);
699
700             if(Settings.getAskToDelete())
701             {
702                 if(!UITool.askToDelete(this))
703                 {
704                     unlock(false);
705
706                     return;
707                 }
708             }
709
710             for(int i = 0; i < length; i++)
711             {
712                 if(dirEntry[i].selected)
713                 {
714                     con.removeFileOrDir(dirEntry[i].file);
715                 }
716             }
717
718             unlock(false);
719             fresh();
720         }
721         else if(e.getActionCommand().equals("mkdir"))
722         {
723             Creator c = new Creator("Create:", con);
724
725             //TODO: do we need this on events? UpdateDaemon.updateRemoteDirGUI();
726
//fresh();
727
}
728         else if(e.getActionCommand().equals("cmd"))
729         {
730             if(!(con instanceof FtpConnection))
731             {
732                 Log.debug("This feature is for ftp only.");
733
734                 return;
735             }
736
737            
738             int opt = JOptionPane.showOptionDialog(this, "Would you like to type one command or to open a shell?","Question", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE,
739                     new ImageIcon JavaDoc(HImage.getImage(this, Settings.helpImage)), new String JavaDoc[] {"Shell","Command", "Cancel"}, "Command");
740             
741             if(opt == 1) {
742                 RemoteCommand rc = new RemoteCommand();
743             }
744             else if(opt == 0) {
745                 FtpConnection conn = (FtpConnection) con;
746                 Shell s = new Shell(conn.getCommandInputReader(), conn.getCommandOutputStream());
747             }
748
749             //fresh();
750
}
751         else if(e.getActionCommand().equals("cd"))
752         {
753             PathChanger pthc = new PathChanger("remote");
754
755             //fresh();
756
//String tmp = UITool.getPathFromDialog();
757
//setPath(tmp);
758
}
759         else if(e.getActionCommand().equals("fresh"))
760         {
761             fresh();
762         }
763         else if(e.getActionCommand().equals("->"))
764         {
765             blockedTransfer(-2);
766         }
767         else if(e.getActionCommand().equals("<-"))
768         {
769             blockedTransfer(-2);
770         }
771         else if(e.getActionCommand().equals("list"))
772         {
773             try
774             {
775                 if(!(con instanceof FtpConnection)) {
776                      Log.debug("Can only list FtpConnection output!");
777                 }
778                 
779                 PrintStream JavaDoc out = new PrintStream JavaDoc(Settings.ls_out);
780                 for(int i=0; i<((FtpConnection)con).currentListing.size(); i++) {
781                     out.println(((FtpConnection)con).currentListing.get(i));
782                 }
783                 out.flush();
784                 out.close();
785                 
786                 java.net.URL JavaDoc url = new java.io.File JavaDoc(Settings.ls_out).toURL();
787                 Displayer d = new Displayer(url, new Font JavaDoc("monospaced",Font.PLAIN, 11));
788                 JFtp.desktop.add(d, new Integer JavaDoc(Integer.MAX_VALUE - 13));
789             }
790             catch(java.net.MalformedURLException JavaDoc ex)
791             {
792                 ex.printStackTrace();
793                 Log.debug("ERROR: Malformed URL!");
794             }
795             catch(FileNotFoundException JavaDoc ex2)
796             {
797                 ex2.printStackTrace();
798                 Log.debug("ERROR: File not found!");
799             }
800         }
801         else if(e.getActionCommand().equals("type") && (!JFtp.uiBlocked))
802         {
803             if(!(con instanceof FtpConnection))
804             {
805                 Log.debug("You can only set the transfer type for ftp connections.");
806
807                 return;
808             }
809
810             FtpConnection c = (FtpConnection) con;
811             String JavaDoc t = c.getTypeNow();
812             boolean ret = false;
813
814             if(t.equals(FtpConnection.ASCII))
815             {
816                 ret = c.type(FtpConnection.BINARY);
817             }
818             else if(t.equals(FtpConnection.BINARY))
819             {
820                 ret = c.type(FtpConnection.EBCDIC);
821             }
822
823             if(t.equals(FtpConnection.EBCDIC) ||
824                    (!ret && !t.equals(FtpConnection.L8)))
825             {
826                 ret = c.type(FtpConnection.L8);
827             }
828
829             if(!ret)
830             {
831                 c.type(FtpConnection.ASCII);
832                 Log.debug("Warning: type should be \"I\" if you want to transfer binary files!");
833             }
834
835             Log.debug("Type is now " + c.getTypeNow());
836         }
837
838         else if(e.getActionCommand().equals("que")) /*&& (!JFtp.uiBlocked))*/
839         {
840             if(!(con instanceof FtpConnection))
841             {
842                 Log.debug("Queue supported only for FTP");
843
844                 return;
845             }
846
847             Object JavaDoc[] o = jl.getSelectedValues();
848             DirEntry[] tmp = new DirEntry[Array.getLength(o)];
849
850             for(int i = 0; i < Array.getLength(o); i++)
851             {
852                 tmp[i] = (DirEntry) o[i];
853                 JFtp.dQueue.addFtp(tmp[i].toString());
854             }
855         }
856         else if(e.getSource() == props)
857         {
858             JFtp.statusP.jftp.clearLog();
859
860             int x = currentPopup.getPermission();
861             String JavaDoc tmp;
862
863             if(x == FtpConnection.R)
864             {
865                 tmp = "read only";
866             }
867             else if(x == FtpConnection.W)
868             {
869                 tmp = "read/write";
870             }
871             else if(x == FtpConnection.DENIED)
872             {
873                 tmp = "denied";
874             }
875             else
876             {
877                 tmp = "undefined";
878             }
879
880             String JavaDoc msg = "File: " + currentPopup.toString() + "\n" + " Size: " +
881                          currentPopup.getFileSize() + " raw size: " +
882                          currentPopup.getRawSize() + "\n" + " Symlink: " +
883                          currentPopup.isLink() + "\n" + " Directory: " +
884                          currentPopup.isDirectory() + "\n" + " Permission: " +
885                          tmp + "\n";
886             Log.debug(msg);
887         }
888         else if(e.getSource() == sorter)
889         {
890             sortMode = (String JavaDoc) sorter.getSelectedItem();
891
892             if(sortMode.equals("Date"))
893             {
894                 Settings.showDateNoSize = true;
895             }
896             else
897             {
898                 Settings.showDateNoSize = false;
899             }
900
901             fresh();
902         }
903         else if(e.getActionCommand().equals("cdUp"))
904         {
905             JFtp.remoteDir.getCon().chdir("..");
906         }
907         else if(e.getActionCommand().equals("rn"))
908         {
909             Object JavaDoc[] target = jl.getSelectedValues();
910
911             if((target == null) || (target.length == 0))
912             {
913                 Log.debug("No file selected");
914
915                 return;
916             }
917             else if(target.length > 1)
918             {
919                 Log.debug("Too many files selected");
920
921                 return;
922             }
923
924             String JavaDoc val = JOptionPane.showInternalInputDialog(this,
925                                                              "Choose a name...");
926
927             if(val != null)
928             {
929                 if(!con.rename(target[0].toString(), val))
930                 {
931                     Log.debug("Rename failed.");
932                 }
933                 else
934                 {
935                     Log.debug("Successfully renamed.");
936                     fresh();
937                 }
938             }
939         }
940     }
941
942     /**
943     * Initiate a tranfer with ui locking enabled
944     */

945     public synchronized void blockedTransfer(int index)
946     {
947         tmpindex = index;
948
949         Runnable JavaDoc r = new Runnable JavaDoc()
950         {
951             public void run()
952             {
953                 boolean block = !Settings.getEnableMultiThreading();
954
955                 if(!(con instanceof FtpConnection))
956                 {
957                     block = true;
958                 }
959
960                 if(block)
961                 {
962                     lock(false);
963                 }
964
965                 transfer(tmpindex);
966
967                 if(block)
968                 {
969                     JFtp.localDir.fresh();
970                     unlock(false);
971                 }
972             }
973         };
974
975         Thread JavaDoc t = new Thread JavaDoc(r);
976         t.start();
977     }
978
979     /**
980     * Lock the gui.
981     */

982     public void lock(boolean first)
983     {
984         JFtp.uiBlocked = true;
985         jl.setEnabled(false);
986
987         if(!first)
988         {
989             JFtp.localDir.lock(true);
990         }
991
992         Log.out("ui locked.");
993     }
994
995     /**
996     * Unlock the gui.
997     */

998     public void unlock(boolean first)
999     {
1000        JFtp.uiBlocked = false;
1001        jl.setEnabled(true);
1002
1003        if(!first)
1004        {
1005            JFtp.localDir.unlock(true);
1006        }
1007
1008        Log.out("ui unlocked.");
1009    }
1010
1011    /**
1012    * Do a hard UI refresh - do no longe call this directly, use
1013    * safeUpdate() instead if possible.
1014    */

1015    public void fresh()
1016    {
1017        Log.out("fresh() called.");
1018
1019        Cursor JavaDoc x = null;
1020
1021        if(JFtp.mainFrame != null)
1022        {
1023            x = JFtp.mainFrame.getCursor();
1024            JFtp.mainFrame.setCursor(Cursor.WAIT_CURSOR);
1025        }
1026
1027        //TODO .debug("fresh()");
1028
String JavaDoc i = "";
1029        int idx = jl.getSelectedIndex();
1030
1031        if(idx >= 0)
1032        {
1033            Object JavaDoc o = jl.getSelectedValue();
1034
1035            if(o != null)
1036            {
1037                i = o.toString();
1038            }
1039        }
1040
1041        con.chdir(path);
1042
1043        if((idx >= 0) && (idx < jl.getModel().getSize()))
1044        {
1045            if(jl.getModel().getElementAt(idx).toString().equals(i))
1046            {
1047                jl.setSelectedIndex(idx);
1048            }
1049            else
1050            {
1051                jl.setSelectedIndex(0);
1052            }
1053        }
1054        
1055        update();
1056
1057        if((JFtp.mainFrame != null) && (x.getType() != Cursor.WAIT_CURSOR))
1058        {
1059            JFtp.mainFrame.setCursor(Cursor.DEFAULT_CURSOR);
1060        }
1061    }
1062
1063    /**
1064    * Called by FtpConnection, DownloadList is updated from here
1065    */

1066    public void updateProgress(String JavaDoc file, String JavaDoc type, long bytes)
1067    {
1068        if((dList == null) || (dirEntry == null))
1069        {
1070            return;
1071        }
1072
1073        boolean flag = false;
1074
1075        if(file.endsWith("/") && (file.length() > 1))
1076        {
1077            flag = true;
1078            file = file.substring(0, file.lastIndexOf("/"));
1079        }
1080
1081        file = file.substring(file.lastIndexOf("/") + 1);
1082
1083        if(flag)
1084        {
1085            file = file + "/";
1086        }
1087
1088        long s = 0;
1089
1090        if(JFtp.dList.sizeCache.containsKey(file))
1091        {
1092            s = ((Long JavaDoc) JFtp.dList.sizeCache.get(file)).longValue();
1093        }
1094        else
1095        {
1096            for(int i = 0; i < dirEntry.length; i++)
1097            {
1098                if(dirEntry[i] == null)
1099                {
1100                    continue;
1101                }
1102
1103                if(dirEntry[i].toString().equals(file))
1104                {
1105                    s = dirEntry[i].getRawSize();
1106                    JFtp.dList.sizeCache.put(file, new Long JavaDoc(s));
1107
1108                    break;
1109                }
1110            }
1111
1112            if(s <= 0)
1113            {
1114                File JavaDoc f = new File JavaDoc(JFtp.localDir.getPath() + file);
1115
1116                if(f.exists())
1117                {
1118                    s = f.length();
1119                }
1120            }
1121        }
1122
1123        dList.updateList(file, type, bytes, s);
1124    }
1125
1126    /**
1127    * Called by FtpConnection
1128    */

1129    public void connectionInitialized(BasicConnection con)
1130    {
1131        if(con == null)
1132        {
1133            return;
1134        }
1135
1136        setDate();
1137
1138        Log.out("remote connection initialized");
1139    }
1140
1141    /**
1142    * Called by FtpConnection
1143    */

1144    public void connectionFailed(BasicConnection con, String JavaDoc reason)
1145    {
1146        Log.out("remote connection failed");
1147
1148        if((Integer.parseInt(reason) == FtpConnection.OFFLINE) &&
1149               Settings.reconnect)
1150        {
1151            return;
1152        }
1153
1154        //this.con = con;
1155
HFrame h = new HFrame();
1156        h.getContentPane().setLayout(new BorderLayout JavaDoc(10, 10));
1157        h.setTitle("Connection failed!");
1158        h.setLocation(150, 200);
1159
1160        JTextArea JavaDoc text = new JTextArea JavaDoc();
1161        h.getContentPane().add("Center", text);
1162        text.setText(" ---------------- Output -----------------\n" +
1163                     JFtp.log.getText());
1164        JFtp.log.setText("");
1165        text.setEditable(false);
1166        h.pack();
1167        h.show();
1168    }
1169
1170    private void setDate()
1171    {
1172        if(!(con instanceof FtpConnection) &&
1173               !(con instanceof FilesystemConnection))
1174        {
1175            try
1176            {
1177                sorter.removeItem("Date");
1178            }
1179            catch(Exception JavaDoc ex)
1180            {
1181            }
1182
1183            dateEnabled = false;
1184
1185            return;
1186        }
1187
1188        //Log.debug(">>> date gui init");
1189
if((con instanceof FtpConnection) &&
1190               (((FtpConnection) con).dateVector.size() > 0))
1191        {
1192            if(!dateEnabled)
1193            {
1194                sorter.addItem("Date");
1195                dateEnabled = true;
1196                UpdateDaemon.updateRemoteDirGUI();
1197            }
1198        }
1199        else if((con instanceof FilesystemConnection) &&
1200                    (((FilesystemConnection) con).dateVector.size() > 0))
1201        {
1202            if(!dateEnabled)
1203            {
1204                sorter.addItem("Date");
1205                dateEnabled = true;
1206                UpdateDaemon.updateRemoteDirGUI();
1207            }
1208        }
1209        else
1210        {
1211            if(dateEnabled)
1212            {
1213                try
1214                {
1215                    sorter.removeItem("Date");
1216                    dateEnabled = false;
1217                    Settings.showDateNoSize = false;
1218                    UpdateDaemon.updateRemoteDirGUI();
1219                }
1220                catch(Exception JavaDoc ex)
1221                {
1222                }
1223            }
1224        }
1225    }
1226
1227    /**
1228    * Called by FtpConnection
1229    */

1230    public void updateRemoteDirectory(BasicConnection c)
1231    {
1232        //TODO Log.debug("updateRemoteDirectory()");
1233
if(con == null)
1234        {
1235            return;
1236        }
1237
1238        if((c != con) && !c.hasUploaded && con instanceof FtpConnection)
1239        {
1240            //System.out.println("Skipping connection: " + con.getCachedPWD() + " : " + JFtp.remoteDir.path);
1241
return;
1242        }
1243
1244        //Log.out(">>> update remote dir");
1245
setDate();
1246
1247        if(con instanceof FtpConnection)
1248        {
1249            path = ((FtpConnection) con).getCachedPWD();
1250        }
1251        else if(con instanceof SmbConnection && !path.startsWith("smb://"))
1252        {
1253            path = c.getPWD();
1254        }
1255        else
1256        {
1257            path = con.getPWD();
1258        }
1259
1260        //System.out.println("path: "+path +":"+ con +":" +con.getPWD() +":"+c+":" +c.getPWD());
1261
if((c != null) && (c instanceof FtpConnection))
1262        {
1263            FtpConnection con = (FtpConnection) c;
1264
1265            String JavaDoc tmp = con.getCachedPWD();
1266            SaveSet s = new SaveSet(Settings.login_def, con.getHost(),
1267                                    con.getUsername(), con.getPassword(),
1268                                    Integer.toString(con.getPort()), tmp,
1269                                    con.getLocalPath());
1270        }
1271        else if((c != null) && (c instanceof FilesystemConnection))
1272        {
1273            JFtp.localDir.getCon().setLocalPath(path);
1274        }
1275
1276        //TODO .debug("before gui()");
1277
//Log.debug(c.toString());
1278
pathChanged = true;
1279        gui(false);
1280
1281        UpdateDaemon.updateLog();
1282
1283        //JFtp.statusP.jftp.ensureLogging();
1284
//TODO .debug("after gui()");
1285
}
1286
1287    /**
1288    * Transfers all selected files
1289    */

1290    public synchronized void transfer()
1291    {
1292        boolean[] bFileSelected = new boolean[dirEntry.length + 1];
1293        DirEntry[] cacheEntry = new DirEntry[dirEntry.length];
1294        System.arraycopy(dirEntry, 0, cacheEntry, 0, cacheEntry.length);
1295
1296        for(int i = 0; i < dirEntry.length; i++)
1297        {
1298            bFileSelected[i] = cacheEntry[i].selected;
1299
1300            if(!cacheEntry[i].equals(dirEntry[i]))
1301            {
1302                Log.out("mismatch");
1303            }
1304        }
1305
1306        for(int i = 0; i < cacheEntry.length; i++)
1307        {
1308            if(bFileSelected[i])
1309            {
1310                startTransfer(cacheEntry[i]);
1311            }
1312        }
1313    }
1314
1315    /**
1316    * Start a file transfer.
1317    * Depending on the local and remote connection types some things like
1318    * local working directory have to be set, resuming may have to be checked etc.
1319    * As with ftp to ftp transfers the action used to download a file might actually be
1320    * an upload.
1321    *
1322    * WARNING: If you do anything here, please check LocalDir.startTransfer(), too!
1323    */

1324    public void startTransfer(DirEntry entry)
1325    {
1326        if(con instanceof FtpConnection &&
1327               JFtp.localDir.getCon() instanceof FtpConnection)
1328        {
1329            if(entry.isDirectory())
1330            {
1331                Log.debug("Directory transfer between remote connections is not supported yet!");
1332
1333                return;
1334            }
1335
1336            Log.out("direct ftp transfer started (download)");
1337            ((FtpConnection) JFtp.localDir.getCon()).upload(entry.file,
1338                                                            ((FtpConnection) JFtp.remoteDir.getCon()).getDownloadInputStream(path +
1339                                                                                                                             entry.file));
1340        }
1341        else if(con instanceof FtpConnection &&
1342                    JFtp.localDir.getCon() instanceof FilesystemConnection)
1343        {
1344            // local: file, remote: ftp
1345
int status = checkForExistingFile(entry);
1346
1347            if(status >= 0)
1348            {
1349                //--------------------------------------------
1350
// dirty bugfix for sizes that would be
1351
// messed up otherwise
1352

1353                /*
1354                boolean flag = false;
1355                String file = entry.file;
1356
1357                if(file.endsWith("/") && (file.length() > 1))
1358                {
1359                    flag = true;
1360                    file = file.substring(0, file.lastIndexOf("/"));
1361                }
1362
1363                file = file.substring(file.lastIndexOf("/") + 1);
1364
1365                if(flag)
1366                {
1367                    file = file + "/";
1368                } */

1369                long s = entry.getRawSize();
1370                JFtp.dList.sizeCache.put(entry.file, new Long JavaDoc(s));
1371
1372                // ---------------------------------
1373
if((entry.getRawSize() < Settings.smallSize) &&
1374                       !entry.isDirectory())
1375                {
1376                    con.download(entry.file);
1377                }
1378                else
1379                {
1380                    con.handleDownload(path + entry.file);
1381                }
1382            }
1383        }
1384        else if(con instanceof FilesystemConnection &&
1385                    JFtp.localDir.getCon() instanceof FtpConnection)
1386        {
1387            try
1388            {
1389                File JavaDoc f = new File JavaDoc(path + entry.file);
1390                FileInputStream JavaDoc in = new FileInputStream JavaDoc(f);
1391                JFtp.localDir.getCon().setLocalPath(path);
1392                Log.debug(JFtp.localDir.getCon().getPWD());
1393                ((FtpConnection) JFtp.localDir.getCon()).upload(entry.file, in);
1394            }
1395            catch(FileNotFoundException JavaDoc ex)
1396            {
1397                Log.debug("Error: File not found: " + path + entry.file);
1398            }
1399        }
1400        else if(con instanceof FilesystemConnection &&
1401                    JFtp.localDir.getCon() instanceof FilesystemConnection)
1402        {
1403            con.download(path + entry.file);
1404            JFtp.localDir.actionPerformed(con, "");
1405        }
1406        else if(JFtp.localDir.getCon() instanceof FilesystemConnection)
1407        {
1408            // local: file, remote: smb, sftp, nfs
1409
con.handleDownload(entry.file);
1410            JFtp.localDir.actionPerformed(con, "");
1411        }
1412        else
1413        {
1414            if(entry.isDirectory())
1415            {
1416                Log.debug("Directory transfer between remote connections is not supported yet!");
1417
1418                return;
1419            }
1420
1421            Log.out("direct transfer started (download)");
1422            JFtp.localDir.getCon().upload(entry.file,
1423                                          JFtp.remoteDir.getCon()
1424                                                        .getDownloadInputStream(path +
1425                                                                                entry.file));
1426            JFtp.localDir.actionPerformed(con, "FRESH");
1427        }
1428    }
1429
1430    /**
1431    * Transfers single file, or all selected files if index is -1
1432    */

1433    public void transfer(int i)
1434    {
1435        if(i == -2)
1436        {
1437            transfer();
1438
1439            return;
1440        }
1441        else if(dirEntry[i].selected)
1442        {
1443            startTransfer(dirEntry[i]);
1444        }
1445    }
1446
1447    /**
1448    * Ask for resuming or overwrite if a local file does already exist for a download
1449    */

1450    private int checkForExistingFile(DirEntry dirEntry)
1451    {
1452        File JavaDoc f = new File JavaDoc(JFtp.localDir.getPath() + dirEntry.file);
1453
1454        if(f.exists() && Settings.enableResuming && Settings.askToResume)
1455        {
1456            ResumeDialog r = new ResumeDialog(dirEntry); // ResumeDialog handels the rest
1457

1458            return -1;
1459        }
1460
1461        return 1;
1462    }
1463
1464    /**
1465    * Called by FtpConnection
1466    */

1467    public void actionFinished(BasicConnection c)
1468    {
1469        JFtp.localDir.actionPerformed(c, "LOWFRESH");
1470
1471        if(c instanceof FtpConnection)
1472        {
1473            if(((FtpConnection) c).hasUploaded)
1474            {
1475                Log.out("actionFinished called by upload: " + c);
1476
1477                //fresh();
1478
UpdateDaemon.updateRemoteDir();
1479            }
1480
1481            Log.out("actionFinished called by download: " + c);
1482        }
1483        else
1484        {
1485            Log.out("actionFinished called by: " + c);
1486
1487            //fresh();
1488
UpdateDaemon.updateRemoteDir();
1489        }
1490
1491        //JFtp.statusP.jftp.ensureLogging();
1492
UpdateDaemon.updateLog();
1493    }
1494
1495    /**
1496    * Called by FtpConnection
1497    */

1498    public void actionPerformed(Object JavaDoc target, String JavaDoc msg)
1499    {
1500        if(msg.equals(type))
1501        {
1502            UpdateDaemon.updateRemoteDirGUI();
1503
1504            //gui(true);
1505
//updateRemoteDirectory(con);
1506
}
1507        else if(msg.equals("FRESH"))
1508        {
1509            UpdateDaemon.updateRemoteDir();
1510
1511            //fresh();
1512
}
1513
1514        //Log.out("actionPerformed called.");
1515
//JFtp.statusP.jftp.ensureLogging();
1516
UpdateDaemon.updateLog();
1517    }
1518
1519    /**
1520    * Mime type handler for doubleclicks on files
1521    */

1522    public void showContentWindow(String JavaDoc url, DirEntry d)
1523    {
1524        try
1525        {
1526            if(d.getRawSize() > 200000)
1527            {
1528                Log.debug("File is too big - 200kb is the maximum, sorry.");
1529
1530                return;
1531            }
1532
1533            String JavaDoc path = JFtp.localDir.getPath();
1534
1535            if(!path.endsWith("/"))
1536            {
1537                path = path + "/";
1538            }
1539
1540            if(!new File JavaDoc(path + StringUtils.getFile(url)).exists())
1541            {
1542                con.download(url);
1543            }
1544            else
1545            {
1546                Log.debug("\nRemote file must be downloaded to be viewed and\n" +
1547                          " you already have a local copy present, pleasen rename it\n" +
1548                          " and try again.");
1549
1550                return;
1551            }
1552
1553            File JavaDoc file = new File JavaDoc(JFtp.localDir.getPath() +
1554                                 StringUtils.getFile(url));
1555
1556            if(!file.exists())
1557            {
1558                Log.debug("File not found: " + JFtp.localDir.getPath() +
1559                          StringUtils.getFile(url));
1560            }
1561
1562            HFrame f = new HFrame();
1563            f.setTitle(url);
1564
1565            JEditorPane JavaDoc pane = new JEditorPane JavaDoc("file://" +
1566                                               file.getAbsolutePath());
1567
1568            if(!pane.getEditorKit().getContentType().equals("text/html") &&
1569                   !pane.getEditorKit().getContentType().equals("text/rtf"))
1570            {
1571                if(!pane.getEditorKit().getContentType().equals("text/plain"))
1572                {
1573                    Log.debug("Nothing to do with this filetype - use the buttons if you want to transfer files.");
1574
1575                    return;
1576                }
1577
1578                pane.setEditable(false);
1579            }
1580
1581            JScrollPane JavaDoc jsp = new JScrollPane JavaDoc(pane);
1582
1583            f.getContentPane().setLayout(new BorderLayout JavaDoc());
1584            f.getContentPane().add("Center", jsp);
1585            f.setModal(false);
1586            f.setLocation(100, 100);
1587            f.setSize(600, 400);
1588
1589            //f.pack();
1590
f.show();
1591
1592            dList.fresh();
1593            JFtp.localDir.getCon().removeFileOrDir(StringUtils.getFile(url));
1594            JFtp.localDir.fresh();
1595        }
1596        catch(Exception JavaDoc ex)
1597        {
1598            Log.debug("File error: " + ex);
1599        }
1600    }
1601
1602    public void keyPressed(KeyEvent JavaDoc e)
1603    {
1604        if(e.getKeyCode() == KeyEvent.VK_ENTER)
1605        {
1606            Object JavaDoc o = jl.getSelectedValue();
1607
1608            if(o == null)
1609            {
1610                return;
1611            }
1612
1613            String JavaDoc tmp = ((DirEntry) o).toString();
1614
1615            if(tmp.endsWith("/"))
1616            {
1617                con.chdir(tmp);
1618            }
1619            else
1620            {
1621                showContentWindow(path + tmp, (DirEntry) o);
1622            }
1623        }
1624        else if(e.getKeyCode() == KeyEvent.VK_SPACE)
1625        {
1626            int x = ((DirPanel) JFtp.localDir).jl.getSelectedIndex();
1627
1628            if(x == -1)
1629            {
1630                x = 0;
1631            }
1632
1633            ((DirPanel) JFtp.localDir).jl.grabFocus();
1634            ((DirPanel) JFtp.localDir).jl.setSelectedIndex(x);
1635        }
1636    }
1637
1638    public void keyReleased(KeyEvent JavaDoc e)
1639    {
1640    }
1641
1642    public void keyTyped(KeyEvent JavaDoc e)
1643    {
1644    }
1645}
1646
Popular Tags