Example usage for com.intellij.openapi.ui Messages getQuestionIcon

List of usage examples for com.intellij.openapi.ui Messages getQuestionIcon

Introduction

In this page you can find the example usage for com.intellij.openapi.ui Messages getQuestionIcon.

Prototype

@NotNull
    public static Icon getQuestionIcon() 

Source Link

Usage

From source file:com.intellij.conversion.impl.ui.ConvertProjectDialog.java

License:Apache License

@Override
protected void doOKAction() {
    final List<File> nonexistentFiles = myContext.getNonExistingModuleFiles();
    if (!nonexistentFiles.isEmpty() && !myNonExistingFilesMessageShown) {
        final String filesString = getFilesString(nonexistentFiles);
        final int res = Messages.showYesNoDialog(getContentPane(), IdeBundle.message(
                "message.files.doesn.t.exists.0.so.the.corresponding.modules.won.t.be.converted.do.you.want.to.continue",
                filesString), IdeBundle.message("dialog.title.convert.project"), Messages.getQuestionIcon());
        if (res != 0) {
            super.doOKAction();
            return;
        }//from  w  w w. j  a  v  a2 s. c o  m
        myNonExistingFilesMessageShown = false;
    }

    try {
        if (!checkReadOnlyFiles()) {
            return;
        }

        ProjectConversionUtil.backupFiles(myAffectedFiles, myContext.getProjectBaseDir(), myBackupDir);
        List<ConversionRunner> usedRunners = new ArrayList<ConversionRunner>();
        for (ConversionRunner runner : myConversionRunners) {
            if (runner.isConversionNeeded()) {
                runner.preProcess();
                runner.process();
                runner.postProcess();
                usedRunners.add(runner);
            }
        }
        myContext.saveFiles(myAffectedFiles, usedRunners);
        myConverted = true;
        super.doOKAction();
    } catch (CannotConvertException e) {
        LOG.info(e);
        showErrorMessage(IdeBundle.message("error.cannot.convert.project", e.getMessage()));
    } catch (IOException e) {
        LOG.info(e);
        showErrorMessage(IdeBundle.message("error.cannot.convert.project", e.getMessage()));
    }
}

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;
        }/*from  w  w w  . j a va2 s.  c o  m*/
    }

    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.debugger.ui.ExportDialog.java

License:Apache License

protected void doOKAction() {
    String path = myTfFilePath.getText();
    File file = new File(path);
    if (file.isDirectory()) {
        Messages.showMessageDialog(myProject,
                DebuggerBundle.message("error.threads.export.dialog.file.is.directory"),
                DebuggerBundle.message("threads.export.dialog.title"), Messages.getErrorIcon());
    } else if (file.exists()) {
        int answer = Messages.showYesNoDialog(myProject,
                DebuggerBundle.message("error.threads.export.dialog.file.already.exists", path),
                DebuggerBundle.message("threads.export.dialog.title"), Messages.getQuestionIcon());
        if (answer == 0) {
            super.doOKAction();
        }/*from  w  w  w .  j  a  va2 s. c  om*/
    } else {
        super.doOKAction();
    }
}

From source file:com.intellij.debugger.ui.InstanceFilterEditor.java

License:Apache License

protected void addClassFilter() {
    String idString = Messages.showInputDialog(myProject,
            DebuggerBundle.message("add.instance.filter.dialog.prompt"),
            DebuggerBundle.message("add.instance.filter.dialog.title"), Messages.getQuestionIcon());
    if (idString != null) {
        ClassFilter filter = createFilter(idString);
        if (filter != null) {
            myTableModel.addRow(filter);
            int row = myTableModel.getRowCount() - 1;
            myTable.getSelectionModel().setSelectionInterval(row, row);
            myTable.scrollRectToVisible(myTable.getCellRect(row, 0, true));

        }/*  w w  w.  j  a  va  2s . c  o  m*/
        myTable.requestFocus();
    }
}

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 ww .j ava2s. 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.impl.ExecutionManagerImpl.java

License:Apache License

private static boolean userApprovesStopForSameTypeConfigurations(Project project, String configName,
        int instancesCount) {
    RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project);
    final RunManagerConfig config = runManager.getConfig();
    if (!config.isRestartRequiresConfirmation())
        return true;

    DialogWrapper.DoNotAskOption option = new DialogWrapper.DoNotAskOption() {
        @Override//from www .  j av  a  2 s .  c  om
        public boolean isToBeShown() {
            return config.isRestartRequiresConfirmation();
        }

        @Override
        public void setToBeShown(boolean value, int exitCode) {
            config.setRestartRequiresConfirmation(value);
        }

        @Override
        public boolean canBeHidden() {
            return true;
        }

        @Override
        public boolean shouldSaveOptionsOnCancel() {
            return false;
        }

        @NotNull
        @Override
        public String getDoNotShowMessage() {
            return CommonBundle.message("dialog.options.do.not.show");
        }
    };
    return Messages.showOkCancelDialog(project,
            ExecutionBundle.message("rerun.singleton.confirmation.message", configName, instancesCount),
            ExecutionBundle.message("process.is.running.dialog.title", configName),
            ExecutionBundle.message("rerun.confirmation.button.text"), CommonBundle.message("button.cancel"),
            Messages.getQuestionIcon(), option) == Messages.OK;
}

