/*
* Copyright 2009 Peter Karich.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* under the License.
*/
package de.timefinder.core.ui;
import java.awt.Dimension;
import javax.swing.JOptionPane;
import org.springframework.core.io.Resource;
import org.springframework.richclient.application.setup.SetupIntroWizardPage;
import org.springframework.richclient.application.setup.SetupLicenseWizardPage;
import org.springframework.richclient.application.setup.SetupWizard;
import org.springframework.richclient.application.setup.SetupWizardDialog;
import org.springframework.richclient.command.ActionCommandExecutor;
import org.springframework.richclient.wizard.AbstractWizard;
import org.springframework.richclient.wizard.WizardDialog;
/**
* This class only overrides the default finishCommandId. It is copied from SetupWizard!
* @see org.springframework.richclient.application.setup.SetupWizard
* @author Peter Karich
*/
public class TimeFinderWizardDialog extends SetupWizard /*we cannot use AbstractWizard -> Exception because setupWizard-bean has to be of this type!*/
implements ActionCommandExecutor {
protected WizardDialog wizardDialog;
protected SetupLicenseWizardPage licensePage = new SetupLicenseWizardPage();
public TimeFinderWizardDialog() {
}
public void setLicenseTextLocation(Resource location) {
licensePage.setLicenseTextLocation(location);
}
public void execute() {
if (wizardDialog == null) {
wizardDialog = new SetupWizardDialog(this) {
@Override
protected String getFinishCommandId() {
return "setup." + super.getFinishCommandId();
}
};
wizardDialog.setPreferredSize(new Dimension(500, 300));
}
wizardDialog.showDialog();
}
public void addPages() {
addPage(new SetupIntroWizardPage());
addPage(licensePage);
}
public boolean onFinish() {
return true;
}
public boolean onCancel() {
if (cancelConfirmed()) {
// TODO use org.springframework.richclient.application.Application.close(b, i) instead (if initialized?)
System.exit(1);
}
return false;
}
protected boolean cancelConfirmed() {
return JOptionPane.showConfirmDialog(wizardDialog.getDialog(), getCancelMessage(), getCancelTitle(),
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.NO_OPTION;
}
protected String getCancelTitle() {
return getMessage("setup.cancel.title");
}
protected String getCancelMessage() {
return getMessage("setup.cancel.message");
}
}