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);
}
}
}
}
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();
}
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);
}
Aggregations