xiejun
2023-07-27 5f545a51231ab4955763fd812a0d914b1d8bc561
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
package com.vci.ubcs.codeapply;
 
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JPanel;
import com.vci.base.ui.exception.VCIException;
import com.vci.base.ui.swing.VCISwingUtil;
import com.vci.base.ui.swing.components.VCIJButton;
import com.vci.base.ui.swing.components.VCIJDialog;
import com.vci.base.ui.swing.components.VCIJPanel;
import com.vci.base.ui.swing.components.VCIJTable;
import com.vci.base.ui.swing.components.table.VCIJTablePanel;
import org.apache.poi.ss.formula.functions.T;
 
public class RMDataReferTempDialog extends VCIJDialog {
    private VCIJDialog rmDataAddDialog;
    private String templateId = "";
    private RMDataReferTempDialogActionListener actionListener = new RMDataReferTempDialogActionListener(this);
    private VCIJButton btnOk = VCISwingUtil.createVCIJButton("ok", "确定", "确定", "accept.png", actionListener);
    private VCIJButton btnCancel = VCISwingUtil.createVCIJButton("cancel", "取消", "取消", "cancel.png", actionListener);
    private static final long serialVersionUID = 1L;
    public RMDataReferTempDialog(VCIJDialog rmDataAddDialog,String templateId) {
        //super(true);
        this.rmDataAddDialog = rmDataAddDialog;
        this.templateId = templateId;
        init();
        setTitle("引用模板-属性选择");
        //initDialogSize(rmDataAddDialog.getWidth(), rmDataAddDialog.getHeight());
    }
 
    private void init(){
        this.setLayout(new BorderLayout());
        JPanel panel = new JPanel(new FlowLayout());
        panel.add(btnOk);
        panel.add(btnCancel);
 
        this.add(createRMDataMainPanel(), BorderLayout.CENTER);
        this.add(panel,BorderLayout.SOUTH);
 
        Dimension dime = Toolkit.getDefaultToolkit().getScreenSize().getSize();
        int x = dime.width/6;
        int y = dime.height/6 + 50;
        this.setLocation(x , y);
        this.setSize(850, 400);
    }
 
    private boolean fromTableDoubleClick = false;
    public boolean isFromTableDoubleClick() {
        return fromTableDoubleClick;
    }
    public void setFromTableDoubleClick(boolean fromTableDoubleClick) {
        this.fromTableDoubleClick = fromTableDoubleClick;
    }
 
    private VCIJPanel createRMDataMainPanel(){
        VCIJPanel rmDataTablePanel = new VCIJPanel();
        if(!templateId.equals("")){
            //rmDataTablePanel = getRMDataMainPanel("", "", templateId);
        }
        rmDataTablePanel.setPreferredSize(new Dimension(880,300));
        return rmDataTablePanel;
    }
    private VCIJTablePanel<T> tablePanel = null;
    private CodeDataMainPanelDataProvider dataProvider;
    public VCIJTablePanel getRMDataMainPanel(String libId, String classifyId, String templateId) {
        dataProvider = new CodeDataMainPanelDataProvider();
        tablePanel = new VCIJTablePanel<T>(dataProvider);
        //tablePanel.setCustomButtons(getCombinedButtons());
        tablePanel.setShowExport(true);
        tablePanel.setShowPaging(true);
        tablePanel.setPageButtonFlowAlign(FlowLayout.CENTER);
        tablePanel.setCustomButtonFlowAlign(FlowLayout.CENTER);
        tablePanel.buildTablePanel();
        int columnCount = tablePanel.getTable().getColumnCount();
        tablePanel.getTable().getColumnModel().getColumn(columnCount - 2).setPreferredWidth(150);
        tablePanel.getTable().getColumnModel().getColumn(columnCount - 4).setPreferredWidth(150);
        /**
         * 禁止table表头拖动,防止第一列的复选框和第二列的序号拖动出问题:
         * 点击某行,表格中的复选框看不到,且选中表头上的复选框系统会报错;数据信息显示不正确。
         * 2012-12-4 wangxl
         */
        tablePanel.getTable().getTableHeader().setReorderingAllowed(false);
        tablePanel.refreshTableData();
         VCIJTable table = tablePanel.getTable();
        table.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                if (e.getButton() == 1 && e.getClickCount() == 2) {
                    setFromTableDoubleClick(true);
                    btnOk.doClick();
                }
            }
        });
        return tablePanel;
    }
 
    /***获取资源数据的主面板**/
/*
    public RMDataMainPanel getRMDataMainPanel() {
        return rmDataMainPanel;
    }
*/
    /*private RMDataTransmitObject loadTemplateAttributes(String libId, String classifyId, String templateId){
        LinkedHashMap<String, TemplatePropertyObject> tempPropObjsMap = new LinkedHashMap<String, TemplatePropertyObject>();
        LinkedList<TemplatePropertyObject> tempPropObjsList = new LinkedList<TemplatePropertyObject>();
 
        LinkedHashMap<String, AttributeObject> tempAttrObjsMap = new LinkedHashMap<String, AttributeObject>();
        LinkedList<AttributeObject> tempAttrObjsList = new LinkedList<AttributeObject>();
 
        TemplateObject templateObject = null;
 
        RMDataTransmitObject transmit = new RMDataTransmitObject();
        transmit.setLibId(libId);
        transmit.setClassifyId(classifyId);
        transmit.setTemplateId(templateId);
        transmit.setSpecialLib(true);//added by ligang 2012.07.04备件库不做权限校验
        try{
            UserEntityObject userEntityObject = LogonApplication.getUserEntityObject();
            TemplateClientDelegate  tempDel = new TemplateClientDelegate(userEntityObject);
            RMTemplateProertyClientDelegate tempPropDel = new RMTemplateProertyClientDelegate(userEntityObject);
            AttributeClientDelegate attrDel = new AttributeClientDelegate(userEntityObject);
//            RMTypeObject rmTypeObject = new RMTypeClientDelegate(userEntityObject).getRMTypeById(classifyId);
            RMTypeObject rmTypeObject = new RMTypeObject();
            // 从资源分类树中选择的对应的分类对象
            transmit.setRmTypeObject(rmTypeObject);
 
            // 获取模板对象
            templateObject = tempDel.getTemplateObjectById(templateId);
            transmit.setTemplateObject(templateObject);
 
            // 获取模板定义的属性对象(这个对象包含的是属性在模板中是否为关键属性、可否为空等等)
            TemplatePropertyObject[] tempPropObjs = tempPropDel.getTempletePropertys(templateId);
            for(TemplatePropertyObject obj : tempPropObjs){
                tempPropObjsMap.put(obj.getAttrId(), obj);
                tempPropObjsList.add(obj);
            }
            transmit.setTempPropObjsMap(tempPropObjsMap);
            transmit.setTempPropObjsList(tempPropObjsList);
 
            // 获取模板定义的属性对象对应到的真实的属性对象(系统配置模块定义的那些属性对象)
            AttributeObject[] attrObjs = attrDel.fetchAttributeByTemplateId(templateId);
            for(AttributeObject obj : attrObjs){
                tempAttrObjsMap.put(obj.getId(), obj);
                tempAttrObjsList.add(obj);
            }
            transmit.setTempAttrObjsMap(tempAttrObjsMap);
            transmit.setTempAttrObjsList(tempAttrObjsList);
 
        }catch(VCIException e){
            e.printStackTrace();
        }
        return transmit;
    }*/
 
}