Java Code Examples for com.intellij.openapi.ui.Messages#showYesNoDialog()
The following examples show how to use
com.intellij.openapi.ui.Messages#showYesNoDialog() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CoverageDataManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Override public void removeCoverageSuite(final CoverageSuite suite) { final String fileName = suite.getCoverageDataFileName(); boolean deleteTraces = suite.isTracingEnabled(); if (!FileUtil.isAncestor(ContainerPathManager.get().getSystemPath(), fileName, false)) { String message = "Would you like to delete file \'" + fileName + "\' "; if (deleteTraces) { message += "and traces directory \'" + FileUtil.getNameWithoutExtension(new File(fileName)) + "\' "; } message += "on disk?"; if (Messages.showYesNoDialog(myProject, message, CommonBundle.getWarningTitle(), Messages.getWarningIcon()) == Messages.YES) { deleteCachedCoverage(fileName, deleteTraces); } } else { deleteCachedCoverage(fileName, deleteTraces); } myCoverageSuites.remove(suite); if (myCurrentSuitesBundle != null && myCurrentSuitesBundle.contains(suite)) { CoverageSuite[] suites = myCurrentSuitesBundle.getSuites(); suites = ArrayUtil.remove(suites, suite); chooseSuitesBundle(suites.length > 0 ? new CoverageSuitesBundle(suites) : null); } }
Example 2
Source File: LayoutTreeComponent.java From consulo with Apache License 2.0 | 6 votes |
public boolean checkCanRemove(final List<? extends PackagingElementNode<?>> nodes) { Set<PackagingNodeSource> rootSources = new HashSet<PackagingNodeSource>(); for (PackagingElementNode<?> node : nodes) { rootSources.addAll(getRootNodeSources(node.getNodeSources())); } if (!rootSources.isEmpty()) { final String message; if (rootSources.size() == 1) { final String name = rootSources.iterator().next().getPresentableName(); message = "The selected node belongs to '" + name + "' element. Do you want to remove the whole '" + name + "' element from the artifact?"; } else { message = "The selected node belongs to " + nodes.size() + " elements. Do you want to remove all these elements from the artifact?"; } final int answer = Messages.showYesNoDialog(myArtifactsEditor.getMainComponent(), message, "Remove Elements", null); if (answer != 0) return false; } return true; }
Example 3
Source File: CreateElementBaseAction.java From PackageTemplates with Apache License 2.0 | 6 votes |
private boolean onAsk(java.io.File fileDuplicate) { int dialogAnswerCode = Messages.showYesNoDialog(project, String.format(Localizer.get("warning.ArgAlreadyExists"), elementToString()), Localizer.get("title.WriteConflict"), Localizer.get("action.Overwrite"), Localizer.get("action.Skip"), Messages.getQuestionIcon(), new NeverShowAskCheckBox() ); if (dialogAnswerCode == Messages.OK) { if (!onOverwrite(fileDuplicate)) { return false; } } else { if (!onUseExisting(fileDuplicate)) { return false; } } return true; }
Example 4
Source File: PsiElementRenameHandler.java From consulo with Apache License 2.0 | 6 votes |
public static void invoke(PsiElement element, Project project, PsiElement nameSuggestionContext, @Nullable Editor editor) { if (element != null && !canRename(project, editor, element)) { return; } VirtualFile contextFile = PsiUtilCore.getVirtualFile(nameSuggestionContext); if (nameSuggestionContext != null && nameSuggestionContext.isPhysical() && (contextFile == null || !ScratchUtil.isScratch(contextFile) && !PsiManager.getInstance(project).isInProject(nameSuggestionContext))) { final String message = "Selected element is used from non-project files. These usages won't be renamed. Proceed anyway?"; if (ApplicationManager.getApplication().isUnitTestMode()) throw new CommonRefactoringUtil.RefactoringErrorHintException(message); if (Messages.showYesNoDialog(project, message, RefactoringBundle.getCannotRefactorMessage(null), Messages.getWarningIcon()) != Messages.YES) { return; } } FeatureUsageTracker.getInstance().triggerFeatureUsed("refactoring.rename"); rename(element, project, nameSuggestionContext, editor); }
Example 5
Source File: ManageCodeStyleSchemesDialog.java From consulo with Apache License 2.0 | 6 votes |
public int exportProjectScheme() { String name = Messages.showInputDialog("Enter new scheme name:", "Copy Project Scheme to Global List", Messages.getQuestionIcon()); if (name != null && !CodeStyleSchemesModel.PROJECT_SCHEME_NAME.equals(name)) { CodeStyleScheme newScheme = mySchemesModel.exportProjectScheme(name); updateSchemes(); int switchToGlobal = Messages .showYesNoDialog("Project scheme was copied to global scheme list as '" + newScheme.getName() + "'.\n" + "Switch to this created scheme?", "Copy Project Scheme to Global List", Messages.getQuestionIcon()); if (switchToGlobal == Messages.YES) { mySchemesModel.setUsePerProjectSettings(false); mySchemesModel.selectScheme(newScheme, null); } int row = 0; for (CodeStyleScheme scheme : mySchemes) { if (scheme == newScheme) { fireTableRowsInserted(row, row); return switchToGlobal == 0 ? row : -1; } row++; } } return -1; }
Example 6
Source File: NewProjectAction.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess private static void generateProjectAsync(Project project, @Nonnull NewProjectPanel panel) { // leave current step panel.finish(); NewModuleWizardContext context = panel.getWizardContext(); final File location = new File(context.getPath()); final int childCount = location.exists() ? location.list().length : 0; if (!location.exists() && !location.mkdirs()) { Messages.showErrorDialog(project, "Cannot create directory '" + location + "'", "Create Project"); return; } final VirtualFile baseDir = WriteAction.compute(() -> LocalFileSystem.getInstance().refreshAndFindFileByIoFile(location)); baseDir.refresh(false, true); if (childCount > 0) { int rc = Messages.showYesNoDialog(project, "The directory '" + location + "' is not empty. Continue?", "Create New Project", Messages.getQuestionIcon()); if (rc == Messages.NO) { return; } } RecentProjectsManager.getInstance().setLastProjectCreationLocation(location.getParent()); UIAccess uiAccess = UIAccess.current(); ProjectManager.getInstance().openProjectAsync(baseDir, uiAccess).doWhenDone((openedProject) -> { uiAccess.give(() -> NewOrImportModuleUtil.doCreate(panel, openedProject, baseDir)); }); }
Example 7
Source File: ModulesConfigurator.java From consulo with Apache License 2.0 | 5 votes |
private boolean doRemoveModule(@Nonnull ModuleEditor selectedEditor) { String question; if (myModuleEditors.size() == 1) { question = ProjectBundle.message("module.remove.last.confirmation"); } else { question = ProjectBundle.message("module.remove.confirmation", selectedEditor.getModule().getName()); } int result = Messages.showYesNoDialog(myProject, question, ProjectBundle.message("module.remove.confirmation.title"), Messages.getQuestionIcon()); if (result != Messages.YES) { return false; } // do remove myModuleEditors.remove(selectedEditor); // destroyProcess removed module final Module moduleToRemove = selectedEditor.getModule(); // remove all dependencies on the module that is about to be removed List<ModifiableRootModel> modifiableRootModels = new ArrayList<>(); for (final ModuleEditor moduleEditor : myModuleEditors) { final ModifiableRootModel modifiableRootModel = moduleEditor.getModifiableRootModelProxy(); modifiableRootModels.add(modifiableRootModel); } // destroyProcess editor ModuleDeleteProvider.removeModule(moduleToRemove, null, modifiableRootModels, myModuleModel); processModuleCountChanged(); Disposer.dispose(selectedEditor); return true; }
Example 8
Source File: TeamServicesSettingsModelTest.java From azure-devops-intellij with MIT License | 5 votes |
@Test public void testUpdatePasswords_OK() { teamServicesSettingsModel.getTableSelectionModel().setSelectionInterval(0, 0); when(Messages.showYesNoDialog(mockProject, TfPluginBundle.message(TfPluginBundle.KEY_SETTINGS_PASSWORD_MGT_DIALOG_UPDATE_MSG), TfPluginBundle.message(TfPluginBundle.KEY_SETTINGS_PASSWORD_MGT_DIALOG_UPDATE_TITLE), Messages.getQuestionIcon())).thenReturn(Messages.YES); teamServicesSettingsModel.getTableModel().addServerContexts(new ArrayList<ServerContext>(ImmutableList.of(mockServerContext_GitRepo, mockServerContext_TfvcRepo))); teamServicesSettingsModel.updatePasswords(); assertEquals(0, teamServicesSettingsModel.getDeleteContexts().size()); assertEquals(2, teamServicesSettingsModel.getTableModel().getRowCount()); verifyStatic(times(1)); Messages.showYesNoDialog(eq(mockProject), eq(TfPluginBundle.message(TfPluginBundle.KEY_SETTINGS_PASSWORD_MGT_DIALOG_UPDATE_MSG)), eq(TfPluginBundle.message(TfPluginBundle.KEY_SETTINGS_PASSWORD_MGT_DIALOG_UPDATE_TITLE)), any(Icon.class)); }
Example 9
Source File: ApplyPatchMergeTool.java From consulo with Apache License 2.0 | 5 votes |
@Nullable @Override public Action getResolveAction(@Nonnull final MergeResult result) { if (result == MergeResult.LEFT || result == MergeResult.RIGHT) return null; String caption = MergeUtil.getResolveActionTitle(result, myMergeRequest, myMergeContext); return new AbstractAction(caption) { @Override public void actionPerformed(ActionEvent e) { if (result == MergeResult.RESOLVED) { int unresolved = getUnresolvedCount(); if (unresolved != 0 && Messages.showYesNoDialog(getComponent().getRootPane(), DiffBundle.message("apply.patch.partially.resolved.changes.confirmation.message", unresolved), DiffBundle.message("apply.partially.resolved.merge.dialog.title"), Messages.getQuestionIcon()) != Messages.YES) { return; } } if (result == MergeResult.CANCEL && !MergeUtil.showExitWithoutApplyingChangesDialog(MyApplyPatchViewer.this, myMergeRequest, myMergeContext)) { return; } myMergeContext.finishMerge(result); } }; }
Example 10
Source File: FileSaverDialogImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void doOKAction() { final File file = getFile(); if (file != null && file.exists()) { if (Messages.YES != Messages.showYesNoDialog(this.getRootPane(), UIBundle.message("file.chooser.save.dialog.confirmation", file.getName()), UIBundle.message("file.chooser.save.dialog.confirmation.title"), Messages.getWarningIcon())) { return; } } storeSelection(myFileSystemTree.getSelectedFile()); super.doOKAction(); }
Example 11
Source File: ProjectOrModuleNameStep.java From consulo with Apache License 2.0 | 5 votes |
private boolean validateNameAndPath(@Nonnull NewModuleWizardContext context) throws WizardStepValidationException { final String name = myNamePathComponent.getNameValue(); if (name.length() == 0) { final ApplicationInfo info = ApplicationInfo.getInstance(); throw new WizardStepValidationException(IdeBundle.message("prompt.new.project.file.name", info.getVersionName(), context.getTargetId())); } final String projectFileDirectory = myNamePathComponent.getPath(); if (projectFileDirectory.length() == 0) { throw new WizardStepValidationException(IdeBundle.message("prompt.enter.project.file.location", context.getTargetId())); } final boolean shouldPromptCreation = myNamePathComponent.isPathChangedByUser(); if (!ProjectWizardUtil.createDirectoryIfNotExists(IdeBundle.message("directory.project.file.directory", context.getTargetId()), projectFileDirectory, shouldPromptCreation)) { return false; } final File file = new File(projectFileDirectory); if (file.exists() && !file.canWrite()) { throw new WizardStepValidationException(String.format("Directory '%s' is not writable!\nPlease choose another project location.", projectFileDirectory)); } boolean shouldContinue = true; final File projectDir = new File(myNamePathComponent.getPath(), Project.DIRECTORY_STORE_FOLDER); if (projectDir.exists()) { int answer = Messages .showYesNoDialog(IdeBundle.message("prompt.overwrite.project.folder", projectDir.getAbsolutePath(), context.getTargetId()), IdeBundle.message("title.file.already.exists"), Messages.getQuestionIcon()); shouldContinue = (answer == Messages.YES); } return shouldContinue; }
Example 12
Source File: InplaceChangeSignature.java From consulo with Apache License 2.0 | 5 votes |
public InplaceChangeSignature(Project project, Editor editor, @Nonnull PsiElement element) { myDocumentManager = PsiDocumentManager.getInstance(project); myProject = project; try { myMarkAction = StartMarkAction.start(editor, project, ChangeSignatureHandler.REFACTORING_NAME); } catch (StartMarkAction.AlreadyStartedException e) { final int exitCode = Messages.showYesNoDialog(myProject, e.getMessage(), ChangeSignatureHandler.REFACTORING_NAME, "Navigate to Started", "Cancel", Messages.getErrorIcon()); if (exitCode == Messages.CANCEL) return; PsiElement method = myStableChange.getMethod(); VirtualFile virtualFile = PsiUtilCore.getVirtualFile(method); new OpenFileDescriptor(project, virtualFile, method.getTextOffset()).navigate(true); return; } myEditor = editor; myDetector = LanguageChangeSignatureDetectors.INSTANCE.forLanguage(element.getLanguage()); myStableChange = myDetector.createInitialChangeInfo(element); myInitialSignature = myDetector.extractSignature(myStableChange); myInitialName = DescriptiveNameUtil.getDescriptiveName(myStableChange.getMethod()); TextRange highlightingRange = myDetector.getHighlightingRange(myStableChange); HighlightManager highlightManager = HighlightManager.getInstance(myProject); TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.LIVE_TEMPLATE_ATTRIBUTES); highlightManager.addRangeHighlight(editor, highlightingRange.getStartOffset(), highlightingRange.getEndOffset(), attributes, false, myHighlighters); for (RangeHighlighter highlighter : myHighlighters) { highlighter.setGreedyToRight(true); highlighter.setGreedyToLeft(true); } myEditor.getDocument().addDocumentListener(this); myEditor.putUserData(INPLACE_CHANGE_SIGNATURE, this); myPreview = InplaceRefactoring.createPreviewComponent(project, myDetector.getFileType()); showBalloon(); }
Example 13
Source File: ITNReporter.java From consulo with Apache License 2.0 | 5 votes |
private static int showYesNoDialog(Component parentComponent, Project project, String message, String title, Icon icon) { if (parentComponent.isShowing()) { return Messages.showYesNoDialog(parentComponent, message, title, icon); } else { return Messages.showYesNoDialog(project, message, title, icon); } }
Example 14
Source File: MergeUtil.java From consulo with Apache License 2.0 | 5 votes |
public static boolean showExitWithoutApplyingChangesDialog(@Nonnull JComponent component, @Nonnull MergeRequest request, @Nonnull MergeContext context) { String message = DiffBundle.message("merge.dialog.exit.without.applying.changes.confirmation.message"); String title = DiffBundle.message("cancel.visual.merge.dialog.title"); Couple<String> customMessage = DiffUtil.getUserData(request, context, DiffUserDataKeysEx.MERGE_CANCEL_MESSAGE); if (customMessage != null) { title = customMessage.first; message = customMessage.second; } return Messages.showYesNoDialog(component.getRootPane(), message, title, Messages.getQuestionIcon()) == Messages.YES; }
Example 15
Source File: CourseTabFactory.java From tmc-intellij with MIT License | 5 votes |
@NotNull private ActionListener deleteCourseActionListener(final JTabbedPane tabbedPanelBase) { return actionEvent -> { logger.info("Trying to delete course folder."); if (Messages .showYesNoDialog("Are you sure you wish to permanently delete the course " + tabbedPanelBase.getSelectedComponent().getName() + " and all its exercises?", "Delete Course", Messages.getWarningIcon()) != 0) { return; } try { FileUtils.deleteDirectory(new File(TmcSettingsManager .get().getProjectBasePath() + File.separator + tabbedPanelBase.getSelectedComponent().getName())); new ProjectListWindow().refreshProjectList(); } catch (IOException e1) { e1.printStackTrace(); logger.warn("Deleting course folder failed", e1, e1.getStackTrace()); } }; }
Example 16
Source File: InplaceRefactoring.java From consulo with Apache License 2.0 | 5 votes |
public static void unableToStartWarning(Project project, Editor editor) { final StartMarkAction startMarkAction = StartMarkAction.canStart(project); final String message = startMarkAction.getCommandName() + " is not finished yet."; final Document oldDocument = startMarkAction.getDocument(); if (editor == null || oldDocument != editor.getDocument()) { final int exitCode = Messages.showYesNoDialog(project, message, RefactoringBundle.getCannotRefactorMessage(null), "Continue Started", "Cancel Started", Messages.getErrorIcon()); navigateToStarted(oldDocument, project, exitCode); } else { CommonRefactoringUtil.showErrorHint(project, editor, message, RefactoringBundle.getCannotRefactorMessage(null), null); } }
Example 17
Source File: PluginManagerConfigurable.java From consulo with Apache License 2.0 | 4 votes |
@Messages.YesNoResult private static int showShutDownIDEADialog(final String title) { String message = IdeBundle.message("message.idea.shutdown.required", ApplicationNamesInfo.getInstance().getFullProductName()); return Messages.showYesNoDialog(message, title, "Shut Down", POSTPONE, Messages.getQuestionIcon()); }
Example 18
Source File: BlazeAndroidDeviceSelector.java From intellij with Apache License 2.0 | 4 votes |
private boolean promptAndKillSession( Executor executor, Project project, AndroidSessionInfo info) { String previousExecutor = info.getExecutorId(); String currentExecutor = executor.getId(); if (ourKillLaunchOption.isToBeShown()) { String msg; String noText; if (previousExecutor.equals(currentExecutor)) { msg = String.format( "Restart App?\nThe app is already running. " + "Would you like to kill it and restart the session?"); noText = "Cancel"; } else { msg = String.format( "To switch from %1$s to %2$s, the app has to restart. Continue?", previousExecutor, currentExecutor); noText = "Cancel " + currentExecutor; } String targetName = info.getExecutionTarget().getDisplayName(); String title = "Launching " + targetName; String yesText = "Restart " + targetName; if (Messages.NO == Messages.showYesNoDialog( project, msg, title, yesText, noText, AllIcons.General.QuestionDialog, ourKillLaunchOption)) { return false; } } LOG.info("Disconnecting existing session of the same launch configuration"); info.getProcessHandler().detachProcess(); return true; }
Example 19
Source File: ProgramRunnerUtil.java From consulo with Apache License 2.0 | 4 votes |
public static void executeConfiguration(@Nonnull ExecutionEnvironment environment, boolean showSettings, boolean assignNewId) { if (ExecutorRegistry.getInstance().isStarting(environment)) { return; } RunnerAndConfigurationSettings runnerAndConfigurationSettings = environment.getRunnerAndConfigurationSettings(); if (runnerAndConfigurationSettings != null) { if (!ExecutionTargetManager.canRun(environment)) { ExecutionUtil.handleExecutionError(environment, new ExecutionException( StringUtil.escapeXml("Cannot run '" + environment.getRunProfile().getName() + "' on '" + environment.getExecutionTarget().getDisplayName() + "'"))); return; } if (!RunManagerImpl.canRunConfiguration(environment) || (showSettings && runnerAndConfigurationSettings.isEditBeforeRun())) { if (!RunDialog.editConfiguration(environment, "Edit configuration")) { return; } while (!RunManagerImpl.canRunConfiguration(environment)) { if (Messages.YES == Messages.showYesNoDialog(environment.getProject(), "Configuration is still incorrect. Do you want to edit it again?", "Change Configuration Settings", "Edit", "Continue Anyway", Messages.getErrorIcon())) { if (!RunDialog.editConfiguration(environment, "Edit configuration")) { return; } } else { break; } } } ConfigurationType configurationType = runnerAndConfigurationSettings.getType(); if (configurationType != null) { UsageTrigger.trigger("execute." + ConvertUsagesUtil.ensureProperKey(configurationType.getId()) + "." + environment.getExecutor().getId()); } } try { if (assignNewId) { environment.assignNewExecutionId(); } environment.getRunner().execute(environment); } catch (ExecutionException e) { String name = runnerAndConfigurationSettings != null ? runnerAndConfigurationSettings.getName() : null; if (name == null) { name = environment.getRunProfile().getName(); } if (name == null && environment.getContentToReuse() != null) { name = environment.getContentToReuse().getDisplayName(); } if (name == null) { name = "<Unknown>"; } ExecutionUtil.handleExecutionError(environment.getProject(), environment.getExecutor().getToolWindowId(), name, e); } }
Example 20
Source File: TemplateUtils.java From code-generator with Apache License 2.0 | 4 votes |
private static boolean userConfirmedOverride(String name) { return Messages.showYesNoDialog(name + " already exists,\nConfirm Overwrite?", "File Exists", null) == Messages.OK; }