wanghong
2024-01-05 09b92db642b8a65f4b3ba56793238b9bc0854ea5
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
package com.vci.rmip.code.client.codeapply.Apply410;
 
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.LinkedList;
 
 
 
import com.vci.base.ui.swing.VCIOptionPane;
import com.vci.base.ui.swing.VCISwingUtil;
import com.vci.base.ui.swing.components.*;
import com.vci.base.ui.swing.components.table.VCIJTablePanel;
import com.vci.rmip.code.client.codeapply.Apply410.object.ubcscode.page.BaseModel;
 
public class CodeApplyFor410SearchDialog extends VCIJDialog {
 
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    private CodeApplyPanelFor410 ownerPanel;
    private VCIJLabel codeName = new VCIJLabel("代码:");
    private VCIJTextField  txtCodeName = new VCIJTextField(false);
    private VCIJButton btnSearch= VCISwingUtil.createVCIJButton("btnSearch", "查询", "查询", "search.png", null);
    private VCIJButton btnOk = VCISwingUtil.createVCIJButton("replace", "确定", "确定", "ok.gif",null);
    private VCIJButton btnCancel = VCISwingUtil.createVCIJButton("cancel", "取消", "取消", "cancel.gif",null);
    private String strName = "";
    private String str = "";
    public CodeApplyFor410SearchDialog(CodeApplyPanelFor410 ownerPanel){
        //super(LogonApplication.frame,true);
        this.ownerPanel = ownerPanel;
        this.setTitle("查询代码");
        Dimension dime = Toolkit.getDefaultToolkit().getScreenSize();
        int x = dime.width/2 - 300;
        int y = dime.height/2 - 300;
        this.setLocation(x, y);
        this.setSize(new Dimension(700, 600));
        init();
        setModal(true);
        setVisible(true);
    }
    private LinkedList<VCIJButton> selfCustomButtons = new LinkedList<VCIJButton>();
    {
        selfCustomButtons.add(btnOk);
        selfCustomButtons.add(btnCancel);
    }
 
    public void init(){
        setLayout(new BorderLayout());
        add(nothPanel(),BorderLayout.NORTH);
        add(createCenterTPanel(), BorderLayout.CENTER);
        cancel();
    }
    private VCIJPanel nothPanel(){
        VCIJPanel pal = new VCIJPanel();
        VCIJPanel nothPanel = new VCIJPanel();
        nothPanel.setLayout(null);
        nothPanel.setPreferredSize(new Dimension(300,40));
        codeName.setBounds(10, 5, 60, 28);
        txtCodeName.setBounds(70, 5, 200, 28);
        btnSearch.setBounds(300, 5, 80, 25);
        nothPanel.add(codeName);
        nothPanel.add(txtCodeName);
        nothPanel.add(btnSearch);
        pal.setLayout(new BorderLayout());
        pal.add(nothPanel);
        pal.setVisible(true);
        return pal;
    }
    private CodeApplyFor410SearchMainPanel codeDataMainPanel=null;
    private VCIJPanel createCenterTPanel(){
        codeDataMainPanel=new CodeApplyFor410SearchMainPanel();
        CodeApplyFor410SearchProvider  dataProvider=new CodeApplyFor410SearchProvider(this);
        codeDataMainPanel.setDataProvider(dataProvider);
        codeDataMainPanel.setCustomTopPanel(nothPanel());
        codeDataMainPanel.buildPanel();
        VCIJTable table = codeDataMainPanel.getTablePanel().getTable();
        table.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                if (e.getButton() == 1 && e.getClickCount() == 2) {
                    btnOk.doClick();
                }
            }
        });
        return codeDataMainPanel;
    }
 
 
    public VCIJTablePanel<BaseModel> getPanel() {
        return codeDataMainPanel.getTablePanel();
    }
    /**
     * 按钮事件
     */
    public void cancel(){
        btnCancel.addActionListener(new ActionListener() {
            @Override
        public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
             btn_Cancel();    //取消
            }
        });
        btnSearch.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent arg0) {
                searchButton_action();//查询
            }
        });
        btnOk.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent arg0) {
                okButton_action();//确定
            }
        });
    }
    public void okButton_action(){
        int len = codeDataMainPanel.getTablePanel().getSelectedRowObjects().size();
        if (len==0) {
            VCIOptionPane.showMessage(this, "请先选择要操作的数据");
            return;
        }else if (len>1) {
            VCIOptionPane.showMessage(this, "一次只能选择一条数据进行操作");
            return;
        }
        LinkedList<BaseModel> list = codeDataMainPanel.getTablePanel().getSelectedRowObjects();
        for (BaseModel object : list) {
            str = object.getId();
            setStr(str);
        }
        this.dispose();
    }
 
    public void searchButton_action(){
        strName = txtCodeName.getText();
        setStrName(strName);
        codeDataMainPanel.getTablePanel().refreshTableData();
    }
 
    public CodeApplyPanelFor410 getOwnerPanel() {
        return ownerPanel;
    }
 
    public void setOwnerPanel(CodeApplyPanelFor410 ownerPanel) {
        this.ownerPanel = ownerPanel;
    }
 
    public String getStr() {
        return str;
    }
    public void setStr(String str) {
        this.str = str;
    }
    public String getStrName() {
        return strName;
    }
    public void setStrName(String strName) {
        this.strName = strName;
    }
    public void btn_Cancel(){
        this.dispose();
    }
}