List of usage examples for com.intellij.openapi.ui Messages showInputDialog
@Nullable public static String showInputDialog(Project project, @Nls String message, @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon, @Nullable String initialValue, @Nullable InputValidator validator, @Nullable TextRange selection)
From source file:io.ballerina.plugins.idea.actions.BallerinaCreateModuleAction.java
License:Open Source License
@Override public void actionPerformed(@NotNull AnActionEvent event) { final IdeView view = event.getData(LangDataKeys.IDE_VIEW); final Project project = event.getData(CommonDataKeys.PROJECT); if (view == null || project == null) { return;//from w w w . ja v a 2s .c om } PsiDirectory dir = DirectoryChooserUtil.getOrChooseDirectory(view); if (dir == null) { return; } // This action is visible only for ballerina project root directory and src directory. if ((dir.findFile(BALLERINA_CONFIG_FILE_NAME) == null || dir.findSubdirectory(BALLERINA_SRC_DIR_NAME) == null) && !dir.getName().equals(BALLERINA_SRC_DIR_NAME)) { return; } // If user tries to create new module in the project root level. if (dir.findFile(BALLERINA_CONFIG_FILE_NAME) != null && dir.findSubdirectory(BALLERINA_SRC_DIR_NAME) != null) { dir = dir.findSubdirectory(BALLERINA_SRC_DIR_NAME); } final CreateDirectoryOrPackageHandler validator; final String message, title; validator = new CreateDirectoryOrPackageHandler(project, dir, true, "\\/"); message = IdeBundle.message("prompt.enter.new.directory.name"); title = IdeBundle.message("title.new.directory"); String initialText = ""; Messages.showInputDialog(project, message, title, null, initialText, validator, TextRange.from(initialText.length(), 0)); final PsiElement result = validator.getCreatedElement(); if (result != null) { view.selectElement(result); } }