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;
}
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);
}
}
}
}
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);
});
}
});
}
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);
}
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);
}
}
Aggregations