wangting
2024-09-27 a3e87f78ee262ca9bb7d9b0c997639d5f3295890
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
package com.vci.client.uif.actions.client;
 
import java.util.Map;
 
import com.vci.client.bof.ClientBusinessObject;
import com.vci.client.ui.swing.components.VCIJDialog;
import com.vci.client.uif.engine.client.ChooseBusinessObjectDialog;
import com.vci.client.uif.engine.client.objopt.ObjectAddEditDialog;
import com.vci.client.uif.engine.common.DefaultTableNode;
import com.vci.mw.ClientContextVariable;
 
/**
 * 选择添加to端对象的选择事件
 * 负责打开选择窗口
 * 出窗口没有doAfter事件,在doPost完成后直接终止后续动作
 * @author VCI-STGK006
 *
 */
public class ChooseSelectAction extends DoseNotSelectDataAction{
    
    /**
     * 按钮参数
     */
    private Map<String, String> paramsMap = null;
 
    @Override
    public String getKey() {
        return "chooseselect";
    }
    
    @Override
    public boolean checkHasRight(){
        return true;
    }
 
    @Override
    public boolean doPost() {
        try {
            //获得按钮参数
            paramsMap = getButtonParams();
            //得到打开窗口的上下文信息
            String type = paramsMap.get("type");
            String context = paramsMap.get("context");
            if(type == null || type.equals("") || context == null || context.equals("")){
                UIFUtils.showMessage(ClientContextVariable.getFrame(),
                        "uifmodel.plm.uif.actions.syserror.parmerror", "");
                return false;
            }
            
            //用户输入属性 期中以t_oid开始的为业务对象属性,其它为link对象属性
            //获得按钮所属窗口,此窗口一定要是一个弹出窗口
            //并且窗口的类型一定是ObjectAddEditDialog
            ObjectAddEditDialog oaed = null;
            VCIJDialog dialog = getOwnerDialog();
            if(dialog instanceof ObjectAddEditDialog){
                oaed = (ObjectAddEditDialog) dialog;
            }
            if(oaed == null){
                return false;
            }
            
            //构建选择窗口
            ChooseBusinessObjectDialog cbd = new ChooseBusinessObjectDialog(
                    ClientContextVariable.getFrame(), type, context, false, "");
            if(cbd.isOk()){
                //得到用户所选数据
                Object[] selectedDatas = cbd.getSelectedData();
                //验证选择的数据类型,在选择窗口中只允许选择业务对象数据,
                //但是如果按钮配置错误有可能会选择成link类型数据
                DefaultTableNode dtn = (DefaultTableNode) selectedDatas[0];
                if(!(dtn.getMaterObject() instanceof ClientBusinessObject)){
                    UIFUtils.showMessage(ClientContextVariable.getFrame(),
                            "uifmodel.plm.uif.actions.syserror.parmerror", "");
                    return false;
                }
                //设置用户选择数据
                oaed.setSelectedDatas(selectedDatas);
                oaed.getOaep().setValueToUIControl(dtn, oaed.getTypeFlag());
            }
            return false;
        } catch (Exception e){
            UIFUtils.showErrorMessage(ClientContextVariable.getFrame(), e);
            return false;
        }
    }
 
}