use of org.jetbrains.android.dom.attrs.AttributeDefinition in project android by JetBrains.
the class EnumSupportFactory method supportsProperty.
public static boolean supportsProperty(@NotNull NlProperty property) {
switch(property.getName()) {
case ATTR_FONT_FAMILY:
case ATTR_TYPEFACE:
case ATTR_TEXT_SIZE:
case ATTR_LINE_SPACING_EXTRA:
case ATTR_TEXT_APPEARANCE:
case ATTR_LAYOUT_HEIGHT:
case ATTR_LAYOUT_WIDTH:
case ATTR_DROPDOWN_HEIGHT:
case ATTR_DROPDOWN_WIDTH:
case ATTR_ON_CLICK:
return true;
case ATTR_ID:
return false;
case ATTR_STYLE:
String tagName = property.getTagName();
return tagName != null && StyleFilter.hasWidgetStyles(property.getModel().getProject(), property.getResolver(), tagName);
default:
if (property.getName().endsWith(TEXT_APPEARANCE_SUFFIX)) {
return true;
}
if (AndroidDomUtil.SPECIAL_RESOURCE_TYPES.get(property.getName()) == ResourceType.ID) {
return true;
}
AttributeDefinition definition = property.getDefinition();
Set<AttributeFormat> formats = definition != null ? definition.getFormats() : Collections.emptySet();
return formats.contains(AttributeFormat.Enum);
}
}
use of org.jetbrains.android.dom.attrs.AttributeDefinition in project android by JetBrains.
the class NlPropertyRenderers method get.
@NotNull
public static TableCellRenderer get(@NotNull NlProperty p) {
AttributeDefinition definition = p.getDefinition();
if (definition == null) {
return getDefaultRenderer();
}
Set<AttributeFormat> formats = definition.getFormats();
if (formats.size() == 1 && formats.contains(AttributeFormat.Boolean)) {
NlBooleanRenderer renderer = getBooleanRenderer();
if (renderer.canRender(p, formats)) {
return renderer;
}
}
if (formats.contains(AttributeFormat.Flag)) {
NlFlagRenderer renderer = getFlagRenderer();
if (renderer.canRender(p, formats)) {
return renderer;
}
}
return getDefaultRenderer();
}
use of org.jetbrains.android.dom.attrs.AttributeDefinition in project android by JetBrains.
the class IdAnalyzerTest method testButton1And2.
public void testButton1And2() {
ModelBuilder modelBuilder = createRelativeLayout();
NlModel model = modelBuilder.build();
NlComponent button1 = findById(model, "button1");
NlComponent button2 = findById(model, "button2");
NlProperty accessibility = new NlPropertyItem(ImmutableList.of(button1, button2), ANDROID_URI, new AttributeDefinition(ATTR_ACCESSIBILITY_TRAVERSAL_BEFORE));
IdAnalyzer analyzer = new IdAnalyzer(accessibility);
List<String> ids = analyzer.findIds();
assertEquals(ImmutableList.of("button3", "button4", "button5", "group1", "radio_button1", "radio_button2", "radio_button3", "text_view1"), ids);
}
use of org.jetbrains.android.dom.attrs.AttributeDefinition in project android by JetBrains.
the class IdAnalyzerTest method testRadioGroup.
public void testRadioGroup() {
ModelBuilder modelBuilder = createRelativeLayout();
NlModel model = modelBuilder.build();
NlComponent group = findById(model, "group1");
NlProperty property = new NlPropertyItem(ImmutableList.of(group), ANDROID_URI, new AttributeDefinition(ATTR_CHECKED_BUTTON));
IdAnalyzer analyzer = new IdAnalyzer(property);
List<String> ids = analyzer.findIds();
assertEquals(ImmutableList.of("radio_button1", "radio_button2", "radio_button3"), ids);
}
use of org.jetbrains.android.dom.attrs.AttributeDefinition in project android by JetBrains.
the class QuantityTest method mockProperty.
private static NlProperty mockProperty(@NotNull String attribute, @NotNull AttributeFormat format) {
NlProperty property = Mockito.mock(NlProperty.class);
Mockito.when(property.getName()).thenReturn(attribute);
Mockito.when(property.getDefinition()).thenReturn(new AttributeDefinition(attribute, null, Collections.singleton(format)));
return property;
}
Aggregations