📄 userpanel.java
字号:
Util.debugPrint("current date = " + ts.toString());
userInfo.setCreateDate(ts.toString());
int id = invoker.addUser(userInfo);
userInfo.setUserID(id);
mdlUser.addInfo(userInfo);
if (Util.getPreferenceInfo().getAuthType() != PreferenceInfo.AUTH_LOGIN) {
sendActionEvent(ActionEventConstants.ACTCMD_REFRESH_SPKEY);
}
}
return true;
}
protected boolean doModify() throws NetworkException, ServerException, TimeOutException {
int selRow = sorter.modelIndex(tblUser.getSelectedRow());
if (selRow >= 0) {
UserInfo2 userInfo = (UserInfo2)mdlUser.getSelectedInfo(selRow);
// 憓擖偝傟偰偄傞SP Key偺儐乕僓偐僠僃僢僋
if (isCurrentKeyInfo(userInfo)) {
if (currentKeyInfo instanceof SPKeyInfo) {
String[] params = new String[] {
MsgUtil.getSPKeyOptMsg()
};
DialogManager.showMessage(this, DialogManager.ERROR_MODIFY_USER_RELATED_SPKEY_INSERT, params);
} else {
DialogManager.showMessage(this, DialogManager.ERROR_MODIFY_RELATED_LOGIN_USER);
}
return false;
}
UserInfoPanel userPanel = new UserInfoPanel(
true, userInfo, vcUserInfo, vcGroupInfo, vcPrInfo, vcLpInfo);
if (DialogManager.showCustomDialog(
this,
Resource.getString(Resource.USERINFO_TITLE),
userPanel) == UserInfoPanel.OK_BUTTON) {
invoker.setUserInfo(userInfo);
mdlUser.setInfo(selRow, userInfo);
if (Util.getPreferenceInfo().getAuthType() != PreferenceInfo.AUTH_LOGIN) {
sendActionEvent(ActionEventConstants.ACTCMD_REFRESH_SPKEY);
}
// Administrator儐乕僓忣曬偑曄峏偝傟偨偲偒丄USB Key僠僃僢僋僗儗僢僪偵捠抦偡傞
/* if (!isApplet()) {
if (userInfo.getPrivilegeInfo().getPrivilegeID() == PrivilegeInfo.PRIVILEGE_ADMIN) {
changeSupport.fireChangeEvent(new ChangeEvent(this));
}
}*/
}
}
return true;
}
protected boolean doDelete() throws NetworkException, ServerException, TimeOutException {
int[] selViewRows = tblUser.getSelectedRows();
Vector vcUserInfo = new Vector();
for (int i = selViewRows.length - 1; i >= 0; i--) {
int selRow = sorter.modelIndex(selViewRows[i]);
if (selRow >= 0) {
UserInfo2 userInfo = (UserInfo2)mdlUser.getSelectedInfo(selRow);
// "sps_admin"儐乕僓偐僠僃僢僋
if (userInfo.getUserName().equals(UserInfo2.AdminUser)) {
DialogManager.showMessage(this, DialogManager.ERROR_DELETE_SPS_ADMIN);
return false;
}
// 憓擖偝傟偰偄傞SP Key偺儐乕僓偐僠僃僢僋
if (isCurrentKeyInfo(userInfo)) {
if (currentKeyInfo instanceof SPKeyInfo) {
String[] params = new String[] {
MsgUtil.getSPKeyOptMsg()
};
DialogManager.showMessage(this, DialogManager.ERROR_DELETE_USER_RELATED_SPKEY_INSERT, params);
} else {
DialogManager.showMessage(this, DialogManager.ERROR_DELETE_RELATED_LOGIN_USER);
}
return false;
}
vcUserInfo.addElement(userInfo);
}
}
// 報嶞棜楌偵愝掕偝傟偰偄傞偐僠僃僢僋
if (invoker.isRelatedUserOnAccount(vcUserInfo)) {
DialogManager.showMessage(this, DialogManager.ERROR_DELETE_USER_RELATED_ACCOUNT);
return false;
}
// SP Key 偵娭楢晅偗傟傜偰偄傞偐僠僃僢僋
// UserInfo偑僉乕偺偲偒偼丄偙偺敾掕偼峴傢側偄
if (currentKeyInfo instanceof SPKeyInfo) {
if (invoker.isRelatedUser(vcUserInfo)) {
DialogManager.showMessage(this, DialogManager.ERROR_DELETE_USER_RELATED_SPKEY);
return false;
}
}
if (DialogManager.showConfirmMessage(
this,
DialogManager.CONFIRM_DELETE,
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
invoker.delUser(vcUserInfo);
for (int i = selViewRows.length - 1; i >= 0; i--) {
int selRow = sorter.modelIndex(selViewRows[i]);
if (selRow >= 0) {
mdlUser.deleteInfo(selRow);
}
}
if (Util.getPreferenceInfo().getAuthType() != PreferenceInfo.AUTH_LOGIN) {
sendActionEvent(ActionEventConstants.ACTCMD_REFRESH_SPKEY);
}
mdlUserSelect.clearSelection();
}
return true;
}
private boolean isCurrentKeyInfo(UserInfo2 userInfo) {
if (currentKeyInfo instanceof SPKeyInfo) {
if (userInfo.getUserID() == ((SPKeyInfo)currentKeyInfo).getUser().getUserID()) {
return true;
}
} else if (currentKeyInfo instanceof UserInfo2) {
if (userInfo.getUserID() == ((UserInfo2)currentKeyInfo).getUserID()) {
return true;
}
}
return false;
}
private void doClearNumPrintedCache() throws NetworkException, ServerException, TimeOutException {
int[] selViewRows = tblUser.getSelectedRows();
Vector vcUserInfo = new Vector();
for (int i = 0; i < selViewRows.length; i++) {
int selRow = sorter.modelIndex(selViewRows[i]);
if (selRow >= 0) {
UserInfo2 userInfo = (UserInfo2)mdlUser.getSelectedInfo(selRow);
userInfo.setNumPrintedCache(0);
vcUserInfo.addElement(userInfo);
}
}
invoker.clearNumPrintedCache(vcUserInfo);
doRefresh();
}
private void doOverPrint(boolean overPrint) throws NetworkException, ServerException, TimeOutException {
menuOverPrintAllowed.setSelected(overPrint);
menuOverPrintDenied.setSelected(!overPrint);
}
/*
private void doMultiRegister() throws NetworkException, ServerException, TimeOutException {
CSVFileFilter filter = new CSVFileFilter();
JFileChooser fc = new JFileChooser();
fc.setFileFilter(filter);
int ret = fc.showOpenDialog(this);
if (ret == JFileChooser.APPROVE_OPTION) {
}
}
}*/
public int getInfosFromServer() {
Util.debugPrint("UserPanel.getInfosFromServer");
int result = GET_INFO_RESULT_NORMAL;
mdlUser.deleteAllInfos();
try {
getUserInfo();
} catch (NetworkException e) {
result = GET_INFO_RESULT_ERROR;
sendActionEvent(MsgUtil.getMessage(MsgUtil.ERROR_NETWORK, null));
} catch (ServerException e) {
result = GET_INFO_RESULT_ERROR;
sendActionEvent(MsgUtil.getMessage(MsgUtil.ERROR_SERVER, null));
} catch (TimeOutException e) {
}
result = getInfosFromServerForInfoPanel();
if (result == GET_INFO_RESULT_NORMAL) {
sendActionEvent(MsgUtil.getMessage(MsgUtil.MSG_IDLE, null));
}
return result;
}
private int getInfosFromServerForInfoPanel() {
int result = GET_INFO_RESULT_NORMAL;
try {
getInstalledGroupInfo();
} catch (NetworkException e) {
result = GET_INFO_RESULT_ERROR;
sendActionEvent(MsgUtil.getMessage(MsgUtil.ERROR_NETWORK, null));
} catch (ServerException e) {
result = GET_INFO_RESULT_ERROR;
sendActionEvent(MsgUtil.getMessage(MsgUtil.ERROR_SERVER, null));
} catch (TimeOutException e) {
}
try {
getPrivilegeInfo();
} catch (NetworkException e) {
result = GET_INFO_RESULT_ERROR;
sendActionEvent(MsgUtil.getMessage(MsgUtil.ERROR_NETWORK, null));
} catch (ServerException e) {
result = GET_INFO_RESULT_ERROR;
sendActionEvent(MsgUtil.getMessage(MsgUtil.ERROR_SERVER, null));
} catch (TimeOutException e) {
}
try {
getLimitPrintInfo();
} catch (NetworkException e) {
result = GET_INFO_RESULT_ERROR;
sendActionEvent(MsgUtil.getMessage(MsgUtil.ERROR_NETWORK, null));
} catch (ServerException e) {
result = GET_INFO_RESULT_ERROR;
sendActionEvent(MsgUtil.getMessage(MsgUtil.ERROR_SERVER, null));
} catch (TimeOutException e) {
}
if (result == GET_INFO_RESULT_NORMAL) {
sendActionEvent(MsgUtil.getMessage(MsgUtil.MSG_IDLE, null));
}
return result;
}
public void addChangeListener(ChangeListener cl) {
changeSupport.addChangeListener(cl);
}
public void removeChangeListener(ChangeListener cl) {
changeSupport.removeChangeListener(cl);
}
public void actionPerformed(ActionEvent ae) {
Object obj = ae.getSource();
try {
if (obj == btnRegister) {
sendActionEvent(ActionEventConstants.ACTCMD_RESET_SESSION_TIMER);
doRegister();
} else if (obj == btnModify || obj == menuModify) {
sendActionEvent(ActionEventConstants.ACTCMD_RESET_SESSION_TIMER);
doModify();
} else if (obj == btnDelete || obj == menuDelete) {
sendActionEvent(ActionEventConstants.ACTCMD_RESET_SESSION_TIMER);
doDelete();
/* } else if (obj == btnMultiRegister) {
doMultiRegister();*/
} else if (obj == btnRefresh) {
sendActionEvent(ActionEventConstants.ACTCMD_RESET_SESSION_TIMER);
doRefresh();
} else if (obj == menuClearNumPrintedCache) {
sendActionEvent(ActionEventConstants.ACTCMD_RESET_SESSION_TIMER);
doClearNumPrintedCache();
} else if (obj == menuOverPrintAllowed) {
sendActionEvent(ActionEventConstants.ACTCMD_RESET_SESSION_TIMER);
doOverPrint(true);
} else if (obj == menuOverPrintDenied) {
sendActionEvent(ActionEventConstants.ACTCMD_RESET_SESSION_TIMER);
doOverPrint(false);
}
} catch (NetworkException e) {
DialogManager.showMessage(this, DialogManager.ERROR_NETWORK);
} catch (ServerException e) {
DialogManager.showMessage(this, DialogManager.ERROR_SERVER);
} catch (TimeOutException e) {
}
}
public void valueChanged(ListSelectionEvent e) {
Object obj = e.getSource();
if (obj == mdlUserSelect) {
sendActionEvent(ActionEventConstants.ACTCMD_RESET_SESSION_TIMER);
int[] rows = tblUser.getSelectedRows();
if (rows == null || rows.length == 0) {
setButtonState(false, null);
} else {
setButtonState(true, rows);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -