wangting
2024-12-26 fa261e8c1220b31af54e8167e4de9c3320b1af27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
package com.vci.client.framework.appConfig;
 
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
 
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
 
import com.vci.client.framework.appConfig.object.AppConfigDetailObject;
import com.vci.client.logon.base.BaseJDialog;
import com.vci.client.ui.locale.LocaleDisplay;
import com.vci.client.ui.swing.KJButton;
import com.vci.client.ui.swing.KTextArea;
import com.vci.client.ui.swing.KTextField;
 
public class AppConfigDetailDialog extends BaseJDialog{
 
    /**
     * 
     */
    private static final long serialVersionUID = -6314831933831820106L;
    private IConfigDetailPanel panel = null;
    private AppConfigDetailObject obj = null;
    private KJButton conformButton = new KJButton(LocaleDisplay.getI18nString("rmip.framework.button.confirm", "RMIPFramework", getLocale()), "bullet_blue.png");
    private KJButton cancelButton = new KJButton(LocaleDisplay.getI18nString("rmip.framework.button.cancel", "RMIPFramework", getLocale()) , "bullet_delete.png");
    private KTextField nameField;
    private JTextArea descriptionArea;
    private KTextField keyField;
    //private KTextField valField;
    private KTextArea valField;
    private String clsfId;
 
    public AppConfigDetailDialog(Frame frame, IConfigDetailPanel panel, String clsfId) {
        super(frame);
        this.setModal(true);
        this.panel = panel;
        this.clsfId = clsfId;
        init();
    }
    
    public AppConfigDetailDialog(Frame frame, IConfigDetailPanel panel, AppConfigDetailObject obj) {
        super(frame);
        this.setModal(true);
        this.panel = panel;
        this.obj = obj;
        init();
    }
    
    private void init() {
        this.setTitle("配置项");
        JLabel titleLabel = new JLabel();
        //titleLabel.setText("配置项");
        
        JPanel bottomPanel = new JPanel();
        bottomPanel.add(conformButton);
        bottomPanel.add(cancelButton);
        JPanel contentPanel = initCenterContentPanel();         
        JPanel midPanel = new JPanel();
        midPanel.setLayout(new BorderLayout());
        JTextField jTextField1 = new JTextField();//instead of up line
        JTextField jTextField2 = new JTextField();//instead of down line
        jTextField1.setPreferredSize(new Dimension(63,2));
        jTextField2.setPreferredSize(new Dimension(63,2));
        midPanel.add(jTextField1, BorderLayout.NORTH);
        midPanel.add(jTextField2, BorderLayout.SOUTH);
        midPanel.add(contentPanel, BorderLayout.CENTER);
        this.setLayout(new BorderLayout());
        this.add(titleLabel, BorderLayout.NORTH);
        this.add(midPanel, BorderLayout.CENTER);
        this.add(bottomPanel, BorderLayout.SOUTH); 
        initDialogSize(500, 380);
        this.setVisible(true);
    }
    
    private JPanel initCenterContentPanel() {
        JPanel contentPanel = new JPanel();
        contentPanel.setLayout(null);
        
        JLabel nameLabel = new JLabel("名称:");
        nameField = new KTextField();
        nameLabel.setBounds(new Rectangle(20,25,40,25));
        nameField.setBounds(new Rectangle(65,25,400,25));
        
        JLabel keyLabel = new JLabel("Key:");
        keyField = new KTextField();
        keyLabel.setBounds(new Rectangle(20,55,40,25));
        keyField.setBounds(new Rectangle(65,55,400,25));
        
        JLabel valLabel = new JLabel("值:");
        valLabel.setBounds(new Rectangle(20,85,40,25));
        valField = new KTextArea();
        valField.setLineWrap(true);
        //valField.setBounds(new Rectangle(85,85,400,150));
        JScrollPane jsValue=new JScrollPane();
        jsValue.setBounds(new Rectangle(65,85,400,120));    
        jsValue.getViewport().add(valField);
        
        JLabel descriptionLabel = new JLabel("描述:");
        descriptionArea = new JTextArea();
        descriptionLabel.setBounds(new Rectangle(20,215,40,30));    
        JScrollPane jsDescription=new JScrollPane();
        jsDescription.setBounds(new Rectangle(65,215,400,80));    
//        contentPanel.add(descriptionLabel);
//        contentPanel.add(jsDescription);        
        descriptionArea.setLineWrap(true);
        jsDescription.getViewport().add(descriptionArea);
        
        
        contentPanel.add(nameLabel);
        contentPanel.add(nameField);
        contentPanel.add(keyLabel);
        contentPanel.add(keyField);
        contentPanel.add(valLabel);
        //contentPanel.add(valField);
        contentPanel.add(jsValue);
        contentPanel.add(descriptionLabel);
        contentPanel.add(jsDescription);
 
        conformButton.setActionCommand("confirm");
        conformButton.addActionListener(new AppConfigDetailDialogActionListener(this));
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
                cancelButton_ActionPerformed(e);
            }
        });
        initContent();
        return contentPanel;
    }
    private void initContent(){
        if (obj != null){
            nameField.setText(obj.getName());
            keyField.setText(obj.getKey());
            valField.setText(obj.getValue());
              descriptionArea.setText(obj.getDesc());
        }
    }
    
    public AppConfigDetailObject getConfigDetail() {
        if (obj == null){
            obj = new AppConfigDetailObject();
        }
        obj.setName(nameField.getText());
        obj.setKey(keyField.getText());
        obj.setValue(valField.getText());
        obj.setDesc(descriptionArea.getText());
        if (clsfId != null && !clsfId.equals("")) {
            obj.setCategoryId(clsfId);
        }
        return obj;
    }
    
     /**
     * 取消按钮事件
     * @param e
     */
    private void cancelButton_ActionPerformed(ActionEvent e) {
        this.dispose();
    }
    
    public IConfigDetailPanel getAppConfigDetailPanel() {
        return this.panel;
    }
}