use of com.microsoft.azuretools.sdkmanage.AzureManager in project azure-tools-for-java by Microsoft.
the class CreateVMWizard method setSubscription.
public void setSubscription(SubscriptionDetail subscription) {
try {
this.subscription = subscription;
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
azure = azureManager.getAzure(subscription.getSubscriptionId());
} catch (Exception ex) {
DefaultLoader.getUIHelper().showException(ex.getMessage(), ex, "Error selecting subscription", true, false);
}
}
use of com.microsoft.azuretools.sdkmanage.AzureManager in project azure-tools-for-java by Microsoft.
the class CreateArmStorageAccountForm method okPressed.
@Override
protected void okPressed() {
if (nameTextField.getText().length() < 3 || nameTextField.getText().length() > 24 || !nameTextField.getText().matches("[a-z0-9]+")) {
DefaultLoader.getUIHelper().showError("Invalid storage account name. The name should be between 3 and 24 characters long and " + "can contain only lowercase letters and numbers.", "Azure Explorer");
return;
}
final boolean isNewResourceGroup = createNewRadioButton.getSelection();
final String resourceGroupName = isNewResourceGroup ? resourceGrpField.getText() : resourceGrpCombo.getText();
String replication = replicationComboBox.getData(replicationComboBox.getText()).toString();
String region = ((Location) regionComboBox.getData(regionComboBox.getText())).name();
Kind kind = (Kind) kindCombo.getData(kindCombo.getText());
if (subscription == null) {
String name = nameTextField.getText();
AccessTier accessTier = (AccessTier) accessTierComboBox.getData(accessTierComboBox.getText());
SubscriptionDetail subscriptionDetail = (SubscriptionDetail) subscriptionComboBox.getData(subscriptionComboBox.getText());
setSubscription(subscriptionDetail);
DefaultLoader.getIdeHelper().runInBackground(null, "Creating storage account", false, true, "Creating storage account " + name + "...", new Runnable() {
@Override
public void run() {
try {
AzureSDKManager.createStorageAccount(subscriptionDetail.getSubscriptionId(), name, region, isNewResourceGroup, resourceGroupName, kind, accessTier, false, replication);
// update resource groups cache if new resource group was created when creating storage account
if (isNewResourceGroup) {
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
if (azureManager != null) {
ResourceGroup rg = azureManager.getAzure(subscriptionDetail.getSubscriptionId()).resourceGroups().getByName(resourceGroupName);
AzureModelController.addNewResourceGroup(subscriptionDetail, rg);
}
}
if (onCreate != null) {
onCreate.run();
}
} catch (Exception e) {
DefaultLoader.getIdeHelper().invokeLater(new Runnable() {
@Override
public void run() {
PluginUtil.displayErrorDialog(PluginUtil.getParentShell(), Messages.err, "An error occurred while creating the storage account: " + e.getMessage());
}
});
}
}
});
} else {
//creating from 'create vm'
newStorageAccount = new com.microsoft.tooling.msservices.model.storage.StorageAccount(nameTextField.getText(), subscription.getSubscriptionId());
newStorageAccount.setResourceGroupName(resourceGroupName);
newStorageAccount.setNewResourceGroup(isNewResourceGroup);
newStorageAccount.setType(replication);
newStorageAccount.setLocation(region);
newStorageAccount.setKind(kind);
if (onCreate != null) {
onCreate.run();
}
}
super.okPressed();
}
use of com.microsoft.azuretools.sdkmanage.AzureManager in project azure-tools-for-java by Microsoft.
the class CreateArmStorageAccountForm method fillFields.
public void fillFields() {
if (subscription == null) {
try {
subscriptionComboBox.setEnabled(true);
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
// not signed in
if (azureManager == null) {
return;
}
SubscriptionManager subscriptionManager = azureManager.getSubscriptionManager();
List<SubscriptionDetail> subscriptionDetails = subscriptionManager.getSubscriptionDetails();
for (SubscriptionDetail sub : subscriptionDetails) {
if (sub.isSelected()) {
subscriptionComboBox.add(sub.getSubscriptionName());
subscriptionComboBox.setData(sub.getSubscriptionName(), sub);
}
}
subscriptionComboBox.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
loadRegionsAndGroups();
}
});
if (subscriptionDetails.size() > 0) {
subscriptionComboBox.select(0);
loadRegionsAndGroups();
}
} catch (Exception e) {
PluginUtil.displayErrorDialogWithAzureMsg(PluginUtil.getParentShell(), Messages.err, "An error occurred while loading subscriptions.", e);
}
for (Map.Entry<String, Kind> entry : ACCOUNT_KIND.entrySet()) {
kindCombo.add(entry.getKey());
kindCombo.setData(entry.getKey(), entry.getValue());
}
kindCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fillPerformanceComboBox();
fillReplicationTypes();
showAccessTier();
}
});
kindCombo.select(1);
showAccessTier();
} else {
// create form create VM form
subscriptionComboBox.setEnabled(false);
subscriptionComboBox.add(subscription.getSubscriptionName());
subscriptionComboBox.setData(subscription.getSubscriptionName(), subscription);
subscriptionComboBox.select(0);
// only General purpose accounts supported for VMs
kindCombo.add("General purpose");
kindCombo.setData(Kind.STORAGE);
kindCombo.setEnabled(false);
kindCombo.select(0);
regionComboBox.add(region.displayName());
regionComboBox.setData(region.displayName(), region);
regionComboBox.setEnabled(false);
regionComboBox.select(0);
loadGroups();
//loadRegions();
}
fillPerformanceComboBox();
//performanceCombo.select(0);
performanceCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
fillReplicationTypes();
}
});
fillReplicationTypes();
}
use of com.microsoft.azuretools.sdkmanage.AzureManager in project azure-tools-for-java by Microsoft.
the class ApplicationInsightsPreferencePage method loadInfoFirstTime.
private void loadInfoFirstTime() {
try {
if (AuthMethodManager.getInstance().isSignedIn()) {
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
List<SubscriptionDetail> subList = azureManager.getSubscriptionManager().getSubscriptionDetails();
if (subList.size() > 0) {
// if (!ApplicationInsightsPreferences.isLoaded()) {
// authenticated using AD. Proceed for updating application insights registry.
ApplicationInsightsResourceRegistryEclipse.updateApplicationInsightsResourceRegistry(subList);
} else {
ApplicationInsightsResourceRegistryEclipse.keeepManuallyAddedList();
}
// } else {
// // show list from preferences - getTableContent() does it. So nothing to handle here
// }
} else {
// just show manually added list from preferences
ApplicationInsightsResourceRegistryEclipse.keeepManuallyAddedList();
}
} catch (Exception ex) {
Activator.getDefault().log(Messages.importErrMsg, ex);
}
}
use of com.microsoft.azuretools.sdkmanage.AzureManager in project azure-tools-for-java by Microsoft.
the class ApplicationInsightsNewDialog method populateValues.
private void populateValues() {
try {
subscription.removeAll();
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
if (azureManager == null) {
return;
}
List<SubscriptionDetail> subList = azureManager.getSubscriptionManager().getSubscriptionDetails();
// check at least single subscription is associated with the account
if (subList.size() > 0) {
for (SubscriptionDetail sub : subList) {
subscription.add(sub.getSubscriptionName());
subscription.setData(sub.getSubscriptionName(), sub);
}
subscription.select(0);
currentSub = subList.get(0);
populateResourceGroupValues(currentSub.getSubscriptionId(), "");
List<String> regionList = AzureSDKManager.getLocationsForApplicationInsights(currentSub);
String[] regionArray = regionList.toArray(new String[regionList.size()]);
region.setItems(regionArray);
region.setText(regionArray[0]);
}
enableOkBtn();
} catch (Exception ex) {
Activator.getDefault().log(Messages.getValuesErrMsg, ex);
}
}
Aggregations