|
|
@@ -3,6 +3,8 @@ package com.leanwo.management;
|
|
|
import java.awt.AWTEvent;
|
|
|
import java.awt.AWTException;
|
|
|
import java.awt.BorderLayout;
|
|
|
+import java.awt.Color;
|
|
|
+import java.awt.Container;
|
|
|
import java.awt.GridBagConstraints;
|
|
|
import java.awt.GridBagLayout;
|
|
|
import java.awt.Image;
|
|
|
@@ -22,6 +24,7 @@ import java.util.Map;
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
import javax.swing.BorderFactory;
|
|
|
+import javax.swing.BoxLayout;
|
|
|
import javax.swing.JButton;
|
|
|
import javax.swing.JFrame;
|
|
|
import javax.swing.JLabel;
|
|
|
@@ -46,116 +49,68 @@ public class ServerSettingJFrame extends JFrame{
|
|
|
private ApplicationSetting applicationSetting;
|
|
|
private XmlConfigPath xmlConfigPath;
|
|
|
private XmlConfigPathService xmlConfigPathService;
|
|
|
- private JPanel jPanel = null;
|
|
|
- private GridBagConstraints constrains = null;
|
|
|
+ private Container jPanel = null;
|
|
|
private JLabel label = null;
|
|
|
private JTextField portTextField;
|
|
|
private JTextField tokenTextField;
|
|
|
private Map<String, JTextArea> textAreas = new HashMap<String, JTextArea>();
|
|
|
private JButton saveButton;
|
|
|
|
|
|
- private int index = 0;
|
|
|
-
|
|
|
public ServerSettingJFrame(ApplicationSetting applicationSetting) {
|
|
|
- this.setLayout(new BorderLayout());
|
|
|
+
|
|
|
+ this.jPanel = this.getContentPane();
|
|
|
+
|
|
|
this.setSize(800, 600);
|
|
|
this.setTitle("程序配置管理器");
|
|
|
this.xmlConfigPathService = (XmlConfigPathService) SpringUtil.getSingleBean(XmlConfigPathService.class);
|
|
|
this.applicationSetting = applicationSetting;
|
|
|
this.xmlConfigPathService.load(applicationSetting);
|
|
|
this.xmlConfigPath = applicationSetting.getXmlConfigPath();
|
|
|
- this.jPanel = new JPanel(new GridBagLayout());
|
|
|
- this.add(jPanel, BorderLayout.NORTH);
|
|
|
+ jPanel.setLayout(new BoxLayout(jPanel, BoxLayout.Y_AXIS));
|
|
|
|
|
|
if(this.xmlConfigPath != null) {
|
|
|
label = new JLabel("端口号");
|
|
|
- constrains = new GridBagConstraints();
|
|
|
- constrains.insets = new Insets(0, 0, 0, 0);
|
|
|
- constrains.fill = GridBagConstraints.BOTH;
|
|
|
- constrains.gridx = 0;
|
|
|
- constrains.gridy = index;
|
|
|
- constrains.weightx = 100;
|
|
|
- constrains.anchor = GridBagConstraints.NORTH;
|
|
|
- jPanel.add(label, constrains);
|
|
|
+ label.setAlignmentY(LEFT_ALIGNMENT);
|
|
|
+
|
|
|
+ jPanel.add(label);
|
|
|
|
|
|
- index++;
|
|
|
portTextField = new JTextField();
|
|
|
+ portTextField.setAlignmentY(LEFT_ALIGNMENT);
|
|
|
if(xmlConfigPath.getPortNo() != null) {
|
|
|
portTextField.setText(xmlConfigPath.getPortNo().toString());
|
|
|
}
|
|
|
- constrains = new GridBagConstraints();
|
|
|
- constrains.insets = new Insets(0, 0, 0, 0);
|
|
|
- constrains.fill = GridBagConstraints.BOTH;
|
|
|
- constrains.gridx = 0;
|
|
|
- constrains.gridy = index;
|
|
|
- constrains.weightx = 100;
|
|
|
- constrains.anchor = GridBagConstraints.NORTH;
|
|
|
- jPanel.add(portTextField, constrains);
|
|
|
+ jPanel.add(portTextField);
|
|
|
|
|
|
|
|
|
- index++;
|
|
|
label = new JLabel("Token");
|
|
|
- constrains = new GridBagConstraints();
|
|
|
- constrains.insets = new Insets(0, 0, 0, 0);
|
|
|
- constrains.fill = GridBagConstraints.BOTH;
|
|
|
- constrains.gridx = 0;
|
|
|
- constrains.gridy = index;
|
|
|
- constrains.weightx = 100;
|
|
|
- constrains.anchor = GridBagConstraints.NORTH;
|
|
|
- jPanel.add(label, constrains);
|
|
|
+ label.setAlignmentY(LEFT_ALIGNMENT);
|
|
|
+ jPanel.add(label);
|
|
|
|
|
|
- index++;
|
|
|
tokenTextField = new JTextField();
|
|
|
+ tokenTextField.setAlignmentY(LEFT_ALIGNMENT);
|
|
|
tokenTextField.setText(xmlConfigPath.getToken());
|
|
|
- constrains = new GridBagConstraints();
|
|
|
- constrains.insets = new Insets(0, 0, 0, 0);
|
|
|
- constrains.fill = GridBagConstraints.BOTH;
|
|
|
- constrains.gridx = 0;
|
|
|
- constrains.gridy = index;
|
|
|
- constrains.weightx = 100;
|
|
|
- constrains.anchor = GridBagConstraints.NORTH;
|
|
|
- jPanel.add(tokenTextField, constrains);
|
|
|
+ jPanel.add(tokenTextField);
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> contents = applicationSetting.getXmlConfigPath().getContents();
|
|
|
for(String key : contents.keySet()) {
|
|
|
- index ++;
|
|
|
label = new JLabel(key);
|
|
|
- constrains = new GridBagConstraints();
|
|
|
- constrains.insets = new Insets(0, 0, 0, 0);
|
|
|
- constrains.fill = GridBagConstraints.BOTH;
|
|
|
- constrains.gridx = 0;
|
|
|
- constrains.gridy = index;
|
|
|
- constrains.weightx = 100;
|
|
|
- constrains.anchor = GridBagConstraints.NORTH;
|
|
|
- jPanel.add(label, constrains);
|
|
|
+ label.setAlignmentY(LEFT_ALIGNMENT);
|
|
|
+ jPanel.add(label);
|
|
|
|
|
|
- index ++;
|
|
|
JTextArea textArea = new JTextArea();
|
|
|
+ textArea.setAlignmentY(LEFT_ALIGNMENT);
|
|
|
textArea.setText(contents.get(key));
|
|
|
- textArea.setRows(5);
|
|
|
- constrains = new GridBagConstraints();
|
|
|
- constrains.insets = new Insets(0, 0, 0, 0);
|
|
|
- constrains.fill = GridBagConstraints.BOTH;
|
|
|
- constrains.gridx = 0;
|
|
|
- constrains.gridy = index;
|
|
|
- constrains.weightx = 100;
|
|
|
- constrains.anchor = GridBagConstraints.NORTH;
|
|
|
- jPanel.add(textArea, constrains);
|
|
|
+ textArea.setSelectedTextColor(Color.RED);
|
|
|
+ textArea.setLineWrap(true); //激活自动换行功能
|
|
|
+ textArea.setWrapStyleWord(true); // 激活断行不断字功能
|
|
|
+ jPanel.add(textArea);
|
|
|
textAreas.put(key, textArea);
|
|
|
}
|
|
|
|
|
|
- index ++;
|
|
|
saveButton = new JButton("保存");
|
|
|
- constrains = new GridBagConstraints();
|
|
|
- constrains.insets = new Insets(0, 0, 0, 0);
|
|
|
- constrains.fill = GridBagConstraints.BOTH;
|
|
|
- constrains.gridx = 0;
|
|
|
- constrains.gridy = index;
|
|
|
- constrains.weightx = 100;
|
|
|
- constrains.anchor = GridBagConstraints.NORTH;
|
|
|
- jPanel.add(saveButton, constrains);
|
|
|
+ jPanel.add(saveButton);
|
|
|
|
|
|
saveButton.addActionListener(new ActionListener() {
|
|
|
@Override
|
|
|
@@ -181,10 +136,5 @@ public class ServerSettingJFrame extends JFrame{
|
|
|
}
|
|
|
|
|
|
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
|
|
-// this.addWindowListener(new java.awt.event.WindowAdapter() {
|
|
|
-// public void windowClosing(java.awt.event.WindowEvent e) {
|
|
|
-// ServerSettingJFrame.this.setVisible(false);
|
|
|
-// }
|
|
|
-// });
|
|
|
}
|
|
|
}
|