dangsn
2024-12-26 4e9ff2ce6a830bb2340d7c8612c72eea0c5a553e
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
package com.vci.client.framework.rightConfig.functiontree;
 
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
 
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.tree.TreePath;
 
import com.vci.client.LogonApplication;
import com.vci.client.common.TransmitTreeObject;
import com.vci.client.framework.delegate.FuncOperationClientDelegate;
import com.vci.client.framework.rightConfig.object.FuncOperationObject;
import com.vci.client.ui.exception.VCIException;
import com.vci.client.ui.image.BundleImage;
import com.vci.client.ui.locale.LocaleDisplay;
import com.vci.client.ui.swing.KTextField;
import com.vci.client.ui.swing.VCIOptionPane;
import com.vci.client.ui.swing.components.VCIJButton;
import com.vci.client.ui.tree.VCIBaseTreeNode;
 
/**
 * 操作类型的管理是初始化系统中每个功能模块所具有的操作的集合。
 * 
 * @author
 */
public class FuncOperatePanel extends JPanel {
 
    private static final long serialVersionUID = -3826623955360533220L;
    private JLabel operateLab = new JLabel();
    private JLabel nameLab = new JLabel();
    private KTextField nameText = new KTextField();
    private JLabel identifyLab = new JLabel();
    private KTextField identifyText = new KTextField();
    private JLabel aliasLab = new JLabel();
    private KTextField aliasText = new KTextField();
    private JLabel numberLab = new JLabel();
    private KTextField numberText = new KTextField();
    private JLabel describeLab = new JLabel();
    private JTextArea describeTxtArea = new JTextArea();
    private VCIJButton editOptAlias = new VCIJButton("修改别名");
    private JButton delButton = new JButton();
    private JTextField top = new JTextField();// 横线
    private JTextField bottom = new JTextField();// 横线
    private TransmitTreeObject transmitTreeObject = new TransmitTreeObject();// 传递树的信息
    /**
     * 是否有效标识
     */
    private JCheckBox isValid = new JCheckBox(LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.modelManagment.isValid", "RMIPFramework", getLocale()));
    // 控件的坐标位置变量
    private int x = 10;
    private int y = 20;
    private int width = 50;
    private int height = 25;
    /**
     * 两控件间水平间隔
     */
    private int hspan = 5;
 
    private FuncOperationClientDelegate funcOperateClient = new FuncOperationClientDelegate(LogonApplication.getUserEntityObject());
 
    private FuncOperationObject curObj = null;
    
    public FuncOperatePanel(FuncOperationObject obj,TransmitTreeObject transmitTreeObject) {
        super();
        this.transmitTreeObject = transmitTreeObject;
        curObj = obj;
        init();
        initData();
        this.setOpaque(false);
    }
 
    public void init(){
        JPanel palMain = new JPanel();
        JPanel contentPanel = new JPanel();
        JPanel buttonPanel = new JPanel();
        palMain.setLayout(new BorderLayout());
 
        operateLab.setText(LocaleDisplay.getI18nString("rmip.framework.operateType.operateTypeLab.file","RMIPFramework", getLocale()));
        operateLab.setBounds(new Rectangle(0, 0, 30, 25));
        
        contentItem(contentPanel);
        jButtonPanl(buttonPanel);
        
        palMain.add(operateLab,BorderLayout.NORTH);
        palMain.add(contentPanel, BorderLayout.CENTER);
        palMain.add(buttonPanel, BorderLayout.SOUTH);
        this.setLayout(new BorderLayout());
        this.add(palMain, BorderLayout.CENTER);
    }
 
    private void initData(){
        try {
            FuncOperationObject[] objs = new FuncOperationClientDelegate().getFuncOperationByModuleId(curObj.getFuncId(), curObj.getOperId(), false);
            if(objs.length > 0){
                curObj = objs[0];
            }else{
                return;
            }
        } catch (VCIException e) {
            e.printStackTrace();
        }
        nameText.setText(curObj.getOperName());
        identifyText.setText(curObj.getOperIndentify());
        aliasText.setText(curObj.getOperAlias());
        numberText.setText(String.valueOf(curObj.getNumber()));
        describeTxtArea.setText(curObj.getOperDesc());
        isValid.setSelected(curObj.getIsValid());
        nameText.setEditable(false);
        identifyText.setEditable(false);
        numberText.setEditable(false);
        describeTxtArea.setEditable(false);
        editOptAlias.setEnabled(true); // 显示按钮
        delButton.setEnabled(true); // 显示按钮
    }
    
 
    /**
     * 按钮
     * 
     * @return
     */
    public void jButtonPanl(JPanel p) {
        editOptAlias.setIcon(new BundleImage().createImageIcon("edit.png"));
        editOptAlias.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    String alias = aliasText.getText();
                    if ("".equals(alias)){
                        VCIOptionPane.showMessage(LogonApplication.frame, "请填写操作别名!");
                        return;
                    }
                    boolean isSelected = isValid.isSelected();
                    String id = curObj.getId();
                    boolean success = funcOperateClient.updateFuncOperation(id , alias, isSelected);
                    if(success){
                        curObj.setOperAlias(alias);
                        curObj.setIsValid(isSelected);
                        VCIBaseTreeNode node = new VCIBaseTreeNode(curObj.getOperAlias(), curObj);
                        VCIBaseTreeNode parentNode = (VCIBaseTreeNode)transmitTreeObject.getCurrentTreeNode().getParent();
                        transmitTreeObject.getTreeModel().removeNodeFromParent(transmitTreeObject.getCurrentTreeNode());
                        parentNode.add(node);
                        node.setLeaf(true);
                        transmitTreeObject.getTree().setSelectionPath(new TreePath(parentNode.getPath()));
                        transmitTreeObject.setCurrentTreeNode(parentNode);
                        transmitTreeObject.getTree().updateUI();
                        VCIOptionPane.showMessage(LogonApplication.frame, "操作别名修改成功!");
                    }
                } catch (VCIException e1) {
                    e1.printStackTrace();
                    VCIOptionPane.showError(LogonApplication.frame,LocaleDisplay.getI18nString(e1, "RMIPFramework", getLocale()));
                }
            }
        });
        delButton.setText(LocaleDisplay.getI18nString("rmip.framework.operateType.delButton.file", "RMIPFramework",getLocale()));
        delButton.setIcon(new BundleImage().createImageIcon("delete.gif"));
        delButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    int ok = VCIOptionPane.showQuestion(LogonApplication.frame, "移除该操作的同时会将其从用户的权限中移除,确认执行移除吗?");
                    if(ok != 0){
                        return;
                    }
                    boolean success = funcOperateClient.deleteFuncOperation(curObj);
                    if(success){
                        VCIBaseTreeNode parentNode = (VCIBaseTreeNode)transmitTreeObject.getCurrentTreeNode().getParent();
                        transmitTreeObject.getTreeModel().removeNodeFromParent(transmitTreeObject.getCurrentTreeNode());
                        transmitTreeObject.getTree().setSelectionPath(new TreePath(parentNode.getPath()));
                        transmitTreeObject.setCurrentTreeNode(parentNode);
                    }
                } catch (VCIException e1) {
                    e1.printStackTrace();
                    VCIOptionPane.showError(LogonApplication.frame,LocaleDisplay.getI18nString(e1, "RMIPFramework", getLocale()));
                }
            }
        });
        delButton.setEnabled(false); // 按钮失效
        p.add(editOptAlias);
        p.add(delButton);
    }
 
    /**
     * 内容项
     * 
     * @return
     */
    public void contentItem(JPanel p) {
        JPanel panel = new JPanel();
        
        top.setPreferredSize(new Dimension(63,2));
        bottom.setPreferredSize(new Dimension(63,2));
        
        x = 30;y = 30;width = 80;height = 25;
        nameLab.setText(LocaleDisplay.getI18nString("rmip.framework.operateType.designationLab.file","RMIPFramework", getLocale()));
        nameLab.setBounds(new Rectangle(x, y, width, height));
 
        x += nameLab.getWidth() + hspan;y = 30;width = 200;height = 25;
        nameText.setBounds(new Rectangle(x, y, width, height));
 
        x = 30;y = 70;width = 80;height = 25;
        identifyLab.setText(LocaleDisplay.getI18nString("rmip.framework.operateType.identifyingLab.file","RMIPFramework", getLocale()));
        identifyLab.setBounds(new Rectangle(x, y, width, height));
 
        x += identifyLab.getWidth() + hspan;y = 70;width = 200;height = 25;
        identifyText.setBounds(new Rectangle(x, y, width, height));
 
        x = 30;y = 110;width = 80;height = 25;
        aliasLab.setText("别名");
        aliasLab.setBounds(x, y, width, height);
        
        x+= aliasLab.getBounds().width + hspan; width = 200; height = 25;
        aliasText.setBounds(x, y, width, height);
        
        x = 30;y = 150;width = 80;height = 25;
        numberLab.setText("编号:");
        numberLab.setBounds(x, y, width, height);
        
        x+= numberLab.getBounds().width + hspan; width = 200; height = 25;
        numberText.setBounds(x, y, width, height);
        
        x = 30;y = 190;width = 80;height = 25;
        describeLab.setText(LocaleDisplay.getI18nString("rmip.framework.operateType.describeLab.file", "RMIPFramework",getLocale()));
        describeLab.setBounds(new Rectangle(x, y, width, height));
 
        x += describeLab.getWidth() + hspan;y = 190;width = 200;height = 100;
        JScrollPane scroll = new JScrollPane(describeTxtArea);
        scroll.setBounds(new Rectangle(x, y, width, height));
        describeTxtArea.setLineWrap(true);
        
        x = 30;y = 300;width = 80;height = 25;
        isValid.setBounds(new Rectangle(x, y, width, height));
        
        panel.setLayout(null);
        panel.add(nameLab);
        panel.add(nameText);
        panel.add(identifyLab);
        panel.add(identifyText);
        panel.add(aliasLab);
        panel.add(aliasText);
        panel.add(numberLab);
        panel.add(numberText);
        panel.add(describeLab);
        panel.add(scroll);
        panel.add(isValid);
        
        p.setLayout(new BorderLayout());
        p.add(top,BorderLayout.NORTH);
        p.add(panel,BorderLayout.CENTER);
        p.add(bottom,BorderLayout.SOUTH);
    }
}