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 dialogCommonShareData = null; /** * 第一步Panel */ private VCIGuideStepPanel firstStep = null; /** * 当前窗口UI */ private VCIGuideStepPanel curStepUI = null; /** * 最后一步的Panel */ private VCIGuideStepPanel lastStep = null; /** * 所有的步骤窗口(仅起到缓存作用)--可取消 *//* private List allStepUI = new ArrayList();*/ 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 getDialogCommonShareData() { if (dialogCommonShareData == null) { dialogCommonShareData = new HashMap(); } 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; } }