List of usage examples for com.intellij.openapi.ui Messages showInputDialog
@Nullable public static String showInputDialog(String message, @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon)
From source file:com.intellij.application.options.TagListDialog.java
License:Apache License
public TagListDialog(String title) { super(true);/*from w w w .j a v a 2 s.c o m*/ myPanel = ToolbarDecorator.createDecorator(myList).setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { final String tagName = Messages.showInputDialog(ApplicationBundle.message("editbox.enter.tag.name"), ApplicationBundle.message("title.tag.name"), Messages.getQuestionIcon()); if (tagName != null) { while (myData.contains(tagName)) { myData.remove(tagName); } myData.add(tagName); updateData(); myList.setSelectedIndex(myData.size() - 1); } } }).setRemoveAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { int selectedIndex = myList.getSelectedIndex(); if (selectedIndex >= 0) { myData.remove(selectedIndex); updateData(); if (selectedIndex >= myData.size()) { selectedIndex -= 1; } if (selectedIndex >= 0) { myList.setSelectedIndex(selectedIndex); } } } }).disableUpDownActions().createPanel(); setTitle(title); init(); }
From source file:com.intellij.codeInspection.util.SpecialAnnotationsUtil.java
License:Apache License
public static JPanel createSpecialAnnotationsListControl(final List<String> list, final String borderTitle, final boolean acceptPatterns) { final SortedListModel<String> listModel = new SortedListModel<String>(new Comparator<String>() { @Override//from w ww . j a v a 2 s . c o m public int compare(final String o1, final String o2) { return o1.compareTo(o2); } }); final JList injectionList = new JBList(listModel); for (String s : list) { listModel.add(s); } injectionList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); injectionList.getModel().addListDataListener(new ListDataListener() { @Override public void intervalAdded(ListDataEvent e) { listChanged(); } private void listChanged() { list.clear(); for (int i = 0; i < listModel.getSize(); i++) { list.add((String) listModel.getElementAt(i)); } } @Override public void intervalRemoved(ListDataEvent e) { listChanged(); } @Override public void contentsChanged(ListDataEvent e) { listChanged(); } }); ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(injectionList) .setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { Project project = CommonDataKeys.PROJECT .getData(DataManager.getInstance().getDataContext(injectionList)); if (project == null) project = ProjectManager.getInstance().getDefaultProject(); TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project) .createWithInnerClassesScopeChooser( InspectionsBundle.message("special.annotations.list.annotation.class"), GlobalSearchScope.allScope(project), new ClassFilter() { @Override public boolean isAccepted(PsiClass aClass) { return aClass.isAnnotationType(); } }, null); chooser.showDialog(); final PsiClass selected = chooser.getSelected(); if (selected != null) { listModel.add(selected.getQualifiedName()); } } }).setAddActionName(InspectionsBundle.message("special.annotations.list.add.annotation.class")) .disableUpDownActions(); if (acceptPatterns) { toolbarDecorator.setAddIcon(IconUtil.getAddClassIcon()) .addExtraAction(new AnActionButton( InspectionsBundle.message("special.annotations.list.annotation.pattern"), IconUtil.getAddPatternIcon()) { @Override public void actionPerformed(AnActionEvent e) { String selectedPattern = Messages.showInputDialog( InspectionsBundle.message("special.annotations.list.annotation.pattern"), InspectionsBundle.message("special.annotations.list.annotation.pattern"), Messages.getQuestionIcon()); if (selectedPattern != null) { listModel.add(selectedPattern); } } }) .setButtonComparator(InspectionsBundle.message("special.annotations.list.add.annotation.class"), InspectionsBundle.message("special.annotations.list.annotation.pattern"), "Remove"); } JPanel panel = new JPanel(new BorderLayout()); panel.add(SeparatorFactory.createSeparator(borderTitle, null), BorderLayout.NORTH); panel.add(toolbarDecorator.createPanel(), BorderLayout.CENTER); return panel; }
From source file:com.intellij.ide.macro.PromptMacro.java
License:Apache License
@Override @Nullable/*from w ww.j a va2 s . co m*/ protected String promptUser(DataContext dataContext) { return Messages.showInputDialog(IdeBundle.message("prompt.enter.parameters"), IdeBundle.message("title.input"), Messages.getQuestionIcon()); }
From source file:com.intellij.ide.projectView.actions.MoveModulesToSubGroupAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent e) { final DataContext dataContext = e.getDataContext(); final Module[] modules = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataContext); final String[] newGroup; if (myModuleGroup != null) { String message = IdeBundle.message("prompt.specify.name.of.module.subgroup", myModuleGroup.presentableText(), whatToMove(modules)); String subgroup = Messages.showInputDialog(message, IdeBundle.message("title.module.sub.group"), Messages.getQuestionIcon()); if (subgroup == null || "".equals(subgroup.trim())) return; newGroup = ArrayUtil.append(myModuleGroup.getGroupPath(), subgroup); } else {// w w w.j a va2 s . c om String message = IdeBundle.message("prompt.specify.module.group.name", whatToMove(modules)); String group = Messages.showInputDialog(message, IdeBundle.message("title.module.group"), Messages.getQuestionIcon()); if (group == null || "".equals(group.trim())) return; newGroup = new String[] { group }; } doMove(modules, new ModuleGroup(newGroup), dataContext); }
From source file:com.intellij.profile.codeInspection.ui.ProfilesComboBox.java
License:Apache License
public void createProfilesCombo(final Profile selectedProfile, final Set<Profile> availableProfiles, final ProfileManager profileManager) { reloadProfiles(profileManager, availableProfiles, selectedProfile); setRenderer(new DefaultListCellRenderer() { @Override//from w ww .j a v a 2s. co m public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { final Component rendererComponent = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof Profile) { final Profile profile = (Profile) value; setText(profile.getName()); setIcon(profile.isLocal() ? AllIcons.General.Settings : AllIcons.General.ProjectSettings); } else if (value instanceof String) { setText((String) value); } return rendererComponent; } }); addItemListener(new ItemListener() { private Object myDeselectedItem = null; @Override public void itemStateChanged(ItemEvent e) { if (myFrozenProfilesCombo) return; //do not update during reloading if (ItemEvent.SELECTED == e.getStateChange()) { final Object item = e.getItem(); if (profileManager instanceof ProjectProfileManager && item instanceof Profile && ((Profile) item).isLocal()) { if (Messages.showOkCancelDialog( InspectionsBundle.message("inspection.new.profile.ide.to.project.warning.message"), InspectionsBundle.message("inspection.new.profile.ide.to.project.warning.title"), Messages.getErrorIcon()) == DialogWrapper.OK_EXIT_CODE) { final String newName = Messages.showInputDialog( InspectionsBundle.message("inspection.new.profile.text"), InspectionsBundle.message("inspection.new.profile.dialog.title"), Messages.getInformationIcon()); final Object selectedItem = getSelectedItem(); if (newName != null && newName.length() > 0 && selectedItem instanceof Profile) { if (ArrayUtil.find(profileManager.getAvailableProfileNames(), newName) == -1 && ArrayUtil.find( InspectionProfileManager.getInstance().getAvailableProfileNames(), newName) == -1) { saveNewProjectProfile(newName, (Profile) selectedItem, profileManager); return; } else { Messages.showErrorDialog( InspectionsBundle.message("inspection.unable.to.create.profile.message", newName), InspectionsBundle .message("inspection.unable.to.create.profile.dialog.title")); } } } setSelectedItem(myDeselectedItem); } } else { myDeselectedItem = e.getItem(); } } }); }
From source file:com.sixrr.guiceyidea.actions.NewGuiceBindingAnnotationAction.java
License:Apache License
protected PsiElement[] invokeDialogImpl(Project project, PsiDirectory directory) { final String annotationName = Messages.showInputDialog("Name for new binding annotation", "Create Guice Binding Annotation", Messages.getQuestionIcon()); if (annotationName != null) { final MyInputValidator validator = new MyInputValidator(project, directory); validator.canClose(annotationName); return validator.getCreatedElements(); }/*from w w w .j a v a2 s .co m*/ return PsiElement.EMPTY_ARRAY; }
From source file:com.sixrr.guiceyidea.actions.NewGuiceMethodInterceptorAction.java
License:Apache License
protected PsiElement[] invokeDialogImpl(Project project, PsiDirectory directory) { final String InterceptorName = Messages.showInputDialog("Name for new Method Interceptor", "Create Guice Method Interceptor", Messages.getQuestionIcon()); if (InterceptorName != null) { final MyInputValidator validator = new MyInputValidator(project, directory); validator.canClose(InterceptorName); return validator.getCreatedElements(); }/*from w w w. j a v a 2 s. c o m*/ return PsiElement.EMPTY_ARRAY; }
From source file:com.sixrr.guiceyidea.actions.NewGuiceModuleAction.java
License:Apache License
protected PsiElement[] invokeDialogImpl(Project project, PsiDirectory directory) { final String moduleName = Messages.showInputDialog("Name for new module", "Create Guice Module", Messages.getQuestionIcon()); if (moduleName != null) { final MyInputValidator validator = new MyInputValidator(project, directory); validator.canClose(moduleName);//from w ww. j a va 2 s . com return validator.getCreatedElements(); } return PsiElement.EMPTY_ARRAY; }
From source file:com.sixrr.guiceyidea.actions.NewGuiceScopeAnnotationAction.java
License:Apache License
protected PsiElement[] invokeDialogImpl(Project project, PsiDirectory directory) { final String annotationName = Messages.showInputDialog("Name for new scope annotation", "Create Guice Scope Annotation", Messages.getQuestionIcon()); if (annotationName != null) { final MyInputValidator validator = new MyInputValidator(project, directory); validator.canClose(annotationName); return validator.getCreatedElements(); }/*from ww w . j av a 2s . co m*/ return PsiElement.EMPTY_ARRAY; }
From source file:intellijeval.toolwindow.NewFileAction.java
License:Apache License
private static void createNewFile(FileSystemTree fileSystemTree, final FileType fileType, final String initialContent) { final VirtualFile file = fileSystemTree.getNewFileParent(); if (file == null || !file.isDirectory()) return;/*from www.j a v a 2 s . c om*/ String newFileName; while (true) { newFileName = Messages.showInputDialog( UIBundle.message("create.new.file.enter.new.file.name.prompt.text"), UIBundle.message("new.file.dialog.title"), Messages.getQuestionIcon()); if (newFileName == null) { return; } if ("".equals(newFileName.trim())) { Messages.showMessageDialog( UIBundle.message("create.new.file.file.name.cannot.be.empty.error.message"), UIBundle.message("error.dialog.title"), Messages.getErrorIcon()); continue; } Exception failReason = ((FileSystemTreeImpl) fileSystemTree).createNewFile(file, newFileName, fileType, initialContent); if (failReason != null) { Messages.showMessageDialog( UIBundle.message("create.new.file.could.not.create.file.error.message", newFileName), UIBundle.message("error.dialog.title"), Messages.getErrorIcon()); continue; } return; } }