田源
2025-01-09 8a166a60cfd1a2e593ffa103d10c0dc224fc8628
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
package com.vci.client.framework.systemConfig.specialCharacter;
 
 
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
 
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
 
import com.vci.client.LogonApplication;
import com.vci.client.common.VCIBasePanel;
import com.vci.client.framework.delegate.SystemCfgClientDelegate;
import com.vci.client.framework.systemConfig.SysConfigTableModel;
import com.vci.client.framework.systemConfig.object.SpecialCharClsfObject;
import com.vci.client.framework.systemConfig.object.SpecialCharObject;
import com.vci.client.framework.systemConfig.stafforgmanage.VCIBaseTableExtend;
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.table.TableCheckboxManager;
import com.vci.client.ui.table.TableSorterData;
import com.vci.client.ui.table.VCIBaseTableNode;
import com.vci.corba.common.VCIError;
/**
 * 特殊字符选择panel
 * <p>Title: </p>
 * <p>Description:此panel为资源数据选择特殊字符而设计,
 *       它是SpecialCharSelectDialog 中使用到的panel</p>
 * <p>Copyright: Copyright (c) 2012</p>
 * <p>Company: VCI</p>
 * @author wangxl
 * @time 2012-12-18
 * @version 1.0
 */
 
public class SpecialCharPanel  extends VCIBasePanel{
    
    /****************************国际化信息**********************************/
    //特殊字符分类
    private String SPECIALCHARCLSF = LocaleDisplay.getI18nString("rmip.framework.sysconfig.specialCharClsf", "RMIPFramework",getLocale());
    //特殊字符
    private String SPECIALCHAR = LocaleDisplay.getI18nString("rmip.framework.sysconfig.specialChar", "RMIPFramework",getLocale());
    //值
    private String VALUE = LocaleDisplay.getI18nString("rmip.framework.sysconfig.value", "RMIPFramework",getLocale());
    
    /**
     *   特殊字符、分类的Panel
     */
    private static final long serialVersionUID = 1L;
    private SysConfigTableModel specialCharacterTableModel; //表格的tableModel
    private JTable specialCharacterTable;  //表格的table
    private KTextField nameField; //名称
    private JTextArea descriptionArea;//描述
    private KTextField valueText = new KTextField() ;
    private SpecialCharObject specialCharObject = null; //选中的字符
    /* 初始化table组件*/
    private String[] columns ;
    private Class[] topClasses ;
    private VCIBaseTableExtend tableModel = null;
    private JTable table = null;
    private TableSorterData sorter = null;//排序
    private TableCheckboxManager tbChkManager;
    String id;
    public SpecialCharClsfObject clsfObj = 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 SpecialCharPanel() {
        super(null);
        init();
    }
 
