001 package org.springframework.richclient.application.setup;
002
003 import java.awt.BorderLayout;
004 import java.awt.Container;
005
006 import javax.swing.JComponent;
007
008 import org.springframework.richclient.command.AbstractCommand;
009 import org.springframework.richclient.command.ActionCommand;
010 import org.springframework.richclient.command.CommandGroup;
011 import org.springframework.richclient.components.GradientPanel;
012 import org.springframework.richclient.util.GuiStandardUtils;
013 import org.springframework.richclient.wizard.Wizard;
014 import org.springframework.richclient.wizard.WizardDialog;
015 import org.springframework.richclient.wizard.WizardPage;
016
017 /**
018 * @author cro
019 */
020 public class SetupWizardDialog extends WizardDialog {
021
022 private Container pageControlBackup;
023
024 private GradientPanel firstPageControl;
025
026 private ActionCommand nextCommand;
027
028 public SetupWizardDialog(Wizard wizard) {
029 super(wizard);
030 this.setTitle(getApplicationName());
031 this.setResizable(false);
032 }
033
034 protected JComponent createDialogContentPane() {
035 createFirstPageControl();
036 return super.createDialogContentPane();
037 }
038
039 protected JComponent createFirstPageControl() {
040 firstPageControl = new GradientPanel();
041 firstPageControl.setLayout(new BorderLayout());
042 firstPageControl.add(createFirstPageButtonBar(), BorderLayout.SOUTH);
043 return firstPageControl;
044 }
045
046 protected JComponent createFirstPageButtonBar() {
047 CommandGroup dialogCommandGroup = CommandGroup.createCommandGroup(null, getIntroPageCommandGroupMembers());
048 JComponent buttonBar = dialogCommandGroup.createButtonBar();
049 GuiStandardUtils.attachDialogBorder(buttonBar);
050 buttonBar.setOpaque(false);
051 return buttonBar;
052 }
053
054 protected Object[] getIntroPageCommandGroupMembers() {
055 nextCommand = new ActionCommand("nextCommand") {
056 public void doExecuteCommand() {
057 onNext();
058 }
059 };
060
061 return new AbstractCommand[] { nextCommand, getCancelCommand() };
062 }
063
064 public void showPage(WizardPage page) {
065 if (page.getPreviousPage() == null) {
066 // is intro page? --> better way to find it out?
067 super.showPage(page);
068 pageControlBackup = getDialogContentPane();
069 firstPageControl.add(page.getControl(), BorderLayout.CENTER);
070 this.getDialog().setContentPane(firstPageControl);
071 }
072 else {
073 if (pageControlBackup != null) {
074 getDialog().setContentPane(pageControlBackup);
075 //stop adding the content pane in future
076 pageControlBackup = null;
077 }
078 super.showPage(page);
079 }
080 }
081
082 }