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

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

Introduction

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

Prototype

@NotNull
    public static Icon getWarningIcon() 

Source Link

Usage

From source file:com.intellij.ide.passwordSafe.ui.PasswordPromptComponent.java

License:Apache License

public PasswordPromptComponent(PasswordSafeSettings.ProviderType type, String message, boolean showUserName,
        String passwordPrompt, String rememberPrompt) {
    myIconLabel.setText("");
    myIconLabel.setIcon(Messages.getWarningIcon());
    myMessageLabel.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
    myMessageLabel.setText(message);//from  ww w.  j  a va 2  s  .  com
    setTargetProviderType(type);
    setUserInputVisible(showUserName);
    if (passwordPrompt != null)
        myPasswordLabel.setText(passwordPrompt);
    if (rememberPrompt != null) {
        myRememberCheckBox.setText(rememberPrompt);
        DialogUtil.registerMnemonic(myRememberCheckBox);
    }
}

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

License:Apache License

private void checkInstalledPluginDependencies(IdeaPluginDescriptorImpl pluginDescriptor) {
    final Set<PluginId> notInstalled = new HashSet<PluginId>();
    final Set<PluginId> disabledIds = new HashSet<PluginId>();
    final PluginId[] dependentPluginIds = pluginDescriptor.getDependentPluginIds();
    final PluginId[] optionalDependentPluginIds = pluginDescriptor.getOptionalDependentPluginIds();
    for (PluginId id : dependentPluginIds) {
        if (ArrayUtilRt.find(optionalDependentPluginIds, id) > -1)
            continue;
        final boolean disabled = ((InstalledPluginsTableModel) pluginsModel).isDisabled(id);
        final boolean enabled = ((InstalledPluginsTableModel) pluginsModel).isEnabled(id);
        if (!enabled && !disabled) {
            notInstalled.add(id);/*from  w  w w  .  j av  a2 s.  com*/
        } else if (disabled) {
            disabledIds.add(id);
        }
    }
    if (!notInstalled.isEmpty()) {
        Messages.showWarningDialog("Plugin " + pluginDescriptor.getName() + " depends on unknown plugin"
                + (notInstalled.size() > 1 ? "s " : " ")
                + StringUtil.join(notInstalled, new Function<PluginId, String>() {
                    @Override
                    public String fun(PluginId id) {
                        return id.toString();
                    }
                }, ", "), CommonBundle.getWarningTitle());
    }
    if (!disabledIds.isEmpty()) {
        final Set<IdeaPluginDescriptor> dependencies = new HashSet<IdeaPluginDescriptor>();
        for (IdeaPluginDescriptor ideaPluginDescriptor : pluginsModel.getAllPlugins()) {
            if (disabledIds.contains(ideaPluginDescriptor.getPluginId())) {
                dependencies.add(ideaPluginDescriptor);
            }
        }
        final String disabledPluginsMessage = "disabled plugin" + (dependencies.size() > 1 ? "s " : " ");
        String message = "Plugin " + pluginDescriptor.getName() + " depends on " + disabledPluginsMessage
                + StringUtil.join(dependencies, new Function<IdeaPluginDescriptor, String>() {
                    @Override
                    public String fun(IdeaPluginDescriptor ideaPluginDescriptor) {
                        return ideaPluginDescriptor.getName();
                    }
                }, ", ") + ". Enable " + disabledPluginsMessage.trim() + "?";
        if (Messages.showOkCancelDialog(myActionsPanel, message, CommonBundle.getWarningTitle(),
                Messages.getWarningIcon()) == Messages.OK) {
            ((InstalledPluginsTableModel) pluginsModel).enableRows(
                    dependencies.toArray(new IdeaPluginDescriptor[dependencies.size()]), Boolean.TRUE);
        }
    }
}

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/*from ww w  .ja  va2 s .  c  o  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.ui.laf.LafManagerImpl.java

License:Apache License

private boolean checkLookAndFeel(final UIManager.LookAndFeelInfo lafInfo, final boolean confirm) {
    String message = null;// ww  w  .jav  a 2s. co  m

    if (lafInfo.getName().contains("GTK") && SystemInfo.isXWindow
            && !SystemInfo.isJavaVersionAtLeast("1.6.0_12")) {
        message = IdeBundle.message("warning.problem.laf.1");
    }

    if (message != null) {
        if (confirm) {
            final String[] options = { IdeBundle.message("confirm.set.look.and.feel"),
                    CommonBundle.getCancelButtonText() };
            final int result = Messages.showOkCancelDialog(message, CommonBundle.getWarningTitle(), options[0],
                    options[1], Messages.getWarningIcon());
            if (result == 0) {
                myLastWarning = message;
                return true;
            }
            return false;
        }

        if (!message.equals(myLastWarning)) {
            Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "L&F Manager",
                    message, NotificationType.WARNING, NotificationListener.URL_OPENING_LISTENER));
            myLastWarning = message;
        }
    }

    return true;
}

From source file:com.intellij.ide.util.ExportToFileUtil.java

License:Apache License

public static void exportTextToFile(Project project, String fileName, String textToExport) {
    String prepend = "";
    File file = new File(fileName);
    if (file.exists()) {
        int result = Messages.showYesNoCancelDialog(project,
                IdeBundle.message("error.text.file.already.exists", fileName),
                IdeBundle.message("title.warning"), IdeBundle.message("action.overwrite"),
                IdeBundle.message("action.append"), CommonBundle.getCancelButtonText(),
                Messages.getWarningIcon());

        if (result != 1 && result != 0) {
            return;
        }//  w  w  w  . j  a  v a  2 s . co  m
        if (result == 1) {
            char[] buf = new char[(int) file.length()];
            try {
                FileReader reader = new FileReader(fileName);
                try {
                    reader.read(buf, 0, (int) file.length());
                    prepend = new String(buf) + SystemProperties.getLineSeparator();
                } finally {
                    reader.close();
                }
            } catch (IOException e) {
            }
        }
    }

    try {
        FileWriter writer = new FileWriter(fileName);
        try {
            writer.write(prepend + textToExport);
        } finally {
            writer.close();
        }
    } catch (IOException e) {
        Messages.showMessageDialog(project, IdeBundle.message("error.writing.to.file", fileName),
                CommonBundle.getErrorTitle(), Messages.getErrorIcon());
    }
}

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

License:Apache License

public boolean validate() throws ConfigurationException {
    if (isProgressRunning()) {
        final int answer = Messages.showOkCancelDialog(getComponent(), myPromptStopSearch,
                IdeBundle.message("title.question"), IdeBundle.message("action.continue.searching"),
                IdeBundle.message("action.stop.searching"), Messages.getWarningIcon());
        if (answer == 1) { // terminate
            cancelSearch();/*  w w  w . java  2  s  . c  o m*/
        }
        return false;
    }
    return true;
}

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

