avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ran...@apache.org
Subject cvs commit: jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui about.html FtpAboutPanel.java FtpAdmin.java FtpFilePanel.java FtpFileTableModel.java FtpSpyFrame.java SpyPanel.java CommonHandler.java ConfigTableModel.java FtpAdminFrame.java FtpConnectionPanel.java FtpConnectionTableModel.java FtpIpPanel.java FtpRootPanel.java FtpStatisticsPanel.java FtpTreeModel.java FtpUserPanel.java GuiUtils.java
Date Wed, 06 Mar 2002 13:53:21 GMT
rana_b      02/03/06 05:53:21

  Modified:    ftpserver/src/java/org/apache/avalon/ftpserver/gui
                        CommonHandler.java ConfigTableModel.java
                        FtpAdminFrame.java FtpConnectionPanel.java
                        FtpConnectionTableModel.java FtpIpPanel.java
                        FtpRootPanel.java FtpStatisticsPanel.java
                        FtpTreeModel.java FtpUserPanel.java GuiUtils.java
  Added:       ftpserver/src/java/org/apache/avalon/ftpserver/gui
                        about.html FtpAboutPanel.java FtpAdmin.java
                        FtpFilePanel.java FtpFileTableModel.java
                        FtpSpyFrame.java SpyPanel.java
  Log:
  second stage of refactoring
  
  Revision  Changes    Path
  1.5       +43 -20    jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/CommonHandler.java
  
  Index: CommonHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/CommonHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CommonHandler.java	14 Dec 2001 01:22:03 -0000	1.4
  +++ CommonHandler.java	6 Mar 2002 13:53:20 -0000	1.5
  @@ -1,4 +1,3 @@
  -
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -6,17 +5,21 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    */
  -package org.apache.avalon.ftpserver.gui;
  -
   
  +package org.apache.avalon.ftpserver.gui;
   
  -import org.apache.avalon.ftpserver.interfaces.RemoteFtpAdmin;
  -import org.apache.avalon.ftpserver.interfaces.RemoteFtpConfig;
  -
  -import java.awt.*;
  +import java.awt.Component;
   
  +import org.apache.avalon.ftpserver.FtpUser;
  +import org.apache.avalon.ftpserver.remote.interfaces.RemoteHandlerInterface;
  +import org.apache.avalon.ftpserver.remote.interfaces.FtpConfigInterface;
  +import org.apache.avalon.ftpserver.remote.interfaces.FtpStatisticsInterface;
  +import org.apache.avalon.ftpserver.remote.interfaces.ConnectionServiceInterface;
  +import org.apache.avalon.ftpserver.remote.interfaces.IpRestrictorInterface;
  +import org.apache.avalon.ftpserver.remote.interfaces.UserManagerInterface;
   
  -/**
  + 
  +/** 
    * GUI common handler methods.
    *
    * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
  @@ -31,30 +34,50 @@
       /**
        * Terminate application
        */
  -    void terminate();
  -
  +    void terminate(); 
  +        
       /**
        * Get admin session
        */
       String getSessionId();
  -
  +    
       /**
        * Get ftp server interface
        */
  -    RemoteFtpAdmin getServer();
  -
  +    RemoteHandlerInterface getRemoteHandler();
  +    
       /**
        * Get config interface
        */
  -    RemoteFtpConfig getConfig();
  -
  +    FtpConfigInterface getConfig();
  +    
       /**
  -     * Logout admin
  +     * Get statistics interface
        */
  -    void logout();
  -
  +    FtpStatisticsInterface getStatistics();    
  +        
  +    /**
  +     * Get connection service
  +     */    
  +    ConnectionServiceInterface getConnectionService();    
  +       
  +    /**
  +     * Get IP restrictor
  +     */   
  +    IpRestrictorInterface getIpRestrictor();    
  +        
  +    /**
  +     * Get user manager
  +     */    
  +    UserManagerInterface getUserManager();
  +      
  +    /**
  +     * Get user object from the session id
  +     */  
  +    FtpUser getUser(String sessionId);    
  +            
       /**
        * Get top component
  -     */
  -    Component getTopComponent();
  +     */ 
  +    Component getTopComponent();  
   }
  
  
  
  1.6       +69 -68    jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/ConfigTableModel.java
  
  Index: ConfigTableModel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/ConfigTableModel.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ConfigTableModel.java	14 Dec 2001 01:22:03 -0000	1.5
  +++ ConfigTableModel.java	6 Mar 2002 13:53:20 -0000	1.6
  @@ -1,4 +1,3 @@
  -
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -6,145 +5,147 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    */
  -package org.apache.avalon.ftpserver.gui;
  -
   
  +package org.apache.avalon.ftpserver.gui;
   
   import java.util.Vector;
  -
   import javax.swing.table.AbstractTableModel;
  -
   import java.rmi.RemoteException;
  -
  -import org.apache.avalon.ftpserver.interfaces.RemoteFtpConfig;
  -
  +import org.apache.avalon.ftpserver.remote.interfaces.FtpConfigInterface;
   
   /**
  - * This table model is used to display <code>Properties</code>.
  + * This table model is used to display ftp configuration parameters.
    *
    * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
    */
  -public class ConfigTableModel extends AbstractTableModel {
  -
  -    private final static String[] COL_NAMES = { "Name", "Value" };
  -
  -    /**
  -     * Ftp config remote object.
  -     */
  -    private RemoteFtpConfig mConfig;
  +public
  +class ConfigTableModel extends AbstractTableModel {
  +    
  +    private final static String[] COL_NAMES = {"Name", "Value"};
  +    
  +    private FtpConfigInterface mConfig;
       private CommonHandler mCommonHandler;
  -
  +    
       /**
        * All properties key.
        */
  -    private Vector mTableKeys = new Vector();
  +    private Vector mTableKeys = new Vector();   
       private Vector mTableVals = new Vector();
  -
  +     
  +     
       /**
        * Create this <code>TableModel</code>.
        */
       public ConfigTableModel(CommonHandler commonHandler) throws RemoteException {
  -
           mConfig = commonHandler.getConfig();
           mCommonHandler = commonHandler;
  -
           initializeTable();
       }
  -
  +    
       /**
        * Initialize table - populate vector.
        */
       private void initializeTable() throws RemoteException {
  -
           mTableKeys.clear();
           mTableVals.clear();
  -
  -        if (mConfig != null) {
  +        
  +        if(mConfig != null) {
               mTableKeys.add("Server Address");
               mTableVals.add(String.valueOf(mConfig.getServerAddress().getHostAddress()));
  +            
               mTableKeys.add("Server Port");
               mTableVals.add(String.valueOf(mConfig.getServerPort()));
  +
  +            mTableKeys.add("Anonymous Login Supported");
  +            mTableVals.add(String.valueOf(mConfig.isAnonymousLoginAllowed()));
  +            
               mTableKeys.add("Maximum Connections");
               mTableVals.add(String.valueOf(mConfig.getMaxConnections()));
  -            mTableKeys.add("Anonymous Login Supported");
  -            mTableVals.add(String.valueOf(mConfig.isAnonymousLoginSupported()));
  +            
               mTableKeys.add("Maximum Anonymous Connections");
  -            mTableVals.add(String.valueOf(mConfig.getMaxAnonymousConnections()));
  +            mTableVals.add(String.valueOf(mConfig.getMaxAnonymousLogins()));
  +            
               mTableKeys.add("Scheduler Interval (sec)");
               mTableVals.add(String.valueOf(mConfig.getSchedulerInterval()));
  +            
               mTableKeys.add("Default Idle Time (sec)");
  -            mTableVals.add(String.valueOf(mConfig.getMaxIdleTime()));
  -            mTableKeys.add("Remote Admin Supported");
  -            mTableVals.add(String.valueOf(mConfig.isRemoteAdminSupported()));
  +            mTableVals.add(String.valueOf(mConfig.getDefaultIdleTime()));
  +            
  +            mTableKeys.add("Default Root Directory");
  +            mTableVals.add(String.valueOf(mConfig.getDefaultRoot()));
  +                        
               mTableKeys.add("Remote Admin Port");
               mTableVals.add(String.valueOf(mConfig.getRemoteAdminPort()));
  +            
  +            mTableKeys.add("Remote Admin Allowed");
  +            mTableVals.add(String.valueOf(mConfig.isRemoteAdminAllowed()));      
  +            
               mTableKeys.add("Base Directory");
  -            mTableVals.add(String.valueOf(mConfig.getBaseDirectory()));
  +            mTableVals.add(mConfig.getBaseDirectory());                          
           }
  -    }
  -
  +    } 
  +    
  +     
       /**
        * Get column class - always string.
        */
       public Class getColumnClass(int index) {
           return String.class;
       }
  -
  +     
       /**
        * Get column count.
        */
       public int getColumnCount() {
           return COL_NAMES.length;
  -    }
  -
  +    } 
  +    
       /**
        * Get column name.
        */
       public String getColumnName(int index) {
           return COL_NAMES[index];
  -    }
  -
  +    } 
  +    
       /**
        * Get row count.
        */
       public int getRowCount() {
           return mTableKeys.size();
  -    }
  -
  +    } 
  +    
       /**
        * Get value at.
        */
       public Object getValueAt(int row, int col) {
  -
  -        if (col == 0) {
  +        if(col == 0) {
               return mTableKeys.get(row);
  -        } else {
  -            return mTableVals.get(row);
           }
  -    }
  -
  +        else {
  +            return mTableVals.get(row); 
  +        }
  +    } 
  +     
       /**
        * Is cell editable - currently true.
        */
       public boolean isCellEditable(int row, int col) {
           return true;
  -    }
  -
  -    /**
  -     * Set value at - does not set value - dummy metod.
  -     */
  -    public void setValueAt(Object val, int row, int col) {}
  -
  -    /**
  -     * Clear table model.
  -     */
  -    public void clear() {
  -
  -        mTableKeys.clear();
  -        mTableVals.clear();
  -
  -        mConfig = null;
  -
  -        fireTableDataChanged();
  -    }
  -}
  +    } 
  +    
  +   /**
  +    * Set value at - does not set value - dummy metod.
  +    */
  +   public void setValueAt(Object val, int row, int col) {
  +   }  
  +   
  +   /**
  +    * Clear table model.
  +    */
  +   public void clear() {
  +       mTableKeys.clear();
  +       mTableVals.clear();
  +       mConfig = null;
  +       fireTableDataChanged();
  +   } 
  +}   
  
  
  
  1.10      +91 -126   jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpAdminFrame.java
  
  Index: FtpAdminFrame.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpAdminFrame.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- FtpAdminFrame.java	14 Dec 2001 01:22:03 -0000	1.9
  +++ FtpAdminFrame.java	6 Mar 2002 13:53:20 -0000	1.10
  @@ -1,4 +1,3 @@
  -
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -6,194 +5,160 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    */
  -package org.apache.avalon.ftpserver.gui;
  -
   
  +package org.apache.avalon.ftpserver.gui;
   
   import java.rmi.RemoteException;
  -
   import java.awt.*;
   import java.awt.event.*;
  -
   import javax.swing.*;
   import javax.swing.event.*;
   import javax.swing.tree.*;
   
  -import org.apache.avalon.ftpserver.interfaces.FtpAdmin;
  -import org.apache.avalon.ftpserver.interfaces.RemoteFtpConfig;
  +import org.apache.avalon.ftpserver.remote.interfaces.RemoteHandlerInterface;
   import org.apache.avalon.ftpserver.FtpException;
   
  -import org.jesktop.frimble.JFrimble;
  -import org.jesktop.frimble.FrimbleEvent;
  -import org.jesktop.frimble.FrimbleAdapter;
  -
   
   /**
  - * Ftp server admin user interface.
  + * Ftp server admin user interface.  
    *
    * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
    */
  -public class FtpAdminFrame extends JFrimble implements TreeSelectionListener {
  -
  -    private JTabbedPane mjTabPane;
  -    private JTree mjFtpTree = null;
  -    private JPanel mjFtpPane = null;
  -    private FtpRootPanel mRootPane = null;
  -    private RemoteFtpConfig mConfig = null;
  -    private CommonHandler mCommonHandler = null;
  -    private FtpAdminPanel mFtpAdminPanel;
  -
  -    /**
  -     * Creates new form MyServerFrame
  -     */
  -    public FtpAdminFrame() {
  -
  -        JMenuBar jmb = new JMenuBar();
  -        JMenu jm = new JMenu("File");
  -        JMenuItem jmi = new JMenuItem("Connect..");
  -
  -        jmb.add(jm);
  -        jm.add(jmi);
  -        jmi.addActionListener(new ActionListener() {
  -
  -            public void actionPerformed(ActionEvent ae) {
  -                new FtpAdminDialog(FtpAdminFrame.this);
  -            }
  -        });
  -        super.setJMenuBar(jmb);
  -
  -        mFtpAdminPanel = new FtpAdminPanel();
  -
  -        this.getContentPane().add(mFtpAdminPanel, BorderLayout.CENTER);
  -        pack();
  -        setTitle("Ftp Server");
  -        GuiUtils.setLocation(this.getFrimbleContained());
  -    }
  -
  -    /**
  -     * Method setCommonHandler
  -     *
  -     *
  -     * @param commonHandler
  -     *
  -     * @throws FtpException
  -     * @throws RemoteException
  -     *
  +public 
  +class FtpAdminFrame extends JFrame implements TreeSelectionListener {
  +    
  +    private final static ImageIcon ICON_IMG = GuiUtils.createImageIcon("org/apache/avalon/ftpserver/gui/server.gif");
  +    
  +    private JTabbedPane mjTabPane;  
  +    
  +    private JTree  mjFtpTree    = null;
  +    private JPanel mjFtpPane    = null;
  +    
  +    private FtpRootPanel  mRootPane      = null;
  +  	private CommonHandler mCommonHandler = null;
  +    
  +    
  +    /** 
  +     * Creates new form MyServerFrame 
        */
  -    void setCommonHandler(CommonHandler commonHandler) throws RemoteException, FtpException {
  -
  +    public FtpAdminFrame(CommonHandler commonHandler) throws RemoteException, FtpException {   
           mCommonHandler = commonHandler;
  -        mConfig = mCommonHandler.getConfig();
  -
  -        initComponents();
  +        initComponents();        
       }
   
  -    /**
  +    /** 
        * This method is called from within the constructor to
        * initialize the form.
        */
  -    private void initComponents() throws RemoteException {
  -
  +    private void initComponents() throws RemoteException { 
           mjTabPane = new JTabbedPane();
  -
  +        
           // top level
           JSplitPane jSplitPane = new JSplitPane();
  -
           jSplitPane.setDividerSize(2);
  -
  +        
           // left pane
           mjFtpTree = new JTree(new FtpTreeModel());
  -
  -        JScrollPane custPane = new JScrollPane(mjFtpTree,
  +        JScrollPane custPane = new JScrollPane(mjFtpTree, 
                                                  JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                                  JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  -
           jSplitPane.setLeftComponent(custPane);
  -
  +        
           // right pane
           mjFtpPane = new JPanel();
  -
           jSplitPane.setRightComponent(mjFtpPane);
  -
  +        
           mRootPane = new FtpRootPanel(mCommonHandler);
   
           mjFtpPane.add(mRootPane);
  +        
           mjFtpTree.addTreeSelectionListener(this);
  -        mjFtpTree.setSelectionPath(new TreePath(FtpAdmin.DISPLAY_NAME));
  -        jSplitPane.setDividerLocation(120);
  -        mjTabPane.addTab(FtpAdmin.DISPLAY_NAME, jSplitPane);
  -        mFtpAdminPanel.add(mjTabPane, BorderLayout.CENTER);
  -        this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
  -
  -        // handle closing of window.
  -        this.addFrimbleListener(new FrimbleAdapter() {
  -
  -            public void frimbleClosing(FrimbleEvent e) {
  -
  -                if (!GuiUtils.getConfirmation(FtpAdminFrame.this.getFrimbleContained(),
  -                                              "Do you really want to exit?")) {
  -                    return;
  -                }
  +        mjFtpTree.setSelectionPath(new TreePath(RemoteHandlerInterface.DISPLAY_NAME));
  +        mjFtpTree.putClientProperty("JTree.lineStyle", "Angled");
  +        
  +        DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
  +        renderer.setLeafIcon(null);
  +        renderer.setOpenIcon(null);
  +        renderer.setClosedIcon(null);
  +        mjFtpTree.setCellRenderer(renderer);
  +        
  +        jSplitPane.setDividerLocation(100);          
  +        mjTabPane.addTab(RemoteHandlerInterface.DISPLAY_NAME, jSplitPane);
  +        
  +        getContentPane().add(mjTabPane, BorderLayout.CENTER);
  +        
  +        pack();
  +        setTitle("Ftp Server");
  +        if (ICON_IMG != null) {
  +            setIconImage(ICON_IMG.getImage());
  +        }
  +        setSize(new Dimension(600, 450));
  +        GuiUtils.setLocation(this);
  +    }
   
  -                mCommonHandler.terminate();
  +    /*
  +     * Handle window closing event.
  +     */ 
  +    protected void processWindowEvent(WindowEvent e) {
  +        int id = e.getID();
  +        if (id == WindowEvent.WINDOW_CLOSING) {
  +            if ( !GuiUtils.getConfirmation(this, "Do you really want to exit?") ) {
  +                return;
               }
  -        });
  +            super.processWindowEvent(e);
  +            mCommonHandler.terminate();
  +        } else {
  +            super.processWindowEvent(e);
  +        }    
       }
   
       /**
        * Handle tree selection
        */
       public void valueChanged(TreeSelectionEvent e) {
  -
           Object node = e.getPath().getLastPathComponent();
           TreeModel model = mjFtpTree.getModel();
           JPanel dispPane = null;
  -
  -        if (model.getRoot().equals(node)) {
  +        if(model.getRoot().equals(node)) {
               dispPane = mRootPane;
  -        } else if (node.equals(FtpTreeModel.CHILDREN[0])) {
  +        }
  +        else if(node.equals(FtpTreeModel.CHILDREN[0])) {
               dispPane = mRootPane.getUserPanel();
  -        } else if (node.equals(FtpTreeModel.CHILDREN[1])) {
  +        }
  +        else if(node.equals(FtpTreeModel.CHILDREN[1])) {
               dispPane = mRootPane.getConnectionPanel();
  -        } else if (node.equals(FtpTreeModel.CHILDREN[2])) {
  +        }
  +        else if(node.equals(FtpTreeModel.CHILDREN[2])) {
               dispPane = mRootPane.getIpPanel();
  -        } else if (node.equals(FtpTreeModel.CHILDREN[3])) {
  +        }
  +        else if(node.equals(FtpTreeModel.CHILDREN[3])) {
  +            dispPane = mRootPane.getUploadPanel();
  +        }
  +        else if(node.equals(FtpTreeModel.CHILDREN[4])) {
  +            dispPane = mRootPane.getDownloadPanel();
  +        }
  +        else if(node.equals(FtpTreeModel.CHILDREN[5])) {
  +            dispPane = mRootPane.getDeletePanel();
  +        }
  +        else if(node.equals(FtpTreeModel.CHILDREN[6])) {
               dispPane = mRootPane.getStatisticsPanel();
           }
  -
  -        if (dispPane != null) {
  +        else if(node.equals(FtpTreeModel.CHILDREN[7])) {
  +            dispPane = mRootPane.getAboutPanel();
  +        }
  +        
  +        if(dispPane != null) {
               GuiUtils.showNewPanel(mjFtpPane, dispPane);
           }
       }
  -
  +    
       /**
        * Release resources
        */
       public void close() {
  -
  -        setVisible(false);
  -
  -        if (mRootPane != null) {
  -            mRootPane.close();
  -        }
  -
  +    	setVisible(false);
  +        mRootPane.close();
           dispose();
       }
   
  -    ////////////////////////////////////////////////////////////////////////
  -    ///////////////////////  Program Starting Point  ///////////////////////
  -    ////////////////////////////////////////////////////////////////////////
  -
  -    /**
  -     * Remote admin starting point.
  -     */
  -    public static void main(String args[]) {
  -
  -        JFrimble f = new FtpAdminFrame();
  -
  -        f.pack();
  -        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  -        f.setSize(new Dimension(600, 450));
  -        f.setVisible(true);
  -    }
  -}
  +}
  \ No newline at end of file
  
  
  
  1.4       +92 -111   jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpConnectionPanel.java
  
  Index: FtpConnectionPanel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpConnectionPanel.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FtpConnectionPanel.java	14 Dec 2001 01:22:03 -0000	1.3
  +++ FtpConnectionPanel.java	6 Mar 2002 13:53:20 -0000	1.4
  @@ -1,4 +1,3 @@
  -
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -6,19 +5,14 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    */
  -package org.apache.avalon.ftpserver.gui;
  -
   
  +package org.apache.avalon.ftpserver.gui;
   
   import java.rmi.RemoteException;
  -
   import java.awt.*;
   import java.awt.event.*;
  -
   import javax.swing.*;
  -
   import org.apache.avalon.ftpserver.FtpUser;
  -import org.apache.avalon.ftpserver.interfaces.UserHandler;
   
   
   /**
  @@ -26,163 +20,150 @@
    *
    * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
    */
  -public class FtpConnectionPanel extends JPanel {
  -
  +public 
  +class FtpConnectionPanel extends JPanel {
  +    
       private JTable mjConnectionTable;
  -    private FtpSpyDialog mSpyDlg;
  -    private UserHandler mUserHandler;
  +    private FtpConnectionPanel mSelf;
  +    
       private CommonHandler mCommonHandler;
  -
  +    private FtpConnectionTableModel mModel;    
  +    private FtpSpyFrame mSpyFrame;
  +    
       /**
        * Instantiate login panel.
        */
       public FtpConnectionPanel(CommonHandler commonHandler) throws RemoteException {
  -
  +        mSelf = this;
           mCommonHandler = commonHandler;
  -        mUserHandler = commonHandler.getConfig().getUserHandler();
  -        mSpyDlg = new FtpSpyDialog(mCommonHandler);
  -
  -        initComponents();
  +        mModel = new FtpConnectionTableModel(mCommonHandler);
  +        initComponents(); 
  +        mSpyFrame = new FtpSpyFrame(commonHandler);
       }
  -
  +     
       /**
        * Initialize UI components
        */
  -    private void initComponents() throws RemoteException {
  -
  +    private void initComponents() {
  +        
           setLayout(new BorderLayout());
  -
  -        mjConnectionTable = new JTable(new FtpConnectionTableModel(mCommonHandler));
  -
  -        mjConnectionTable.setPreferredScrollableViewportSize(new Dimension(420, 320));
  +        
  +        mjConnectionTable = new JTable(mModel);
  +        mjConnectionTable.setPreferredScrollableViewportSize(new Dimension(470, 320));
           mjConnectionTable.setColumnSelectionAllowed(false);
  -
  -        JScrollPane bottomPane = new JScrollPane(mjConnectionTable,
  -                                                 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
  -                                                 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  -
  +        JScrollPane bottomPane = new JScrollPane(mjConnectionTable, 
  +                                     JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
  +                                     JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);                          
           add(bottomPane, BorderLayout.CENTER);
  -
  +        
  +        
           // buttons
           JPanel btnPane = new JPanel();
  -
           btnPane.setLayout(new FlowLayout(FlowLayout.CENTER));
  -
  -        JButton jCloseBtn = new JButton("Close");
  -
  -        btnPane.add(jCloseBtn);
  -
  +        
  +        JButton jLogoutBtn = new JButton("Disconnect");
  +        btnPane.add(jLogoutBtn);
  +        
           JButton jSpyBtn = new JButton("Spy User");
  -
           btnPane.add(jSpyBtn);
  -
  +        
           JButton jReloadBtn = new JButton("Reload");
  -
           btnPane.add(jReloadBtn);
  +        
           add(btnPane, BorderLayout.SOUTH);
  -
  +        
           // event handlers
  -        jCloseBtn.addActionListener(new ActionListener() {
  -
  -            public void actionPerformed(ActionEvent evt) {
  +        jLogoutBtn.addActionListener(new ActionListener() {
  +             public void actionPerformed(ActionEvent evt) {
                   closeConnection();
  -            }
  +             }
           });
  +        
           jSpyBtn.addActionListener(new ActionListener() {
  -
  -            public void actionPerformed(ActionEvent evt) {
  +             public void actionPerformed(ActionEvent evt) {
                   spyUser();
  -            }
  +             }
           });
  +        
           jReloadBtn.addActionListener(new ActionListener() {
  -
  -            public void actionPerformed(ActionEvent evt) {
  +             public void actionPerformed(ActionEvent evt) {
                   reload();
  -            }
  +             }
           });
  +        
       }
  -
  +     
       /**
  -     * Close this connection.
  +     * Logout this user
        */
  -    public void closeConnection() {
  -
  +    private void closeConnection() {
  +        int indices[] = mjConnectionTable.getSelectedRows();
  +        if(indices.length == 0) {
  +            GuiUtils.showErrorMessage(mSelf, "Please select connection(s).");
  +            return;
  +        }
  +        
  +        boolean response = GuiUtils.getConfirmation(mSelf, "Do you really want to close the selected connection(s)?");
  +        if(!response) {
  +            return;
  +        }
  +        
           try {
  -            FtpConnectionTableModel tableModel =
  -                (FtpConnectionTableModel) mjConnectionTable.getModel();
  -            int indices[] = mjConnectionTable.getSelectedRows();
  -
  -            if (indices.length == 0) {
  -                GuiUtils.showErrorMessage(mCommonHandler.getTopComponent(),
  -                                          "Please select user(s).");
  -
  -                return;
  -            }
  -
  -            boolean response = GuiUtils.getConfirmation(
  -                mCommonHandler.getTopComponent(),
  -                "Do you really want to close the selected connection(s)?");
  -
  -            if (!response) {
  -                return;
  -            }
  -
  -            for (int i = 0; i < indices.length; i++) {
  -                FtpUser user = tableModel.getUser(indices[i]);
  -
  -                if (user != null) {
  -                    mUserHandler.closeConnection(user.getSessionId());
  +            for(int i=indices.length; --i>=0; ) {
  +                FtpUser user = mModel.getUser(indices[i]);
  +                if(user != null) {
  +                    mCommonHandler.getConnectionService().closeConnection(user.getSessionId());
                   }
               }
  -        } catch (Exception ex) {
  +        }
  +        catch(Exception ex) {
               mCommonHandler.handleException(ex);
           }
       }
  -
  +    
       /**
        * Monitor the selected user.
        */
  -    public void spyUser() {
  -
  -        FtpConnectionTableModel tableModel =
  -            (FtpConnectionTableModel) mjConnectionTable.getModel();
  +    private void spyUser() {
           int indices[] = mjConnectionTable.getSelectedRows();
  -
  -        if (indices.length == 0) {
  -            GuiUtils.showErrorMessage(mCommonHandler.getTopComponent(),
  -                                      "Please select a connection.");
  -
  +        if(indices.length == 0) {
  +            GuiUtils.showErrorMessage(mSelf, "Please select connection(s).");
               return;
           }
  -
  -        FtpUser thisUser = tableModel.getUser(indices[0]);
  -
  -        mSpyDlg.init(thisUser);
  +        
  +        try {
  +            for(int i=indices.length; --i>=0; ) {   
  +                FtpUser thisUser = mModel.getUser(indices[i]);
  +                if (thisUser != null) {
  +                    mSpyFrame.monitorConnection(thisUser);
  +                }
  +            }
  +            mSpyFrame.setVisible(true);
  +        }
  +        catch(Exception ex) {
  +            mCommonHandler.handleException(ex);
  +        }
       }
  -
  +    
       /**
  -     * Reload logn table
  +     * Reload connection table
        */
  -    public void reload() {
  -
  +    private void reload() {
           try {
  -            FtpConnectionTableModel model =
  -                (FtpConnectionTableModel) mjConnectionTable.getModel();
  -
  -            model.reload();
  -        } catch (Exception ex) {
  +            mModel.reload();
  +        }
  +        catch(Exception ex) {
               mCommonHandler.handleException(ex);
           }
       }
  -
  +    
       /**
  -     * Release resources
  +     * Close it
        */
       public void close() {
  -
  -        FtpConnectionTableModel model = (FtpConnectionTableModel) mjConnectionTable.getModel();
  -
  -        model.close();
  -        mSpyDlg.close();
  -    }
  -}
  +        mModel.close();
  +        mSpyFrame.close();
  +        mSpyFrame.dispose();
  +    } 
  +     
  +}
  \ No newline at end of file
  
  
  
  1.4       +141 -157  jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpConnectionTableModel.java
  
  Index: FtpConnectionTableModel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpConnectionTableModel.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FtpConnectionTableModel.java	14 Dec 2001 01:22:03 -0000	1.3
  +++ FtpConnectionTableModel.java	6 Mar 2002 13:53:20 -0000	1.4
  @@ -1,4 +1,3 @@
  -
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -6,26 +5,23 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    */
  -package org.apache.avalon.ftpserver.gui;
  -
   
  +package org.apache.avalon.ftpserver.gui;
   
   import java.rmi.RemoteException;
  -import java.rmi.server.UnicastRemoteObject;
  -
   import java.net.InetAddress;
  -
   import java.util.Date;
   import java.util.List;
  -import java.util.ArrayList;
  -
  +import java.util.Iterator;
  +import java.util.Vector;
  +import java.util.Hashtable;
   import java.text.SimpleDateFormat;
  -
   import javax.swing.table.AbstractTableModel;
   
  -import org.apache.avalon.ftpserver.interfaces.UserHandler;
  -import org.apache.avalon.ftpserver.interfaces.FtpConnectionObserver;
   import org.apache.avalon.ftpserver.FtpUser;
  +import org.apache.avalon.ftpserver.remote.interfaces.ConnectionServiceInterface;
  +import org.apache.avalon.ftpserver.remote.interfaces.FtpConnectionObserver;
  +import org.apache.avalon.ftpserver.gui.remote.FtpConnectionObserverAdapter;
   
   
   /**
  @@ -33,229 +29,217 @@
    *
    * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
    */
  -public class FtpConnectionTableModel extends AbstractTableModel implements FtpConnectionObserver {
  -
  -    private final static SimpleDateFormat DATE_FMT = new SimpleDateFormat("MM/dd/yy HH:mm:ss");
  -    private final static String[] COL_NAMES = { "Name", "Login Time", "Last Access Time",
  -                                                "Client" };
  -    private List mConnectedUserList = new ArrayList();
  -    private UserHandler mUserHandler;
  +public
  +class FtpConnectionTableModel extends AbstractTableModel 
  +                              implements FtpConnectionObserver {
  +    
  +    private final static SimpleDateFormat DATE_FMT = new SimpleDateFormat("MM/dd HH:mm:ss");
  +    
  +    private final static String[] COL_NAMES = {"Name", 
  +                                               "Login Time", 
  +                                               "Last Access Time",    
  +                                               "Client"};
  +                                               
  +    private Vector mUserList;
  +    
  +    private ConnectionServiceInterface mConService;
       private CommonHandler mCommonHandler;
  -
  +    private FtpConnectionObserverAdapter mObserver;
  +    
  +    
       /**
        * Constructor - initialize user list
        */
       public FtpConnectionTableModel(CommonHandler commonHandler) throws RemoteException {
  -
           mCommonHandler = commonHandler;
  -        mUserHandler = mCommonHandler.getConfig().getUserHandler();
  -        mConnectedUserList = mUserHandler.getAllConnectedUsers();
  -
  -        UnicastRemoteObject.exportObject(this);
  -        mUserHandler.setObserver(this);
  +        mConService = mCommonHandler.getConnectionService();
  +        mUserList = new Vector();        
  +        mObserver = new FtpConnectionObserverAdapter(mConService, this);
  +        reload();
       }
  -
  +    
  +    /**
  +     * Get user
  +     */
  +    public FtpUser getUser(int index) {
  +        FtpUser user = null;
  +        synchronized(mUserList) {
  +            if ( (index >= 0) && (index < mUserList.size()) ) {
  +                user = (FtpUser)mUserList.get(index);
  +            }
  +        }
  +        return user;
  +    }
  +    
  +          
       /**
        * Get column class - always string
        */
       public Class getColumnClass(int index) {
           return String.class;
       }
  -
  +    
       /**
        * Get column count.
        */
       public int getColumnCount() {
           return COL_NAMES.length;
       }
  -
  +    
       /**
        * Get column name.
        */
       public String getColumnName(int index) {
           return COL_NAMES[index];
  -    }
  -
  +    } 
  +    
       /**
        * Get row count.
        */
  -    public synchronized int getRowCount() {
  -        return mConnectedUserList.size();
  +    public int getRowCount() {
  +        return mUserList.size();
       }
  -
  +    
       /**
        * Is cell editable - currently false.
        */
       public boolean isCellEditable(int row, int col) {
           return true;
       }
  -
  -    /**
  -     * Set value at - dummy method
  -     */
  -    public void setValueAt(Object val, int row, int col) {}
  -
  -    /**
  -     * Get value at.
  -     */
  -    public synchronized Object getValueAt(int row, int col) {
  -
  +    
  +   /**
  +    * Set value at - dummy method
  +    */
  +   public void setValueAt(Object val, int row, int col) {
  +   }
  +      
  +   /**
  +    * Get value at.
  +    */
  +    public Object getValueAt(int row, int col) {
  +        
           // error check
  -        String retVal = "";
  -
  -        if (row >= mConnectedUserList.size()) {
  +        String retVal = "";    
  +        FtpUser thisUser = getUser(row);
  +        if (thisUser == null) {
               return retVal;
           }
  -
  -        FtpUser thisUser = (FtpUser) mConnectedUserList.get(row);
  -
  -        switch (col) {
  -
  -        case 0 :
  -            if (thisUser.getName() != null) {
  +        
  +        switch(col) {
  +            case 0:
                   retVal = thisUser.getName();
  -            }
  -            break;
  -
  -        case 1 :
  -            if (thisUser.getLoginTime() != 0) {
  -                retVal = DATE_FMT.format(new Date(thisUser.getLoginTime()));
  -            }
  -            break;
  -
  -        case 2 :
  -            if (thisUser.getLastAccessTime() != 0) {
  -                retVal = DATE_FMT.format(new Date(thisUser.getLastAccessTime()));
  -            }
  -            break;
  -
  -        case 3 :
  -            InetAddress remoteHost = thisUser.getRemoteHost();
  -
  -            if (remoteHost != null) {
  -                retVal = remoteHost.getHostAddress();
  -            }
  -            break;
  +                if (retVal == null) {
  +                    retVal = "";
  +                }
  +                break;
  +            
  +            case 1:
  +                long loginTime = thisUser.getLoginTime();
  +                if (loginTime > 0) {
  +                    retVal = DATE_FMT.format(new Date(loginTime));
  +                }
  +                break;
  +            
  +            case 2:
  +                long accessTime = thisUser.getLastAccessTime();
  +                if (accessTime > 0) {
  +                    retVal = DATE_FMT.format(new Date(accessTime));
  +                }
  +                break;
  +                
  +            case 3:
  +                InetAddress remoteHost = thisUser.getClientAddress();
  +                if(remoteHost != null) {
  +                    retVal = remoteHost.getHostAddress();
  +                }
  +                break;   
           }
  -
           return retVal;
       }
  -
  -    /**
  -     * Get user at an index.
  -     */
  -    public synchronized FtpUser getUser(int index) {
  -
  -        if ((index < 0) || (index >= mConnectedUserList.size())) {
  -            return null;
  -        }
  -
  -        return (FtpUser) mConnectedUserList.get(index);
  -    }
  -
  +     
  +     
       ///////////////////////////  Observer Methods ///////////////////////////
  -
       /**
        * Add a new user
        */
  -    public synchronized void newConnection(String sessId) throws RemoteException {
  -
  -        if (sessId == null) {
  -            return;
  -        }
  -
  -        FtpUser thisUser = mUserHandler.getConnectedUser(sessId);
  -
  +    public void newConnection(final FtpUser thisUser) {
           if (thisUser == null) {
               return;
           }
  +        
  +        int sz = -1;
  +        synchronized(mUserList) {
  +            mUserList.add(thisUser);
  +            sz = mUserList.size();
  +        }
   
  -        mConnectedUserList.add(thisUser);
  -
  -        int sz = mConnectedUserList.size();
  -
  -        fireTableRowsInserted(sz, sz);
  -    }
  -
  +        if (sz != -1) {
  +            fireTableRowsInserted(sz, sz);
  +        }
  +    } 
  +     
  +    
       /**
        * Close .
        */
  -    public synchronized void closeConnection(String sessionId) {
  -
  -        if (sessionId == null) {
  +    public void removeConnection(final FtpUser user) {
  +        if (user == null) {
               return;
           }
  -
  +    
           int index = -1;
  -
  -        for (int i = 0; i < mConnectedUserList.size(); i++) {
  -            FtpUser currUser = (FtpUser) mConnectedUserList.get(i);
  -            String currSessId = currUser.getSessionId();
  -
  -            if (currSessId.equals(sessionId)) {
  -                index = i;
  -
  -                break;
  +        synchronized(mUserList) {
  +            index = mUserList.indexOf(user);
  +            if (index != -1) {
  +                mUserList.remove(index);
               }
           }
  -
  +        
           if (index != -1) {
  -            mConnectedUserList.remove(index);
               fireTableRowsDeleted(index, index);
           }
       }
  -
  +     
       /**
        * Existing connected user update notification.
        */
  -    public synchronized void updateConnection(String sessId) throws RemoteException {
  -
  -        if (sessId == null) {
  -            return;
  -        }
  -
  -        FtpUser thisUser = mUserHandler.getConnectedUser(sessId);
  -
  -        if (thisUser == null) {
  +    public void updateConnection(final FtpUser user) {
  +        if (user == null) {
               return;
           }
  -
  +        
           int index = -1;
  -
  -        for (int i = 0; i < mConnectedUserList.size(); i++) {
  -            FtpUser currUser = (FtpUser) mConnectedUserList.get(i);
  -
  -            if (currUser.getSessionId().equals(sessId)) {
  -                index = i;
  -
  -                break;
  +        synchronized(mUserList) {
  +            index = mUserList.indexOf(user);
  +            if (index != -1) {
  +                mUserList.set(index, user);
               }
           }
  -
  +        
           if (index != -1) {
  -            mConnectedUserList.set(index, thisUser);
               fireTableRowsUpdated(index, index);
           }
  -    }
  -
  +    } 
  +    
  +    
       /**
        * Reload table model
        */
  -    public synchronized void reload() throws RemoteException {
  -
  -        mConnectedUserList = mUserHandler.getAllConnectedUsers();
  -
  +    public void reload() throws RemoteException {
  +        synchronized(mUserList) {
  +            mUserList.clear();
  +            mUserList.addAll(mConService.getAllUsers());
  +        }
           fireTableDataChanged();
  -    }
  -
  +    } 
  +    
  +    
       /**
        * Close the resource
        */
       public void close() {
  -
  -        try {
  -            mUserHandler.setObserver(null);
  -            mConnectedUserList.clear();
  -        } catch (Exception ex) {}
  -    }
  -}
  +        mObserver.close();
  +        mUserList.clear();
  +    } 
  +     
  +}    
  \ No newline at end of file
  
  
  
  1.7       +49 -67    jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpIpPanel.java
  
  Index: FtpIpPanel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpIpPanel.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FtpIpPanel.java	14 Dec 2001 01:22:03 -0000	1.6
  +++ FtpIpPanel.java	6 Mar 2002 13:53:20 -0000	1.7
  @@ -1,4 +1,3 @@
  -
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -6,139 +5,122 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    */
  -package org.apache.avalon.ftpserver.gui;
  -
   
  +package org.apache.avalon.ftpserver.gui;
   
   import java.util.Iterator;
   import java.util.StringTokenizer;
  -
  -import java.rmi.RemoteException;
  -
   import java.awt.*;
   import java.awt.event.*;
  -
   import javax.swing.*;
   import javax.swing.border.*;
  -
  -import org.apache.avalon.ftpserver.interfaces.RemoteIpRestrictor;
  -
  +import org.apache.avalon.ftpserver.remote.interfaces.IpRestrictorInterface;
   
   /**
    * Ip restrictor panel.
    *
    * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
    */
  -public class FtpIpPanel extends JPanel {
  -
  +public
  +class FtpIpPanel extends JPanel {
  +    
       private JTextArea mjIpTxt;
  -    private RemoteIpRestrictor mRestrictor;
  +    private IpRestrictorInterface mRestrictor;    
       private CommonHandler mCommonHandler;
  -
  +    private FtpIpPanel mSelf;
  +    
       /**
        * Instantiate IP restrictor panel
        */
  -    public FtpIpPanel(CommonHandler commonHandler) throws RemoteException {
  -
  +    public FtpIpPanel(CommonHandler commonHandler) {
           mCommonHandler = commonHandler;
  -        mRestrictor = mCommonHandler.getConfig().getRemoteIpRestrictor();
  -
  +        mRestrictor = mCommonHandler.getIpRestrictor();
           initComponents();
           refresh();
       }
  -
  +    
       /**
        * Initialize UI components
        */
       private void initComponents() {
  -
           setLayout(new BorderLayout());
  -
  +        
           JLabel headerLab = new JLabel("IP Restriction");
  -
           headerLab.setHorizontalAlignment(JLabel.CENTER);
           headerLab.setForeground(Color.black);
           add(headerLab, BorderLayout.NORTH);
  -
  +        
           mjIpTxt = new JTextArea(18, 15);
  -
  -        JScrollPane txtPane = new JScrollPane(mjIpTxt, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
  -                                              JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  -
  +        JScrollPane txtPane = new JScrollPane(mjIpTxt, 
  +                    JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
  +                    JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
           add(txtPane, BorderLayout.CENTER);
  -
  +        
           // buttons
           JPanel btnPane = new JPanel();
  -
           btnPane.setLayout(new FlowLayout(FlowLayout.CENTER));
  -
  +        
           JButton jSaveBtn = new JButton("Save");
  -
           btnPane.add(jSaveBtn);
  -
  -        JButton jRefreshBtn = new JButton("Refresh");
  -
  -        btnPane.add(jRefreshBtn);
  +        
  +        JButton jResetBtn = new JButton("Reset");
  +        btnPane.add(jResetBtn);
  +        
           add(btnPane, BorderLayout.SOUTH);
  -
  +        
           // event handlers
           jSaveBtn.addActionListener(new ActionListener() {
  -
  -            public void actionPerformed(ActionEvent evt) {
  +             public void actionPerformed(ActionEvent evt) {
                   save();
  -            }
  +             }
           });
  -        jRefreshBtn.addActionListener(new ActionListener() {
  -
  -            public void actionPerformed(ActionEvent evt) {
  +        
  +        jResetBtn.addActionListener(new ActionListener() {
  +             public void actionPerformed(ActionEvent evt) {
                   refresh();
  -            }
  +             }
           });
       }
  -
  +     
       /**
        * Save IP data
        */
       public void save() {
  -
  -        if (mRestrictor != null) {
  +        if(mRestrictor != null) {
               try {
                   mRestrictor.clear();
  -
                   StringTokenizer st = new StringTokenizer(mjIpTxt.getText(), "\r\n");
  -
  -                while (st.hasMoreTokens()) {
  +                while(st.hasMoreTokens()) {
                       mRestrictor.addEntry(st.nextToken());
                   }
  -
                   mRestrictor.save();
  -            } catch (Exception ex) {
  +            }
  +            catch(Exception ex) {
                   mCommonHandler.handleException(ex);
               }
           }
       }
  -
  +    
       /**
        * Refresh table data
        */
       private void refresh() {
  -
  -        try {
  -            mjIpTxt.setText("");
  -
  -            Iterator ipRestrictorIt = mRestrictor.getAllEntries().iterator();
  -
  -            while (ipRestrictorIt.hasNext()) {
  -                mjIpTxt.append(ipRestrictorIt.next().toString());
  -                mjIpTxt.append("\n");
  -            }
  -        } catch (RemoteException ex) {
  -            mCommonHandler.handleException(ex);
  +    	try {
  +	        mjIpTxt.setText("");
  +	        Iterator ipRestrictorIt = mRestrictor.getAllEntries().iterator();
  +	        while(ipRestrictorIt.hasNext()) {
  +	            mjIpTxt.append(ipRestrictorIt.next().toString());
  +	            mjIpTxt.append("\n");
  +	        }
  +    	}
  +        catch(Exception ex) {
  +        	mCommonHandler.handleException(ex);
           }
       }
  -
  +    
       /**
        * Close resource
        */
  -    public void close() {}
  -}
  +    public void close() {
  +    } 
  +}    
  
  
  
  1.7       +86 -67    jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpRootPanel.java
  
  Index: FtpRootPanel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpRootPanel.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FtpRootPanel.java	14 Dec 2001 01:22:03 -0000	1.6
  +++ FtpRootPanel.java	6 Mar 2002 13:53:20 -0000	1.7
  @@ -1,4 +1,3 @@
  -
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -6,161 +5,181 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    */
  -package org.apache.avalon.ftpserver.gui;
  -
  -
  -
  -import java.rmi.*;
  -
  -import java.util.*;
   
  -import java.io.*;
  +package org.apache.avalon.ftpserver.gui;
   
  +import java.rmi.RemoteException;
   import java.awt.*;
   import java.awt.event.*;
  -
   import javax.swing.*;
   
  -import org.apache.avalon.ftpserver.interfaces.*;
  -
   
   /**
  - * FTP user interface root panel. We can stop
  - * the server, view comfig parameters  using this panel.
  + * FTP user interface root panel. We can view comfig parameters  
  + * using this panel.
    *
    * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
    */
  -public class FtpRootPanel extends JPanel {
  -
  +public 
  +class FtpRootPanel extends JPanel {
  +    
       private JTextField mjHostTxt = null;
  -    private JTable mjCfgTbl = null;
  -    private FtpUserPanel mUserPane = null;
  +    private JTable mjCfgTbl      = null;
  +    
  +    private FtpUserPanel mUserPane             = null; 
       private FtpConnectionPanel mConnectionPane = null;
  -    private FtpIpPanel mIpPane = null;
  -    private FtpStatisticsPanel mStatPane = null;
  -    private FtpRootPanel mSelf = null;
  +    private FtpIpPanel mIpPane                 = null;      
  +    private FtpStatisticsPanel mStatPane       = null;
  +    private FtpFilePanel mUploadPane           = null;
  +    private FtpFilePanel mDownloadPane         = null;
  +    private FtpFilePanel mDeletePane           = null;        
  +    private FtpAboutPanel mAboutPanel          = null;
  +    
       private CommonHandler mCommonHandler = null;
  -
  -    /**
  -     * Creates new panel for root.
  +    
  +    
  +    /** 
  +     * Creates new panel for root. 
        */
       public FtpRootPanel(CommonHandler commonHandler) throws RemoteException {
  -
           mCommonHandler = commonHandler;
  -
  -        initComponents();
  +        initComponents ();
       }
  -
  -    /**
  +    
  +    /** 
        * This method is called from within the constructor to
        * initialize the form.
        */
       private void initComponents() throws RemoteException {
  -
  +        
           setLayout(new BorderLayout());
  -
  +        
           // top panel
           JPanel topPane = new JPanel();
  -
           topPane.setLayout(new GridBagLayout());
  -
           GridBagConstraints gc;
  +        
           JLabel hostLab = new JLabel("Remote Host");
  -
           hostLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 0;
           gc.insets = new Insets(0, 0, 0, 10);
  -
           topPane.add(hostLab, gc);
  -
  +        
           mjHostTxt = new JTextField();
  -
           mjHostTxt.setColumns(15);
           mjHostTxt.setEditable(false);
           mjHostTxt.setText(mCommonHandler.getConfig().getServerAddress().getHostAddress());
  -
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 0;
           gc.gridwidth = 1;
           gc.insets = new Insets(0, 0, 0, 10);
  -
           topPane.add(mjHostTxt, gc);
  -
  +        
           JLabel headerLab = new JLabel("Configuration Parameters");
  -
           headerLab.setHorizontalAlignment(JLabel.CENTER);
           headerLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 1;
           gc.gridwidth = 2;
           gc.insets = new Insets(30, 0, 0, 0);
  -
           topPane.add(headerLab, gc);
           add(topPane, BorderLayout.NORTH);
  -
  +        
  +        
           // bottom panel - display config parameters
           ConfigTableModel cfgModel = new ConfigTableModel(mCommonHandler);
  -
           mjCfgTbl = new JTable(cfgModel);
  -
           mjCfgTbl.setPreferredScrollableViewportSize(new Dimension(420, 200));
           mjCfgTbl.setColumnSelectionAllowed(false);
  -
  -        JScrollPane bottomPane = new JScrollPane(mjCfgTbl,
  -                                                 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
  -                                                 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  -
  +        JScrollPane bottomPane = new JScrollPane(mjCfgTbl, 
  +                                    JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
  +                                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
           add(bottomPane, BorderLayout.CENTER);
  -
  +        
  +        
           // create other panels
  -        mUserPane = new FtpUserPanel(mCommonHandler);
  +        mUserPane       = new FtpUserPanel(mCommonHandler);
           mConnectionPane = new FtpConnectionPanel(mCommonHandler);
  -        mIpPane = new FtpIpPanel(mCommonHandler);
  -        mStatPane = new FtpStatisticsPanel(mCommonHandler);
  +        mIpPane         = new FtpIpPanel(mCommonHandler); 
  +        mStatPane       = new FtpStatisticsPanel(mCommonHandler); 
  +        mUploadPane     = new FtpFilePanel(mStatPane.getUploadModel(),   "Uploaded Files");
  +        mDownloadPane   = new FtpFilePanel(mStatPane.getDownloadModel(), "Downloaded Files");
  +        mDeletePane     = new FtpFilePanel(mStatPane.getDeleteModel(),   "Deleted Files");
  +        mAboutPanel     = new FtpAboutPanel();
       }
  -
  +    
       /**
        * Get user panel.
        */
       public JPanel getUserPanel() {
  -        return mUserPane;
  -    }
  -
  +         return mUserPane; 
  +    } 
  +    
       /**
        * Get login panel.
        */
       public JPanel getConnectionPanel() {
           return mConnectionPane;
       }
  -
  +     
       /**
        * Get IP panel.
        */
       public JPanel getIpPanel() {
           return mIpPane;
       }
  -
  +    
       /**
        * Get statistics panel
        */
       public JPanel getStatisticsPanel() {
  -        return mStatPane;
  +         return mStatPane;
  +    } 
  +     
  +    /**
  +     * Get uploaded file panel
  +     */ 
  +    public JPanel getUploadPanel() {
  +        return mUploadPane;
  +    } 
  +     
  +    /**
  +     * Get downloaded file panel
  +     */ 
  +    public JPanel getDownloadPanel() {
  +        return mDownloadPane;
  +    } 
  +     
  +    /**
  +     * Get deleted file panel
  +     */ 
  +    public JPanel getDeletePanel() {
  +        return mDeletePane;
  +    } 
  +    
  +    /**
  +     * Get ftp server about panel.
  +     */ 
  +    public JPanel getAboutPanel() {
  +        return mAboutPanel;
       }
  -
  +     
       /**
        * Close the resources.
        */
       public void close() {
  -
           mStatPane.close();
           mConnectionPane.close();
           mUserPane.close();
           mIpPane.close();
  -    }
  -}
  +        mUploadPane.close();
  +        mDownloadPane.close();
  +        mDeletePane.close();
  +        mAboutPanel.close();
  +    } 
  +    
  +}
  \ No newline at end of file
  
  
  
  1.8       +214 -238  jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpStatisticsPanel.java
  
  Index: FtpStatisticsPanel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpStatisticsPanel.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FtpStatisticsPanel.java	14 Dec 2001 01:22:03 -0000	1.7
  +++ FtpStatisticsPanel.java	6 Mar 2002 13:53:20 -0000	1.8
  @@ -1,4 +1,3 @@
  -
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -6,550 +5,527 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    */
  -package org.apache.avalon.ftpserver.gui;
  -
   
  +package org.apache.avalon.ftpserver.gui;
   
   import java.rmi.RemoteException;
  -import java.rmi.server.UnicastRemoteObject;
  -
   import java.text.SimpleDateFormat;
  -
   import java.awt.*;
  -import java.awt.event.ActionListener;
  -import java.awt.event.ActionEvent;
  -
  -import org.apache.avalon.ftpserver.interfaces.FtpStatisticsListener;
  -import org.apache.avalon.ftpserver.interfaces.FtpStatistics;
  -import org.apache.avalon.ftpserver.interfaces.RemoteFtpStatistics;
  -
  +import java.awt.event.*;
   import javax.swing.*;
  -
  +import org.apache.avalon.ftpserver.FtpUser;
  +import org.apache.avalon.ftpserver.remote.interfaces.FtpFileListener;
  +import org.apache.avalon.ftpserver.remote.interfaces.FtpStatisticsListener;
  +import org.apache.avalon.ftpserver.remote.interfaces.FtpStatisticsInterface;
  +import org.apache.avalon.ftpserver.gui.remote.FtpFileListenerAdapter;
  +import org.apache.avalon.ftpserver.gui.remote.FtpStatisticsListenerAdapter;
   
   /**
    * Ftp server global statistics panel. It listenes to the global
    * statistics changes.
  - *
  + * 
    * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
    */
  -public class FtpStatisticsPanel extends JPanel implements FtpStatisticsListener {
  +public
  +class FtpStatisticsPanel extends JPanel 
  +                         implements FtpStatisticsListener,
  +                                    FtpFileListener {                    
   
  -    private final static SimpleDateFormat DATE_FMT = new SimpleDateFormat("dd,MMM,yyyy HH:mm");
  +    private final static SimpleDateFormat DATE_FMT = new SimpleDateFormat("MM/dd HH:mm:ss");
  +                
       private JTextField mjStartTimeTxt;
  +    
       private JTextField mjUploadNbrTxt;
       private JTextField mjDownloadNbrTxt;
       private JTextField mjDeleteNbrTxt;
  +    
       private JTextField mjUploadBytesTxt;
       private JTextField mjDownloadBytesTxt;
  +    
       private JTextField mjLoginNbrTxt;
       private JTextField mjAnonLoginNbrTxt;
       private JTextField mjConNbrTxt;
  +    
       private JTextField mjTotalLoginNbrTxt;
       private JTextField mjTotalAnonLoginNbrTxt;
       private JTextField mjTotalConNbrTxt;
  +    
  +    private FtpFileTableModel mUploadModel;
  +    private FtpFileTableModel mDownloadModel;
  +    private FtpFileTableModel mDeleteModel;
  +        
       private CommonHandler mCommonHandler;
  -    private RemoteFtpStatistics mStat;
  -
  -    /**
  -     * Creates new panel to display ftp global statistics.
  +    private FtpStatisticsInterface mStat;   
  +    
  +    private FtpFileListenerAdapter mFileListener;
  +    private FtpStatisticsListenerAdapter mListener;
  +    
  +    /** 
  +     * Creates new panel to display ftp global statistics. 
        */
       public FtpStatisticsPanel(CommonHandler commonHandler) throws RemoteException {
  -
           mCommonHandler = commonHandler;
  -
  -        UnicastRemoteObject.exportObject(this);
  -
  -        mStat = mCommonHandler.getConfig().getStatistics();
  -
  -        mStat.setListener(this);
  +        mStat = mCommonHandler.getStatistics();
  +                
  +        mUploadModel = new FtpFileTableModel();
  +        mDownloadModel = new FtpFileTableModel();
  +        mDeleteModel = new FtpFileTableModel();
           initComponents();
  -
  -        try {
  -            mjStartTimeTxt.setText(DATE_FMT.format(mStat.getStartTime()));
  -        } catch (Exception ex) {}
  -
  +        
  +        mFileListener = new FtpFileListenerAdapter(mStat, this);        
  +        mListener = new FtpStatisticsListenerAdapter(mStat, this);
  +        
           reload();
  +        mjStartTimeTxt.setText(DATE_FMT.format(mStat.getStartTime()));
       }
   
  -    /**
  +    /** 
        * This method is called from within the constructor to
        * initialize the panel.
        */
       private void initComponents() {
  -
  +        setLayout(new BorderLayout());
  +        
  +        JPanel topPane = new JPanel();
           GridBagConstraints gc;
  -
  -        setLayout(new GridBagLayout());
  -
  +        topPane.setLayout(new GridBagLayout());
  +    
           // start time
           JLabel jStartTimeLab = new JLabel("Start Time");
  -
           jStartTimeLab.setHorizontalAlignment(JLabel.RIGHT);
           jStartTimeLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 0;
           gc.gridwidth = 1;
           gc.anchor = GridBagConstraints.EAST;
  -        gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(jStartTimeLab, gc);
  -
  +        gc.insets = new Insets(15, 0, 0, 5);
  +        topPane.add(jStartTimeLab, gc);
  +         
           mjStartTimeTxt = new JTextField();
  -
           mjStartTimeTxt.setColumns(15);
           mjStartTimeTxt.setEditable(false);
  -
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 0;
           gc.gridwidth = 2;
           gc.anchor = GridBagConstraints.WEST;
  -        gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(mjStartTimeTxt, gc);
  -
  +        gc.insets = new Insets(15, 0, 0, 5);
  +        topPane.add(mjStartTimeTxt, gc);
  +    
           // number of uploads
           JLabel jUploadNbrLab = new JLabel("Number of uploads");
  -
           jUploadNbrLab.setHorizontalAlignment(JLabel.RIGHT);
           jUploadNbrLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 1;
           gc.gridwidth = 1;
           gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(jUploadNbrLab, gc);
  -
  +        topPane.add(jUploadNbrLab, gc);        
  +    
           mjUploadNbrTxt = new JTextField();
  -
           mjUploadNbrTxt.setColumns(6);
           mjUploadNbrTxt.setEditable(false);
  -
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 1;
           gc.gridwidth = 2;
           gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(mjUploadNbrTxt, gc);
  -
  +        topPane.add(mjUploadNbrTxt, gc);
  +    
           // number of downloads
           JLabel jDownloadNbrLab = new JLabel("Number of downloads");
  -
           jDownloadNbrLab.setHorizontalAlignment(JLabel.RIGHT);
           jDownloadNbrLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 2;
           gc.gridwidth = 1;
           gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(jDownloadNbrLab, gc);
  -
  +        topPane.add(jDownloadNbrLab, gc);
  +    
           mjDownloadNbrTxt = new JTextField();
  -
           mjDownloadNbrTxt.setColumns(6);
           mjDownloadNbrTxt.setEditable(false);
  -
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 2;
           gc.gridwidth = 2;
           gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(mjDownloadNbrTxt, gc);
  -
  +        topPane.add(mjDownloadNbrTxt, gc);
  +    
           // number of downloads
           JLabel jDeleteNbrLab = new JLabel("Number of deletes");
  -
           jDeleteNbrLab.setHorizontalAlignment(JLabel.RIGHT);
           jDeleteNbrLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 3;
           gc.gridwidth = 1;
           gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(jDeleteNbrLab, gc);
  -
  +        topPane.add(jDeleteNbrLab, gc);
  +    
           mjDeleteNbrTxt = new JTextField();
  -
           mjDeleteNbrTxt.setColumns(6);
           mjDeleteNbrTxt.setEditable(false);
  -
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 3;
           gc.gridwidth = 2;
           gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(mjDeleteNbrTxt, gc);
  -
  +        topPane.add(mjDeleteNbrTxt, gc);        
  +    
           // number of uploaded bytes
           JLabel jUploadBytesLab = new JLabel("Uploaded bytes");
  -
           jUploadBytesLab.setHorizontalAlignment(JLabel.RIGHT);
           jUploadBytesLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 4;
           gc.gridwidth = 1;
           gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(jUploadBytesLab, gc);
  -
  +        topPane.add(jUploadBytesLab, gc);
  +    
           mjUploadBytesTxt = new JTextField();
  -
           mjUploadBytesTxt.setColumns(15);
           mjUploadBytesTxt.setEditable(false);
  -
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 4;
           gc.gridwidth = 2;
           gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(mjUploadBytesTxt, gc);
  -
  +        topPane.add(mjUploadBytesTxt, gc);
  +    
           // number of uploaded bytes
           JLabel jDownloadBytesLab = new JLabel("Downloaded bytes");
  -
           jDownloadBytesLab.setHorizontalAlignment(JLabel.RIGHT);
           jDownloadBytesLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 5;
           gc.gridwidth = 1;
           gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(jDownloadBytesLab, gc);
  -
  +        topPane.add(jDownloadBytesLab, gc);
  +    
           mjDownloadBytesTxt = new JTextField();
  -
           mjDownloadBytesTxt.setColumns(15);
  -        mjDownloadBytesTxt.setEditable(false);
  -
  +        mjDownloadBytesTxt.setEditable(false); 
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 5;
           gc.gridwidth = 2;
           gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(mjDownloadBytesTxt, gc);
  -
  +        topPane.add(mjDownloadBytesTxt, gc);
  +    
           // number of current logins
           JLabel jLoginNbrLab = new JLabel("Current logins");
  -
           jLoginNbrLab.setHorizontalAlignment(JLabel.RIGHT);
           jLoginNbrLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 6;
           gc.gridwidth = 1;
           gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(jLoginNbrLab, gc);
  -
  +        topPane.add(jLoginNbrLab, gc);
  +    
           mjLoginNbrTxt = new JTextField();
  -
           mjLoginNbrTxt.setColumns(6);
           mjLoginNbrTxt.setEditable(false);
  -
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 6;
           gc.gridwidth = 2;
           gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(mjLoginNbrTxt, gc);
  -
  +        topPane.add(mjLoginNbrTxt, gc);
  +    
           // number of total logins
           JLabel jTotalLoginNbrLab = new JLabel("Total logins");
  -
           jTotalLoginNbrLab.setHorizontalAlignment(JLabel.RIGHT);
           jTotalLoginNbrLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 7;
           gc.gridwidth = 1;
           gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(jTotalLoginNbrLab, gc);
  -
  +        topPane.add(jTotalLoginNbrLab, gc);
  +    
           mjTotalLoginNbrTxt = new JTextField();
  -
           mjTotalLoginNbrTxt.setColumns(6);
           mjTotalLoginNbrTxt.setEditable(false);
  -
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 7;
           gc.gridwidth = 2;
           gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(mjTotalLoginNbrTxt, gc);
  -
  +        topPane.add(mjTotalLoginNbrTxt, gc);
  +    
           // number of current anonymous logins
           JLabel jAnonLoginNbrLab = new JLabel("Current anonymous logins");
  -
           jAnonLoginNbrLab.setHorizontalAlignment(JLabel.RIGHT);
           jAnonLoginNbrLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 8;
           gc.gridwidth = 1;
           gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(jAnonLoginNbrLab, gc);
  -
  +        topPane.add(jAnonLoginNbrLab, gc);
  +    
           mjAnonLoginNbrTxt = new JTextField();
  -
           mjAnonLoginNbrTxt.setColumns(6);
           mjAnonLoginNbrTxt.setEditable(false);
  -
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 8;
           gc.gridwidth = 2;
           gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(mjAnonLoginNbrTxt, gc);
  -
  +        topPane.add(mjAnonLoginNbrTxt, gc);  
  +    
           // number of total anonymous logins
           JLabel jTotalAnonLoginNbrLab = new JLabel("Total anonymous logins");
  -
           jTotalAnonLoginNbrLab.setHorizontalAlignment(JLabel.RIGHT);
           jTotalAnonLoginNbrLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 9;
           gc.gridwidth = 1;
           gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(jTotalAnonLoginNbrLab, gc);
  -
  +        topPane.add(jTotalAnonLoginNbrLab, gc);
  +    
           mjTotalAnonLoginNbrTxt = new JTextField();
  -
           mjTotalAnonLoginNbrTxt.setColumns(6);
           mjTotalAnonLoginNbrTxt.setEditable(false);
  -
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 9;
           gc.gridwidth = 2;
           gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(mjTotalAnonLoginNbrTxt, gc);
  -
  +        topPane.add(mjTotalAnonLoginNbrTxt, gc);
  +    
           // number of current connections
           JLabel jConNbrLab = new JLabel("Current connections");
  -
           jConNbrLab.setHorizontalAlignment(JLabel.RIGHT);
           jConNbrLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 10;
           gc.gridwidth = 1;
           gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(jConNbrLab, gc);
  -
  +        topPane.add(jConNbrLab, gc);
  +    
           mjConNbrTxt = new JTextField();
  -
           mjConNbrTxt.setColumns(6);
           mjConNbrTxt.setEditable(false);
  -
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 10;
           gc.gridwidth = 2;
           gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(mjConNbrTxt, gc);
  -
  +        topPane.add(mjConNbrTxt, gc); 
  +    
           // number of current connections
           JLabel jTotalConNbrLab = new JLabel("Total connections");
  -
           jTotalConNbrLab.setHorizontalAlignment(JLabel.RIGHT);
           jTotalConNbrLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 11;
           gc.gridwidth = 1;
           gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(jTotalConNbrLab, gc);
  -
  +        topPane.add(jTotalConNbrLab, gc);
  +    
           mjTotalConNbrTxt = new JTextField();
  -
           mjTotalConNbrTxt.setColumns(6);
           mjTotalConNbrTxt.setEditable(false);
  -
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 11;
           gc.gridwidth = 2;
           gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 5);
  -
  -        add(mjTotalConNbrTxt, gc);
  -
  -        // reload button
  -        JButton reloadBtn = new JButton("Reload");
  -
  -        gc = new GridBagConstraints();
  -        gc.gridx = 1;
  -        gc.gridy = 12;
  -        gc.gridwidth = 1;
  -        gc.anchor = GridBagConstraints.WEST;
  -        gc.insets = new Insets(15, 0, 0, 5);
  -
  -        add(reloadBtn, gc);
  -        reloadBtn.addActionListener(new ActionListener() {
  -
  -            public void actionPerformed(ActionEvent evt) {
  +        topPane.add(mjTotalConNbrTxt, gc); 
  +        
  +        add(topPane, BorderLayout.CENTER);           
  +    
  +        JPanel bottomPane = new JPanel();
  +        bottomPane.setLayout(new FlowLayout(FlowLayout.CENTER));
  +        JButton jReloadButton = new JButton("Reload");
  +        jReloadButton.addActionListener(new ActionListener() {
  +             public void actionPerformed(ActionEvent evt) {
                   reload();
  -            }
  +             }
           });
  +        bottomPane.add(jReloadButton);
  +        
  +        add(bottomPane, BorderLayout.SOUTH);
       }
  -
  +    
  +    /**
  +     * Get upload file table model.
  +     */
  +    public FtpFileTableModel getUploadModel() {
  +        return mUploadModel;
  +    }
  +    
  +    /**
  +     * Get download file table model.
  +     */
  +    public FtpFileTableModel getDownloadModel() {
  +        return mDownloadModel;
  +    }
  +    
  +    /**
  +     * Get delete file table model.
  +     */
  +    public FtpFileTableModel getDeleteModel() {
  +        return mDeleteModel;
  +    }
  +    
  +    
       /**
        * Upload notification.
        */
       public void notifyUpload() {
  -
  -        if (mStat != null) {
  -            try {
  -                mjUploadNbrTxt.setText(String.valueOf(mStat.getFileUploadNbr()));
  -                mjUploadBytesTxt.setText(String.valueOf(mStat.getFileUploadSize()));
  -            } catch (Exception ex) {
  -                mCommonHandler.handleException(ex);
  -            }
  -        }
  +       try { 
  +           mjUploadNbrTxt.setText(String.valueOf(mStat.getFileUploadNbr()));
  +           mjUploadBytesTxt.setText(String.valueOf(mStat.getFileUploadSize()));
  +       }
  +       catch(Exception ex) {
  +           mCommonHandler.handleException(ex);
  +       }
       }
  -
  +    
       /**
        * Download notification.
        */
       public void notifyDownload() {
  -
  -        if (mStat != null) {
  -            try {
  -                mjDownloadNbrTxt.setText(String.valueOf(mStat.getFileDownloadNbr()));
  -                mjDownloadBytesTxt.setText(String.valueOf(mStat.getFileDownloadSize()));
  -            } catch (Exception ex) {
  -                mCommonHandler.handleException(ex);
  -            }
  -        }
  +       try {
  +           mjDownloadNbrTxt.setText(String.valueOf(mStat.getFileDownloadNbr()));
  +           mjDownloadBytesTxt.setText(String.valueOf(mStat.getFileDownloadSize()));
  +       }
  +       catch(Exception ex) {
  +           mCommonHandler.handleException(ex);
  +       }
       }
  -
  +    
  +    
       /**
        * Delete notification.
        */
       public void notifyDelete() {
  -
  -        if (mStat != null) {
  -            try {
  -                mjDeleteNbrTxt.setText(String.valueOf(mStat.getFileDeleteNbr()));
  -            } catch (Exception ex) {
  -                mCommonHandler.handleException(ex);
  -            }
  -        }
  +       try {
  +           mjDeleteNbrTxt.setText(String.valueOf(mStat.getFileDeleteNbr()));
  +       }
  +       catch(Exception ex) {
  +           mCommonHandler.handleException(ex);
  +       }
       }
  -
  +    
       /**
        * User login notification.
        */
       public void notifyLogin() {
  -
  -        if (mStat != null) {
  -            try {
  -                mjLoginNbrTxt.setText(String.valueOf(mStat.getLoginNbr()));
  -                mjAnonLoginNbrTxt.setText(String.valueOf(mStat.getAnonLoginNbr()));
  -                mjTotalLoginNbrTxt.setText(String.valueOf(mStat.getTotalLoginNbr()));
  -                mjTotalAnonLoginNbrTxt.setText(String.valueOf(mStat.getTotalAnonLoginNbr()));
  -            } catch (Exception ex) {
  -                mCommonHandler.handleException(ex);
  -            }
  -        }
  +       try {
  +           mjLoginNbrTxt.setText(String.valueOf(mStat.getLoginNbr()));
  +           mjAnonLoginNbrTxt.setText(String.valueOf(mStat.getAnonLoginNbr()));
  +           mjTotalLoginNbrTxt.setText(String.valueOf(mStat.getTotalLoginNbr()));
  +           mjTotalAnonLoginNbrTxt.setText(String.valueOf(mStat.getTotalAnonLoginNbr()));
  +       }
  +       catch(Exception ex) {
  +           mCommonHandler.handleException(ex);
  +       }
       }
  -
  +    
       /**
        * User logout notification.
        */
       public void notifyLogout() {
           notifyLogin();
  -    }
  -
  +    } 
  +     
       /**
        * Notify open/close connection
  -     */
  +     */ 
       public void notifyConnection() {
  -
  -        if (mStat != null) {
  -            try {
  -                mjConNbrTxt.setText(String.valueOf(mStat.getConnectionNbr()));
  -                mjTotalConNbrTxt.setText(String.valueOf(mStat.getTotalConnectionNbr()));
  -            } catch (Exception ex) {
  -                mCommonHandler.handleException(ex);
  -            }
  +       try {
  +           mjConNbrTxt.setText(String.valueOf(mStat.getConnectionNbr()));
  +           mjTotalConNbrTxt.setText(String.valueOf(mStat.getTotalConnectionNbr()));
  +       }
  +       catch(Exception ex) {
  +           mCommonHandler.handleException(ex);
  +       }
  +    } 
  +     
  +    /**
  +     * Notify file upload
  +     */ 
  +    public void notifyUpload(final String fl, final String sessId) {
  +        FtpUser user = mCommonHandler.getUser(sessId);
  +        if (user != null) {
  +            mUploadModel.newEntry(fl, user);
  +        }
  +    } 
  +    
  +    /**
  +     * Notify file download
  +     */ 
  +    public void notifyDownload(final String fl, final String sessId) {
  +        FtpUser user = mCommonHandler.getUser(sessId);
  +        if (user != null) {
  +            mDownloadModel.newEntry(fl, user);
           }
       }
  -
  +    
  +    /**
  +     * Notify file delete
  +     */ 
  +    public void notifyDelete(final String fl, final String sessId) {
  +        FtpUser user = mCommonHandler.getUser(sessId);
  +        if (user != null) {
  +            mDeleteModel.newEntry(fl, user);
  +        }
  +    }
  +     
  +     
       /**
        * Load all the global statistics parameters
        */
       public void reload() {
  -
           notifyUpload();
           notifyDownload();
           notifyDelete();
           notifyLogin();
           notifyConnection();
       }
  -
  +     
  +     
       /**
        * Close it.
        */
       public void close() {
  -
  -        try {
  -            mStat.setListener(null);
  -        } catch (RemoteException ex) {}
  -    }
  -}
  +        mListener.close();
  +        mFileListener.close(); 
  +    } 
  +    
  +}
  \ No newline at end of file
  
  
  
  1.7       +46 -34    jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpTreeModel.java
  
  Index: FtpTreeModel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpTreeModel.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FtpTreeModel.java	14 Dec 2001 01:22:03 -0000	1.6
  +++ FtpTreeModel.java	6 Mar 2002 13:53:20 -0000	1.7
  @@ -1,4 +1,3 @@
  -
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -6,19 +5,16 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    */
  -package org.apache.avalon.ftpserver.gui;
   
  +package org.apache.avalon.ftpserver.gui;
   
   
   import java.util.Vector;
  -
   import javax.swing.tree.TreePath;
   import javax.swing.tree.TreeModel;
   import javax.swing.event.TreeModelEvent;
   import javax.swing.event.TreeModelListener;
  -
  -import org.apache.avalon.ftpserver.interfaces.FtpAdmin;
  -
  +import org.apache.avalon.ftpserver.remote.interfaces.RemoteHandlerInterface;
   
   /**
    * This is FTP user interface tree structure. Currently it is very simple.
  @@ -26,22 +22,42 @@
    * <pre>
    *   FTP
    *    |
  - *    +-- Users (User management)
  + *    +-- User (User management)
    *    |
  - *    +-- Connection (Connection statistics)
  + *    +-- Connection (Connection monitor)
    *    |
  - *    +-- Ip (IP restrictions)
  + *    +-- IP (IP restriction)
  + *    |
  + *    +-- Upload (File upload statistics)
  + *    |
  + *    +-- Download (File download statistics)
  + *    |
  + *    +-- Delete (File deletion statistics)
    *    |
    *    +-- Statistics (Global statistics)
  + *    |
  + *    +-- About (Ftp server summary)
    * </pre>
    *
    * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
    */
  -public class FtpTreeModel implements TreeModel {
  -
  +public
  +class FtpTreeModel implements TreeModel {
  +    
       private Vector mListenrList;
  -    public final static String[] CHILDREN = { "Users", "Connection", "IP", "Statistics" };
  -
  +    
  +    public final static String[] CHILDREN = {
  +        "Users",
  +        "Connection",
  +        "IP",
  +        "Upload",
  +        "Download",
  +        "Delete",
  +        "Statistics",
  +        "About"    
  +    }; 
  +    
  +    
       /**
        * create this tree model
        */
  @@ -49,29 +65,28 @@
           mListenrList = new Vector();
       }
   
  +
       /**
        * get root object
        */
       public Object getRoot() {
  -        return FtpAdmin.DISPLAY_NAME;
  +        return RemoteHandlerInterface.DISPLAY_NAME;
       }
   
  -    /**
  +    /** 
        * get child object
        */
       public Object getChild(Object parent, int index) {
           return CHILDREN[index];
  -    }
  +    } 
   
       /**
        * get child count
        */
       public int getChildCount(Object parent) {
  -
  -        if (parent.equals(FtpAdmin.DISPLAY_NAME)) {
  +        if(parent.equals(RemoteHandlerInterface.DISPLAY_NAME)) {
               return CHILDREN.length;
           }
  -
           return 0;
       }
   
  @@ -79,31 +94,28 @@
        * is a leaf or node
        */
       public boolean isLeaf(Object node) {
  -        return !node.equals(FtpAdmin.DISPLAY_NAME);
  +       return !node.equals(RemoteHandlerInterface.DISPLAY_NAME);
       }
   
       /**
        * get child index
        */
       public int getIndexOfChild(Object parent, Object child) {
  -
  -        int childIdx = -1;
  -
  -        for (int i = 0; i < CHILDREN.length; i++) {
  -            if (CHILDREN[i].equals(child)) {
  -                childIdx = i;
  -
  -                break;
  -            }
  -        }
  -
  -        return childIdx;
  +       int childIdx = -1;
  +       for(int i=0; i<CHILDREN.length; i++) {
  +           if(CHILDREN[i].equals(child)) {
  +               childIdx = i;
  +               break;
  +           }
  +       }
  +       return childIdx;
       }
   
       /**
        * Object changed. In our case it is not possible - so ignore it.
        */
  -    public void valueForPathChanged(TreePath path, Object newValue) {}
  +    public void valueForPathChanged(TreePath path, Object newValue) {
  +    }
   
       /**
        * Add a listener
  @@ -118,4 +130,4 @@
       public void removeTreeModelListener(TreeModelListener l) {
           mListenrList.remove(l);
       }
  -}
  +}
  \ No newline at end of file
  
  
  
  1.10      +270 -292  jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpUserPanel.java
  
  Index: FtpUserPanel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpUserPanel.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- FtpUserPanel.java	14 Dec 2001 01:22:03 -0000	1.9
  +++ FtpUserPanel.java	6 Mar 2002 13:53:20 -0000	1.10
  @@ -1,4 +1,3 @@
  -
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -6,247 +5,242 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    */
  -package org.apache.avalon.ftpserver.gui;
  -
  -
   
  -import java.util.*;
  -
  -import java.io.*;
  -
  -import java.awt.*;
  -import java.awt.event.*;
  +package org.apache.avalon.ftpserver.gui;
   
  -import java.rmi.*;
  -import java.rmi.registry.*;
  +import java.util.Collections;
  +import java.util.Random;
  +import java.util.Iterator;
  +import java.util.List;
  +import java.awt.Color;
  +import java.awt.Insets;
  +import java.awt.FlowLayout;
  +import java.awt.GridBagLayout;
  +import java.awt.GridBagConstraints;
  +import java.awt.event.ActionEvent;
  +import java.awt.event.ActionListener;
   
   import javax.swing.*;
   import javax.swing.event.*;
  -
  -import org.apache.avalon.ftpserver.interfaces.UserHandler;
  -import org.apache.avalon.ftpserver.FtpUser;
  +import org.apache.avalon.ftpserver.usermanager.User;
  +import org.apache.avalon.ftpserver.remote.interfaces.UserManagerInterface;
   
   
   /**
    * Ftp server user admin panel. You can create, update,
    * delete user using this panel.
  - *
  + * 
    * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
    */
  -public class FtpUserPanel extends JPanel implements ActionListener {
  +public 
  +class FtpUserPanel extends JPanel 
  +                   implements ActionListener {                    
   
  +    private final static Random PASS_GEN = new Random(System.currentTimeMillis()); 
  +   
       private final static Object[] BYTE_RATES = {
  -        "No limit", new Integer(1200), new Integer(2400), new Integer(4800), new Integer(9600),
  -        new Integer(14400), new Integer(28800), new Integer(57600), new Integer(115200)
  -    };
  -    private final static Object[] IDLE_MINUTES = {
  -        "No limit", new Integer(1), new Integer(5), new Integer(15), new Integer(30),
  -        new Integer(60)
  +       "No limit",
  +       new Integer(1200),
  +       new Integer(2400),
  +       new Integer(4800),
  +       new Integer(9600),
  +       new Integer(14400),
  +       new Integer(28800),    
  +       new Integer(57600),
  +       new Integer(115200)    
  +    };                   
  +   
  +    private final static Object[] IDLE_SECONDS = {
  +       "No limit",
  +       new Integer(60),
  +       new Integer(300),
  +       new Integer(900),
  +       new Integer(1800),
  +       new Integer(3600)    
       };
  -    private UserHandler mUserHandler;
  +                   
  +    private UserManagerInterface mUserManager;
  +    
       private JComboBox mjUserLst;
       private JTextField mjNameTxt;
  +    
       private JPasswordField mjPasswordTxt;
       private JPasswordField mjRetypePasswordTxt;
       private JCheckBox mjPasswordChkBox;
  +    
       private JTextField mjDirectoryTxt;
       private JCheckBox mjEnabledChkBox;
       private JCheckBox mjWriteChkBox;
       private JComboBox mjIdleLst;
       private JComboBox mjUploadLst;
       private JComboBox mjDownloadLst;
  -    private JButton mjDeleteBtn;
  -    private JButton mjSaveBtn;
  +    
  +    private FtpUserPanel mSelf;
  +    
       private CommonHandler mCommonHandler;
  -
  -    /**
  -     * Creates new panel.
  +    
  +    /** 
  +     * Creates new panel. 
        */
  -    public FtpUserPanel(CommonHandler commonHandler) throws RemoteException {
  -
  +    public FtpUserPanel(CommonHandler commonHandler) {
           mCommonHandler = commonHandler;
  -        mUserHandler = mCommonHandler.getConfig().getUserHandler();
  -
  -        initComponents();
  -        refresh();
  +        mUserManager = mCommonHandler.getUserManager();
  +        initComponents ();
  +        refresh(); 
       }
   
  -    /**
  +    /** 
        * This method is called from within the constructor to
        * initialize the form.
        */
       private void initComponents() {
  -
           GridBagConstraints gc;
  -
           setLayout(new GridBagLayout());
  -
  +        
           // user list
           mjUserLst = new JComboBox();
  -
           mjUserLst.addActionListener(this);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 0;
           gc.gridwidth = 3;
  -        gc.insets = new Insets(5, 0, 0, 10);
  -
  +        gc.insets = new Insets(10, 0, 10, 10);
           add(mjUserLst, gc);
  -
  +        
           // user name
           JLabel jNameLab = new JLabel("Name");
  -
           jNameLab.setHorizontalAlignment(JLabel.RIGHT);
           jNameLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 1;
           gc.gridwidth = 1;
  -        gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  +        gc.anchor = GridBagConstraints.EAST;
           add(jNameLab, gc);
  -
  +         
           mjNameTxt = new JTextField();
  -
           mjNameTxt.setColumns(12);
  -
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 1;
           gc.gridwidth = 2;
  -        gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  +        gc.anchor = GridBagConstraints.WEST;
           add(mjNameTxt, gc);
  -
  +        
           // password
           JLabel jPasswordLab = new JLabel("Password");
  -
           jPasswordLab.setHorizontalAlignment(JLabel.RIGHT);
           jPasswordLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 2;
           gc.gridwidth = 1;
  -        gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  -        add(jPasswordLab, gc);
  -
  +        gc.anchor = GridBagConstraints.EAST;
  +        add(jPasswordLab, gc);        
  +        
           mjPasswordTxt = new JPasswordField();
  -
           mjPasswordTxt.setColumns(12);
  -
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 2;
           gc.gridwidth = 2;
  -        gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  +        gc.anchor = GridBagConstraints.WEST;
           add(mjPasswordTxt, gc);
   
  +        JButton jGeneratePassBtn = new JButton("Generate");
  +        jGeneratePassBtn.addActionListener(new ActionListener() {
  +           public void actionPerformed(ActionEvent evt) {
  +               generatePassword();
  +           }
  +        });
  +        gc = new GridBagConstraints();
  +        gc.gridx = 2;
  +        gc.gridy = 2;
  +        gc.gridwidth = 1;
  +        gc.insets = new Insets(5, 0, 0, 10);
  +        gc.anchor = GridBagConstraints.WEST;
  +        add(jGeneratePassBtn, gc);
  +        
           // retype password
           JLabel jRetypePasswordLab = new JLabel("Retype Password");
  -
           jRetypePasswordLab.setHorizontalAlignment(JLabel.RIGHT);
           jRetypePasswordLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 3;
           gc.gridwidth = 1;
  -        gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  +        gc.anchor = GridBagConstraints.EAST;
           add(jRetypePasswordLab, gc);
  -
  +        
           mjRetypePasswordTxt = new JPasswordField();
  -
           mjRetypePasswordTxt.setColumns(12);
  -
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 3;
           gc.gridwidth = 2;
  -        gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  +        gc.anchor = GridBagConstraints.WEST;
           add(mjRetypePasswordTxt, gc);
  -
  +        
           // set password
           JLabel jSetPasswordLab = new JLabel("Set Password");
  -
           jSetPasswordLab.setHorizontalAlignment(JLabel.RIGHT);
           jSetPasswordLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 4;
           gc.gridwidth = 1;
  -        gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  +        gc.anchor = GridBagConstraints.EAST;
           add(jSetPasswordLab, gc);
  -
  +        
           mjPasswordChkBox = new JCheckBox();
  -
           mjPasswordChkBox.setHorizontalTextPosition(SwingConstants.LEFT);
  -
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 4;
           gc.gridwidth = 2;
  -        gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  +        gc.anchor = GridBagConstraints.WEST;
           add(mjPasswordChkBox, gc);
   
           // root directory
           JLabel jDirectoryLab = new JLabel("Root Directory");
  -
           jDirectoryLab.setHorizontalAlignment(JLabel.RIGHT);
           jDirectoryLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 5;
           gc.gridwidth = 1;
           gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
           add(jDirectoryLab, gc);
  -
  +        
           mjDirectoryTxt = new JTextField();
  -
  -        mjDirectoryTxt.setColumns(18);
  -
  +        mjDirectoryTxt.setColumns(12);      
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 5;
           gc.gridwidth = 1;
           gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  -        add(mjDirectoryTxt, gc);
  -
  +        add(mjDirectoryTxt, gc); 
  +        
           // enable/disable
           JLabel jEnabledLab = new JLabel("Enabled");
  -
           jEnabledLab.setHorizontalAlignment(JLabel.RIGHT);
           jEnabledLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 6;
           gc.gridwidth = 1;
  -        gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  +        gc.anchor = GridBagConstraints.EAST;
           add(jEnabledLab, gc);
   
           mjEnabledChkBox = new JCheckBox();
  @@ -254,254 +248,230 @@
           gc.gridx = 1;
           gc.gridy = 6;
           gc.gridwidth = 2;
  -        gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  +        gc.anchor = GridBagConstraints.WEST;
           add(mjEnabledChkBox, gc);
  -
  +        
           // write permission
           JLabel jWritePermLab = new JLabel("Write Permission");
  -
           jWritePermLab.setHorizontalAlignment(JLabel.RIGHT);
           jWritePermLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 7;
           gc.gridwidth = 1;
  -        gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  +        gc.anchor = GridBagConstraints.EAST;
           add(jWritePermLab, gc);
  -
  +        
           mjWriteChkBox = new JCheckBox();
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 7;
           gc.gridwidth = 2;
  -        gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  +        gc.anchor = GridBagConstraints.WEST;
           add(mjWriteChkBox, gc);
  -
  +              
           // idle time
  -        JLabel jIdleLab = new JLabel("Max. Idle Time (minutes)");
  -
  +        JLabel jIdleLab = new JLabel("Max. Idle Time (seconds)");
           jIdleLab.setHorizontalAlignment(JLabel.RIGHT);
           jIdleLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 8;
           gc.gridwidth = 1;
  -        gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  +        gc.anchor = GridBagConstraints.EAST;
           add(jIdleLab, gc);
  -
  -        mjIdleLst = new JComboBox(IDLE_MINUTES);
  +        
  +        mjIdleLst = new JComboBox(IDLE_SECONDS);
  +        mjIdleLst.setEditable(true);
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 8;
           gc.gridwidth = 2;
  -        gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  +        gc.anchor = GridBagConstraints.WEST;
           add(mjIdleLst, gc);
  -
  +        
           JPanel btnPane = new JPanel();
  -
           btnPane.setLayout(new FlowLayout(FlowLayout.CENTER));
  -
  +        
           // user upload limit
           JLabel jUploadLab = new JLabel("Max. Upload (bytes/sec)");
  -
           jUploadLab.setHorizontalAlignment(JLabel.RIGHT);
           jUploadLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 9;
           gc.gridwidth = 1;
  -        gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  +        gc.anchor = GridBagConstraints.EAST;
           add(jUploadLab, gc);
  -
  +        
           mjUploadLst = new JComboBox(BYTE_RATES);
  +        mjUploadLst.setEditable(true);
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 9;
           gc.gridwidth = 2;
  -        gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  +        gc.anchor = GridBagConstraints.WEST;
           add(mjUploadLst, gc);
  -
  +        
           // user download limit
           JLabel jDownloadLab = new JLabel("Max. Download (bytes/sec)");
  -
           jDownloadLab.setHorizontalAlignment(JLabel.RIGHT);
           jDownloadLab.setForeground(Color.black);
  -
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 10;
           gc.gridwidth = 1;
  -        gc.anchor = GridBagConstraints.EAST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  +        gc.anchor = GridBagConstraints.EAST;
           add(jDownloadLab, gc);
  -
  +        
           mjDownloadLst = new JComboBox(BYTE_RATES);
  +        mjDownloadLst.setEditable(true);
           gc = new GridBagConstraints();
           gc.gridx = 1;
           gc.gridy = 10;
           gc.gridwidth = 2;
  -        gc.anchor = GridBagConstraints.WEST;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  +        gc.anchor = GridBagConstraints.WEST;
           add(mjDownloadLst, gc);
  -
  +        
           // save user
  -        mjSaveBtn = new JButton("Save");
  -
  -        mjSaveBtn.addActionListener(new ActionListener() {
  -
  -            public void actionPerformed(ActionEvent evt) {
  -                save(evt);
  -            }
  +        JButton jSaveBtn = new JButton("Save");
  +        jSaveBtn.addActionListener(new ActionListener() {
  +             public void actionPerformed(ActionEvent evt) {
  +                save();
  +             }
           });
  -        btnPane.add(mjSaveBtn);
  -
  +        btnPane.add(jSaveBtn);
  +        
           // delete user
  -        mjDeleteBtn = new JButton("Delete");
  -
  -        mjDeleteBtn.addActionListener(new ActionListener() {
  -
  -            public void actionPerformed(ActionEvent evt) {
  -                delete(evt);
  -            }
  +        JButton jDeleteBtn = new JButton("Delete");
  +        jDeleteBtn.addActionListener(new ActionListener() {
  +             public void actionPerformed(ActionEvent evt) {
  +                delete();
  +             }
           });
  -        btnPane.add(mjDeleteBtn);
  -
  +        btnPane.add(jDeleteBtn);
  +        
  +        // reload user data
  +        JButton jReloadBtn = new JButton("Reload");
  +        jReloadBtn.addActionListener(new ActionListener() {
  +             public void actionPerformed(ActionEvent evt) {
  +                refresh();
  +             }
  +        });
  +        btnPane.add(jReloadBtn);
  +        
           gc = new GridBagConstraints();
           gc.gridx = 0;
           gc.gridy = 11;
           gc.gridwidth = 3;
           gc.insets = new Insets(5, 0, 0, 10);
  -
  -        add(btnPane, gc);
  +        add(btnPane, gc);          
       }
  -
  +        
  +    
       /**
        * Save the user object
        */
  -    private void save(ActionEvent evt) {
  -
  +    private void save() {
  +        
           // check user name field
           String userName = mjNameTxt.getText().trim();
  -
  -        if (userName.equals("")) {
  -            GuiUtils.showErrorMessage(mCommonHandler.getTopComponent(),
  -                                      "Please enter an user name");
  -
  +        if(userName.equals("")) {
  +            GuiUtils.showErrorMessage(mCommonHandler.getTopComponent(), "Please enter an user name");
               return;
           }
  -
  +        
           try {
  -            FtpUser user = new FtpUser(null, null, null);
  -
  +            User user = new User();
               user.setName(userName);
  -
  -            if (setPassword(user)) {
  -                user.getVirtualDirectory()
  -                    .setRootDirectory(new File(mjDirectoryTxt.getText()).getCanonicalFile());
  -                user.setEnabled(mjEnabledChkBox.isSelected());
  -                user.getVirtualDirectory().setWritePermission(mjWriteChkBox.isSelected());
  -                user.setMaxIdleTime(getMaxIdleTime());
  -                user.setMaxUploadRate(getBytesTransferRate(mjUploadLst));
  -                user.setMaxDownloadRate(getBytesTransferRate(mjDownloadLst));
  -                mUserHandler.save(user);
  -                refresh();
  +            if(setPassword(user)) {
  +              user.getVirtualDirectory().setRootDirectory(mjDirectoryTxt.getText());
  +              user.setEnabled(mjEnabledChkBox.isSelected());
  +              user.getVirtualDirectory().setWritePermission(mjWriteChkBox.isSelected());
  +              user.setMaxIdleTime(getMaxIdleTime());
  +              user.setMaxUploadRate(getBytesTransferRate(mjUploadLst));
  +              user.setMaxDownloadRate(getBytesTransferRate(mjDownloadLst));
  +              mUserManager.save(user);
  +              refresh();
               }
  -        } catch (Exception ex) {
  +        }
  +        catch(Exception ex) {
               mCommonHandler.handleException(ex);
           }
       }
  -
  +    
  +    
       /**
        * Save the user object
        */
  -    private void delete(ActionEvent evt) {
  -
  +    private void delete() {
           Object selVal = mjUserLst.getSelectedItem();
  -
  -        if (selVal == null) {
  +        if(selVal == null) {
               return;
           }
  -
  +        
           String userName = selVal.toString();
  -        boolean bConf = GuiUtils.getConfirmation(mCommonHandler.getTopComponent(),
  -                                                 "Do you really want to delete user " + userName
  -                                                 + "?");
  -
  -        if (!bConf) {
  +        boolean bConf = GuiUtils.getConfirmation(mCommonHandler.getTopComponent(), "Do you really want to delete user " + userName + "?");
  +        if(!bConf) {
               return;
           }
  -
           try {
  -            mUserHandler.delete(userName);
  +            mUserManager.delete(userName);
               refresh();
  -        } catch (Exception ex) {
  +        }
  +        catch(Exception ex) {
               mCommonHandler.handleException(ex);
           }
       }
  -
  +    
       /**
        * Initialize user list.
        */
       private void refresh() {
  -
           try {
               mjUserLst.removeAllItems();
  -
  -            java.util.List allUsers = mUserHandler.getAllUserNames();
  -
  -            Collections.sort(allUsers);
  -
  -            for (Iterator userIt = allUsers.iterator(); userIt.hasNext(); ) {
  +            List allUsers = mUserManager.getAllUserNames();
  +            for(Iterator userIt = allUsers.iterator(); userIt.hasNext(); ) {
                   mjUserLst.addItem(userIt.next());
               }
  -        } catch (Exception ex) {
  +        }
  +        catch(Exception ex) {
               mCommonHandler.handleException(ex);
           }
       }
   
  +    
  +    
       /**
  -     * List selection changed.
  +     * List selection changed. 
        */
       public void actionPerformed(ActionEvent e) {
  -
           Object selVal = mjUserLst.getSelectedItem();
  -
           try {
  -            if (selVal != null) {
  +            if(selVal != null) {
                   String userName = selVal.toString();
  -                FtpUser thisUser = mUserHandler.getUserByName(userName);
  -
  +                User thisUser = mUserManager.getUserByName(userName);
                   populateFields(thisUser);
               }
  -        } catch (Exception ex) {
  +        }
  +        catch(Exception ex) {
               mCommonHandler.handleException(ex);
           }
  -    }
  -
  +    } 
  +    
       /**
        * Populate user data fields.
        */
  -    public void populateFields(FtpUser user) {
  -
  +    public void populateFields(User user) {
           mjNameTxt.setText(user.getName());
           mjPasswordTxt.setText("");
           mjRetypePasswordTxt.setText("");
  @@ -512,139 +482,147 @@
           setIdleTimeCombo(user.getMaxIdleTime());
           setByteRateCombo(mjUploadLst, user.getMaxUploadRate());
           setByteRateCombo(mjDownloadLst, user.getMaxDownloadRate());
  -
  -        // admin and anonymous users cannot be deleted
  -        if (user.getIsAnonymous() || user.getIsAdmin()) {
  -            mjDeleteBtn.setEnabled(false);
  -        } else {
  -            mjDeleteBtn.setEnabled(true);
  +    }
  +    
  +    /**
  +     * Generate random password.
  +     */
  +    private void generatePassword() {
  +        StringBuffer sb = new StringBuffer(8);
  +        for(int i=0; i<8; i++) {
  +            int charType = PASS_GEN.nextInt(3);
  +            switch (charType) {
  +            
  +                // number
  +                case 0:
  +                    sb.append( (char)('0' + PASS_GEN.nextInt(10)) );
  +                    break;
  +                
  +                // uppercase character    
  +                case 1:    
  +                    sb.append( (char)('A' + PASS_GEN.nextInt(26)) );
  +                    break;
  +                    
  +                // lowercase character
  +                case 2:
  +                    sb.append( (char)('a' + PASS_GEN.nextInt(26)) );
  +                    break;
  +            }
           }
  +        String password = sb.toString();
  +        GuiUtils.showInformationMessage(mSelf, "Generated password: " + password);
  +        mjPasswordTxt.setText(password);
  +        mjRetypePasswordTxt.setText(password);
  +        mjPasswordChkBox.setSelected(true);
       }
  -
  +    
  +    
       /**
        * Set password if necessary.
        */
  -    private boolean setPassword(FtpUser usr) {
  -
  +    private boolean setPassword(User usr) {
  +        
           try {
               String userName = usr.getName();
  -            boolean bNewUser = !mUserHandler.doesExist(userName);
  +            boolean bNewUser = !mUserManager.doesExist(userName);
               boolean bPassSet = mjPasswordChkBox.isSelected();
               String password = new String(mjPasswordTxt.getPassword());
  -            String repassword = new String(mjRetypePasswordTxt.getPassword());
  -
  -            usr.setPassword(null);
  -
  -            // anonymous user - password not required
  -            if (usr.getIsAnonymous()) {
  -                return true;
  -            }
  -
  -            // new user - no password - error
  -            if (bNewUser && (!bPassSet)) {
  -                GuiUtils.showErrorMessage(mCommonHandler.getTopComponent(),
  -                                          "New user - password required");
  -
  +            String repassword = new String(mjRetypePasswordTxt.getPassword()); 
  +        
  +            // new user
  +            if( bNewUser && (!bPassSet) && (!usr.getIsAnonymous()) ) {
  +                GuiUtils.showErrorMessage(mSelf, "New user - password required");
                   return false;
               }
  -
  -            // password set - two passwords are not same - error
  -            if (bPassSet && (!password.equals(repassword))) {
  -                GuiUtils.showErrorMessage(mCommonHandler.getTopComponent(),
  -                                          "Password entries are not equal");
  -
  +        
  +            // password set 
  +            if( bPassSet && (!password.equals(repassword)) && (!usr.getIsAnonymous()) ) {
  +                GuiUtils.showErrorMessage(mSelf, "Password entries are not equal");
                   return false;
               }
  -
  -            // password set
  -            if (bPassSet) {
  +        
  +            // set password if necessary
  +            if(bPassSet && (!usr.getIsAnonymous())) {
                   usr.setPassword(password);
               }
  -
  +            else {
  +                usr.setPassword(null);
  +            }
               return true;
  -        } catch (Exception ex) {
  +        }
  +        catch(Exception ex) {
               mCommonHandler.handleException(ex);
           }
  -
           return false;
  -    }
  -
  +    } 
  +    
       /**
        * Get max bytes/sec.
        */
       private int getBytesTransferRate(JComboBox byteLst) {
  -
           int rate = 0;
  -        int byteInd = byteLst.getSelectedIndex();
  -
  -        if (byteInd != 0) {
  -            rate = ((Integer) BYTE_RATES[byteInd]).intValue();
  +        Object selObj = byteLst.getSelectedItem();
  +        if (!selObj.equals(BYTE_RATES[0])) {
  +            try {
  +                rate = Integer.parseInt(selObj.toString());
  +            }
  +            catch(NumberFormatException ex) {
  +                GuiUtils.showErrorMessage(mSelf, ex.getMessage());
  +            }
           }
  -
  +        
           return rate;
       }
  -
  +     
       /**
        * Get max idle time in sec.
        */
       private int getMaxIdleTime() {
  -
           int sec = 0;
  -        int idleInd = mjIdleLst.getSelectedIndex();
  -
  -        if (idleInd != 0) {
  -            sec = ((Integer) IDLE_MINUTES[idleInd]).intValue() * 60;
  +        Object selObj = mjIdleLst.getSelectedItem();
  +        if (!selObj.equals(IDLE_SECONDS[0])) {
  +            try {
  +                sec = Integer.parseInt(selObj.toString());
  +            }
  +            catch(NumberFormatException ex) {
  +                GuiUtils.showErrorMessage(mSelf, ex.getMessage());
  +            }
           }
  -
  +        
           return sec;
       }
  -
  +    
       /**
        * Set byte transfer rate combo.
        */
       private void setByteRateCombo(JComboBox combo, int rate) {
  -
           int index = 0;
  -
  -        if (rate != 0) {
  +        if(rate != 0) {
               Integer currRate = new Integer(rate);
  -
  -            for (int i = 1; i < BYTE_RATES.length; i++) {
  -                if (BYTE_RATES[i].equals(currRate)) {
  +            for(int i=1; i<BYTE_RATES.length; i++) {
  +                if(BYTE_RATES[i].equals(currRate)) {
                       index = i;
  -
                       break;
                   }
               }
           }
  -
           combo.setSelectedIndex(index);
       }
  -
  +    
       /**
        * Set idle time combo.
        */
       private void setIdleTimeCombo(int idle) {
  -
  -        int index = 0;
  -
  -        if (idle != 0) {
  -            Integer currIdle = new Integer(idle / 60);
  -
  -            for (int i = 0; i < IDLE_MINUTES.length; i++) {
  -                if (IDLE_MINUTES[i].equals(currIdle)) {
  -                    index = i;
  -
  -                    break;
  -                }
  -            }
  +        Object selItem = new Integer(idle);
  +        if (idle == 0){
  +            selItem = IDLE_SECONDS[0];
           }
  -
  -        mjIdleLst.setSelectedIndex(index);
  +        mjIdleLst.setSelectedItem(selItem);
       }
  -
  +        
       /**
        * Close all resources.
        */
  -    public void close() {}
  -}
  +    public void close() {
  +    } 
  +}
  \ No newline at end of file
  
  
  
  1.6       +86 -63    jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/GuiUtils.java
  
  Index: GuiUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/GuiUtils.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- GuiUtils.java	14 Dec 2001 01:22:03 -0000	1.5
  +++ GuiUtils.java	6 Mar 2002 13:53:20 -0000	1.6
  @@ -1,4 +1,3 @@
  -
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -6,83 +5,109 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    */
  -package org.apache.avalon.ftpserver.gui;
  -
  -
  -
  -import java.util.*;
  -
  -import java.io.*;
   
  -import java.net.*;
  -
  -import java.awt.*;
  +package org.apache.avalon.ftpserver.gui;
   
  -import javax.swing.*;
  +import java.io.IOException;
  +import java.io.InputStream;
  +import java.io.ByteArrayOutputStream;
  +import java.awt.Component;
  +import java.awt.Dimension;
  +import java.awt.Toolkit;
  +import java.awt.Rectangle;
  +import javax.swing.JFileChooser;
  +import javax.swing.ImageIcon;
  +import javax.swing.JWindow;
  +import javax.swing.JPanel;
  +import javax.swing.JLabel;
  +import javax.swing.JOptionPane;
  +import javax.swing.SwingUtilities;
   
  +import org.apache.avalon.ftpserver.util.IoUtils;
   
   /**
    * This is the GUI utility class.
  - *
  + * 
    * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
    */
  -public class GuiUtils {
  +public
  +class GuiUtils {
   
  -    private static JFileChooser mDirChoose = null;
  -    private static JFileChooser mFileChoose = null;
  -    private static final GuiUtils SELF_REF = new GuiUtils();
  +    private static JFileChooser mDirChoose   = null;    
  +    private static JFileChooser mFileChoose  = null;
  +    
  +    private static final GuiUtils SELF_REF   = new GuiUtils();
   
       /**
        * Create image icon.
        */
  -    public static ImageIcon createImageIcon(String imgFile) {
  -
  -        URL imgUrl = SELF_REF.getClass().getClassLoader().getResource(imgFile);
  -
  -        if (imgUrl == null) {
  -            return null;
  +    public static ImageIcon createImageIcon(String imgResource) {
  +        InputStream is = null;
  +        ByteArrayOutputStream out = null;
  +        try {
  +            is = SELF_REF.getClass().getClassLoader().getResourceAsStream(imgResource);
  +            if (is != null) {
  +                out = new ByteArrayOutputStream();
  +                byte buff[] = new byte[1024];
  +                int count = 0;
  +                while ( -1 != (count = is.read(buff)) ) {
  +                    out.write(buff, 0, count);
  +                }
  +                buff = out.toByteArray();
  +                if (buff.length != 0){
  +                   return new ImageIcon(buff); 
  +                }
  +            }
  +        }
  +        catch(IOException ex) {
  +        }
  +        finally {
  +            IoUtils.close(is);
  +            IoUtils.close(out);
           }
  -
  -        return new ImageIcon(imgUrl);
  +        return null;
       }
   
  +
       /**
        * Create splash window. Returns null if image not found.
        */
  -    public static JWindow createSplashWindow(String imgFile) {
  -
  -        ImageIcon icon = createImageIcon(imgFile);
  +    public static JWindow createSplashWindow(String imgResource) {
   
  +        ImageIcon icon = createImageIcon(imgResource);
           if (icon == null) {
               return null;
           }
   
           JLabel lab = new JLabel();
  -
           lab.setIcon(icon);
   
           Dimension iDim = new Dimension(icon.getIconWidth(), icon.getIconHeight());
  -        JWindow splashWin = new JWindow();
   
  +        JWindow splashWin = new JWindow();
           splashWin.getContentPane().add(lab);
           splashWin.setSize(iDim);
           setLocation(splashWin);
  -
           return splashWin;
       }
   
  +
  +
       /**
        * Display error message.
        */
       public static void showErrorMessage(Component parent, String str) {
  -        JOptionPane.showMessageDialog(parent, str, "Error!", JOptionPane.ERROR_MESSAGE);
  +        JOptionPane.showMessageDialog(parent, str, "Error!",
  +                                      JOptionPane.ERROR_MESSAGE);
       }
   
  +
       /**
        * Display warning message.
        */
       public static void showWarningMessage(Component parent, String str) {
  -        JOptionPane.showMessageDialog(parent, str, "Warning!", JOptionPane.WARNING_MESSAGE);
  +        JOptionPane.showMessageDialog(parent, str, "Warning!",
  +                                      JOptionPane.WARNING_MESSAGE);
       }
   
       /**
  @@ -90,21 +115,26 @@
        */
       public static void showInformationMessage(Component parent, String str) {
           JOptionPane.showMessageDialog(parent, str, "Information!",
  -                                      JOptionPane.INFORMATION_MESSAGE);
  +                                      JOptionPane.INFORMATION_MESSAGE );
       }
   
  +
  +
       /**
        * Get confirmation.
        */
       public static boolean getConfirmation(Component parent, String str) {
   
  -        int res = JOptionPane.showConfirmDialog(parent, str, "Confirmation",
  -                                                JOptionPane.YES_NO_OPTION,
  -                                                JOptionPane.QUESTION_MESSAGE);
  -
  -        return (res == JOptionPane.YES_OPTION);
  +        int res = JOptionPane.showConfirmDialog(parent, 
  +                                                str,
  +                                                "Confirmation",
  +                                                JOptionPane.YES_NO_OPTION, 
  +                                                JOptionPane.QUESTION_MESSAGE 
  +                                               );
  +        return(res == JOptionPane.YES_OPTION); 
       }
   
  +
       /**
        * Get file name.
        */
  @@ -112,7 +142,6 @@
   
           if (mFileChoose == null) {
               mFileChoose = new JFileChooser();
  -
               mFileChoose.setFileSelectionMode(JFileChooser.FILES_ONLY);
           }
   
  @@ -127,12 +156,11 @@
   
       /**
        * Get directory name.
  -     */
  +     */  
       public static String getDirName(Component parent) {
   
           if (mDirChoose == null) {
               mDirChoose = new JFileChooser();
  -
               mDirChoose.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
           }
   
  @@ -153,7 +181,6 @@
           if (mDirChoose != null) {
               SwingUtilities.updateComponentTreeUI(mDirChoose);
           }
  -
           if (mFileChoose != null) {
               SwingUtilities.updateComponentTreeUI(mFileChoose);
           }
  @@ -163,34 +190,30 @@
        * Position properly - center.
        */
       public static void setLocation(Component comp) {
  -
           Dimension cDim = comp.getSize();
           Dimension wDim = Toolkit.getDefaultToolkit().getScreenSize();
  -
  -        comp.setLocation((wDim.width - cDim.width) / 2, (wDim.height - cDim.height) / 2);
  -    }
  -
  -    /**
  - * Position with respect to the parent component.
  - */
  -    public static void setLocation(Component comp, Component parent) {
  -
  -        Dimension cDim = comp.getSize();
  -        Rectangle pRect = parent.getBounds();
  -        int x = pRect.x + (pRect.width - cDim.width) / 2;
  -        int y = pRect.y + (pRect.height - cDim.height) / 2;
  -
  -        comp.setLocation(x, y);
  +        comp.setLocation((wDim.width - cDim.width)/2, (wDim.height - cDim.height)/2);
       }
  -
  +	
  +	/**
  +     * Position with respect to the parent component.
  +     */
  +	public static void setLocation(Component comp, Component parent)  {
  +		Dimension cDim = comp.getSize();
  +		Rectangle pRect = parent.getBounds();
  +		int x = pRect.x + (pRect.width - cDim.width)/2;
  +		int y = pRect.y + (pRect.height - cDim.height)/2;
  +		comp.setLocation(x, y);
  +	}
  +    
       /**
        * Display a new panel. First removes all children, then add.
        */
  -    public static void showNewPanel(JPanel parent, JPanel child) {
  -
  +	public static void showNewPanel(JPanel parent, JPanel child) {
           parent.removeAll();
           parent.add(child);
           parent.validate();
           parent.repaint();
       }
  -}
  +     
  +}
  \ No newline at end of file
  
  
  
  1.1                  jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/about.html
  
  Index: about.html
  ===================================================================
  <html>
  
  <head>
  <meta http-equiv="Content-Language" content="en-us">
  <title>FTP Server</title>
  </head>
  
  <body bgcolor="#FFFFFF">
  
  <h1 align="center"><font size="6" face="Arial" color="#663300"><i>FTP Server</i></font></h1>
  <p align="center"><font face="Courier" color="#663300"><a href="http://www.apache.org">http://www.apache.org</a></font></p>
  <p align="left"><font face="Arial">This is a fully featured FTP server written 
    in Java. It is an implementation of <a href="http://www.w3.org/Protocols/rfc959/">RFC 
    959</a>. The design is really modular and the server is fully customizable. 
    Using it you can share files over the Internet.</font></p> 
  <p align="left"><b><font face="Arial">Notes:</font></b></p> 
  <ul>
    <li><font face="Arial">100% pure Java, open source resumable FTP server!!!</font></li>
    <li><font face="Arial">Multi platform support. It is based on <a href="http://jakarta.apache.org/avalon">Apache Avalon</a> framework.</font></li>
    <li><font face="Arial">User virtual directory, write permission, idle time-out and upload/download bandwidth limitation support.</font></li>
    <li><font face="Arial">You can monitor all the user activities.</font></li>
    <li><font face="Arial">Anonymous login support.</font></li>
    <li><font face="Arial">Handles both ASCII and binary data transfers.</font></li>
    <li><font face="Arial">IP restriction support. You can use a limited set of regular expressions (*?[^-]) to specify the banned IPs.</font></li>
    <li><font face="Arial">The server reloads the user data at a regular interval if necessary.</font></li>
    <li><font face="Arial">Database and LDAP can be used to store user data.</font></li>
    <li><font face="Arial">Default users <i>admin/admin</i> and <i>anonymous</i> will be created by the server when you start it for the first time.</font></li>
    <li><font face="Arial">New user managers can be added very easily by replacing user manager component.</font></li>
    <li><font face="Arial">You can encrypt the password in property file based user manager by specifying user manager encrypt key. The encryption algorithm is MD5.</font></li>
    <li><font face="Arial">Database based user manager will try to create the user table FTP_USER if not found. You can create it manually by executing apps/ftp/conf/ftp-db.sql file. I have tested it using MySQL and Oracle database.</font></li>
    <li><font face="Arial">If you want to use LDAP to store and authenticate user, you need to change the LDAP schema and the config file. The schema file is ftp-db.ldif. I have tested it using Netscape LDAP (version 4.1).</font></li>
    <li><font face="Arial">You can start remote admin GUI by executing <code>java -jar ftp-admin.jar</code>.</font></li>
    <li><font face="Arial">Tested with different FTP clients like 
        <a href="http://www.microsoft.com/windows/ie/">Internet Explorer</a>, 
        <a href="http://www.netscape.com/">Netscape Navigator</a>, 
        <a href="http://www.globalscape.com/">CuteFTP</a>, 
        <a href="http://www.smartftp.com/">SmartFTP</a>, 
        <a href="http://www.ipswitch.com/">WsFtp</a>,
        <a href="http://stud.fh-heilbronn.de/~jdebis/leechftp/">LeechFTP</a> etc.</font></li>
    <li><font face="Arial" color="red">If you are using property file based user manager, make sure that the user property file is not accesible by the FTP users.
        Otherwise it will be a security problem. Keep it below the user virtual root directory.</font></li>
  </ul>
  </body>
  </html>
  
  
  
  1.1                  jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpAboutPanel.java
  
  Index: FtpAboutPanel.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  
  package org.apache.avalon.ftpserver.gui;
  
  import java.io.InputStream;
  import java.io.IOException;
  import java.awt.Dimension;
  import java.awt.FlowLayout;
  import java.awt.BorderLayout;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import javax.swing.JPanel;
  import javax.swing.JButton;
  import javax.swing.JEditorPane;
  import javax.swing.JScrollPane;
  import javax.swing.event.HyperlinkEvent;
  import javax.swing.event.HyperlinkListener;
  import javax.swing.text.html.HTMLFrameHyperlinkEvent;
  import javax.swing.text.html.HTMLDocument;
  
  import org.apache.avalon.ftpserver.util.IoUtils;
  
  /**
   * Displays <a href="about.html">about.html</a> page.
   *
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public
  class FtpAboutPanel extends JPanel implements HyperlinkListener {
      
      public final static String ABOUT_PAGE = "org/apache/avalon/ftpserver/gui/about.html";
      private JEditorPane mjEditorPane = null;
      
      /**
       * Constructor.
       */
      public FtpAboutPanel() {
          initComponents();
      }
      
      
      /**
       * Initialize GUI components.
       */
      private void initComponents() {
          setLayout(new BorderLayout());
          mjEditorPane = new JEditorPane();
          mjEditorPane.setEditable(false);
          mjEditorPane.setContentType("text/html");
          goHome();
          mjEditorPane.addHyperlinkListener(this);
          
          JScrollPane editorScrollPane = new JScrollPane(mjEditorPane);
          editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
          editorScrollPane.setPreferredSize(new Dimension(480, 340));
          add(editorScrollPane, BorderLayout.CENTER);
          
          JPanel bottomPane = new JPanel();
          bottomPane.setLayout(new FlowLayout(FlowLayout.CENTER));
          JButton homeButton = new JButton("Home");
          homeButton.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent evt) {
                  goHome();
               }
          });
          bottomPane.add(homeButton);
          add(bottomPane, BorderLayout.SOUTH);
      }
      
      /**
       * Handle user mouse click.
       */
      public void hyperlinkUpdate(HyperlinkEvent e) {
          try {
              if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                  JEditorPane pane = (JEditorPane) e.getSource();
                  if (e instanceof HTMLFrameHyperlinkEvent) {
                      HTMLFrameHyperlinkEvent  evt = (HTMLFrameHyperlinkEvent)e;
                      HTMLDocument doc = (HTMLDocument)pane.getDocument();
                      doc.processHTMLFrameHyperlinkEvent(evt);
                  } 
                  else {
                      pane.setPage(e.getURL());
                  }
              }
          }
          catch(Throwable th) {
          }
      } 
      
      /**
       * Display about page
       */
      private void goHome() {
          InputStream is = null;
          try {
              is = getClass().getClassLoader().getResourceAsStream(ABOUT_PAGE);
              if (is != null) {
                  mjEditorPane.read(is, null);
                   
              }
          }
          catch(IOException ex) {
          }
          finally {
              IoUtils.close(is);
          }
      } 
      
      /**
       * Close panel - does nothing
       */
      public void close() {
      } 
  }
  
  
  
  1.9       +164 -88   jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpAdmin.java
  
  
  
  
  1.1                  jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpFilePanel.java
  
  Index: FtpFilePanel.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  
  package org.apache.avalon.ftpserver.gui;
  
  
  import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  
  
  /**
   * This panel displays all the logged in users.
   */
  public 
  class FtpFilePanel extends JPanel {
      
      private FtpFileTableModel mModel;
      private FtpFilePanel      mSelf;
      private String            mstHeader;
      
      /**
       * Instantiate login panel.
       */
      public FtpFilePanel(FtpFileTableModel model, String header) {
          mSelf = this;
          mModel = model;
          mstHeader = header;
          initComponents();
      }
       
      /**
       * Initialize UI components
       */
      private void initComponents() {
          
          setLayout(new BorderLayout());
          
          JPanel topPane = new JPanel();
          JLabel headerLab = new JLabel(mstHeader);
          headerLab.setForeground(Color.black);
          topPane.add(headerLab);
          add(topPane, BorderLayout.NORTH);
          
          JTable fileTable = new JTable(mModel);
          fileTable.setPreferredScrollableViewportSize(new Dimension(470, 300));
          fileTable.setColumnSelectionAllowed(false);
          JScrollPane scrollPane = new JScrollPane(fileTable, 
                                       JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                                       JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);                          
          add(scrollPane, BorderLayout.CENTER);
          
          
          // button
          JPanel bottomPanel = new JPanel();
          JButton jResetBtn = new JButton("Clear");
          bottomPanel.add(jResetBtn);
          add(bottomPanel, BorderLayout.SOUTH);
          
          // event handler
          jResetBtn.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent evt) {
                  mModel.reset();
               }
          });
      }
       
      /**
       * Refresh window.
       */
      public void refresh() {
          mModel.reset();
      }
      
      /**
       * Close panel
       */
      public void close() {
          mModel.close();
      }
      
  }
  
  
  1.1                  jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpFileTableModel.java
  
  Index: FtpFileTableModel.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  
  package org.apache.avalon.ftpserver.gui;
  
  import java.util.Date;
  import java.util.Vector;
  import java.text.SimpleDateFormat;
  import javax.swing.table.AbstractTableModel;
  import org.apache.avalon.ftpserver.FtpUser;
  
  /**
   * This table model tracks user file related activities.
   * 
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>.
   */
  public
  class FtpFileTableModel extends AbstractTableModel {
      
      private final static SimpleDateFormat DATE_FMT = new SimpleDateFormat("MM/dd HH:mm:ss");
      
      private final static String[] COL_NAMES = {"File", 
                                                 "User", 
                                                 "Time"};    
  
      private Vector mEntryList = new Vector();
     
      
      /**
       * Reload the model.
       */
      public void reset() {
          mEntryList.clear();
          fireTableDataChanged();
      }
       
      /**
       * Get column class - always string
       */
      public Class getColumnClass(int index) {
          return String.class;
      }
      
      /**
       * Get column count.
       */
      public int getColumnCount() {
          return COL_NAMES.length;
      }
      
      /**
       * Get column name.
       */
      public String getColumnName(int index) {
          return COL_NAMES[index];
      } 
      
      /**
       * Get row count.
       */
      public int getRowCount() {
          return mEntryList.size();
      }
      
      /**
       * Is cell editable - currently false.
       */
      public boolean isCellEditable(int row, int col) {
          return true;
      }
      
     /**
      * Set value at - dummy method
      */
     public void setValueAt(Object val, int row, int col) {
     }
     
     /**
       * Get value at.
       */
      public Object getValueAt(int row, int col) {
          
          String retVal = "";
          TableEntry entry = null;
          try {
              entry = (TableEntry)mEntryList.get(row);
          }
          catch(Exception ex) {
          }
          if (entry == null) {
              return retVal;
          }
          
          switch(col) {
              case 0:
                  retVal = entry.fileName;
                  break;
              
              case 1:
                  retVal = entry.userName;
                  break;
              
              case 2:
                  retVal = entry.date;
                  break;  
          }
          return retVal;
      }
    
     /**
      * Find column index.
      */
     public int findColumn(String columnName) {
          int index = -1;
          for(int i=COL_NAMES.length; --i>=0; ) {
              if (COL_NAMES[i].equals(columnName)) {
                  index = i;
                  break;
              }
          }
          return index;
     }
      
      /**
       * Add a new user
       */
      public void newEntry(String file, FtpUser user) {
          
          TableEntry entry = new TableEntry();
          entry.fileName = file;
          entry.userName = user.getName();
          entry.date = DATE_FMT.format(new Date());
          
          int sz = 0;
          synchronized(mEntryList) {
              mEntryList.add(entry);
              sz = mEntryList.size();
          }
          
          fireTableRowsInserted(sz, sz);
      }  
      
      /**
       * Remove all entries
       */
      public void close() {
          mEntryList.clear();
      }
      
      //////////////////////////////////////////////////////////
      ///////////////////////list entry  ///////////////////////
      public class TableEntry {
          String fileName;
          String userName;
          String date;
      }
      
  }    
  
  
  
  1.1                  jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpSpyFrame.java
  
  Index: FtpSpyFrame.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  
  package org.apache.avalon.ftpserver.gui;
  
  import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  
  import org.apache.avalon.ftpserver.FtpUser;
  
  /**
   * This frame holds all connection spy frames
   */
  public
  class FtpSpyFrame extends JFrame {
      
      private final static ImageIcon ICON_IMG = GuiUtils.createImageIcon("org/apache/avalon/ftpserver/gui/spy.gif");
      
      private CommonHandler mCommonHandler = null;
      private JTabbedPane mjTabbedPane     = null;
      
      private JButton mjClearButton        = null;
      private JButton mjCloseButton        = null;
      private JButton mjDisconnectButton   = null;
      
      private FtpSpyFrame mSelf            = null;
      
      /**
       * Constructor - create empty tabbed frame
       */
      public FtpSpyFrame(CommonHandler commonHandler) {
          mSelf = this;
          mCommonHandler = commonHandler;
          initComponents();
      }
      
      /**
       * Initialize all components
       */
      private void initComponents() {
          getContentPane().setLayout(new BorderLayout());
          mjTabbedPane = new JTabbedPane();
          getContentPane().add(mjTabbedPane, BorderLayout.CENTER);
          
          JPanel bottomPane = new JPanel();
          bottomPane.setLayout(new FlowLayout(FlowLayout.CENTER));
          
          mjClearButton = new JButton("Clear");
          bottomPane.add(mjClearButton);
          mjClearButton.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent evt) {
                  clearLog();
               }
          });
          
          mjCloseButton = new JButton("Close");
          bottomPane.add(mjCloseButton);
          mjCloseButton.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent evt) {
                  closePane();
               }
          });
          
          mjDisconnectButton = new JButton("Disconnect");
          bottomPane.add(mjDisconnectButton);
          mjDisconnectButton.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent evt) {
                  disconnectUser();
               }
          });
          getContentPane().add(bottomPane, BorderLayout.SOUTH);
          
          setTitle("Spy User");
          if (ICON_IMG != null) {
              setIconImage(ICON_IMG.getImage());
          }
          
          setSize(new Dimension(500, 400));
          GuiUtils.setLocation(this);
      }
      
      /*
       * Handle window closing event.
       */ 
      protected void processWindowEvent(WindowEvent e) {
          int id = e.getID();
          if (id == WindowEvent.WINDOW_CLOSING) {
              close();
          } else {
              super.processWindowEvent(e);
          }    
      }
      
      /**
       * Close window
       */
      public void close() {
          int tabCount = mjTabbedPane.getTabCount();
          for(int i=0; i<tabCount; i++) {
              SpyPanel spyPane = (SpyPanel)mjTabbedPane.getComponentAt(i);
              spyPane.closePane();
          }
          mjTabbedPane.removeAll();
          setVisible(false);
      } 
      
      /**
       * Clear user log
       */
      private void clearLog() {
          SpyPanel spyPane = (SpyPanel)mjTabbedPane.getSelectedComponent();
          if (spyPane != null) {
              spyPane.clearLog();
          }
      }
       
      /**
       * Close connection spy panel
       */ 
      private void closePane() {
          SpyPanel spyPane = (SpyPanel)mjTabbedPane.getSelectedComponent();
          if (spyPane != null) {
              spyPane.closePane();
              mjTabbedPane.remove(spyPane);
          }
      }
      
      /**
       * Disconnected user connection
       */
      private void disconnectUser() {
          SpyPanel spyPane = (SpyPanel)mjTabbedPane.getSelectedComponent();
          if (spyPane == null) {
              return;
          }
      
          boolean bConf = GuiUtils.getConfirmation(this, "Do you want to close the connection?");
          if(bConf) {
              spyPane.disconnect();
          }
      }
      
      /**
       * Monitor connection
       */
      public void monitorConnection(FtpUser user) {
          
          String userName = getName(user);
          
          // don't add another tab if already being monitored
          int tabCount = mjTabbedPane.getTabCount();
          for(int i=0; i<tabCount; i++) {
              SpyPanel spyPane = (SpyPanel)mjTabbedPane.getComponentAt(i);
              FtpUser tabUser = spyPane.getUser();
              if (tabUser.equals(user)) {
                  mjTabbedPane.setTitleAt(i, userName);
                  mjTabbedPane.setSelectedIndex(i);
                  return;
              }
          }
          
          // add new tab
          try {
              SpyPanel spyPane = new SpyPanel(mCommonHandler, user);
              mjTabbedPane.add(userName, spyPane);
              mjTabbedPane.setSelectedComponent(spyPane);
          }
          catch(Exception ex) {
              mCommonHandler.handleException(ex);
          }
      } 
      
      /**
       * Get name
       */
      private String getName(FtpUser user) {
          String name = "";
          if (user != null) {
              name = user.getName();
              if (name == null) {
                  name = "UNKNOWN";
              }
          }
          return name;
      } 
       
  }
  
  
  1.1                  jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/SpyPanel.java
  
  Index: SpyPanel.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  
  package org.apache.avalon.ftpserver.gui;
  
  import java.rmi.RemoteException;
  import java.awt.BorderLayout;
  import javax.swing.JPanel;
  import javax.swing.JTextArea;
  import javax.swing.JScrollPane;
  import org.apache.avalon.ftpserver.FtpUser;
  import org.apache.avalon.ftpserver.remote.interfaces.SpyConnectionInterface;
  import org.apache.avalon.ftpserver.gui.remote.SpyConnectionAdapter;
  import org.apache.avalon.ftpserver.gui.GuiUtils;
  
  
  /**
   * This panel is used to monitor user activity.
   *
   * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
   */
  public 
  class SpyPanel extends JPanel implements SpyConnectionInterface {
      
      private JTextArea mLogTxt    = null;
      
      private SpyConnectionAdapter mSpyAdapter = null;
      private CommonHandler mCommonHandler     = null;
      private FtpUser mUser                    = null;
      
      /**
       * Instantiate this dialog box
       */
      public SpyPanel(CommonHandler commonHandler, FtpUser user) throws RemoteException {
          mUser = user;
          mCommonHandler = commonHandler;
  
          initComponents();
          mSpyAdapter = new SpyConnectionAdapter(mCommonHandler.getConnectionService(), mUser.getSessionId(), this);
      }
      
      /**
       * Initialize the UI components
       */
      private void initComponents() throws RemoteException {
          setLayout(new BorderLayout());
          mLogTxt = new JTextArea();
          mLogTxt.setEditable(false);
          JScrollPane txtPane = new JScrollPane(mLogTxt, 
                      JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                      JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
          add(txtPane, BorderLayout.CENTER);
      }
      
      /**
       * Get user 
       */
      public FtpUser getUser() {
          return mUser;
      }
      
      /**
       * Write message
       */
      public void write(String msg) {
          mLogTxt.append(msg);
      }
      
      /**
       * Clear log messages
       */
      public void clearLog() {
          mLogTxt.setText("");
      }
      
      /**
       * Close pane
       */
      public void closePane() {
          mSpyAdapter.close();
          mLogTxt.setText("");
      }
      
      /**
       * Disconnect user
       */
      public void disconnect() {
          try {
              mSpyAdapter.close();
              mCommonHandler.getConnectionService().closeConnection(mUser.getSessionId());
          }
          catch(Exception ex) {
              mCommonHandler.handleException(ex);
          }
      }
      
  }
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message