本文整理了Java中com.intellij.openapi.ui.Messages.showInputDialog()
方法的一些代码示例,展示了Messages.showInputDialog()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Messages.showInputDialog()
方法的具体详情如下:
包路径:com.intellij.openapi.ui.Messages
类名称:Messages
方法名:showInputDialog
暂无
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@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);
}
代码示例来源:origin: hsz/idea-gitignore
String name = Messages.showInputDialog(this,
IgnoreBundle.message("settings.userTemplates.dialogDescription"),
IgnoreBundle.message("settings.userTemplates.dialogTitle"),
代码示例来源:origin: ballerina-platform/ballerina-lang
Project project = editor.getProject();
if (suggestAlias) {
alias = Messages.showInputDialog(project, "Package '" + ((PsiDirectory) element).getName() +
"' already imported. Please enter an alias:", "Enter Alias",
Messages.getInformationIcon());
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@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;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@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);
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
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;
代码示例来源:origin: dubreuia/intellij-plugin-save-actions
@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);
}
}
};
}
代码示例来源:origin: huoguangjin/MultiHighlight
@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);
}
代码示例来源:origin: uwolfer/gerrit-intellij-plugin
@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;
}
代码示例来源:origin: Camelcade/Perl5-IDEA
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);
}
代码示例来源:origin: makejavas/EasyCode
/**
* 输入元素名称
*
* @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);
}
});
}
代码示例来源:origin: makejavas/EasyCode
/**
* 输入元素名称
*
* @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);
}
});
}
代码示例来源:origin: dubreuia/intellij-plugin-save-actions
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);
}
}
};
}
代码示例来源:origin: SonarSource/sonarlint-intellij
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();
}
代码示例来源:origin: BashSupport/BashSupport
@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();
}
代码示例来源:origin: Camelcade/Perl5-IDEA
Ref<String> pathRef = Ref.create();
ApplicationManager.getApplication().invokeAndWait(
() -> pathRef.set(Messages.showInputDialog(
(Project)null, null, dialogTitle, null,
defaultPath == null ? null : FileUtil.toSystemIndependentName(defaultPath.getPath()),
代码示例来源:origin: Camelcade/Perl5-IDEA
@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_]+")));
}
}
代码示例来源:origin: SonarSource/sonarlint-intellij
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;
}
}
}
代码示例来源:origin: Camelcade/Perl5-IDEA
@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));
}
}
});
}
代码示例来源:origin: Camelcade/Perl5-IDEA
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());
}
}
内容来源于网络,如有侵权,请联系作者删除!