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:net.groboclown.idea.p4ic.ui.ErrorDialog.java

License:Apache License

public static void logError(@NotNull final Project project, @NotNull final String action,
        @NotNull final Throwable t) {
    // no response from the user is required, so it's fine
    // to run in an invoke later (there's no Future involved).

    // using ApplicationManager.getApplication().invokeLater
    // will cause the dialog to delay displaying until all
    // other active gui are dismissed.
    SwingUtilities.invokeLater(new Runnable() {
        @Override//from  ww w .  j  a va  2s.c o  m
        public void run() {
            if (!(t instanceof VcsException) && !(t instanceof CancellationException)) {
                LOG.warn("Something threw an invalid exception without being properly wrapped", t);
            }
            if (
            // User explicitly cancelled the operation
            !VcsExceptionUtil.isCancellation(t) &&

            // User has already been warned of these
            !(t instanceof P4WorkingOfflineException) && !(t instanceof P4DisconnectedException)) {
                LOG.warn(t);
                String message = t.getMessage();
                if (message != null) {
                    // Some P4 exceptions can have trailing EOLs.
                    message = message.trim();
                }
                Messages.showMessageDialog(project, P4Bundle.message("errordialog.message", message),
                        P4Bundle.message("errordialog.title", action), Messages.getErrorIcon());
            }
        }
    });
}

From source file:net.groboclown.idea.p4ic.v2.ui.alerts.AbstractErrorHandler.java

License:Apache License

protected void goOffline() {
    serverConnectedController.disconnect();
    Messages.showMessageDialog(getProject(), P4Bundle.message("dialog.offline.went-offline.message"),
            P4Bundle.message("dialog.offline.went-offline.title"), Messages.getInformationIcon());
}

From source file:net.groboclown.idea.p4ic.v2.ui.alerts.ConfigPanelErrorHandler.java

License:Apache License

@Override
public void handleError(@NotNull final Date when) {
    // using ApplicationManager.getApplication().invokeLater
    // will cause the dialog to delay displaying until all
    // other active gui are dismissed.
    SwingUtilities.invokeLater(new Runnable() {
        @Override//www.  ja  v a2  s  .c om
        public void run() {
            Messages.showMessageDialog(project, message, title, Messages.getErrorIcon());
        }
    });
}

From source file:org.evosuite.intellij.EvoAction.java

License:Open Source License

public void actionPerformed(AnActionEvent event) {

    String title = "EvoSuite Plugin";
    Project project = event.getData(PlatformDataKeys.PROJECT);

    ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    ToolWindow toolWindow = toolWindowManager.getToolWindow("EvoSuite");

    final AsyncGUINotifier notifier = IntelliJNotifier.getNotifier(project);

    if (EvoSuiteExecutor.getInstance().isAlreadyRunning()) {
        Messages.showMessageDialog(project, "An instance of EvoSuite is already running", title,
                Messages.getErrorIcon());
        return;/*from w  w w .  j a  va2 s  .  co m*/
    }

    Map<String, Set<String>> map = getCUTsToTest(event);
    if (map == null || map.isEmpty() || map.values().stream().mapToInt(Set::size).sum() == 0) {
        Messages.showMessageDialog(project,
                "No '.java' file or non-empty source folder was selected in a valid module", title,
                Messages.getErrorIcon());
        return;
    }

    EvoStartDialog dialog = new EvoStartDialog();
    dialog.initFields(project, EvoParameters.getInstance());
    dialog.setModal(true);
    dialog.setLocationRelativeTo(null);
    //dialog.setLocationByPlatform(true);
    dialog.pack();
    dialog.setVisible(true);

    if (dialog.isWasOK()) {
        toolWindow.show(() -> notifier.clearConsole());
        EvoParameters.getInstance().save(project);
        EvoSuiteExecutor.getInstance().run(project, EvoParameters.getInstance(), map, notifier);
    }
}

From source file:org.evosuite.intellij.EvoStartDialog.java

License:Open Source License

private void onSelectJavaHome() {

    String jdkStartLocation = getJDKStartLocation();

    JFileChooser fc = new JFileChooser(jdkStartLocation);
    fc.setAcceptAllFileFilterUsed(false);
    fc.setFileFilter(new FileFilter() {
        @Override//ww w .  j  ava 2 s  . c  o m
        public boolean accept(File file) {
            //return checkIfValidJavaHome(file);
            return true; //otherwise all folders will be greyed out
        }

        @Override
        public String getDescription() {
            return "Java Home (containing bin/javac)";
        }
    });
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    int returnVal = fc.showOpenDialog(null);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        String path = fc.getSelectedFile().getAbsolutePath();

        if (!checkIfValidJavaHome(new File(path))) {
            Messages.showMessageDialog(project,
                    "Invalid JDK home: choose a correct one that contains bin/javac", "EvoSuite Plugin",
                    Messages.getErrorIcon());
            return;
        }

        params.setJavaHome(path);
        javaHomeField.setText(path);
    }
}

