田源
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
package com.vci.client.uif.actions.client;
 
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;
 
import com.vci.client.bof.ClientLinkObject;
import com.vci.client.portal.utility.PLDefination;
import com.vci.client.ui.swing.VCIOptionPane;
import com.vci.client.ui.swing.components.VCIJOptionPane;
import com.vci.client.uif.engine.common.DefaultTableNode;
import com.vci.mw.ClientContextVariable;
 
/**
 * link类型移除按钮事件
 * 对于link对象的删除,只删除link对象
 * @author VCI-STGK006
 *
 */
public class RemoveAction extends AbstractBatchBusionessOperationAction {
    /**
     * 操作方法集合
     */
    private UIFUtils operation = 
            new UIFUtils();
    
    public RemoveAction(){
        super();
    }
    
    @Override
    public String getKey() {
        return REMOVE;
    }
    
    @Override
    public boolean checkHasRight(){
        // 按LBO进行数据权限检查
        setDataRightCheckType(RightCheckConstants.RIGHT_CHECK_TYPE_L);
        return super.checkHasRight();
    }
 
    @Override
    public boolean beforePost() {
        boolean res = false;
        //  删除前,给出提示
        if(getQuestionDialogResult("您确定要执行移除操作吗") == VCIJOptionPane.OK_OPTION){
            res = true;
        } else {
            res = false;
        }
        return res;
    }
 
    @Override
    public boolean doPost() {
        try {
            //检查用户选择数据
            Object[] objs = getDataModel().getSelectObjects();
            if(objs == null || objs.length < 1){
                return false;
            }
            PLDefination defination = getDefination();
            //modify 2014.03.09 start
            //得到所有要移除的link对象
            List<ClientLinkObject> loList = new ArrayList<ClientLinkObject>();
            for(int i = 0; i < objs.length; i++){
                DefaultTableNode dtn = (DefaultTableNode) objs[i];
                try {
                    //判断主对象类型,修改link是主对象类型一定是link对象
                    if (dtn.getMaterObject() instanceof ClientLinkObject){
                        ClientLinkObject lo = (ClientLinkObject) dtn.getMaterObject();
                        if(lo == null || lo.getLinkObject().oid == null
                                || "".equals(lo.getLinkObject().oid)){
                            int confirm = VCIOptionPane.showConfirmDialog(
                                    ClientContextVariable.getFrame(), 
                                    "关系不存在或者已经被删除.\n是否继续执行移除操作?",
                                    "系统提示",JOptionPane.YES_NO_OPTION);
                            if(confirm == JOptionPane.NO_OPTION){
                                return false;
                            }
                        } else {
                                //XXX lo中的信息不全,暂时使用上下文link类型代替lo的link类型
                                //这样做在特定条件下是有问题的
                                lo.getLinkObject().ltName = defination.getLinkType();
                                loList.add(lo);
                            }
                    } else {
                        //主对象为其他类型的处理
                        UIFUtils.showMessage(ClientContextVariable.getFrame(),
                                "uifmodel.plm.uif.actions.syserror.btnconferror");
                        return false;
                    }
                    
                } catch (Exception e){
                    UIFUtils.showErrorMessage(
                            ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.removeerror", e);
                    return false;
                }
            }
            
            //移除所有查找到的link对象
            boolean success = false;
            if(!loList.isEmpty()){
                success = operation.deleteLinkObject(
                        ClientContextVariable.getFrame(), loList.toArray(new ClientLinkObject[0]));
                if(success){
                    UIFUtils.showMessage(
                            ClientContextVariable.getFrame(),
                            "uifmodel.plm.uif.actions.removesuccessmsg","");
                }
            }
            return success;            
            //modify 2014.03.09 end
        } catch (Exception e){
            UIFUtils.showErrorMessage(
                    ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.removeerror", e);
            return false;
        }
    }
}