wangting
2024-11-27 3b3fd904b9b34e77445d749bca8c28beadcaf3db
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
package com.vci.client.framework.systemConfig.specialCharacter;
 
 
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedHashMap;
import java.util.LinkedList;
 
import javax.swing.JPanel;
import javax.swing.JTextArea;
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.rightConfig.object.FunctionObject;
import com.vci.client.framework.systemConfig.object.SpecialCharClsfObject;
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.VCIJPanel;
import com.vci.client.ui.swing.components.table.AbstractVCIJTableDataProvider;
import com.vci.client.ui.swing.components.table.VCIJTableNode;
import com.vci.client.ui.swing.components.table.VCIJTablePanel;
 
public class SpecialCharacterClassificationPanel  extends VCIBasePanel{
    
    /****************************国际化信息**********************************/
    private String DELETE = LocaleDisplay.getI18nString("rmip.framework.sysconfig.delete", "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 String SPECIALCHARCLSF = LocaleDisplay.getI18nString("rmip.framework.sysconfig.specialCharClsf", "RMIPFramework",getLocale());
    /**
     *   特殊字符分类的Panel
     */
    private static final long serialVersionUID = 1L;
    private KTextField nameField; //名称
    private JTextArea descriptionArea;//描述
    public SpecialCharClsfObject clsfObj = null;
 
    private LinkedList<VCIJButton> selfCustomButtons = new LinkedList<VCIJButton>();
    {
        selfCustomButtons.add(addButton);
        selfCustomButtons.add(editButton);
        selfCustomButtons.add(deleteButton);
    }
    public SpecialCharacterClassificationPanel(FunctionObject funcObj) {
        super(funcObj);
        init();
        checkPermission();
    }
 
    public void init() {
        this.setLayout(new BorderLayout());
        JPanel tablePanel = initTablePanel();
        this.add(tablePanel,BorderLayout.CENTER);
        initAction();
    }
 
    private void checkPermission(){
        checkRight(RightControlUtil.CREATE, addButton);
        checkRight(RightControlUtil.UPDATE, editButton);
        checkRight(RightControlUtil.DELETE, deleteButton);
    }
    /**
     * 初始化table的Panle
     * @return
     */
    private JPanel initTablePanel(){
        JPanel palTable = new JPanel();
        palTable.setLayout(new BorderLayout());
        palTable.setBorder(new TitledBorder(SPECIALCHARCLSF));
        palTable.add(tablePanel(), BorderLayout.CENTER);
        return palTable;
    }
    
    class MyDataProvider extends AbstractVCIJTableDataProvider<SpecialCharClsfObject> {
 
        @Override
        public SpecialCharClsfObject[] getDatas(int pageNo, int pageSize) {
            SpecialCharClsfObject[] Objects = null;
            try {
                Objects = new SystemCfgClientDelegate(LogonApplication.getUserEntityObject())
                        .getSpecialCharClsfList(pageNo,pageSize);
            } catch (VCIException e) {
                VCIOptionPane.showError(LogonApplication.frame,"RMIPFramework", e);
                return null;
            }
 
            return Objects;
        }
 
        @Override
        public VCIJTableNode<SpecialCharClsfObject> getNewRowNode(SpecialCharClsfObject dataObj) {
            VCIJTableNode<SpecialCharClsfObject> node = new VCIJTableNode<SpecialCharClsfObject>(
                    dataObj);
            node.setPropertyValue(getSpecialColumns()[0], dataObj.getName());
            node.setPropertyValue(getSpecialColumns()[1], dataObj.getDesc());
            return node;
        }
 
        @Override
        public String[] getSpecialColumns() {
            return "名称,描述".split(",");
        }
 
        @Override
        public int getTotal() {
            try {
                total = new SystemCfgClientDelegate(LogonApplication.getUserEntityObject()).getSpecialCharClsTotal();
            } catch (VCIException e) {
                e.printStackTrace();
                VCIOptionPane.showError(LogonApplication.frame,"RMIPFramework", e);
            }
            return this.total;
        }
    }
 
    MyDataProvider dataProvider = new MyDataProvider();
    VCIJTablePanel<SpecialCharClsfObject> tablePanel = new VCIJTablePanel<SpecialCharClsfObject>(dataProvider);
 
    private VCIJPanel tablePanel() {
        int startIndex = dataProvider.getDataColumnStartIndex();
        LinkedHashMap<Integer, Integer> widthMaps = new LinkedHashMap<Integer, Integer>();
        widthMaps.put(startIndex++, 300);
        widthMaps.put(startIndex++, 300);
        tablePanel.setColumnWidthMaps(widthMaps);
        tablePanel.setShowPaging(true);
        tablePanel.setCustomButtons(selfCustomButtons);
        tablePanel.setCustomButtonFlowAlign(FlowLayout.CENTER);
        tablePanel.setPageButtonFlowAlign(FlowLayout.CENTER);
        tablePanel.buildTablePanel();
        tablePanel.refreshTableData();
        return tablePanel;
 
    }
    
    /**
     * 
     * <p>Description:初始化特殊字符分类按钮 </p>
     * 
     * @author sunbo
     * @time 2012-5-25
     */
     public void initAction(){
//         添加分类
         addButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                addClassButton_conform();
            }
        });
         editButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    editClassButton_conform();
                }
            });
         deleteButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    deleteClassButton_conform();
                }
            });
     }
     
 
    /**
     * 添加特殊字符分类
     */
    private void addClassButton_conform(){
        new SpecialCharacterDialog("add",null);
        tablePanel.refreshTableData();
    }
    /**
     * 修改特殊字符分类
     */
    private void editClassButton_conform(){
        int len = tablePanel.getSelectedRowIndexs().length;
        if(len == 0){
            VCIOptionPane.showMessage(this, 
                    LocaleDisplay.getI18nString("rmip.stafforg.operate.deptedit1", "RMIPFramework", getLocale()));
            return;
        }
        if (len > 1){
            VCIOptionPane.showMessage(this, 
                    LocaleDisplay.getI18nString("rmip.stafforg.operate.deptedit2", "RMIPFramework", getLocale()));
            return;
        }
        SpecialCharClsfObject clsObj = tablePanel.getSelectedRowObjects().get(0);
        new SpecialCharacterDialog("modify",clsObj);
        tablePanel.refreshTableData();
    }
    /**
     * 
     * <p>Description: 删除分类</p>
     * 
     * @author sunbo
     * @time 2012-5-28
     */
    private void deleteClassButton_conform() {
        int len = tablePanel.getSelectedRowIndexs().length;
        if(len == 0){
            VCIOptionPane.showMessage(this, 
                    LocaleDisplay.getI18nString("rmip.stafforg.operate.deptdelete1", "RMIPFramework", getLocale()));
            return;
        }
        String[] puids = new String[len];
        for (int i = 0; i < len; i++) {
            SpecialCharClsfObject obj = tablePanel.getSelectedRowObjects().get(i);
            puids[i] = obj.getId();
        }
        int ok=VCIOptionPane.showQuestion(LogonApplication.frame,"您确定要删除选中的特殊字符分类吗?(删除分类将同时删除分类下特殊字符)");
        if (ok == 0) {
            boolean rs=true;
            try {
                rs = new SystemCfgClientDelegate(LogonApplication.getUserEntityObject()).deletSpecialCharClsf(puids);
            } catch (VCIException e) {
                VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework",e);
                return;
            }
            if (!rs) {
                return;
            }
        }
        tablePanel.refreshTableData();
    }
    
    
    private void decreaseSelRows(int start, Integer[] selRows){
        for(int i = start + 1; i < selRows.length; i++){
            selRows[i] = selRows[i] - 1;
        }
    }
    public String getDescriptionArea() {
        return descriptionArea.getText().trim();
    }
    public String getNameFieldText() {
        return nameField.getText().trim();
    }
}