@Override public void run(AnActionButton button) { String packageName = Messages.showInputDialog("Enter the import path to exclude from auto-import and completion:", "Exclude Import Path", Messages.getWarningIcon()); addExcludedPackage(packageName); }
String name = Messages.showInputDialog(this, IgnoreBundle.message("settings.userTemplates.dialogDescription"), IgnoreBundle.message("settings.userTemplates.dialogTitle"),
Project project = editor.getProject(); if (suggestAlias) { alias = Messages.showInputDialog(project, "Package '" + ((PsiDirectory) element).getName() + "' already imported. Please enter an alias:", "Enter Alias", Messages.getInformationIcon());
@Nullable public static PsiElement invokeCreateCompilerPass(@NotNull PhpClass bundleClass, @Nullable Editor editor) { String className = Messages.showInputDialog("Class name for CompilerPass (no namespace needed): ", "New File", Symfony2Icons.SYMFONY); if(StringUtils.isBlank(className)) { return null; } if(!PhpNameUtil.isValidClassName(className)) { Messages.showMessageDialog(bundleClass.getProject(), "Invalid class name", "Error", Symfony2Icons.SYMFONY); } try { return PhpBundleFileFactory.createCompilerPass(bundleClass, className); } catch (Exception e) { if(editor != null) { HintManager.getInstance().showErrorHint(editor, "Error:" + e.getMessage()); } else { JOptionPane.showMessageDialog(null, "Error:" + e.getMessage()); } } return null; }
@Override public void actionPerformed(@NotNull AnActionEvent event) { final Project project = getEventProject(event); if(project == null) { this.setStatus(event, false); return; } PsiDirectory bundleDirContext = BundleClassGeneratorUtil.getBundleDirContext(event); if(bundleDirContext == null) { return; } final PhpClass phpClass = BundleClassGeneratorUtil.getBundleClassInDirectory(bundleDirContext); if(phpClass == null) { return; } String className = Messages.showInputDialog(project, "New class name:", "New File", Symfony2Icons.SYMFONY); if(StringUtils.isBlank(className)) { return; } if(!PhpNameUtil.isValidClassName(className)) { JOptionPane.showMessageDialog(null, "Invalid class name"); return; } write(project, phpClass, className); }
public static void buildFile(AnActionEvent event, final Project project, String templatePath) { String extension = (templatePath.endsWith(".yml") || templatePath.endsWith(".yaml")) ? "yml" : "xml" ; String fileName = Messages.showInputDialog(project, "File name (without extension)", String.format("Create %s Service", extension), Symfony2Icons.SYMFONY); if(fileName == null || StringUtils.isBlank(fileName)) { return;
@NotNull private AnActionButtonRunnable getAddActionButtonRunnable(Set<String> patterns) { return actionButton -> { String pattern = Messages.showInputDialog( textAddMessage, textAddTitle, null, null, getRegexInputValidator()); if (pattern != null) { if (patterns.add(pattern)) { patternModels.addElementSorted(pattern); } } }; }
@Nullable private String askForColorName(@Nullable NamedTextAttr attr) { final String name = attr != null ? attr.getName() : "default name"; return Messages.showInputDialog("Color Name:", "Edit Color Name", null, name, null); }
@Override public boolean submit(IdeaLoggingEvent[] events, String additionalInfo, Component parentComponent, Consumer<SubmittedReportInfo> consumer) { if (Strings.isNullOrEmpty(additionalInfo) || !additionalInfo.contains("@")) { String emailAddress = Messages.showInputDialog( "It seems you have not included your email address.\n" + "If you enter it below, you will get most probably a message " + "with a solution for your issue or a question which " + "will help to solve it.", "Information Required", null); if (!Strings.isNullOrEmpty(emailAddress)) { additionalInfo = additionalInfo == null ? emailAddress : additionalInfo + '\n' + emailAddress; } } ErrorBean errorBean = createErrorBean(events[0], additionalInfo); String json = new Gson().toJson(errorBean); postError(json); return true; }
protected List<String> askFieldsNames( Project project, String promptText, String promptTitle ) { Set<String> result = new THashSet<>(); String name = Messages.showInputDialog(project, promptText, promptTitle, Messages.getQuestionIcon(), "", null); if (!StringUtil.isEmpty(name)) { for (String nameChunk : name.split("[ ,]+")) { if (!nameChunk.isEmpty() && PerlParserUtil.IDENTIFIER_PATTERN.matcher(nameChunk).matches()) { result.add(nameChunk); } } } return new ArrayList<>(result); }
/** * 输入元素名称 * * @param initValue 初始值 * @return 获得的名称,为null表示取消输入 */ private String inputItemName(String initValue) { return Messages.showInputDialog(MsgValue.GROUP_NAME_LABEL, MsgValue.TITLE_INFO, Messages.getQuestionIcon(), initValue, new InputValidator() { @Override public boolean checkInput(String inputString) { // 非空校验 if (StringUtils.isEmpty(inputString)) { return false; } // 不能出现同名 for (String name : groupNameList) { if (Objects.equals(name, inputString)) { return false; } } return true; } @Override public boolean canClose(String inputString) { return this.checkInput(inputString); } }); }
/** * 输入元素名称 * * @param initValue 初始值 * @return 获得的名称,为null表示取消输入 */ private String inputItemName(String initValue) { return Messages.showInputDialog(MsgValue.ITEM_NAME_LABEL, MsgValue.TITLE_INFO, Messages.getQuestionIcon(), initValue, new InputValidator() { @Override public boolean checkInput(String inputString) { // 非空校验 if (StringUtils.isEmpty(inputString)) { return false; } // 不能出现同名 for (T item : itemList) { if (Objects.equals(item.getName(), inputString)) { return false; } } return true; } @Override public boolean canClose(String inputString) { return this.checkInput(inputString); } }); }
private AnActionButtonRunnable getEditActionButtonRunnable(Set<String> patterns) { return actionButton -> { String oldValue = patternList.getSelectedValue(); String pattern = Messages.showInputDialog( textEditMessage, textEditTitle, null, oldValue, getRegexInputValidator()); if (pattern != null && !pattern.equals(oldValue)) { patterns.remove(oldValue); patternModels.removeElement(oldValue); if (patterns.add(pattern)) { patternModels.addElementSorted(pattern); } } }; }
private void createUIComponents() { Supplier<String> onAdd = () -> { String s = Messages.showInputDialog(panel, "Enter new exclusion pattern", "Add File Exclusion", null, null, validator); return StringUtils.stripToNull(s); }; Function<String, String> onEdit = value -> { String s = Messages.showInputDialog(panel, "Modify exclusion pattern", "Edit File Exclusion", null, value, validator); return StringUtils.stripToNull(s); }; list = new EditableList<>(EMPTY_LABEL, onAdd, onEdit); patternList = list.getComponent(); }
@NotNull protected final PsiElement[] invokeDialog(final Project project, final PsiDirectory directory) { final MyInputValidator validator = new MyInputValidator(project, directory); Messages.showInputDialog(project, getDialogPrompt(), getDialogTitle(), Messages.getQuestionIcon(), "", validator); return validator.getCreatedElements(); }
Ref<String> pathRef = Ref.create(); ApplicationManager.getApplication().invokeAndWait( () -> pathRef.set(Messages.showInputDialog( (Project)null, null, dialogTitle, null, defaultPath == null ? null : FileUtil.toSystemIndependentName(defaultPath.getPath()),
@Override public void actionPerformed(@NotNull AnActionEvent e) { PackageManagerAdapter packageManagerAdapter = getAdapter(e); if (packageManagerAdapter == null) { return; } String packageNames = Messages.showInputDialog( getEventProject(e), "Enter packages names", getTemplatePresentation().getText(), null ); if (StringUtil.isEmpty(packageNames)) { return; } packageManagerAdapter.install(Arrays.asList(packageNames.split("[^:\\w_]+"))); } }
private void enterCustomOrganizationKey() { while (true) { String organizationKey = Messages.showInputDialog(panel, "Please enter the organization key", "Add Another Organization", null); if (StringUtil.isNotEmpty(organizationKey)) { boolean found = selectOrganizationIfExists(organizationKey); if (found) { break; } GetOrganizationTask task = new GetOrganizationTask(model.createServerWithoutOrganization(), organizationKey); ProgressManager.getInstance().run(task); if (task.organization().isPresent()) { listModel.add(0, task.organization().get()); orgList.setSelectedIndex(0); orgList.ensureIndexIsVisible(0); break; } else if (task.getException() != null) { Messages.showErrorDialog("Failed to fetch organization from SonarQube server: " + task.getException().getMessage(), "Connection Failure"); } else { Messages.showErrorDialog(String.format("Organization '%s' not found. Please enter the key of an existing organization.", organizationKey), "Organization Not Found"); } } else { break; } } }
@Override public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException { ApplicationManager.getApplication().invokeLater(() -> { String markerText = Messages.showInputDialog( project, PerlBundle.message("perl.intention.heredoc.dialog.prompt"), PerlBundle.message("perl.intention.heredoc.dialog.title"), Messages.getQuestionIcon(), HEREDOC_MARKER, null); if (markerText != null) { if (markerText.isEmpty()) { Messages.showErrorDialog( project, PerlBundle.message("perl.intention.heredoc.error.message"), PerlBundle.message("perl.intention.heredoc.error.title") ); } else // converting { HEREDOC_MARKER = markerText; WriteCommandAction.runWriteCommandAction(project, () -> super.invoke(project, editor, element)); } } }); }
protected void createAutobaseNamesComponent(FormBuilder builder) { autobaseModel = new CollectionListModel<>(); autobaseList = new JBList<>(autobaseModel); builder.addLabeledComponent( new JLabel("Autobase names (autobase_names option. Order is important, later components may be inherited from early):"), ToolbarDecorator .createDecorator(autobaseList) .setAddAction(anActionButton -> { String fileName = Messages.showInputDialog( myProject, "Type new Autobase filename:", "New Autobase Filename", Messages.getQuestionIcon(), "", null); if (StringUtil.isNotEmpty(fileName) && !autobaseModel.getItems().contains(fileName)) { autobaseModel.add(fileName); } }) .setPreferredSize(JBUI.size(0, PerlConfigurationUtil.WIDGET_HEIGHT)) .createPanel()); } }