|
14 | 14 | import com.intellij.ui.SimpleListCellRenderer; |
15 | 15 | import com.intellij.util.ui.UIUtil; |
16 | 16 | import com.microsoft.azure.toolkit.ide.common.store.AzureConfigInitializer; |
17 | | -import com.microsoft.azure.toolkit.intellij.connector.Password; |
| 17 | +import com.microsoft.azure.toolkit.intellij.common.AzureComboBox; |
18 | 18 | import com.microsoft.azure.toolkit.intellij.connector.database.component.PasswordSaveComboBox; |
19 | 19 | import com.microsoft.azure.toolkit.lib.Azure; |
20 | 20 | import com.microsoft.azure.toolkit.lib.AzureConfiguration; |
|
31 | 31 | import org.jetbrains.annotations.NotNull; |
32 | 32 |
|
33 | 33 | import javax.annotation.Nonnull; |
34 | | -import javax.swing.ComboBoxModel; |
35 | | -import javax.swing.DefaultComboBoxModel; |
36 | | -import javax.swing.JCheckBox; |
37 | | -import javax.swing.JComboBox; |
38 | | -import javax.swing.JComponent; |
39 | | -import javax.swing.JLabel; |
40 | | -import javax.swing.JList; |
41 | | -import javax.swing.JPanel; |
42 | | -import javax.swing.JTextPane; |
43 | | -import java.awt.Dimension; |
| 34 | +import javax.swing.*; |
| 35 | +import java.awt.*; |
44 | 36 | import java.awt.event.ItemEvent; |
45 | | -import java.util.Arrays; |
46 | 37 | import java.util.Objects; |
47 | 38 |
|
| 39 | +import static com.microsoft.azure.toolkit.intellij.common.AzureBundle.message; |
48 | 40 | import static com.microsoft.azuretools.telemetry.TelemetryConstants.ACCOUNT; |
49 | 41 | import static com.microsoft.azuretools.telemetry.TelemetryConstants.SIGNOUT; |
50 | | -import static com.microsoft.azure.toolkit.intellij.common.AzureBundle.message; |
51 | 42 |
|
52 | 43 |
|
53 | 44 | @Slf4j |
@@ -101,10 +92,7 @@ public void setData(AzureConfiguration config) { |
101 | 92 | //ignore |
102 | 93 | funcCoreToolsPath.setValue(config.getFunctionCoreToolsPath()); |
103 | 94 | } |
104 | | - |
105 | | - savePasswordComboBox.setValue(Arrays.stream(Password.SaveType.values()) |
106 | | - .filter(e -> StringUtils.equals(e.name(), config.getDatabasePasswordSaveType())).findAny() |
107 | | - .orElse(Password.SaveType.UNTIL_RESTART)); |
| 95 | + savePasswordComboBox.setValue(new AzureComboBox.ItemReference<>(config.getDatabasePasswordSaveType().toLowerCase(), e -> e.name().toLowerCase())); |
108 | 96 | allowTelemetryCheckBox.setSelected(config.getTelemetryEnabled()); |
109 | 97 |
|
110 | 98 | azureEnvironmentComboBox.setSelectedItem(ObjectUtils.firstNonNull(AzureEnvironmentUtils.stringToAzureEnvironment(config.getCloud()), |
@@ -135,11 +123,11 @@ private void displayDescriptionForAzureEnv() { |
135 | 123 | azureEnvDesc.setIcon(AllIcons.General.Information); |
136 | 124 | } else { |
137 | 125 | setTextToLabel(azureEnvDesc, |
138 | | - String.format("You are currently signed in with environment: %s, your change will sign out your account.", currentEnvStr)); |
| 126 | + String.format("You are currently signed in to environment: %s, your change will sign out your account.", currentEnvStr)); |
139 | 127 | azureEnvDesc.setIcon(AllIcons.General.Warning); |
140 | 128 | } |
141 | 129 | } else { |
142 | | - setTextToLabel(azureEnvDesc, "You are currently not signed, the environment will be applied when you sign in next time."); |
| 130 | + setTextToLabel(azureEnvDesc, "You are currently not signed in, the environment will be applied when you sign in next time."); |
143 | 131 | azureEnvDesc.setIcon(AllIcons.General.Warning); |
144 | 132 | } |
145 | 133 | } |
@@ -181,7 +169,7 @@ public boolean doOKAction() { |
181 | 169 | config.setUserAgent(userAgent); |
182 | 170 | CommonSettings.setUserAgent(config.getUserAgent()); |
183 | 171 | // apply changes |
184 | | - |
| 172 | + this.originalData = config; |
185 | 173 | // we need to get rid of AuthMethodManager, using az.azure_account |
186 | 174 | if (AuthMethodManager.getInstance().isSignedIn()) { |
187 | 175 | final AuthMethodManager authMethodManager = AuthMethodManager.getInstance(); |
@@ -224,7 +212,9 @@ public boolean isModified() { |
224 | 212 |
|
225 | 213 | final AzureConfiguration data = getData(); |
226 | 214 |
|
227 | | - if (!StringUtils.equalsIgnoreCase(data.getCloud(), originalData.getCloud())) { |
| 215 | + final AzureEnvironment newEnv = AzureEnvironmentUtils.stringToAzureEnvironment(data.getCloud()); |
| 216 | + final AzureEnvironment oldEnv = AzureEnvironmentUtils.stringToAzureEnvironment(originalData.getCloud()); |
| 217 | + if (!Objects.equals(newEnv, oldEnv)) { |
228 | 218 | return true; |
229 | 219 | } |
230 | 220 |
|
|
0 commit comments