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

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

Introduction

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

Prototype

@YesNoResult
public static int showYesNoDialog(String message,
        @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon) 

Source Link

Document

Use this method only if you do not know project or component

Usage

From source file:com.intellij.ide.plugins.PluginInstaller.java

License:Apache License

@Nullable("Will return null is download failed")
private static Set<PluginNode> prepareToInstall(@NotNull PluginNode toInstall,
        @NotNull List<PluginId> toInstallAll, @NotNull List<IdeaPluginDescriptor> allPlugins)
        throws IOException {
    val depends = new ArrayListSet<PluginNode>();
    val unknownDepends = new ArrayListSet<String>();
    collectDepends(toInstall, toInstallAll, depends, allPlugins, unknownDepends);

    if (!unknownDepends.isEmpty()) {
        val ref = new boolean[1];
        UIUtil.invokeAndWaitIfNeeded(new Runnable() {
            @Override/*  w  w w .j  av a2s. co  m*/
            public void run() {
                String mergedIds = StringUtil.join(unknownDepends, ", ");

                String title = IdeBundle.message("plugin.manager.unknown.dependencies.detected.title");
                String message = IdeBundle.message("plugin.manager.unknown.dependencies.detected.message",
                        unknownDepends.size(), mergedIds);
                ref[0] = Messages.showYesNoDialog(message, title, Messages.getWarningIcon()) == Messages.YES;
            }
        });

        if (!ref[0]) {
            return null;
        }
    }
    val toDownloadList = new ArrayListSet<PluginNode>();
    if (!depends.isEmpty()) {

        UIUtil.invokeAndWaitIfNeeded(new Runnable() {
            @Override
            public void run() {
                String mergedIds = StringUtil.join(depends, new Function<PluginNode, String>() {
                    @Override
                    public String fun(PluginNode pluginNode) {
                        return pluginNode.getName();
                    }
                }, ", ");

                String title = IdeBundle.message("plugin.manager.dependencies.detected.title");
                String message = IdeBundle.message("plugin.manager.dependencies.detected.message",
                        depends.size(), mergedIds);
                if (Messages.showYesNoDialog(message, title, Messages.getWarningIcon()) == Messages.YES) {
                    toDownloadList.addAll(depends);
                }
            }
        });
    }

    toDownloadList.add(toInstall);

    for (PluginNode pluginNode : toDownloadList) {
        PluginDownloader downloader = null;
        final String repositoryName = pluginNode.getRepositoryName();
        if (repositoryName != null) {
            try {
                final List<PluginDownloader> downloaders = new ArrayList<PluginDownloader>();
                if (!UpdateChecker.checkPluginsHost(repositoryName, downloaders)) {
                    return null;
                }
                for (PluginDownloader pluginDownloader : downloaders) {
                    if (Comparing.strEqual(pluginDownloader.getPluginId(),
                            pluginNode.getPluginId().getIdString())) {
                        downloader = pluginDownloader;
                        break;
                    }
                }
                if (downloader == null)
                    return null;
            } catch (Exception e) {
                return null;
            }
        } else {
            downloader = PluginDownloader.createDownloader(pluginNode);
        }
        if (downloader.prepareToInstall(ProgressManager.getInstance().getProgressIndicator())) {
            downloader.install(true);
            pluginNode.setStatus(PluginNode.STATUS_DOWNLOADED);
        } else {
            return null;
        }
    }
    return toDownloadList;
}

From source file:com.intellij.ide.util.projectWizard.NamePathComponent.java

License:Apache License

