Search in sources :

Example 6 with Runtime

use of com.microsoft.azure.toolkit.lib.appservice.model.Runtime in project azure-tools-for-java by Microsoft.

the class AppServiceInfoAdvancedPanel method onRuntimeChanged.

private void onRuntimeChanged(final ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED || e.getStateChange() == ItemEvent.DESELECTED) {
        final Runtime runtime = (Runtime) e.getItem();
        final OperatingSystem operatingSystem = Objects.isNull(runtime) ? null : runtime.getOperatingSystem();
        this.selectorServicePlan.setOperatingSystem(operatingSystem);
    }
}
Also used : OperatingSystem(com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem) Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime)

Example 7 with Runtime

use of com.microsoft.azure.toolkit.lib.appservice.model.Runtime in project azure-tools-for-java by Microsoft.

the class WebAppBasePropertyViewPresenter method generateProperty.

protected <T extends AppServiceBaseEntity> WebAppProperty generateProperty(@Nonnull final IAppService<T> appService, @Nonnull final IAppServicePlan plan) {
    final AppServiceBaseEntity appServiceEntity = appService.entity();
    final AppServicePlanEntity planEntity = plan.entity();
    final Map<String, String> appSettingsMap = appServiceEntity.getAppSettings();
    final Map<String, Object> propertyMap = new HashMap<>();
    propertyMap.put(KEY_NAME, appServiceEntity.getName());
    propertyMap.put(KEY_RESOURCE_GRP, appServiceEntity.getResourceGroup());
    propertyMap.put(KEY_LOCATION, appServiceEntity.getRegion().getLabel());
    propertyMap.put(KEY_SUB_ID, appService.subscriptionId());
    propertyMap.put(KEY_STATUS, appService.state());
    propertyMap.put(KEY_PLAN, plan.name());
    propertyMap.put(KEY_URL, appService.hostName());
    final PricingTier pricingTier = planEntity.getPricingTier();
    propertyMap.put(KEY_PRICING, String.format("%s_%s", pricingTier.getTier(), pricingTier.getSize()));
    final Runtime runtime = appService.getRuntime();
    final JavaVersion javaVersion = runtime.getJavaVersion();
    if (javaVersion != null && ObjectUtils.notEqual(javaVersion, JavaVersion.OFF)) {
        propertyMap.put(KEY_JAVA_VERSION, javaVersion.getValue());
        propertyMap.put(KEY_JAVA_CONTAINER, runtime.getWebContainer().getValue());
    }
    propertyMap.put(KEY_OPERATING_SYS, runtime.getOperatingSystem());
    propertyMap.put(KEY_APP_SETTING, appSettingsMap);
    return new WebAppProperty(propertyMap);
}
Also used : PricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier) Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) AppServiceBaseEntity(com.microsoft.azure.toolkit.lib.appservice.entity.AppServiceBaseEntity) AppServicePlanEntity(com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity) HashMap(java.util.HashMap) JavaVersion(com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion) WebAppProperty(com.microsoft.azuretools.core.mvp.ui.webapp.WebAppProperty)

Example 8 with Runtime

use of com.microsoft.azure.toolkit.lib.appservice.model.Runtime in project azure-tools-for-java by Microsoft.

the class AppServiceInfoBasicPanel method getData.

@SneakyThrows
@Override
public T getData() {
    final String name = this.textName.getValue();
    final Runtime platform = this.selectorRuntime.getValue();
    final AzureArtifact artifact = this.selectorApplication.getValue();
    final T result = (T) (this.config == null ? initConfig() : this.config).toBuilder().build();
    result.setName(name);
    result.setRuntime(platform);
    if (Objects.nonNull(artifact)) {
        final AzureArtifactManager manager = AzureArtifactManager.getInstance(this.project);
        final String path = manager.getFileForDeployment(this.selectorApplication.getValue());
        result.setApplication(Paths.get(path));
    }
    this.config = result;
    return result;
}
Also used : Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) AzureArtifact(com.microsoft.azure.toolkit.intellij.common.AzureArtifact) AzureArtifactManager(com.microsoft.azure.toolkit.intellij.common.AzureArtifactManager) SneakyThrows(lombok.SneakyThrows)

Example 9 with Runtime

use of com.microsoft.azure.toolkit.lib.appservice.model.Runtime in project azure-tools-for-java by Microsoft.

the class AppServiceInfoAdvancedPanel method getData.

