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

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

Introduction

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

Prototype

public static void showMessageDialog(@NotNull Component parent, String message,
            @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon) 

Source Link

Usage

From source file:com.intellij.debugger.ui.breakpoints.JavaFieldBreakpointType.java

License:Apache License

@Nullable
@Override//from w w w  .j  a  v a2  s . co  m
public XLineBreakpoint<JavaFieldBreakpointProperties> addBreakpoint(final Project project,
        JComponent parentComponent) {
    final Ref<XLineBreakpoint> result = Ref.create(null);
    AddFieldBreakpointDialog dialog = new AddFieldBreakpointDialog(project) {
        protected boolean validateData() {
            final String className = getClassName();
            if (className.length() == 0) {
                Messages.showMessageDialog(project,
                        DebuggerBundle.message("error.field.breakpoint.class.name.not.specified"),
                        DebuggerBundle.message("add.field.breakpoint.dialog.title"), Messages.getErrorIcon());
                return false;
            }
            final String fieldName = getFieldName();
            if (fieldName.length() == 0) {
                Messages.showMessageDialog(project,
                        DebuggerBundle.message("error.field.breakpoint.field.name.not.specified"),
                        DebuggerBundle.message("add.field.breakpoint.dialog.title"), Messages.getErrorIcon());
                return false;
            }
            PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(className,
                    GlobalSearchScope.allScope(project));
            if (psiClass != null) {
                final PsiFile psiFile = psiClass.getContainingFile();
                Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
                if (document != null) {
                    PsiField field = psiClass.findFieldByName(fieldName, true);
                    if (field != null) {
                        final int line = document.getLineNumber(field.getTextOffset());
                        ApplicationManager.getApplication().runWriteAction(new Runnable() {
                            @Override
                            public void run() {
                                XLineBreakpoint<JavaFieldBreakpointProperties> fieldBreakpoint = XDebuggerManager
                                        .getInstance(project).getBreakpointManager().addLineBreakpoint(
                                                JavaFieldBreakpointType.this, psiFile.getVirtualFile().getUrl(),
                                                line, new JavaFieldBreakpointProperties(fieldName, className));
                                result.set(fieldBreakpoint);
                            }
                        });
                        return true;
                    } else {
                        Messages.showMessageDialog(project,
                                DebuggerBundle.message("error.field.breakpoint.field.not.found", className,
                                        fieldName, fieldName),
                                CommonBundle.getErrorTitle(), Messages.getErrorIcon());
                    }
                }
            } else {
                Messages.showMessageDialog(
                        project, DebuggerBundle.message("error.field.breakpoint.class.sources.not.found",
                                className, fieldName, className),
                        CommonBundle.getErrorTitle(), Messages.getErrorIcon());
            }
            return false;
        }
    };
    dialog.show();
    return result.get();
}

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   ww w  . ja  v  a 2  s. c  o m*/
    } else {
        super.doOKAction();
    }
}

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

License:Apache License

protected ClassFilter createFilter(String pattern) {
    try {/*  ww  w  .  j  a v a2 s.  co m*/
        Long.parseLong(pattern);
        return super.createFilter(pattern);
    } catch (NumberFormatException e) {
        Messages.showMessageDialog(this,
                DebuggerBundle.message("add.instance.filter.dialog.error.numeric.value.expected"),
                DebuggerBundle.message("add.instance.filter.dialog.title"), Messages.getErrorIcon());
        return null;
    }
}

From source file:com.intellij.diagnostic.ITNReporter2.java

License:Apache License

private static void showMessageDialog(Component parentComponent, Project project, String message, String title,
        Icon icon) {/*from  w ww  . ja  v  a  2  s.  c o m*/
    if (parentComponent.isShowing()) {
        Messages.showMessageDialog(parentComponent, message, title, icon);
    } else {
        Messages.showMessageDialog(project, message, title, icon);
    }
}

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

License:Apache License

@Override
protected void doOKAction() {
    try {/* www.  j a v a2  s  .  c o m*/
        myConfigurable.apply();
    } catch (ConfigurationException e) {
        Messages.showMessageDialog(myProject, e.getMessage(),
                ExecutionBundle.message("invalid.data.dialog.title"), Messages.getErrorIcon());
        return;
    }
    super.doOKAction();
}

From source file:com.intellij.execution.MethodBrowser.java

License:Apache License