public boolean validateNameAndPath(WizardContext context) throws ConfigurationException {
    final String name = getNameValue();
    if (name.length() == 0) {
        final ApplicationInfo info = ApplicationManager.getApplication().getComponent(ApplicationInfo.class);
        throw new ConfigurationException(IdeBundle.message("prompt.new.project.file.name",
                info.getVersionName(), context.getPresentationName()));
    }/*from  w  w  w. ja  v  a  2 s . c  o m*/

    final String projectFileDirectory = getPath();
    if (projectFileDirectory.length() == 0) {
        throw new ConfigurationException(
                IdeBundle.message("prompt.enter.project.file.location", context.getPresentationName()));
    }

    final boolean shouldPromptCreation = isPathChangedByUser();
    if (!ProjectWizardUtil.createDirectoryIfNotExists(
            IdeBundle.message("directory.project.file.directory", context.getPresentationName()),
            projectFileDirectory, shouldPromptCreation)) {
        return false;
    }

    final File file = new File(projectFileDirectory);
    if (file.exists() && !file.canWrite()) {
        throw new ConfigurationException(
                String.format("Directory '%s' is not writable!\nPlease choose another project location.",
                        projectFileDirectory));
    }

    boolean shouldContinue = true;
    final File projectDir = new File(getPath(), Project.DIRECTORY_STORE_FOLDER);
    if (projectDir.exists()) {
        int answer = Messages.showYesNoDialog(
                IdeBundle.message("prompt.overwrite.project.folder", projectDir.getAbsolutePath(),
                        context.getPresentationName()),
                IdeBundle.message("title.file.already.exists"), Messages.getQuestionIcon());
        shouldContinue = (answer == Messages.YES);
    }

    return shouldContinue;
}

From source file:com.intellij.ide.util.projectWizard.ProjectNameStep.java

License:Apache License

public boolean validate() throws ConfigurationException {
    String name = myNamePathComponent.getNameValue();
    if (name.length() == 0) {
        final ApplicationInfo info = ApplicationManager.getApplication().getComponent(ApplicationInfo.class);
        throw new ConfigurationException(IdeBundle.message("prompt.new.project.file.name",
                info.getVersionName(), myWizardContext.getPresentationName()));
    }//from   w w  w. j  av  a 2 s. co m

    final String projectFileDirectory = getProjectFileDirectory();
    if (projectFileDirectory.length() == 0) {
        throw new ConfigurationException(
                IdeBundle.message("prompt.enter.project.file.location", myWizardContext.getPresentationName()));
    }

    final boolean shouldPromptCreation = myNamePathComponent.isPathChangedByUser();
    if (!ProjectWizardUtil.createDirectoryIfNotExists(
            IdeBundle.message("directory.project.file.directory", myWizardContext.getPresentationName()),
            projectFileDirectory, shouldPromptCreation)) {
        return false;
    }

    boolean shouldContinue = true;

    final String path = getProjectFileDirectory() + "/" + Project.DIRECTORY_STORE_FOLDER;
    final File projectFile = new File(path);
    if (projectFile.exists()) {
        final String title = myWizardContext.isCreatingNewProject() ? IdeBundle.message("title.new.project")
                : IdeBundle.message("title.add.module");
        final String message = IdeBundle.message("prompt.overwrite.project.folder",
                Project.DIRECTORY_STORE_FOLDER, projectFile.getParentFile().getAbsolutePath());
        int answer = Messages.showYesNoDialog(message, title, Messages.getQuestionIcon());
        shouldContinue = answer == Messages.OK;
    }

    return shouldContinue;
}

From source file:com.intellij.ide.util.scopeChooser.EditScopesDialog.java

License:Apache License

@Override
protected void doOKAction() {
    final Object selectedObject = ((ScopeChooserConfigurable) getConfigurable()).getSelectedObject();
    if (selectedObject instanceof NamedScope) {
        mySelectedScope = (NamedScope) selectedObject;
    }//from   w  w  w.ja v  a 2  s  . c o  m
    super.doOKAction();
    if (myCheckShared && mySelectedScope != null) {
        final Project project = getProject();
        final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);
        NamedScope scope = manager.getScope(mySelectedScope.getName());
        if (scope == null) {
            if (Messages.showYesNoDialog(IdeBundle.message("scope.unable.to.save.scope.message"),
                    IdeBundle.message("scope.unable.to.save.scope.title"),
                    Messages.getErrorIcon()) == DialogWrapper.OK_EXIT_CODE) {
                final String newName = Messages.showInputDialog(project,
                        IdeBundle.message("add.scope.name.label"),
                        IdeBundle.message("scopes.save.dialog.title.shared"), Messages.getQuestionIcon(),
                        mySelectedScope.getName(), new InputValidator() {
                            @Override
                            public boolean checkInput(String inputString) {
                                return inputString != null && inputString.length() > 0
                                        && manager.getScope(inputString) == null;
                            }

                            @Override
                            public boolean canClose(String inputString) {
                                return checkInput(inputString);
                            }
                        });
                if (newName != null) {
                    final PackageSet packageSet = mySelectedScope.getValue();
                    scope = new NamedScope(newName, packageSet != null ? packageSet.createCopy() : null);
                    mySelectedScope = scope;
                    manager.addScope(mySelectedScope);
                }
            }
        }
    }
}

From source file:com.intellij.lang.javascript.uml.FlashUmlDataModel.java

License:Apache License

@Override
@Nullable//from   w w  w  . j a v  a2  s.  c om
public DiagramEdge<Object> createEdge(@NotNull final DiagramNode<Object> from,
        @NotNull final DiagramNode<Object> to) {
    final JSClass fromClass = (JSClass) from.getIdentifyingElement();
    final JSClass toClass = (JSClass) to.getIdentifyingElement();

    if (fromClass.isEquivalentTo(toClass)) {
        return null;
    }

    if (toClass.isInterface()) {
        if (JSPsiImplUtils.containsEquivalent(
                fromClass.isInterface() ? fromClass.getSuperClasses() : fromClass.getImplementedInterfaces(),
                toClass)) {
            return null;
        }

        Callable<DiagramEdge<Object>> callable = () -> {
            String targetQName = toClass.getQualifiedName();
            JSRefactoringUtil.addToSupersList(fromClass, targetQName, true);
            if (targetQName.contains(".") && !(fromClass instanceof XmlBackedJSClassImpl)) {
                List<FormatFixer> formatters = new ArrayList<>();
                formatters.add(
                        ImportUtils.insertImportStatements(fromClass, Collections.singletonList(targetQName)));
                formatters.addAll(ECMAScriptImportOptimizer.executeNoFormat(fromClass.getContainingFile()));
                FormatFixer.fixAll(formatters);
            }
            return addEdgeAndRefresh(from, to, fromClass.isInterface() ? FlashUmlRelationship.GENERALIZATION
                    : FlashUmlRelationship.INTERFACE_GENERALIZATION);
        };
        String commandName = FlexBundle.message(
                fromClass.isInterface() ? "create.extends.relationship.command.name"
                        : "create.implements.relationship.command.name",
                fromClass.getQualifiedName(), toClass.getQualifiedName());
        return DiagramAction.performCommand(getBuilder(), callable, commandName, null,
                fromClass.getContainingFile());
    } else {
        if (fromClass.isInterface()) {
            return null;
        } else if (fromClass instanceof XmlBackedJSClassImpl) {
            JSClass[] superClasses = fromClass.getSuperClasses();
            if (JSPsiImplUtils.containsEquivalent(superClasses, toClass)) {
                return null;
            }

            if (superClasses.length > 0) { // if base component is not resolved, replace it silently
                final JSClass currentParent = superClasses[0];
                if (Messages.showYesNoDialog(
                        FlexBundle.message("replace.base.component.prompt", currentParent.getQualifiedName(),
                                toClass.getQualifiedName()),
                        FlexBundle.message("create.edge.title"), Messages.getQuestionIcon()) == Messages.NO) {
                    return null;
                }
            }
            Callable<DiagramEdge<Object>> callable = () -> {
                NewFlexComponentAction.setParentComponent((MxmlJSClass) fromClass, toClass.getQualifiedName());
                return addEdgeAndRefresh(from, to, DiagramRelationships.GENERALIZATION);
            };
            String commandName = FlexBundle.message("create.extends.relationship.command.name",
                    fromClass.getQualifiedName(), toClass.getQualifiedName());
            return DiagramAction.performCommand(getBuilder(), callable, commandName, null,
                    fromClass.getContainingFile());
        } else {
            final JSClass[] superClasses = fromClass.getSuperClasses();
            if (JSPsiImplUtils.containsEquivalent(superClasses, toClass)) {
                return null;
            }

            if (superClasses.length > 0 && !JSResolveUtil.isObjectClass(superClasses[0])) { // if base class is not resolved, replace it silently
                final JSClass currentParent = superClasses[0];
                if (Messages.showYesNoDialog(
                        FlexBundle.message("replace.base.class.prompt", currentParent.getQualifiedName(),
                                toClass.getQualifiedName()),
                        FlexBundle.message("create.edge.title"), Messages.getQuestionIcon()) == Messages.NO) {
                    return null;
                }
            }
            Callable<DiagramEdge<Object>> callable = () -> {
                List<FormatFixer> formatters = new ArrayList<>();
                boolean optimize = false;
                if (superClasses.length > 0 && !JSResolveUtil.isObjectClass(superClasses[0])) {
                    JSRefactoringUtil.removeFromReferenceList(fromClass.getExtendsList(), superClasses[0],
                            formatters);
                    optimize = needsImport(fromClass, superClasses[0]);
                }
                JSRefactoringUtil.addToSupersList(fromClass, toClass.getQualifiedName(), false);
                if (needsImport(fromClass, toClass)) {
                    formatters.add(ImportUtils.insertImportStatements(fromClass,
                            Collections.singletonList(toClass.getQualifiedName())));
                    optimize = true;
                }
                if (optimize) {
                    formatters.addAll(ECMAScriptImportOptimizer.executeNoFormat(fromClass.getContainingFile()));
                }
                FormatFixer.fixAll(formatters);
                return addEdgeAndRefresh(from, to, DiagramRelationships.GENERALIZATION);
            };
            String commandName = FlexBundle.message("create.extends.relationship.command.name",
                    fromClass.getQualifiedName(), toClass.getQualifiedName());
            return DiagramAction.performCommand(getBuilder(), callable, commandName, null,
                    fromClass.getContainingFile());
        }
    }
}

