Skip to content

Commit 802c821

Browse files
committed
Restrct logic for config model in AppServiceComboBox
1 parent d285eff commit 802c821

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/appservice/AppServiceComboBox.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
import com.microsoft.azure.toolkit.intellij.common.AzureComboBox;
1313
import com.microsoft.azuretools.azurecommons.helpers.NotNull;
1414
import com.microsoft.azuretools.azurecommons.helpers.Nullable;
15-
import lombok.Getter;
16-
import lombok.Setter;
1715
import org.apache.commons.lang3.StringUtils;
1816
import rx.Subscription;
1917

@@ -26,8 +24,6 @@ public abstract class AppServiceComboBox<T extends AppServiceComboBoxModel> exte
2624
protected Project project;
2725
protected Subscription subscription;
2826

29-
@Getter
30-
@Setter
3127
private T configModel;
3228

3329
public AppServiceComboBox(final Project project) {
@@ -36,13 +32,18 @@ public AppServiceComboBox(final Project project) {
3632
this.setRenderer(new AppCombineBoxRender(this));
3733
}
3834

35+
public void setConfigModel(T configModel) {
36+
this.configModel = configModel;
37+
setValue(new ItemReference<>(item -> AppServiceComboBoxModel.isSameApp(item, configModel)));
38+
}
39+
3940
@NotNull
4041
@Override
4142
protected List<? extends T> loadItems() throws Exception {
4243
final List<T> items = loadAppServiceModels();
43-
if (super.getItemReference() != null && configModel != null && configModel.isNewCreateResource()) {
44-
final T target = items.stream().filter(model -> getItemReference().is(model)).findAny().orElse(null);
45-
if (target == null) {
44+
if (configModel != null && configModel.isNewCreateResource()) {
45+
final boolean exist = items.stream().anyMatch(item -> AppServiceComboBoxModel.isSameApp(item, configModel));
46+
if (!exist) {
4647
items.add(configModel);
4748
}
4849
}

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/common/AzureComboBox.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@ public void setValue(final ItemReference<T> val) {
121121
this.refreshValue();
122122
}
123123

124-
protected ItemReference<T> getItemReference() {
125-
return this.value instanceof ItemReference ? (ItemReference<T>) this.value : null;
126-
}
127-
128124
private void refreshValue() {
129125
if (Objects.equals(this.value, this.getSelectedItem())) {
130126
return;

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/function/runner/deploy/ui/FunctionDeploymentPanel.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ protected void resetFromConfig(@NotNull FunctionDeployConfiguration configuratio
135135
final FunctionAppComboBoxModel configModel = new FunctionAppComboBoxModel(configuration.getModel());
136136
appSettingsFunctionApp = configModel;
137137
functionAppComboBox.setConfigModel(configModel);
138-
functionAppComboBox.setValue(new AzureComboBox.ItemReference<>(value -> AppServiceComboBoxModel.isSameApp(value, configModel)));
139138
}
140139
functionAppComboBox.refreshItems();
141140
final Module previousModule = configuration.getModule();

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/webapp/runner/webappconfig/slimui/WebAppSlimSettingPanel.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ protected void resetFromConfig(@NotNull WebAppConfiguration configuration) {
187187
if (!StringUtils.isAllEmpty(configuration.getWebAppName(), configuration.getWebAppId())) {
188188
final WebAppComboBoxModel configModel = new WebAppComboBoxModel(configuration.getModel());
189189
comboBoxWebApp.setConfigModel(configModel);
190-
comboBoxWebApp.setValue(new AzureComboBox.ItemReference<>(value -> AppServiceComboBoxModel.isSameApp(value, configModel)));
191190
}
192191
comboBoxWebApp.refreshItems();
193192
if (configuration.getAzureArtifactType() != null) {

0 commit comments

Comments
 (0)