ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
package com.vci.client.framework.systemConfig.stafforgmanage;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
 
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.border.TitledBorder;
 
import com.vci.client.LogonApplication;
import com.vci.client.common.TransmitTreeObject;
import com.vci.client.common.VCIBasePanel;
import com.vci.client.framework.delegate.RightManagementClientDelegate;
import com.vci.client.framework.rightConfig.object.FunctionObject;
import com.vci.client.framework.systemConfig.SysConfigTableModel;
import com.vci.client.framework.systemConfig.object.CombinationObject;
import com.vci.client.framework.systemConfig.object.CombinationValueObject;
import com.vci.client.framework.util.RightControlUtil;
import com.vci.client.ui.exception.VCIException;
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.VCISwingUtil;
import com.vci.client.ui.swing.components.VCIJButton;
import com.vci.client.ui.swing.components.VCIJComboBox;
import com.vci.client.ui.swing.components.VCIJLabel;
import com.vci.client.ui.table.VCIBaseTableNode;
/**
 * 组合方式取值范围
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2012</p>
 * <p>Company: VCI</p>
 * @author wangxl
 * @time 2013-1-3
 * @version 1.0
 */
public class CombinationValueTablePanel  extends VCIBasePanel{
    //值
    private String VALUE = LocaleDisplay.getI18nString("rmip.framework.sysconfig.value", "RMIPFramework",getLocale());
    private VCIJButton addButton = VCISwingUtil.createVCIJButton("",
            LocaleDisplay.getI18nString("rmip.stafforg.operate.add",
                    "RMIPFramework", getLocale()), LocaleDisplay.getI18nString(
                    "rmip.stafforg.operate.add", "RMIPFramework", getLocale()),
            "create.gif", null);
    private VCIJButton editButton = VCISwingUtil.createVCIJButton("",
            LocaleDisplay.getI18nString("rmip.stafforg.operate.modify",
                    "RMIPFramework", getLocale()), LocaleDisplay.getI18nString(
                    "rmip.stafforg.operate.modify", "RMIPFramework",
                    getLocale()), "modify.gif", null);
    private VCIJButton deleteButton = VCISwingUtil.createVCIJButton("",
            LocaleDisplay.getI18nString("rmip.stafforg.operate.delete",
                    "RMIPFramework", getLocale()), LocaleDisplay.getI18nString(
                    "rmip.stafforg.operate.delete", "RMIPFramework",
                    getLocale()), "delete.gif", null);
    
    private VCIJLabel classLabel = new VCIJLabel("组合方式:");
    private VCIJComboBox classComBox = new VCIJComboBox(); 
 
    private static final long serialVersionUID = 1L;
    private SysConfigTableModel combValTableModel; //表格的tableModel
    private JTable combValTable;  //表格的table
    private KTextField valueText = new KTextField() ;
    private TransmitTreeObject transmitTreeObject;
    private CombinationValueObject combinationValueObject = null; //选中的字符
    public CombinationObject combObject = null;
    private Class[] classes = { String.class,String.class,String.class,String.class,String.class,String.class,String.class,String.class,String.class,String.class,String.class,String.class};
    public CombinationValueTablePanel(FunctionObject funcObj) {
        super(funcObj);
        init();
        checkPermission();
    }
 
    public void init() {
        setLayout(new BorderLayout());
        JPanel rightPanel = initTablePanel();
        this.add(rightPanel, BorderLayout.CENTER);
        initAction();
    }
 
    
    private void checkPermission(){
        checkRight(RightControlUtil.CREATE, addButton);
        checkRight(RightControlUtil.UPDATE, editButton);
        checkRight(RightControlUtil.DELETE, deleteButton);
    }
    
