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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package com.vci.client.uif.actions.client;
 
import java.util.Map;
 
import com.vci.client.common.FreeMarkerCommon;
import com.vci.client.common.FreemarkerParamObject;
import com.vci.client.logon.base.TabPanelManage;
import com.vci.client.uif.engine.client.UIHelper;
import com.vci.client.uif.engine.client.UILayoutPanel;
import com.vci.client.uif.engine.common.IDataNode;
import com.vci.mw.ClientContextVariable;
 
/**
 * 浏览按钮
 * 在新的tab页签中打开新的tab页
 * 通过选中对象的属性值判断打开新的tab也的type 和 context
 */
public class ViewSuperAction extends ViewAction{
 
    /**
     * 按钮参数
     */
    private Map<String, String> paramsMap = null;
    
    public ViewSuperAction(){
        super();
    }
    
    @Override
    public String getKey() {
        return "superview";
    }
    
    @Override
    public boolean checkHasRight(){
        // 按BO进行数据权限检查
        setDataRightCheckType(RightCheckConstants.RIGHT_CHECK_TYPE_B);
        return super.checkHasRight();
    }
    
    @Override
    public boolean doPost() {
        try{
            //获得按钮参数
            paramsMap = getButtonParams();
            //得到打开窗口的上下文信息
            String expression = paramsMap.get("expression");
            if(expression == null || expression.equals("")){
                UIFUtils.showMessage(ClientContextVariable.getFrame(),
                        "uifmodel.plm.uif.actions.syserror.parmerror", "");
                return false;
            }
            //XXX 获得用户所选数据,暂时默认选中对象一定是个BO对象
            Object[] objs = getDataModel().getSelectObjects();
            Map<String, FreemarkerParamObject> freeMap = getFreemarkerParamMap(((IDataNode) objs[0]).getValueMap());
            expression = expression.replaceAll("\\.", "Ψ");
            expression = FreeMarkerCommon.getValueByTempRule(freeMap, expression);
            String type = paramsMap.get("type:" + expression);
            String context = paramsMap.get("context:" + expression);
            String oidKey = paramsMap.get("oid:" + expression);
            String showName = paramsMap.get("showname:" + expression);
            if(type == null || type.equals("") || context == null || context.equals("")){
                UIFUtils.showMessage(ClientContextVariable.getFrame(),
                        "uifmodel.plm.uif.actions.syserror.parmerror", "");
                return false;
            }
            if(oidKey == null){
                oidKey = "";
            }
            // 得到业务对象、设置需要显示的属性值
            IDataNode idn = getBusinessObject(type, oidKey);
            if(idn.getMaterObject() == null){
                return false;
            }
            Map<String, String> map = idn.getValueMap();
             
            // 从主管理界面的数据列表中跳转到数据对象明细数据展示(Navigation\MainData\TabPage)
            map.put(UIHelper.TYPE,  type);
            map.put(UIHelper.CONTEXT, context);
            map.put(UIHelper.OID, cbo.getBusinessObject().oid);
            
            IDataNode inputData = (IDataNode)objs[objs.length - 1];
            
            UILayoutPanel uipl = new UILayoutPanel(map);
            uipl.setInputData(inputData);
            uipl.setSourceDataNode(idn);
            uipl.setDataValueMap(map);
            uipl.prep();
            uipl.initMainPanel();
            //在按钮参数中增加一个参数 showName 用来作为tab页的名称
            String tabName = "";
            if(showName == null || showName.equals("")){
                tabName = map.get("name");
            } else {
                if(showName.indexOf("${") != -1){
                    Map<String, FreemarkerParamObject> freeMap1 = getFreemarkerParamMap(map);
                    tabName = FreeMarkerCommon.getValueByTempRule(freeMap1, showName);
                } else {
                    tabName = showName;
                }
            }
            TabPanelManage.getInstance().addTabPanel(uipl, tabName, true);
            return false;
        } catch(Throwable e){
            UIFUtils.showErrorMessage(ClientContextVariable.getFrame(), e);
            return false;
        }
    }
}