Search in sources :

Example 1 with WebAppComboBoxModel

use of com.microsoft.azure.toolkit.intellij.webapp.WebAppComboBoxModel in project azure-tools-for-java by Microsoft.

the class WebAppSlimSettingPanel method isAbleToDeployToRoot.

private boolean isAbleToDeployToRoot(final AzureArtifact azureArtifact) {
    final WebAppComboBoxModel selectedWebApp = getSelectedWebApp();
    if (selectedWebApp == null || azureArtifact == null) {
        return false;
    }
    final WebContainer webContainer = selectedWebApp.getRuntime().getWebContainer();
    final String packaging = AzureArtifactManager.getInstance(project).getPackaging(azureArtifact);
    final boolean isDeployingWar = StringUtils.equalsAnyIgnoreCase(packaging, MavenConstants.TYPE_WAR, "ear");
    return isDeployingWar && StringUtils.containsAnyIgnoreCase(webContainer.getValue(), "tomcat", "jboss");
}
Also used : WebAppComboBoxModel(com.microsoft.azure.toolkit.intellij.webapp.WebAppComboBoxModel) WebContainer(com.microsoft.azure.toolkit.lib.appservice.model.WebContainer)

Example 2 with WebAppComboBoxModel

use of com.microsoft.azure.toolkit.intellij.webapp.WebAppComboBoxModel in project azure-tools-for-java by Microsoft.

the class WebAppSlimSettingPanel method apply.

@Override
protected void apply(@NotNull WebAppConfiguration configuration) {
    final WebAppComboBoxModel selectedWebApp = getSelectedWebApp();
    if (selectedWebApp != null) {
        configuration.saveModel(selectedWebApp);
    }
    configuration.saveArtifact(comboBoxArtifact.getValue());
    configuration.setDeployToSlot(chkDeployToSlot.isSelected());
    configuration.setSlotPanelVisible(slotDecorator.isExpanded());
    chkToRoot.setVisible(isAbleToDeployToRoot(comboBoxArtifact.getValue()));
    toggleSlotPanel(configuration.isDeployToSlot() && selectedWebApp != null);
    if (chkDeployToSlot.isSelected()) {
        configuration.setDeployToSlot(true);
        configuration.setSlotName(cbxSlotName.getSelectedItem() == null ? "" : cbxSlotName.getSelectedItem().toString());
        if (rbtNewSlot.isSelected()) {
            configuration.setSlotName(Constants.CREATE_NEW_SLOT);
            configuration.setNewSlotName(txtNewSlotName.getText());
            configuration.setNewSlotConfigurationSource((String) cbxSlotConfigurationSource.getSelectedItem());
        }
    } else {
        configuration.setDeployToSlot(false);
    }
    configuration.setDeployToRoot(chkToRoot.isVisible() && chkToRoot.isSelected());
    configuration.setOpenBrowserAfterDeployment(chkOpenBrowser.isSelected());
    // hot fix, to avoid similar cases, prefer to refactor this code with common factory
    if (ApplicationManager.getApplication().isDispatchThread()) {
        syncBeforeRunTasks(comboBoxArtifact.getValue(), configuration);
    } else {
        ApplicationManager.getApplication().invokeLater(() -> syncBeforeRunTasks(comboBoxArtifact.getValue(), configuration));
    }
}
Also used : WebAppComboBoxModel(com.microsoft.azure.toolkit.intellij.webapp.WebAppComboBoxModel)

Example 3 with WebAppComboBoxModel

use of com.microsoft.azure.toolkit.intellij.webapp.WebAppComboBoxModel in project azure-tools-for-java by Microsoft.

the class WebAppSlimSettingPanel method resetFromConfig.

@Override
protected void resetFromConfig(@NotNull WebAppConfiguration configuration) {
    if (!StringUtils.isAllEmpty(configuration.getWebAppName(), configuration.getWebAppId())) {
        final WebAppComboBoxModel configModel = new WebAppComboBoxModel(configuration.getModel());
        comboBoxWebApp.setConfigModel(configModel);
    }
    if (configuration.getAzureArtifactType() != null) {
        final AzureArtifact artifact = AzureArtifactManager.getInstance(this.project).getAzureArtifactById(configuration.getAzureArtifactType(), configuration.getArtifactIdentifier());
        comboBoxArtifact.setArtifact(artifact);
    }
    if (configuration.getWebAppId() != null && configuration.isDeployToSlot()) {
        toggleSlotPanel(true);
        chkDeployToSlot.setSelected(true);
        final boolean useNewDeploymentSlot = StringUtils.equals(configuration.getSlotName(), Constants.CREATE_NEW_SLOT);
        rbtNewSlot.setSelected(useNewDeploymentSlot);
        rbtExistingSlot.setSelected(!useNewDeploymentSlot);
        toggleSlotType(!useNewDeploymentSlot);
        txtNewSlotName.setText(configuration.getNewSlotName());
        cbxSlotName.addItem(useNewDeploymentSlot ? configuration.getNewSlotName() : configuration.getSlotName());
        cbxSlotConfigurationSource.addItem(configuration.getNewSlotConfigurationSource());
    } else {
        toggleSlotPanel(false);
        chkDeployToSlot.setSelected(false);
    }
    final DateFormat df = new SimpleDateFormat("yyMMddHHmmss");
    final String defaultSlotName = StringUtils.isEmpty(configuration.getNewSlotName()) ? String.format(DEFAULT_SLOT_NAME, df.format(new Date())) : configuration.getNewSlotName();
    txtNewSlotName.setText(defaultSlotName);
    chkToRoot.setSelected(configuration.isDeployToRoot());
    chkOpenBrowser.setSelected(configuration.isOpenBrowserAfterDeployment());
    slotDecorator.setOn(configuration.isSlotPanelVisible());
}
Also used : WebAppComboBoxModel(com.microsoft.azure.toolkit.intellij.webapp.WebAppComboBoxModel) AzureArtifact(com.microsoft.azure.toolkit.intellij.common.AzureArtifact) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Aggregations

WebAppComboBoxModel (com.microsoft.azure.toolkit.intellij.webapp.WebAppComboBoxModel)3 AzureArtifact (com.microsoft.azure.toolkit.intellij.common.AzureArtifact)1 WebContainer (com.microsoft.azure.toolkit.lib.appservice.model.WebContainer)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1