    public void init() {
        setLayout(new BorderLayout());
        JPanel palLeft = initSpecialCharacterClass();
        JPanel palRight = initSpecialCharacter();
        
        JSplitPane jsplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, palLeft, palRight);
        jsplit.setDividerSize(10);
        jsplit.setContinuousLayout(true);
        jsplit.setOneTouchExpandable(true);
        jsplit.setDividerLocation(300);
        this.add(jsplit, BorderLayout.CENTER);
        
    }
 
    /**
     * 加载特殊字符分类 
     * <p>Description: </p>
     * 
     * @author wangxl
     * @time 2012-12-18
     * @return
     */
    private JPanel initSpecialCharacterClass() {
        this.setLayout(new BorderLayout());
        JPanel tablePanel = initTablePanel();
        JPanel palSubmit = new JPanel();//按钮panel
        palSubmit.setLayout(new FlowLayout(FlowLayout.LEADING));
        JPanel classPanel = new JPanel();
        classPanel.setLayout(new BorderLayout());
        tablePanel.add(palSubmit, BorderLayout.SOUTH);
        classPanel.add(tablePanel, BorderLayout.NORTH);
        loadTableData();
        return tablePanel;
    }
    
    /**
     * 加载特殊字符
     * <p>Description: </p>
     * 
     * @author wangxl
     * @time 2012-12-18
     * @return
     */
    private JPanel initSpecialCharacter() {
        JPanel bottomPanel = new JPanel();
        specialCharacterTableModel=new SysConfigTableModel(classes);
        VCIBaseTableNode specialCharacterTableNode=new VCIBaseTableNode(null);
        specialCharacterTableModel.addRow(1, specialCharacterTableNode);
        specialCharacterTable=new JTable(specialCharacterTableModel);
        specialCharacterTable.setRowHeight(25);
        specialCharacterTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent e) {
                 initContent();
            }
        }); 
        initTableProperty("");
        specialCharacterTable.setColumnSelectionAllowed(true);
        JScrollPane js=new JScrollPane(specialCharacterTable);
        JPanel centerBottomCPanel = new JPanel();
        centerBottomCPanel.setLayout(null);
        centerBottomCPanel.setPreferredSize(new Dimension(400,40));
        JLabel valueLabel = new JLabel(VALUE);
        
        valueLabel.setBounds(20, 10, 80, 25);
        valueText.setBounds(50, 10, 200, 25);
        centerBottomCPanel.add(valueLabel);
        valueText.setEditable(false);
        centerBottomCPanel.add(valueText);
        JTextField line = new JTextField();
        line.setPreferredSize(new Dimension(63,2));
        JPanel centerPanel = new JPanel();
        TitledBorder titleBorder = new TitledBorder(SPECIALCHAR);
        centerPanel.setBorder(titleBorder);
        centerPanel.setLayout(new BorderLayout());
        
        JPanel palTable = new JPanel(new BorderLayout());
        palTable.add(js, BorderLayout.CENTER);
        
        JPanel palInputAndBtns = new JPanel(new BorderLayout());
        palInputAndBtns.add(centerBottomCPanel, BorderLayout.CENTER);
        palInputAndBtns.add(bottomPanel, BorderLayout.SOUTH);
        
        centerPanel.setLayout(new BorderLayout());
        centerPanel.add(palTable, BorderLayout.CENTER);
        centerPanel.add(palInputAndBtns, BorderLayout.SOUTH);
        return centerPanel;
    }
    
    /**
     * 初始化table的Panle
     * @return
     */
    private JPanel initTablePanel(){
        initTable();
        JPanel palTable = new JPanel();
        palTable.setBorder(new TitledBorder(SPECIALCHARCLSF));
        JScrollPane jspTable = new JScrollPane();
        jspTable.setAutoscrolls(true);
        jspTable.getViewport().add(table);
        palTable.setLayout(new BorderLayout());
        palTable.add(jspTable, BorderLayout.CENTER);
        return palTable;
    }
    public void initTable(){
        columns = new String[3];
        topClasses = new Class[3];
        columns[0] = "选择";
        columns[1] = "名称";
        columns[2] = "描述";
        topClasses[0] = Boolean.class;
        for(int i=0;i<2;i++) {
            topClasses[i + 1] = String.class;
        }
        tableModel = new VCIBaseTableExtend(columns, topClasses);
        sorter = new TableSorterData(tableModel);
        table = new JTable(sorter);
        table.setColumnSelectionAllowed(true);
        sorter.setTableHeader(table.getTableHeader());
        table.setRowHeight(25);
        tbChkManager = new TableCheckboxManager(table);
        table.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
        tbChkManager.setHeaderShowCheckbox(0);
        table.getTableHeader().setReorderingAllowed(false);
        table.getColumnModel().getColumn(1).setPreferredWidth(150);
        table.getColumnModel().getColumn(2).setPreferredWidth(100);
        table.setCellSelectionEnabled(false);
        table.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                int selectedRow = table.getSelectedRow();
                VCIBaseTableNode clsfNode = tableModel.getValueAt(selectedRow);
                clsfObj = (SpecialCharClsfObject) clsfNode.getObj();
                id = clsfObj.getId();
                initTableProperty(id);
            }
        });
    }
 
    /**
     * 加载特殊字符
     * <p>Description: </p>
     * 
     * @author wangxl
     * @time 2012-12-18
     * @param id
     */
    public void initTableProperty(String id){
        try {
            specialCharacterTableModel.list.clear();
            valueText.setText("");
            SpecialCharObject[] specialCharInfos = new SystemCfgClientDelegate(LogonApplication.getUserEntityObject()).fetchSpecialChar(id);
            int length=specialCharInfos.length;
            int rowLength = length/12;
            if (length%12 != 0) {
                rowLength += 1;
            }
            for (int i = 0; i < rowLength; i++) {
                VCIBaseTableNode specialCharacterTableNode = new VCIBaseTableNode(null);
                for(int column = 0; column < 12;column++){
                    if (i*12 + column < length){
                        SpecialCharObject specialCharObject= specialCharInfos[i*12 + column];
                        String name=String.valueOf(column+1);
                        specialCharacterTableNode.setPropertyValueByName(name, specialCharObject);
                    }
                }
                specialCharacterTableModel.addRow(i + 1 , specialCharacterTableNode);
            }
            specialCharacterTable.setModel(specialCharacterTableModel);
            specialCharacterTableModel.fireTableDataChanged();
         }  catch (VCIError e) {
             VCIOptionPane.showError(LogonApplication.frame, LocaleDisplay.getI18nString(String.valueOf(e.code), "RMIPFramework", getLocale()));
         }
    }
    
    /**
     * 加载特殊分类
     * <p>Description: </p>
     * 
     * @author wangxl
     * @time 2012-12-18
     */
    public void loadTableData(){
        tableModel.list.clear();
            SpecialCharClsfObject[] Objects;
            try {
                Objects = new SystemCfgClientDelegate(LogonApplication.getUserEntityObject()).getSpecialCharClsfList();
                if(Objects.length!=0){
                    for (int i = 0 ; i < Objects.length ; i ++ ){
                        VCIBaseTableNode node = new VCIBaseTableNode(Objects[i]);
                        node.setPropertyValueByName(columns[1], Objects[i].getName());
                        node.setPropertyValueByName(columns[2], Objects[i].getDesc());
                        tableModel.addRow(tableModel.getRowCount(), node);
                    }
                    tbChkManager.addCheckBoxs(Objects.length);
                    tableModel.fireTableDataChanged();
                }
            } catch (VCIException e) {
                e.printStackTrace();
            }
    }    
    /**
     * 点击获得特殊字符
     * <p>Description: </p>
     * 
     * @author wangxl
     * @time 2012-12-18
     */
    public void initContent(){
        int rowIndex = specialCharacterTable.getSelectedRow();
        int columnIndex = specialCharacterTable.getSelectedColumn();
        Object selectCharObj =  specialCharacterTableModel.getValueAt(rowIndex, columnIndex);
        if(selectCharObj instanceof SpecialCharObject){
            specialCharObject = (SpecialCharObject)selectCharObj;
            valueText.setText(specialCharObject.getValue());
        } else {
            specialCharObject = null;
            valueText.setText("");
        }
    }
    public SpecialCharObject getSpecialCharObject() {
        return specialCharObject;
    }
    public void setValueText(String value) {
        valueText.setText(value);
    }
    
    public String getDescriptionArea() {
        return descriptionArea.getText().trim();
    }
    public String getNameFieldText() {
        return nameField.getText().trim();
    }
    public String getValueText() {
        return valueText.getText().trim();
    }
 
}