From source file:com.liferay.ide.idea.ui.modules.LiferayModuleNameLocationComponent.java

License:Open Source License

private boolean _validateModulePaths() throws ConfigurationException {
    String moduleName = _getModuleName();
    String moduleFileDirectory = _moduleFileLocation.getText();

    if (moduleFileDirectory.length() == 0) {
        throw new ConfigurationException("Enter module file location");
    }/*from   www. j a  va2  s  . com*/

    if (moduleName.length() == 0) {
        throw new ConfigurationException("Enter a module name");
    }

    if (!ProjectWizardUtil.createDirectoryIfNotExists(IdeBundle.message("directory.module.file"),
            moduleFileDirectory, _imlLocationChangedByUser)) {

        return false;
    }

    if (!ProjectWizardUtil.createDirectoryIfNotExists(IdeBundle.message("directory.module.content.root"),
            _moduleContentRoot.getText(), _contentRootChangedByUser)) {

        return false;
    }

    File moduleFile = new File(moduleFileDirectory, moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION);

    if (moduleFile.exists()) {
        String identification = IdeBundle.message("project.new.wizard.module.identification");
        String existsTitle = IdeBundle.message("title.file.already.exists");
        String filePrompt = IdeBundle.message("prompt.overwrite.project.file", moduleFile.getAbsolutePath(),
                identification);

        int answer = Messages.showYesNoDialog(filePrompt, existsTitle, Messages.getQuestionIcon());

        if (answer != Messages.YES) {
            return false;
        }
    }

    return true;
}

From source file:com.liferay.ide.idea.ui.modules.LiferayNamePathComponent.java

License:Open Source License

