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

📄 jremservergui.java

📁 JRemoteControl is a simple Java&#8482 driven bluetooth remote control.It allows you to initiate virt
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* * JRemCntl - Copyright (C) 2007 Filippo Di Vattimo <fildiv@gmail.com> * See COPYING */package fildiv.jremcntl.server.gui.app;import java.awt.BorderLayout;import java.awt.Color;import java.awt.ComponentOrientation;import java.awt.Cursor;import java.awt.Dimension;import java.awt.Event;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.Point;import java.awt.event.KeyEvent;import java.awt.event.WindowEvent;import java.awt.event.WindowListener;import java.io.File;import java.net.URL;import java.util.Hashtable;import java.util.Iterator;import java.util.Map;import javax.swing.Action;import javax.swing.BorderFactory;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JCheckBoxMenuItem;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JMenu;import javax.swing.JMenuBar;import javax.swing.JMenuItem;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JSplitPane;import javax.swing.JTabbedPane;import javax.swing.JToolBar;import javax.swing.KeyStroke;import javax.swing.SwingUtilities;import javax.swing.UIManager;import javax.swing.border.BevelBorder;import javax.swing.border.SoftBevelBorder;import fildiv.jremcntl.common.core.Config;import fildiv.jremcntl.common.core.ConfigIntegrityInfo;import fildiv.jremcntl.common.core.JRemRuntimeException;import fildiv.jremcntl.common.core.Logger;import fildiv.jremcntl.common.util.JRemUtils;import fildiv.jremcntl.server.core.AppConfiguration;import fildiv.jremcntl.server.core.JRemEnv;import fildiv.jremcntl.server.gui.core.CmdUI;import fildiv.jremcntl.server.gui.core.DocModifiedContent;import fildiv.jremcntl.server.gui.core.DocumentAttachedEvent;import fildiv.jremcntl.server.gui.core.DocumentDetachedEvent;import fildiv.jremcntl.server.gui.core.DocumentEvent;import fildiv.jremcntl.server.gui.core.DocumentListener;import fildiv.jremcntl.server.gui.core.DocumentModifiedEvent;import fildiv.jremcntl.server.gui.core.Frame;import fildiv.jremcntl.server.gui.core.JRemUIManager;import fildiv.jremcntl.server.gui.model.JRemCommandDoc;import fildiv.jremcntl.server.gui.model.JRemConfigDoc;import fildiv.jremcntl.server.gui.model.JRemContextDoc;import fildiv.jremcntl.server.gui.model.JRemGUIDoc;import fildiv.jremcntl.server.gui.model.JRemServerDoc;import fildiv.jremcntl.server.gui.util.swing.JRemAbstractAction;import fildiv.jremcntl.server.gui.util.swing.JRemAbstractToggleAction;import fildiv.jremcntl.server.gui.util.swing.MouseOverHintManager;import fildiv.jremcntl.server.gui.util.swing.StatusBar;import fildiv.jremcntl.server.gui.util.swing.SwingUtils;public class JRemServerGUI implements Frame {	private final int MAIN_TAB_EDITOR = 0;	private final int MAIN_TAB_SERVER = 1;	private JRemUIManager uiMng;		private JRemEnv env = null;	private JFrame jFrame = null; // @jve:decl-index=0:visual-constraint="40,10"	private JMenuBar jMenuBar = null;	private JMenu fileMenu = null;	private JMenu editMenu = null;	private JMenu serverMenu = null;	private JMenu helpMenu = null;	private JMenuItem exitMenuItem = null;	private JMenuItem aboutMenuItem = null;		private JMenuItem helpMenuItem = null;	private JMenuItem consoleMenuItem = null;	private JMenuItem newMenuItem = null;	private JMenuItem openMenuItem = null;	private JMenuItem saveMenuItem = null;	private JMenuItem saveAsMenuItem = null;	private JMenuItem addMenuCtxItem = null;	private JMenuItem addMenuCmdItem = null;	private JMenuItem editPreferencesItem = null;	private JMenuItem remMenuItem = null;	private JMenuItem startServerMenuItem = null;	private JMenuItem stopServerMenuItem = null;	private JMenuItem clearServerOutputMenuItem = null;	private JCheckBoxMenuItem showServerOutMenuItem = null;	private JCheckBoxMenuItem showServerStdOutMenuItem = null;	private JCheckBoxMenuItem showServerStdErrMenuItem = null;	private JPanel jPanelMain = null;	private JTabbedPane jTabbedPane = null;	private JSplitPane jSplitPane = null;	private JScrollPane jScrollPane = null;	private JRemConfigView jRemConfigView = null;	private JRemGUIDoc guiDoc;	private Map cmdActionsMap;	private UIServerEventsListener uiServerEventsListener;		private MouseOverHintManager mouseHintMgn;	private DocumentListener listener = new DocumentListener() {		public void actionPerformed(DocumentEvent event) {			JRemServerGUI.this.actionPerformed(event);		}	};	private JToolBar jToolBarBar = null;	private JButton newJButton = null;	private JButton openJButton;	private JButton infoJButton;	private JButton saveJButton;	private JButton saveAsJButton;	private JButton exitJButton;	private JButton addJButtonCtx;	private JButton addJButtonCmd;	private JButton startServerJButton;	private JButton stopServerJButton;	private JButton remJButton;	private JRemContextDoc currContext = null;	private JRemCommandDoc currCommand = null;	private JRemConfigViewListener configViewListener = new JRemConfigViewListener() {		public void configRootSelected() {			currContext = null;			currCommand = null;			JRemConfigDoc configDoc = guiDoc.getConfigDoc();			getJRemPropertyEditorView().setDocument(configDoc);			getJRemExtensionView().setDocument(configDoc);			getJRemEventsView().setDocument(configDoc);			updateUI();		}		public void commandSelected(JRemCommandDoc command) {			currContext = (JRemContextDoc) command.getContext();			currCommand = command;			getJRemPropertyEditorView().setDocument(currCommand);			getJRemExtensionView().setDocument(currCommand);			updateUI();		}		public void contextSelected(JRemContextDoc context) {			currContext = context;			currCommand = null;			getJRemPropertyEditorView().setDocument(currContext);			getJRemExtensionView().setDocument(currContext);			updateUI();		}	};	private boolean updatingView;	private Logger logger;	private JRemServerGUI XYZ = null; // @jve:decl-index=0:	private JRemServerGUI XYZ1 = null;	private JTabbedPane jTabbedPane1Edit = null;	private JSplitPane jSplitPane1EditProperties = null;	private JRemPropertyEditorView jRemPropertyEditorView = null;	private JRemExtensionView jRemExtensionView = null;	private JPanel jPanelServer = null;	private JScrollPane jScrollPane1ServerView = null;	private JRemServerView jRemServerView = null;	private StatusBar statusBar = null;	private JRemEventsView jRemEventsView = null;	protected JRemServerGUI() {		this.env = JRemEnv.getInstance();		this.uiMng = new JRemUIManager(this);		this.uiServerEventsListener =  new UIServerEventsListener(uiMng);				this.logger = env.getLogger();		setLookAndFeel();		registerActions();				guiDoc = new JRemGUIDoc();		guiDoc.addActionListener(listener);		guiDoc.getServerDoc().addServerEventsListener(				uiServerEventsListener);		getJRemServerView().setDocument(guiDoc.getServerDoc());		applyStartupSettings();		selectStartNode();		initHintsManager();		updateUI();	}	protected JRemUIManager getUIManager() {		return uiMng;	}			protected void show() {		JFrame mainFrame = getJFrame();		mainFrame.setIconImage(uiMng.getImageIcon().getImage());		mainFrame.setSize(800, 600);		mainFrame.setVisible(true);		afterGUIup();	}	private void afterGUIup() {		JRemConsole.getInstance(getJFrame());		if (JRemConsole.hasErrors()) {			SwingUtils.showMessage(getJFrame(), env,					"There was some errors during startup!");			JRemConsole.showConsole();		}	}	private void initHintsManager() {		getJFrame();		this.mouseHintMgn = new MouseOverHintManager(statusBar);		mouseHintMgn.enableHints(getJToolBarBar());		mouseHintMgn.enableHints(getJMenuBar());	}	private void selectStartNode() {		getJRemConfigView().select(guiDoc.getConfigDoc());		getJRemConfigView().expandAll(true);	}	private void applyStartupSettings() {		try {			AppConfiguration conf = env.getAppConfiguration();			if (conf.isReloadLastConfigOnStartup()) {				String configFilePath = conf.getLastConfigFilePath();				if (!"".equals(configFilePath)) {					guiDoc.loadConfig(configFilePath);					if (conf.isStartServerOnStartup()) {						startServer(configFilePath);					}				}			}		} catch (Exception e) {			logger.error(e);			SwingUtils.showErrorMessage(env, getJFrame(),					"Error reading default configuration settings.");		}	}	private void registerActions() {		cmdActionsMap = new Hashtable();		cmdActionsMap.put("SAVE", new JRemAbstractAction(env, jFrame) {			public void executeCmd() {				onSaveCommand();			}			public void updateUI(CmdUI cmdUI) {				cmdUI.setShortDesc("Save ...");				cmdUI.setLongDesc("Save current configuration ...");				if (guiDoc == null)					return;				cmdUI.setEnabled(guiDoc.isModified());			}		});		cmdActionsMap.put("SAVE_AS", new JRemAbstractAction(env, jFrame) {			public void executeCmd() {				onSaveAsCommand();			}			public void updateUI(CmdUI cmdUI) {				cmdUI.setShortDesc("Save As ...");				cmdUI						.setLongDesc("Save current configuration in a new file ...");				if (guiDoc == null)					return;				cmdUI.setEnabled(true);			}		});		cmdActionsMap.put("OPEN", new JRemAbstractAction(env, jFrame) {			public void executeCmd() {				onOpenCommand();			}			public void updateUI(CmdUI cmdUI) {				cmdUI.setShortDesc("Open ...");				cmdUI.setLongDesc("Open a saved configuration ...");				cmdUI.setEnabled(true);			}		});		cmdActionsMap.put("NEW", new JRemAbstractAction(env, jFrame) {			public void executeCmd() {				onNewCommand();			}			public void updateUI(CmdUI cmdUI) {				cmdUI.setShortDesc("New");				cmdUI.setLongDesc("Create a new configuration");				cmdUI.setEnabled(true);			}		});		cmdActionsMap.put("ADD_CMD", new JRemAbstractAction(env, jFrame) {			public void executeCmd() {				onAddCommandCommand();			}			public void updateUI(CmdUI cmdUI) {				cmdUI.setShortDesc("Add new command");				cmdUI						.setLongDesc("Add a new command after the current position");				cmdUI.setEnabled(currContext != null);			}		});		cmdActionsMap.put("ADD_CXT", new JRemAbstractAction(env, jFrame) {			public void executeCmd() {				onAddContextCommand();			}			public void updateUI(CmdUI cmdUI) {				cmdUI.setShortDesc("Add new context");				cmdUI.setLongDesc("Add new context after the current position");				cmdUI.setEnabled(true);			}		});		cmdActionsMap.put("REMOVE", new JRemAbstractAction(env, jFrame) {			public void executeCmd() {				onRemoveCommand();			}			public void updateUI(CmdUI cmdUI) {				cmdUI.setShortDesc("Delete selected item");				cmdUI.setLongDesc("Delete the selected item");				cmdUI						.setEnabled((currContext != null)								|| (currCommand != null));			}		});		cmdActionsMap.put("ABOUT", new JRemAbstractAction(env, jFrame) {			public void executeCmd() {				onAboutCommand();			}			public void updateUI(CmdUI cmdUI) {				cmdUI.setShortDesc("About ...");				cmdUI.setLongDesc("Show about dialog ...");				cmdUI.setEnabled(true);			}		});		cmdActionsMap.put("HELP", new JRemAbstractAction(env, jFrame) {			public void executeCmd() {				onHelpCommand();			}			public void updateUI(CmdUI cmdUI) {				cmdUI.setShortDesc("Help contents ...");				cmdUI.setLongDesc("Show help contents ...");				cmdUI.setEnabled(true);			}		});		cmdActionsMap.put("CONSOLE", new JRemAbstractAction(env, jFrame) {			public void executeCmd() {				onConsoleCommand();			}			public void updateUI(CmdUI cmdUI) {				cmdUI.setShortDesc("Console ...");				cmdUI.setLongDesc("Show console dialog ...");				cmdUI.setEnabled(true);			}		});		cmdActionsMap.put("EXIT", new JRemAbstractAction(env, jFrame) {			public void executeCmd() {				onExitCommand();			}			public void updateUI(CmdUI cmdUI) {				cmdUI.setShortDesc("Close");				cmdUI.setLongDesc("Close application");				cmdUI.setEnabled(true);

⌨️ 快捷键说明

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