📄 ftpstatisticspanel.java
字号:
package ranab.server.ftp.gui;
import java.io.File;
import java.awt.Color;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.awt.FlowLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import ranab.server.ftp.FtpUser;
import ranab.server.ftp.FtpConfig;
import ranab.server.ftp.FtpStatistics;
import ranab.server.ftp.FtpFileListener;
import ranab.server.ftp.FtpStatisticsListener;
/**
* Ftp server global statistics panel.
*
* @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
*/
public
class FtpStatisticsPanel extends PluginPanel
implements FtpStatisticsListener, FtpFileListener {
private final static SimpleDateFormat DATE_FMT = new SimpleDateFormat("dd,MMM,yyyy HH:mm");
private FtpConfig mConfig;
private FtpStatistics mStat;
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;
/**
* Creates new panel to display ftp global statistics.
*/
public FtpStatisticsPanel(FtpTree tree) {
super(tree);
initComponents();
mUploadModel = new FtpFileTableModel();
mDownloadModel = new FtpFileTableModel();
mDeleteModel = new FtpFileTableModel();
}
/**
* This method is called from within the constructor to
* initialize the panel.
*/
private void initComponents() {
GridBagConstraints gc;
setLayout(new GridBagLayout());
int yindex = -1;
// start time
JLabel jStartTimeLab = new JLabel("Start Time");
jStartTimeLab.setHorizontalAlignment(JLabel.RIGHT);
jStartTimeLab.setForeground(Color.black);
gc = new GridBagConstraints();
gc.gridx = 0;
gc.gridy = ++yindex;
gc.gridwidth = 1;
gc.anchor = GridBagConstraints.EAST;
gc.insets = new Insets(3, 0, 0, 3);
add(jStartTimeLab, gc);
mjStartTimeTxt = new JTextField();
mjStartTimeTxt.setColumns(12);
mjStartTimeTxt.setEditable(false);
gc = new GridBagConstraints();
gc.gridx = 1;
gc.gridy = yindex;
gc.gridwidth = 2;
gc.anchor = GridBagConstraints.WEST;
gc.insets = new Insets(3, 0, 0, 3);
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 = ++yindex;
gc.gridwidth = 1;
gc.anchor = GridBagConstraints.EAST;
gc.insets = new Insets(3, 0, 0, 3);
add(jUploadNbrLab, gc);
mjUploadNbrTxt = new JTextField();
mjUploadNbrTxt.setColumns(6);
mjUploadNbrTxt.setEditable(false);
gc = new GridBagConstraints();
gc.gridx = 1;
gc.gridy = yindex;
gc.gridwidth = 2;
gc.anchor = GridBagConstraints.WEST;
gc.insets = new Insets(3, 0, 0, 3);
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 = ++yindex;
gc.gridwidth = 1;
gc.anchor = GridBagConstraints.EAST;
gc.insets = new Insets(3, 0, 0, 3);
add(jDownloadNbrLab, gc);
mjDownloadNbrTxt = new JTextField();
mjDownloadNbrTxt.setColumns(6);
mjDownloadNbrTxt.setEditable(false);
gc = new GridBagConstraints();
gc.gridx = 1;
gc.gridy = yindex;
gc.gridwidth = 2;
gc.anchor = GridBagConstraints.WEST;
gc.insets = new Insets(3, 0, 0, 3);
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 = ++yindex;
gc.gridwidth = 1;
gc.anchor = GridBagConstraints.EAST;
gc.insets = new Insets(3, 0, 0, 3);
add(jDeleteNbrLab, gc);
mjDeleteNbrTxt = new JTextField();
mjDeleteNbrTxt.setColumns(6);
mjDeleteNbrTxt.setEditable(false);
gc = new GridBagConstraints();
gc.gridx = 1;
gc.gridy = yindex;
gc.gridwidth = 2;
gc.anchor = GridBagConstraints.WEST;
gc.insets = new Insets(3, 0, 0, 3);
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 = ++yindex;
gc.gridwidth = 1;
gc.anchor = GridBagConstraints.EAST;
gc.insets = new Insets(3, 0, 0, 3);
add(jUploadBytesLab, gc);
mjUploadBytesTxt = new JTextField();
mjUploadBytesTxt.setColumns(12);
mjUploadBytesTxt.setEditable(false);
gc = new GridBagConstraints();
gc.gridx = 1;
gc.gridy = yindex;
gc.gridwidth = 2;
gc.anchor = GridBagConstraints.WEST;
gc.insets = new Insets(3, 0, 0, 3);
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 = ++yindex;
gc.gridwidth = 1;
gc.anchor = GridBagConstraints.EAST;
gc.insets = new Insets(3, 0, 0, 3);
add(jDownloadBytesLab, gc);
mjDownloadBytesTxt = new JTextField();
mjDownloadBytesTxt.setColumns(12);
mjDownloadBytesTxt.setEditable(false);
gc = new GridBagConstraints();
gc.gridx = 1;
gc.gridy = yindex;
gc.gridwidth = 2;
gc.anchor = GridBagConstraints.WEST;
gc.insets = new Insets(3, 0, 0, 3);
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 = ++yindex;
gc.gridwidth = 1;
gc.anchor = GridBagConstraints.EAST;
gc.insets = new Insets(3, 0, 0, 3);
add(jLoginNbrLab, gc);
mjLoginNbrTxt = new JTextField();
mjLoginNbrTxt.setColumns(6);
mjLoginNbrTxt.setEditable(false);
gc = new GridBagConstraints();
gc.gridx = 1;
gc.gridy = yindex;
gc.gridwidth = 2;
gc.anchor = GridBagConstraints.WEST;
gc.insets = new Insets(3, 0, 0, 3);
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 = ++yindex;
gc.gridwidth = 1;
gc.anchor = GridBagConstraints.EAST;
gc.insets = new Insets(3, 0, 0, 3);
add(jTotalLoginNbrLab, gc);
mjTotalLoginNbrTxt = new JTextField();
mjTotalLoginNbrTxt.setColumns(6);
mjTotalLoginNbrTxt.setEditable(false);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -