⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 statisticspanel.java

📁 用java写的ftp服务器程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            notifyDownload();
            notifyDelete();
            notifyLogin(true);
            notifyOpenConnection();
        }
        else {
            if(m_statistics != null) {
                m_statistics.setObserver(null);
                m_statistics.setFileObserver(null);
            }
            m_statistics = null;
        }
    }

    /**
     * Upload notification.
     */
    public void notifyUpload() {
        Runnable runnable = new Runnable() {
            public void run() { 
                IFtpStatistics stat = m_statistics;
                if(stat != null) {
                    int totalUpload = stat.getTotalUploadNumber();
                    setValue(I_FILE_UPLOAD, String.valueOf(totalUpload));
                
                    long totalUploadSz = stat.getTotalUploadSize();
                    setValue(I_UPLOAD_BYTES, String.valueOf(totalUploadSz));
                }
            }
        };
        SwingUtilities.invokeLater(runnable);
    }
    
    /**
     * File upload notification.
     */
    public void notifyUpload(final IConnection connection, final FileObject file, final long size) {
        Runnable runnable = new Runnable() {
            public void run() { 
                FilePanel filePanel = (FilePanel)getContainer().getPluginPanel(PluginPanelContainer.FILE_INDEX);
                filePanel.notifyUpload(connection, file, size);        
            }
        };
        SwingUtilities.invokeLater(runnable);
    }
    
    /**
     * Download notification.
     */
    public void notifyDownload() {
        Runnable runnable = new Runnable() {
            public void run() {
                IFtpStatistics stat = m_statistics;
                if(stat != null) {
                    int totalDownload = stat.getTotalDownloadNumber();
                    setValue(I_FILE_DOWNLOAD, String.valueOf(totalDownload));
                    
                    long totalDownloadSz = stat.getTotalDownloadSize();
                    setValue(I_DOWNLOAD_BYTES, String.valueOf(totalDownloadSz));
                }
            }
        };
        SwingUtilities.invokeLater(runnable);
    }

    /**
     * File download notification.
     */
    public void notifyDownload(final IConnection connection, final FileObject file, final long size) {
        Runnable runnable = new Runnable() {
            public void run() { 
                FilePanel filePanel = (FilePanel)getContainer().getPluginPanel(PluginPanelContainer.FILE_INDEX);
                filePanel.notifyDownload(connection, file, size);        
            }
        };
        SwingUtilities.invokeLater(runnable);
    }
    
    /**
     * Delete notification.
     */
    public void notifyDelete() {
        Runnable runnable = new Runnable() {
            public void run() { 
                IFtpStatistics stat = m_statistics;
                if(stat != null) {
                    int totalDelete = stat.getTotalDeleteNumber();
                    setValue(I_FILE_REMOVED, String.valueOf(totalDelete));
                }
            }
        };
        SwingUtilities.invokeLater(runnable);
    }
    
    /**
     * File delete notification.
     */
    public void notifyDelete(final IConnection connection, final FileObject file) {
        Runnable runnable = new Runnable() {
            public void run() { 
                FilePanel filePanel = (FilePanel)getContainer().getPluginPanel(PluginPanelContainer.FILE_INDEX);
                filePanel.notifyDelete(connection, file);        
            }
        };
        SwingUtilities.invokeLater(runnable);
    }
    
    /**
     * User login notification.
     */
    public void notifyLogin(final boolean anonymous) {
        Runnable runnable = new Runnable() {
            public void run() { 
                IFtpStatistics stat = m_statistics;
                if(stat != null) {
                    int loginNbr = stat.getCurrentLoginNumber();
                    setValue(I_CURR_LOGINS, String.valueOf(loginNbr));
                    
                    int totalLoginNbr = stat.getTotalLoginNumber();
                    setValue(I_TOTAL_LOGINS, String.valueOf(totalLoginNbr));
                    
                    if(anonymous) {
                        int anonLoginNbr = stat.getCurrentAnonymousLoginNumber();
                        setValue(I_CURR_ANON_LOGINS, String.valueOf(anonLoginNbr));
                        
                        int totalAnonLoginNbr = stat.getTotalAnonymousLoginNumber();
                        setValue(I_TOTAL_ANON_LOGINS, String.valueOf(totalAnonLoginNbr));
                    }
                }
            }
        };
        SwingUtilities.invokeLater(runnable);
    }
    
    /**
     * User logout notification.
     */
    public void notifyLogout(boolean anonymous) {
        notifyLogin(anonymous);
    } 
     
    /**
     * Notify open connection
     */ 
    public void notifyOpenConnection() {
        Runnable runnable = new Runnable() {
            public void run() { 
                IFtpStatistics stat = m_statistics;
                if(stat != null) {
                    int currCon = stat.getCurrentConnectionNumber();
                    setValue(I_CURR_CONS, String.valueOf(currCon));
                
                    int totalCon = stat.getTotalConnectionNumber();
                    setValue(I_TOTAL_CONS, String.valueOf(totalCon));
                }
            }
        };
        SwingUtilities.invokeLater(runnable);
    }
    
    /**
     * Notify close connection.
     */
    public void notifyCloseConnection() {
        notifyOpenConnection();
    }
    
    /**
     * Make directory notification.
     */
    public void notifyMkdir() {
        Runnable runnable = new Runnable() {
            public void run() { 
                IFtpStatistics stat = m_statistics;
                if(stat != null) {
                    int totalMkdir = stat.getTotalDirectoryCreated();
                    setValue(I_DIR_CREATED, String.valueOf(totalMkdir));
                }
            }
        };
        SwingUtilities.invokeLater(runnable);
    }

    /**
     * Make directry notification.
     */
    public void notifyMkdir(final IConnection connection, final FileObject file) {
        Runnable runnable = new Runnable() {
            public void run() { 
                DirectoryPanel dirPanel = (DirectoryPanel)getContainer().getPluginPanel(PluginPanelContainer.DIR_INDEX);
                dirPanel.notifyMkdir(connection, file);        
            }
        };
        SwingUtilities.invokeLater(runnable);
    }
    
    /**
     * Directory removal notification.
     */
    public void notifyRmdir() {
        Runnable runnable = new Runnable() {
            public void run() { 
                IFtpStatistics stat = m_statistics;
                if(stat != null) {
                    int totalRmdir = stat.getTotalDirectoryRemoved();
                    setValue(I_DIR_REMOVED, String.valueOf(totalRmdir));
                }
            }
        };
        SwingUtilities.invokeLater(runnable);
    }   
    
    /**
     * Remove directry notification.
     */
    public void notifyRmdir(final IConnection connection, final FileObject file) {
        Runnable runnable = new Runnable() {
            public void run() { 
                DirectoryPanel dirPanel = (DirectoryPanel)getContainer().getPluginPanel(PluginPanelContainer.DIR_INDEX);
                dirPanel.notifyRmdir(connection, file);        
            }
        };
        SwingUtilities.invokeLater(runnable);
    }
        
    /** 
     * This can be displayed only when the server is running.
     */
    public boolean canBeDisplayed() {
        return (m_ftpConfig != null);
    }

    /**
     * Get the string representation.
     */
    public String toString() {
        return "Statistics";
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -