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

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

Introduction

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

Prototype

int YES

To view the source code for com.intellij.openapi.ui Messages YES.

Click Source Link

Usage

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

License:Apache License

@Override
public void handleError(@NotNull final Date when) {
    LOG.warn("Cached client " + cachedClientName + " does not match p4 reported client " + p4ClientName);

    ApplicationManager.getApplication().assertIsDispatchThread();

    int result = Messages.showYesNoDialog(getProject(),
            P4Bundle.message("configuration.client-mismatch-ask", cachedClientName, p4ClientName),
            P4Bundle.message("configuration.check-connection"), Messages.getErrorIcon());
    if (result == Messages.YES) {
        // Signal to the API to try again only if
        // the user selected "okay".
        tryConfigChange();// ww w.j a  v a  2  s .c o m
    } else {
        goOffline();
    }
}

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

License:Apache License

@Override
public void handleError(@NotNull final Date when) {
    LOG.warn("Configuration problem", getException());

    if (isInvalid()) {
        return;//from w w  w.  j  a  v a  2 s .  c o m
    }

    int result = Messages.showYesNoDialog(getProject(),
            P4Bundle.message("configuration.connection-problem-ask", getExceptionMessage()),
            P4Bundle.message("configuration.check-connection"), Messages.getErrorIcon());
    if (result == Messages.YES) {
        // Signal to the API to try again only if
        // the user selected "okay".
        tryConfigChange();
    } else {
        // Work offline
        goOffline();
    }
}

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

License:Apache License

@Override
public void handleError(@NotNull final Date when) {
    LOG.warn("Invalid client " + clientName);

    ApplicationManager.getApplication().assertIsDispatchThread();

    int result = Messages.showYesNoDialog(getProject(),
            P4Bundle.message("configuration.connection-problem-ask", getExceptionMessage()),
            P4Bundle.message("configuration.check-connection"), Messages.getErrorIcon());
    if (result == Messages.YES) {
        // Signal to the API to try again only if
        // the user selected "okay".
        tryConfigChange();/*from  ww w .  j  a v  a  2 s .c o  m*/
    } else {
        // Work offline
        goOffline();
    }
}

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

License:Apache License

@Override
public void handleError(@NotNull final Date when) {
    LOG.warn("Invalid client root", getException());

    if (isInvalid()) {
        return;/*  w  w w. j  a  v  a2  s.com*/
    }
    final List<VirtualFile> vcsRoots = getVcs().getVcsRoots();
    List<String> vcsPresentableRoots = new ArrayList<String>(vcsRoots.size());
    for (VirtualFile vcsRoot : vcsRoots) {
        vcsPresentableRoots.add(vcsRoot.getPresentableName());
    }

    int result;
    if (workspaceRoots.isEmpty()) {
        result = Messages.showYesNoDialog(getProject(), P4Bundle.message("error.config.no-workspace-roots"),
                P4Bundle.message("error.config.invalid-roots.title", clientServerId.getClientId()),
                P4Bundle.message("error.config.invalid-roots.yes"),
                P4Bundle.message("error.config.invalid-roots.no"), Messages.getErrorIcon());
    } else {
        result = Messages.showYesNoDialog(getProject(),
                P4Bundle.message("error.config.invalid-roots", workspaceRoots, vcsPresentableRoots),
                P4Bundle.message("error.config.invalid-roots.title", clientServerId.getClientId()),
                P4Bundle.message("error.config.invalid-roots.yes"),
                P4Bundle.message("error.config.invalid-roots.no"), Messages.getErrorIcon());
    }
    if (result == Messages.YES) {
        // Signal to the API to try again only if
        // the user selected "okay".
        tryConfigChange(false);
    }
    // Don't go offline if not changed.
}

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

License:Apache License

@Override
public void handleError(@NotNull final Date when) {
    LOG.warn("SSL fingerprint problem", getException());

    if (isInvalid()) {
        return;/*from  ww  w  . j a  v  a 2  s .  co m*/
    }

    // TODO this needs to better handle the SSL fingerprint issues.

    int result = Messages.showYesNoDialog(getProject(),
            P4Bundle.message("configuration.ssl-fingerprint-problem.ask", getExceptionMessage()),
            P4Bundle.message("configuration.ssl-fingerprint-problem.title"), Messages.getErrorIcon());
    if (result == Messages.YES) {
        // Signal to the API to try again only if
        // the user selected "okay".
        tryConfigChange();
    } else {
        // Work offline
        goOffline();
    }
}

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

