📄 jremoptioneditor.java
字号:
/* * JRemCntl - Copyright (C) 2007 Filippo Di Vattimo <fildiv@gmail.com> * See COPYING */package fildiv.jremcntl.server.gui.app;import java.awt.Color;import java.awt.Dimension;import java.awt.Frame;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.Point;import java.util.List;import javax.swing.BorderFactory;import javax.swing.DefaultListModel;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JDialog;import javax.swing.JLabel;import javax.swing.JList;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTabbedPane;import javax.swing.JTextArea;import javax.swing.border.LineBorder;import javax.swing.border.TitledBorder;import javax.swing.event.ListSelectionEvent;import javax.swing.event.ListSelectionListener;import fildiv.jremcntl.server.core.AppConfiguration;import fildiv.jremcntl.server.core.AppExtension;import fildiv.jremcntl.server.core.ExtensionLoader;import fildiv.jremcntl.server.core.JRemEnv;import fildiv.jremcntl.server.core.JRemExtension;public class JRemOptionEditor extends JDialog { private JTextArea extDescTextArea; private JScrollPane scrollPane; private JList extListbox; private JLabel descriptionLabel; private JList list; private JPanel panel; private JCheckBox jCbRestoreOnCmdError; private JCheckBox jCbRestoreOnError; private static final long serialVersionUID = 1L; private JPanel jContentPane = null; private JButton jButtonCancel = null; private JButton jButtonOK = null; private JRemEnv env; private AppConfiguration conf; private JTabbedPane jTabbedPane = null; private JPanel jPanelGeneral = null; private JPanel jPanelBottom = null; private JCheckBox jCbReloadLastOnCfgStartup = null; private JCheckBox jCbStartServerOnStartup = null; private JPanel jPanelStartup = null; private JPanel jPanelServer = null; private JCheckBox jCbMinimizeOnConnect = null; private JLabel jLabel = null; private JLabel jLabel1 = null; private JCheckBox jCheckBoxSwitchServerOut = null; private JCheckBox jCbMinimizeOnSystemTray = null; private JCheckBox jCbSuppressServerOutputIfMinimized = null; public static void openEditor(Frame frame) { JDialog dialog = new JRemOptionEditor(frame); dialog.pack(); Point loc = frame.getLocation(); loc.translate(20, 20); dialog.setLocation(loc); dialog.setModal(true); dialog.setVisible(true); } /** * @param owner */ public JRemOptionEditor(Frame owner) { super(owner); this.env = JRemEnv.getInstance(); this.conf = env.getAppConfiguration(); initialize(); setTitle("Edit options dialog ..."); setupInitialState(); } private void setupInitialState() { setupGeneralState(); setupExtension(); } private void setupExtension() { List extsList = env.getAppExtensions().asList(); JList jl = getExtListbox(); DefaultListModel lm = new DefaultListModel(); jl.setModel(lm); lm.removeAllElements(); for (int index = 0; index < extsList.size(); ++index) { AppExtension ext = (AppExtension) extsList.get(index); lm.addElement(ext); } } private void setupGeneralState() { getJCbStartServerOnStartup().setSelected( conf.isStartServerOnStartup()); getJCbReloadLastOnCfgStartup().setSelected( conf.isReloadLastConfigOnStartup()); getJCbMinimizeOnConnect().setSelected( conf.isMinimizeGUIOnConnect()); getJCbRestoreOnError().setSelected( conf.isRestoreGUIOnError()); getJCbRestoreOnCmdError().setSelected( conf.isRestoreGUIOnCmdError()); getJCheckBoxSwitchServerOut().setSelected( conf.isSwitchAutServerOut()); getJCbMinimizeOnSystemTray().setSelected(conf.isGUIMinimizeInTray()); getJCbSuppressServerOutputIfMinimized().setSelected( conf.isSuppressServerOutputWhenGUINotVisible()); } private void applyChanges() { applyGeneralChanges(); } /** * */ private void applyGeneralChanges() { conf.setStartServerOnStartup(getJCbStartServerOnStartup().isSelected()); conf.setReloadLastConfigOnStartup(getJCbReloadLastOnCfgStartup().isSelected()); conf.setMinimizeGUIOnConnect(getJCbMinimizeOnConnect().isSelected()); conf.setRestoreGUIOnError(getJCbRestoreOnError().isSelected()); conf.setRestoreGUIOnCmdError(getJCbRestoreOnCmdError().isSelected()); conf.setSwitchAutServerOut(getJCheckBoxSwitchServerOut().isSelected()); conf.setGUIMinimizeInTray(getJCbMinimizeOnSystemTray().isSelected()); conf.setSuppressServerOutputWhenGUINotVisible( getJCbSuppressServerOutputIfMinimized().isSelected()); } protected void onOKButton() { applyChanges(); dispose(); } protected void onCancelButton() { dispose(); } protected void onExtensionSelected() { JList lb = getExtListbox(); DefaultListModel lm = (DefaultListModel) lb.getModel(); AppExtension appExt = (AppExtension) lb.getSelectedValue(); ExtensionLoader loader = env.getExtensionLoader(); JRemExtension ext = loader.getExtension(appExt.getClassName()); fillExtensionInfo(ext); } private void fillExtensionInfo(JRemExtension ext) { StringBuffer info = new StringBuffer(); info.append("\n"); info.append("Name: " + ext.getName()); info.append("\n"); info.append("Id: " + ext.getID()); info.append("\n"); info.append("Vendor: " + ext.getVendor()); info.append("\n"); info.append("Version: " + ext.getVersion()); info.append("\n"); info.append("\n"); info.append("Description:"); info.append("\n"); info.append("\n"); info.append(ext.getDescription()); JTextArea ta = getExtDescTextArea(); ta.setText(info.toString()); ta.setCaretPosition(0); } /** * This method initializes this * * @return void */ private void initialize() { this.setSize(581, 500); this.setContentPane(getJContentPane()); } /** * This method initializes jContentPane * * @return javax.swing.JPanel */ private JPanel getJContentPane() { if (jContentPane == null) { GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); gridBagConstraints3.gridx = 8; gridBagConstraints3.anchor = GridBagConstraints.EAST; gridBagConstraints3.insets = new Insets(2, 2, 2, 2); gridBagConstraints3.gridy = 2; GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.weighty = 1.0; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.gridy = 0; gridBagConstraints.weightx = 1.0; gridBagConstraints.gridwidth = 7; gridBagConstraints.gridx = 2; jContentPane = new JPanel(); jContentPane.setLayout(new GridBagLayout()); jContentPane.add(getJTabbedPane(), gridBagConstraints); jContentPane.add(getJPanelBottom(), gridBagConstraints3); } return jContentPane; } /** * This method initializes jButtonCancel * * @return javax.swing.JButton */ private JButton getJButtonCancel() { if (jButtonCancel == null) { jButtonCancel = new JButton(); jButtonCancel.setMaximumSize(new Dimension(80, 30)); jButtonCancel.setPreferredSize(new Dimension(80, 30)); jButtonCancel.setMinimumSize(new Dimension(80, 30)); jButtonCancel.setPreferredSize(new Dimension(80, 30)); jButtonCancel.setMaximumSize(new Dimension(80, 30)); jButtonCancel.setText("Cancel"); jButtonCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { onCancelButton(); } }); jButtonCancel.setMinimumSize(new Dimension(80, 30)); } return jButtonCancel; } /** * This method initializes jButtonOK * * @return javax.swing.JButton */ private JButton getJButtonOK() { if (jButtonOK == null) { jButtonOK = new JButton(); jButtonOK.setPreferredSize(new Dimension(80, 30)); jButtonOK.setMinimumSize(new Dimension(80, 30)); jButtonOK.setMaximumSize(new Dimension(80, 30)); jButtonOK.setMaximumSize(new Dimension(80, 30)); jButtonOK.setPreferredSize(new Dimension(80, 30)); jButtonOK.setText("OK"); jButtonOK.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { onOKButton(); } }); jButtonOK.setMinimumSize(new Dimension(80, 30)); } return jButtonOK; } /** * This method initializes jTabbedPane * * @return javax.swing.JTabbedPane */ private JTabbedPane getJTabbedPane() { if (jTabbedPane == null) { jTabbedPane = new JTabbedPane(); jTabbedPane.addTab("General", null, getJPanelGeneral(), null); jTabbedPane.addTab("Extensions", null, getPanel(), null); } return jTabbedPane; } /** * This method initializes jPanelGeneral * * @return javax.swing.JPanel */ private JPanel getJPanelGeneral() { if (jPanelGeneral == null) { GridBagConstraints gridBagConstraints12 = new GridBagConstraints(); gridBagConstraints12.gridx = 0; gridBagConstraints12.weightx = 1.0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -