use of com.microsoft.azure.toolkit.lib.storage.model.Kind in project azure-tools-for-java by Microsoft.
the class CreateArmStorageAccountForm method fillReplicationTypes.
private void fillReplicationTypes() {
replicationComboBox.removeAll();
Kind kind = (Kind) kindCombo.getData(kindCombo.getText());
Performance performance = (Performance) performanceCombo.getData(performanceCombo.getText());
List<Redundancy> redundancies = Objects.isNull(performance) ? Collections.emptyList() : Azure.az(AzureStorageAccount.class).listSupportedRedundancies(performance, kind);
for (Redundancy redundancy : redundancies) {
replicationComboBox.add(redundancy.getLabel());
replicationComboBox.setData(redundancy.getLabel(), redundancy);
}
if (redundancies.contains(Redundancy.STANDARD_RAGRS)) {
replicationComboBox.select(redundancies.indexOf(Redundancy.STANDARD_RAGRS));
} else {
replicationComboBox.select(0);
}
}
use of com.microsoft.azure.toolkit.lib.storage.model.Kind in project azure-tools-for-java by Microsoft.
the class BaseStorageAccountCreationDialog method onKindChanged.
private void onKindChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
final Kind kind = (Kind) e.getItem();
this.redundancyComboBox.setKind(kind);
} else if (e.getStateChange() == ItemEvent.DESELECTED) {
this.redundancyComboBox.setKind(null);
}
}
use of com.microsoft.azure.toolkit.lib.storage.model.Kind 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;
}
if (subscription == null) {
subscription = (Subscription) subscriptionComboBox.getData(subscriptionComboBox.getText());
}
final boolean isNewResourceGroup = createNewRadioButton.getSelection();
final ResourceGroup resourceGroup = isNewResourceGroup ? new DraftResourceGroup(subscription, resourceGrpField.getText()) : Azure.az(AzureGroup.class).subscription(subscription.getId()).getByName(resourceGrpCombo.getText());
Region region = ((Region) regionComboBox.getData(regionComboBox.getText()));
Kind kind = (Kind) kindCombo.getData(kindCombo.getText());
String name = nameTextField.getText();
newStorageAccount = StorageAccountConfig.builder().name(name).region(region).kind(kind).resourceGroup(resourceGroup).performance((Performance) performanceCombo.getData(performanceCombo.getText())).redundancy((Redundancy) replicationComboBox.getData(replicationComboBox.getText())).subscription(subscription).accessTier(Optional.ofNullable(accessTierComboBox).map(t -> (AccessTier) accessTierComboBox.getData(accessTierComboBox.getText())).orElse(null)).build();
this.onCreate.run();
super.okPressed();
}
use of com.microsoft.azure.toolkit.lib.storage.model.Kind 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;
}
List<Subscription> subscriptions = azureManager.getSelectedSubscriptions();
for (Subscription sub : subscriptions) {
if (sub.isSelected()) {
subscriptionComboBox.add(sub.getName());
subscriptionComboBox.setData(sub.getName(), sub);
}
}
subscriptionComboBox.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
loadRegionsAndGroups();
}
});
if (subscriptions.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.getName());
subscriptionComboBox.setData(subscription.getName(), subscription);
subscriptionComboBox.select(0);
// only General purpose accounts supported for VMs
kindCombo.add("General purpose v1");
kindCombo.setData("General purpose v1", Kind.STORAGE);
kindCombo.setEnabled(false);
kindCombo.select(0);
regionComboBox.add(region.getLabel());
regionComboBox.setData(region.getLabel(), region);
regionComboBox.setEnabled(false);
regionComboBox.select(0);
loadGroups();
// loadRegions();
}
fillPerformanceComboBox();
// performanceCombo.select(0);
performanceCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
fillReplicationTypes();
}
});
fillReplicationTypes();
}
Aggregations