Source code: com/yaftp/ftp/gui/FtpCustomizer.java
1 /**
2 *
3 * CopyRights Jean-Yves MENGANT 1999,2000,2001,2002
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 package com.yaftp.ftp.gui ;
21
22
23 import java.awt.* ;
24 import java.util.* ;
25 import java.awt.event.* ;
26 import java.beans.* ;
27
28 import com.yaftp.ftp.* ;
29
30 /**
31
32 Use this class as a presentation interface for class
33 Ftp
34
35 Still implemented as a Bean
36
37 @Author Jean-Yves MENGANT
38 @version : 0.0.1
39
40
41 */
42
43 public class FtpCustomizer
44 extends FtpSwingCustomizer
45 implements Customizer {
46
47 /** Implements customizer interface */
48 public FtpCustomizer()
49 {
50 super() ;
51 _support = new PropertyChangeSupport(this) ;
52 setSize(400,300) ;
53 }
54
55 public Dimension getPreferredSize()
56 { return new Dimension(400,300) ; }
57
58 /** customized object given here by caller */
59 public void setObject( Object bean )
60 {
61 super.set_Object( (Ftp)bean ) ;
62 }
63
64 /** Standard Property change listener implementation (MULTICAST) */
65 public void addPropertyChangeListener( PropertyChangeListener l )
66 {
67 _support.addPropertyChangeListener(l) ;
68 }
69
70 public void removePropertyChangeListener( PropertyChangeListener l )
71 {
72 _support.removePropertyChangeListener(l) ;
73 }
74
75
76 public static void main ( String arg[] )
77 {
78
79 Frame f = new Frame("FTP Customizer MAIN static ") ;
80 f.setForeground(Color.black) ;
81 f.setBackground(Color.lightGray) ;
82 f.addWindowListener( new WL() ) ;
83 FtpCustomizer w = new FtpCustomizer() ;
84 if ( arg.length == 0 )
85 {
86 Ftp ftp = new Ftp() ;
87
88 w.addPropertyChangeListener( new _FTPFILE_SELECTED_() ) ;
89 w.setObject( ftp ) ;
90
91 w.getPreferredSize() ;
92 }
93 else
94 try {
95 w.setObject( Ftp.loadSerialized( arg[0]) ) ;
96 } catch ( ClientFtpError e ){
97 System.out.println( e.getMessage() ) ;
98 System.exit(0) ;
99 }
100 f.add("Center", w ) ;
101 f.pack() ;
102 f.setVisible(true) ;
103 }
104 }
105 // Exit the debug window frame
106 class WL extends WindowAdapter{
107 public void windowClosing( WindowEvent e )
108 { System.exit(0) ; }
109 }
110
111 class _FTPFILE_SELECTED_
112 implements PropertyChangeListener {
113 public void propertyChange( PropertyChangeEvent e )
114 {
115 System.out.println(" Entering Ftp Property Change Event"+e.getPropertyName() ) ;
116 FtpOsFile f = (FtpOsFile) e.getNewValue() ;
117 System.out.println("downloaded : "+f.toString() ) ;
118 }
119 }