From source file:com.intellij.execution.impl.ExecutionManagerImpl.java

License:Apache License

private static boolean userApprovesStopForIncompatibleConfigurations(Project project, String configName,
        List<RunContentDescriptor> runningIncompatibleDescriptors) {
    RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project);
    final RunManagerConfig config = runManager.getConfig();
    if (!config.isRestartRequiresConfirmation())
        return true;

    DialogWrapper.DoNotAskOption option = new DialogWrapper.DoNotAskOption() {
        @Override/*  w w  w  .ja  v  a2  s .  c o m*/
        public boolean isToBeShown() {
            return config.isRestartRequiresConfirmation();
        }

        @Override
        public void setToBeShown(boolean value, int exitCode) {
            config.setRestartRequiresConfirmation(value);
        }

        @Override
        public boolean canBeHidden() {
            return true;
        }

        @Override
        public boolean shouldSaveOptionsOnCancel() {
            return false;
        }

        @NotNull
        @Override
        public String getDoNotShowMessage() {
            return CommonBundle.message("dialog.options.do.not.show");
        }
    };

    final StringBuilder names = new StringBuilder();
    for (final RunContentDescriptor descriptor : runningIncompatibleDescriptors) {
        String name = descriptor.getDisplayName();
        if (names.length() > 0) {
            names.append(", ");
        }
        names.append(StringUtil.isEmpty(name) ? ExecutionBundle.message("run.configuration.no.name")
                : String.format("'%s'", name));
    }

    //noinspection DialogTitleCapitalization
    return Messages.showOkCancelDialog(project,
            ExecutionBundle.message("stop.incompatible.confirmation.message", configName, names.toString(),
                    runningIncompatibleDescriptors.size()),
            ExecutionBundle.message("incompatible.configuration.is.running.dialog.title",
                    runningIncompatibleDescriptors.size()),
            ExecutionBundle.message("stop.incompatible.confirmation.button.text"),
            CommonBundle.message("button.cancel"), Messages.getQuestionIcon(), option) == Messages.OK;
}

From source file:com.intellij.execution.testframework.export.ExportTestResultsAction.java

License:Apache License

@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
    LOG.assertTrue(project != null);//from   ww w .j a  v a 2  s . c om
    final ExportTestResultsConfiguration config = ExportTestResultsConfiguration.getInstance(project);

    final String name = ExecutionBundle.message("export.test.results.filename",
            PathUtil.suggestFileName(myRunConfiguration.getName()));
    String filename = name + "." + config.getExportFormat().getDefaultExtension();
    boolean showDialog = true;
    while (showDialog) {
        final ExportTestResultsDialog d = new ExportTestResultsDialog(project, config, filename);
        d.show();
        if (!d.isOK()) {
            return;
        }
        filename = d.getFileName();
        showDialog = getOutputFile(config, project, filename).exists() && Messages.showOkCancelDialog(project,
                ExecutionBundle.message("export.test.results.file.exists.message", filename),
                ExecutionBundle.message("export.test.results.file.exists.title"),
                Messages.getQuestionIcon()) != DialogWrapper.OK_EXIT_CODE;
    }

    final String filename_ = filename;
    ProgressManager.getInstance().run(new Task.Backgroundable(project,
            ExecutionBundle.message("export.test.results.task.name"), false, new PerformInBackgroundOption() {
                @Override
                public boolean shouldStartInBackground() {
                    return true;
                }

                @Override
                public void processSentToBackground() {
                }
            }) {
        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            indicator.setIndeterminate(true);

            final File outputFile = getOutputFile(config, project, filename_);
            final String outputText;
            try {
                outputText = getOutputText(config);
                if (outputText == null) {
                    return;
                }
            } catch (IOException ex) {
                LOG.warn(ex);
                showBalloon(project, MessageType.ERROR,
                        ExecutionBundle.message("export.test.results.failed", ex.getMessage()), null);
                return;
            } catch (TransformerException ex) {
                LOG.warn(ex);
                showBalloon(project, MessageType.ERROR,
                        ExecutionBundle.message("export.test.results.failed", ex.getMessage()), null);
                return;
            } catch (SAXException ex) {
                LOG.warn(ex);
                showBalloon(project, MessageType.ERROR,
                        ExecutionBundle.message("export.test.results.failed", ex.getMessage()), null);
                return;
            } catch (RuntimeException ex) {
                ExportTestResultsConfiguration c = new ExportTestResultsConfiguration();
                c.setExportFormat(ExportTestResultsConfiguration.ExportFormat.Xml);
                c.setOpenResults(false);
                try {
                    String xml = getOutputText(c);
                    LOG.error(LogMessageEx.createEvent("Failed to export test results",
                            ExceptionUtil.getThrowableText(ex), null, null, new Attachment("dump.xml", xml)));
                } catch (Throwable ignored) {
                    LOG.error("Failed to export test results", ex);
                }
                return;
            }

            final Ref<VirtualFile> result = new Ref<VirtualFile>();
            final Ref<String> error = new Ref<String>();
            ApplicationManager.getApplication().invokeAndWait(new Runnable() {
                @Override
                public void run() {
                    result.set(
                            ApplicationManager.getApplication().runWriteAction(new Computable<VirtualFile>() {
                                @Override
                                public VirtualFile compute() {
                                    outputFile.getParentFile().mkdirs();
                                    final VirtualFile parent = LocalFileSystem.getInstance()
                                            .refreshAndFindFileByIoFile(outputFile.getParentFile());
                                    if (parent == null || !parent.isValid()) {
                                        error.set(ExecutionBundle.message("failed.to.create.output.file",
                                                outputFile.getPath()));
                                        return null;
                                    }

                                    try {
                                        VirtualFile result = parent.createChildData(this, outputFile.getName());
                                        VfsUtil.saveText(result, outputText);
                                        return result;
                                    } catch (IOException e) {
                                        LOG.warn(e);
                                        error.set(e.getMessage());
                                        return null;
                                    }
                                }
                            }));
                }
            }, ModalityState.defaultModalityState());

            if (!result.isNull()) {
                if (config.isOpenResults()) {
                    openEditorOrBrowser(result.get(), project,
                            config.getExportFormat() == ExportTestResultsConfiguration.ExportFormat.Xml);
                } else {
                    HyperlinkListener listener = new HyperlinkListener() {
                        @Override
                        public void hyperlinkUpdate(HyperlinkEvent e) {
                            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                                openEditorOrBrowser(result.get(), project, config
                                        .getExportFormat() == ExportTestResultsConfiguration.ExportFormat.Xml);
                            }
                        }
                    };
                    showBalloon(project, MessageType.INFO,
                            ExecutionBundle.message("export.test.results.succeeded", outputFile.getName()),
                            listener);
                }
            } else {
                showBalloon(project, MessageType.ERROR,
                        ExecutionBundle.message("export.test.results.failed", error.get()), null);
            }
        }
    });
}

