|
25 | 25 | import com.intellij.ui.EditorTextField; |
26 | 26 | import com.intellij.ui.EditorTextFieldProvider; |
27 | 27 | import com.intellij.ui.SoftWrapsEditorCustomization; |
| 28 | +import com.intellij.util.ui.UIUtil; |
28 | 29 | import com.microsoft.azure.toolkit.intellij.common.AzureCommentLabel; |
29 | 30 | import com.microsoft.azure.toolkit.intellij.common.AzureDialog; |
30 | 31 | import com.microsoft.azure.toolkit.intellij.common.TextDocumentListenerAdapter; |
@@ -90,8 +91,7 @@ protected ServicePrincipalLoginDialog(@Nonnull Project project) { |
90 | 91 | init(); |
91 | 92 | super.setOKButtonText("Sign In"); |
92 | 93 |
|
93 | | - pasteFromClipboard(); |
94 | | - uiTextComponents2Json(); |
| 94 | + initJsonData(); |
95 | 95 |
|
96 | 96 | // initialize cert file select |
97 | 97 | FileChooserDescriptor pem = FileChooserDescriptorFactory.createSingleFileDescriptor("pem"); |
@@ -221,13 +221,15 @@ public List<AzureValidationInfo> validateData() { |
221 | 221 | return Collections.emptyList(); |
222 | 222 | } |
223 | 223 |
|
224 | | - private void pasteFromClipboard() { |
| 224 | + private void initJsonData() { |
225 | 225 | String textFromClip = findTextInClipboard(str -> |
226 | | - StringUtils.contains(str, "appId") && StringUtils.contains(str, "tenant") && StringUtils.contains(str, "password") |
| 226 | + StringUtils.contains(str, "appId") && StringUtils.contains(str, "tenant") && |
| 227 | + (StringUtils.contains(str, "password") || StringUtils.contains(str, "fileWithCertAndPrivateKey")) |
227 | 228 | ); |
228 | 229 | if (StringUtils.isNotBlank(textFromClip)) { |
229 | 230 | json2UIComponents(textFromClip); |
230 | 231 | } |
| 232 | + uiTextComponents2Json(); |
231 | 233 | } |
232 | 234 |
|
233 | 235 | @javax.annotation.Nullable |
@@ -279,7 +281,7 @@ private void json2UIComponents(String json) { |
279 | 281 | try { |
280 | 282 | Map<String, String> map = JsonUtils.fromJson(json, HashMap.class); |
281 | 283 | if (map != null) { |
282 | | - ApplicationManager.getApplication().invokeLater(() -> { |
| 284 | + UIUtil.invokeLaterIfNeeded(() -> { |
283 | 285 | intermediateState = true; |
284 | 286 | try { |
285 | 287 | if (map.containsKey("appId")) { |
|
0 commit comments