License:Apache License

@Override
public void handleError(@NotNull final Date when) {
    LOG.warn("SSL key strength problem", getException());

    if (isInvalid()) {
        return;/*from   w  w  w  .ja v a 2  s  .co m*/
    }

    int result = Messages.showYesNoDialog(getProject(), P4Bundle.message("exception.java.ssl.keystrength-ask",
            System.getProperty("java.version") == null ? "<unknown>" : System.getProperty("java.version"),
            System.getProperty("java.vendor") == null ? "<unknown>" : System.getProperty("java.vendor"),
            System.getProperty("java.vendor.url") == null ? "<unknown>" : System.getProperty("java.vendor.url"),
            System.getProperty("java.home") == null ? "<unknown>" : System.getProperty("java.home"),
            getExceptionMessage()), P4Bundle.message("exception.java.ssl.keystrength-ask.title"),
            P4Bundle.message("dialog.confirm.edit-config"), P4Bundle.message("dialog.confirm.work-offline"),
            Messages.getErrorIcon());
    if (result == Messages.YES) {
        // Signal to the API to try again only if
        // the user selected "okay".
        tryConfigChange();
    } else {
        // Work offline
        goOffline();
    }
}

From source file:org.coding.git.util.CodingNetNotifications.java

License:Apache License

@Messages.YesNoResult
public static boolean showYesNoDialog(@Nullable Project project, @NotNull String title,
        @NotNull String message) {
    return Messages.YES == Messages.showYesNoDialog(project, message, title, Messages.getQuestionIcon());
}

From source file:org.coding.git.util.CodingNetNotifications.java

License:Apache License

@Messages.YesNoResult
public static boolean showYesNoDialog(@Nullable Project project, @NotNull String title, @NotNull String message,
        @NotNull DialogWrapper.DoNotAskOption doNotAskOption) {
    return Messages.YES == Messages.showYesNoDialog(project, message, title, Messages.getQuestionIcon(),
            doNotAskOption);/*from w  w w  .ja  v  a  2 s . c o  m*/
}

From source file:org.cordovastudio.utils.CordovaStudioUtils.java

License:Apache License

public static void addRunConfiguration(@NotNull final CordovaFacet facet, @Nullable final String activityClass,
        final boolean ask, @Nullable final TargetSelectionMode targetSelectionMode,
        @Nullable final String preferredAvdName) {
    final Module module = facet.getModule();
    final Project project = module.getProject();

    final Runnable r = new Runnable() {
        @Override// www . j  a  v a  2s  . c  o  m
        public void run() {
            final RunManagerEx runManager = RunManagerEx.getInstanceEx(project);
            final RunnerAndConfigurationSettings settings = runManager.createRunConfiguration(module.getName(),
                    CordovaRunConfigurationType.getInstance().getFactory());
            final CordovaRunConfiguration configuration = (CordovaRunConfiguration) settings.getConfiguration();
            configuration.setModule(module);

            if (activityClass != null) {
                configuration.MODE = CordovaRunConfiguration.LAUNCH_SPECIFIC_ACTIVITY;
                configuration.ACTIVITY_CLASS = activityClass;
            } else {
                configuration.MODE = CordovaRunConfiguration.LAUNCH_DEFAULT_ACTIVITY;
            }

            if (targetSelectionMode != null) {
                configuration.setTargetSelectionMode(targetSelectionMode);
            }
            if (preferredAvdName != null) {
                configuration.PREFERRED_AVD = preferredAvdName;
            }
            runManager.addConfiguration(settings, false);
            runManager.setActiveConfiguration(settings);
        }
    };
    if (!ask) {
        r.run();
    } else {
        UIUtil.invokeLaterIfNeeded(new Runnable() {
            @Override
            public void run() {
                final String moduleName = facet.getModule().getName();
                final int result = Messages.showYesNoDialog(project,
                        "Do you want to create run configuration for module " + moduleName + "?",
                        "Create Run Configuration", Messages.getQuestionIcon());
                if (result == Messages.YES) {
                    r.run();
                }
            }
        });
    }
}

From source file:org.intellij.plugins.relaxNG.convert.IdeaDriver.java

License:Apache License

@SuppressWarnings({ "ThrowableInstanceNeverThrown" })
public void convert(SchemaType inputType, IdeaErrorHandler errorHandler, VirtualFile... inputFiles) {
    if (inputFiles.length == 0) {
        throw new IllegalArgumentException();
    }/*from  ww  w  .ja v  a2s . c o m*/

    try {
        final InputFormat inFormat = getInputFormat(inputType);
        if (inputFiles.length > 1) {
            if (!(inFormat instanceof MultiInputFormat)) {
                throw new IllegalArgumentException();
            }
        }

        final VirtualFile inputFile = inputFiles[0];
        final SchemaType type = settings.getOutputType();
        final String outputType = type.toString().toLowerCase();

        final ArrayList<String> inputParams = new ArrayList<>();

        if (inputType != SchemaType.DTD) {
            final Charset charset = inputFile.getCharset();
            inputParams.add("encoding=" + charset.name());
        }

        final ArrayList<String> outputParams = new ArrayList<>();
        settings.addAdvancedSettings(inputParams, outputParams);

        //      System.out.println("INPUT: " + inputParams);
        //      System.out.println("OUTPUT: " + outputParams);

        Resolver catalogResolver = BasicResolver.getInstance();
        final SchemaCollection sc;
        final String input = inputFile.getPath();
        final String uri = UriOrFile.toUri(input);
        try {
            if (inFormat instanceof MultiInputFormat) {
                final MultiInputFormat format = (MultiInputFormat) inFormat;
                final String[] uris = new String[inputFiles.length];
                for (int i = 0; i < inputFiles.length; i++) {
                    uris[i] = UriOrFile.toUri(inputFiles[i].getPath());
                }
                sc = format.load(uris, ArrayUtil.toStringArray(inputParams), outputType, errorHandler,
                        catalogResolver);
            } else {
                sc = inFormat.load(uri, ArrayUtil.toStringArray(inputParams), outputType, errorHandler,
                        catalogResolver);
            }
        } catch (IOException e) {
            errorHandler.fatalError(new SAXParseException(e.getMessage(), null, uri, -1, -1, e));
            return;
        }

        final File destination = new File(settings.getOutputDestination());
        final File outputFile;
        if (destination.isDirectory()) {
            final String name = new File(input).getName();
            final int ext = name.lastIndexOf('.');
            outputFile = new File(destination, (ext > 0 ? name.substring(0, ext) : name) + "." + outputType);
        } else {
            outputFile = destination;
        }

        try {
            final int indent = settings.getIndent();
            final int length = settings.getLineLength();
            final OutputDirectory od = new LocalOutputDirectory(sc.getMainUri(), outputFile, "." + outputType,
                    settings.getOutputEncoding(), length > 0 ? length : DEFAULT_LINE_LENGTH,
                    indent > 0 ? indent : DEFAULT_INDENT) {
                @Override
                public Stream open(String sourceUri, String encoding) throws IOException {
                    final String s = reference(null, sourceUri);
                    final File file = new File(outputFile.getParentFile(), s);
                    if (file.exists()) {
                        final String msg = "The file '" + file.getAbsolutePath()
                                + "' already exists. Overwrite it?";
                        final int choice = Messages.showYesNoDialog(myProject, msg, "Output File Exists",
                                Messages.getWarningIcon());
                        if (choice == Messages.YES) {
                            return super.open(sourceUri, encoding);
                        } else if (choice == 1) {
                            throw new CanceledException();
                        }
                    }
                    return super.open(sourceUri, encoding);
                }
            };

            final OutputFormat of = getOutputFormat(settings.getOutputType());

            of.output(sc, od, ArrayUtil.toStringArray(outputParams), inputType.toString().toLowerCase(),
                    errorHandler);
        } catch (IOException e) {
            errorHandler.fatalError(
                    new SAXParseException(e.getMessage(), null, UriOrFile.fileToUri(outputFile), -1, -1, e));
        }
    } catch (CanceledException | InvalidParamsException | InputFailedException e) {
        // user abort
    } catch (SAXParseException e) {
        errorHandler.error(e);
    } catch (OutputFailedException e) {
        // handled by ErrorHandler
    } catch (SAXException e) {
        // cannot happen or is already handled
    }
}