@Override
public T getData() {
    final Subscription subscription = this.selectorSubscription.getValue();
    final ResourceGroup resourceGroup = this.selectorGroup.getValue();
    final String name = this.textName.getValue();
    final Runtime runtime = this.selectorRuntime.getValue();
    final Region region = this.selectorRegion.getValue();
    final AppServicePlanEntity servicePlan = this.selectorServicePlan.getValue();
    final AzureArtifact artifact = this.selectorApplication.getValue();
    final T config = supplier.get();
    config.setSubscription(subscription);
    config.setResourceGroup(resourceGroup);
    config.setName(name);
    config.setRuntime(runtime);
    config.setRegion(region);
    config.setServicePlan(servicePlan);
    if (Objects.nonNull(artifact)) {
        final AzureArtifactManager manager = AzureArtifactManager.getInstance(this.project);
        final String path = manager.getFileForDeployment(this.selectorApplication.getValue());
        config.setApplication(Paths.get(path));
    }
    return config;
}
Also used : Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) AzureArtifact(com.microsoft.azure.toolkit.intellij.common.AzureArtifact) AppServicePlanEntity(com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity) Region(com.microsoft.azure.toolkit.lib.common.model.Region) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) AzureArtifactManager(com.microsoft.azure.toolkit.intellij.common.AzureArtifactManager) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)

Example 10 with Runtime

use of com.microsoft.azure.toolkit.lib.appservice.model.Runtime in project azure-tools-for-java by Microsoft.

the class AppServiceInfoAdvancedPanel method init.

private void init() {
    final String date = DATE_FORMAT.format(new Date());
    final String defaultWebAppName = String.format("app-%s-%s", this.project.getName(), date);
    this.textName.setValue(defaultWebAppName);
    this.textSku.setBorder(JBUI.Borders.emptyLeft(5));
    this.textSku.setText(NOT_APPLICABLE);
    this.selectorServicePlan.addItemListener(this::onServicePlanChanged);
    this.selectorSubscription.addItemListener(this::onSubscriptionChanged);
    this.selectorRuntime.addItemListener(this::onRuntimeChanged);
    this.selectorRegion.addItemListener(this::onRegionChanged);
    this.textName.setRequired(true);
    this.selectorServicePlan.setRequired(true);
    this.selectorSubscription.setRequired(true);
    this.selectorRuntime.setRequired(true);
    this.selectorRegion.setRequired(true);
    this.lblSubscription.setLabelFor(selectorSubscription);
    this.lblResourceGroup.setLabelFor(selectorGroup);
    this.lblName.setLabelFor(textName);
    this.lblPlatform.setLabelFor(selectorRuntime);
    this.lblRegion.setLabelFor(selectorRegion);
    this.lblAppServicePlan.setLabelFor(selectorServicePlan);
    this.lblArtifact.setLabelFor(selectorApplication);
    this.selectorApplication.setFileFilter(virtualFile -> {
        final String ext = FileNameUtils.getExtension(virtualFile.getPath());
        final Runtime runtime = this.selectorRuntime.getValue();
        return StringUtils.isNotBlank(ext) && isSupportedArtifactType(runtime, ext);
    });
}
Also used : Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) Date(java.util.Date)

Aggregations

Runtime (com.microsoft.azure.toolkit.lib.appservice.model.Runtime)12 PricingTier (com.microsoft.azure.toolkit.lib.appservice.model.PricingTier)4 HashMap (java.util.HashMap)4 JavaVersion (com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion)3 OperatingSystem (com.microsoft.azure.toolkit.lib.appservice.model.OperatingSystem)3 Point (org.eclipse.swt.graphics.Point)3 AzureArtifact (com.microsoft.azure.toolkit.intellij.common.AzureArtifact)2 AzureArtifactManager (com.microsoft.azure.toolkit.intellij.common.AzureArtifactManager)2 AppServicePlanEntity (com.microsoft.azure.toolkit.lib.appservice.entity.AppServicePlanEntity)2 WebContainer (com.microsoft.azure.toolkit.lib.appservice.model.WebContainer)2 IWebApp (com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)2 Region (com.microsoft.azure.toolkit.lib.common.model.Region)2 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)2 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)2 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 AppServiceInfoAdvancedPanel (com.microsoft.azure.toolkit.intellij.appservice.AppServiceInfoAdvancedPanel)1 AppServiceMonitorPanel (com.microsoft.azure.toolkit.intellij.appservice.AppServiceMonitorPanel)1 Azure (com.microsoft.azure.toolkit.lib.Azure)1 AzureAppService (com.microsoft.azure.toolkit.lib.appservice.AzureAppService)1 AppServiceBaseEntity (com.microsoft.azure.toolkit.lib.appservice.entity.AppServiceBaseEntity)1