use of com.android.tools.idea.editors.theme.datamodels.ThemeEditorStyle in project android by JetBrains.
the class ThemeAttributeResolver method resolveFromInheritance.
private void resolveFromInheritance(@NotNull ThemeEditorStyle themeEditorStyle, @NotNull FolderConfiguration configuration, @NotNull RestrictedConfiguration restricted, @NotNull Set<String> seenAttributes) {
RestrictedConfiguration styleRestricted = getRestrictedConfiguration(themeEditorStyle, configuration);
if (styleRestricted == null) {
LOG.warn(configuration + " is unreachable");
return;
}
styleRestricted = restricted.intersect(styleRestricted);
if (styleRestricted == null) {
return;
}
Set<String> newSeenAttributes = new HashSet<String>(seenAttributes);
for (ItemResourceValue item : themeEditorStyle.getValues(configuration)) {
String itemName = ResolutionUtils.getQualifiedItemName(item);
if (!newSeenAttributes.contains(itemName)) {
myItemValueMap.putValue(itemName, ConfiguredElement.create(styleRestricted.getAny(), item));
newSeenAttributes.add(itemName);
}
}
String parentName = themeEditorStyle.getParentName(configuration);
if (parentName == null) {
// We have reached the top of the theme hierarchy (i.e "android:Theme")
return;
}
ThemeEditorStyle parent = new ThemeEditorStyle(myManager, parentName);
for (FolderConfiguration folder : parent.getFolders()) {
resolveFromInheritance(parent, folder, styleRestricted, newSeenAttributes);
}
}
use of com.android.tools.idea.editors.theme.datamodels.ThemeEditorStyle in project android by JetBrains.
the class ThemeAttributeResolver method resolveAll.
@NotNull
private List<EditedStyleItem> resolveAll() {
ThemeEditorStyle theme = new ThemeEditorStyle(myManager, myStyle.getQualifiedName());
for (FolderConfiguration folder : theme.getFolders()) {
resolveFromInheritance(myStyle, folder, new RestrictedConfiguration(), new HashSet<String>());
}
List<EditedStyleItem> result = Lists.newArrayList();
FolderConfiguration configuration = myStyle.getConfiguration().getFullConfig();
for (String key : myItemValueMap.keySet()) {
Collection<ConfiguredElement<ItemResourceValue>> itemValues = myItemValueMap.get(key);
final ConfiguredElement<ItemResourceValue> selectedValue = (ConfiguredElement<ItemResourceValue>) configuration.findMatchingConfigurable(Lists.<Configurable>newArrayList(itemValues));
if (selectedValue == null) {
// TODO: there is NO value for this attribute in the current config,so instead we need to show "no value for current device"
result.add(new EditedStyleItem(itemValues.iterator().next(), itemValues, myStyle));
} else {
itemValues.remove(selectedValue);
assert !itemValues.contains(selectedValue);
result.add(new EditedStyleItem(selectedValue, itemValues, myStyle));
}
}
return result;
}
Aggregations