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

📄 spkeypanel.java

📁 打印管理程序,测试完全通过.windows开发环境.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			invoker.addSPKey(spKeyInfo);
			mdlSPKey.addInfo(spKeyInfo);

			addUserHistory(spKeyInfo);
			sendActionEvent(ActionEventConstants.ACTCMD_REFRESH_USER_HISTORY);
		}
		
		return true;
	}
	
	protected boolean doModify() throws NetworkException, ServerException, TimeOutException {
		int		selRow = sorter.modelIndex(tblSPKey.getSelectedRow());
		if (selRow >= 0) {
			SPKeyInfo	spKeyInfo = (SPKeyInfo)mdlSPKey.getSelectedInfo(selRow);
			if (spKeyInfo.getSerial().equals(currentKeyInfo.getSerial()) &&
					spKeyInfo.getKeyKind() == currentKeyInfo.getKeyKind()) {
				
				String[]	params = new String[] {
					MsgUtil.getSPKeyOptMsg()	
				};
				
				DialogManager.showMessage(this, DialogManager.ERROR_MODIFY_SPKEY_INSERT, params);
				return false;
			}
			
			SPKeyInfoPanel	p = new SPKeyInfoPanel(true, spKeyInfo, vcSPKeyInfo, vcUserInfo/*, insertedSPKeyInfo, uhInfoInvoker*/);
			preValidity = spKeyInfo.getValidity();
			
			if (DialogManager.showCustomDialog(
					this, Resource.getString(Resource.SPKEYINFO_TITLE), p) == SPKeyInfoPanel.OK_BUTTON) {
				
				// 妱傝摉偰偨儐乕僓偼丄偡偱偵懠偺僉乕偵妱傝摉偰傜傟偰偄傞
				Vector	vcRegSPKeyInfo = invoker.getSPKeyInfoByUserName(spKeyInfo.getUser().getUserName(), spKeyInfo.getKeyKind(), 1);
				if (vcRegSPKeyInfo.size() > 0) {
					DialogManager.showMessage(this, DialogManager.ERROR_ALREADY_RELATED_USER);
					return false;
				}
				
				invoker.changeSPKeyInfo(spKeyInfo);
				mdlSPKey.setInfo(selRow, spKeyInfo);
				if (preValidity != spKeyInfo.getValidity()) {
					addUserHistory(spKeyInfo);
				}
				sendActionEvent(ActionEventConstants.ACTCMD_REFRESH_USER_HISTORY);
			}
			
/*			// Administrator儐乕僓忣曬偑曄峏偝傟偨偲偒丄USB Key僠僃僢僋僗儗僢僪偵捠抦偡傞
			if (!isApplet()) {
				if (spKeyInfo.getUser().getPrivilegeInfo().getCategory() == PrivilegeInfo.PRIVILEGE_ADMIN) {
					changeSupport.fireChangeEvent(new ChangeEvent(this));
				}
			}*/
		}

		return true;
	}
	
	protected boolean doDelete() throws NetworkException, ServerException, TimeOutException {
		return true;
	}

