田源
2024-03-07 4b4083fd73dc27ece42f4835483565eef0e4f608
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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
package com.vci.client.framework.systemConfig.stafforgmanage;
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
 
import javax.swing.BorderFactory;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.border.TitledBorder;
import javax.swing.event.TreeExpansionEvent;
import javax.swing.event.TreeExpansionListener;
import javax.swing.tree.TreePath;
 
import com.vci.client.LogonApplication;
import com.vci.client.common.VCIBasePanel;
import com.vci.client.common.objects.DeptObject;
import com.vci.client.common.objects.UserObject;
import com.vci.client.framework.delegate.RightManagementClientDelegate;
import com.vci.client.framework.rightConfig.object.FunctionObject;
import com.vci.client.framework.util.RightControlUtil;
import com.vci.client.ui.excel.ExcelFileOperation;
import com.vci.client.ui.exception.VCIException;
import com.vci.client.ui.locale.LocaleDisplay;
import com.vci.client.ui.process.QANProcessBar;
import com.vci.client.ui.process.QANProcessBarFrame;
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.treeTable.InterfaceTreeTableModel;
import com.vci.client.ui.treeTable.JTreeTable;
import com.vci.client.ui.treeTable.TreeTableModel;
import com.vci.common.utility.ObjectUtility;
/**
 * <p>Title: DeptTablePanel</p>
 * <p>Description:部门管理 </p>
 * <p>Copyright: Copyright (c) 2012</p>
 * <p>Company: VCI</p>
 * @author wangxl
 * @time 2012-5-9
 * @version 1.0
 */
public class DeptTablePanel extends VCIBasePanel {
 
    private static final long serialVersionUID = 1L;
    private boolean fromManualExpand = false;
    private String[] columns = {"名称","编号","代号","专业","描述"};
    DeptObject rootObj;
    private Class[] colClasses = {InterfaceTreeTableModel.class,String.class,String.class,String.class,String.class} ;
    private PLDeptInfoDataTreeModel treeTableModel = null;
    private Object transObject = "";
    private JTreeTable treeTable = null;
    private TreeTableModel.TreeTableNode rootNode = null;
    
    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 VCIJButton btnDisplay = VCISwingUtil.createVCIJButton("", "统计","统计","group.gif",null);
    private VCIJButton rightButton = VCISwingUtil.createVCIJButton("", "分配成员","分配成员", "user.gif" ,null);
    private VCIJButton importButton = VCISwingUtil.createVCIJButton("import", "导入部门" ,"导入部门" , "import.gif",null);
    private VCIJButton exportButton = VCISwingUtil.createVCIJButton("export", "导出部门模板", "导出部门模板", "export.gif", null);
    
    public DeptTablePanel(FunctionObject funcObj){
        super(funcObj);
        init();
        if(funcObj.getId() != null){
            checkPermission();
        }
    }
    
    public void init(){
        //LogonApplication.getUserEntityObject().setModules(this.getClass().getName());
        LogonApplication.getUserEntityObject().setModules("部门管理");
        initControl();//添加按钮
        initAction();//初始化按钮点击事件
    }
    
    private void checkPermission(){
        checkRight(RightControlUtil.CREATE, addButton);
        checkRight(RightControlUtil.UPDATE, editButton);
        checkRight(RightControlUtil.DELETE, deleteButton);
        checkRight(RightControlUtil.FREEZE, rightButton);
        checkRight(RightControlUtil.DISCARD, btnDisplay);
        checkRight(RightControlUtil.IMPORT, importButton);
        checkRight(RightControlUtil.EXPORT, exportButton);
    }
    
    /**
     * <p>Description:添加按钮 </p>
     * 
     * @author wangxl
     * @time 2012-5-10
     */
    private void initControl(){
        this.setLayout(new BorderLayout());
        this.setBorder(new TitledBorder("部门管理"));
        try{
            JScrollPane jspTable = reloadTree();
            this.add(jspTable, BorderLayout.CENTER);
        }catch (VCIException e) {
            VCIOptionPane.showError(LogonApplication.frame, "RMIPBom", e);
        }
        
        JPanel palSubmit = new JPanel();
        palSubmit.setLayout(new FlowLayout());
        
        palSubmit.add(addButton);
        palSubmit.add(editButton);
        palSubmit.add(deleteButton);
        palSubmit.add(rightButton);
        palSubmit.add(btnDisplay);
        palSubmit.add(importButton);
        palSubmit.add(exportButton);
        palSubmit.setBorder(BorderFactory.createLineBorder(Color.gray));
        this.add(palSubmit, BorderLayout.SOUTH);
    }
    
