use of com.android.ide.common.resources.ResourceItemResolver in project android by JetBrains.
the class ResourceDrawablePanel method updateResolutionChain.
private void updateResolutionChain(@NotNull ResourceChooserItem item) {
// Resource resolver
myResolvedPanel.removeAll();
ResourceValue resourceValue = item.getResourceValue();
Configuration configuration = myDialog.getConfiguration();
ResourceRepository frameworkResources = configuration.getFrameworkResources();
if (frameworkResources != null) {
AppResourceRepository appResources = AppResourceRepository.getAppResources(myDialog.geFacet(), true);
ResourceItemResolver resolver = new ResourceItemResolver(configuration.getFullConfig(), frameworkResources, appResources, null);
List<ResourceValue> lookupChain = Lists.newArrayList();
lookupChain.add(resourceValue);
resolver.setLookupChainList(lookupChain);
resolver.resolveResValue(resourceValue);
String prev = null;
int indent = 0;
if (lookupChain.size() >= 2) {
for (ResourceValue element : lookupChain) {
if (element == null) {
continue;
}
String value = element.getValue();
if (value == null) {
continue;
}
String text = value;
if (text.equals(prev)) {
continue;
}
// Strip paths
if (!(text.startsWith(PREFIX_THEME_REF) || text.startsWith(PREFIX_RESOURCE_REF))) {
if (indent == 0) {
break;
}
int end = Math.max(text.lastIndexOf('/'), text.lastIndexOf('\\'));
if (end != -1) {
text = text.substring(end + 1);
}
}
if (indent > 0) {
// 21D2: Rightwards arrow
text = "⇒ " + text;
}
JBLabel label = new JBLabel(text);
label.setBorder(IdeBorderFactory.createEmptyBorder(0, JBUI.scale(indent * 12), 0, 0));
myResolvedPanel.add(label);
indent++;
prev = value;
}
}
}
}
Aggregations