Search in sources :

Example 1 with SettingsGroup

use of com.intellij.psi.codeStyle.presentation.CodeStyleSettingPresentation.SettingsGroup in project intellij-community by JetBrains.

the class CodeStyleSettingsNameProvider method moveStandardOption.

@Override
public void moveStandardOption(String fieldName, String newGroup) {
    for (SettingsType settingsType : SettingsType.values()) {
        Map<SettingsGroup, List<CodeStyleSettingPresentation>> standardGroups = mySettings.get(settingsType);
        if (standardGroups == null) {
            standardGroups = ContainerUtil.newLinkedHashMap();
            mySettings.put(settingsType, standardGroups);
        }
        for (Map.Entry<SettingsGroup, List<CodeStyleSettingPresentation>> entry : standardGroups.entrySet()) {
            CodeStyleSettingPresentation moveSetting = null;
            for (CodeStyleSettingPresentation setting : entry.getValue()) {
                if (setting.getFieldName().equals(fieldName)) {
                    moveSetting = setting;
                    break;
                }
            }
            if (moveSetting != null) {
                entry.getValue().remove(moveSetting);
                addSetting(new SettingsGroup(newGroup), moveSetting, null, null);
            }
        }
    }
}
Also used : CodeStyleSettingPresentation(com.intellij.psi.codeStyle.presentation.CodeStyleSettingPresentation) SettingsGroup(com.intellij.psi.codeStyle.presentation.CodeStyleSettingPresentation.SettingsGroup) SettingsType(com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider.SettingsType)

Example 2 with SettingsGroup

use of com.intellij.psi.codeStyle.presentation.CodeStyleSettingPresentation.SettingsGroup in project intellij-community by JetBrains.

the class CodeStyleSettingsNameProvider method getSettings.

public String getSettings(List<Value> values) {
    StringBuilder builder = new StringBuilder();
    for (SettingsType settingsType : LanguageCodeStyleSettingsProvider.SettingsType.values()) {
        builder.append("<br><b><u>").append(getSettingsTypeName(settingsType)).append("</u></b>");
        Map<SettingsGroup, List<CodeStyleSettingPresentation>> groups = mySettings.get(settingsType);
        if (groups != null) {
            for (Map.Entry<SettingsGroup, List<CodeStyleSettingPresentation>> entry : groups.entrySet()) {
                boolean firstSettingGroupTop = entry.getKey().isNull();
                boolean groupReported = false;
                for (final CodeStyleSettingPresentation setting : entry.getValue()) {
                    Value myValue = ContainerUtil.find(values, value -> value.state == Value.STATE.SELECTED && value.name.equals(setting.getFieldName()));
                    if (myValue == null) {
                        continue;
                    }
                    if (!groupReported) {
                        if (firstSettingGroupTop) {
                            builder.append("<b>");
                        } else {
                            builder.append("<br><b>").append(entry.getKey().name).append("</b>");
                        }
                    }
                    builder.append("<br>");
                    String postNameSign = setting.getUiName().endsWith(":") ? " " : ": ";
                    builder.append(setting.getUiName()).append(postNameSign).append(setting.getValueUiName(myValue.value));
                    if (!groupReported) {
                        if (firstSettingGroupTop) {
                            builder.append("</b>");
                        }
                    }
                    groupReported = true;
                }
            }
        }
    }
    return builder.toString();
}
Also used : CodeStyleSettingPresentation(com.intellij.psi.codeStyle.presentation.CodeStyleSettingPresentation) SettingsGroup(com.intellij.psi.codeStyle.presentation.CodeStyleSettingPresentation.SettingsGroup) SettingsType(com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider.SettingsType) Value(com.intellij.psi.codeStyle.extractor.values.Value)

Example 3 with SettingsGroup

use of com.intellij.psi.codeStyle.presentation.CodeStyleSettingPresentation.SettingsGroup in project intellij-community by JetBrains.

the class CodeStyleSettingsNameProvider method addSetting.

protected void addSetting(@NotNull SettingsType settingsType, @NotNull SettingsGroup group, @NotNull CodeStyleSettingPresentation setting, @Nullable OptionAnchor anchor, @Nullable String anchorFieldName) {
    Map<CodeStyleSettingPresentation.SettingsGroup, List<CodeStyleSettingPresentation>> groups = mySettings.get(settingsType);
    if (groups == null) {
        groups = ContainerUtil.newLinkedHashMap();
    }
    List<CodeStyleSettingPresentation> settingsList = groups.get(group);
    if (settingsList == null) {
        settingsList = ContainerUtil.newLinkedList();
    }
    if (settingsList.contains(setting))
        return;
    if (anchor != null && anchorFieldName != null) {
        CodeStyleSettingPresentation anchorSettingRepresentation = new CodeStyleSettingPresentation(anchorFieldName, anchorFieldName);
        int insertIndex = settingsList.indexOf(anchorSettingRepresentation);
        if (insertIndex < 0) {
            insertIndex = settingsList.size();
        } else {
            switch(anchor) {
                case BEFORE:
                    break;
                case AFTER:
                    insertIndex++;
                    break;
                case NONE:
                    insertIndex = settingsList.size();
            }
        }
        settingsList.add(insertIndex, setting);
    } else {
        settingsList.add(setting);
    }
    groups.put(group, settingsList);
}
Also used : CodeStyleSettingPresentation(com.intellij.psi.codeStyle.presentation.CodeStyleSettingPresentation) SettingsGroup(com.intellij.psi.codeStyle.presentation.CodeStyleSettingPresentation.SettingsGroup)

Aggregations

CodeStyleSettingPresentation (com.intellij.psi.codeStyle.presentation.CodeStyleSettingPresentation)3 SettingsGroup (com.intellij.psi.codeStyle.presentation.CodeStyleSettingPresentation.SettingsGroup)3 SettingsType (com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider.SettingsType)2 Value (com.intellij.psi.codeStyle.extractor.values.Value)1