com.cedarsoft.spring.rcp.commands.AbstractWizardCommand Maven / Gradle / Ivy
package com.cedarsoft.spring.rcp.commands;
import com.cedarsoft.CanceledException;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.springframework.richclient.application.config.ApplicationWindowAware;
import org.springframework.richclient.wizard.Wizard;
import org.springframework.richclient.wizard.WizardDialog;
/**
* A wizard command executes a wizard
*
* @param the type of the wizard
*/
public abstract class AbstractWizardCommand extends ExtendedCommand {
/**
* Creates a new wizard command
*
* @param commandId the command id
*/
protected AbstractWizardCommand( @NotNull @NonNls String commandId ) {
super( commandId );
}
@Override
protected void executeCommand() throws Exception {
W wizard = createWizard();
WizardDialog wizardDialog = new WizardDialog( wizard );
wizardDialog.setTitle( getMessage( wizard.getId() + ".title" ) );
//noinspection InstanceofIncompatibleInterface
if ( wizard instanceof ApplicationWindowAware ) {
//noinspection CastToIncompatibleInterface
( ( ApplicationWindowAware ) wizard ).setApplicationWindow( getApplicationWindow() );
}
wizardDialog.showDialog();
}
/**
* Creates the wizard that will be shown
*
* @return the wizard
*
* @throws CanceledException
*/
@NotNull
protected abstract W createWizard() throws CanceledException;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy