Search in sources :

Example 1 with ReplicationTypes

use of com.microsoft.tooling.msservices.model.ReplicationTypes in project azure-tools-for-java by Microsoft.

the class CreateArmStorageAccountForm method fillFields.

public void fillFields(final SubscriptionDetail subscription, Location region) {
    if (subscription == null) {
        //            loadRegions();
        accoountKindCombo.setModel(new DefaultComboBoxModel(Kind.values()));
        accoountKindCombo.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    fillPerformanceComboBox();
                    fillReplicationTypes();
                    boolean isBlobKind = e.getItem().equals(Kind.BLOB_STORAGE);
                    accessTeirComboBox.setVisible(isBlobKind);
                    accessTierLabel.setVisible(isBlobKind);
                }
            }
        });
        accessTeirComboBox.setModel(new DefaultComboBoxModel(AccessTier.values()));
        subscriptionComboBox.setEnabled(true);
        try {
            AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
            // not signed in
            if (azureManager == null) {
                return;
            }
            SubscriptionManager subscriptionManager = azureManager.getSubscriptionManager();
            List<SubscriptionDetail> subscriptionDetails = subscriptionManager.getSubscriptionDetails();
            List<SubscriptionDetail> selectedSubscriptions = subscriptionDetails.stream().filter(SubscriptionDetail::isSelected).collect(Collectors.toList());
            subscriptionComboBox.setModel(new DefaultComboBoxModel<>(selectedSubscriptions.toArray(new SubscriptionDetail[selectedSubscriptions.size()])));
            if (selectedSubscriptions.size() > 0) {
                loadRegions();
            }
        } catch (Exception ex) {
            DefaultLoader.getUIHelper().logError("An error occurred when trying to load Subscriptions\n\n" + ex.getMessage(), ex);
        }
        subscriptionComboBox.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent itemEvent) {
                loadRegions();
            }
        });
    } else {
        // if you create SA while creating VM
        this.subscription = subscription;
        subscriptionComboBox.addItem(subscription);
        // only General purpose accounts supported for VMs
        accoountKindCombo.addItem(Kind.STORAGE);
        accoountKindCombo.setEnabled(false);
        // Access tier is not available for General purpose accounts
        accessTeirComboBox.setVisible(false);
        accessTierLabel.setVisible(false);
        regionComboBox.addItem(region);
        regionComboBox.setEnabled(false);
        loadGroups();
    }
    //performanceComboBox.setModel(new DefaultComboBoxModel(SkuTier.values()));
    fillPerformanceComboBox();
    performanceComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                fillReplicationTypes();
            }
        }
    });
    replicationComboBox.setRenderer(new ListCellRendererWrapper<ReplicationTypes>() {

        @Override
        public void customize(JList jList, ReplicationTypes replicationTypes, int i, boolean b, boolean b1) {
            if (replicationTypes != null) {
                setText(replicationTypes.getDescription());
            }
        }
    });
    fillReplicationTypes();
}
Also used : ItemEvent(java.awt.event.ItemEvent) AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) SubscriptionManager(com.microsoft.azuretools.authmanage.SubscriptionManager) ReplicationTypes(com.microsoft.tooling.msservices.model.ReplicationTypes) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) ItemListener(java.awt.event.ItemListener)

Aggregations

SubscriptionManager (com.microsoft.azuretools.authmanage.SubscriptionManager)1 SubscriptionDetail (com.microsoft.azuretools.authmanage.models.SubscriptionDetail)1 AzureManager (com.microsoft.azuretools.sdkmanage.AzureManager)1 ReplicationTypes (com.microsoft.tooling.msservices.model.ReplicationTypes)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1