Search in sources :

Example 1 with Quantity

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();
}
Also used : ValueWithDisplayString(com.android.tools.idea.uibuilder.property.editors.support.ValueWithDisplayString) AttributeDefinition(org.jetbrains.android.dom.attrs.AttributeDefinition) Quantity(com.android.tools.idea.uibuilder.property.editors.support.Quantity) ValueWithDisplayString(com.android.tools.idea.uibuilder.property.editors.support.ValueWithDisplayString)

Aggregations

Quantity (com.android.tools.idea.uibuilder.property.editors.support.Quantity)1 ValueWithDisplayString (com.android.tools.idea.uibuilder.property.editors.support.ValueWithDisplayString)1 AttributeDefinition (org.jetbrains.android.dom.attrs.AttributeDefinition)1