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
package com.vci.client.framework.appConfig;
 
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Locale;
 
import com.vci.client.LogonApplication;
import com.vci.client.framework.appConfig.object.AppConfigCategoryObject;
import com.vci.client.framework.appConfig.object.AppConfigDetailObject;
import com.vci.client.framework.delegate.AppConfigCategoryClientDelegate;
import com.vci.client.framework.delegate.AppConfigDetailClientDelegate;
import com.vci.client.ui.exception.VCIException;
import com.vci.client.ui.locale.LocaleDisplay;
import com.vci.client.ui.swing.VCIOptionPane;
 
public class AppConfigCategoryPanelActionListener implements ActionListener {
 
    private AppConfigCategoryPanel owner = null;
    private LinkedHashMap<String, Runnable> actionMaps = new LinkedHashMap<String, Runnable>();
 
    public AppConfigCategoryPanelActionListener(AppConfigCategoryPanel owner) {
        this.owner = owner;
        this.initActionMap();
    }
 
    private void initActionMap() {
        actionMaps.put("create", new Runnable() {
            public void run() {
                createAppConfigCategory();//
            }
        });
        actionMaps.put("edit", new Runnable() {
            public void run() {
                editAppConfigCategory();//
            }
        });
        actionMaps.put("delete", new Runnable() {
            public void run() {
                deleteAppConfigCategory();//
            }
        });
 
    }
 
    @Override
    public void actionPerformed(ActionEvent e) {
        String key = e.getActionCommand();
        if (actionMaps.containsKey(key)) {
            actionMaps.get(key).run();
        }
    }
 
    private void createAppConfigCategory() {
        showAppConfigCategoryDialog(null);
        if (owner.getOwnerPanel() != null) {
            owner.getOwnerPanel().refrashTree();
        }
    }
 
    private void showAppConfigCategoryDialog(AppConfigCategoryObject obj) {
        AppConfigCategoryDialog dialog = new AppConfigCategoryDialog(LogonApplication.frame, owner, obj);
//        dialog.setModal(true);
//        dialog.setVisible(true);
    }
 
    private void editAppConfigCategory() {
        int[] chk = owner.getTablePanel().getSelectedRowIndexs();
        Integer[] chkSelRows = new Integer[chk.length];
        for (int i = 0; i < chk.length; i++) {
            chkSelRows[i] = new Integer(chk[i]);
        }
        int len = chkSelRows.length;
        if (len == 0) {
            VCIOptionPane.showMessage(owner,
                    LocaleDisplay.getI18nString("rmip.stafforg.operate.deptedit1", "RMIPFramework", owner.getLocale()));
            return;
        }
        if (len > 1) {
            VCIOptionPane.showMessage(owner,
                    LocaleDisplay.getI18nString("rmip.stafforg.operate.deptedit2", "RMIPFramework", owner.getLocale()));
            return;
        }
        AppConfigCategoryObject obj = owner.getTablePanel().getSelectedRowObjects().get(0);
        showAppConfigCategoryDialog(obj);
        
        if (owner.getOwnerPanel() != null) {
            owner.getOwnerPanel().refrashTree();
        }        
    }
 
    private void deleteAppConfigCategory() {
        int[] chk = owner.getTablePanel().getSelectedRowIndexs();
        Integer[] chkSelRows = new Integer[chk.length];
        for (int i = 0; i < chk.length; i++) {
            chkSelRows[i] = new Integer(chk[i]);
        }
        int len = chkSelRows.length;
        if (len == 0) {
            VCIOptionPane.showMessage(owner, "请选择要删除的对象!");
            return;
        }
        String[] puids = new String[len];
        for (int i = 0; i < len; i++) {
            LinkedList<AppConfigCategoryObject> list = owner.getTablePanel().getSelectedRowObjects();
            puids[i] = list.get(i).getId();
            int ok = VCIOptionPane.showQuestion(LogonApplication.frame, "您确定要删除选中的对象吗?");
            if (ok == 0) {
                boolean rs = true;
                try {
                    rs = new AppConfigCategoryClientDelegate(LogonApplication.getUserEntityObject())
                            .deleteAppConfigCategory(puids);
                } catch (VCIException e) {
                    VCIOptionPane.showError(LogonApplication.frame,
                            LocaleDisplay.getI18nString(e, "RMIPFramework", Locale.getDefault()));
                    return;
                }
                if (!rs) {
                    return;
                }
                owner.getTablePanel().refreshTableData();
            }
        }
        
        if (owner.getOwnerPanel() != null) {
            owner.getOwnerPanel().refrashTree();
        }
    }
}