田源
2024-03-07 4b4083fd73dc27ece42f4835483565eef0e4f608
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
package com.vci.client.portal.UI.dialog;
 
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.Map;
 
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
 
import com.vci.client.LogonApplication;
import com.vci.client.ui.swing.components.VCIJDialog;
import com.vci.mw.ClientContextVariable;
 
/**
 * VCI平台公共向导窗口
 * @Title        :VCICommonGuideDialog.java
 * @Description    : 
 * @Copyright    :宏博远达科技有限公司
 * @Author        :平台与规划部/ZhongGY/E-mail:zhonggy@vci-tech.com
 * @Date        :2015-6-4
 * @Version        :1
 * @Other        :产生注释:Alt+Shift+J
 */
public class VCICommonGuideDialog extends VCIJDialog {
 
    private static final long serialVersionUID = 1L;
    
    /**
     * (各步骤)向导公共共享数据
     */
    private Map<String, Object> dialogCommonShareData = null;
    
    /**
     * 第一步Panel
     */
    private VCIGuideStepPanel firstStep = null;
    /**
     * 当前窗口UI
     */
    private VCIGuideStepPanel curStepUI = null;
    /**
     * 最后一步的Panel
     */
    private VCIGuideStepPanel lastStep = null;
    /**
     * 所有的步骤窗口(仅起到缓存作用)--可取消
     *//*
    private List<VCIGuideStepPanel> allStepUI = new ArrayList<VCIGuideStepPanel>();*/
    
    private JPanel centerPanel = null;
    private JLabel lblStepName = null;
    private JButton preBtn = null;
    private JButton nextBtn = null;
    private JButton cancelBtn = null;
    private JLabel lblProcess;
    