public boolean validateNameAndPath(WizardContext context, boolean defaultFormat) throws ConfigurationException {
    String name = getNameValue();

    if (StringUtil.isEmptyOrSpaces(name)) {
        throw new ConfigurationException(IdeBundle.message("prompt.new.project.file.name",
                ApplicationInfo.getInstance().getVersionName(), context.getPresentationName()));
    }/*from   w w w .j  ava 2 s. c o  m*/

    String projectDirectory = getPath();

    if (StringUtil.isEmptyOrSpaces(projectDirectory)) {
        throw new ConfigurationException(
                IdeBundle.message("prompt.enter.project.file.location", context.getPresentationName()));
    }

    if (_shouldBeAbsolute && !new File(projectDirectory).isAbsolute()) {
        throw new ConfigurationException(StringUtil.capitalize(
                IdeBundle.message("file.location.should.be.absolute", context.getPresentationName())));
    }

    String message = IdeBundle.message("directory.project.file.directory", context.getPresentationName());

    if (!ProjectWizardUtil.createDirectoryIfNotExists(message, projectDirectory, isPathChangedByUser())) {
        return false;
    }

    File file = new File(projectDirectory);

    if (file.exists() && !file.canWrite()) {
        String msg = String.format(
                "Directory '%s' is not seem to be writable. Please consider another location.",
                projectDirectory);

        throw new ConfigurationException(msg);
    }

    for (Project project : ProjectManager.getInstance().getOpenProjects()) {
        if (ProjectUtil.isSameProject(projectDirectory, project)) {
            String msg = String.format(
                    "Directory '%s' is already taken by the project '%s'. Please consider another location.",
                    projectDirectory, project.getName());

            throw new ConfigurationException(msg);
        }
    }

    boolean shouldContinue = true;
    String fileName = defaultFormat ? name + ProjectFileType.DOT_DEFAULT_EXTENSION
            : Project.DIRECTORY_STORE_FOLDER;

    File projectFile = new File(file, fileName);

    if (projectFile.exists()) {
        message = IdeBundle.message("prompt.overwrite.project.file", projectFile.getAbsolutePath(),
                context.getPresentationName());

        int answer = Messages.showYesNoDialog(message, IdeBundle.message("title.file.already.exists"),
                Messages.getQuestionIcon());

        shouldContinue = answer == Messages.YES;
    }

    return shouldContinue;
}

From source file:com.maddyhome.idea.vim.VimPlugin.java

License:Open Source License

private void updateState() {
    if (isEnabled() && !ApplicationManager.getApplication().isUnitTestMode()) {
        if (SystemInfo.isMac) {
            final MacKeyRepeat keyRepeat = MacKeyRepeat.getInstance();
            final Boolean enabled = keyRepeat.isEnabled();
            final Boolean isKeyRepeat = editor.isKeyRepeat();
            if ((enabled == null || !enabled) && (isKeyRepeat == null || isKeyRepeat)) {
                if (Messages.showYesNoDialog(
                        "Do you want to enable repeating keys in Mac OS X on press and hold?\n\n"
                                + "(You can do it manually by running 'defaults write -g "
                                + "ApplePressAndHoldEnabled 0' in the console).",
                        IDEAVIM_NOTIFICATION_TITLE, Messages.getQuestionIcon()) == Messages.YES) {
                    editor.setKeyRepeat(true);
                    keyRepeat.setEnabled(true);
                } else {
                    editor.setKeyRepeat(false);
                }//from   w w  w  .j  ava 2 s  .c om
            }
        }
        if (previousStateVersion > 0 && previousStateVersion < 3) {
            final KeymapManagerEx manager = KeymapManagerEx.getInstanceEx();
            Keymap keymap = null;
            if (previousKeyMap != null) {
                keymap = manager.getKeymap(previousKeyMap);
            }
            if (keymap == null) {
                keymap = manager.getKeymap(DefaultKeymap.getInstance().getDefaultKeymapName());
            }
            assert keymap != null : "Default keymap not found";
            new Notification(VimPlugin.IDEAVIM_STICKY_NOTIFICATION_ID, VimPlugin.IDEAVIM_NOTIFICATION_TITLE,
                    String.format("IdeaVim plugin doesn't use the special \"Vim\" keymap any longer. "
                            + "Switching to \"%s\" keymap.<br/><br/>" + "Now it is possible to set up:<br/>"
                            + "<ul>" + "<li>Vim keys in your ~/.ideavimrc file using key mapping commands</li>"
                            + "<li>IDE action shortcuts in \"File | Settings | Keymap\"</li>"
                            + "<li>Vim or IDE handlers for conflicting shortcuts in <a href='#settings'>Vim Emulation</a> settings</li>"
                            + "</ul>", keymap.getPresentableName()),
                    NotificationType.INFORMATION, new NotificationListener.Adapter() {
                        @Override
                        protected void hyperlinkActivated(@NotNull Notification notification,
                                @NotNull HyperlinkEvent e) {
                            ShowSettingsUtil.getInstance().editConfigurable((Project) null,
                                    new VimEmulationConfigurable());
                        }
                    }).notify(null);
            manager.setActiveKeymap(keymap);
        }
        if (previousStateVersion > 0 && previousStateVersion < 4) {
            new Notification(VimPlugin.IDEAVIM_STICKY_NOTIFICATION_ID, VimPlugin.IDEAVIM_NOTIFICATION_TITLE,
                    "The ~/.vimrc file is no longer read by default, use ~/.ideavimrc instead. You can read it from your "
                            + "~/.ideavimrc using this command:<br/><br/>" + "<code>source ~/.vimrc</code>",
                    NotificationType.INFORMATION).notify(null);
        }
    }
}

