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.visage.ideaplugin.NewVisageClassAction.java
License:Open Source License
@NotNull protected final PsiElement[] invokeDialog(Project project, PsiDirectory directory) { Module module = ModuleUtil.findModuleForFile(directory.getVirtualFile(), project); if (module == null) return PsiElement.EMPTY_ARRAY; MyInputValidator validator = new MyInputValidator(project, directory); Messages.showInputDialog(project, "Enter a new class name", "New Visage Class", Messages.getQuestionIcon(), "", validator); return validator.getCreatedElements(); }
From source file:org.zmlx.hg4idea.command.mq.HgQRenameCommand.java
License:Apache License
public void execute(@NotNull final Hash patchHash) { final Project project = myRepository.getProject(); HgNameWithHashInfo patchInfo = ContainerUtil.find(myRepository.getMQAppliedPatches(), new Condition<HgNameWithHashInfo>() { @Override/*from w w w. j a v a 2s.co m*/ public boolean value(HgNameWithHashInfo info) { return info.getHash().equals(patchHash); } }); if (patchInfo == null) { LOG.error("Could not find patch " + patchHash.toString()); return; } final String oldName = patchInfo.getName(); final String newName = Messages.showInputDialog(project, String.format("Enter a new name for %s patch:", oldName), "Rename Patch", Messages.getQuestionIcon(), "", new HgPatchReferenceValidator(myRepository)); if (newName != null) { performPatchRename(myRepository, oldName, newName); } }
From source file:org.zmlx.hg4idea.util.HgUtil.java
License:Apache License
/** * Shows a message dialog to enter the name of new branch. * * @return name of new branch or {@code null} if user has cancelled the dialog. *//*from w w w. ja v a 2s . c o m*/ @Nullable public static String getNewBranchNameFromUser(@NotNull HgRepository repository, @NotNull String dialogTitle) { return Messages.showInputDialog(repository.getProject(), "Enter the name of new branch:", dialogTitle, Messages.getQuestionIcon(), "", new HgBranchReferenceValidator(repository)); }
From source file:ro.catalin.prata.testflightuploader.view.TFUploader.java
License:Apache License
public TFUploader() { // update the list updateListOfTeams(KeysManager.instance().getTeamList()); uploadButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { performUploadValidation();//ww w . j a v a 2 s.c om } }); teamList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { // if the Add new Team item is selected, open a dialog with name and token input fields if (teamList.getSelectedIndex() == 0) { AddTeamDialog dialog = new AddTeamDialog(new AddTeamDialog.AddTeamListener() { @Override public void onTeamAdded(Team newTeam) { // add the new team to the list KeysManager.instance().addTeam(newTeam); // update the list updateListOfTeams(KeysManager.instance().getTeamList()); } }); dialog.pack(); dialog.setVisible(true); } } }); deleteTeamButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (teamList.getSelectedIndex() > 0) { // remove the selected team from the list KeysManager.instance().removeTeamAtIndex(teamList.getSelectedIndex()); // update the list updateListOfTeams(KeysManager.instance().getTeamList()); } } }); browseButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // create a new file type with the apk extension to be used for file type filtering FileType type = FileTypeManager.getInstance().getFileTypeByExtension("apk"); // create a descriptor for the file chooser FileChooserDescriptor descriptor = Utils.createSingleFileDescriptor(type); descriptor.setTitle("Android Apk File"); descriptor.setDescription("Please chose the project Apk file to be uploaded to Test Flight"); // by default open the first opened project root directory VirtualFile fileToSelect = ProjectManager.getInstance().getOpenProjects()[0].getBaseDir(); // open the file chooser FileChooser.chooseFiles(descriptor, null, fileToSelect, new FileChooser.FileChooserConsumer() { @Override public void cancelled() { // do nothing for now... } @Override public void consume(List<VirtualFile> virtualFiles) { String filePath = virtualFiles.get(0).getPath(); // the file was selected so add it to the text field apkFilePathTextField.setText(filePath); // save the file path KeysManager.instance().setApkFilePath(filePath); } }); } }); setApiKeyButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // open an input dialog for the api key String apiKey = Messages.showInputDialog(ProjectManager.getInstance().getOpenProjects()[0], "<HTML>This token gives you access to the upload API. You can get it from <a href=\"https://testflightapp.com/account/#api\">here</a>.</HTML>", "Upload API Token", null, KeysManager.instance().getApiKey(), null); // save the api key after a minor validation if (apiKey != null && apiKey.length() > 3) { KeysManager.instance().setApiKey(apiKey); } } }); teamList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { distributionsListTextArea.setText(""); if (teamList.getSelectedIndex() > 0) { distributionsListTextArea.setText(KeysManager.instance().getTeamList() .get(teamList.getSelectedIndex()).getDistributionList()); distributionsListTextArea.setEnabled(true); } else { distributionsListTextArea.setEnabled(false); } } }); distributionsListTextArea.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { super.focusLost(e); if (teamList.getSelectedIndex() > 0) { KeysManager.instance().getTeamList().get(teamList.getSelectedIndex()) .setDistributionList(distributionsListTextArea.getText()); } } }); buildVersionHelpBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // build version info button was pressed, display the about text... Messages.showInfoMessage( "This feature let you change the version code/name of the build after it is sent to Test Flight.\n" + "If you change the values of the build version code or name, it will be saved in your main manifest file. \n" + "This can be useful to remind you to increment the build number after sending the apk to TestFlight. \n \n" + "Please note that the change is made after the build is sent to Test Flight.", "Android Build Version Code/Name Update"); } }); buildVersionCheck.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (buildVersionCheck.isSelected()) { setBuildFeatureComponentsVisible(true); } else { setBuildFeatureComponentsVisible(false); } } }); moduleCombo.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { // if a module is selected, save the module KeysManager.instance().setSelectedModuleName((String) moduleCombo.getSelectedItem()); // update the apk path Module module = ModulesManager.instance().getModuleByName((String) moduleCombo.getSelectedItem()); apkFilePathTextField.setText(ModulesManager.instance().getAndroidApkPath(module)); // update the build version fields too updateBuildVersionFields(); } }); // setup the previously saved values on the UI or the default ones setupValuesOnUI(); }
From source file:ru.artlebedev.idea.plugins.parser.zencoding.ZenCodingTemplate.java
License:Apache License
public void wrap(final String selection, @NotNull final CustomTemplateCallback callback) { InputValidatorEx validator = new InputValidatorEx() { public String getErrorText(String inputString) { if (!checkTemplateKey(inputString, callback)) { return XmlBundle.message("zen.coding.incorrect.abbreviation.error"); }// w w w .j a v a 2 s. com return null; } public boolean checkInput(String inputString) { return getErrorText(inputString) == null; } public boolean canClose(String inputString) { return checkInput(inputString); } }; final String abbreviation = Messages.showInputDialog(callback.getProject(), XmlBundle.message("zen.coding.enter.abbreviation.dialog.label"), XmlBundle.message("zen.coding.title"), Messages.getQuestionIcon(), "", validator); if (abbreviation != null) { doWrap(selection, abbreviation, callback); } }