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

📄 spoolerpanel.java

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

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JApplet;
import javax.swing.JFrame;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import jp.co.ntl.Net;
import jp.co.ntl.Util;
import jp.co.ntl.NetworkException;
import jp.co.ntl.ServerException;
import jp.co.ntl.TimeOutException;
import jp.co.ntl.ActionEventConstants;
import jp.co.ntl.swing.TabbedPane;
import jp.co.ntl.swing.ext.MsgUtil;

public class SpoolerPanel extends AbstractSpoolerPanel implements ActionListener, ChangeListener {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private static final int				IDX_TAB_WAIT_QUEUE		= 0;
	private static final int				IDX_TAB_PRINTED_QUEUE	= 1;
	
	private TabbedPane						tab;
	private WaitQueuePanel					waitQueuePanel;
	private PrintedQueuePanel				printedQueuePanel;
	
	public SpoolerPanel(JFrame parent, Net net, boolean admin, Object info) {
		super(parent, net, admin, info);
	}
	
	public SpoolerPanel(JApplet appl, Net net, boolean admin, Object info) {
		super(appl, net, admin, info);
	}
	
	protected void buildComponents() {
		Resource.load(loc);

	    tab = new TabbedPane();

	    waitQueuePanel = new WaitQueuePanel(parent, this, net, admin, keyInfo);
	    printedQueuePanel = new PrintedQueuePanel(parent, this, net, admin, keyInfo);
	    
	    tab.addTab(Resource.getString(Resource.TAB_WAITQUEUE), waitQueuePanel);
	    tab.addTab(Resource.getString(Resource.TAB_PRINTEDQUEUE), printedQueuePanel);
	    
	    add(tab, BorderLayout.CENTER);
	    
	    startGetSpoolerInfoTimer(true, SPOOLERTHREAD_PERIOD);
	    
///	    waitQueuePanel.addActionListener(this);
///	    printedQueuePanel.addActionListener(this);
	    tab.addChangeListener(this);
	    waitQueuePanel.addActionListener(this);
	    printedQueuePanel.addActionListener(this);
	}
	
	public void beginPanel(Object info, boolean bInit, String targetPrinterName) throws NetworkException, ServerException, TimeOutException {
		this.targetPrinterName = targetPrinterName;
		this.keyInfo = info;
		start();
	}
	
	public boolean start() {
		try {
			waitQueuePanel.beginPanel(keyInfo);
			printedQueuePanel.beginPanel(keyInfo);
		} catch (NetworkException e) {
			sendActionEvent(MsgUtil.getMessage(MsgUtil.ERROR_NETWORK, null));
		} catch (ServerException e) {
			sendActionEvent(MsgUtil.getMessage(MsgUtil.ERROR_SERVER, null));
		} catch (TimeOutException e) {
		}
		
		int		idx = tab.getSelectedIndex();
		if (!bInit[idx]) {
			sendActionEvent(MsgUtil.getMessage(MsgUtil.MSG_GETTING_SPOOL_INFO, null));
			setExecGetSpoolerInfo();
		}
		
		return true;
	}
	
	public void finalize() throws Throwable {
		cancelGetSpoolerInfoTimer();
		
		super.finalize();
	}
	
	public void actionPerformed(ActionEvent ae) {
		Object	obj = ae.getSource();
		
		if (obj == waitQueuePanel) {
/*			String	cmd = waitQueuePanel.getActionCommand();
			if (cmd.equals(ACTCMD_REFRESH_SPOOLER)) {
				sendActionEvent(MsgUtil.getMessage(MsgUtil.MSG_GETTING_SPOOL_INFO, null));
				doRefresh();
			} else {
				sendActionEvent(waitQueuePanel.getActionCommand());
			}*/
			sendActionEvent(ActionEventConstants.ACTCMD_RESET_SESSION_TIMER);
		} else if (obj == printedQueuePanel) {
/*			String	cmd = printedQueuePanel.getActionCommand();
			if (cmd.equals(ACTCMD_REFRESH_SPOOLER)) {
				sendActionEvent(MsgUtil.getMessage(MsgUtil.MSG_GETTING_SPOOL_INFO, null));
				doRefresh();
			} else {
				sendActionEvent(printedQueuePanel.getActionCommand());
			}*/
			sendActionEvent(ActionEventConstants.ACTCMD_RESET_SESSION_TIMER);
		}
	}
	
	public void stateChanged(ChangeEvent ce) {
		Object	obj = ce.getSource();
		
		if (obj == tab) {
			sendActionEvent(ActionEventConstants.ACTCMD_RESET_SESSION_TIMER);
			start();
		}
	}
	
	public int getInfosFromServer() {
		int		result = GET_INFO_RESULT_NORMAL;
		
		// 捠怣拞偺偲偒僗僉僢僾
		if (net.isConnected()) {
			Util.debugPrint("Get Job Infomation skip  Class = " + getClass());
			return GET_INFO_RESULT_WAIT;
		}
		
		int			idx = tab.getSelectedIndex();
		if (idx == IDX_TAB_WAIT_QUEUE) {
			Util.debugPrint("Get Job Infomation (Wait)");
			
			try {
///				sendActionEvent(MsgUtil.getMessage(MsgUtil.MSG_GETTING_SPOOL_INFO, null));
				waitQueuePanel.getSpoolerInfo();
			} 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) {
			}
		} else if (idx == IDX_TAB_PRINTED_QUEUE){
			Util.debugPrint("Get Job Infomation (Printed)");
			
			try {
///				sendActionEvent(MsgUtil.getMessage(MsgUtil.MSG_GETTING_SPOOL_INFO, null));
				printedQueuePanel.getSpoolerInfo();
			} 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) {
			bInit[idx] = true;
			sendActionEvent(MsgUtil.getMessage(MsgUtil.MSG_IDLE, null));
		}
		
		return result;
	}
}

⌨️ 快捷键说明

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