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: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);
                }// w  w w. j av  a2s.  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();
                        }//from ww w . j a va2 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.InstallPluginAction.java

License:Apache License

private boolean userConfirm(IdeaPluginDescriptor[] selection) {
    String message;//from  ww  w.  j a  v  a2 s. co m
    if (selection.length == 1) {
        if (selection[0] instanceof IdeaPluginDescriptorImpl) {
            message = IdeBundle.message("prompt.update.plugin", selection[0].getName());
        } else {
            message = IdeBundle.message("prompt.download.and.install.plugin", selection[0].getName());
        }
    } else {
        message = IdeBundle.message("prompt.install.several.plugins", selection.length);
    }

    return Messages.showYesNoDialog(myHost.getMainPanel(), message,
            IdeBundle.message("action.download.and.install.plugin"),
            Messages.getQuestionIcon()) == Messages.YES;
}

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. ja 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;
}

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

License:Apache License

@Override
public void apply() throws ConfigurationException {
    final String applyMessage = myPluginManagerMain.apply();
    if (applyMessage != null) {
        throw new ConfigurationException(applyMessage);
    }/*from  w ww  .  jav a 2 s  .c o m*/

    if (myPluginManagerMain.isRequireShutdown()) {
        if (showRestartDialog() == Messages.YES) {
            ApplicationManagerEx.getApplicationEx().restart(true);
        } else {
            myPluginManagerMain.ignoreChanges();
        }
    }
}

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

License:Apache License

public static void shutdownOrRestartApp(@NotNull String title) {
    if (showRestartDialog(title) == Messages.YES) {
        ApplicationManagerEx.getApplicationEx().restart(true);
    }//from   w w w  .j av  a2 s . c  o m
}

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

License:Apache License

public static void uninstall(PluginManagerMain host, boolean confirmed, IdeaPluginDescriptor... selection) {
    String message;//from  w ww  .  j  a  va2 s . co  m

    if (selection.length == 1) {
        message = IdeBundle.message("prompt.uninstall.plugin", selection[0].getName());
    } else {
        message = IdeBundle.message("prompt.uninstall.several.plugins", selection.length);
    }

    if (!confirmed && Messages.showYesNoDialog(host.getMainPanel(), message,
            IdeBundle.message("title.plugin.uninstall"), Messages.getQuestionIcon()) != Messages.YES)
        return;

    for (IdeaPluginDescriptor descriptor : selection) {
        IdeaPluginDescriptorImpl pluginDescriptor = (IdeaPluginDescriptorImpl) descriptor;

        boolean actualDelete = true;

        //  Get the list of plugins which depend on this one. If this list is
        //  not empty - issue warning instead of simple prompt.
        List<IdeaPluginDescriptorImpl> dependant = host.getDependentList(pluginDescriptor);
        if (dependant.size() > 0) {
            message = IdeBundle.message("several.plugins.depend.on.0.continue.to.remove",
                    pluginDescriptor.getName());
            actualDelete = (Messages.showYesNoDialog(host.getMainPanel(), message,
                    IdeBundle.message("title.plugin.uninstall"), Messages.getQuestionIcon()) == Messages.YES);
        }

        if (actualDelete) {
            uninstallPlugin(pluginDescriptor, host);
        }
    }
}

From source file:com.microsoft.azure.hdinsight.projects.ui.HDInsightProjectTypeStep.java

License:Open Source License

private void showRestartMsg() {
    if (PluginManagerConfigurable.showRestartDialog() == Messages.YES) {
        ApplicationManagerEx.getApplicationEx().restart(true);
    }
}

From source file:com.microsoft.intellij.AzurePlugin.java

License:Open Source License

private void setValues(final String dataFile) throws Exception {
    final Document doc = ParseXMLUtilMethods.parseFile(dataFile);
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override/*from w ww.  j a  v  a2s . c  o m*/
        public void run() {
            boolean accepted = Messages.showYesNoDialog(message("preferenceQueMsg"),
                    message("preferenceQueTtl"), null) == Messages.YES;
            DataOperations.updatePropertyValue(doc, message("prefVal"), String.valueOf(accepted));

            DataOperations.updatePropertyValue(doc, message("pluginVersion"), PLUGIN_VERSION);
            DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
            DataOperations.updatePropertyValue(doc, message("instID"), dateFormat.format(new Date()));
            try {
                ParseXMLUtilMethods.saveXMLDocument(dataFile, doc);
            } catch (Exception ex) {
                LOG.error(message("error"), ex);
            }
            if (accepted) {
                AppInsightsCustomEvent.create(message("telAgrEvtName"), "");
            }
        }
    }, ModalityState.defaultModalityState());
}

From source file:com.microsoft.intellij.ui.ApplicationsTab.java

License:Open Source License

private ActionListener createRemoveButtonListener() {
    return new ActionListener() {
        @Override//from  w  w w .  j  a v a  2 s. c o m
        public void actionPerformed(ActionEvent e) {
            int curSelIndex = appTable.getSelectedRow();
            if (curSelIndex > -1) {
                if (!newRole) {
                    try {
                        int choice = Messages.showYesNoDialog(message("appRmvMsg"), message("appRmvTtl"),
                                Messages.getQuestionIcon());
                        if (choice == Messages.YES) {
                            String cmpntName = appList.get(curSelIndex).getImpAs();
                            String cmpntPath = String.format("%s%s%s%s%s",
                                    PluginUtil.getModulePath(ModuleManager.getInstance(project)
                                            .findModuleByName(waProjManager.getProjectName())),
                                    File.separator, waRole.getName(), message("approot"), cmpntName);
                            waRole.removeServerApplication(cmpntName);
                            modified = true;
                            if (!fileToDel.contains(cmpntPath)) {
                                fileToDel.add(cmpntPath);
                            }
                            //                                JdkSrvConfig.getTableViewer().refresh();
                            //                                JdkSrvConfigListener.disableRemoveButton();
                        } else {
                            return;
                        }
                    } catch (Exception ex) {
                        PluginUtil.displayErrorDialogAndLog(message("srvErrTtl"), message("rmvSrvAppErrMsg"),
                                ex);
                        return;
                    }
                }
                appList.remove(curSelIndex);
                ((ApplicationsTableModel) appTable.getModel()).fireTableDataChanged();

            }
        }
    };
}