use of org.jetbrains.android.dom.attrs.AttributeDefinition in project android by JetBrains.
the class IdAnalyzerTest method testRelativeLayout.
public void testRelativeLayout() {
ModelBuilder modelBuilder = createRelativeLayout();
NlModel model = modelBuilder.build();
NlComponent button2 = findById(model, "button3");
NlProperty property = new NlPropertyItem(ImmutableList.of(button2), ANDROID_URI, new AttributeDefinition(ATTR_LAYOUT_ALIGN_START));
IdAnalyzer analyzer = new IdAnalyzer(property);
List<String> ids = analyzer.findIds();
assertEquals(ImmutableList.of("button4", "button5", "group1"), ids);
}
use of org.jetbrains.android.dom.attrs.AttributeDefinition in project android by JetBrains.
the class IdAnalyzerTest method testButton1.
public void testButton1() {
ModelBuilder modelBuilder = createRelativeLayout();
NlModel model = modelBuilder.build();
NlComponent button1 = findById(model, "button1");
NlProperty labelFor = new NlPropertyItem(ImmutableList.of(button1), ANDROID_URI, new AttributeDefinition(ATTR_LABEL_FOR));
IdAnalyzer analyzer = new IdAnalyzer(labelFor);
List<String> ids = analyzer.findIds();
assertEquals(ImmutableList.of("button2", "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 BrowsePanel method showResourceChooser.
public static ChooseResourceDialog showResourceChooser(@NotNull NlProperty property) {
Module module = property.getModel().getModule();
AttributeDefinition definition = property.getDefinition();
EnumSet<ResourceType> types = getResourceTypes(property.getName(), definition);
//return new ChooseResourceDialog(module, types, property.getValue(), property.getTag());
return ChooseResourceDialog.builder().setModule(module).setTypes(types).setCurrentValue(property.getValue()).setTag(property.getTag()).build();
}
use of org.jetbrains.android.dom.attrs.AttributeDefinition in project android by JetBrains.
the class AttributeDefinitionEnumSupport method getAllValues.
@Override
@NotNull
public List<ValueWithDisplayString> getAllValues() {
AttributeDefinition definition = myProperty.getDefinition();
String[] stringValues = definition != null ? definition.getValues() : ArrayUtil.EMPTY_STRING_ARRAY;
List<ValueWithDisplayString> values = new ArrayList<>(stringValues.length);
for (String stringValue : stringValues) {
values.add(new ValueWithDisplayString(stringValue, stringValue));
}
return values;
}
use of org.jetbrains.android.dom.attrs.AttributeDefinition in project android by JetBrains.
the class NlReferenceEditor method configureSlider.
private boolean configureSlider() {
if (myProperty == null) {
return false;
}
AttributeDefinition definition = myProperty.getDefinition();
if (definition == null || Collections.disjoint(definition.getFormats(), ImmutableList.of(AttributeFormat.Dimension, AttributeFormat.Float))) {
return false;
}
int maximum;
int value;
switch(myProperty.getName()) {
case SdkConstants.ATTR_ELEVATION:
case SdkConstants.ATTR_CARD_ELEVATION:
// Range: [0, 24] integer (dp)
maximum = 24;
value = getValueInDp(0);
break;
case SdkConstants.ATTR_MIN_HEIGHT:
// Range: [0, 250] integer (dp)
maximum = 250;
value = getValueInDp(180);
break;
case SdkConstants.ATTR_MOCKUP_OPACITY:
case SdkConstants.ATTR_COLLAPSE_PARALLAX_MULTIPLIER:
// Range: [0.0, 1.0] float (no unit)
maximum = 10;
value = (int) (getValueAsFloat(1.0) * 10 + 0.5);
break;
default:
return false;
}
mySlider.setMinimum(0);
mySlider.setMaximum(maximum);
mySlider.setValue(value);
return true;
}
Aggregations