    /**
     * 加载组合方式取值范围
     * <p>Description: </p>
     * 
     * @author wangxl
     * @time 2013-1-3
     * @return
     */
    private JPanel initSpecialCharacter() {
       
        JPanel bottomPanel = new JPanel();
        bottomPanel.add(addButton);
        bottomPanel.add(editButton);
        bottomPanel.add(deleteButton);
        
        combValTableModel=new SysConfigTableModel(classes);
        VCIBaseTableNode specialCharacterTableNode=new VCIBaseTableNode(null);
        combValTableModel.addRow(1, specialCharacterTableNode);
        combValTable=new JTable(combValTableModel);
        combValTable.setRowHeight(25);
        combValTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent e) {
                 initContent();
            }
        }); 
        /**
         * 修改界面初始加载密码组合方式取值范围
         */
        if (this.classComBox.getItemCount() == 0){
            initTableProperty("");
        }else {
            CombinationObject obj = (CombinationObject)classComBox.getItemAt(0);
            initTableProperty(obj.getId());
        }
        
        combValTable.setColumnSelectionAllowed(true);
        combValTable.setCellSelectionEnabled(false);
        JScrollPane js=new JScrollPane(combValTable);
        
    
        //创建值输入框
        JPanel centerBottomCPanel = new JPanel();
        centerBottomCPanel.setLayout(null);
        JLabel valueLabel = new JLabel(VALUE);
        valueLabel.setBounds(20, 10, 80, 25);
        valueText.setBounds(50, 10, 200, 25);
        centerBottomCPanel.add(valueLabel);
        centerBottomCPanel.add(valueText);
        centerBottomCPanel.setPreferredSize(new Dimension(400, 70));
        
        
        JPanel palTable = new JPanel(new BorderLayout());
        palTable.add(js, BorderLayout.CENTER);
        palTable.add(centerBottomCPanel,BorderLayout.SOUTH);
        
        
        JPanel centerPanel = new JPanel();
        centerPanel.setLayout(new BorderLayout());
        
        centerPanel.add(palTable, BorderLayout.CENTER);
        centerPanel.add(bottomPanel,BorderLayout.SOUTH);
        return centerPanel;
    }
    
 
    /**
     * 初始化table的Panle
     * @return
     */
    private JPanel initTablePanel(){
        JPanel palTable = new JPanel();
        palTable.setBorder(new TitledBorder("组合方式取值范围"));
        palTable.setLayout(new BorderLayout());
        
        //初始化下拉框
        initCharacterClassCombox();
        
        //分类下拉框
        JPanel searchPal = new JPanel();
        searchPal.setLayout(null);
        searchPal.setPreferredSize(new Dimension(300,40));
        classLabel.setBounds(20, 10, 80, 25);
        classComBox.setBounds(78, 10, 200, 25);
        searchPal.add(classLabel);
        searchPal.add(classComBox);
        
        palTable.add(searchPal,BorderLayout.NORTH);
        palTable.add(initSpecialCharacter(), BorderLayout.CENTER);
        
        
        return palTable;
    }
    /**
     * 获取密码组合方式,填充下拉列表
     * <p>Description: </p>
     * 
     * @author wangxl
     * @time 2013-1-3
     */
    public void initCharacterClassCombox(){
        try {
            CombinationObject[]    objs = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchAllCombinations();
            int size = objs.length;
            for (int i = 0; i < size; i++) {
                classComBox.addItem(objs[i]);
            }
        } catch (VCIException e) {
            VCIOptionPane.showError(LogonApplication.frame,    "RMIPFramework", e);
            return ;
        }
        
    }
    
  /**
   * 通过选中的密码组合方式的id获取组合方式取值范围
   * <p>Description: </p>
   * 
   * @author wangxl
   * @time 2013-1-3
   * @param id
   */
    public void initTableProperty(String id){
        try {
            combValTableModel.list.clear();
            valueText.setText("");
            CombinationValueObject[] combValueObjs = new RightManagementClientDelegate(LogonApplication.getUserEntityObject())
                                                               .fetchCombinationValuesByParentId(id);//objs是由id取到的取值
            int length=combValueObjs.length;
            int rowLength = length/12;
            if (length%12 != 0) {
                rowLength += 1;
            }
            for (int i = 0; i < rowLength; i++) {
                VCIBaseTableNode combValueTableNode = new VCIBaseTableNode(null);
                for(int column = 0; column < 12;column++){
                    if (i*12 + column < length){
                        CombinationValueObject combValObject= combValueObjs[i*12 + column];
                        String name=String.valueOf(column+1);
                        combValueTableNode.setPropertyValueByName(name, combValObject);
                    }
                }
                combValTableModel.addRow(i + 1 , combValueTableNode);
            }
            combValTable.setModel(combValTableModel);
            combValTableModel.fireTableDataChanged();
         }  catch (VCIException e) {
             VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
         }
    }
    
    
    /**
     * 填充控件值
     * <p>Description: </p>
     * 
     * @author wangxl
     * @time 2013-1-3
     */
    public void initContent(){
        int rowIndex = combValTable.getSelectedRow();
        int columnIndex = combValTable.getSelectedColumn();
        Object combValObj =  combValTableModel.getValueAt(rowIndex, columnIndex);
        if(combValObj instanceof CombinationValueObject){
            combinationValueObject = (CombinationValueObject)combValObj;
            valueText.setText(combinationValueObject.getValue());
        } else {
            combinationValueObject = null;
            valueText.setText("");
        }
    }
     
     
    /**
     * 分类下拉框触发事件
     * <p>Description: </p>
     * 
     * @author llb
     * @time 2013-1-3
     */
     public void initAction(){
         classComBox.addActionListener(new ActionListener() {
            
            @Override
            public void actionPerformed(ActionEvent e) {
                classCombox_conform();
                
            }
        });
            classCombox_conform();
        addButton.addActionListener(new CombinationValueActionListener(this,"add"));
        editButton.addActionListener(new CombinationValueActionListener(this,"modify"));
        deleteButton.addActionListener(new CombinationValueActionListener(this,"delete"));
     }
     
    private void classCombox_conform(){
        String id = "";
        int select = classComBox.getSelectedIndex();
        if(select>=0){
            CombinationObject obj = (CombinationObject)classComBox.getSelectedItem();
            combObject = obj;
            id = obj.getId();
        }
        initTableProperty(id);//用户在下拉框取到的id,刷新table
    }
    
    private void decreaseSelRows(int start, Integer[] selRows){
        for(int i = start + 1; i < selRows.length; i++){
            selRows[i] = selRows[i] - 1;
        }
    }
    
    public CombinationValueObject getCombinationValueObject() {
        return combinationValueObject;
    }
    public CombinationObject getCombinationObject() {
        return combObject;
    }
    public TransmitTreeObject getTransmitTreeObject() {
        return transmitTreeObject;
    }
    public void setValueText(String value) {
        valueText.setText(value);
    }
    
    public VCIJComboBox getClassComBox(){
        return classComBox;
    }
    public String getValueText() {
        return valueText.getText().trim();
    }
 
}