diff --git a/PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-lib/src/main/java/com/microsoft/azure/toolkit/intellij/common/BaseAzureTextInput.java b/PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-lib/src/main/java/com/microsoft/azure/toolkit/intellij/common/BaseAzureTextInput.java index bee2000ae4..e7c45a4c94 100644 --- a/PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-lib/src/main/java/com/microsoft/azure/toolkit/intellij/common/BaseAzureTextInput.java +++ b/PluginsAndFeatures/azure-toolkit-for-intellij/azure-intellij-plugin-lib/src/main/java/com/microsoft/azure/toolkit/intellij/common/BaseAzureTextInput.java @@ -23,16 +23,16 @@ import java.util.function.Function; public class BaseAzureTextInput extends ExtendableTextField - implements AzureFormInputComponent, TextDocumentListenerAdapter { + implements AzureFormInputComponent, 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> 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; @@ -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); }