田源
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
package com.vci.client.auth2.action;
 
import java.util.List;
 
import javax.swing.JOptionPane;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
 
import com.vci.client.auth2.utils.RightManagerHelper;
import com.vci.client.omd.btm.ui.BtmTree;
import com.vci.client.omd.btm.ui.ResourceTree;
import com.vci.client.omd.btm.wrapper.BtmItemWrapper;
import com.vci.corba.framework.data.GrandValue;
import com.vci.corba.common.VCIError;
import com.vci.corba.omd.btm.BtmItem;
 
public class SaveRuleAction extends Action {
 
    /**
     * 
     */
    private static final long serialVersionUID = 3971185753141477631L;
 
    public SaveRuleAction(String name) {
        super(name);
    }
 
    @Override
    public void execute() {
 
        // 获取资源类型树
        BtmItem btm = RightManagerHelper.getResourceType(getFunclet());
        if (btm == null) {
            JOptionPane.showMessageDialog(
                    com.vci.client.LogonApplication.frame,
                    "请选择业务类型", "提示", JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        // 操作信息
        List<GrandValue> values = RightManagerHelper.fillOperationsInfo(
                getFunclet(), btm.name);
        // 主体信息
        boolean isFill_subject = RightManagerHelper.fillSubjectInfo(
                getFunclet(), values);
        // 获取规则面板
        boolean isFill_object = RightManagerHelper.fillObjectInfo(getFunclet(), values);
        if (!isFill_subject || !isFill_object) {
            return;
        }
        // delete
 
        // DataBase
        boolean isTrue = false;
        try {
            isTrue = RightManagerHelper.getFrameworkService().deleteTypeRuleGrand(
                    btm.name, values.get(0).ruleName);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(
                    com.vci.client.LogonApplication.frame,
                    e.getMessage(), "错误提示", JOptionPane.ERROR_MESSAGE);
            return;
        }
        if (isTrue) {
 
        }
        // save
        boolean isTrue_add = false;
        try {
            isTrue_add = RightManagerHelper.getFrameworkService().saveGrand(
                    values.toArray(new GrandValue[values.size()]));
        } catch (Exception e) {
            JOptionPane.showMessageDialog(
                    com.vci.client.LogonApplication.frame,
                    ((VCIError) e).messages[0], "错误提示",
                    JOptionPane.ERROR_MESSAGE);
            return;
        }
        if (isTrue_add) {
            JOptionPane.showMessageDialog(
                    com.vci.client.LogonApplication.frame, "保存成功",
                    "提示", JOptionPane.INFORMATION_MESSAGE);
        }
        getFunclet().enable(false);
        // 资源树
        getFunclet().getResourceTree().setEnabled(true);
        
        
        
        refreshTable();
    }
 
    private void refreshTable() {
        BtmTree resource = (BtmTree) getFunclet().getResourceTree();
        TreePath path = resource.getSelectionPath();
        if (path == null) {
            return;
        }
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) path
                .getLastPathComponent();
        if (!node.isRoot()) {
            BtmItemWrapper bizItem = (BtmItemWrapper) node
                    .getUserObject();
            // 重新刷新规则面板信息
            GrandValue[] dataSets = RightManagerHelper
                    .getRightDatas(bizItem.btmItem.name);
            // 设置规则Table
            //add by caill 2015.12.18 增加参数bizItem.btmItem.name
            RightManagerHelper.setRuleListDatas(getFunclet(), dataSets,bizItem.btmItem.name);
            // 刷新操作中的生命周期与链接
 
            getFunclet().initLcOfOperationPanel(bizItem.btmItem);
 
        } else {
            RightManagerHelper.clear(getFunclet());
        }
        //RightManagerHelper.clear(getFunclet());
        // 资源树
        getFunclet().getResourceTree().setEnabled(true);
        getFunclet().enable(false);
        getFunclet().getRightMainPanel().getSelectedSubjectComponent().setEnabled(false);
        getFunclet().getRightMainPanel().getOrdinaryOpPanel().setEnabled(false);
        getFunclet().getRightMainPanel().getRelationAndLifeCycleOpPanel().setEnabled(false);
        getFunclet().getRightMainPanel().getLeft().setEnabled(false);
        getFunclet().getRightMainPanel().getRight().setEnabled(false);
    }
 
}