List of usage examples for com.intellij.openapi.ui Messages YES
int YES
To view the source code for com.intellij.openapi.ui Messages YES.
Click Source Link
From source file:com.hp.alm.ali.idea.entity.EntityEditManager.java
License:Apache License
@Override public synchronized void contentRemoveQuery(ContentManagerEvent contentManagerEvent) { Entity entity = ((HasEntity) contentManagerEvent.getContent().getComponent()).getEntity(); if (!edited.containsKey(entity)) { // not edited return;/*from ww w .ja v a 2s . co m*/ } if (!Boolean.TRUE.equals(edited.get(entity))) { // not dirty return; } if (closeContentsCanceled) { // dirty and canceled contentManagerEvent.consume(); return; } switch (askUser()) { case Messages.YES: // approve return; case Messages.CANCEL: closeContentsCanceled = true; } // dirty and rejected or canceled contentManagerEvent.consume(); }
From source file:com.hp.alm.ali.idea.ui.dialog.MyDialog.java
License:Apache License
protected void close(boolean cleanClose) { if (!cleanClose) { JButton save = getButton(Button.Save); if (save != null && save.isEnabled()) { if (project.getComponent(EntityEditManager.class).askUser() != Messages.YES) { return; }/* www .j av a 2 s . c om*/ } } setVisible(false); dispose(); }
From source file:com.igormaznitsa.ideamindmap.editor.MindMapDialogProvider.java
License:Apache License
@Override public boolean msgConfirmYesNo(final String title, final String text) { return Messages.showYesNoDialog(this.project, text, title, Messages.getQuestionIcon()) == Messages.YES; }
From source file:com.igormaznitsa.ideamindmap.editor.MindMapDialogProvider.java
License:Apache License
@Override public Boolean msgConfirmYesNoCancel(final String title, final String text) { final int result = Messages.showYesNoCancelDialog(this.project, text, title, Messages.getQuestionIcon()); return result == Messages.CANCEL ? null : result == Messages.YES; }
From source file:com.intellij.application.options.codeStyle.ManageCodeStyleSchemesDialog.java
License:Apache License
@Nullable private String importExternalCodeStyle(String importerName) throws SchemeImportException { final SchemeImporter<CodeStyleScheme> importer = SchemeImporterEP.getImporter(importerName, CodeStyleScheme.class); if (importer != null) { FileChooserDialog fileChooser = FileChooserFactory.getInstance() .createFileChooser(new FileChooserDescriptor(true, false, false, false, false, false) { @Override//from w w w . j av a 2s . c om public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { return file.isDirectory() || importer.getSourceExtension().equals(file.getExtension()); } @Override public boolean isFileSelectable(VirtualFile file) { return !file.isDirectory() && importer.getSourceExtension().equals(file.getExtension()); } }, null, myContentPane); VirtualFile[] selection = fileChooser.choose(null, CodeStyleSchemesUIConfiguration.Util.getRecentImportFile()); if (selection.length == 1) { VirtualFile selectedFile = selection[0]; selectedFile.refresh(false, false); CodeStyleSchemesUIConfiguration.Util.setRecentImportFile(selectedFile); try { InputStream nameInputStream = selectedFile.getInputStream(); String[] schemeNames; try { schemeNames = importer.readSchemeNames(nameInputStream); } finally { nameInputStream.close(); } CodeStyleScheme currScheme = myModel.getSelectedScheme(); ImportSchemeChooserDialog schemeChooserDialog = new ImportSchemeChooserDialog(myContentPane, schemeNames, !currScheme.isDefault() ? currScheme.getName() : null); if (schemeChooserDialog.showAndGet()) { String schemeName = schemeChooserDialog.getSelectedName(); String targetName = schemeChooserDialog.getTargetName(); CodeStyleScheme targetScheme = null; if (schemeChooserDialog.isUseCurrentScheme()) { targetScheme = myModel.getSelectedScheme(); } else { if (targetName == null) targetName = ApplicationBundle.message("code.style.scheme.import.unnamed"); for (CodeStyleScheme scheme : myModel.getSchemes()) { if (targetName.equals(scheme.getName())) { targetScheme = scheme; break; } } if (targetScheme == null) { int row = mySchemesTableModel.createNewScheme(getSelectedScheme(), targetName); mySchemesTable.getSelectionModel().setSelectionInterval(row, row); targetScheme = mySchemesTableModel.getSchemeAt(row); } else { int result = Messages.showYesNoDialog(myContentPane, ApplicationBundle.message("message.code.style.scheme.already.exists", targetName), ApplicationBundle.message("title.code.style.settings.import"), Messages.getQuestionIcon()); if (result != Messages.YES) { return null; } } } InputStream dataInputStream = selectedFile.getInputStream(); try { importer.importScheme(dataInputStream, schemeName, targetScheme); myModel.fireSchemeChanged(targetScheme); } finally { dataInputStream.close(); } return targetScheme.getName(); } } catch (IOException e) { throw new SchemeImportException(e); } } } return null; }
From source file:com.intellij.application.options.InitialConfigurationDialog.java
License:Apache License
@Override protected void doOKAction() { final Project project = CommonDataKeys.PROJECT .getData(DataManager.getInstance().getDataContext(myMainPanel)); super.doOKAction(); // set keymap ((KeymapManagerImpl) KeymapManager.getInstance()) .setActiveKeymap((Keymap) myKeymapComboBox.getSelectedItem()); // set color scheme EditorColorsManager.getInstance()//w w w . j ava 2 s .com .setGlobalScheme((EditorColorsScheme) myColorSchemeComboBox.getSelectedItem()); // create default todo_pattern for color scheme TodoConfiguration.getInstance().resetToDefaultTodoPatterns(); final boolean createScript = myCreateScriptCheckbox.isSelected(); final boolean createEntry = myCreateEntryCheckBox.isSelected(); if (createScript || createEntry) { final String pathName = myScriptPathTextField.getText(); final boolean globalEntry = myGlobalEntryCheckBox.isSelected(); ProgressManager.getInstance().run(new Task.Backgroundable(project, getTitle()) { @Override public void run(@NotNull final ProgressIndicator indicator) { indicator.setFraction(0.0); if (createScript) { indicator.setText("Creating launcher script..."); CreateLauncherScriptAction.createLauncherScript(project, pathName); indicator.setFraction(0.5); } if (createEntry) { CreateDesktopEntryAction.createDesktopEntry(project, indicator, globalEntry); } indicator.setFraction(1.0); } }); } UIManager.LookAndFeelInfo info = (UIManager.LookAndFeelInfo) myAppearanceComboBox.getSelectedItem(); LafManagerImpl lafManager = (LafManagerImpl) LafManager.getInstance(); if (info.getName().contains("Darcula") != (LafManager.getInstance() .getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo)) { lafManager.setLookAndFeelAfterRestart(info); int rc = Messages.showYesNoDialog(project, "IDE appearance settings will be applied after restart. Would you like to restart now?", "IDE Appearance", Messages.getQuestionIcon()); if (rc == Messages.YES) { ((ApplicationImpl) ApplicationManager.getApplication()).restart(true); } } else if (!info.equals(lafManager.getCurrentLookAndFeel())) { lafManager.setCurrentLookAndFeel(info); lafManager.updateUI(); } }
From source file:com.intellij.conversion.impl.ConversionServiceImpl.java
License:Apache License
@Override @NotNull//w w w. j a v a 2s . c om public ConversionResult convertModule(@NotNull final Project project, @NotNull final File moduleFile) { final IProjectStore stateStore = ((ProjectImpl) project).getStateStore(); final String url = stateStore.getPresentableUrl(); assert url != null : project; final String projectPath = FileUtil.toSystemDependentName(url); if (!isConversionNeeded(projectPath, moduleFile)) { return ConversionResultImpl.CONVERSION_NOT_NEEDED; } final int res = Messages.showYesNoDialog(project, IdeBundle.message("message.module.file.has.an.older.format.do.you.want.to.convert.it"), IdeBundle.message("dialog.title.convert.module"), Messages.getQuestionIcon()); if (res != Messages.YES) { return ConversionResultImpl.CONVERSION_CANCELED; } if (!moduleFile.canWrite()) { Messages.showErrorDialog(project, IdeBundle.message("error.message.cannot.modify.file.0", moduleFile.getAbsolutePath()), IdeBundle.message("dialog.title.convert.module")); return ConversionResultImpl.ERROR_OCCURRED; } try { ConversionContextImpl context = new ConversionContextImpl(projectPath); final List<ConversionRunner> runners = createConversionRunners(context, Collections.<String>emptySet()); final File backupFile = ProjectConversionUtil.backupFile(moduleFile); List<ConversionRunner> usedRunners = new ArrayList<ConversionRunner>(); for (ConversionRunner runner : runners) { if (runner.isModuleConversionNeeded(moduleFile)) { runner.convertModule(moduleFile); usedRunners.add(runner); } } context.saveFiles(Collections.singletonList(moduleFile), usedRunners); Messages.showInfoMessage(project, IdeBundle.message( "message.your.module.was.successfully.converted.br.old.version.was.saved.to.0", backupFile.getAbsolutePath()), IdeBundle.message("dialog.title.convert.module")); return new ConversionResultImpl(runners); } catch (CannotConvertException e) { LOG.info(e); Messages.showErrorDialog(IdeBundle.message("error.cannot.load.project", e.getMessage()), "Cannot Convert Module"); return ConversionResultImpl.ERROR_OCCURRED; } catch (IOException e) { LOG.info(e); return ConversionResultImpl.ERROR_OCCURRED; } }
From source file:com.intellij.debugger.engine.DebugProcessEvents.java
License:Apache License
private void processLocatableEvent(final SuspendContextImpl suspendContext, final LocatableEvent event) { if (myReturnValueWatcher != null && event instanceof MethodExitEvent) { if (myReturnValueWatcher.processMethodExitEvent(((MethodExitEvent) event))) { return; }// w ww . j a v a2 s . c om } ThreadReference thread = event.thread(); //LOG.assertTrue(thread.isSuspended()); preprocessEvent(suspendContext, thread); //we use schedule to allow processing other events during processing this one //this is especially necessary if a method is breakpoint condition getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) { @Override public void contextAction() throws Exception { final SuspendManager suspendManager = getSuspendManager(); SuspendContextImpl evaluatingContext = SuspendManagerUtil.getEvaluatingContext(suspendManager, getSuspendContext().getThread()); if (evaluatingContext != null && !DebuggerSession.enableBreakpointsDuringEvaluation()) { // is inside evaluation, so ignore any breakpoints suspendManager.voteResume(suspendContext); return; } final LocatableEventRequestor requestor = (LocatableEventRequestor) getRequestsManager() .findRequestor(event.request()); boolean resumePreferred = requestor != null && DebuggerSettings.SUSPEND_NONE.equals(requestor.getSuspendPolicy()); boolean requestHit; try { requestHit = (requestor != null) && requestor.processLocatableEvent(this, event); } catch (final LocatableEventRequestor.EventProcessingException ex) { if (LOG.isDebugEnabled()) { LOG.debug(ex.getMessage()); } final boolean[] considerRequestHit = new boolean[] { true }; DebuggerInvocationUtil.invokeAndWait(getProject(), new Runnable() { @Override public void run() { DebuggerPanelsManager.getInstance(getProject()).toFront(mySession); final String displayName = requestor instanceof Breakpoint ? ((Breakpoint) requestor).getDisplayName() : requestor.getClass().getSimpleName(); final String message = DebuggerBundle.message( "error.evaluating.breakpoint.condition.or.action", displayName, ex.getMessage()); considerRequestHit[0] = Messages.showYesNoDialog(getProject(), message, ex.getTitle(), Messages.getQuestionIcon()) == Messages.YES; } }, ModalityState.NON_MODAL); requestHit = considerRequestHit[0]; resumePreferred = !requestHit; } if (requestHit && requestor instanceof Breakpoint) { // if requestor is a breakpoint and this breakpoint was hit, no matter its suspend policy ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { XDebugSession session = getSession().getXDebugSession(); if (session != null) { XBreakpoint breakpoint = ((Breakpoint) requestor).getXBreakpoint(); if (breakpoint != null) { ((XDebugSessionImpl) session).processDependencies(breakpoint); } } } }); } if (!requestHit || resumePreferred) { suspendManager.voteResume(suspendContext); } else { if (myReturnValueWatcher != null) { myReturnValueWatcher.disable(); } //if (suspendContext.getSuspendPolicy() == EventRequest.SUSPEND_ALL) { // // there could be explicit resume as a result of call to voteSuspend() // // e.g. when breakpoint was considered invalid, in that case the filter will be applied _after_ // // resuming and all breakpoints in other threads will be ignored. // // As resume() implicitly cleares the filter, the filter must be always applied _before_ any resume() action happens // myBreakpointManager.applyThreadFilter(DebugProcessEvents.this, event.thread()); //} suspendManager.voteSuspend(suspendContext); showStatusText(DebugProcessEvents.this, event); } } }); }
From source file:com.intellij.diagnostic.SubmitPerformanceReportAction.java
License:Apache License
@Override public void actionPerformed(final AnActionEvent e) { String reportFileName = "perf_" + ApplicationInfo.getInstance().getBuild().asString() + "_" + SystemProperties.getUserName() + "_" + myDateFormat.format(new Date()) + ".zip"; final File reportPath = new File(SystemProperties.getUserHome(), reportFileName); final File logDir = new File(PathManager.getLogPath()); final Project project = e.getData(CommonDataKeys.PROJECT); final boolean[] archiveCreated = new boolean[1]; final boolean completed = ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { @Override//w w w .j a va 2s . com public void run() { try { ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(reportPath)); ZipUtil.addDirToZipRecursively(zip, reportPath, logDir, "", new FileFilter() { @Override public boolean accept(final File pathname) { ProgressManager.checkCanceled(); if (logDir.equals(pathname.getParentFile())) { return pathname.getPath().contains("threadDumps"); } return true; } }, null); zip.close(); archiveCreated[0] = true; } catch (final IOException ex) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { Messages.showErrorDialog(project, "Failed to create performance report archive: " + ex.getMessage(), MESSAGE_TITLE); } }); } } }, "Collecting Performance Report data", true, project); if (!completed || !archiveCreated[0]) { return; } int rc = Messages.showYesNoDialog(project, "The performance report has been saved to\n" + reportPath + "\n\nWould you like to submit it to JetBrains?", MESSAGE_TITLE, Messages.getQuestionIcon()); if (rc == Messages.YES) { ProgressManager.getInstance().run(new Task.Backgroundable(project, "Uploading Performance Report") { @Override public void run(@NotNull final ProgressIndicator indicator) { final String error = uploadFileToFTP(reportPath, "ftp.intellij.net", ".uploads", indicator); if (error != null) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { Messages.showErrorDialog(error, MESSAGE_TITLE); } }); } } }); } }
From source file:com.intellij.execution.ProgramRunnerUtil.java
License:Apache License
public static void executeConfiguration(@NotNull ExecutionEnvironment environment, boolean showSettings, boolean assignNewId) { if (ExecutorRegistry.getInstance().isStarting(environment)) { return;// w w w . j a v a 2 s .co m } 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); } }