Package com.cedarsoft.spring.rcp.commands

Source Code of com.cedarsoft.spring.rcp.commands.AbstractWizardCommand

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 <W> the type of the wizard
*/
public abstract class AbstractWizardCommand<W extends Wizard> 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;
}
TOP

Related Classes of com.cedarsoft.spring.rcp.commands.AbstractWizardCommand

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.