use of com.microsoft.azure.toolkit.lib.compute.security.model.SecurityRule in project azure-tools-for-java by Microsoft.
the class VMCreationDialog method setData.
@Override
public void setData(DraftVirtualMachine data) {
Optional.ofNullable(data.getResourceGroup()).ifPresent(groupName -> cbResourceGroup.setValue(new AzureComboBox.ItemReference<>(group -> StringUtils.equalsIgnoreCase(group.getName(), groupName))));
Optional.ofNullable(data.getSubscriptionId()).ifPresent(id -> cbSubscription.setValue(new AzureComboBox.ItemReference<>(subscription -> StringUtils.equalsIgnoreCase(subscription.getId(), id))));
Optional.ofNullable(data.getName()).ifPresent(name -> txtVisualMachineName.setText(name));
Optional.ofNullable(data.getRegion()).ifPresent(region -> cbRegion.setValue(region));
Optional.ofNullable(data.getImage()).ifPresent(image -> cbImage.setValue(image));
Optional.ofNullable(data.getSize()).ifPresent(size -> cbSize.setValue(size));
Optional.ofNullable(data.getUserName()).ifPresent(name -> txtUserName.setText(name));
cbAvailabilityOptions.setValue(data.getAvailabilitySet());
// skip set value for password/cert
Optional.ofNullable(data.getNetwork()).ifPresent(network -> cbVirtualNetwork.setData(network));
Optional.ofNullable(data.getSubnet()).ifPresent(subnet -> cbSubnet.setValue(subnet));
rdoNoneSecurityGroup.setSelected(data.getSecurityGroup() == null);
Optional.ofNullable(data.getSecurityGroup()).ifPresent(networkSecurityGroup -> {
if (networkSecurityGroup instanceof DraftNetworkSecurityGroup) {
rdoBasicSecurityGroup.setSelected(true);
final List<SecurityRule> securityRuleList = ((DraftNetworkSecurityGroup) networkSecurityGroup).getSecurityRuleList();
rdoAllowSelectedInboundPorts.setSelected(!Collections.isEmpty(securityRuleList));
pnlPorts.setData(securityRuleList);
pnlBasicPorts.setData(securityRuleList);
} else if (networkSecurityGroup.exists()) {
rdoAdvancedSecurityGroup.setSelected(true);
cbSecurityGroup.setData(networkSecurityGroup);
}
});
cbPublicIp.setData(data.getIpAddress());
cbStorageAccount.setData(data.getStorageAccount());
final AzureSpotConfig azureSpotConfig = data.getAzureSpotConfig();
if (azureSpotConfig == null) {
chkAzureSpotInstance.setSelected(false);
} else {
chkAzureSpotInstance.setSelected(true);
rdoStopAndDeallocate.setSelected(azureSpotConfig.getPolicy() != AzureSpotConfig.EvictionPolicy.StopAndDeallocate);
rdoDelete.setSelected(azureSpotConfig.getPolicy() == AzureSpotConfig.EvictionPolicy.StopAndDeallocate);
txtMaximumPrice.setText(String.valueOf(azureSpotConfig.getMaximumPrice()));
}
}
Aggregations