/*
	private void doMultiRegister() throws NetworkException, ServerException, TimeOutException {
		if (!isApplet()) {
			CSVFileFilter	filter = new CSVFileFilter();
			JFileChooser	fc = new JFileChooser();
			fc.setFileFilter(filter);
			
			int	ret = fc.showOpenDialog(this);
			if (ret == JFileChooser.APPROVE_OPTION) {
				
			}
		}
	}*/
	
	private boolean doChangeValidity() throws NetworkException, ServerException, TimeOutException {
		int[]	selViewRows = tblSPKey.getSelectedRows();
		
		for (int i = 0; i < selViewRows.length; i++) {
			int	selRow = sorter.modelIndex(selViewRows[i]);
			if (selRow >= 0) {
				SPKeyInfo	spKeyInfo = (SPKeyInfo)mdlSPKey.getSelectedInfo(selRow);

				int	validity = spKeyInfo.getValidity();
			
				// 巊梡掆巭仺巊梡奐巒偵偡傞応崌丄懠偵摨偠儐乕僓偺巊梡奐巒偺僉乕偑偁偭偨応崌僄儔乕偵偡傞
				if (validity == SPKeyInfo.VALIDITY_INVALIDITY) {
					Vector	vcRegSPKeyInfo = invoker.getSPKeyInfoByUserName(spKeyInfo.getUser().getUserName(), spKeyInfo.getKeyKind(), 1);
					if (vcRegSPKeyInfo.size() > 0) {
						DialogManager.showMessage(this, DialogManager.ERROR_VALIDITY_OTHER_KEY);
						return false;
					}
				}
				
				switch (validity) {
				case SPKeyInfo.VALIDITY_EFFECTIVE:
					spKeyInfo.setValidity(SPKeyInfo.VALIDITY_INVALIDITY);
					break;
				case SPKeyInfo.VALIDITY_INVALIDITY:
					spKeyInfo.setValidity(SPKeyInfo.VALIDITY_EFFECTIVE);
					break;
				}
				
				invoker.changeSPKeyInfo(spKeyInfo);
				mdlSPKey.setInfo(selRow, spKeyInfo);
				addUserHistory(spKeyInfo);
			}
		}
		sendActionEvent(ActionEventConstants.ACTCMD_REFRESH_USER_HISTORY);
		
		return true;
	}
	
	private boolean addUserHistory(SPKeyInfo spKeyInfo) throws NetworkException, ServerException, TimeOutException {
		UserHistoryInfo	uhInfo = new UserHistoryInfo();
		uhInfo.setSPKeySerial(spKeyInfo.getSerial());
		uhInfo.setUserID(currentKeyInfo.getUser().getUserID());
		uhInfo.setUserName(currentKeyInfo.getUser().getUserName());
		if (spKeyInfo.getValidity() == SPKeyInfo.VALIDITY_EFFECTIVE) {
			uhInfo.setDateEnd("");
			Calendar	cal = Calendar.getInstance(); 
			Timestamp	ts = new Timestamp(cal.getTimeInMillis());
			uhInfo.setDateStart(ts.toString());
			
			uhInfoInvoker.addUserHistory(uhInfo);
		} else if (spKeyInfo.getValidity() == SPKeyInfo.VALIDITY_INVALIDITY) {
			uhInfo.setDateStart("");
			Calendar	cal = Calendar.getInstance(); 
			Timestamp	ts = new Timestamp(cal.getTimeInMillis());
			uhInfo.setDateEnd(ts.toString());
			uhInfoInvoker.setUserHistoryInfo(uhInfo);
		}
		
		return true;
	}
	
	public int getInfosFromServer() {
		int		result = GET_INFO_RESULT_NORMAL;

		mdlSPKey.deleteAllInfos();
		
		try {
			getSPKeyInfo();
		} 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 {
			getInstalledUserInfo();
		} 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 == btnMultiRegister) {
				doMultiRegister();*/
			} else if (obj == btnRefresh) {
				sendActionEvent(ActionEventConstants.ACTCMD_RESET_SESSION_TIMER);
				doRefresh();
			} else if (obj == menuValidity) {
				sendActionEvent(ActionEventConstants.ACTCMD_RESET_SESSION_TIMER);
				doChangeValidity();
			}
		} 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 le) {
		Object	obj = le.getSource();
		if (obj == mdlSPKeySelect) {
			sendActionEvent(ActionEventConstants.ACTCMD_RESET_SESSION_TIMER);
			int[]	rows = tblSPKey.getSelectedRows();
			if (rows == null || rows.length == 0) {
				setButtonState(false, null);
			} else {
				setButtonState(true, rows);
			}
		}
	}
}

⌨️ 快捷键说明

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