From source file:com.mbeddr.pluginmanager.com.intellij.ide.plugins.InstallPluginAction.java

License:Apache License

private static boolean suggestToEnableInstalledPlugins(InstalledPluginsTableModel pluginsModel,
        Set<IdeaPluginDescriptor> disabled, Set<IdeaPluginDescriptor> disabledDependants,
        List<PluginNode> list) {
    if (!disabled.isEmpty() || !disabledDependants.isEmpty()) {
        String message = "";
        if (disabled.size() == 1) {
            message += "Updated plugin '" + disabled.iterator().next().getName() + "' is disabled.";
        } else if (!disabled.isEmpty()) {
            message += "Updated plugins "
                    + StringUtil.join(disabled, new Function<IdeaPluginDescriptor, String>() {
                        @Override
                        public String fun(IdeaPluginDescriptor pluginDescriptor) {
                            return pluginDescriptor.getName();
                        }/* ww w  . j av a 2  s.  c o  m*/
                    }, ", ") + " are disabled.";
        }

        if (!disabledDependants.isEmpty()) {
            message += "<br>";
            message += "Updated plugin" + (list.size() > 1 ? "s depend " : " depends ") + "on disabled";
            if (disabledDependants.size() == 1) {
                message += " plugin '" + disabledDependants.iterator().next().getName() + "'.";
            } else {
                message += " plugins "
                        + StringUtil.join(disabledDependants, new Function<IdeaPluginDescriptor, String>() {
                            @Override
                            public String fun(IdeaPluginDescriptor pluginDescriptor) {
                                return pluginDescriptor.getName();
                            }
                        }, ", ") + ".";
            }
        }
        message += " Disabled plugins " + (disabled.isEmpty() ? "and plugins which depend on disabled " : "")
                + "won't be activated after restart.";

        int result;
        if (!disabled.isEmpty() && !disabledDependants.isEmpty()) {
            result = Messages.showYesNoCancelDialog(XmlStringUtil.wrapInHtml(message),
                    CommonBundle.getWarningTitle(), "Enable all",
                    "Enable updated plugin" + (disabled.size() > 1 ? "s" : ""),
                    CommonBundle.getCancelButtonText(), Messages.getQuestionIcon());
            if (result == Messages.CANCEL)
                return false;
        } else {
            message += "<br>Would you like to enable ";
            if (!disabled.isEmpty()) {
                message += "updated plugin" + (disabled.size() > 1 ? "s" : "");
            } else {
                //noinspection SpellCheckingInspection
                message += "plugin dependenc" + (disabledDependants.size() > 1 ? "ies" : "y");
            }
            message += "?";
            result = Messages.showYesNoDialog(XmlStringUtil.wrapInHtml(message), CommonBundle.getWarningTitle(),
                    Messages.getQuestionIcon());
            if (result == Messages.NO)
                return false;
        }

        if (result == Messages.YES) {
            disabled.addAll(disabledDependants);
            pluginsModel.enableRows(disabled.toArray(new IdeaPluginDescriptor[disabled.size()]), true);
        } else if (result == Messages.NO && !disabled.isEmpty()) {
            pluginsModel.enableRows(disabled.toArray(new IdeaPluginDescriptor[disabled.size()]), true);
        }
        return true;
    }
    return false;
}

From source file:com.mbeddr.pluginmanager.com.intellij.ide.plugins.PluginInstaller.java

License:Apache License

