Search in sources :

Example 1 with Region

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

the class PublishWebAppOnLinuxDialog method getSelectedLocation.

private Region getSelectedLocation() {
    Region loc = null;
    int locIndex = cpNew.cbLocation.getSelectionIndex();
    if (locationList != null && locIndex >= 0 && locIndex < locationList.size()) {
        loc = locationList.get(locIndex);
    }
    return loc;
}
Also used : Region(com.microsoft.azure.toolkit.lib.common.model.Region) Point(org.eclipse.swt.graphics.Point)

Example 2 with Region

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

the class PublishWebAppOnLinuxDialog method apply.

private void apply() {
    model.setDockerFilePath(cpAcr.getDockerfilePath());
    // set ACR info
    model.setPrivateRegistryImageSetting(new PrivateRegistryImageSetting(cpAcr.getServerUrl(), cpAcr.getUserName(), cpAcr.getPassword(), cpAcr.getImageTag(), cpAcr.getStartupFile()));
    // set target
    model.setTargetPath(targetPath);
    model.setTargetName(Paths.get(targetPath).getFileName().toString());
    // set web app info
    if (rdoExistingWebApp.getSelection()) {
        // existing web app
        model.setCreatingNewWebAppOnLinux(false);
        IWebApp selectedWebApp = getSelectedWebApp();
        if (selectedWebApp != null) {
            model.setWebAppId(selectedWebApp.id());
            model.setWebAppName(selectedWebApp.name());
            model.setSubscriptionId(selectedWebApp.subscriptionId());
            model.setResourceGroupName(selectedWebApp.resourceGroup());
        } else {
            model.setWebAppId(null);
            model.setWebAppName(null);
            model.setSubscriptionId(null);
            model.setResourceGroupName(null);
        }
    } else if (rdoNewWebApp.getSelection()) {
        // create new web app
        model.setCreatingNewWebAppOnLinux(true);
        model.setWebAppId("");
        model.setWebAppName(cpNew.txtAppName.getText());
        Subscription selectedSubscription = getSelectedSubscription();
        if (selectedSubscription != null) {
            model.setSubscriptionId(selectedSubscription.getId());
        }
        // resource group
        if (cpNew.rdoExistingResourceGroup.getSelection()) {
            // existing RG
            model.setCreatingNewResourceGroup(false);
            ResourceGroup selectedRg = getSelectedResourceGroup();
            if (selectedRg != null) {
                model.setResourceGroupName(selectedRg.getName());
            } else {
                model.setResourceGroupName(null);
            }
        } else if (cpNew.rdoNewResourceGroup.getSelection()) {
            // new RG
            model.setCreatingNewResourceGroup(true);
            model.setResourceGroupName(cpNew.txtNewResourceGroupName.getText());
        }
        // app service plan
        if (cpNew.rdoNewAppServicePlan.getSelection()) {
            model.setCreatingNewAppServicePlan(true);
            model.setAppServicePlanName(cpNew.txtAppServicePlanName.getText());
            Region selectedLocation = getSelectedLocation();
            if (selectedLocation != null) {
                model.setLocationName(selectedLocation.getLabel());
            } else {
                model.setLocationName(null);
            }
            PricingTier selectedPricingTier = getSelectedPricingTier();
            if (selectedPricingTier != null) {
                model.setPricingSkuTier(selectedPricingTier.getTier());
                model.setPricingSkuSize(selectedPricingTier.getSize());
            } else {
                model.setPricingSkuTier(null);
                model.setPricingSkuSize(null);
            }
        } else if (cpNew.rdoExistingAppServicePlan.getSelection()) {
            model.setCreatingNewAppServicePlan(false);
            IAppServicePlan selectedAsp = getSelectedAppServicePlan();
            if (selectedAsp != null) {
                model.setAppServicePlanId(selectedAsp.id());
            } else {
                model.setAppServicePlanId(null);
            }
        }
    }
}
Also used : PrivateRegistryImageSetting(com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting) PricingTier(com.microsoft.azure.toolkit.lib.appservice.model.PricingTier) IAppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan) Region(com.microsoft.azure.toolkit.lib.common.model.Region) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup) IWebApp(com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)

Example 3 with Region

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

the class AppServiceCreateDialog method fillRegions.

