Search in sources :

Example 6 with AvailabilitySet

use of com.microsoft.azure.management.compute.AvailabilitySet in project azure-tools-for-java by Microsoft.

the class SettingsStep method retrieveAvailabilitySets.

private void retrieveAvailabilitySets() {
    DefaultLoader.getIdeHelper().runInBackground(null, "Loading availability sets...", false, true, "Loading availability sets...", new Runnable() {

        @Override
        public void run() {
            if (availabilitySets == null) {
                availabilitySets = wizard.getAzure().availabilitySets().list();
            }
            DefaultLoader.getIdeHelper().invokeLater(new Runnable() {

                @Override
                public void run() {
                    availabilityCombo.removeAll();
                    availabilityCombo.add(NONE);
                    availabilityCombo.add(CREATE_NEW);
                    for (AvailabilitySet availabilitySet : availabilitySets) {
                        availabilityCombo.add(availabilitySet.name());
                        availabilityCombo.setData(availabilitySet.name(), availabilitySet);
                    }
                    availabilityCombo.select(0);
                }
            });
        }
    });
    availabilityCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (NONE.equals(availabilityCombo.getText())) {
                wizard.setAvailabilitySet(null);
                wizard.setWithNewAvailabilitySet(false);
            } else if (CREATE_NEW.equals(availabilityCombo.getText())) {
                wizard.setWithNewAvailabilitySet(true);
                wizard.setAvailabilitySet(null);
            } else if (availabilityCombo.getData(availabilityCombo.getText()) instanceof AvailabilitySet) {
                wizard.setAvailabilitySet((AvailabilitySet) availabilityCombo.getData(availabilityCombo.getText()));
                wizard.setWithNewAvailabilitySet(false);
            }
        }
    });
    if (availabilitySets == null) {
        DefaultLoader.getIdeHelper().invokeAndWait(new Runnable() {

            @Override
            public void run() {
                availabilityCombo.setItems(new String[] { NONE, CREATE_NEW, LOADING });
            }
        });
    }
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) AvailabilitySet(com.microsoft.azure.management.compute.AvailabilitySet)

Aggregations

AvailabilitySet (com.microsoft.azure.management.compute.AvailabilitySet)6 VirtualMachine (com.microsoft.azure.management.compute.VirtualMachine)4 Network (com.microsoft.azure.management.network.Network)4 Creatable (com.microsoft.azure.management.resources.fluentcore.model.Creatable)3 ArrayList (java.util.ArrayList)3 LoadBalancer (com.microsoft.azure.management.network.LoadBalancer)2 NetworkInterface (com.microsoft.azure.management.network.NetworkInterface)2 StopWatch (org.apache.commons.lang3.time.StopWatch)2 VirtualMachineSize (com.microsoft.azure.management.compute.VirtualMachineSize)1 PublicIPAddress (com.microsoft.azure.management.network.PublicIPAddress)1 Region (com.microsoft.azure.management.resources.fluentcore.arm.Region)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1