Search in sources :

Example 1 with SpringCloudDeploymentConfig

use of com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudDeploymentConfig in project azure-tools-for-java by Microsoft.

the class SpringCloudAppConfigPanel method getData.

@Contract("_->_")
public SpringCloudAppConfig getData(@Nonnull SpringCloudAppConfig appConfig) {
    // get config from form
    final SpringCloudDeploymentConfig deploymentConfig = appConfig.getDeployment();
    final String javaVersion = this.useJava11.isSelected() ? SpringCloudJavaVersion.JAVA_11 : SpringCloudJavaVersion.JAVA_8;
    appConfig.setIsPublic("disable".equals(this.toggleEndpoint.getActionCommand()));
    deploymentConfig.setRuntimeVersion(javaVersion);
    deploymentConfig.setEnablePersistentStorage("disable".equals(this.toggleStorage.getActionCommand()));
    deploymentConfig.setCpu(numCpu.getItem());
    deploymentConfig.setMemoryInGB(numMemory.getItem());
    deploymentConfig.setInstanceCount(numInstance.getValue());
    deploymentConfig.setJvmOptions(Optional.ofNullable(this.txtJvmOptions.getText()).map(String::trim).orElse(""));
    deploymentConfig.setEnvironment(Optional.ofNullable(envTable.getEnvironmentVariables()).orElse(new HashMap<>()));
    return appConfig;
}
Also used : HashMap(java.util.HashMap) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) SpringCloudDeploymentConfig(com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudDeploymentConfig) Contract(org.jetbrains.annotations.Contract)

Example 2 with SpringCloudDeploymentConfig

use of com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudDeploymentConfig in project azure-tools-for-java by Microsoft.

the class SpringCloudAppConfigPanel method setData.

@Override
public synchronized void setData(SpringCloudAppConfig config) {
    this.originalConfig = config;
    final SpringCloudDeploymentConfig deployment = config.getDeployment();
    this.toggleStorage(deployment.getEnablePersistentStorage());
    this.toggleEndpoint(config.getIsPublic());
    final boolean java11 = StringUtils.equalsIgnoreCase(deployment.getRuntimeVersion(), SpringCloudJavaVersion.JAVA_11);
    this.useJava11.setSelected(java11);
    this.useJava8.setSelected(!java11);
    this.txtJvmOptions.setText(deployment.getJvmOptions());
    final Map<String, String> env = deployment.getEnvironment();
    this.envTable.setEnvironmentVariables(ObjectUtils.firstNonNull(env, Collections.emptyMap()));
    this.numCpu.setItem(Optional.ofNullable(deployment.getCpu()).orElse(1));
    this.numMemory.setItem(Optional.ofNullable(deployment.getMemoryInGB()).orElse(1));
    this.numInstance.setValue(Optional.ofNullable(deployment.getInstanceCount()).orElse(1));
}
Also used : AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) SpringCloudDeploymentConfig(com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudDeploymentConfig)

Example 3 with SpringCloudDeploymentConfig

use of com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudDeploymentConfig in project azure-tools-for-java by Microsoft.

the class SpringCloudDeploymentConfigurationPanel method getData.

public SpringCloudAppConfig getData(SpringCloudAppConfig appConfig) {
    final SpringCloudDeploymentConfig deploymentConfig = appConfig.getDeployment();
    appConfig.setSubscriptionId(this.selectorSubscription.getValue().getId());
    appConfig.setClusterName(this.selectorCluster.getValue().name());
    appConfig.setAppName(this.selectorApp.getValue().name());
    final AzureArtifact artifact = this.selectorArtifact.getValue();
    deploymentConfig.setArtifact(new WrappedAzureArtifact(this.selectorArtifact.getValue(), this.project));
    return appConfig;
}
Also used : AzureArtifact(com.microsoft.azure.toolkit.intellij.common.AzureArtifact) SpringCloudDeploymentConfig(com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudDeploymentConfig)

Example 4 with SpringCloudDeploymentConfig

use of com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudDeploymentConfig in project azure-tools-for-java by Microsoft.

the class SpringCloudDeploymentConfigurationPanel method setData.