protected void fillRegions() {
    Subscription selectedSubscription = getSelectedSubscription();
    if (selectedSubscription == null) {
        return;
    }
    setComboRefreshingStatus(comboAppServicePlanLocation, true);
    Mono.fromCallable(() -> Azure.az(AzureAccount.class).listRegions(selectedSubscription.getId())).subscribeOn(Schedulers.boundedElastic()).subscribe(locl -> {
        if (locl != null) {
            binderAppServicePlanLocation = new ArrayList<>();
            DefaultLoader.getIdeHelper().invokeLater(() -> {
                for (int i = 0; i < locl.size(); i++) {
                    Region loc = locl.get(i);
                    comboAppServicePlanLocation.add(loc.getLabel());
                    binderAppServicePlanLocation.add(loc);
                    if (Objects.equals(loc, DEFAULT_REGION)) {
                        comboAppServicePlanLocation.select(i);
                    }
                }
                if (comboAppServicePlanLocation.getSelectionIndex() < 0 && comboAppServicePlanLocation.getItemCount() > 0) {
                    comboAppServicePlanLocation.select(0);
                }
                String aspLocation = CommonUtils.getPreference(ASP_CREATE_LOCATION);
                CommonUtils.selectComboIndex(comboAppServicePlanLocation, aspLocation);
            });
        }
    });
}
Also used : Region(com.microsoft.azure.toolkit.lib.common.model.Region) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) Point(org.eclipse.swt.graphics.Point)

Example 4 with Region

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

the class CreateDeploymentForm method doOKAction.

@Override
protected void doOKAction() {
    deploymentName = deploymentNameTextField.getText();
    final AzureString title = AzureOperationBundle.title("arm|deployment.deploy", deploymentName);
    AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, false, () -> {
        EventUtil.executeWithLog(TelemetryConstants.ARM, TelemetryConstants.CREATE_DEPLOYMENT, (operation -> {
            Subscription subs = (Subscription) subscriptionCb.getSelectedItem();
            com.microsoft.azure.management.Azure azure = AuthMethodManager.getInstance().getAzureClient(subs.getId());
            WithTemplate template;
            if (createNewRgButton.isSelected()) {
                rgName = rgNameTextFiled.getText();
                final Region region = (Region) regionCb.getSelectedItem();
                template = azure.deployments().define(deploymentName).withNewResourceGroup(rgNameTextFiled.getText(), com.microsoft.azure.management.resources.fluentcore.arm.Region.fromName(region.getName()));
            } else {
                ResourceGroup rg = (ResourceGroup) rgNameCb.getSelectedItem();
                List<ResourceEx<Deployment>> deployments = AzureMvpModel.getInstance().getDeploymentByRgName(subs.getId(), rg.getName());
                boolean isExist = deployments.parallelStream().anyMatch(deployment -> deployment.getResource().name().equals(deploymentName));
                if (isExist) {
                    throw new RuntimeException(DUPLICATED_DEPLOYMENT_NAME);
                }
                rgName = rg.getName();
                template = azure.deployments().define(deploymentName).withExistingResourceGroup(rg.getName());
            }
            String fileText = templateTextField.getText();
            String content = IOUtils.toString(new FileReader(fileText));
            String parametersPath = parametersTextField.getText();
            String parameters = StringUtils.isEmpty(parametersPath) ? "{}" : IOUtils.toString(new FileReader(parametersPath));
            parameters = DeploymentUtils.parseParameters(parameters);
            template.withTemplate(content).withParameters(parameters).withMode(DeploymentMode.INCREMENTAL).create();
            UIUtils.showNotification(statusBar, NOTIFY_CREATE_DEPLOYMENT_SUCCESS, MessageType.INFO);
            updateUI();
        }), (ex) -> {
            UIUtils.showNotification(statusBar, NOTIFY_CREATE_DEPLOYMENT_FAIL + ", " + ex.getMessage(), MessageType.ERROR);
            updateUI();
        });
    }));
    close(DialogWrapper.OK_EXIT_CODE, true);
}
Also used : AuthMethodManager(com.microsoft.azuretools.authmanage.AuthMethodManager) Azure(com.microsoft.azure.toolkit.lib.Azure) NOTIFY_CREATE_DEPLOYMENT_FAIL(com.microsoft.azure.toolkit.intellij.arm.action.CreateDeploymentAction.NOTIFY_CREATE_DEPLOYMENT_FAIL) MessageType(com.intellij.openapi.ui.MessageType) SimpleListCellRenderer(com.intellij.ui.SimpleListCellRenderer) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton) StringUtils(org.apache.commons.lang3.StringUtils) HyperlinkLabel(com.intellij.ui.HyperlinkLabel) NOTIFY_CREATE_DEPLOYMENT_SUCCESS(com.microsoft.azure.toolkit.intellij.arm.action.CreateDeploymentAction.NOTIFY_CREATE_DEPLOYMENT_SUCCESS) StatusBar(com.intellij.openapi.wm.StatusBar) WithTemplate(com.microsoft.azure.management.resources.Deployment.DefinitionStages.WithTemplate) ResourceManagementNode(com.microsoft.tooling.msservices.serviceexplorer.azure.arm.ResourceManagementNode) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) JComboBox(javax.swing.JComboBox) ResourceEx(com.microsoft.azuretools.core.mvp.model.ResourceEx) WindowManager(com.intellij.openapi.wm.WindowManager) JRadioButton(javax.swing.JRadioButton) RegionComboBox(com.microsoft.azure.toolkit.intellij.common.component.RegionComboBox) IOUtils(org.apache.commons.io.IOUtils) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) AzureMvpModel(com.microsoft.azuretools.core.mvp.model.AzureMvpModel) EventUtil(com.microsoft.azuretools.telemetrywrapper.EventUtil) JPanel(javax.swing.JPanel) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) FileChooserDescriptorFactory(com.intellij.openapi.fileChooser.FileChooserDescriptorFactory) JTextField(javax.swing.JTextField) AzureUIRefreshCore(com.microsoft.azuretools.utils.AzureUIRefreshCore) AzureOperationBundle(com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) Region(com.microsoft.azure.toolkit.lib.common.model.Region) DeploymentMode(com.microsoft.azure.management.resources.DeploymentMode) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) Project(com.intellij.openapi.project.Project) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) JComponent(javax.swing.JComponent) Deployment(com.microsoft.azure.management.resources.Deployment) ButtonGroup(javax.swing.ButtonGroup) UIUtils(com.microsoft.intellij.ui.util.UIUtils) AzureUIRefreshEvent(com.microsoft.azuretools.utils.AzureUIRefreshEvent) JList(javax.swing.JList) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup) EventType(com.microsoft.azuretools.telemetrywrapper.EventType) TelemetryConstants(com.microsoft.azuretools.telemetry.TelemetryConstants) JLabel(javax.swing.JLabel) FileReader(java.io.FileReader) SubscriptionComboBox(com.microsoft.azure.toolkit.intellij.common.component.SubscriptionComboBox) BROWSE_TEMPLATE_SAMPLES(com.microsoft.azuretools.telemetry.TelemetryConstants.BROWSE_TEMPLATE_SAMPLES) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) AzureString(com.microsoft.azure.toolkit.lib.common.bundle.AzureString) WithTemplate(com.microsoft.azure.management.resources.Deployment.DefinitionStages.WithTemplate) Region(com.microsoft.azure.toolkit.lib.common.model.Region) FileReader(java.io.FileReader) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) ResourceEx(com.microsoft.azuretools.core.mvp.model.ResourceEx) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)