    public JScrollPane reloadTree() throws VCIException{
        DeptObject rootDeptObj = new DeptObject();
        treeTableModel = new PLDeptInfoDataTreeModel(transObject, columns, colClasses);
        rootNode = treeTableModel.getRootNode();
        rootObj = new DeptObject();
        rootObj.setName("部门");
        rootNode.setObj(rootObj);
        this.loadTreeTableData(rootNode, rootDeptObj);
        treeTable = new JTreeTable(treeTableModel);
        treeTable.setRowHeight(25);
        treeTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        treeTable.getTableHeader().setReorderingAllowed(false);
        treeTable.getTableHeader().setResizingAllowed(true);
        treeTable.setColumnSelectionAllowed(false);
        treeTable.setShowGrid(true);
        treeTable.getColumnModel().getColumn(0).setMinWidth(200);
        treeTable.getTree().setCellRenderer(new DeptInfoTreeTableCellRender());
        treeTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
 
 
        treeTable.getColumnModel().getColumn(1).setMinWidth(150);
        treeTable.getColumnModel().getColumn(2).setMinWidth(150);
        treeTable.getColumnModel().getColumn(3).setMinWidth(250);
        treeTable.getColumnModel().getColumn(4).setMinWidth(250);
        
        treeTable.getTree().addTreeExpansionListener(new TreeExpansionListener(){
            public void treeExpanded(TreeExpansionEvent e) {
                if(fromManualExpand) return;
                TreePath path = e.getPath();
                TreeTableModel.TreeTableNode tableNode = (TreeTableModel.TreeTableNode)path.getLastPathComponent();
                if(!tableNode.isExpand()){
                    loadSelectedTreeNodeChild(tableNode);
                    // 展开过就不再加载数据
                    tableNode.setExpand(true);
                }
            }
            public void treeCollapsed(TreeExpansionEvent e) {}
        });
        JScrollPane jspTable = new JScrollPane();
        jspTable.getViewport().add(treeTable);
        return jspTable;
    }
    
    
    /**
     * 事件
     */
    private void initAction(){
        addButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
                addButton_conform();
            }
        });
        
         editButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    editButton_conform();
                }
         });
         
         deleteButton.addActionListener(new java.awt.event.ActionListener() {
             public void actionPerformed(ActionEvent e) {
                 deleteButton_conform();
             }
         });
         rightButton.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent arg0) {
                 rightButton_conform();
             }
         });
         
         btnDisplay.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg0) {
                    btnDisplay_conform();
                }
         });
         
         importButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg0) {
                    importButton_conform();
                }
         });
         
         exportButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg0) {
                    exportButton_conform();
                }
         });
    }
    
    /**
     * 添加事件
     */
    private void addButton_conform(){
        if (null == this.treeTable.getTree().getSelectionPaths()){
            VCIOptionPane.showMessage(this, "请选择节点!");
            return;
        }
        TreePath path = this.treeTable.getTree().getSelectionPaths()[0];
        TreeTableModel.TreeTableNode treeNode = (TreeTableModel.TreeTableNode)path.getLastPathComponent();
        DeptObject parentObj =(DeptObject)treeNode.getObj();
        DeptDialog dial =    new DeptDialog(this,parentObj, "addDept");
        dial.setDialogCallback(new Runnable() {
            @Override
            public void run() {
                // TODO Auto-generated method stub
                tableRowSelect();
            }
        });
    }
    public void tableRowSelect(){
        treeTable.selectAll();
    }
    /**
     * 修改事件
     */
    private void editButton_conform(){
        if (null == this.treeTable.getTree().getSelectionPaths()){
            VCIOptionPane.showMessage(this, "请选择节点!");
            return;
        }
        TreePath path = this.treeTable.getTree().getSelectionPaths()[0];
        TreeTableModel.TreeTableNode treeNode = (TreeTableModel.TreeTableNode)path.getLastPathComponent();
        DeptObject currentObj =(DeptObject)treeNode.getObj();
        if (currentObj == rootObj){
            VCIOptionPane.showMessage(this, "此节点为部门标示,不能修改.请选择其它节点!");
            return;
        }
        TreeTableModel.TreeTableNode parentNode = (TreeTableModel.TreeTableNode)treeNode.getParent();
        DeptObject parentObj =(DeptObject)parentNode.getObj();
        new DeptDialog(this, parentObj, currentObj, "editDept");
        
    }
    /**
     * 删除事件
     */
    private void deleteButton_conform(){
        if (null == this.treeTable.getTree().getSelectionPaths()){
            VCIOptionPane.showMessage(this, "请选择部门节点!");
            return;
        }
        if (this.treeTable.getTree().getSelectionPaths().length > 1){
            VCIOptionPane.showMessage(this, "仅支持单个部门节点的删除操作,请重新选择!");
            return;
        }
        TreePath path = this.treeTable.getTree().getSelectionPaths()[0];
        TreeTableModel.TreeTableNode treeNode = (TreeTableModel.TreeTableNode)path.getLastPathComponent();
        DeptObject currentObj =(DeptObject)treeNode.getObj();
        if (currentObj == rootObj){
            VCIOptionPane.showMessage(this, "此节点为部门标示,不能删除.请选择其它节点!");
            return;
        }
        int ask = VCIOptionPane.showQuestion(this,
                "确定要删除所选择的部门吗?");
        if(ask == 1) return;
        try {
            DeptObject[] deptObjs = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchDepartmentInfosById(currentObj.getId());
            if(deptObjs == null){
                return;
            }
            for (int i = 0 ; i < deptObjs.length ; i ++){
                UserObject[] userObj = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).getUserByDeptId(deptObjs[i].getId());
                if (userObj.length > 0){
                    VCIOptionPane.showMessage(this, "要删除的部门树中,名称为'"+deptObjs[i].getName() +"'的部门中存在人员,不能直接删除!");
                    return;
                }
            }
            
           new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).deleteDepartment(new String[]{currentObj.getId()});
          
          this.removeSelectedTreeNodeByDelete(treeNode);
            
        } catch (VCIException e) {
            VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
        }
        
    }
    
    private void rightButton_conform(){
        if (null == this.treeTable.getTree().getSelectionPaths()){
            VCIOptionPane.showMessage(this, "请选择部门节点!");
            return;
        }
        if (this.treeTable.getTree().getSelectionPaths().length > 1){
            VCIOptionPane.showMessage(this, "仅支持单个部门的分配人员操作,请重新选择!");
            return;
        }
        TreePath path = this.treeTable.getTree().getSelectionPaths()[0];
        TreeTableModel.TreeTableNode treeNode = (TreeTableModel.TreeTableNode)path.getLastPathComponent();
        DeptObject currentObj =(DeptObject)treeNode.getObj();
        if (currentObj == rootObj){
            VCIOptionPane.showMessage(this, "此节点为部门标示,不能分配人员操作.请选择其它节点!");
            return;
        }
        RightDeptDialog dialog = new RightDeptDialog(currentObj);
        dialog.setVisible(true);
    }
    private void btnDisplay_conform(){
        if (null == this.treeTable.getTree().getSelectionPaths()){
            VCIOptionPane.showMessage(this, "请选择部门节点!");
            return;
        }
        if (this.treeTable.getTree().getSelectionPaths().length > 1){
            VCIOptionPane.showMessage(this, "仅支持单个部门的统计操作,请重新选择!");
            return;
        }
        TreePath path = this.treeTable.getTree().getSelectionPaths()[0];
        TreeTableModel.TreeTableNode treeNode = (TreeTableModel.TreeTableNode)path.getLastPathComponent();
        DeptObject currentObj =(DeptObject)treeNode.getObj();
        DisplayDialog dialog = null;
        
        dialog = new DisplayDialog(new DeptObject[]{currentObj});
        dialog.setModal(true);
        dialog.setVisible(true);
    }
    
    private void importButton_conform() {
        File f = this.getFile();
        if (f == null) {
            return;
        }
        if (!f.exists()) {
            VCIOptionPane.showMessageDialog(this, "请选择文件进行导入!");
            return;
        }
        final String filePath = f.getAbsolutePath();
        final QANProcessBarFrame frame = new QANProcessBarFrame();
        Thread t = new Thread() {
            public void run() {
                boolean b = false;
                frame.setContent("正在进行处理数据,请稍等......");
                try {
                    b = importData(frame, filePath);
                } catch (VCIException e){
                    
                } finally {
                    frame.setProcessBarCancel(true);
                    if (b) {
                        VCIOptionPane.showMessageDialog(LogonApplication.frame,
                                "导入成功!");
                    }else{
                        VCIOptionPane.showMessageDialog(LogonApplication.frame,
                                "导入失败!");
                    }
                }
            }
        };
        QANProcessBar bar = new QANProcessBar(t, frame, frame,
                "导入部门数据......", false);
        bar.setVisible(true);
        
    }
    
    private boolean importData(QANProcessBarFrame frame, String filePath) throws VCIException {
        String[][] datas = new ExcelFileOperation().readExcelFileInfo(filePath);
        if (datas == null || datas.length < 2) {
            return true;
        }
        Map<String, String> idMap = new HashMap<String, String>();
        String parentId = "";
        String id = "";
        DeptObject[] deptObjs = new DeptObject[datas.length - 1];
        for(int i = 1; i < datas.length; i++){
            if (idMap.get(datas[i][0]) != null) {
                id = idMap.get(datas[i][0]);
            } else {
                id = ObjectUtility.getNewObjectID36();
                idMap.put(datas[i][0], id);
            }
            if (datas[i][4] == null || datas[i][4].trim().equals("")) {
                parentId = "";
            } else if (idMap.get(datas[i][4]) != null) {
                parentId = idMap.get(datas[i][4]);
            } else {
                parentId = ObjectUtility.getNewObjectID36();
                idMap.put(datas[i][4], parentId);
            }
            deptObjs[i - 1] = constructDeptObj(datas[i], id, parentId);
        }
        frame.setContent("正在存储数据,请稍等......");
        boolean  rs = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).batchsaveDepartment(deptObjs);
        frame.setContent("存储完成!");
        return rs;
    }
    
    private DeptObject constructDeptObj(String[] data, String id, String parentId) {
        DeptObject  departmentInfo = new DeptObject();
        departmentInfo.setId(id);
        departmentInfo.setNum(data[1]);
        departmentInfo.setName(data[2]);
        departmentInfo.setCode(data[3]);
        departmentInfo.setSpecialties(data[4]);
        departmentInfo.setDescription(data[5]);
        departmentInfo.setParentId(parentId);
        departmentInfo.setStatus((short)0);
        departmentInfo.setCreateTime(System.currentTimeMillis());
        departmentInfo.setCreateUser(LogonApplication.getUserEntityObject().getUserName());
        departmentInfo.setUpdateTime(System.currentTimeMillis());
        departmentInfo.setUpdateUser(LogonApplication.getUserEntityObject().getUserName());
        departmentInfo.setGrantor("");
        return departmentInfo;
    }
    
    
    
    private void exportButton_conform() {
        String[] columns = new String[] { "ID", "编号", "名称", "代码", "专业", "父ID", "描述"};// 设置表单列名
        final boolean[] ress = new boolean[1];
        String[][] datas = new String[1][columns.length];
        datas[0] = columns;
        ress[0] = exportExcel(datas, "部门模板");
        final QANProcessBarFrame frame = new QANProcessBarFrame();
        final QANProcessBar[] bar = new QANProcessBar[1];
        bar[0] = new QANProcessBar(new Thread() {
            public void run() {
                try {
                    frame.setContent("正在导出Excel文件,请稍等......");
                } finally {
                    frame.setProcessBarCancel(true);
                }
            }
        }, frame, frame, "人员模板导出", false);
        bar[0].setVisible(true);
        if (ress[0]) {
            VCIOptionPane.showMessageDialog(LogonApplication.frame, "导出成功!");
        }
    }
    
    private boolean exportExcel(String[][] datas, String title){
        File f = this.getFile();
        if (f == null) return false;
        /**判断导出的文件是否被使用的校验,如果文件已经打开,不允许导入**/
        if(!f.renameTo(f) && f.exists()) {
            VCIOptionPane.showMessageDialog(this, "文件已经被使用,请重新选择!");
            if(exportExcel(datas, title)){
                return true;
            }
        }
        new ExcelFileOperation().writeExcelFileInfo(f.getPath(), title, datas);
        return true;
    }
    
    private File getFile() {
        File f = null;
        JFileChooser fileDialog = new JFileChooser("选择文件");
        @SuppressWarnings("static-access")
        String fileURL = new VCISwingUtil().getExcelFileURL(fileDialog, true, "");
        if (fileURL == null) return null;
        f = new File(fileURL);
        return f;
    }
    
    /**
     * <p>Description: 获取顶级部门</p>
     * 
     * @author wangxl
     * @time 2012-5-14
     * @param rootNode
     * @param rootDeptObj
     */
    private void loadTreeTableData(TreeTableModel.TreeTableNode rootNode, DeptObject rootDeptObj){
        DeptObject[] deptObjs  = null;
        try {
            deptObjs = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchDepartmentInfoRoot();
            if (deptObjs != null){
                if (deptObjs.length > 0){
                    for (int i = 0 ; i < deptObjs.length ; i ++){
                        TreeTableModel.TreeTableNode tableNode = treeTableModel.new TreeTableNode(rootNode, deptObjs[i]);
                        rootNode.addChild(tableNode);
                        setPropertyValue(tableNode);
                    }
                }
            }
        }catch(VCIException e) {
            VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
        }
    }
    /**
     * <p>Description:获取子部门 </p>
     * 
     * @author wangxl
     * @time 2012-5-14
     * @param parentTableNode
     */
    private void loadSelectedTreeNodeChild(TreeTableModel.TreeTableNode parentTableNode){
        try{
            if(parentTableNode.getObj() instanceof DeptObject){
                DeptObject parentObj = (DeptObject)parentTableNode.getObj();
                DeptObject[] childStructDatas = null ; 
                if (parentObj.getId() == null ){
                    parentTableNode.removeAll();
                    childStructDatas = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchDepartmentInfoRoot();
                }else {
                    childStructDatas = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchDepartmentInfoByParentId(parentObj.getId());
                }
                parentTableNode.setExpand(true);
                if (childStructDatas != null){
                    for (int i = 0 ; i < childStructDatas.length ; i ++){
                        TreeTableModel.TreeTableNode tableNode = treeTableModel.new TreeTableNode(parentTableNode, childStructDatas[i]);
                        parentTableNode.addChild(tableNode);
                        setPropertyValue(tableNode);
                    }
                }
                
                // 设置选择节点
                this.treeTable.getTree().setSelectionPath(new TreePath(parentTableNode));
            }
        } catch (VCIException e) {
            VCIOptionPane.showError(LogonApplication.frame, "RMIPFramework", e);
        }
    }
    
    /**
     * <p>Description:新增加的部门节点插入到树上 </p>
     * 
     * @author wangxl
     * @time 2012-5-15
     * @param newDeptObj
     */
    public void insertNewDeptObjToTree(DeptObject newDeptObj){
        TreePath path = this.treeTable.getTree().getSelectionPath();
        TreeTableModel.TreeTableNode parentTreeNode = (TreeTableModel.TreeTableNode)path.getLastPathComponent(); 
        TreeTableModel.TreeTableNode treeNode = treeTableModel.new TreeTableNode(parentTreeNode, newDeptObj);
        parentTreeNode.addChild(treeNode);
        setPropertyValue(treeNode);
        // 设置选择节点
        parentTreeNode.setLeaf(false);
        parentTreeNode.setExpand(true);
 
        TreePath selectedPath = new TreePath(treeNode);
        this.fromManualExpand = true;
        treeTable.getTree().expandPath(selectedPath);
        this.fromManualExpand = false;
        treeTable.getTree().setSelectionPath(selectedPath);
        
    }
    /**
     * <p>Description:修改后,更新树节点信息 </p>
     * 
     * @author wangxl
     * @time 2012-5-15
     * @param currentDeptObj
     */
    public void updateCurrentDeptObjForTree(DeptObject currentDeptObj){
        TreePath path = this.treeTable.getTree().getSelectionPath();
        TreeTableModel.TreeTableNode tableNode = (TreeTableModel.TreeTableNode)path.getLastPathComponent();
        tableNode.setObj(currentDeptObj);
        setPropertyValue(tableNode);
        treeTable.getTree().updateUI();
    }
    /**
     * <p>Description:删除后,节点移除 </p>
     * 
     * @author wangxl
     * @time 2012-5-15
     * @param isRoot
     * @throws VCIException
     */
    public void removeSelectedTreeNodeByDelete(TreeTableModel.TreeTableNode treeNode) throws VCIException{
 
            TreeTableModel.TreeTableNode parentTreeNode = (TreeTableModel.TreeTableNode)treeNode.getParent();
            parentTreeNode.removeChild(treeNode);
            this.treeTable.getTree().setSelectionPaths(null);
            this.treeTable.updateUI();
            this.treeTable.setShowGrid(true);
    }
    
    /**
     * <p>Description:单元格属性填充 </p>
     * 
     * @author wangxl
     * @time 2012-5-14
     * @param tableNode
     */
    private void setPropertyValue(TreeTableModel.TreeTableNode tableNode){
        DeptObject deptObj = (DeptObject)tableNode.getObj();
        tableNode.setPropertyValueByName(columns[1], deptObj.getNum() == null ? "" : deptObj.getNum());
        tableNode.setPropertyValueByName(columns[2], deptObj.getCode() == null ? "" : deptObj.getCode());
        tableNode.setPropertyValueByName(columns[3], deptObj.getSpecialties() == null ? "" : deptObj.getSpecialties());
        tableNode.setPropertyValueByName(columns[4], deptObj.getDescription() == null ? "" : deptObj.getDescription());
        
    }
}