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.util.net.HTTPProxySettingsPanel.java

License:Apache License

public HTTPProxySettingsPanel(final HttpConfigurable httpConfigurable) {
    final ButtonGroup group = new ButtonGroup();
    group.add(myUseHTTPProxyRb);/*  w w  w.  ja v a 2 s.c  o m*/
    group.add(myAutoDetectProxyRb);
    group.add(myNoProxyRb);
    myNoProxyRb.setSelected(true);

    final ButtonGroup proxyTypeGroup = new ButtonGroup();
    proxyTypeGroup.add(myHTTP);
    proxyTypeGroup.add(mySocks);
    myHTTP.setSelected(true);

    myProxyExceptions.setBorder(UIUtil.getTextFieldBorder());

    final Boolean property = Boolean.getBoolean(JavaProxyProperty.USE_SYSTEM_PROXY);
    mySystemProxyDefined.setVisible(Boolean.TRUE.equals(property));
    if (Boolean.TRUE.equals(property)) {
        mySystemProxyDefined.setIcon(Messages.getWarningIcon());
        mySystemProxyDefined.setFont(mySystemProxyDefined.getFont().deriveFont(Font.BOLD));
        mySystemProxyDefined.setUI(new MultiLineLabelUI());
    }

    myProxyAuthCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            enableProxyAuthentication(myProxyAuthCheckBox.isSelected());
        }
    });

    final ActionListener listener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            enableProxy(myUseHTTPProxyRb.isSelected());
        }
    };
    myUseHTTPProxyRb.addActionListener(listener);
    myAutoDetectProxyRb.addActionListener(listener);
    myNoProxyRb.addActionListener(listener);
    myHttpConfigurable = httpConfigurable;

    myClearPasswordsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            myHttpConfigurable.clearGenericPasswords();
            Messages.showMessageDialog(myMainPanel, "Proxy passwords were cleared.", "Auto-detected proxy",
                    Messages.getInformationIcon());
        }
    });

    if (HttpConfigurable.getInstance() != null) {
        myCheckButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                final String title = "Check Proxy Settings";
                final String answer = Messages.showInputDialog(myMainPanel,
                        "Warning: your settings will be saved.\n\nEnter any URL to check connection to:", title,
                        Messages.getQuestionIcon(), "http://", null);
                if (!StringUtil.isEmptyOrSpaces(answer)) {
                    apply();
                    final HttpConfigurable instance = HttpConfigurable.getInstance();
                    final AtomicReference<IOException> exc = new AtomicReference<IOException>();
                    myCheckButton.setEnabled(false);
                    myCheckButton.setText("Check connection (in progress...)");
                    myConnectionCheckInProgress = true;
                    final Application application = ApplicationManager.getApplication();
                    application.executeOnPooledThread(new Runnable() {
                        @Override
                        public void run() {
                            HttpURLConnection connection = null;
                            try {
                                //already checked for null above
                                //noinspection ConstantConditions
                                connection = instance.openHttpConnection(answer);
                                connection.setReadTimeout(3 * 1000);
                                connection.setConnectTimeout(3 * 1000);
                                connection.connect();
                                final int code = connection.getResponseCode();
                                if (HttpURLConnection.HTTP_OK != code) {
                                    exc.set(new IOException("Error code: " + code));
                                }
                            } catch (IOException e1) {
                                exc.set(e1);
                            } finally {
                                if (connection != null) {
                                    connection.disconnect();
                                }
                            }
                            //noinspection SSBasedInspection
                            SwingUtilities.invokeLater(new Runnable() {
                                @Override
                                public void run() {
                                    myConnectionCheckInProgress = false;
                                    reset(); // since password might have been set
                                    Component parent = null;
                                    if (myMainPanel.isShowing()) {
                                        parent = myMainPanel;
                                        myCheckButton.setText("Check connection");
                                        myCheckButton.setEnabled(canEnableConnectionCheck());
                                    } else {
                                        final IdeFrame frame = IdeFocusManager.findInstance()
                                                .getLastFocusedFrame();
                                        if (frame == null) {
                                            return;
                                        }
                                        parent = frame.getComponent();
                                    }
                                    //noinspection ThrowableResultOfMethodCallIgnored
                                    final IOException exception = exc.get();
                                    if (exception == null) {
                                        Messages.showMessageDialog(parent, "Connection successful", title,
                                                Messages.getInformationIcon());
                                    } else {
                                        final String message = exception.getMessage();
                                        if (instance.USE_HTTP_PROXY) {
                                            instance.LAST_ERROR = message;
                                        }
                                        Messages.showErrorDialog(parent, errorText(message));
                                    }
                                }
                            });
                        }
                    });
                }
            }
        });
    } else {
        myCheckButton.setVisible(false);
    }
}

From source file:com.intellij.util.net.HTTPProxySettingsPanel.java

License:Apache License

public void reset() {
    myNoProxyRb.setSelected(true); // default
    HttpConfigurable httpConfigurable = myHttpConfigurable;
    myAutoDetectProxyRb.setSelected(httpConfigurable.USE_PROXY_PAC);
    myUseHTTPProxyRb.setSelected(httpConfigurable.USE_HTTP_PROXY);
    myProxyAuthCheckBox.setSelected(httpConfigurable.PROXY_AUTHENTICATION);

    enableProxy(httpConfigurable.USE_HTTP_PROXY);

    myProxyLoginTextField.setText(httpConfigurable.PROXY_LOGIN);
    myProxyPasswordTextField.setText(httpConfigurable.getPlainProxyPassword());

    myProxyPortTextField.setText(Integer.toString(httpConfigurable.PROXY_PORT));
    myProxyHostTextField.setText(httpConfigurable.PROXY_HOST);
    myProxyExceptions.setText(httpConfigurable.PROXY_EXCEPTIONS);

    myRememberProxyPasswordCheckBox.setSelected(httpConfigurable.KEEP_PROXY_PASSWORD);
    mySocks.setSelected(httpConfigurable.PROXY_TYPE_IS_SOCKS);
    myHTTP.setSelected(!httpConfigurable.PROXY_TYPE_IS_SOCKS);

    final boolean showError = !StringUtil.isEmptyOrSpaces(httpConfigurable.LAST_ERROR);
    myErrorLabel.setVisible(showError);/*from  ww  w.  j  a v a2 s .co  m*/
    myErrorLabel.setText(showError ? errorText(httpConfigurable.LAST_ERROR) : "");

    final String oldStyleText = CommonProxy.getMessageFromProps(CommonProxy.getOldStyleProperties());
    myOtherWarning.setVisible(oldStyleText != null);
    if (oldStyleText != null) {
        myOtherWarning.setText(oldStyleText);
        myOtherWarning.setUI(new MultiLineLabelUI());
        myOtherWarning.setIcon(Messages.getWarningIcon());
    }
}

From source file:com.intellij.util.net.HttpProxySettingsUi.java

License:Apache License

public HttpProxySettingsUi(@NotNull final HttpConfigurable settings) {
    ButtonGroup group = new ButtonGroup();
    group.add(myUseHTTPProxyRb);//from  w w  w.  j av a  2 s .c  o m
    group.add(myAutoDetectProxyRb);
    group.add(myNoProxyRb);
    myNoProxyRb.setSelected(true);

    ButtonGroup proxyTypeGroup = new ButtonGroup();
    proxyTypeGroup.add(myHTTP);
    proxyTypeGroup.add(mySocks);
    myHTTP.setSelected(true);

    Boolean property = Boolean.getBoolean(JavaProxyProperty.USE_SYSTEM_PROXY);
    mySystemProxyDefined.setVisible(Boolean.TRUE.equals(property));
    if (Boolean.TRUE.equals(property)) {
        mySystemProxyDefined.setIcon(Messages.getWarningIcon());
        RelativeFont.BOLD.install(mySystemProxyDefined);
    }

    myProxyAuthCheckBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(@NotNull ActionEvent e) {
            enableProxyAuthentication(myProxyAuthCheckBox.isSelected());
        }
    });
    myPacUrlCheckBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(@NotNull ActionEvent e) {
            myPacUrlTextField.setEnabled(myPacUrlCheckBox.isSelected());
        }
    });

    ActionListener listener = new ActionListener() {
        @Override
        public void actionPerformed(@NotNull ActionEvent e) {
            enableProxy(myUseHTTPProxyRb.isSelected());
        }
    };
    myUseHTTPProxyRb.addActionListener(listener);
    myAutoDetectProxyRb.addActionListener(listener);
    myNoProxyRb.addActionListener(listener);

    myClearPasswordsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(@NotNull ActionEvent e) {
            settings.clearGenericPasswords();
            //noinspection DialogTitleCapitalization
            Messages.showMessageDialog(myMainPanel, "Proxy passwords were cleared.", "Auto-detected Proxy",
                    Messages.getInformationIcon());
        }
    });

    configureCheckButton();
}

From source file:com.intellij.util.net.HttpProxySettingsUi.java

License:Apache License

@Override
public void reset(@NotNull HttpConfigurable settings) {
    myNoProxyRb.setSelected(true); // default
    myAutoDetectProxyRb.setSelected(settings.USE_PROXY_PAC);
    myPacUrlCheckBox.setSelected(settings.USE_PAC_URL);
    myPacUrlTextField.setText(settings.PAC_URL);
    myUseHTTPProxyRb.setSelected(settings.USE_HTTP_PROXY);
    myProxyAuthCheckBox.setSelected(settings.PROXY_AUTHENTICATION);

    enableProxy(settings.USE_HTTP_PROXY);

    myProxyLoginTextField.setText(settings.PROXY_LOGIN);
    myProxyPasswordTextField.setText(settings.getPlainProxyPassword());

    myProxyPortTextField.setNumber(settings.PROXY_PORT);
    myProxyHostTextField.setText(settings.PROXY_HOST);
    myProxyExceptions.setText(StringUtil.notNullize(settings.PROXY_EXCEPTIONS));

    myRememberProxyPasswordCheckBox.setSelected(settings.KEEP_PROXY_PASSWORD);
    mySocks.setSelected(settings.PROXY_TYPE_IS_SOCKS);
    myHTTP.setSelected(!settings.PROXY_TYPE_IS_SOCKS);

    boolean showError = !StringUtil.isEmptyOrSpaces(settings.LAST_ERROR);
    myErrorLabel.setVisible(showError);//from   w ww . j  ava2 s. com
    myErrorLabel.setText(showError ? errorText(settings.LAST_ERROR) : null);

    final String oldStyleText = CommonProxy.getMessageFromProps(CommonProxy.getOldStyleProperties());
    myOtherWarning.setVisible(oldStyleText != null);
    if (oldStyleText != null) {
        myOtherWarning.setText(oldStyleText);
        myOtherWarning.setIcon(Messages.getWarningIcon());
    }
}

From source file:com.intellij.util.ui.tree.AbstractFileTreeTable.java

License:Apache License

public boolean clearSubdirectoriesOnDemandOrCancel(final VirtualFile parent, final String message,
        final String title) {
    Map<VirtualFile, T> mappings = myModel.myCurrentMapping;
    Map<VirtualFile, T> subdirectoryMappings = new THashMap<VirtualFile, T>();
    for (VirtualFile file : mappings.keySet()) {
        if (file != null && (parent == null || VfsUtilCore.isAncestor(parent, file, true))) {
            subdirectoryMappings.put(file, mappings.get(file));
        }//from   w ww  .j  a v  a  2s . c om
    }
    if (subdirectoryMappings.isEmpty()) {
        return true;
    }
    int ret = Messages.showYesNoCancelDialog(myProject, message, title, "Override", "Do Not Override", "Cancel",
            Messages.getWarningIcon());
    if (ret == 0) {
        for (VirtualFile file : subdirectoryMappings.keySet()) {
            myModel.setValueAt(null, new DefaultMutableTreeNode(file), 1);
        }
    }
    return ret != 2;
}

From source file:com.magnet.plugin.r2m.helpers.AsyncHelper.java

License:Open Source License

private void showOverrideConfirmationDialog(final List<String> list) {
    this.result = false;
    StringBuilder sb = new StringBuilder("\n");
    for (String e : list) {
        sb.append(e).append("\n");
    }/*from w ww  . j a  v a  2  s .c  o  m*/
    int option = Messages.showOkCancelDialog(R2MMessages.getMessage("CONFIRM_OVERRIDE_FILES", sb.toString()),
            R2MMessages.getMessage("CONFIRM_OVERRIDE_FILES_TITLE"),
            R2MMessages.getMessage("CONFIRM_OVERRIDE_FILES_BUTTON_TEXT"), Messages.CANCEL_BUTTON,
            Messages.getWarningIcon());
    if (option == 0) {
        onActionSuccess(GenerateActions.START_FILE_OPERATIONS);
    } else {
        this.result = true;
        onActionSuccess(GenerateActions.FILE_OPERATION_SUCCESS);
    }
}

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