public synchronized void setData(SpringCloudAppConfig appConfig) {
    final SpringCloudCluster cluster = Azure.az(AzureSpringCloud.class).cluster(appConfig.getClusterName());
    if (Objects.nonNull(cluster) && !cluster.app(appConfig.getAppName()).exists()) {
        this.selectorApp.addLocalItem(cluster.app(appConfig));
    }
    final SpringCloudDeploymentConfig deploymentConfig = appConfig.getDeployment();
    final AzureArtifactManager manager = AzureArtifactManager.getInstance(this.project);
    Optional.ofNullable(deploymentConfig.getArtifact()).map(a -> ((WrappedAzureArtifact) a)).ifPresent((a -> this.selectorArtifact.setArtifact(a.getArtifact())));
    Optional.ofNullable(appConfig.getSubscriptionId()).ifPresent((id -> this.selectorSubscription.setValue(new ItemReference<>(id, Subscription::getId))));
    Optional.ofNullable(appConfig.getClusterName()).ifPresent((id -> this.selectorCluster.setValue(new ItemReference<>(id, SpringCloudCluster::name))));
    Optional.ofNullable(appConfig.getAppName()).ifPresent((id -> this.selectorApp.setValue(new ItemReference<>(id, SpringCloudApp::name))));
}
Also used : SpringCloudCluster(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudCluster) FileNameUtils(org.apache.commons.compress.utils.FileNameUtils) Azure(com.microsoft.azure.toolkit.lib.Azure) Setter(lombok.Setter) Arrays(java.util.Arrays) AzureFormInput(com.microsoft.azure.toolkit.lib.common.form.AzureFormInput) SpringCloudDeploymentConfig(com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudDeploymentConfig) DataContext(com.intellij.openapi.actionSystem.DataContext) Getter(lombok.Getter) SpringCloudAppComboBox(com.microsoft.azure.toolkit.intellij.springcloud.component.SpringCloudAppComboBox) SpringCloudAppConfig(com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudAppConfig) StringUtils(org.apache.commons.lang3.StringUtils) SpringCloudClusterComboBox(com.microsoft.azure.toolkit.intellij.springcloud.component.SpringCloudClusterComboBox) Project(com.intellij.openapi.project.Project) AzureArtifactManager(com.microsoft.azure.toolkit.intellij.common.AzureArtifactManager) AzureArtifactComboBox(com.microsoft.azure.toolkit.intellij.common.AzureArtifactComboBox) AzureFormPanel(com.microsoft.azure.toolkit.intellij.common.AzureFormPanel) DataManager(com.intellij.ide.DataManager) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) ItemEvent(java.awt.event.ItemEvent) AzureArtifact(com.microsoft.azure.toolkit.intellij.common.AzureArtifact) SpringCloudApp(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudApp) BeforeRunTaskUtils(com.microsoft.intellij.util.BeforeRunTaskUtils) AzureSpringCloud(com.microsoft.azure.toolkit.lib.springcloud.AzureSpringCloud) Objects(java.util.Objects) List(java.util.List) ItemReference(com.microsoft.azure.toolkit.intellij.common.AzureComboBox.ItemReference) Optional(java.util.Optional) ConfigurationSettingsEditorWrapper(com.intellij.execution.impl.ConfigurationSettingsEditorWrapper) SubscriptionComboBox(com.microsoft.azure.toolkit.intellij.common.component.SubscriptionComboBox) javax.swing(javax.swing) SpringCloudCluster(com.microsoft.azure.toolkit.lib.springcloud.SpringCloudCluster) SpringCloudDeploymentConfig(com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudDeploymentConfig) AzureArtifactManager(com.microsoft.azure.toolkit.intellij.common.AzureArtifactManager) AzureSpringCloud(com.microsoft.azure.toolkit.lib.springcloud.AzureSpringCloud)

Aggregations

SpringCloudDeploymentConfig (com.microsoft.azure.toolkit.lib.springcloud.config.SpringCloudDeploymentConfig)4 AzureArtifact (com.microsoft.azure.toolkit.intellij.common.AzureArtifact)2 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)2 ConfigurationSettingsEditorWrapper (com.intellij.execution.impl.ConfigurationSettingsEditorWrapper)1 DataManager (com.intellij.ide.DataManager)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 Project (com.intellij.openapi.project.Project)1 AzureArtifactComboBox (com.microsoft.azure.toolkit.intellij.common.AzureArtifactComboBox)1 AzureArtifactManager (com.microsoft.azure.toolkit.intellij.common.AzureArtifactManager)1 ItemReference (com.microsoft.azure.toolkit.intellij.common.AzureComboBox.ItemReference)1 AzureFormPanel (com.microsoft.azure.toolkit.intellij.common.AzureFormPanel)1 SubscriptionComboBox (com.microsoft.azure.toolkit.intellij.common.component.SubscriptionComboBox)1 SpringCloudAppComboBox (com.microsoft.azure.toolkit.intellij.springcloud.component.SpringCloudAppComboBox)1 SpringCloudClusterComboBox (com.microsoft.azure.toolkit.intellij.springcloud.component.SpringCloudClusterComboBox)1 Azure (com.microsoft.azure.toolkit.lib.Azure)1 AzureFormInput (com.microsoft.azure.toolkit.lib.common.form.AzureFormInput)1 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)1 AzureSpringCloud (com.microsoft.azure.toolkit.lib.springcloud.AzureSpringCloud)1 SpringCloudApp (com.microsoft.azure.toolkit.lib.springcloud.SpringCloudApp)1 SpringCloudCluster (com.microsoft.azure.toolkit.lib.springcloud.SpringCloudCluster)1