    public VCICommonGuideDialog(String title,int width, int height) {
        super(LogonApplication.frame,true);
        if (width < 200) {
            width = 800;    //默认
        }
        if (height < 150) {
            height = 600;    //默认
        }
        this.setSize(800, 600);
        this.setLocationRelativeTo(null);
        if (title == null || title.trim().equals("")) {
            title = "VCI向导窗口";
        }
        setTitle(title);
        JPanel topPanel = new JPanel();
        getContentPane().add(topPanel, BorderLayout.NORTH);
        GridBagLayout gbl_topPanel = new GridBagLayout();
        gbl_topPanel.columnWidths = new int[]{0, 200, 60, 0, 0};
        gbl_topPanel.rowHeights = new int[]{40, 0};
        gbl_topPanel.columnWeights = new double[]{0.0, 1.0, 0.0, 0.0, Double.MIN_VALUE};
        gbl_topPanel.rowWeights = new double[]{0.0, Double.MIN_VALUE};
        topPanel.setLayout(gbl_topPanel);
        
        JLabel label = new JLabel(" ");
        GridBagConstraints gbc_label = new GridBagConstraints();
        gbc_label.insets = new Insets(0, 0, 0, 5);
        gbc_label.gridx = 0;
        gbc_label.gridy = 0;
        topPanel.add(label, gbc_label);
        
        lblStepName = new JLabel("第一步:向导步骤内容");
        GridBagConstraints gbc_lblStepName = new GridBagConstraints();
        gbc_lblStepName.insets = new Insets(0, 0, 0, 5);
        gbc_lblStepName.fill = GridBagConstraints.BOTH;
        gbc_lblStepName.gridx = 1;
        gbc_lblStepName.gridy = 0;
        topPanel.add(lblStepName, gbc_lblStepName);
        
        lblProcess = new JLabel("[第X步/共X步]");
        GridBagConstraints gbc_lblProcess = new GridBagConstraints();
        gbc_lblProcess.insets = new Insets(0, 0, 0, 5);
        gbc_lblProcess.gridx = 2;
        gbc_lblProcess.gridy = 0;
        topPanel.add(lblProcess, gbc_lblProcess);
        
        JLabel label_1 = new JLabel(" ");
        GridBagConstraints gbc_label_1 = new GridBagConstraints();
        gbc_label_1.gridx = 3;
        gbc_label_1.gridy = 0;
        topPanel.add(label_1, gbc_label_1);
        
        JPanel buttonPanel = new JPanel();
        getContentPane().add(buttonPanel, BorderLayout.SOUTH);
        GridBagLayout gbl_buttonPanel = new GridBagLayout();
        gbl_buttonPanel.columnWidths = new int[]{0, 0, 0, 0, 0, 0, 0};
        gbl_buttonPanel.rowHeights = new int[]{40, 0};
        gbl_buttonPanel.columnWeights = new double[]{0.0, 1.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
        gbl_buttonPanel.rowWeights = new double[]{0.0, Double.MIN_VALUE};
        buttonPanel.setLayout(gbl_buttonPanel);
        
        JLabel label_3 = new JLabel(" ");
        GridBagConstraints gbc_label_3 = new GridBagConstraints();
        gbc_label_3.insets = new Insets(0, 0, 0, 5);
        gbc_label_3.gridx = 0;
        gbc_label_3.gridy = 0;
        buttonPanel.add(label_3, gbc_label_3);
        
        preBtn = new JButton("上一步");
        preBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if(curStepUI.doPreBtnAction() && curStepUI.getPreStepUI() != null){
                    setCurStepUI(curStepUI.getPreStepUI());
                }
            }
        });
        GridBagConstraints gbc_preBtn = new GridBagConstraints();
        gbc_preBtn.insets = new Insets(0, 0, 0, 5);
        gbc_preBtn.gridx = 2;
        gbc_preBtn.gridy = 0;
        buttonPanel.add(preBtn, gbc_preBtn);
        
        nextBtn = new JButton("下一步");
        nextBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (lastStep != null) {
                    lastStep.setNextStepUI(null);
                    //lastStep.setNextBtnVisible(false);
                }
                if(curStepUI.doNextBtnAction() && curStepUI.getNextStepUI() != null){
                    setCurStepUI(curStepUI.getNextStepUI());
                }
            }
        });
        GridBagConstraints gbc_nextBtn = new GridBagConstraints();
        gbc_nextBtn.insets = new Insets(0, 0, 0, 5);
        gbc_nextBtn.gridx = 3;
        gbc_nextBtn.gridy = 0;
        buttonPanel.add(nextBtn, gbc_nextBtn);
        
        cancelBtn = new JButton("取消");
        cancelBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (cancelBtn.getText().trim().equals("完成")) {
                    VCICommonGuideDialog.this.setVisible(false);
                    return;
                }
                int confirm = JOptionPane.showConfirmDialog(ClientContextVariable.getFrame(), 
                        "是否确认关闭该向导窗口?","Action导出", JOptionPane.OK_CANCEL_OPTION);
                if(confirm == JOptionPane.OK_OPTION) {
                    VCICommonGuideDialog.this.setVisible(false);
                    //VCICommonGuideDialog.this.dispose();
                }
            }
        });
        GridBagConstraints gbc_cancelBtn = new GridBagConstraints();
        gbc_cancelBtn.insets = new Insets(0, 0, 0, 5);
        gbc_cancelBtn.gridx = 4;
        gbc_cancelBtn.gridy = 0;
        buttonPanel.add(cancelBtn, gbc_cancelBtn);
        
        JLabel label_2 = new JLabel(" ");
        GridBagConstraints gbc_label_2 = new GridBagConstraints();
        gbc_label_2.gridx = 5;
        gbc_label_2.gridy = 0;
        buttonPanel.add(label_2, gbc_label_2);
        centerPanel = new JPanel();
        getContentPane().add(centerPanel, BorderLayout.CENTER);
        centerPanel.setLayout(new BorderLayout(0, 0));
    }
    protected void exportAction() {
        
        
    }
 
    /**
     * 正式加载窗口
     */
    @Override
    public void setVisible(boolean b) {
        if (b && firstStep != null) {
            this.setCurStepUI(firstStep);
            firstStep.initUI();
        }
        super.setVisible(b);
    }
    /**
     * (各步骤)获取向导公共共享数据[请慎用,通常直接使用向导每步骤自身的"getGuidCommonShareData()"即可]
     * @Title        :getCommonData
     * @Description    :
     * @return
     */
    @Deprecated
    public Map<String, Object> getDialogCommonShareData() {
        if (dialogCommonShareData == null) {
            dialogCommonShareData = new HashMap<String, Object>();
        }
        return dialogCommonShareData;
    }
 
    /**
     * (各步骤)可设置向导公共共享数据
     * @Title        :setCommonData
     * @Description    :
     * @param commonData
     *//*
    public void setDialogCommonShareData(Object dialogCommonShareData) {
        this.dialogCommonShareData = dialogCommonShareData;
    }*/
    
    private VCIGuideStepPanel preStepTemp = null;
    /**
     * 向导窗口中增加某步骤界面:可只增加第一步界面(在第一步界面中自己负责增加后续页面);但也支持动态增加多页(即每页是可动态组装复用) ,
     * @Title        :addStepUI
     * @Description    :
     * @param stepUI
     */
    public void addStepUI(VCIGuideStepPanel stepUI){
        if (stepUI == null) {
            return;
        }
        stepUI.setOwnParent(this);
        if (firstStep == null) {
            firstStep = stepUI;
            firstStep.setPreStepUI(null);
        }
        if (preStepTemp != null) {
            preStepTemp.setNextStepUI(stepUI);
            stepUI.setPreStepUI(preStepTemp);
        }
        preStepTemp = stepUI;
        //allStepUI.add(stepUI);
    }
 
    public VCIGuideStepPanel getCurStepUI() {
        return curStepUI;
    }
 
    public void setCurStepUI(VCIGuideStepPanel curStepUI) {
        this.curStepUI = curStepUI;
        this.lblStepName.setText(curStepUI.getStepName());
        this.preBtn.setVisible(curStepUI.isPreBtnVisible());
        this.preBtn.setText(curStepUI.getPreBtnText());
        this.nextBtn.setText(curStepUI.getNextBtnText());
        this.nextBtn.setVisible(curStepUI.isNextBtnVisible());
        this.cancelBtn.setVisible(curStepUI.isCancelBtnVisible());
        this.cancelBtn.setText(curStepUI.getcancelBtnText());
        this.centerPanel.removeAll();
        this.centerPanel.add(curStepUI,BorderLayout.CENTER);
        this.update(getGraphics());
        String dialogProcess = curStepUI.getDialogProcess();
        if(dialogProcess != null && !dialogProcess.trim().equals("")){
            this.lblProcess.setText(dialogProcess);
        }
    }
 
    public VCIGuideStepPanel getLastStep() {
        return lastStep;
    }
 
    public void setLastStep(VCIGuideStepPanel lastStep) {
        this.lastStep = lastStep;
    }
}