use of com.microsoft.azure.management.storage.AccessTier in project azure-tools-for-java by Microsoft.
the class CreateArmStorageAccountForm method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
setTitle("Create New Storage Account");
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "com.microsoft.azuretools.azureexplorer.storage_account_dialog");
Composite container = new Composite(parent, SWT.FILL);
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
gridLayout.marginBottom = 10;
container.setLayout(gridLayout);
GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalAlignment = SWT.FILL;
// gridData.widthHint = 250;
container.setLayoutData(gridData);
nameLabel = new Label(container, SWT.LEFT);
nameLabel.setText("Name:");
nameTextField = new Text(container, SWT.LEFT | SWT.BORDER);
// gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
nameTextField.setLayoutData(gridDataForText(180));
subscriptionLabel = new Label(container, SWT.LEFT);
subscriptionLabel.setText("Subscription:");
subscriptionComboBox = new Combo(container, SWT.READ_ONLY);
subscriptionComboBox.setLayoutData(gridDataForText(180));
resourceGroupLabel = new Label(container, SWT.LEFT);
resourceGroupLabel.setText("Resource group:");
gridData = new GridData();
gridData.verticalAlignment = SWT.TOP;
resourceGroupLabel.setLayoutData(gridData);
final Composite composite = new Composite(container, SWT.NONE);
gridLayout = new GridLayout();
gridLayout.numColumns = 2;
gridData = new GridData();
gridData.horizontalAlignment = SWT.FILL;
gridData.verticalAlignment = GridData.BEGINNING;
gridData.grabExcessHorizontalSpace = true;
// gridData.widthHint = 250;
composite.setLayout(gridLayout);
composite.setLayoutData(gridData);
createNewRadioButton = new Button(composite, SWT.RADIO);
createNewRadioButton.setText("Create new");
createNewRadioButton.setSelection(true);
resourceGrpField = new Text(composite, SWT.LEFT | SWT.BORDER);
gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
resourceGrpField.setLayoutData(gridData);
useExistingRadioButton = new Button(composite, SWT.RADIO);
useExistingRadioButton.setText("Use existing");
resourceGrpCombo = new Combo(composite, SWT.READ_ONLY);
gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
resourceGrpCombo.setLayoutData(gridData);
resourceGroupViewer = new ComboViewer(resourceGrpCombo);
resourceGroupViewer.setContentProvider(ArrayContentProvider.getInstance());
SelectionListener updateListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
updateResourceGroup();
}
};
createNewRadioButton.addSelectionListener(updateListener);
useExistingRadioButton.addSelectionListener(updateListener);
updateResourceGroup();
regionLabel = new Label(container, SWT.LEFT);
regionLabel.setText("Region:");
regionComboBox = new Combo(container, SWT.READ_ONLY);
regionComboBox.setLayoutData(gridDataForText(180));
kindLabel = new Label(container, SWT.LEFT);
kindLabel.setText("Account kind:");
kindCombo = new Combo(container, SWT.READ_ONLY);
kindCombo.setLayoutData(gridDataForText(180));
performanceLabel = new Label(container, SWT.LEFT);
performanceLabel.setText("Performance:");
performanceCombo = new Combo(container, SWT.READ_ONLY);
performanceCombo.setLayoutData(gridDataForText(180));
replicationLabel = new Label(container, SWT.LEFT);
replicationLabel.setText("Replication:");
replicationComboBox = new Combo(container, SWT.READ_ONLY);
replicationComboBox.setLayoutData(gridDataForText(180));
if (subscription == null) {
// not showing access tier with general purpose storage account which is used when creating vm
accessTierLabel = new Label(container, SWT.LEFT);
accessTierLabel.setText("Access Tier:");
accessTierComboBox = new Combo(container, SWT.READ_ONLY);
accessTierComboBox.setLayoutData(gridDataForText(180));
for (AccessTier type : AccessTier.values()) {
accessTierComboBox.add(type.toString());
accessTierComboBox.setData(type.toString(), type);
}
accessTierComboBox.select(0);
}
pricingLabel = new Link(container, SWT.LEFT);
pricingLabel.setText(PRICING_LINK);
gridData = new GridData();
gridData.horizontalSpan = 2;
pricingLabel.setLayoutData(gridData);
pricingLabel.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
try {
PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL(event.text));
} catch (Exception ex) {
/*
* only logging the error in log file
* not showing anything to end user
*/
Activator.getDefault().log("Error occurred while opening link in default browser.", ex);
}
}
});
nameTextField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent modifyEvent) {
validateEmptyFields();
}
});
regionComboBox.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
validateEmptyFields();
}
});
resourceGrpField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent modifyEvent) {
validateEmptyFields();
}
});
resourceGrpCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
validateEmptyFields();
}
});
fillFields();
return super.createDialogArea(parent);
}
use of com.microsoft.azure.management.storage.AccessTier 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();
}
Aggregations