Search in sources :

Example 1 with Kind

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);
    }
}
Also used : Redundancy(com.microsoft.azure.toolkit.lib.storage.model.Redundancy) Kind(com.microsoft.azure.toolkit.lib.storage.model.Kind) Performance(com.microsoft.azure.toolkit.lib.storage.model.Performance)

Example 2 with Kind

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);
    }
}
Also used : Kind(com.microsoft.azure.toolkit.lib.storage.model.Kind)

Example 3 with Kind

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();
}
Also used : DraftResourceGroup(com.microsoft.azuretools.azureexplorer.forms.common.DraftResourceGroup) Kind(com.microsoft.azure.toolkit.lib.storage.model.Kind) Region(com.microsoft.azure.toolkit.lib.common.model.Region) AzureGroup(com.microsoft.azure.toolkit.lib.resource.AzureGroup) Performance(com.microsoft.azure.toolkit.lib.storage.model.Performance) DraftResourceGroup(com.microsoft.azuretools.azureexplorer.forms.common.DraftResourceGroup) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)

Example 4 with Kind

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();
}
Also used : AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Kind(com.microsoft.azure.toolkit.lib.storage.model.Kind) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Aggregations

Kind (com.microsoft.azure.toolkit.lib.storage.model.Kind)4 Performance (com.microsoft.azure.toolkit.lib.storage.model.Performance)2 Region (com.microsoft.azure.toolkit.lib.common.model.Region)1 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)1 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)1 AzureGroup (com.microsoft.azure.toolkit.lib.resource.AzureGroup)1 Redundancy (com.microsoft.azure.toolkit.lib.storage.model.Redundancy)1 DraftResourceGroup (com.microsoft.azuretools.azureexplorer.forms.common.DraftResourceGroup)1 AzureManager (com.microsoft.azuretools.sdkmanage.AzureManager)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1