Skip to content

Commit

Permalink
validationExtension might be null, which is not acceptable for Exte…
Browse files Browse the repository at this point in the history
…nsibleTextField.
  • Loading branch information
wangmingliang-ms committed Sep 2, 2022
1 parent 2c33bad commit bd1953d
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
import java.util.function.Function;

public class BaseAzureTextInput<T> extends ExtendableTextField
implements AzureFormInputComponent<T>, TextDocumentListenerAdapter {
implements AzureFormInputComponent<T>, TextDocumentListenerAdapter {
protected static final int DEBOUNCE_DELAY = 500;
private final Debouncer debouncer;
private static final Extension VALIDATING = Extension.create(AnimatedIcon.Default.INSTANCE, "Validating...", null);
private static final Extension SUCCESS = Extension.create(AllIcons.General.InspectionsOK, "Validation passed.", null);
private static final Map<AzureValidationInfo.Type, Function<AzureValidationInfo, Extension>> extensions = ImmutableMap.of(
AzureValidationInfo.Type.PENDING, (i) -> VALIDATING,
AzureValidationInfo.Type.SUCCESS, (i) -> SUCCESS,
AzureValidationInfo.Type.ERROR, (i) -> Extension.create(AllIcons.General.BalloonError, i.getMessage(), null),
AzureValidationInfo.Type.WARNING, (i) -> Extension.create(AllIcons.General.BalloonWarning, i.getMessage(), null)
AzureValidationInfo.Type.PENDING, (i) -> VALIDATING,
AzureValidationInfo.Type.SUCCESS, (i) -> SUCCESS,
AzureValidationInfo.Type.ERROR, (i) -> Extension.create(AllIcons.General.BalloonError, i.getMessage(), null),
AzureValidationInfo.Type.WARNING, (i) -> Extension.create(AllIcons.General.BalloonWarning, i.getMessage(), null)
);
protected Extension validationExtension;

Expand Down Expand Up @@ -63,12 +63,14 @@ public void onDocumentChanged() {
this.debouncer.debounce();
}

protected synchronized void setValidationExtension(final Extension extension) {
protected synchronized void setValidationExtension(@Nullable final Extension extension) {
AzureTaskManager.getInstance().runLater(() -> {
if (validationExtension != null) {
this.removeExtension(validationExtension);
}
this.addExtension(extension);
if (Objects.nonNull(extension)) {
this.addExtension(extension);
}
this.validationExtension = extension;
}, AzureTask.Modality.ANY);
}
Expand Down

0 comments on commit bd1953d

Please sign in to comment.