List of usage examples for com.intellij.openapi.ui Messages getQuestionIcon
@NotNull public static Icon getQuestionIcon()
From source file:com.intellij.gwt.actions.GwtCreateActionBase.java
License:Apache License
@Override @Nonnull/* ww w . j av a2 s . c o m*/ protected final PsiElement[] invokeDialog(final Project project, final PsiDirectory directory) { Module module = ModuleUtil.findModuleForFile(directory.getVirtualFile(), project); if (module == null) { return PsiElement.EMPTY_ARRAY; } GoogleGwtModuleExtension facet = ModuleUtilCore.getExtension(module, GoogleGwtModuleExtension.class); if (facet == null) { return PsiElement.EMPTY_ARRAY; } if (requireGwtModule()) { final GwtModule gwtModule = findGwtModule(project, directory); if (gwtModule == null) { final String message = GwtBundle.message( "error.message.this.action.is.allowed.only.for.client.side.packages.of.a.gwt.module"); Messages.showErrorDialog(project, message, CommonBundle.getErrorTitle()); return PsiElement.EMPTY_ARRAY; } } MyInputValidator validator = new MyInputValidator(project, directory); Messages.showInputDialog(project, getDialogPrompt(), getDialogTitle(), Messages.getQuestionIcon(), "", validator); return validator.getCreatedElements(); }
From source file:com.intellij.ide.actionMacro.ActionMacroConfigurationPanel.java
License:Apache License
public JPanel getPanel() { if (mySplitter == null) { mySplitter = new Splitter(false, 0.5f); final String value = PropertiesComponent.getInstance().getValue(SPLITTER_PROPORTION); if (value != null) { mySplitter.setProportion(Float.parseFloat(value)); }//from w w w . j av a 2 s . c o m mySplitter.setFirstComponent( ToolbarDecorator.createDecorator(myMacrosList).setEditAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { final int selIndex = myMacrosList.getSelectedIndex(); if (selIndex == -1) return; final ActionMacro macro = (ActionMacro) myMacrosModel.getElementAt(selIndex); String newName; do { newName = Messages.showInputDialog(mySplitter, IdeBundle.message("prompt.enter.new.name"), IdeBundle.message("title.rename.macro"), Messages.getQuestionIcon(), macro.getName(), null); if (newName == null || macro.getName().equals(newName)) return; } while (!canRenameMacro(newName)); if (myRenamingList == null) myRenamingList = new ArrayList<Pair<String, String>>(); myRenamingList.add(new Pair<String, String>(macro.getName(), newName)); macro.setName(newName); myMacrosList.repaint(); } private boolean canRenameMacro(final String name) { final Enumeration elements = myMacrosModel.elements(); while (elements.hasMoreElements()) { final ActionMacro macro = (ActionMacro) elements.nextElement(); if (macro.getName().equals(name)) { if (Messages.showYesNoDialog(IdeBundle.message("message.macro.exists", name), IdeBundle.message("title.macro.name.already.used"), Messages.getWarningIcon()) != 0) { return false; } myMacrosModel.removeElement(macro); break; } } return true; } }).disableAddAction().disableUpDownActions().createPanel()); mySplitter.setSecondComponent(ToolbarDecorator.createDecorator(myMacroActionsList) .setRemoveAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { final int macrosSelectedIndex = myMacrosList.getSelectedIndex(); if (macrosSelectedIndex != -1) { final ActionMacro macro = (ActionMacro) myMacrosModel .getElementAt(macrosSelectedIndex); macro.deleteAction(myMacroActionsList.getSelectedIndex()); } ListUtil.removeSelectedItems(myMacroActionsList); } }).disableAddAction().disableUpDownActions().createPanel()); } return mySplitter; }
From source file:com.intellij.ide.actionMacro.ActionMacroManager.java
License:Apache License
public void stopRecording(@Nullable Project project) { LOG.assertTrue(myIsRecording);//from w w w . j a v a2 s . com if (myWidget != null) { myWidget.delete(); myWidget = null; } myIsRecording = false; myLastActionInputEvent.clear(); String macroName; do { macroName = Messages.showInputDialog(project, IdeBundle.message("prompt.enter.macro.name"), IdeBundle.message("title.enter.macro.name"), Messages.getQuestionIcon()); if (macroName == null) { myRecordingMacro = null; return; } if (macroName.isEmpty()) macroName = null; } while (macroName != null && !checkCanCreateMacro(macroName)); myLastMacro = myRecordingMacro; addRecordedMacroWithName(macroName); registerActions(); }
From source file:com.intellij.ide.actions.CreateDirectoryOrPackageAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent e) { IdeView view = e.getData(LangDataKeys.IDE_VIEW); Project project = e.getData(CommonDataKeys.PROJECT); if (view == null || project == null) { return;// w ww . j av a2s . c o m } val directory = DirectoryChooserUtil.getOrChooseDirectory(view); if (directory == null) { return; } val info = getInfo(directory); val validator = new CreateDirectoryOrPackageHandler(project, directory, info.getThird() == ChildType.Directory, info.getThird().getSeparator()); Messages.showInputDialog(project, IdeBundle.message("prompt.enter.new.name"), info.getThird().getName(), Messages.getQuestionIcon(), "", validator); val result = validator.getCreatedElement(); if (result != null) { view.selectElement(result); } }
From source file:com.intellij.ide.actions.CreateFileAction.java
License:Apache License
@Override @NotNull//w w w . ja va 2 s . com protected PsiElement[] invokeDialog(final Project project, PsiDirectory directory) { MyInputValidator validator = new MyValidator(project, directory); if (ApplicationManager.getApplication().isUnitTestMode()) { try { return validator.create("test"); } catch (Exception e) { throw new RuntimeException(e); } } else { Messages.showInputDialog(project, IdeBundle.message("prompt.enter.new.file.name"), IdeBundle.message("title.new.file"), Messages.getQuestionIcon(), null, validator); return validator.getCreatedElements(); } }
From source file:com.intellij.ide.actions.CreateLauncherScriptAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent e) { if (!isAvailable()) return;/* ww w .j av a 2 s .c o m*/ Project project = e.getProject(); CreateLauncherScriptDialog dialog = new CreateLauncherScriptDialog(project); dialog.show(); if (!dialog.isOK()) { return; } String path = dialog.myPathField.getText(); if (!path.startsWith("/")) { final String home = System.getenv("HOME"); if (home != null && new File(home).isDirectory()) { if (path.startsWith("~")) { path = home + path.substring(1); } else { path = home + "/" + path; } } } final File target = new File(path, dialog.myNameField.getText()); if (target.exists()) { int rc = Messages.showOkCancelDialog(project, ApplicationBundle.message("launcher.script.overwrite", target), "Create Launcher Script", Messages.getQuestionIcon()); if (rc != 0) { return; } } createLauncherScript(project, target.getAbsolutePath()); }
From source file:com.intellij.ide.actions.ImportSettingsAction.java
License:Apache License
private static void doImport(String path) { final File saveFile = new File(path); try {/*from w w w.j a v a 2 s . co m*/ if (!saveFile.exists()) { Messages.showErrorDialog(IdeBundle.message("error.cannot.find.file", presentableFileName(saveFile)), IdeBundle.message("title.file.not.found")); return; } @SuppressWarnings("IOResourceOpenedButNotSafelyClosed") final ZipEntry magicEntry = new ZipFile(saveFile) .getEntry(ImportSettingsFilenameFilter.SETTINGS_JAR_MARKER); if (magicEntry == null) { Messages.showErrorDialog( IdeBundle.message("error.file.contains.no.settings.to.import", presentableFileName(saveFile), promptLocationMessage()), IdeBundle.message("title.invalid.file")); return; } MultiMap<File, ExportableComponent> fileToComponents = ExportSettingsAction .getExportableComponentsMap(false, true); List<ExportableComponent> components = getComponentsStored(saveFile, fileToComponents.values()); fileToComponents.values().retainAll(components); final ChooseComponentsToExportDialog dialog = new ChooseComponentsToExportDialog(fileToComponents, false, IdeBundle.message("title.select.components.to.import"), IdeBundle.message("prompt.check.components.to.import")); if (!dialog.showAndGet()) { return; } final Set<ExportableComponent> chosenComponents = dialog.getExportableComponents(); Set<String> relativeNamesToExtract = new HashSet<String>(); for (final ExportableComponent chosenComponent : chosenComponents) { final File[] exportFiles = chosenComponent.getExportFiles(); for (File exportFile : exportFiles) { final File configPath = new File(PathManager.getConfigPath()); final String rPath = FileUtil.getRelativePath(configPath, exportFile); assert rPath != null; final String relativePath = FileUtil.toSystemIndependentName(rPath); relativeNamesToExtract.add(relativePath); } } relativeNamesToExtract.add(PluginManager.INSTALLED_TXT); final File tempFile = new File(PathManager.getPluginTempPath() + "/" + saveFile.getName()); FileUtil.copy(saveFile, tempFile); File outDir = new File(PathManager.getConfigPath()); final ImportSettingsFilenameFilter filenameFilter = new ImportSettingsFilenameFilter( relativeNamesToExtract); StartupActionScriptManager.ActionCommand unzip = new StartupActionScriptManager.UnzipCommand(tempFile, outDir, filenameFilter); StartupActionScriptManager.addActionCommand(unzip); // remove temp file StartupActionScriptManager.ActionCommand deleteTemp = new StartupActionScriptManager.DeleteCommand( tempFile); StartupActionScriptManager.addActionCommand(deleteTemp); UpdateSettings.getInstance().forceCheckForUpdateAfterRestart(); String key = ApplicationManager.getApplication().isRestartCapable() ? "message.settings.imported.successfully.restart" : "message.settings.imported.successfully"; final int ret = Messages.showOkCancelDialog( IdeBundle.message(key, ApplicationNamesInfo.getInstance().getProductName(), ApplicationNamesInfo.getInstance().getFullProductName()), IdeBundle.message("title.restart.needed"), Messages.getQuestionIcon()); if (ret == Messages.OK) { ((ApplicationEx) ApplicationManager.getApplication()).restart(true); } } catch (ZipException e1) { Messages.showErrorDialog(IdeBundle.message("error.reading.settings.file", presentableFileName(saveFile), e1.getMessage(), promptLocationMessage()), IdeBundle.message("title.invalid.file")); } catch (IOException e1) { Messages.showErrorDialog(IdeBundle.message("error.reading.settings.file.2", presentableFileName(saveFile), e1.getMessage()), IdeBundle.message("title.error.reading.file")); } }
From source file:com.intellij.ide.actions.OpenFileAction.java
License:Apache License
private static void doOpenFile(@Nullable final Project project, @NotNull final List<VirtualFile> result) { for (final VirtualFile file : result) { if (file.isDirectory()) { Project openedProject = ProjectUtil.openOrImport(file.getPath(), project, false); FileChooserUtil.setLastOpenedFile(openedProject, file); return; }//from w w w .j a v a2 s .c o m if (OpenProjectFileChooserDescriptor.isProjectFile(file)) { int answer = Messages.showYesNoDialog(project, IdeBundle.message("message.open.file.is.project", file.getName()), IdeBundle.message("title.open.project"), Messages.getQuestionIcon()); if (answer == 0) { FileChooserUtil.setLastOpenedFile(ProjectUtil.openOrImport(file.getPath(), project, false), file); return; } } FileType type = FileTypeChooser.getKnownFileTypeOrAssociate(file, project); if (type == null) return; if (project != null) { openFile(file, project); } else { PlatformProjectOpenProcessor processor = PlatformProjectOpenProcessor.getInstance(); processor.doOpenProject(file, null, false); } } }
From source file:com.intellij.ide.bookmarks.BookmarkManager.java
License:Apache License
public void editDescription(@NotNull Bookmark bookmark) { String description = Messages.showInputDialog(myProject, IdeBundle.message("action.bookmark.edit.description.dialog.message"), IdeBundle.message("action.bookmark.edit.description.dialog.title"), Messages.getQuestionIcon(), bookmark.getDescription(), new InputValidator() { @Override//ww w.j a v a2 s. c o m public boolean checkInput(String inputString) { return true; } @Override public boolean canClose(String inputString) { return true; } }); if (description != null) { setDescription(bookmark, description); } }
From source file:com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable.java
License:Apache License
private void onReset() { FileTemplate selected = myCurrentTab.getSelectedTemplate(); if (selected instanceof BundledFileTemplate) { if (Messages.showOkCancelDialog(IdeBundle.message("prompt.reset.to.original.template"), IdeBundle.message("title.reset.template"), Messages.getQuestionIcon()) != DialogWrapper.OK_EXIT_CODE) { return; }/* w w w .j a va2 s . c o m*/ ((BundledFileTemplate) selected).revertToDefaults(); myEditor.reset(); myModified = true; } }