List of usage examples for com.intellij.openapi.ui Messages showInputDialog
@Nullable public static String showInputDialog(@NotNull Component parent, String message, @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon, @Nullable String initialValue, @Nullable InputValidator validator)
From source file:org.jboss.forge.plugin.idea.ui.component.many.TextBoxMultipleComponentBuilder.java
License:Open Source License
@Override public ForgeComponent build(final UIContext context, final InputComponent<?, Object> input) { return new ListComponent((UIInputMany) input) { @Override/*from w w w . ja v a2 s.co m*/ protected String editSelectedItem(String item) { return showEditDialog("Edit item", item); } @Override protected String findItemToAdd() { return showEditDialog("Add item", ""); } private String showEditDialog(String title, final String initialValue) { return Messages.showInputDialog(IDEUtil.projectFromContext(context), "", title, Messages.getQuestionIcon(), initialValue, null); } }; }
From source file:org.jetbrains.android.actions.CreateTypedResourceFileAction.java
License:Apache License
@NotNull @Override//w ww .j a v a 2 s .c om protected PsiElement[] invokeDialog(Project project, PsiDirectory directory) { InputValidator validator = createValidator(project, directory); Messages.showInputDialog(project, AndroidBundle.message("new.file.dialog.text"), AndroidBundle.message("new.typed.resource.dialog.title", myResourcePresentableName), Messages.getQuestionIcon(), "", validator); return PsiElement.EMPTY_ARRAY; }
From source file:org.jetbrains.android.AndroidResourceRenameResourceProcessor.java
License:Apache License
@Nullable private static String getResourceName(Project project, String newFieldName, String oldResourceName) { if (newFieldName.indexOf('_') < 0) return newFieldName; if (oldResourceName.indexOf('_') < 0 && oldResourceName.indexOf('.') >= 0) { String suggestion = newFieldName.replace('_', '.'); newFieldName = Messages.showInputDialog(project, AndroidBundle.message("rename.resource.dialog.text", oldResourceName), RefactoringBundle.message("rename.title"), Messages.getQuestionIcon(), suggestion, null); }/*w w w. j a v a 2 s .c om*/ return newFieldName; }
From source file:org.jetbrains.idea.devkit.actions.GenerateClassAndPatchPluginXmlActionBase.java
License:Apache License
protected PsiElement[] invokeDialogImpl(Project project, PsiDirectory directory) { MyInputValidator validator = new MyInputValidator(project, directory); Messages.showInputDialog(project, getClassNamePrompt(), getClassNamePromptTitle(), Messages.getQuestionIcon(), "", validator); return validator.getCreatedElements(); }
From source file:org.moe.designer.rendering.multi.RenderPreview.java
License:Apache License
/** * Handles clicks within the preview (x and y are positions relative within the * preview/*from ww w.ja v a 2s. co m*/ * * @param x the x coordinate within the preview where the click occurred * @param y the y coordinate within the preview where the click occurred * @return true if this preview handled (and therefore consumed) the click */ public boolean click(int x, int y) { if (y >= myTitleHeight && y < myTitleHeight + HEADER_HEIGHT) { int left = 0; left += AllIcons.Actions.CloseHovered.getIconWidth(); if (x <= left) { // Delete myManager.deletePreview(this); return true; } if (ZOOM_SUPPORT) { left += AndroidIcons.ZoomIn.getIconWidth(); if (x <= left) { // Zoom in myScale *= (1 / 0.5); if (Math.abs(myScale - 1.0) < 0.0001) { myScale = 1.0; } myManager.scheduleRender(this, 0); myManager.layout(true); myManager.redraw(); return true; } left += AndroidIcons.ZoomOut.getIconWidth(); if (x <= left) { // Zoom out myScale *= (0.5 / 1); if (Math.abs(myScale - 1.0) < 0.0001) { myScale = 1.0; } myManager.scheduleRender(this, 0); myManager.layout(true); myManager.redraw(); return true; } } left += AllIcons.Actions.Edit.getIconWidth(); if (x <= left) { // Edit. For now, just rename Project project = myConfiguration.getConfigurationManager().getProject(); String newName = Messages.showInputDialog(project, "Name:", "Rename Preview", null, myConfiguration.getDisplayName(), null); if (newName != null) { myConfiguration.setDisplayName(newName); myManager.redraw(); } return true; } // Clicked anywhere else on header // Perhaps open Edit dialog here? } // myManager.switchTo(this); return true; }
From source file:org.mustbe.consulo.dotnet.module.extension.DotNetConfigurationPanel.java
License:Apache License
public DotNetConfigurationPanel(final DotNetMutableModuleExtension<?> extension, final List<String> variables, final Runnable updater) { super(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, true)); add(DotNetModuleExtensionWithSdkPanel.create(extension, EmptyRunnable.INSTANCE)); val fileNameField = new JBTextField(extension.getFileName()); fileNameField.getEmptyText().setText(DotNetModuleExtension.DEFAULT_FILE_NAME); fileNameField.getDocument().addDocumentListener(new DocumentAdapter() { @Override//from w ww . j a va2s . c o m protected void textChanged(DocumentEvent documentEvent) { extension.setFileName(fileNameField.getText()); } }); add(LabeledComponent.left(fileNameField, DotNetBundle.message("file.label"))); val outputDirectoryField = new JBTextField(extension.getOutputDir()); outputDirectoryField.getEmptyText().setText(DotNetModuleExtension.DEFAULT_OUTPUT_DIR); outputDirectoryField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent documentEvent) { extension.setOutputDir(outputDirectoryField.getText()); } }); add(LabeledComponent.left(outputDirectoryField, DotNetBundle.message("output.dir.label"))); val comp = new ComboBox(DotNetTarget.values()); comp.setRenderer(new ListCellRendererWrapper<DotNetTarget>() { @Override public void customize(JList jList, DotNetTarget dotNetTarget, int i, boolean b, boolean b2) { setText(dotNetTarget.getDescription()); } }); comp.setSelectedItem(extension.getTarget()); comp.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { extension.setTarget((DotNetTarget) comp.getSelectedItem()); } }); add(LabeledComponent.left(comp, DotNetBundle.message("target.label"))); final List<Object> items = new ArrayList<Object>(); final CollectionComboBoxModel model = new CollectionComboBoxModel(items); val mainClassList = new ComboBox(model); mainClassList.setEnabled(false); mainClassList.setRenderer(new ColoredListCellRenderer() { @Override protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { if (!mainClassList.isEnabled()) { return; } if (value instanceof DotNetQualifiedElement) { setIcon(IconDescriptorUpdaters.getIcon((PsiElement) value, 0)); append(((DotNetQualifiedElement) value).getPresentableQName()); } else if (value instanceof String) { setIcon(AllIcons.Toolbar.Unknown); append((String) value, SimpleTextAttributes.ERROR_ATTRIBUTES); } else { append("<none>"); } } }); mainClassList.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!mainClassList.isEnabled()) { return; } Object selectedItem = mainClassList.getSelectedItem(); if (selectedItem instanceof DotNetQualifiedElement) { extension.setMainType(((DotNetQualifiedElement) selectedItem).getPresentableQName()); } else if (selectedItem instanceof String) { extension.setMainType((String) selectedItem); } else { extension.setMainType(null); } } }); model.update(); ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { @Override public void run() { final Ref<DotNetQualifiedElement> selected = Ref.create(); final List<Object> newItems = new ArrayList<Object>(); newItems.add(null); ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { for (PsiElement psiElement : extension.getEntryPointElements()) { if (psiElement instanceof DotNetQualifiedElement) { newItems.add(psiElement); String mainType = extension.getMainType(); DotNetQualifiedElement qualifiedElement = (DotNetQualifiedElement) psiElement; if (mainType != null && Comparing.equal(mainType, qualifiedElement.getPresentableQName())) { selected.set(qualifiedElement); } } } } }); UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { DotNetQualifiedElement selectedType = selected.get(); String mainType = extension.getMainType(); if (mainType != null && selectedType == null) { newItems.add(mainType); } items.clear(); items.addAll(newItems); if (mainType != null) { if (selectedType != null) { model.setSelectedItem(selectedType); } else { model.setSelectedItem(mainType); } } else { model.setSelectedItem(null); } mainClassList.setEnabled(true); model.update(); } }); } }); add(LabeledComponent.left(mainClassList, DotNetBundle.message("main.type.label"))); val debugCombobox = new JBCheckBox(DotNetBundle.message("generate.debug.info.label"), extension.isAllowDebugInfo()); debugCombobox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { extension.setAllowDebugInfo(debugCombobox.isSelected()); } }); add(debugCombobox); val namespacePrefixField = new JBTextField(extension.getNamespacePrefix()); namespacePrefixField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent documentEvent) { extension.setNamespacePrefix(namespacePrefixField.getText()); } }); final LabeledComponent<JBTextField> namespaceComponent = LabeledComponent.left(namespacePrefixField, "Namespace:"); val allowSourceRootsBox = new JBCheckBox(DotNetBundle.message("allow.source.roots.label"), extension.isAllowSourceRoots()); allowSourceRootsBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { extension.setAllowSourceRoots(allowSourceRootsBox.isSelected()); namespaceComponent.setVisible(!allowSourceRootsBox.isSelected()); updater.run(); } }); add(allowSourceRootsBox); add(namespaceComponent); val dataModel = new CollectionListModel<String>(variables) { @Override public int getSize() { return variables.size(); } @Override public String getElementAt(int index) { return variables.get(index); } @Override public void add(final String element) { int i = variables.size(); variables.add(element); fireIntervalAdded(this, i, i); } @Override public void remove(@NotNull final String element) { int i = variables.indexOf(element); variables.remove(element); fireIntervalRemoved(this, i, i); } @Override public void remove(int index) { variables.remove(index); fireIntervalRemoved(this, index, index); } }; val variableList = new JBList(dataModel); ToolbarDecorator variableDecorator = ToolbarDecorator.createDecorator(variableList); variableDecorator.setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton anActionButton) { String name = Messages.showInputDialog(DotNetConfigurationPanel.this, DotNetBundle.message("new.variable.message"), DotNetBundle.message("new.variable.title"), null, null, new InputValidator() { @Override public boolean checkInput(String s) { return !variables.contains(s); } @Override public boolean canClose(String s) { return true; } }); if (StringUtil.isEmpty(name)) { return; } dataModel.add(name); } }); add(variableDecorator.createPanel()); }
From source file:org.mustbe.consulo.unity3d.module.ui.UnityConfigurationPanel.java
License:Apache License
@RequiredDispatchThread public UnityConfigurationPanel(final Unity3dRootMutableModuleExtension extension, final List<String> variables, final Runnable updater) { super(new VerticalFlowLayout(true, true)); ModuleExtensionSdkBoxBuilder<Unity3dRootMutableModuleExtension> sdkBoxBuilder = ModuleExtensionSdkBoxBuilder .create(extension, updater); sdkBoxBuilder.sdkTypeClass(extension.getSdkTypeClass()); sdkBoxBuilder.sdkPointerFunc(// www .ja va2 s .c o m new NullableFunction<Unity3dRootMutableModuleExtension, MutableModuleInheritableNamedPointer<Sdk>>() { @Nullable @Override public MutableModuleInheritableNamedPointer<Sdk> fun( Unity3dRootMutableModuleExtension mutableModuleExtension) { return mutableModuleExtension.getInheritableSdk(); } }); add(sdkBoxBuilder.build()); final ComboBox target = new ComboBox(Unity3dTarget.values()); target.setRenderer(new ColoredListCellRendererWrapper<Unity3dTarget>() { @Override protected void doCustomize(JList list, Unity3dTarget value, int index, boolean selected, boolean hasFocus) { String presentation = value.getPresentation(); int i = presentation.indexOf('('); if (i != -1) { append(presentation.substring(0, i)); append(presentation.substring(i, presentation.length()), SimpleTextAttributes.GRAY_ATTRIBUTES); } else { append(presentation); } } }); target.setSelectedItem(extension.getBuildTarget()); target.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { extension.setBuildTarget((Unity3dTarget) target.getSelectedItem()); } } }); val fileNameField = new JBTextField(extension.getFileName()); fileNameField.getEmptyText().setText(Unity3dRootModuleExtension.FILE_NAME); fileNameField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent documentEvent) { extension.setFileName(fileNameField.getText()); } }); add(LabeledComponent.left(fileNameField, DotNetBundle.message("file.label"))); val outputDirectoryField = new JBTextField(extension.getOutputDir()); outputDirectoryField.getEmptyText().setText(DotNetModuleExtension.DEFAULT_OUTPUT_DIR); outputDirectoryField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent documentEvent) { extension.setOutputDir(outputDirectoryField.getText()); } }); add(LabeledComponent.left(outputDirectoryField, DotNetBundle.message("output.dir.label"))); add(LabeledComponent.left(target, "Target:")); val dataModel = new CollectionListModel<String>(variables) { @Override public int getSize() { return variables.size(); } @Override public String getElementAt(int index) { return variables.get(index); } @Override public void add(final String element) { int i = variables.size(); variables.add(element); fireIntervalAdded(this, i, i); } @Override public void remove(@NotNull final String element) { int i = variables.indexOf(element); variables.remove(element); fireIntervalRemoved(this, i, i); } @Override public void remove(int index) { variables.remove(index); fireIntervalRemoved(this, index, index); } }; val variableList = new JBList(dataModel); ToolbarDecorator variableDecorator = ToolbarDecorator.createDecorator(variableList); variableDecorator.setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton anActionButton) { String name = Messages.showInputDialog(UnityConfigurationPanel.this, DotNetBundle.message("new.variable.message"), DotNetBundle.message("new.variable.title"), null, null, new InputValidator() { @Override public boolean checkInput(String s) { return !variables.contains(s); } @Override public boolean canClose(String s) { return true; } }); if (StringUtil.isEmpty(name)) { return; } dataModel.add(name); } }); add(new JBLabel("Preprocessor variables:")); add(variableDecorator.createPanel()); }
From source file:org.mustbe.consulo.vfs.backgroundTask.ui.BackgroundTaskByVfsChangeManageDialog.java
License:Apache License
private void add(@NotNull BackgroundTaskByVfsChangeProvider provider) { String name = Messages.showInputDialog(myProject, "Name", "Enter Name", UIUtil.getInformationIcon(), provider.getTemplateName(), null); if (name == null) { return;//from w w w.j a v a 2 s. c om } List<BackgroundTaskByVfsChangeTask> tasks = getTasks(); BackgroundTaskByVfsParametersImpl parameters = new BackgroundTaskByVfsParametersImpl(myProject); provider.setDefaultParameters(myProject, myVirtualFile, parameters); BackgroundTaskByVfsChangeManagerImpl manager = (BackgroundTaskByVfsChangeManagerImpl) BackgroundTaskByVfsChangeManagerImpl .getInstance(myProject); BackgroundTaskByVfsChangeTaskImpl e = new BackgroundTaskByVfsChangeTaskImpl(myProject, myVirtualFile, manager, provider, name, parameters); e.setEnabled(true); tasks.add(e); set(tasks); }
From source file:org.qi4j.ide.plugin.idea.common.actions.AbstractCreateElementActionBase.java
License:Apache License
protected MyInputValidator doInvokeDialog(Project project, PsiDirectory directory) { MyInputValidator validator = new MyInputValidator(project, directory); Messages.showInputDialog(project, getDialogPrompt(), getDialogTitle(), Messages.getQuestionIcon(), "", validator);//from w w w. ja va 2 s .c o m return validator; }
From source file:org.qi4j.ide.plugin.idea.concerns.actions.create.inPackage.CreateConcernOfInPackageAction.java
License:Apache License
@NotNull protected final PsiElement[] invokeDialog(Project project, PsiDirectory directory) { MyInputValidator validator = new MyInputValidator(project, directory); Messages.showInputDialog(project, message("createConcernOfInPackage.dlg.prompt"), message("createConcernOfInPackage.dlg.title"), Messages.getQuestionIcon(), "", validator); return validator.getCreatedElements(); }