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

📄 spsmainbasepanel.java

📁 打印管理程序,测试完全通过.windows开发环境.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package jp.co.ntl.swing.ext;

import java.awt.CardLayout;
import java.util.Vector;
import java.util.Timer;
import java.util.TimerTask;

import javax.swing.JApplet;
import javax.swing.JFrame;

import jp.co.ntl.Net;
import jp.co.ntl.NetworkException;
import jp.co.ntl.NoUSBException;
import jp.co.ntl.FelicaException;
import jp.co.ntl.ServerException;
import jp.co.ntl.TimeOutException;
import jp.co.ntl.NotRegisterSPKeyException;
import jp.co.ntl.InvaliditySPKeyException;
import jp.co.ntl.NotRegisteredUserException;
import jp.co.ntl.InvalidUserException;
import jp.co.ntl.WrongPasswordException;
import jp.co.ntl.Util;
import jp.co.ntl.spkey.SPKeyInfo;
import jp.co.ntl.user.UserInfo2;
import jp.co.ntl.preference.PreferenceInfo;
import jp.co.ntl.privilege.PrivilegeInfo;
import jp.co.ntl.ext.SPSJNI;
import jp.co.ntl.swing.BasePanel;
import jp.co.ntl.swing.ext.printauth.SPSGeneralUserPanel;
import jp.co.ntl.swing.ext.spstool.CheckSPKeyPanel;
import jp.co.ntl.swing.ext.spstool.Resource;
import jp.co.ntl.swing.ext.spstool.SPSAdminUserPanel;
import jp.co.ntl.swing.ext.user.spkey.SPKeyInfoInvoker;
import jp.co.ntl.swing.ext.user.spkey.SPKeyRegisterPanel;
import jp.co.ntl.swing.ext.user.user.UserInfoInvoker;

public abstract class SPSMainBasePanel extends MainBasePanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public static final String			CHECK_SPKEY_PANEL		= "CheckSPKeyPanel";
	public static final String			ADMIN_USER_PANEL		= "SPSAdminUserPanel";
	public static final String			GENERAL_USER_PANEL		= "SPSGeneralUserPanel";
	public static final String			SP_KEY_REGISTER_PANEL	= "SPKeyRegisterPanel";
	public static final String			CHECK_LOGIN_USER_PANEL	= "CheckLoginUserPanel"; 
	
	public static final int				CHECKUSER_RET_NORMAL				= 0;
	public static final int				CHECKUSER_RET_CONNECTION_SKIP		= -1;
	public static final int				CHECKUSER_RET_CHECK_SKIP			= -2;
	
	public static final int				CHECKUSER_PERIOD					= 3000;
	
	public static final int				KEY_UNKNOWN							= -1;
	public static final int				KEY_USB								= 0;
	public static final int				KEY_NET_FELICA						= 1;
	public static final int				KEY_FELICA							= 2;
	
	protected CheckSPKeyPanel				checkSPKeyPanel;
	protected CheckLoginUserPanelBase		checkLoginUserPanel;
	protected SPSAdminUserPanel			spsAdminUserPanel = null;
	protected SPSGeneralUserPanel			spsGeneralUserPanel;
	protected SPKeyRegisterPanel			spKeyRegisterPanel = null;
	protected CardLayout					layout;
	protected SPKeyInfoInvoker				invoker;
	protected UserInfoInvoker				userInvoker;
	protected SPKeyInfo					spKeyInfo;
	protected UserInfo2					userInfo;
	protected static boolean				preError = false;
	protected static boolean				ignoreUserServerCheck = false;
	protected static int					keyKind = KEY_UNKNOWN;
	protected ImagePanel					pnlBackground = null;
	protected String						msgIdle = "";
	protected String						msgNotAdminCard = "";
	protected String						msgOperation = "";
	
	private Timer							checkSPKeyTimer = null;
	private TimerTask						checkSPKeyTimerTask = null;
		