From source file:org.evosuite.intellij.EvoStartDialog.java

License:Open Source License

private boolean saveParameters(boolean validate) {

    int cores = ((Number) coreField.getValue()).intValue();
    int memory = ((Number) memoryField.getValue()).intValue();
    int time = ((Number) timeField.getValue()).intValue();
    String dir = folderField.getText();
    String mvn = mavenField.getText();
    String javaHome = javaHomeField.getText();
    String evosuiteJar = evosuiteLocationTesxField.getText();

    List<String> errors = new ArrayList<>();

    if (cores < 1) {
        errors.add("Number of cores needs to be positive value");
    } else {//from   ww  w. jav  a2  s  .  c  om
        params.setCores(cores);
    }

    if (memory < 1) {
        errors.add("Memory needs to be a positive value");
    } else {
        params.setMemory(memory);
    }

    if (time < 1) {
        errors.add("Duration needs to be a positive value");
    } else {
        params.setTime(time);
    }

    if (params.usesMaven() && !checkIfValidMaven(new File(mvn))) {
        errors.add("Invalid Maven executable: choose a correct one");
    } else {
        params.setMvnLocation(mvn);
    }

    if (!params.usesMaven() && !checkIfValidEvoSuiteJar(new File(evosuiteJar))) {
        errors.add("Invalid EvoSuite executable jar: choose a correct evosuite*.jar one");
    } else {
        params.setEvosuiteJarLocation(evosuiteJar);
    }

    if (!checkIfValidJavaHome(new File(javaHome))) {
        errors.add("Invalid JDK home: choose a correct one that contains bin/javac");
    } else {
        params.setJavaHome(javaHome);
    }

    params.setFolder(dir);
    params.setGuiWidth(this.getWidth());
    params.setGuiHeight(this.getHeight());

    if (validate && !errors.isEmpty()) {
        String title = "ERROR: EvoSuite Plugin";
        String msg = String.join("\n", errors);
        Messages.showMessageDialog(project, msg, title, Messages.getErrorIcon());
        return false;
    }

    return true;
}

From source file:org.evosuite.intellij.IntelliJNotifier.java

License:Open Source License

@Override
public void success(final String message) {
    SwingUtilities.invokeLater(new Runnable() {
        @Override/*from  w  w w . j ava2s  .c o  m*/
        public void run() {
            Messages.showMessageDialog(project, message, title, Messages.getInformationIcon());
        }
    });
}

From source file:org.evosuite.intellij.IntelliJNotifier.java

License:Open Source License

@Override
public void failed(final String message) {
    SwingUtilities.invokeLater(new Runnable() {
        @Override// w  ww .j  a v  a 2 s .  co  m
        public void run() {
            Messages.showMessageDialog(project, message, title, Messages.getWarningIcon());
        }
    });
}

From source file:org.intellij.lang.xpath.xslt.refactoring.XsltExtractFunctionAction.java

License:Apache License

protected RefactoringOptions getSettings(XPathExpression expression, Set<XPathExpression> matchingExpressions) {
    final String name = Messages.showInputDialog(expression.getProject(), "Function Name: ",
            getRefactoringName(), Messages.getQuestionIcon());
    final boolean[] b = new boolean[] { false };
    if (name != null) {
        final String[] parts = name.split(":", 2);
        if (parts.length < 2) {
            Messages.showMessageDialog(expression.getProject(), "Custom functions require a prefixed name",
                    "Error", Messages.getErrorIcon());
            b[0] = true;//from   w  ww  .j av a 2s .  c  o m
        }
        final XmlElement context = PsiTreeUtil.getContextOfType(expression, XmlElement.class);
        final NamespaceContext namespaceContext = expression.getXPathContext().getNamespaceContext();
        if (namespaceContext != null && context != null
                && namespaceContext.resolve(parts[0], context) == null) {
            Messages.showMessageDialog(expression.getProject(), "Prefix '" + parts[0] + "' is not defined",
                    "Error", Messages.getErrorIcon());
            b[0] = true;
        }
    }
    return new RefactoringOptions() {
        @Override
        public boolean isCanceled() {
            return b[0];
        }

        @Override
        public String getName() {
            return name;
        }
    };
}

From source file:org.intellij.plugins.junit.JUnitHelper.java

License:Open Source License

public static boolean checkProjectCorrectlySetup(Project project) {
    if (!isJUnitInClassPath(project)) {
        Messages.showMessageDialog(project, "JUnit is not in the class path. Please add it first",
                "JUnit Test Plugin Prerequisite Not Met", Messages.getErrorIcon());
        return false;
    }//  w w w.  j  a  va2  s  .  c o  m
    return true;
}