use of com.microsoft.azure.PagedList in project azure-tools-for-java by Microsoft.
the class AzureNewDockerConfigPage method updateDockerHostVMSizeComboBox.
private void updateDockerHostVMSizeComboBox(Composite mainContainer, boolean preferredSizesOnly) {
dockerHostVMSizeComboBox.deselectAll();
dockerHostVMSizeComboBox.removeAll();
dockerHostVMSizeComboBox.redraw();
if (preferredSizesOnly) {
int index = 0;
for (KnownDockerVirtualMachineSizes knownDockerVirtualMachineSize : KnownDockerVirtualMachineSizes.values()) {
dockerHostVMSizeComboBox.add(knownDockerVirtualMachineSize.name());
if (newHost.hostVM.vmSize.equals(knownDockerVirtualMachineSize.name())) {
dockerHostVMSizeComboBox.select(index);
}
index++;
}
if (index == 0 || !newHost.hostVM.vmSize.equals((String) dockerHostVMSizeComboBox.getText())) {
dockerHostVMSizeComboBox.add(newHost.hostVM.vmSize, 0);
dockerHostVMSizeComboBox.select(0);
}
updateDockerSelectStorageComboBox(mainContainer, getCurrentSubscription());
} else {
dockerHostVMSizeComboBox.add("<Loading...>", 0);
dockerHostVMSizeComboBox.select(0);
dockerHostVMSizeComboBox.redraw();
Azure azureClient = getCurrentSubscription().azureClient;
DefaultLoader.getIdeHelper().runInBackground(null, "Loading VM sizes...", false, true, "", new Runnable() {
@Override
public void run() {
PagedList<VirtualMachineSize> sizes = null;
try {
sizes = azureClient.virtualMachines().sizes().listByRegion(preferredLocation);
Collections.sort(sizes, new Comparator<VirtualMachineSize>() {
@Override
public int compare(VirtualMachineSize size1, VirtualMachineSize size2) {
if (size1.name().contains("Basic") && size2.name().contains("Basic")) {
return size1.name().compareTo(size2.name());
} else if (size1.name().contains("Basic")) {
return -1;
} else if (size2.name().contains("Basic")) {
return 1;
}
int coreCompare = Integer.valueOf(size1.numberOfCores()).compareTo(size2.numberOfCores());
if (coreCompare == 0) {
return Integer.valueOf(size1.memoryInMB()).compareTo(size2.memoryInMB());
} else {
return coreCompare;
}
}
});
} catch (Exception notHandled) {
}
PagedList<VirtualMachineSize> sortedSizes = sizes;
DefaultLoader.getIdeHelper().invokeAndWait(new Runnable() {
@Override
public void run() {
dockerHostVMSizeComboBox.deselectAll();
dockerHostVMSizeComboBox.removeAll();
if (sortedSizes != null) {
int index = 0;
for (VirtualMachineSize vmSize : sortedSizes) {
dockerHostVMSizeComboBox.add(vmSize.name());
if (vmSize.name().equals(newHost.hostVM.vmSize))
dockerHostVMSizeComboBox.select(index);
index++;
}
}
if (sortedSizes.size() != 0 && !newHost.hostVM.vmSize.equals((String) dockerHostVMSizeComboBox.getText())) {
dockerHostVMSizeComboBox.add(newHost.hostVM.vmSize, 0);
dockerHostVMSizeComboBox.select(0);
}
updateDockerSelectStorageComboBox(mainContainer, getCurrentSubscription());
dockerHostVMSizeComboBox.redraw();
}
});
}
});
}
}
Aggregations