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
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.ltm.LinkType;
import com.vci.mw.ClientContextVariable;
 
public class LinkTypePopupDialog extends BasePopupDialog {
 
    /**
     * 
     */
    private static final long serialVersionUID = -8179948797311106093L;
 
 
    private VCIJTextField btmLinKTypeTxt = null;
    private LinkTypePopupTablePanel linkTypeTablePanel = 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 LinkTypePopupDialog(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));
 
        linkTypeTablePanel = new LinkTypePopupTablePanel(this);
        linkTypeTablePanel.buildTablePanel();
        linkTypeTablePanel.getTablePanel().getTable()
                .addMouseListener(new MouseAdapter() {
                    public void mouseClicked(MouseEvent e) {
                        int row = linkTypeTablePanel.getTablePanel().getTable()
                                .rowAtPoint(e.getPoint());
                        int column = linkTypeTablePanel.getTablePanel()
                                .getTable().columnAtPoint(e.getPoint());
                        if (row < 0 || column <= 0) {
                            return;
                        }
                        setBtmTypeNameTableRowIndex(row);
                    }
                });
        pal.add(linkTypeTablePanel, 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) {
            LinkType[] sels = linkTypeTablePanel.getTablePanel()
                    .getSelectedRowObjectsList().toArray(new LinkType[] {});
            if (sels.length == 0 && !isSelected()) {
                VCIJOptionPane.showMessage(ClientContextVariable.getFrame(), "请先选择数据");
                return;
            }
            if (sels.length >= 2) {
                VCIJOptionPane
                        .showMessage(
                                ClientContextVariable.getFrame(), "只能选择一条数据");
                return;
            }
            setSelectedLinkTypeName(sels[0]);
            close(DialogResult.OK);
        } else {
            int row = linkTypeTablePanel.getTablePanel().getTable()
                    .getSelectedRow();
            setBtmTypeNameTableRowIndex(row);
        }
    }
 
    private void setBtmTypeNameTableRowIndex(int rowIndex) {
        if (rowIndex >= 0
                && rowIndex < linkTypeTablePanel.getTablePanel()
                        .getTableModel().getList().size()) {
            LinkType vi = linkTypeTablePanel.getTablePanel()
                    .getSpecialObjectByRowIndex(rowIndex);
            setSelectedLinkTypeName(vi);
            close(DialogResult.OK);
        }
    }
 
    private void setSelectedLinkTypeName(LinkType lt) {
        selectedPortalVIName = lt.name;
    }
 
    private String selectedPortalVIName = "";
    public String getSelectedPortalVIName() {
        return selectedPortalVIName;
    }
 
    private boolean isSelected() {
        return linkTypeTablePanel.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 LinkTypePopupTablePanel getLinkTypeTablePanel() {
        return linkTypeTablePanel;
    }
 
    @Override
    public void loadData() {
        linkTypeTablePanel.getTablePanel().refreshTableData();
    }
 
    public VCIJTextField getBtmLinKTypeTxt() {
        return btmLinKTypeTxt;
    }
 
}