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
package com.vci.client.portal.UI.v3.comptdesign.compt.popupcompt;
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
 
import javax.swing.JRootPane;
import javax.swing.border.LineBorder;
 
import com.vci.client.portal.UI.v3.comptdesign.UIComptDesignDialog;
import com.vci.client.ui.swing.VCISwingUtil;
import com.vci.client.ui.swing.components.VCIJButton;
import com.vci.client.ui.swing.components.VCIJOptionPane;
import com.vci.client.ui.swing.components.VCIJPanel;
import com.vci.client.ui.swing.components.VCIJTextField;
import com.vci.corba.omd.qtm.QTInfo;
import com.vci.mw.ClientContextVariable;
 
public class QTPopupDialog extends BasePopupDialog {
 
    /**
     * 
     */
    private static final long serialVersionUID = -7290990397315653210L;
    
    private VCIJTextField btmLinKTypeTxt = null;
    private QTPopupTablePanel queryTemplateTablePanel = null;
    
    private VCIJButton btnOk = VCISwingUtil.createVCIJButton("ok", "确定", "确定", "accept.png", new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            btnOk_actionPerformed(e, true);
        }
    });
    private VCIJButton btnCancel = VCISwingUtil.createVCIJButton("cancel", "取消", "取消", "cancel.png", new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            btnCancel_actionPerformed(e);
        }
    });
    
    public QTPopupDialog(UIComptDesignDialog ownedUIComptDesignDialog,
            VCIJTextField searchInputTxt,
            VCIJTextField btmLinkTypeTxt){
        super(ownedUIComptDesignDialog, searchInputTxt);
        this.btmLinKTypeTxt = btmLinkTypeTxt;
    }
    
    @Override
    public void buildDialog(){
        init();
        super.setBuildCompleted(true);
    }
    
    private void init(){
        initUI();
    }
    
    private void initUI(){
        setUndecorated(true);
        getRootPane().setWindowDecorationStyle(JRootPane.NONE);
        setLayout(new BorderLayout());
        
        VCIJPanel pal = new VCIJPanel(new BorderLayout());
        pal.setBorder(new LineBorder(Color.black));
        
        queryTemplateTablePanel = new QTPopupTablePanel(this);
        queryTemplateTablePanel.buildTablePanel();
        queryTemplateTablePanel.getTablePanel().getTable().addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                int row = queryTemplateTablePanel.getTablePanel().getTable().rowAtPoint(e.getPoint());
                int column = queryTemplateTablePanel.getTablePanel().getTable().columnAtPoint(e.getPoint());
                if(row < 0 || column <= 0){
                    return;
                }
                setBtmTypeNameTableRowIndex(row);
            }
        });
        pal.add(queryTemplateTablePanel, BorderLayout.CENTER);
        pal.add(getSouthButtonPanel(), BorderLayout.SOUTH);
        add(pal, BorderLayout.CENTER);
    }
    
    private VCIJPanel getSouthButtonPanel(){
        VCIJPanel pal = new VCIJPanel();
        pal.add(btnOk);
        pal.add(btnCancel);
        return pal;
    }
    private void btnOk_actionPerformed(ActionEvent e, boolean fromBtnOk){
        if(fromBtnOk){
            QTInfo[] sels = queryTemplateTablePanel.getTablePanel().getSelectedRowObjectsList().toArray(new QTInfo[]{});
            if(sels.length == 0 && !isSelected()){
                VCIJOptionPane.showMessage(ClientContextVariable.getFrame(), "请选择数据");
                return;
            }
            if(sels.length >= 2){
                VCIJOptionPane.showMessage(ClientContextVariable.getFrame(), "只能选择一条数据");
                return;
            }
            setSelectedQTName(sels[0]);
            close(DialogResult.OK);
        } else {
            int row = queryTemplateTablePanel.getTablePanel().getTable().getSelectedRow();
            setBtmTypeNameTableRowIndex(row);
        }
    }
    private void setBtmTypeNameTableRowIndex(int rowIndex){
        if(rowIndex >= 0 && rowIndex < queryTemplateTablePanel.getTablePanel().getTableModel().getList().size()){
            QTInfo vi = queryTemplateTablePanel.getTablePanel().getSpecialObjectByRowIndex(rowIndex);
            setSelectedQTName(vi);
            close(DialogResult.OK);
        }
    }
    private void setSelectedQTName(QTInfo qt){
        selectedQTName = qt.qtName;
    }
    private String selectedQTName = "";
    public String getSelectedQTName(){
        return selectedQTName;
    }
    private boolean isSelected(){
        return queryTemplateTablePanel.getTablePanel().getTable().getSelectedRow() >= 0;
    }
    private void btnCancel_actionPerformed(ActionEvent e){
        close(DialogResult.CANCEL);
    }
    private void close(DialogResult dialogRes){
        setDialogResult(dialogRes);
        if(getDialogCallback() != null){
            getDialogCallback().run();
        }
        setVisible(false);
    }
 
    public QTPopupTablePanel getPortalVITablePanel() {
        return queryTemplateTablePanel;
    }
 
    public void setPortalVITablePanel(QTPopupTablePanel portalVITablePanel) {
        this.queryTemplateTablePanel = portalVITablePanel;
    }
 
    @Override
    public void loadData(){
        queryTemplateTablePanel.getTablePanel().refreshTableData();
    }
 
    public VCIJTextField getBtmLinKTypeTxt() {
        return btmLinKTypeTxt;
    }
    
}