use of com.android.tools.idea.uibuilder.property.editors.support.Quantity in project android by JetBrains.
the class NlEnumEditor method findBestInsertionPoint.
private int findBestInsertionPoint(@NotNull ValueWithDisplayString newValue) {
AttributeDefinition definition = myProperty.getDefinition();
boolean isDimension = definition != null && definition.getFormats().contains(AttributeFormat.Dimension);
int startIndex = 1;
if (!isDimension) {
return startIndex;
}
String newTextValue = newValue.getDisplayString();
if (StringUtil.isEmpty(newTextValue)) {
return startIndex;
}
Quantity newQuantity = Quantity.parse(newTextValue);
if (newQuantity == null) {
return startIndex;
}
ComboBoxModel<ValueWithDisplayString> model = myCombo.getModel();
for (int index = startIndex, size = model.getSize(); index < size; index++) {
String textValue = model.getElementAt(index).getValue();
if (textValue != null) {
Quantity quantity = Quantity.parse(textValue);
if (newQuantity.compareTo(quantity) <= 0) {
return index;
}
}
}
return model.getSize();
}
Aggregations