?? ftpstatisticspanel.java
字號:
mjTotalLoginNbrTxt = new JTextField();
mjTotalLoginNbrTxt.setColumns(6);
mjTotalLoginNbrTxt.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(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 = ++yindex;
gc.gridwidth = 1;
gc.anchor = GridBagConstraints.EAST;
gc.insets = new Insets(3, 0, 0, 3);
add(jAnonLoginNbrLab, gc);
mjAnonLoginNbrTxt = new JTextField();
mjAnonLoginNbrTxt.setColumns(6);
mjAnonLoginNbrTxt.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(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 = ++yindex;
gc.gridwidth = 1;
gc.anchor = GridBagConstraints.EAST;
gc.insets = new Insets(3, 0, 0, 3);
add(jTotalAnonLoginNbrLab, gc);
mjTotalAnonLoginNbrTxt = new JTextField();
mjTotalAnonLoginNbrTxt.setColumns(6);
mjTotalAnonLoginNbrTxt.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(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 = ++yindex;
gc.gridwidth = 1;
gc.anchor = GridBagConstraints.EAST;
gc.insets = new Insets(3, 0, 0, 3);
add(jConNbrLab, gc);
mjConNbrTxt = new JTextField();
mjConNbrTxt.setColumns(6);
mjConNbrTxt.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(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 = ++yindex;
gc.gridwidth = 1;
gc.anchor = GridBagConstraints.EAST;
gc.insets = new Insets(3, 0, 0, 3);
add(jTotalConNbrLab, gc);
mjTotalConNbrTxt = new JTextField();
mjTotalConNbrTxt.setColumns(6);
mjTotalConNbrTxt.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(mjTotalConNbrTxt, gc);
// reload statistics
JButton reloadButton = new JButton("Reload");
gc = new GridBagConstraints();
gc.gridx = 1;
gc.gridy = ++yindex;
gc.gridwidth = 1;
gc.anchor = GridBagConstraints.WEST;
gc.insets = new Insets(3, 0, 0, 3);
add(reloadButton, gc);
reloadButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
reloadStatistics();
}
});
}
/**
* 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() {
mjUploadNbrTxt.setText(String.valueOf(mStat.getFileUploadNbr()));
mjUploadBytesTxt.setText(String.valueOf(mStat.getFileUploadSize()));
}
/**
* Download notification.
*/
public void notifyDownload() {
mjDownloadNbrTxt.setText(String.valueOf(mStat.getFileDownloadNbr()));
mjDownloadBytesTxt.setText(String.valueOf(mStat.getFileDownloadSize()));
}
/**
* Delete notification.
*/
public void notifyDelete() {
mjDeleteNbrTxt.setText(String.valueOf(mStat.getFileDeleteNbr()));
}
/**
* User login notification.
*/
public void notifyLogin() {
mjLoginNbrTxt.setText(String.valueOf(mStat.getLoginNbr()));
mjAnonLoginNbrTxt.setText(String.valueOf(mStat.getAnonLoginNbr()));
mjTotalLoginNbrTxt.setText(String.valueOf(mStat.getTotalLoginNbr()));
mjTotalAnonLoginNbrTxt.setText(String.valueOf(mStat.getTotalAnonLoginNbr()));
}
/**
* User logout notification.
*/
public void notifyLogout() {
notifyLogin();
}
/**
* Notify open/close connection
*/
public void notifyConnection() {
mjConNbrTxt.setText(String.valueOf(mStat.getConnectionNbr()));
mjTotalConNbrTxt.setText(String.valueOf(mStat.getTotalConnectionNbr()));
}
/**
* Notify file upload
*/
public void notifyUpload(final File fl, final FtpUser user) {
mUploadModel.newEntry(fl.getAbsolutePath(), user);
}
/**
* Notify file download
*/
public void notifyDownload(final File fl, final FtpUser user) {
mDownloadModel.newEntry(fl.getAbsolutePath(), user);
}
/**
* Notify file delete
*/
public void notifyDelete(final File fl, final FtpUser user) {
mDeleteModel.newEntry(fl.getAbsolutePath(), user);
}
/**
* Reload data
*/
private void reloadStatistics() {
FtpConfig cfg = mConfig;
if(cfg != null) {
mjStartTimeTxt.setText( DATE_FMT.format(mStat.getStartTime()) );
notifyUpload();
notifyDownload();
notifyDelete();
notifyLogin();
notifyConnection();
}
}
/**
* Initialize the statistics data.
*/
public void refresh(FtpConfig cfg) {
mConfig = cfg;
if (cfg != null) {
mStat = mConfig.getStatistics();
mStat.setListener(this);
mStat.setFileListener(this);
reloadStatistics();
}
else {
mStat = null;
}
mUploadModel.reset();
mDownloadModel.reset();
mDeleteModel.reset();
}
/**
* Is displayable
*/
public boolean isDisplayable() {
return mConfig != null;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -