package jetbrains.mps.ide.dialogs.project.creation;

/*Generated by MPS */

import jetbrains.mps.annotations.GeneratedClass;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.mps.openapi.persistence.ModelRoot;
import org.jetbrains.mps.openapi.persistence.ModelFactoryType;
import javax.swing.JComponent;
import jetbrains.mps.project.IProject;
import org.jetbrains.mps.openapi.module.SModule;

/**
 * Abstraction of center settings panel in the 'new model' dialogue. Provides attributes used by model creation in 
 * 'new model' dialogue:
 * - fully qualified name of new model
 * - new model stereotype
 * - model root where new model should be placed
 * - model factory that should be used to create new model
 * 
 * Each attribute can be either predefined of configured by user via {@link jetbrains.mps.ide.dialogs.project.creation.NewModelDialogDefaultSettings#getSettingsPanel() }.
 * 
 * For adoption of 'new model' dialogue in RCPs, custom implementations can be provided to 
 * {@link jetbrains.mps.ide.dialogs.project.creation.NewModelDialog }.
 */
@GeneratedClass(node = "r:478bf62d-84fb-4fba-aeda-183fb2769e64(jetbrains.mps.ide.dialogs.project.creation)/7081154005682091284", model = "r:478bf62d-84fb-4fba-aeda-183fb2769e64(jetbrains.mps.ide.dialogs.project.creation)")
public interface NewModelDialogSettings {

  /**
   * Fully qualified name of a model to be created.
   */
  @Nullable
  String getModelName();


  /**
   * Stereotype of a model to be created.
   */
  @NotNull
  String getStereotype();


  /**
   * Model root where new model will be placed.
   */
  @Nullable
  ModelRoot getModelRoot();


  /**
   * Type of model factory that will be used to create model.
   */
  @Nullable
  ModelFactoryType getModelFactoryType();


  /**
   * Settings panel that is shown in center of 'new model' dialogue.
   */
  @NotNull
  JComponent getSettingsPanel();


  /**
   * Component that will focused when the dialogue will be shown.
   */
  @NotNull
  default JComponent getPreferredFocusedComponent() {
    return getSettingsPanel();
  }

  /**
   * Creates settings for 'new model' action for given project and module. Provided {@code validator} has to be called
   * on each user interaction with settings to ensure that modified settings are valid.
   */
  interface Factory {
    @NotNull
    NewModelDialogSettings create(@NotNull IProject project, @NotNull SModule module, @NotNull SettingsValidator validator);
  }

  interface SettingsValidator {

    /**
     * Ensure that chosen settings are correct.
     */
    void validate();
  }
}
