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

📄 jhylafax.java

📁 发送传真的program,发送传真的program,发送传真的program.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/** * JHylaFax - A java client for HylaFAX. * * Copyright (C) 2005 by Steffen Pingel <steffenp@gmx.de> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */package net.sf.jhylafax;import gnu.hylafax.HylaFAXClient;import gnu.inet.ftp.ConnectionEvent;import gnu.inet.ftp.ConnectionListener;import gnu.inet.ftp.ServerResponseException;import java.awt.BorderLayout;import java.awt.Font;import java.awt.Image;import java.awt.MenuItem;import java.awt.event.ActionEvent;import java.awt.event.KeyEvent;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.beans.PropertyChangeEvent;import java.beans.PropertyChangeListener;import java.io.BufferedInputStream;import java.io.BufferedOutputStream;import java.io.File;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import java.lang.reflect.InvocationTargetException;import java.net.URL;import java.util.List;import java.util.Locale;import java.util.MissingResourceException;import java.util.Properties;import javax.swing.Action;import javax.swing.JComponent;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JMenu;import javax.swing.JMenuBar;import javax.swing.JMenuItem;import javax.swing.JPanel;import javax.swing.JTabbedPane;import javax.swing.JTextArea;import javax.swing.JToolBar;import javax.swing.KeyStroke;import javax.swing.SwingUtilities;import javax.swing.UIManager;import javax.swing.plaf.basic.BasicBorders;import net.sf.jhylafax.JobHelper.StatusResponse;import net.sf.jhylafax.addressbook.AddressBook;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.apache.log4j.BasicConfigurator;import org.apache.log4j.PropertyConfigurator;import org.xnap.commons.gui.AboutDialog;import org.xnap.commons.gui.Builder;import org.xnap.commons.gui.Dialogs;import org.xnap.commons.gui.ErrorDialog;import org.xnap.commons.gui.action.AbstractXNapAction;import org.xnap.commons.gui.factory.DefaultFactory;import org.xnap.commons.gui.shortcut.ActionShortcut;import org.xnap.commons.gui.util.GUIHelper;import org.xnap.commons.gui.util.IconHelper;import org.xnap.commons.gui.util.LabelUpdater;import org.xnap.commons.gui.util.WhatsThisAction;import org.xnap.commons.i18n.I18n;import org.xnap.commons.i18n.I18nFactory;import org.xnap.commons.i18n.I18nManager;import org.xnap.commons.io.Job;import org.xnap.commons.io.ProgressMonitor;import org.xnap.commons.io.UserAbortException;import org.xnap.commons.settings.SettingStore;import org.xnap.commons.util.FileHelper;/** * The main class, that provides the main window as well as the network connection. *  * @author Steffen Pingel */@SuppressWarnings("serial")public class JHylaFAX extends JFrame implements LocaleChangeListener {	public final static I18n i18n = I18nFactory.getI18n(JHylaFAX.class);	public final static String JDK14_LOG_CONFIG_KEY = "java.util.logging.config.file";	public final static Locale[] SUPPORTED_LOCALES = { 		Locale.ENGLISH,		/*new Locale("bg"),*/        new Locale("ca"),         new Locale("cs"),         new Locale("de"),        new Locale("es"),         new Locale("fr"),         new Locale("it"),        /*new Locale("hu"),*/        new Locale("nl"),         /* new Locale("ko"), */        new Locale("pl"),         new Locale("pt", "BR"),         new Locale("ru"),         new Locale("sv"),        new Locale("tr"), 	};	private final static Log logger = LogFactory.getLog(JHylaFAX.class);	private static final int BUFFER_SIZE = 1024 * 512;	private static JHylaFAX app;	private static String version;	private JTabbedPane mainTabbedPane;	private JMenu fileMenu;	private SettingsDialogAction settingsDialogAction;	private JPanel statusBarPanel;	private JLabel statusLabel;	private JLabel serverInfoLabel;	private ExitAction exitAction;	private UpdateStatusAction updateStatusAction;	private HylaFAXClient connection;	private JToolBar mainToolBar;	private SendAction sendAction;	private PollAction pollAction;	private JMenu helpMenu;	private AboutAction aboutAction;	private String password;	private String adminPassword;	private ConnectionHandler connectionHandler = new ConnectionHandler();	private ActionShortcut sendActionShortcut;	private AddressBook addressBook;	private AddressBookAction addressBookAction;	private ActionShortcut updateStatusActionShortcut;	private ReceiveQueuePanel recvqPanel;	private JobQueuePanel sendqPanel;	private JobQueuePanel pollqPanel;	private JobQueuePanel doneqPanel;	private DocumentQueuePanel docqPanel;	private SettingsWizardAction settingsWizardAction;	private JobQueue jobQueue = new JobQueue();	private NotificationTimer notificationTimer = new NotificationTimer();	private File addressBookFile;	private Object connectionLock = new Object();	private FaxTray tray;    	public JHylaFAX() {		app = this;				try {			Settings.load(getSettingsFile());			// XXX load does not trigger a property change event, therefore			// this needs to be updated manually			Settings.DEFAULT_COMPLETION_MODE.updateMode();		}		catch (FileNotFoundException e) {			logger.debug("Error loading settings", e);			// ignore, probably the first time		}		catch (IOException e) {			logger.debug("Error loading settings", e);			ErrorDialog.showError(this, i18n.tr("Could not load settings"),					i18n.tr("JHylaFAX Error"),					e);		}		        updateResourceBundle();        I18nManager.getInstance().addLocaleChangeListener(new LabelUpdater());	        IconHelper.classLoader = JHylaFAX.class.getClassLoader();        		initializeToolkit();		initialize();				restoreLayout();				PropertyChangeListener disconnector = new PropertyChangeListener() {			public void propertyChange(PropertyChangeEvent evt) {				if (connection != null) {					try {						connection.quit();					}					catch (Exception e) {						logger.debug("Error closing connection", e);					}					connection = null;				}			}					};		Settings.HOSTNAME.addPropertyChangeListener(disconnector);		Settings.PORT.addPropertyChangeListener(disconnector);		Settings.USE_PASSIVE.addPropertyChangeListener(disconnector);		Settings.USERNAME.addPropertyChangeListener(disconnector);				Settings.LOCALE.addPropertyChangeListener(new PropertyChangeListener() {			public void propertyChange(PropertyChangeEvent evt) {				updateResourceBundle();			}		});				notificationTimer.settingsUpdated();	}		private void restoreLayout() {		SettingStore store = new SettingStore(Settings.backstore);		store.restoreWindow("window.main", 40, 40, 540, 400, this);		recvqPanel.restoreLayout(store, new String[] { "sender", "pages", "time", "filename", "filesize", "error" });		sendqPanel.restoreLayout(store, new String[] { "id", "priority", "sender", "number", "dials", "pages", "error", "state" });		pollqPanel.restoreLayout(store, new String[] { "id", "priority", "sender", "number", "dials", "pages", "error", "state" });		doneqPanel.restoreLayout(store, new String[] { "id", "priority", "sender", "number", "dials", "pages", "error", "state" });		docqPanel.restoreLayout(store, new String[] { "permissions", "owner", "modified", "filename", "filesize", "time" });	}		private void saveLayout() {		SettingStore store = new SettingStore(Settings.backstore);		store.saveWindow("window.main", this);		recvqPanel.saveLayout(store);		sendqPanel.saveLayout(store);		pollqPanel.saveLayout(store);		doneqPanel.saveLayout(store);		docqPanel.saveLayout(store);	}		private void updateResourceBundle() {		try {			I18nManager.getInstance().setDefaultLocale(Settings.LOCALE.getValue());        }		catch (MissingResourceException e) {			logger.warn("Error loading resource bundle", e);		}	}	public static void initializeToolkit()	{		// configure UI properties		UIManager.put("swing.boldMetal", Boolean.FALSE);		UIManager.put("SplitPaneDivider.border", 					  new BasicBorders.MarginBorder());			UIManager.put("TitledBorder.font", UIManager.getFont("Label.font").deriveFont(Font.BOLD));		UIManager.put("TitledBorder.titleColor", UIManager.getColor("Label.foreground").brighter());				Builder.setProperty(DefaultFactory.ENHANCED_TEXT_FIELD_MENU_KEY, true);	}		private void initialize() {		initializeIcon();		initializeActions();		initializeShortCuts();		initializeMenuBar();		initializeContent();		initializeToolBar();		initializeStatusBar();		initializeSystemTray();				updateLabels();				updateServerInfo();	}	private void initializeIcon() {		List<? extends Image> images = IconHelper.getApplicationIcons("kdeprintfax.png");		if (images != null) {			setIconImages(images);		}	}	private void initializeActions() {		updateStatusAction = new UpdateStatusAction();		settingsDialogAction = new SettingsDialogAction();		settingsWizardAction = new SettingsWizardAction();		addressBookAction = new AddressBookAction();		exitAction = new ExitAction();		sendAction = new SendAction();		pollAction = new PollAction();		aboutAction = new AboutAction();	}		private void initializeShortCuts() {		sendActionShortcut = new ActionShortcut(sendAction);		sendActionShortcut.setKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK));		updateStatusActionShortcut = new ActionShortcut(updateStatusAction);		updateStatusActionShortcut.setKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));	}		private void initializeContent() {		setTitle("JHylaFAX");		setLayout(new BorderLayout());		addWindowListener(new WindowAdapter() {			public void windowClosing(WindowEvent event) {				exit();			}		});				mainTabbedPane = new JTabbedPane();		mainTabbedPane.setBorder(GUIHelper.createEmptyBorder(10));		getContentPane().add(mainTabbedPane, BorderLayout.CENTER);		recvqPanel = new ReceiveQueuePanel("recvq");		mainTabbedPane.addTab("", IconHelper.getTabTitleIcon("folder_inbox.png"), recvqPanel);				sendqPanel = new JobQueuePanel("sendq");		mainTabbedPane.addTab("", IconHelper.getTabTitleIcon("folder_outbox.png"), sendqPanel);		doneqPanel = new JobQueuePanel("doneq");		mainTabbedPane.addTab("", IconHelper.getTabTitleIcon("folder_sent_mail.png"), doneqPanel);		pollqPanel = new JobQueuePanel("pollq");		if (Settings.SHOW_POLLQ.getValue()) {			mainTabbedPane.addTab("", IconHelper.getTabTitleIcon("folder_print.png"), pollqPanel);		}		docqPanel = new DocumentQueuePanel("docq");		mainTabbedPane.addTab("", IconHelper.getTabTitleIcon("folder_txt.png"), docqPanel);	}		private void initializeSystemTray()	{		tray = new FaxTray();				if (tray.isSupported()) {			tray.getPopupMenu().add(new MenuItem((String) exitAction.getValue(Action.NAME)));		}	}

⌨️ 快捷键说明

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