ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
package com.vci.client.oq.ui;
 
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedHashMap;
import java.util.LinkedList;
 
import com.vci.client.common.providers.ServiceProvider;
import com.vci.client.oq.QTClient;
import com.vci.client.oq.QTDClient;
import com.vci.client.ui.swing.VCIOptionPane;
import com.vci.client.ui.swing.VCISwingUtil;
import com.vci.client.ui.swing.components.VCIJButton;
import com.vci.client.ui.swing.components.VCIJDialog;
import com.vci.client.ui.swing.components.VCIJLabel;
import com.vci.client.ui.swing.components.VCIJPanel;
import com.vci.client.ui.swing.components.VCIJTextField;
import com.vci.client.ui.swing.components.table.AbstractVCIJTableDataProvider;
import com.vci.client.ui.swing.components.table.VCIJTableNode;
import com.vci.client.ui.swing.components.table.VCIJTablePanel;
import com.vci.corba.common.VCIError;
import com.vci.corba.omd.qtm.QTInfo;
import com.vci.mw.ClientContextVariable;
 
public class SelectorQTDialog extends VCIJDialog {
 
    private VCIJButton btnOk = VCISwingUtil.createVCIJButton("ok", "确定", "确定", "accept.png");
    private VCIJButton btnCancel = VCISwingUtil.createVCIJButton("cancel", "取消", "取消", "cancel.png");
    private VCIJTextField attrText =  new  VCIJTextField("");
    private VCIJLabel  attrLable = new VCIJLabel();
    private VCIJPanel northPanel= new VCIJPanel();
    private QTInfo item;
 
    public QTInfo getItem() {
        return item;
    }
 
    public void setItem(QTInfo item) {
        this.item = item;
    }
    
    private String attr;
    
    public String getAttr() {
        return attr;
    }
 
    public void setAttr(String attr) {
        this.attr = attr;
    }
 
    private Component parentComponent = null;
 
    public SelectorQTDialog(Component parentComponent) {
        super(ClientContextVariable.getFrame(), true);
        init();
        //setSize(UIHelper.DIALOG_DEFAULT_WIDTH, UIHelper.DIALOG_DEFAULT_HEIGHT);    // modify by zgy 2015-02-13 [oq不不建议引用uif工程]
        setSize(700,500);
        this.parentComponent = parentComponent;
        setLocationRelativeTo(parentComponent);
        setVisible(true);
    }
 
    public void init() {
        setLayout(new BorderLayout());
        this.setTitle("选择查询模板");
        attrLable.setText("输入查询字段:");
        northPanel.add(attrLable);
        northPanel.add(attrText);
        add(northPanel, BorderLayout.NORTH);
        add(tablePanel(), BorderLayout.CENTER);
        initAction();// 初始化按钮点击事件
    }
 
    private LinkedList<VCIJButton> selfCustomButtons = new LinkedList<VCIJButton>();
    {
        selfCustomButtons.add(btnOk);
        selfCustomButtons.add(btnCancel);
    }
 
    MyDataProvider dataProvider = new MyDataProvider();
    VCIJTablePanel<QTInfo> tablePanel = new VCIJTablePanel<QTInfo>(dataProvider);
 
    private VCIJPanel tablePanel() {
        int startIndex = dataProvider.getDataColumnStartIndex();
        LinkedHashMap<Integer, Integer> widthMaps = new LinkedHashMap<Integer, Integer>();
        widthMaps.put(startIndex++, 300);
        widthMaps.put(startIndex++, 300);
        tablePanel.setColumnWidthMaps(widthMaps);
        tablePanel.setCustomButtons(selfCustomButtons);
        tablePanel.setShowPaging(true);
        tablePanel.setCustomButtonFlowAlign(FlowLayout.CENTER);
        tablePanel.setPageButtonFlowAlign(FlowLayout.CENTER);
        tablePanel.setShowExport(false);
        tablePanel.buildTablePanel();
        tablePanel.refreshTableData();
        return tablePanel;
    }
 
    class MyDataProvider extends AbstractVCIJTableDataProvider<QTInfo> {
        QTInfo[] allQts = null;
        @Override
        public QTInfo[] getDatas(int arg0, int arg1) {
            try {
                allQts = ServiceProvider.getOMDService().getQTDService().getAllQTs();
            } catch (VCIError e) {
                e.printStackTrace();
                //UIFUtils.showErrorMessage(ClientContextVariable.getFrame(), e);    // modify by zgy 2015-02-13 [oq不不建议引用uif工程]
            }
            // TODO Auto-generated method stub
            return allQts;
        }
 
        @Override
        public VCIJTableNode<QTInfo> getNewRowNode(QTInfo QtObj) {
            // TODO Auto-generated method stub
            VCIJTableNode<QTInfo> node = new VCIJTableNode<QTInfo>(QtObj);
            node.setPropertyValue(getSpecialColumns()[0], QtObj.qtName);
            node.setPropertyValue(getSpecialColumns()[1], QtObj.btmName);
            return node;
        }
 
        @Override
        public String[] getSpecialColumns() {
            // TODO Auto-generated method stub
            return "查询模板名称, 业务类型或链接类型".split(",");
        }
 
        @Override
        public int getTotal() {
            // TODO Auto-generated method stub
            return allQts.length;
        }
 
    }
 
    private void initAction() {
        btnCancel.addActionListener(new ActionListener() {
 
            @Override
            public void actionPerformed(ActionEvent e) {
                // TODO Auto-generated method stub
                cancelButton_ActionPerformed(e);
            }
        });
        btnOk.addActionListener(new ActionListener() {
 
            @Override
            public void actionPerformed(ActionEvent e) {
                // TODO Auto-generated method stub
                addButton_ActionPerformed();
            }
        });
    }
 
    /**
     * 确认按钮事件
     * <p>
     * Description:
     * </p>
     * 
     * @author heyj
     * @time 2014-3-25
     */
    private void addButton_ActionPerformed() {
        int len = tablePanel.getSelectedRowIndexs().length;
        if (len == 0) {
            VCIOptionPane.showMessage(this, "请选择查询模板再进行操作!");
            return;
        }
        if (len > 1) {
            VCIOptionPane.showMessage(this, "一次只能选择一个查询模板进行操作");
            return;
        }
        if(attrText.getText()==null||attrText.getText().equals("")){
            VCIOptionPane.showMessage(this, "请填写输入查询字段");
            return;
        }
        QTInfo obj = tablePanel.getSelectedRowObjects().get(0);
        this.setItem(obj);
        this.setAttr(attrText.getText());
        this.dispose();
    }
    /**
     * 取消按钮事件
     * 
     * @param e
     */
    private void cancelButton_ActionPerformed(ActionEvent e) {
        this.item = null;
        this.dispose();
    }
 
}