License:Apache License

private static void checkInstalledPluginDependencies(@NotNull InstalledPluginsTableModel model,
        @NotNull IdeaPluginDescriptorImpl pluginDescriptor, @Nullable Component parent) {
    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 = model.isDisabled(id);
        final boolean enabled = model.isEnabled(id);
        if (!enabled && !disabled && !ReflectionUtil.isModuleDependency(id)) {
            notInstalled.add(id);//from  ww w  .ja v a 2  s. c  o  m
        } else if (disabled) {
            disabledIds.add(id);
        }
    }
    if (!notInstalled.isEmpty()) {
        String deps = StringUtil.join(notInstalled, new Function<PluginId, String>() {
            @Override
            public String fun(PluginId id) {
                return id.toString();
            }
        }, ", ");
        String message = "Plugin " + pluginDescriptor.getName() + " depends on unknown plugin"
                + (notInstalled.size() > 1 ? "s " : " ") + deps;
        MessagesEx.showWarningDialog(parent, message, CommonBundle.getWarningTitle());
    }
    if (!disabledIds.isEmpty()) {
        final Set<IdeaPluginDescriptor> dependencies = new HashSet<IdeaPluginDescriptor>();
        for (IdeaPluginDescriptor ideaPluginDescriptor : model.getAllPlugins()) {
            if (disabledIds.contains(ideaPluginDescriptor.getPluginId())) {
                dependencies.add(ideaPluginDescriptor);
            }
        }
        String part = "disabled plugin" + (dependencies.size() > 1 ? "s " : " ");
        String deps = StringUtil.join(dependencies, new Function<IdeaPluginDescriptor, String>() {
            @Override
            public String fun(IdeaPluginDescriptor descriptor) {
                return descriptor.getName();
            }
        }, ", ");
        String message = "Plugin " + pluginDescriptor.getName() + " depends on " + part + deps + ". Enable "
                + part.trim() + "?";
        if (MessagesEx.showOkCancelDialog(parent, message, CommonBundle.getWarningTitle(),
                Messages.getWarningIcon()) == Messages.OK) {
            model.enableRows(dependencies.toArray(new IdeaPluginDescriptor[dependencies.size()]), Boolean.TRUE);
        }
    }
}

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);//  ww  w.jav 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.microsoft.intellij.ui.azureroles.AzureRolePanel.java

License:Open Source License

private void handleSmallVMCacheConf() {
    try {//from   w w  w. jav a 2 s.c  om
        if (message("txtExtraSmallVM").equals((String) comboVMSize.getSelectedItem())
                && windowsAzureRole.getCacheMemoryPercent() > 0) {
            // If extra small VM and cache is enabled
            int choice = Messages.showYesNoDialog((Project) null, message("cacheConfMsg"),
                    message("cacheConfTitle"), Messages.getWarningIcon());
            if (choice == Messages.YES) {
                // Yes - Disable cache
                windowsAzureRole.setCacheMemoryPercent(0);
            } else {
                // No or if dialog is closed directly then reset VM size back to original
                comboVMSize.setSelectedItem(arrVMSize[getVMSizeIndex()]);
            }
        }
    } catch (WindowsAzureInvalidProjectOperationException e) {
        PluginUtil.displayErrorDialogAndLog(message("cachErrTtl"), message("cachGetErMsg"), e);
    }
}

From source file:com.perl5.lang.perl.idea.configuration.module.PerlInterpreterForModuleStep.java

License:Apache License

public boolean validate() {
    final Sdk jdk = myJdkChooser.getChosenJdk();
    if (jdk == null) {
        int result = Messages.showOkCancelDialog(IdeBundle.message("prompt.confirm.project.no.jdk"),
                IdeBundle.message("title.no.jdk.specified"), Messages.getWarningIcon());
        if (result != Messages.OK) {
            return false;
        }//from ww w . ja va 2  s .  c o  m
    }
    return true;
}