📄 spkeypanel.java
字号:
package jp.co.ntl.swing.ext.user.spkey;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Vector;
import javax.swing.JApplet;
import javax.swing.JButton;
///import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import jp.co.ntl.ActionEventConstants;
import jp.co.ntl.Net;
import jp.co.ntl.NetworkException;
import jp.co.ntl.Page;
import jp.co.ntl.ServerException;
import jp.co.ntl.TimeOutException;
///import jp.co.ntl.awt.event.ChangeEvent;
import jp.co.ntl.awt.event.ChangeListener;
import jp.co.ntl.awt.event.ChangeSupport;
import jp.co.ntl.spkey.SPKeyInfo;
import jp.co.ntl.swing.BasePanel;
import jp.co.ntl.swing.TableSorter;
///import jp.co.ntl.swing.ext.CSVFileFilter;
import jp.co.ntl.swing.ext.DialogManager;
import jp.co.ntl.swing.ext.MsgUtil;
import jp.co.ntl.swing.ext.history.userhistory.UserHistoryInvoker;
import jp.co.ntl.swing.ext.user.user.UserInfoInvoker;
///import jp.co.ntl.user.PrivilegeInfo;
import jp.co.ntl.userhistory.UserHistoryInfo;
public class SPKeyPanel extends BasePanel implements ActionListener, ListSelectionListener {
/**
*
*/
private static final long serialVersionUID = 1L;
private JTable tblSPKey;
private SPKeyTableModel mdlSPKey;
private ListSelectionModel mdlSPKeySelect;
private JScrollPane scrSPKey;
private JButton btnRegister;
private JButton btnModify;
/// private JButton btnMultiRegister;
private JButton btnRefresh;
private JMenuItem menuModify;
private JMenuItem menuValidity;
private Vector vcSPKeyInfo;
private Vector vcUserInfo;
private TableSorter sorter;
private SPKeyInfoInvoker invoker;
private UserHistoryInvoker uhInfoInvoker;
private int preValidity;
private SPKeyInfo currentKeyInfo;
private ChangeSupport changeSupport = new ChangeSupport();
public SPKeyPanel(JFrame parent, Net net) {
super(parent, net);
}
public SPKeyPanel(JApplet appl, Net net) {
super(appl, net);
}
protected void buildComponents() {
Resource.load(loc);
currentKeyInfo = new SPKeyInfo();
Page.initialize(net);
invoker = SPKeyInfoInvoker.getInstance(net);
uhInfoInvoker = UserHistoryInvoker.getInstance(net);
createPopupMenu();
vcUserInfo = new Vector();
vcSPKeyInfo = new Vector();
mdlSPKey = new SPKeyTableModel(vcSPKeyInfo);
sorter = new TableSorter(mdlSPKey);
tblSPKey = new JTable(sorter);
sorter.setTableHeader(tblSPKey.getTableHeader());
scrSPKey = new JScrollPane(tblSPKey);
add(scrSPKey, BorderLayout.CENTER);
tblSPKey.getTableHeader().setReorderingAllowed(false);
btnRegister = new JButton(Resource.getString(Resource.ADD));
btnModify = new JButton(Resource.getString(Resource.MODIFY));
/// btnMultiRegister = new JButton(Resource.getString(Resource.MULTI_REGISTER));
btnRefresh = new JButton(Resource.getString(Resource.REFRESH));
addButtonPanel(
new JButton[] {btnRegister, btnModify, /*btnMultiRegister,*/ btnRefresh},
new String[] {
Resource.getString(Resource.TIP_REGISTER),
Resource.getString(Resource.TIP_MODIFY),
/// Resource.getString(Resource.TIP_MULTI_REGISTER),
Resource.getString(Resource.TIP_REFRESH)
});
btnRegister.addActionListener(this);
btnModify.addActionListener(this);
/// btnMultiRegister.addActionListener(this);
btnRefresh.addActionListener(this);
mdlSPKeySelect = tblSPKey.getSelectionModel();
mdlSPKeySelect.addListSelectionListener(this);
mdlSPKeySelect.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
setButtonState(false, null);
tblSPKey.setColumnSelectionAllowed(false);
tblSPKey.addMouseListener(this);
}
private void createPopupMenu() {
popupMenu = new JPopupMenu();
menuModify = new JMenuItem(Resource.getString(Resource.MODIFY));
menuModify.addActionListener(this);
popupMenu.add(menuModify);
menuValidity = new JMenuItem(Resource.getString(Resource.VALIDITY));
menuValidity.addActionListener(this);
popupMenu.add(menuValidity);
}
public void beginPanel() throws NetworkException, ServerException, TimeOutException {
beginPanel(currentKeyInfo);
}
public void beginPanel(Object info) throws NetworkException, ServerException, TimeOutException {
currentKeyInfo = (SPKeyInfo)info;
doRefresh();
}
public void setCurrentKeyInfo(Object info) {
this.currentKeyInfo = (SPKeyInfo)info;
}
private void setButtonState(boolean b, int[] selViewRows) {
if (selViewRows != null && selViewRows.length <= 1) {
btnModify.setEnabled(b);
for (int i = 0; i < selViewRows.length; i++) {
int selRow = sorter.modelIndex(selViewRows[i]);
if (selRow >= 0) {
SPKeyInfo spKeyInfo = (SPKeyInfo)mdlSPKey.getSelectedInfo(selRow);
if (spKeyInfo.getUser().isAdminUser()) {
btnModify.setEnabled(false);
break;
}
}
}
} else {
btnModify.setEnabled(false);
}
}
protected void setPopupMenuState() {
menuValidity.setEnabled(true);
int[] selViewRows = tblSPKey.getSelectedRows();
if (selViewRows.length > 1) {
menuModify.setEnabled(false);
} else {
menuModify.setEnabled(true);
for (int i = 0; i < selViewRows.length; i++) {
int selRow = sorter.modelIndex(selViewRows[i]);
if (selRow >= 0) {
SPKeyInfo spKeyInfo = (SPKeyInfo)mdlSPKey.getSelectedInfo(selRow);
if (spKeyInfo.getUser().isAdminUser()) {
menuModify.setEnabled(false);
menuValidity.setEnabled(false);
break;
}
}
}
}
}
private boolean getSPKeyInfo() throws NetworkException, ServerException, TimeOutException {
Vector vcSPKeyInfo = invoker.getSPKeyInfo();
Vector vcTemp = new Vector();
for (int i = 0; i < vcSPKeyInfo.size(); i++) { //
SPKeyInfo spKeyInfo = (SPKeyInfo)vcSPKeyInfo.elementAt(i);
// 僔儕傾儖斣崋偑僽儔儞僋偺傕偺偼昞帵偟側偄
if (spKeyInfo.getSerial().length() > 0) {
vcTemp.addElement(spKeyInfo);
}
}
mdlSPKey.addInfos(vcTemp);
return true;
}
private boolean getInstalledUserInfo() throws NetworkException, ServerException, TimeOutException {
UserInfoInvoker ui = UserInfoInvoker.getInstance(net);
vcUserInfo = ui.getUserInfo();
return true;
}
protected boolean doRegister() throws NetworkException, ServerException, TimeOutException {
// 儐乕僓偑搊榐偝傟偰偄側偄
if ((vcUserInfo.size() - 1) <= 0) {
DialogManager.showMessage(this, DialogManager.ERROR_NOT_REGISTER_USER);
return false;
}
SPKeyInfo spKeyInfo = new SPKeyInfo();
spKeyInfo.setValidity(SPKeyInfo.VALIDITY_EFFECTIVE);
SPKeyInfoPanel p = new SPKeyInfoPanel(false, spKeyInfo, vcSPKeyInfo, vcUserInfo/*, insertedSPKeyInfo, uhInfoInvoker*/);
if (DialogManager.showCustomDialog(
this, Resource.getString(Resource.SPKEYINFO_TITLE), p) == SPKeyInfoPanel.OK_BUTTON) {
// 妱傝摉偰偨儐乕僓偼丄偡偱偵懠偺僉乕偵妱傝摉偰傜傟偰偄傞
Vector vcRegSPKeyInfo = invoker.getSPKeyInfoByUserName(spKeyInfo.getUser().getUserName(), spKeyInfo.getKeyKind(), spKeyInfo.getValidity());
if (vcRegSPKeyInfo.size() > 0) {
DialogManager.showMessage(this, DialogManager.ERROR_ALREADY_RELATED_USER);
return false;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -