Java Code Examples for com.intellij.openapi.ui.Messages#showEditableChooseDialog()

The following examples show how to use com.intellij.openapi.ui.Messages#showEditableChooseDialog() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SlackSettings.java    From SlackStorm with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getData(CommonDataKeys.PROJECT);

    List<String> channelsId = SlackStorage.getInstance().getChannelsId();

    if (channelsId.size() > 0) {
        String channelToRemove = Messages.showEditableChooseDialog(
            "Select the channel to remove",
            SlackChannel.getSettingsDescription(),
            SlackStorage.getSlackIcon(),
            channelsId.toArray(new String[channelsId.size()]),
            channelsId.get(0),
            null
        );

        if (channelsId.contains(channelToRemove)) {
            SlackStorage.getInstance().removeChannelByDescription(channelToRemove);
            Messages.showMessageDialog(project, "Channel \"" + channelToRemove + "\" removed.", "Information", Messages.getInformationIcon());
        }
    }
}
 
Example 2
Source File: ExampleChooserHelper.java    From r2m-plugin-android with Apache License 2.0 6 votes vote down vote up
public static String showExamplesDialog() {

        EXAMPLES_DIALOG_UP = true;
        try {
            List<String> examples = getManifest().getExamplesList();
            String response = Messages.showEditableChooseDialog(
                    R2MMessages.getMessage("CHOOSE_EXAMPLE_LABEL"),
                    R2MMessages.getMessage("CHOOSE_EXAMPLE_TITLE"),
                    Messages.getQuestionIcon(),
                    examples.toArray(new String[examples.size()]),
                    R2MMessages.getMessage("CHOOSE_EXAMPLE_DEFAULT_VALUE"),
                    null);
            return response == null ? null : response.split(ExamplesManifest.DESCRIPTION_SEPARATOR_KEY)[0];
        } finally {
            EXAMPLES_DIALOG_UP = false;
        }
    }
 
Example 3
Source File: SetSeparatorAction.java    From nosql4idea with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent event) {
    String[] strings = ArrayUtil.toStringArray(myPredefinedSeparators);
    String current = redisPanel.getGroupSeparator();
    String separator = Messages.showEditableChooseDialog("Redis Keys Separator",
            "Select Separator",
            Messages.getQuestionIcon(),
            strings, current, null);
    if (separator == null) {
        return;
    }

    if (StringUtils.equals(redisPanel.getGroupSeparator(), separator)) {
        return;
    }

    redisPanel.setGroupSeparator(separator);

    myPredefinedSeparators.add(separator);
    update(event);
}
 
Example 4
Source File: DojoSettingsConfigurable.java    From needsmoredojo with Apache License 2.0 5 votes vote down vote up
private void addAutoDetectedSource(Collection<String> possibleSourceRoots)
{
    String[] choices = possibleSourceRoots.toArray(new String[0]);

    if(choices.length == 0)
    {
        Messages.showInfoMessage("Could not find any source roots via auto-detection", "Auto-detect Project Sources");
        return;
    }

    String result = choices[0];
    if(choices.length > 1)
    {
        result = Messages.showEditableChooseDialog("Found these possible source roots: ", "Auto-detect Project Sources", null, choices, choices[0], null);
        if(result == null || result.equals(""))
        {
            return;
        }

        if(result.contains("(") && result.contains(")"))
        {
            result = result.substring(result.indexOf('(') + 1, result.indexOf(')'));
        }
    }
    else if (choices.length == 1)
    {
        if(result.contains("(") && result.contains(")"))
        {
            result = result.substring(result.indexOf('(') + 1, result.indexOf(')'));
        }
    }

    projectSourceString = result;
    projectSourcesText.setText(result);
}
 
Example 5
Source File: SlackSettings.java    From SlackStorm with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getData(CommonDataKeys.PROJECT);
    SlackStorage slackStorage = SlackStorage.getInstance();

    List<String> channelsId = SlackStorage.getInstance().getChannelsId();

    if (channelsId.size() > 0) {
        String channelToUpdate = Messages.showEditableChooseDialog(
                "Select the channel to edit",
                SlackChannel.getSettingsDescription(),
                SlackStorage.getSlackIcon(),
                channelsId.toArray(new String[channelsId.size()]),
                channelsId.get(0),
                null
        );

        if (channelsId.contains(channelToUpdate)) {
            // Load the channel
            SlackChannel selectedChannel = slackStorage.getSlackChannelByDescription(channelToUpdate);

            String description = this.showInputDialog(SlackChannel.getIdDescription(), selectedChannel.getId());
            if (!isValidField(description)) {
                errorMessage();
                return;
            }

            String userAlias = this.showInputDialog(SlackChannel.getSenderNameDescription(), selectedChannel.senderName);

            if (!isValidField(userAlias)) {
                errorMessage();
                return;
            }

            String icon = this.showInputDialog(SlackChannel.getSenderIconDescription(), selectedChannel.senderIcon);

            if (!isValidField(icon)) {
                errorMessage();
                return;
            }

            String channel = this.showInputDialog(SlackChannel.getChanneNameDescription(), selectedChannel.channelName);

            String token = this.showInputDialog(SlackChannel.getTokenDescription(), selectedChannel.token);

            if (!isValidField(token)) {
                errorMessage();
                return;
            }

            // To update, we just remove and add since the ID can change
            SlackStorage.getInstance().removeChannelByDescription(channelToUpdate);
            SlackStorage.getInstance().registerChannel(new SlackChannel(token, description, userAlias, icon, channel));
            Messages.showMessageDialog(project, "Channel \"" + channelToUpdate + "\" updated.", "Information", Messages.getInformationIcon());
        }
    }
}