use of com.android.tools.idea.uibuilder.property.editors.support.ValueWithDisplayString in project android by JetBrains.
the class NlEnumEditor method cancel.
private void cancel() {
String text = myProperty.getValue();
myCombo.getEditor().setItem(text);
ValueWithDisplayString value = createFromEditorValue(myProperty.getValue());
selectItem(value);
myPopupValueChanged = false;
cancelEditing();
myCombo.getEditor().selectAll();
myCombo.hidePopup();
}
use of com.android.tools.idea.uibuilder.property.editors.support.ValueWithDisplayString in project android by JetBrains.
the class NlEnumEditor method enter.
private void enter() {
if (!myCombo.isPopupVisible()) {
ValueWithDisplayString value = createFromEditorValue(myEditor.getText());
selectItem(value);
stopEditing(value.getValue());
myCombo.getEditor().selectAll();
}
myCombo.hidePopup();
}
use of com.android.tools.idea.uibuilder.property.editors.support.ValueWithDisplayString 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();
}
use of com.android.tools.idea.uibuilder.property.editors.support.ValueWithDisplayString in project android by JetBrains.
the class NlEnumEditorFixture method checkChoices.
private static void checkChoices(@NotNull ComboBoxModel<ValueWithDisplayString> model, int count, @NotNull String... choices) {
for (int index = 0; index < count; index++) {
ValueWithDisplayString value = model.getElementAt(index);
assertThat(value).isNotNull();
assertThat(value.getDisplayString()).isEqualTo(choices[2 * index]);
assertThat(value.getValue()).isEqualTo(choices[2 * index + 1]);
}
}
use of com.android.tools.idea.uibuilder.property.editors.support.ValueWithDisplayString in project android by JetBrains.
the class NlEnumEditorFixture method dumpDifference.
private static void dumpDifference(@NotNull ComboBoxModel<ValueWithDisplayString> model, @NotNull String... choices) {
StringBuilder msg = new StringBuilder();
msg.append("\nExpected:\n");
int rows = choices.length / 2;
for (int index = 0; index < rows; index++) {
msg.append(String.format("%10s - %s\n", choices[2 * index], choices[2 * index + 1]));
}
msg.append("\nActual:\n");
for (int index = 0; index < model.getSize(); index++) {
ValueWithDisplayString value = model.getElementAt(index);
msg.append(String.format("%10s - %s\n", value.getDisplayString(), value.getValue()));
}
msg.append(String.format("\nExpected count: %d, Actual count: %d\n", choices.length, model.getSize() * 2));
Assert.fail(msg.toString());
}
Aggregations