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

📄 abstractspoolerpanel.java

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

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.ServerException;
import jp.co.ntl.TimeOutException;
import jp.co.ntl.swing.BasePanel;

public abstract class AbstractSpoolerPanel extends BasePanel {
	public static final int				SPOOLERTHREAD_PERIOD	= 5000;

	protected Object						keyInfo = null;
	protected boolean						admin;
	protected boolean[]					bInit = {false, false};
	protected String						targetPrinterName = null;
	
	private Timer							getSpoolerInfoTimer = null;
	private GetSpoolerInfoTimerTask		getSpoolerInfoTimerTask = null;

	public AbstractSpoolerPanel() {
	}
	
	public AbstractSpoolerPanel(JFrame parent, Net net, boolean admin, Object info) {
		this.parent = parent;
		commonConstractor(net, admin, info);
	}
	
	public AbstractSpoolerPanel(JApplet appl, Net net, boolean admin, Object info) {
		this.app = appl;
		commonConstractor(net, admin, info);
	}
	
	protected void commonConstractor(Net net, boolean admin, Object info) {
		this.net = net;
		this.admin = admin;
		this.keyInfo = info;
		this.bInit = new boolean[] {false, false};
		buildComponents();		
	}
	
	public void beginPanel() throws NetworkException, ServerException, TimeOutException {
	}

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

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

	protected boolean doRegister() throws NetworkException, ServerException, TimeOutException {
		return true;
	}
	
	protected void setPopupMenuState() {
	}
	
	public Object getKeyInfo() {
		return keyInfo;
	}
	
	public void setKeyInfo(Object info) {
		this.keyInfo = info;
	}
	
	public boolean isAdmin() {
		return admin;
	}
	
	public void setAdmin(boolean admin) {
		this.admin = admin;
	}
	
	public void startGetSpoolerInfoTimer(boolean ignoreGetSpoolerInfo, int period) {
		getSpoolerInfoTimer = new Timer(true);
		getSpoolerInfoTimerTask = new GetSpoolerInfoTimerTask(ignoreGetSpoolerInfo);
		getSpoolerInfoTimer.schedule(getSpoolerInfoTimerTask, 0, period);
	}
	
	public void cancelGetSpoolerInfoTimer() {
		if (getSpoolerInfoTimer != null) {
			getSpoolerInfoTimer.cancel();
		}
	}
	
	public boolean isGetSpoolerInfoTimerStarted() {
		if (getSpoolerInfoTimer != null) {
			return true;
		}
		
		return false;
	}
	
	public void setIgnoreGetSpoolerInfo() {
		getSpoolerInfoTimerTask.setIgnoreGetSpoolerInfo();
	}
	
	public void setExecGetSpoolerInfo() {
		getSpoolerInfoTimerTask.setExecGetSpoolerInfo();
	}
	
	private class GetSpoolerInfoTimerTask extends TimerTask {
		private boolean	ignoreGetSpoolerInfo = false;
		
		public GetSpoolerInfoTimerTask(boolean ignoreGetSpoolerInfo) {
			this.ignoreGetSpoolerInfo = ignoreGetSpoolerInfo;
		}

		public void run() {
			if (!ignoreGetSpoolerInfo) {
				getInfosFromServer();
			}
		}
		
		public void setIgnoreGetSpoolerInfo() {
			ignoreGetSpoolerInfo = true;
		}
		
		public void setExecGetSpoolerInfo() {
			ignoreGetSpoolerInfo = false;
		}
	}
	
	public abstract void beginPanel(Object info, boolean bInit, String targetPrinterName) throws NetworkException, ServerException, TimeOutException;
	public abstract boolean start();
	protected abstract void buildComponents();
	public abstract int getInfosFromServer();
}

⌨️ 快捷键说明

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