use of org.ovirt.engine.ui.uicommonweb.models.Model in project ovirt-engine by oVirt.
the class StorageDataCenterListModel method onAttach.
private void onAttach() {
final ListModel<EntityModel<StoragePool>> model = (ListModel<EntityModel<StoragePool>>) getWindow();
if (model.getProgress() != null) {
return;
}
if (getEntity() == null) {
cancel();
return;
}
ArrayList<StoragePool> items = new ArrayList<>();
for (EntityModel<StoragePool> a : model.getItems()) {
if (a.getIsSelected()) {
items.add(a.getEntity());
}
}
if (items.size() == 0) {
cancel();
return;
}
setSelectedDataCentersForAttach(items);
model.startProgress();
if (getEntity().getStorageDomainType() == StorageDomainType.Data) {
StoragePool dataCenter = items.get(0);
ArrayList<StorageDomain> storageDomains = new ArrayList<>();
storageDomains.add(getEntity());
AsyncDataProvider.getInstance().getStorageDomainsWithAttachedStoragePoolGuid(new AsyncQuery<>(attachedStorageDomains -> {
if (!attachedStorageDomains.isEmpty()) {
ConfirmationModel confirmationModel = new ConfirmationModel();
setWindow(null);
setWindow(confirmationModel);
List<String> stoageDomainNames = new ArrayList<>();
for (StorageDomainStatic domain : attachedStorageDomains) {
stoageDomainNames.add(domain.getStorageName());
}
confirmationModel.setItems(stoageDomainNames);
confirmationModel.setTitle(ConstantsManager.getInstance().getConstants().storageDomainsAttachedToDataCenterWarningTitle());
confirmationModel.setMessage(ConstantsManager.getInstance().getConstants().storageDomainsAttachedToDataCenterWarningMessage());
confirmationModel.setHelpTag(HelpTag.attach_storage_domain_confirmation);
// $NON-NLS-1$
confirmationModel.setHashName("attach_storage_domain_confirmation");
confirmationModel.getLatch().setIsAvailable(true);
confirmationModel.getLatch().setIsChangeable(true);
// $NON-NLS-1$
UICommand onApprove = new UICommand("OnAttachApprove", StorageDataCenterListModel.this);
onApprove.setTitle(ConstantsManager.getInstance().getConstants().ok());
onApprove.setIsDefault(true);
confirmationModel.getCommands().add(onApprove);
// $NON-NLS-1$
UICommand cancel = new UICommand("Cancel", StorageDataCenterListModel.this);
cancel.setTitle(ConstantsManager.getInstance().getConstants().cancel());
cancel.setIsCancel(true);
confirmationModel.getCommands().add(cancel);
} else {
executeAttachStorageDomains(model);
}
}), dataCenter, storageDomains);
} else {
executeAttachStorageDomains(model);
}
}
use of org.ovirt.engine.ui.uicommonweb.models.Model in project ovirt-engine by oVirt.
the class NewEditStorageModelBehavior method updateItemSelectability.
private void updateItemSelectability(IStorageModel item, boolean isSelectable) {
Model model = (Model) item;
model.setIsSelectable(isSelectable);
onStorageModelUpdated(item);
}
use of org.ovirt.engine.ui.uicommonweb.models.Model in project ovirt-engine by oVirt.
the class ImportStorageModelBehavior method postUpdateItemsAvailability.
public void postUpdateItemsAvailability(IStorageModel item, boolean isNoStorageAttached) {
Model model = (Model) item;
StoragePool dataCenter = getModel().getDataCenter().getSelectedItem();
boolean isItemSelectable = isItemSelectable(item, dataCenter, isNoStorageAttached);
model.setIsSelectable(isItemSelectable);
onStorageModelUpdated(item);
}
use of org.ovirt.engine.ui.uicommonweb.models.Model in project ovirt-engine by oVirt.
the class VmBaseListModel method displayHighPerformanceConfirmationPopup.
protected void displayHighPerformanceConfirmationPopup() {
final UnitVmModel model = (UnitVmModel) getWindow();
if (model == null || model.getProgress() != null) {
return;
}
VmHighPerformanceConfigurationModel confirmModel = new VmHighPerformanceConfigurationModel();
// Handle CPU Pinning topology
final boolean isVmAssignedToSpecificHosts = !model.getIsAutoAssign().getEntity();
final boolean isVmCpuPinningSet = model.getCpuPinning().getIsChangable() && model.getCpuPinning().getEntity() != null && !model.getCpuPinning().getEntity().isEmpty();
confirmModel.addRecommendationForCpuPinning(isVmAssignedToSpecificHosts, isVmCpuPinningSet);
// Handle NUMA
final boolean isVmVirtNumaSet = model.getNumaEnabled().getEntity() && model.getNumaNodeCount().getEntity() > 0;
final boolean isVmVirtNumaPinned = model.getVmNumaNodes() != null && !model.getVmNumaNodes().isEmpty() && model.getVmNumaNodes().stream().filter(x -> !x.getVdsNumaNodeList().isEmpty()).count() > 0;
confirmModel.addRecommendationForVirtNumaSetAndPinned(isVmVirtNumaSet, isVmVirtNumaPinned);
// Handle Huge Pages
KeyValueModel keyValue = model.getCustomPropertySheet();
// $NON-NLS-1$
final boolean isVmHugePagesSet = keyValue != null && keyValue.getUsedKeys().contains("hugepages");
confirmModel.addRecommendationForHugePages(isVmHugePagesSet);
// Handle KSM (Kernel Same Page Merging)
confirmModel.addRecommendationForKsm(model.getSelectedCluster().isEnableKsm(), model.getSelectedCluster().getName());
// If there are recommendations to display and it is not a Pool VM then display the popup
if (!confirmModel.getRecommendationsList().isEmpty() && !model.isVmAttachedToPool()) {
confirmModel.setTitle(ConstantsManager.getInstance().getConstants().configurationChangesForHighPerformanceVmTitle());
confirmModel.setHelpTag(HelpTag.configuration_changes_for_high_performance_vm);
// $NON-NLS-1$
confirmModel.setHashName("configuration_changes_for_high_performance_vm");
confirmModel.getCommands().add(// $NON-NLS-1$
new UICommand("SaveOrUpdateVM", VmBaseListModel.this).setTitle(ConstantsManager.getInstance().getConstants().ok()).setIsDefault(true));
confirmModel.getCommands().add(// $NON-NLS-1$
UICommand.createCancelUiCommand("CancelConfirmation", VmBaseListModel.this));
setConfirmWindow(null);
setConfirmWindow(confirmModel);
} else {
saveOrUpdateVM(model);
}
}
use of org.ovirt.engine.ui.uicommonweb.models.Model in project ovirt-engine by oVirt.
the class StorageModel method host_SelectedItemChanged.
private void host_SelectedItemChanged() {
VDS host = getHost().getSelectedItem();
if (getCurrentStorageItem() != null) {
// When changing host clear items for san storage model.
if (getCurrentStorageItem() instanceof SanStorageModelBase) {
SanStorageModelBase sanStorageModel = (SanStorageModelBase) getCurrentStorageItem();
if (getStorage() == null) {
sanStorageModel.setItems(null);
}
}
if (host != null) {
getCurrentStorageItem().getUpdateCommand().execute();
// $NON-NLS-1$
String prefix = host.isOvirtVintageNode() ? localFSPath : "";
if (!StringHelper.isNullOrEmpty(prefix)) {
getStorageModels().stream().filter(item -> item instanceof LocalStorageModel).map(item -> (LocalStorageModel) item).forEach(model -> {
model.getPath().setEntity(prefix);
model.getPath().setIsChangeable(false);
});
}
}
}
}
Aggregations