Search in sources :

Example 1 with CreateStepDefinitionFileDialog

use of org.jetbrains.plugins.cucumber.inspections.ui.CreateStepDefinitionFileDialog in project intellij-plugins by JetBrains.

the class CucumberCreateStepFixBase method askUserForFilePath.

@Nullable
private static CreateStepDefinitionFileModel askUserForFilePath(@NotNull final GherkinStep step) {
    final InputValidator validator = new InputValidator() {

        public boolean checkInput(final String filePath) {
            return !StringUtil.isEmpty(filePath);
        }

        public boolean canClose(final String fileName) {
            return true;
        }
    };
    Map<BDDFrameworkType, String> supportedFileTypesAndDefaultFileNames = new HashMap<>();
    Map<BDDFrameworkType, PsiDirectory> fileTypeToDefaultDirectoryMap = new HashMap<>();
    for (CucumberJvmExtensionPoint e : Extensions.getExtensions(CucumberJvmExtensionPoint.EP_NAME)) {
        if (e instanceof OptionalStepDefinitionExtensionPoint) {
            // Skip if framework file creation support is optional
            if (!((OptionalStepDefinitionExtensionPoint) e).participateInStepDefinitionCreation(step)) {
                continue;
            }
        }
        supportedFileTypesAndDefaultFileNames.put(e.getStepFileType(), e.getStepDefinitionCreator().getDefaultStepFileName(step));
        fileTypeToDefaultDirectoryMap.put(e.getStepFileType(), e.getStepDefinitionCreator().getDefaultStepDefinitionFolder(step));
    }
    CreateStepDefinitionFileModel model = new CreateStepDefinitionFileModel(step.getProject(), supportedFileTypesAndDefaultFileNames, fileTypeToDefaultDirectoryMap);
    CreateStepDefinitionFileDialog createStepDefinitionFileDialog = new CreateStepDefinitionFileDialog(step.getProject(), model, validator);
    if (createStepDefinitionFileDialog.showAndGet()) {
        return model;
    } else {
        return null;
    }
}
Also used : InputValidator(com.intellij.openapi.ui.InputValidator) HashMap(com.intellij.util.containers.HashMap) PsiDirectory(com.intellij.psi.PsiDirectory) CreateStepDefinitionFileModel(org.jetbrains.plugins.cucumber.inspections.model.CreateStepDefinitionFileModel) CreateStepDefinitionFileDialog(org.jetbrains.plugins.cucumber.inspections.ui.CreateStepDefinitionFileDialog) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

InputValidator (com.intellij.openapi.ui.InputValidator)1 PsiDirectory (com.intellij.psi.PsiDirectory)1 HashMap (com.intellij.util.containers.HashMap)1 Nullable (org.jetbrains.annotations.Nullable)1 CreateStepDefinitionFileModel (org.jetbrains.plugins.cucumber.inspections.model.CreateStepDefinitionFileModel)1 CreateStepDefinitionFileDialog (org.jetbrains.plugins.cucumber.inspections.ui.CreateStepDefinitionFileDialog)1