Skip to content

Commit bd1642f

Browse files
committed
Migrate to web app deployment configuration panel in run configuration panel
1 parent 3474843 commit bd1642f

File tree

5 files changed

+170
-552
lines changed

5 files changed

+170
-552
lines changed

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

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
import com.intellij.ui.HideableDecorator;
1212
import com.intellij.ui.HyperlinkLabel;
1313
import com.microsoft.azure.toolkit.ide.appservice.model.AzureArtifactConfig;
14+
import com.microsoft.azure.toolkit.ide.appservice.model.DeploymentSlotConfig;
1415
import com.microsoft.azure.toolkit.ide.appservice.webapp.model.WebAppConfig;
1516
import com.microsoft.azure.toolkit.ide.appservice.webapp.model.WebAppDeployRunConfigurationModel;
1617
import com.microsoft.azure.toolkit.intellij.common.AzureArtifact;
1718
import com.microsoft.azure.toolkit.intellij.common.AzureArtifactComboBox;
1819
import com.microsoft.azure.toolkit.intellij.common.AzureArtifactManager;
1920
import com.microsoft.azure.toolkit.intellij.common.AzureArtifactType;
21+
import com.microsoft.azure.toolkit.intellij.common.AzureComboBox;
2022
import com.microsoft.azure.toolkit.intellij.common.AzureFormPanel;
2123
import com.microsoft.azure.toolkit.lib.Azure;
2224
import com.microsoft.azure.toolkit.lib.appservice.AzureWebApp;
@@ -38,7 +40,10 @@
3840
import java.awt.event.FocusEvent;
3941
import java.awt.event.FocusListener;
4042
import java.awt.event.MouseEvent;
43+
import java.text.DateFormat;
44+
import java.text.SimpleDateFormat;
4145
import java.util.Arrays;
46+
import java.util.Date;
4247
import java.util.List;
4348
import java.util.Objects;
4449
import java.util.Optional;
@@ -82,14 +87,15 @@ public class WebAppDeployConfigurationPanel extends JPanel implements AzureFormP
8287
public WebAppDeployConfigurationPanel(@NotNull Project project) {
8388
super();
8489
this.project = project;
90+
$$$setupUI$$$();
91+
comboBoxWebApp.addItemListener(e -> loadDeploymentSlot(getSelectedWebApp()));
8592

8693
final ButtonGroup slotButtonGroup = new ButtonGroup();
8794
slotButtonGroup.add(rbtNewSlot);
8895
slotButtonGroup.add(rbtExistingSlot);
89-
rbtExistingSlot.addActionListener(e -> toggleSlotType(true));
90-
rbtNewSlot.addActionListener(e -> toggleSlotType(false));
91-
92-
chkDeployToSlot.addActionListener(e -> toggleSlotPanel(chkDeployToSlot.isSelected()));
96+
rbtExistingSlot.addItemListener(e -> toggleSlotType(true));
97+
rbtNewSlot.addItemListener(e -> toggleSlotType(false));
98+
chkDeployToSlot.addItemListener(e -> toggleSlotPanel(chkDeployToSlot.isSelected()));
9399

94100
final Icon informationIcon = AllIcons.General.ContextHelp;
95101
btnSlotHover.setIcon(informationIcon);
@@ -120,6 +126,9 @@ public void focusLost(FocusEvent focusEvent) {
120126
lblArtifact.setLabelFor(comboBoxArtifact);
121127
lblWebApp.setLabelFor(comboBoxWebApp);
122128

129+
final DateFormat df = new SimpleDateFormat("yyMMddHHmmss");
130+
txtNewSlotName.setText(String.format(DEFAULT_SLOT_NAME, df.format(new Date())));
131+
123132
slotDecorator = new HideableDecorator(pnlSlotHolder, DEPLOYMENT_SLOT, true);
124133
slotDecorator.setContentComponent(pnlSlot);
125134
}
@@ -173,7 +182,6 @@ private void createUIComponents() {
173182
lblNewSlot.addHyperlinkListener(e -> rbtNewSlot.doClick());
174183

175184
comboBoxWebApp = new WebAppComboBox(project);
176-
comboBoxWebApp.addItemListener(e -> loadDeploymentSlot(getSelectedWebApp()));
177185
comboBoxWebApp.refreshItems();
178186

179187
comboBoxArtifact = new AzureArtifactComboBox(this.project);
@@ -224,7 +232,25 @@ public void setValue(WebAppDeployRunConfigurationModel data) {
224232
.getAzureArtifactById(AzureArtifactType.valueOf(config.getArtifactType()), config.getArtifactIdentifier()))
225233
.ifPresent(artifact -> comboBoxArtifact.setArtifact(artifact));
226234
// web app
227-
Optional.ofNullable(data.getWebAppConfig()).ifPresent(webApp -> comboBoxWebApp.setValue(webApp));
235+
Optional.ofNullable(data.getWebAppConfig()).ifPresent(webApp -> {
236+
comboBoxWebApp.setConfigModel(webApp);
237+
comboBoxWebApp.setValue(new AzureComboBox.ItemReference<>(item -> WebAppConfig.isSameApp(item, webApp)));
238+
toggleSlotPanel(webApp.getDeploymentSlot() != null);
239+
Optional.ofNullable(webApp.getDeploymentSlot()).ifPresent(slot -> {
240+
chkDeployToSlot.setSelected(true);
241+
rbtNewSlot.setSelected(slot.isNewCreate());
242+
rbtExistingSlot.setSelected(!slot.isNewCreate());
243+
toggleSlotType(!slot.isNewCreate());
244+
if (slot.isNewCreate()) {
245+
txtNewSlotName.setText(slot.getName());
246+
cbxSlotConfigurationSource.addItem(slot.getConfigurationSource());
247+
cbxSlotConfigurationSource.setSelectedItem(slot.getConfigurationSource());
248+
} else {
249+
cbxSlotName.addItem(slot.getName());
250+
cbxSlotName.setSelectedItem(slot.getName());
251+
}
252+
});
253+
});
228254
// configuration
229255
chkToRoot.setSelected(data.isDeployToRoot());
230256
chkOpenBrowser.setSelected(data.isOpenBrowserAfterDeployment());
@@ -233,10 +259,19 @@ public void setValue(WebAppDeployRunConfigurationModel data) {
233259
@Override
234260
public WebAppDeployRunConfigurationModel getValue() {
235261
final AzureArtifact artifact = comboBoxArtifact.getValue();
236-
final AzureArtifactConfig artifactConfig = AzureArtifactConfig.builder().artifactType(artifact.getType().name())
237-
.artifactIdentifier(AzureArtifactManager.getInstance(project).getArtifactIdentifier(artifact)).build();
262+
final AzureArtifactConfig artifactConfig = artifact == null ? null :
263+
AzureArtifactConfig.builder().artifactType(artifact.getType().name())
264+
.artifactIdentifier(AzureArtifactManager.getInstance(project).getArtifactIdentifier(artifact)).build();
265+
final DeploymentSlotConfig slotConfig = chkDeployToSlot.isSelected() ? rbtExistingSlot.isSelected() ?
266+
DeploymentSlotConfig.builder().newCreate(false).name(cbxSlotName.getSelectedItem().toString()).build() :
267+
DeploymentSlotConfig.builder().newCreate(true).name(txtNewSlotName.getText())
268+
.configurationSource(cbxSlotConfigurationSource.getSelectedItem().toString()).build() : null;
269+
final WebAppConfig webAppConfig = comboBoxWebApp.getValue();
270+
if (webAppConfig != null) {
271+
webAppConfig.setDeploymentSlot(slotConfig);
272+
}
238273
return WebAppDeployRunConfigurationModel.builder()
239-
.webAppConfig(comboBoxWebApp.getValue())
274+
.webAppConfig(webAppConfig)
240275
.artifactConfig(artifactConfig)
241276
.openBrowserAfterDeployment(chkOpenBrowser.isSelected())
242277
.deployToRoot(chkToRoot.isSelected())

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

Lines changed: 0 additions & 17 deletions
This file was deleted.

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

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)