From source file:com.intellij.find.findUsages.JavaFindUsagesHandler.java

License:Apache License

private static boolean askWhetherShouldSearchForParameterInOverridingMethods(final PsiElement psiElement,
        final PsiParameter parameter) {
    return Messages.showOkCancelDialog(psiElement.getProject(),
            FindBundle.message("find.parameter.usages.in.overriding.methods.prompt", parameter.getName()),
            FindBundle.message("find.parameter.usages.in.overriding.methods.title"),
            CommonBundle.getYesButtonText(), CommonBundle.getNoButtonText(),
            Messages.getQuestionIcon()) == Messages.OK;
}

From source file:com.intellij.find.findUsages.JavaFindUsagesHandler.java

License:Apache License

@Override
@NotNull/*from   ww  w. j a va2 s.co  m*/
public PsiElement[] getSecondaryElements() {
    PsiElement element = getPsiElement();
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        return PsiElement.EMPTY_ARRAY;
    }
    if (element instanceof PsiField) {
        final PsiField field = (PsiField) element;
        PsiClass containingClass = field.getContainingClass();
        if (containingClass != null) {
            String fieldName = field.getName();
            final String propertyName = JavaCodeStyleManager.getInstance(getProject())
                    .variableNameToPropertyName(fieldName, VariableKind.FIELD);
            Set<PsiMethod> accessors = new THashSet<PsiMethod>();
            boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC);
            PsiMethod getter = PropertyUtil.findPropertyGetterWithType(propertyName, isStatic, field.getType(),
                    ContainerUtil.iterate(containingClass.getMethods()));
            if (getter != null) {
                accessors.add(getter);
            }
            PsiMethod setter = PropertyUtil.findPropertySetterWithType(propertyName, isStatic, field.getType(),
                    ContainerUtil.iterate(containingClass.getMethods()));
            if (setter != null) {
                accessors.add(setter);
            }
            accessors.addAll(PropertyUtil.getAccessors(containingClass, fieldName));
            if (!accessors.isEmpty()) {
                boolean containsPhysical = ContainerUtil.find(accessors, new Condition<PsiMethod>() {
                    @Override
                    public boolean value(PsiMethod psiMethod) {
                        return psiMethod.isPhysical();
                    }
                }) != null;
                final boolean doSearch = !containsPhysical || Messages.showOkCancelDialog(
                        FindBundle.message("find.field.accessors.prompt", fieldName),
                        FindBundle.message("find.field.accessors.title"), CommonBundle.getYesButtonText(),
                        CommonBundle.getNoButtonText(), Messages.getQuestionIcon()) == Messages.OK;
                if (doSearch) {
                    final Set<PsiElement> elements = new THashSet<PsiElement>();
                    for (PsiMethod accessor : accessors) {
                        ContainerUtil.addAll(elements,
                                SuperMethodWarningUtil.checkSuperMethods(accessor, ACTION_STRING));
                    }
                    return PsiUtilCore.toPsiElementArray(elements);
                }
            }
        }
    }
    return super.getSecondaryElements();
}