Example 5 with Region

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

the class AppServiceInfoAdvancedPanel method onRegionChanged.

private void onRegionChanged(final ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED || e.getStateChange() == ItemEvent.DESELECTED) {
        final Region region = (Region) e.getItem();
        this.selectorServicePlan.setRegion(region);
    }
}
Also used : Region(com.microsoft.azure.toolkit.lib.common.model.Region)

Aggregations

Region (com.microsoft.azure.toolkit.lib.common.model.Region)17 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)8 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)6 AzureAccount (com.microsoft.azure.toolkit.lib.auth.AzureAccount)5 RegionComboBox (com.microsoft.azure.toolkit.intellij.common.component.RegionComboBox)2 SubscriptionComboBox (com.microsoft.azure.toolkit.intellij.common.component.SubscriptionComboBox)2 PricingTier (com.microsoft.azure.toolkit.lib.appservice.model.PricingTier)2 IAppServicePlan (com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan)2 IWebApp (com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)2 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)2 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)2 DraftResourceGroup (com.microsoft.azuretools.azureexplorer.forms.common.DraftResourceGroup)2 PrivateRegistryImageSetting (com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting)2 List (java.util.List)2 Point (org.eclipse.swt.graphics.Point)2 FileChooserDescriptorFactory (com.intellij.openapi.fileChooser.FileChooserDescriptorFactory)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Project (com.intellij.openapi.project.Project)1 DialogWrapper (com.intellij.openapi.ui.DialogWrapper)1 MessageType (com.intellij.openapi.ui.MessageType)1