001 package org.springframework.richclient.application.setup; 002 003 import java.awt.Dimension; 004 005 import javax.swing.JOptionPane; 006 007 import org.springframework.core.io.Resource; 008 import org.springframework.richclient.command.ActionCommandExecutor; 009 import org.springframework.richclient.wizard.AbstractWizard; 010 import org.springframework.richclient.wizard.WizardDialog; 011 012 /** 013 * @author Claudio Romano 014 * @author Keith Donald 015 */ 016 public class SetupWizard extends AbstractWizard implements ActionCommandExecutor { 017 private WizardDialog wizardDialog; 018 019 private SetupLicenseWizardPage licensePage = new SetupLicenseWizardPage(); 020 021 public SetupWizard() { 022 super("setup"); 023 } 024 025 public void setLicenseTextLocation(Resource location) { 026 licensePage.setLicenseTextLocation(location); 027 } 028 029 public void execute() { 030 if (wizardDialog == null) { 031 wizardDialog = new SetupWizardDialog(this); 032 wizardDialog.setPreferredSize(new Dimension(500, 300)); 033 } 034 wizardDialog.showDialog(); 035 } 036 037 public void addPages() { 038 addPage(new SetupIntroWizardPage()); 039 addPage(licensePage); 040 } 041 042 public boolean onFinish() { 043 return true; 044 } 045 046 public boolean onCancel() { 047 if (cancelConfirmed()) { 048 // TODO use org.springframework.richclient.application.Application.close(b, i) instead (if initialized?) 049 System.exit(1); 050 } 051 return false; 052 } 053 054 protected boolean cancelConfirmed() { 055 return JOptionPane.showConfirmDialog(wizardDialog.getDialog(), getCancelMessage(), getCancelTitle(), 056 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.NO_OPTION; 057 } 058 059 protected String getCancelTitle() { 060 return getMessage("setup.cancel.title"); 061 } 062 063 protected String getCancelMessage() { 064 return getMessage("setup.cancel.message"); 065 } 066 067 }