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

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

Introduction

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

Prototype

@NotNull
    public static Icon getQuestionIcon() 

Source Link

Usage

From source file:com.intellij.uiDesigner.snapShooter.CreateSnapShotAction.java

License:Apache License

@Nullable
private static RunnerAndConfigurationSettings promptForSnapshotConfiguration(final Project project,
        final List<RunnerAndConfigurationSettings> configurations) {
    if (configurations.isEmpty()) {
        Messages.showMessageDialog(project, UIDesignerBundle.message("snapshot.no.configuration.error"),
                UIDesignerBundle.message("snapshot.title"), Messages.getInformationIcon());
        return null;
    }/*from  w w w  . j  ava  2  s  .  c om*/

    for (int i = configurations.size() - 1; i >= 0; i--) {
        final JreVersionDetector detector = new JreVersionDetector();
        final ApplicationConfiguration configuration = (ApplicationConfiguration) configurations.get(i)
                .getConfiguration();
        if (!detector.isJre50Configured(configuration) && !detector.isModuleJre50Configured(configuration)) {
            configurations.remove(i);
        }
    }

    if (configurations.isEmpty()) {
        Messages.showMessageDialog(project,
                UIDesignerBundle.message("snapshot.no.compatible.configuration.error"),
                UIDesignerBundle.message("snapshot.title"), Messages.getInformationIcon());
        return null;
    }

    final RunnerAndConfigurationSettings snapshotConfiguration;
    if (configurations.size() == 1) {
        final int rc = Messages.showYesNoDialog(project,
                UIDesignerBundle.message("snapshot.confirm.configuration.prompt",
                        configurations.get(0).getConfiguration().getName()),
                UIDesignerBundle.message("snapshot.title"), Messages.getQuestionIcon());
        if (rc == 1) {
            return null;
        }
        snapshotConfiguration = configurations.get(0);
    } else {
        String[] names = new String[configurations.size()];
        for (int i = 0; i < configurations.size(); i++) {
            names[i] = configurations.get(i).getConfiguration().getName();
        }
        int rc = Messages.showChooseDialog(project,
                UIDesignerBundle.message("snapshot.choose.configuration.prompt"),
                UIDesignerBundle.message("snapshot.title"), Messages.getQuestionIcon(), names, names[0]);
        if (rc < 0)
            return null;
        snapshotConfiguration = configurations.get(rc);
    }
    ((ApplicationConfiguration) snapshotConfiguration.getConfiguration()).ENABLE_SWING_INSPECTOR = true;
    return snapshotConfiguration;
}

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.  j  a va2  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.HttpProxySettingsUi.java

License:Apache License

private void configureCheckButton() {
    if (HttpConfigurable.getInstance() == null) {
        myCheckButton.setVisible(false);
        return;/*from  w  ww  .j a va2  s .c  o m*/
    }

    myCheckButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(@NotNull 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)) {
                return;
            }

            final HttpConfigurable settings = HttpConfigurable.getInstance();
            apply(settings);
            final AtomicReference<IOException> exceptionReference = new AtomicReference<IOException>();
            myCheckButton.setEnabled(false);
            myCheckButton.setText("Check connection (in progress...)");
            myConnectionCheckInProgress = true;
            ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
                @Override
                public void run() {
                    HttpURLConnection connection = null;
                    try {
                        //already checked for null above
                        //noinspection ConstantConditions
                        connection = settings.openHttpConnection(answer);
                        connection.setReadTimeout(3 * 1000);
                        connection.setConnectTimeout(3 * 1000);
                        connection.connect();
                        final int code = connection.getResponseCode();
                        if (HttpURLConnection.HTTP_OK != code) {
                            exceptionReference.set(new IOException("Error code: " + code));
                        }
                    } catch (IOException e) {
                        exceptionReference.set(e);
                    } finally {
                        if (connection != null) {
                            connection.disconnect();
                        }
                    }
                    //noinspection SSBasedInspection
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            myConnectionCheckInProgress = false;
                            reset(settings); // since password might have been set
                            Component parent;
                            if (myMainPanel.isShowing()) {
                                parent = myMainPanel;
                                myCheckButton.setText("Check connection");
                                myCheckButton.setEnabled(canEnableConnectionCheck());
                            } else {
                                IdeFrame frame = IdeFocusManager.findInstance().getLastFocusedFrame();
                                if (frame == null) {
                                    return;
                                }
                                parent = frame.getComponent();
                            }
                            //noinspection ThrowableResultOfMethodCallIgnored
                            final IOException exception = exceptionReference.get();
                            if (exception == null) {
                                Messages.showMessageDialog(parent, "Connection successful", title,
                                        Messages.getInformationIcon());
                            } else {
                                final String message = exception.getMessage();
                                if (settings.USE_HTTP_PROXY) {
                                    settings.LAST_ERROR = message;
                                }
                                Messages.showErrorDialog(parent, errorText(message));
                            }
                        }
                    });
                }
            });
        }
    });
}

From source file:com.intellij.util.xml.tree.actions.DeleteDomElement.java

License:Apache License

public void actionPerformed(AnActionEvent e, DomModelTreeView treeView) {
    final SimpleNode selectedNode = treeView.getTree().getSelectedNode();

    if (selectedNode instanceof BaseDomElementNode) {

        if (selectedNode instanceof DomFileElementNode) {
            e.getPresentation().setVisible(false);
            return;
        }//from  w  w  w  .  j ava2s  .c om

        final DomElement domElement = ((BaseDomElementNode) selectedNode).getDomElement();

        final int ret = Messages.showOkCancelDialog(getPresentationText(selectedNode) + "?",
                ApplicationBundle.message("action.remove"), Messages.getQuestionIcon());
        if (ret == 0) {
            new WriteCommandAction(domElement.getManager().getProject(), DomUtil.getFile(domElement)) {
                protected void run(final Result result) throws Throwable {
                    domElement.undefine();
                }
            }.execute();
        }
    }
}

From source file:com.intellij.vcs.starteam.StarteamChangeProvider.java

private void processFailedConnection(final String msg) {
    if (!warnShown) {
        Runnable action = new Runnable() {
            public void run() {
                String title = StarteamBundle.message("message.title.configuration.error");
                String reconnectText = StarteamBundle.message("text.reconnect");
                String cancelText = StarteamBundle.message("text.cancel");
                int result = Messages.showChooseDialog(project, msg, title, Messages.getQuestionIcon(),
                        new String[] { reconnectText, cancelText }, reconnectText);
                if (result == 0) {
                    try {
                        host.doShutdown();
                        host.doStart();//from   www .j  a  va  2 s  .co  m
                        warnShown = false;
                    } catch (VcsException e) {
                        Messages.showErrorDialog(msg,
                                StarteamBundle.message("message.title.configuration.error"));
                    }
                }
            }
        };
        ApplicationManager.getApplication().invokeLater(action);
        warnShown = true;
    }
}

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 ww  w. ja  v a2 s .c  om

    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 ww.j a  v  a2 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.copyright.actions.GenerateCopyrightAction.java

License:Apache License

public void actionPerformed(AnActionEvent event) {
    DataContext context = event.getDataContext();
    Project project = CommonDataKeys.PROJECT.getData(context);
    assert project != null;
    Module module = LangDataKeys.MODULE.getData(context);
    PsiDocumentManager.getInstance(project).commitAllDocuments();

    PsiFile file = getFile(context, project);
    assert file != null;
    if (CopyrightManager.getInstance(project).getCopyrightOptions(file) == null) {
        if (Messages.showOkCancelDialog(project,
                "No copyright configured for current file. Would you like to edit copyright settings?",
                "No Copyright Available", Messages.getQuestionIcon()) == DialogWrapper.OK_EXIT_CODE) {
            ShowSettingsUtil.getInstance().showSettingsDialog(project,
                    new CopyrightProjectConfigurable(project).getDisplayName());
        } else {//from w  w  w  . java 2s.  c  o m
            return;
        }
    }
    new UpdateCopyrightProcessor(project, module, file).run();
}

From source file:com.maddyhome.idea.copyright.ui.CopyrightProfilesPanel.java

License:Apache License

@Nullable
private String askForProfileName(String title, String initialName) {
    return Messages.showInputDialog("New copyright profile name:", title, Messages.getQuestionIcon(),
            initialName, new InputValidator() {
                public boolean checkInput(String s) {
                    return !getAllProfiles().containsKey(s) && s.length() > 0;
                }/*  w  w w  .j a va2 s.co m*/

                public boolean canClose(String s) {
                    return checkInput(s);
                }
            });
}

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 ww . j  a  va  2s . 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);
        }
    }
}