License:Apache License

public boolean validate() throws ConfigurationException {
    final Sdk jdk = myProjectSdksConfigurable.getSelectedJdk();
    if (jdk == null && !ApplicationManager.getApplication().isUnitTestMode()) {
        int result = Messages.showOkCancelDialog(IdeBundle.message("prompt.confirm.project.no.jdk"),
                IdeBundle.message("title.no.jdk.specified"), Messages.getWarningIcon());
        if (result != 0) {
            return false;
        }/*from ww w  . j  a v  a2s.c o m*/
    }
    myProjectSdksConfigurable.apply();
    return true;
}

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

License:Apache License

@Override
public boolean validate() throws ConfigurationException {
    if (mySdkComboBox.getSelectedSdk() == null) {
        if (Messages.showDialog(getNoSdkMessage(), IdeBundle.message("title.no.jdk.specified"),
                new String[] { CommonBundle.getYesButtonText(), CommonBundle.getNoButtonText() }, 1,
                Messages.getWarningIcon()) != Messages.YES) {
            return false;
        }/*from  w ww  .jav  a2  s.c  o m*/
    }
    try {
        myModel.apply(null, true);
    } catch (ConfigurationException e) {
        //IDEA-98382 We should allow Next step if user has wrong SDK
        if (Messages.showDialog(e.getMessage() + "/nDo you want to proceed?", e.getTitle(),
                new String[] { CommonBundle.getYesButtonText(), CommonBundle.getNoButtonText() }, 1,
                Messages.getWarningIcon()) != Messages.YES) {
            return false;
        }
    }
    return true;
}

From source file:com.intellij.ide.util.SuperMethodWarningDialog.java

License:Apache License

public JComponent createNorthPanel() {
    JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
    Icon icon = Messages.getWarningIcon();
    if (icon != null) {
        JLabel iconLabel = new JLabel(Messages.getQuestionIcon());
        panel.add(iconLabel, BorderLayout.WEST);
    }/*from   w ww.  j a v  a  2 s .c om*/
    JPanel labelsPanel = new JPanel(new GridLayout(0, 1, 0, 0));
    labelsPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 10));
    String classType = myIsParentInterface ? IdeBundle.message("element.of.interface")
            : IdeBundle.message("element.of.class");
    String methodString = IdeBundle.message("element.method");
    labelsPanel.add(new JLabel(IdeBundle.message("label.method", myName)));
    if (myClassNames.length == 1) {
        final String className = myClassNames[0];
        labelsPanel.add(new JLabel(myIsContainedInInterface || !myIsSuperAbstract
                ? IdeBundle.message("label.overrides.method.of_class_or_interface.name", methodString,
                        classType, className)
                : IdeBundle.message("label.implements.method.of_class_or_interface.name", methodString,
                        classType, className)));
    } else {
        labelsPanel.add(new JLabel(IdeBundle.message("label.implements.method.of_interfaces")));
        for (final String className : myClassNames) {
            labelsPanel.add(new JLabel("    " + className));
        }
    }
    labelsPanel.add(new JLabel(IdeBundle.message("prompt.do.you.want.to.action_verb.the.method.from_class",
            myActionString, myClassNames.length > 1 ? 2 : 1)));
    panel.add(labelsPanel, BorderLayout.CENTER);
    return panel;
}

From source file:com.intellij.plugins.haxe.ide.hierarchy.HaxeHierarchyTimeoutHandler.java

License:Apache License

/**
 * Post a modal dialog on screen to alert the user that the search was cancelled and
 * the results may not be complete./*from   w w  w  .  java 2s. c  om*/
 *
 * Warns if the process was not cancelled.
 */
public void postCanceledDialog(Project project) {
    if (!canceled) {
        LOG.warn("Displaying cancel message dialog when the process was not canceled.");
    }

    final Project messageProject = project;
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            // TODO: Put this message and title in a resource bundle.
            String title = "Call Hierarchy Search Timed Out";
            String msg = "Search took too long (>" + max_duration_seconds
                    + "seconds).  Results may be incomplete.";
            if (DEBUG) {
                msg += " Canceled after " + (stopTime - startTime) + " milliseconds.";
            }
            Messages.showMessageDialog(messageProject, msg, title, Messages.getWarningIcon());
        }
    });
}