/*	static {
		System.loadLibrary("SPSJNI");
	}*/
	
	protected SPSMainBasePanel(JFrame frame, int kind) {
		super(frame, kind);
		
		buildComponents();
	}

	protected SPSMainBasePanel(JFrame frame, int kind, ImagePanel pnlBackground) {
		super(frame, kind);
		this.pnlBackground = pnlBackground;
		buildComponents();
	}
	
	protected SPSMainBasePanel(JApplet applet, int kind) {
		super(applet, kind);
		buildComponents();
	}
	
	protected SPSMainBasePanel(JApplet applet, int kind, ImagePanel pnlBackground) {
		super(applet, kind);
		this.pnlBackground = pnlBackground;
		buildComponents();
	}
	
	public CheckSPKeyPanel getCheckSPKeyPanel() {
		return checkSPKeyPanel;
	}
	
	public CheckLoginUserPanelBase getCheckLoginUserPanel() {
		return checkLoginUserPanel;
	}
	
	public SPSAdminUserPanel getSPSAdminUserPanel() {
		return spsAdminUserPanel;
	}
	
	public SPSGeneralUserPanel getSPSGeneralUserPanel() {
		return spsGeneralUserPanel;
	}
	
	public SPKeyRegisterPanel getSPKeyRegisterPanel() {
		return spKeyRegisterPanel;
	}
	
	protected void buildComponents() {
		super.buildComponents();
		invoker = SPKeyInfoInvoker.getInstance(net);
		userInvoker = UserInfoInvoker.getInstance(net);
		spKeyInfo = new SPKeyInfo();
		userInfo = new UserInfo2();
		
		layout = new CardLayout();
		setLayout(layout);
	}
	
	protected void startCheckSPKeyTimer(Net net, String msgConnection, int period) {
		if (Util.getPreferenceInfo().getAuthType() != PreferenceInfo.AUTH_LOGIN) {
			checkSPKeyTimer = new Timer(true);
			checkSPKeyTimerTask = new CheckSPKeyTimerTask(net, msgConnection);
			checkSPKeyTimer.schedule(checkSPKeyTimerTask, 0, period);
		}		
	}
	
	protected void cancelCheckSPKeyTimer() {
		checkSPKeyTimer.cancel();
	}
	
	protected void goCheckSPKeyPanel(String msg) {
		if (!checkSPKeyPanel.isShowing()) {
			checkSPKeyPanel.setMessage(msg);
			checkSPKeyPanel.beginPanel();
			layout.show(this, CHECK_SPKEY_PANEL);
		}
	}
	
	protected void goCheckLoginUserPanel(String msg) {
		if (!checkLoginUserPanel.isShowing()) {
			checkLoginUserPanel.setMessage(msg);
			try {
				checkLoginUserPanel.beginPanel();
			} catch (NetworkException e) {
			} catch (ServerException e) {
			} catch (TimeOutException e) {
			}
			layout.show(this, CHECK_LOGIN_USER_PANEL);
		}
	}
	
	protected void checkSPKey(Net net, String msgConnection) {
		int	ret = CHECKUSER_RET_NORMAL;
		CheckSPKeyPanel	checkPanel = (CheckSPKeyPanel)getCheckPanel();
		
		keyKind = KEY_UNKNOWN;

		try {
			switch (Util.getPreferenceInfo().getAuthType()) {
			case PreferenceInfo.AUTH_USB:
				ret = checkUSB(net, msgConnection);
				if (ret == CHECKUSER_RET_NORMAL) {
					keyKind = KEY_USB;
				}
				break;
			case PreferenceInfo.AUTH_NET_FELICA:
				ret = checkNetFelica(net, msgConnection);
				if (ret == CHECKUSER_RET_NORMAL) {
					keyKind = KEY_FELICA;
				}
				break;
			}

			if (ret == CHECKUSER_RET_CONNECTION_SKIP || ret == CHECKUSER_RET_CHECK_SKIP) {
				return;
			}
			if (kind == ADMIN) {
				if (!getMainPanel().isShowing()) {
					if (spKeyInfo.getUser().getPrivilegeInfo().getCategory() == PrivilegeInfo.PRIVILEGE_ADMIN) {
						// 娗棟幰梡僉乕偑憓偝傟偨偲偒娗棟夋柺傪昞帵
						goMainPanel(spKeyInfo);
					} else {
						// 娗棟幰埲奜偺僉乕偑憓偝傟偨偲偒丄僄儔乕偵偡傞
						preError = true;
						ignoreUserServerCheck = false;
						if (checkPanel != null) {
							checkPanel.setMessage(msgNotAdminCard);
						}
					}
				}
			} else {
				if (!getMainPanel().isShowing()) {
					goMainPanel(spKeyInfo);
				}
			}
		} catch (NoUSBException e) {
			// 僉乕偑憓偝傟偰偄側偄偲偒
			Util.debugPrint("NoUSBException detected: " + e.getMessage());
			goCheckPanel();
			if (checkPanel != null) {
				checkPanel.setMessage(msgIdle);
			}
		} catch (FelicaException e) {
			Util.debugPrint("FelicaException detected: " + e.getMessage());
			goCheckPanel();
			if (checkPanel != null) {
				checkPanel.setMessage(msgIdle);
			}
		} catch (NetworkException e) {
			// 僱僢僩儚乕僋僄儔乕偺偲偒
			Util.debugPrint("NetworkException detected: " + e.getMessage());
			goCheckPanel();
			if (checkPanel != null) {
				checkPanel.setMessage(Resource.getString(Resource.STATUS_NETWORK_ERROR));
			}
		} catch (NotRegisterSPKeyException e) {
			// 枹搊榐僉乕偑憓偝傟偨偲偒
			Util.debugPrint("NotRegisterUserException detected: " + e.getMessage());
			if (kind == ADMIN) {
				goRegPanel(spKeyInfo);
			} else {
				if (checkPanel != null) {
					checkPanel.setMessage(Resource.getString(Resource.STATUS_NOT_REGISTERED_SPKEY), new String[] { msgOperation });
				}
			}
		} catch (InvaliditySPKeyException e) {
			// 巊梡掆巭拞偺僉乕偑憓偝傟偨偲偒
			Util.debugPrint("InvaliditySPKeyException detected: " + e.getMessage());
			if (checkPanel != null) {
				checkPanel.setMessage(Resource.getString(Resource.STATUS_SPKEY_INVALIDITY), new String[] { msgOperation });
			}
		}
	}
	

⌨️ 快捷键说明

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