private static boolean prepareToInstall(PluginNode pluginNode, List<PluginId> pluginIds,
        List<IdeaPluginDescriptor> allPlugins, Set<PluginNode> installedDependant,
        @NotNull ProgressIndicator indicator) throws IOException {
    installedDependant.add(pluginNode);/*from   w w  w  .j  a v  a  2  s  .  c o  m*/

    // check for dependent plugins at first.
    if (pluginNode.getDepends() != null && pluginNode.getDepends().size() > 0) {
        // prepare plugins list for install
        final PluginId[] optionalDependentPluginIds = pluginNode.getOptionalDependentPluginIds();
        final List<PluginNode> depends = new ArrayList<PluginNode>();
        final List<PluginNode> optionalDeps = new ArrayList<PluginNode>();
        for (int i = 0; i < pluginNode.getDepends().size(); i++) {
            PluginId depPluginId = pluginNode.getDepends().get(i);
            if (PluginManager.isPluginInstalled(depPluginId) || ReflectionUtil.isModuleDependency(depPluginId)
                    || InstalledPluginsState.getInstance().wasInstalled(depPluginId)
                    || (pluginIds != null && pluginIds.contains(depPluginId))) {
                // ignore installed or installing plugins
                continue;
            }

            IdeaPluginDescriptor depPluginDescriptor = findPluginInRepo(depPluginId, allPlugins);
            PluginNode depPluginNode;
            if (depPluginDescriptor instanceof PluginNode) {
                depPluginNode = (PluginNode) depPluginDescriptor;
            } else {
                depPluginNode = new PluginNode(depPluginId);
                depPluginNode.setSize("-1");
                depPluginNode.setName(depPluginId.getIdString()); //prevent from exceptions
            }

            if (depPluginDescriptor != null) {
                if (ArrayUtil.indexOf(optionalDependentPluginIds, depPluginId) != -1) {
                    optionalDeps.add(depPluginNode);
                } else {
                    depends.add(depPluginNode);
                }
            }
        }

        if (depends.size() > 0) { // has something to install prior installing the plugin
            final boolean[] proceed = new boolean[1];
            try {
                GuiUtils.runOrInvokeAndWait(new Runnable() {
                    @Override
                    public void run() {
                        String title = IdeBundle.message("plugin.manager.dependencies.detected.title");
                        String deps = StringUtil.join(depends, new Function<PluginNode, String>() {
                            @Override
                            public String fun(PluginNode node) {
                                return node.getName();
                            }
                        }, ", ");
                        String message = IdeBundle.message("plugin.manager.dependencies.detected.message",
                                depends.size(), deps);
                        proceed[0] = Messages.showYesNoDialog(message, title,
                                Messages.getWarningIcon()) == Messages.YES;
                    }
                });
            } catch (Exception e) {
                return false;
            }
            if (!proceed[0] || !prepareToInstall(depends, allPlugins, installedDependant, indicator)) {
                return false;
            }
        }

        if (optionalDeps.size() > 0) {
            final boolean[] proceed = new boolean[1];
            try {
                GuiUtils.runOrInvokeAndWait(new Runnable() {
                    @Override
                    public void run() {
                        String title = IdeBundle.message("plugin.manager.dependencies.detected.title");
                        String deps = StringUtil.join(optionalDeps, new Function<PluginNode, String>() {
                            @Override
                            public String fun(PluginNode node) {
                                return node.getName();
                            }
                        }, ", ");
                        String message = IdeBundle.message(
                                "plugin.manager.optional.dependencies.detected.message", optionalDeps.size(),
                                deps);
                        proceed[0] = Messages.showYesNoDialog(message, title,
                                Messages.getWarningIcon()) == Messages.YES;
                    }
                });
            } catch (Exception e) {
                return false;
            }
            if (proceed[0] && !prepareToInstall(optionalDeps, allPlugins, installedDependant, indicator)) {
                return false;
            }
        }
    }

    PluginDownloader downloader = PluginDownloader.createDownloader(pluginNode, pluginNode.getRepositoryName(),
            null);

    if (downloader.prepareToInstall(indicator)) {
        synchronized (ourLock) {
            downloader.install();
        }
        pluginNode.setStatus(PluginNode.STATUS_DOWNLOADED);
    } else {
        return false;
    }

    return true;
}