protected String showDialog() {
    final String className = getClassName();
    if (className.trim().length() == 0) {
        Messages.showMessageDialog(getField(), ExecutionBundle.message("set.class.name.message"),
                ExecutionBundle.message("cannot.browse.method.dialog.title"), Messages.getInformationIcon());
        return null;
    }//from w w  w.  j  a  v a2s  . co  m
    final PsiClass testClass = getModuleSelector().findClass(className);
    if (testClass == null) {
        Messages.showMessageDialog(getField(),
                ExecutionBundle.message("class.does.not.exists.error.message", className),
                ExecutionBundle.message("cannot.browse.method.dialog.title"), Messages.getInformationIcon());
        return null;
    }
    final MethodListDlg dlg = new MethodListDlg(testClass, getFilter(testClass), getField());
    if (dlg.showAndGet()) {
        final PsiMethod method = dlg.getSelected();
        if (method != null) {
            return method.getName();
        }
    }
    return null;
}

From source file:com.intellij.find.actions.FindUsagesAction.java

License:Apache License

static void chooseAmbiguousTargetAndPerform(@NotNull final Project project, final Editor editor,
        @NotNull PsiElementProcessor<PsiElement> processor) {
    if (editor == null) {
        Messages.showMessageDialog(project, FindBundle.message("find.no.usages.at.cursor.error"),
                CommonBundle.getErrorTitle(), Messages.getErrorIcon());
    } else {/*from ww  w . j a va  2 s .c  o  m*/
        int offset = editor.getCaretModel().getOffset();
        boolean chosen = GotoDeclarationAction.chooseAmbiguousTarget(editor, offset, processor,
                FindBundle.message("find.usages.ambiguous.title"), null);
        if (!chosen) {
            ApplicationManager.getApplication().invokeLater(new Runnable() {
                @Override
                public void run() {
                    if (editor.isDisposed() || !editor.getComponent().isShowing())
                        return;
                    HintManager.getInstance().showErrorHint(editor,
                            FindBundle.message("find.no.usages.at.cursor.error"));
                }
            }, project.getDisposed());
        }
    }
}

From source file:com.intellij.find.actions.FindUsagesInFileAction.java

License:Apache License

@Override
public void actionPerformed(AnActionEvent e) {
    DataContext dataContext = e.getDataContext();
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    if (project == null)
        return;//from  w w w  .  ja  v  a  2s .  com
    PsiDocumentManager.getInstance(project).commitAllDocuments();
    Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);

    UsageTarget[] usageTargets = UsageView.USAGE_TARGETS_KEY.getData(dataContext);
    if (usageTargets != null) {
        FileEditor fileEditor = PlatformDataKeys.FILE_EDITOR.getData(dataContext);
        if (fileEditor != null) {
            usageTargets[0].findUsagesInEditor(fileEditor);
        }
    } else if (editor == null) {
        Messages.showMessageDialog(project, FindBundle.message("find.no.usages.at.cursor.error"),
                CommonBundle.getErrorTitle(), Messages.getErrorIcon());
    } else {
        HintManager.getInstance().showErrorHint(editor, FindBundle.message("find.no.usages.at.cursor.error"));
    }
}

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

License:Apache License

private boolean findUsageInFile(@NotNull FileEditor editor, @NotNull FileSearchScope direction) {
    ApplicationManager.getApplication().assertIsDispatchThread();

    if (myLastSearchInFileData == null)
        return false;
    PsiElement[] primaryElements = myLastSearchInFileData.getPrimaryElements();
    PsiElement[] secondaryElements = myLastSearchInFileData.getSecondaryElements();
    if (primaryElements.length == 0) {//all elements have been invalidated
        Messages.showMessageDialog(myProject,
                FindBundle.message("find.searched.elements.have.been.changed.error"),
                FindBundle.message("cannot.search.for.usages.title"), Messages.getInformationIcon());
        // SCR #10022
        //clearFindingNextUsageInFile();
        return false;
    }/*  w w  w .j av a 2  s  . co  m*/

    //todo
    TextEditor textEditor = (TextEditor) editor;
    Document document = textEditor.getEditor().getDocument();
    PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(document);
    if (psiFile == null)
        return false;

    final FindUsagesHandler handler = getFindUsagesHandler(primaryElements[0], false);
    if (handler == null)
        return false;
    findUsagesInEditor(primaryElements, secondaryElements, handler, psiFile, direction,
            myLastSearchInFileData.myOptions, textEditor);
    return true;
}

From source file:com.intellij.find.impl.FindDialog.java

License:Apache License

private void doOKAction(boolean findAll) {
    FindModel validateModel = (FindModel) myModel.clone();
    applyTo(validateModel, findAll);// ww w . j  a v  a 2  s  .  com

    ValidationInfo validationInfo = getValidationInfo(validateModel);

    if (validationInfo == null) {
        myModel.copyFrom(validateModel);
        updateFindSettings();

        super.doOKAction();
        myOkHandler.consume(myModel);
    } else {
        String message = validationInfo.message;
        Messages.showMessageDialog(myProject, message, CommonBundle.getErrorTitle(), Messages.getErrorIcon());
    }
}