use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.
the class DataCenterListModel method edit.
public void edit() {
StoragePool dataCenter = getSelectedItem();
final UIConstants constants = ConstantsManager.getInstance().getConstants();
if (getWindow() != null) {
return;
}
final DataCenterModel model = new DataCenterModel();
setWindow(model);
model.setEntity(dataCenter);
model.setDataCenterId(dataCenter.getId());
model.setTitle(constants.editDataCenterTitle());
model.setHelpTag(HelpTag.edit_data_center);
// $NON-NLS-1$
model.setHashName("edit_data_center");
model.getName().setEntity(dataCenter.getName());
model.getDescription().setEntity(dataCenter.getdescription());
model.getComment().setEntity(dataCenter.getComment());
model.setOriginalName(dataCenter.getName());
model.getStoragePoolType().setSelectedItem(dataCenter.isLocal());
model.getQuotaEnforceTypeListModel().setSelectedItem(dataCenter.getQuotaEnforcementType());
// $NON-NLS-1$
UICommand tempVar = UICommand.createDefaultOkUiCommand("OnSave", this);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
model.getCommands().add(tempVar2);
}
use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.
the class DataCenterListModel method onSave.
public void onSave() {
final DataCenterModel dcModel = (DataCenterModel) getWindow();
if (!dcModel.validate()) {
return;
}
if ((dcModel.getIsNew() || dcModel.getEntity() == null) && dcModel.getQuotaEnforceTypeListModel().getSelectedItem() == QuotaEnforcementTypeEnum.HARD_ENFORCEMENT) {
promptNoQuotaInDCMessage();
} else if (!dcModel.getIsNew() && getSelectedItem() != null && !dcModel.getVersion().getSelectedItem().equals(getSelectedItem().getCompatibilityVersion())) {
final ConfirmationModel confirmModel = new ConfirmationModel();
setConfirmWindow(confirmModel);
confirmModel.setTitle(ConstantsManager.getInstance().getConstants().changeDataCenterCompatibilityVersionTitle());
confirmModel.setHelpTag(HelpTag.change_data_center_compatibility_version);
// $NON-NLS-1$
confirmModel.setHashName("change_data_center_compatibility_version");
final StoragePool sp = getSelectedItem();
startProgress();
IdQueryParameters params = new IdQueryParameters(sp.getId());
Frontend.getInstance().runQuery(QueryType.GetStorageDomainsByStoragePoolId, params, new AsyncQuery<QueryReturnValue>(returnValue -> {
List<StorageDomain> storages = returnValue.getReturnValue();
StorageDomain storage = null;
for (StorageDomain sd : storages) {
if (sd.getStorageDomainType().isDataDomain()) {
storage = sd;
}
}
StorageFormatType newFormat = null;
StorageFormatType oldFormat = null;
if (storage != null) {
newFormat = VersionStorageFormatUtil.getForVersion(dcModel.getVersion().getSelectedItem());
oldFormat = VersionStorageFormatUtil.getForVersion(sp.getCompatibilityVersion());
}
if (newFormat == oldFormat) {
confirmModel.setMessage(ConstantsManager.getInstance().getConstants().youAreAboutChangeDcCompatibilityVersionMsg());
} else {
Version v = VersionStorageFormatUtil.getEarliestVersionSupported(newFormat);
confirmModel.setMessage(ConstantsManager.getInstance().getMessages().youAreAboutChangeDcCompatibilityVersionWithUpgradeMsg(v.getValue()));
}
stopProgress();
}));
// $NON-NLS-1$
UICommand tempVar = UICommand.createDefaultOkUiCommand("OnSaveInternal", this);
confirmModel.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createCancelUiCommand("CancelConfirmation", this);
confirmModel.getCommands().add(tempVar2);
} else if (getSelectedItem() != null && getSelectedItem().getQuotaEnforcementType() != QuotaEnforcementTypeEnum.HARD_ENFORCEMENT && dcModel.getQuotaEnforceTypeListModel().getSelectedItem() == QuotaEnforcementTypeEnum.HARD_ENFORCEMENT) {
checkForQuotaInDC(dcModel.getEntity(), this);
} else if (dcModel.getIsNew()) {
// New data center, check for name uniqueness.
validateDataCenterName(dcModel);
} else {
onSaveInternal();
}
}
use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.
the class DataCenterListModel method onSaveInternal.
public void onSaveInternal() {
DataCenterModel model = (DataCenterModel) getWindow();
if (model.getProgress() != null) {
return;
}
StoragePool dataCenter = model.getIsNew() ? new StoragePool() : (StoragePool) Cloner.clone(getSelectedItem());
// cancel confirm window if there is
cancelConfirmation();
// Save changes.
dataCenter.setName(model.getName().getEntity());
dataCenter.setdescription(model.getDescription().getEntity());
dataCenter.setComment(model.getComment().getEntity());
dataCenter.setIsLocal(model.getStoragePoolType().getSelectedItem());
dataCenter.setCompatibilityVersion(model.getVersion().getSelectedItem());
dataCenter.setQuotaEnforcementType(model.getQuotaEnforceTypeListModel().getSelectedItem());
model.startProgress();
if (model.getIsNew()) {
// When adding a data center use sync action to be able present a Guide Me dialog afterwards.
Frontend.getInstance().runAction(ActionType.AddEmptyStoragePool, new StoragePoolManagementParameter(dataCenter), result -> {
DataCenterListModel localModel = (DataCenterListModel) result.getState();
localModel.postOnSaveInternal(result.getReturnValue());
}, this);
} else {
// Use async action in order to close dialog immediately.
Frontend.getInstance().runMultipleAction(ActionType.UpdateStoragePool, new ArrayList<ActionParametersBase>(Arrays.asList(new StoragePoolManagementParameter(dataCenter))), result -> {
DataCenterListModel localModel = (DataCenterListModel) result.getState();
localModel.postOnSaveInternal(result.getReturnValue().get(0));
}, this);
}
}
use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.
the class DataCenterListModel method guide.
public void guide() {
DataCenterGuideModel model = new DataCenterGuideModel();
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().newDataCenterGuideMeTitle());
model.setHelpTag(HelpTag.new_data_center___guide_me);
// $NON-NLS-1$
model.setHashName("new_data_center_-_guide_me");
if (getGuideContext() == null) {
StoragePool dataCenter = getSelectedItem();
setGuideContext(dataCenter.getId());
}
AsyncDataProvider.getInstance().getDataCenterById(new AsyncQuery<>(returnValue -> {
DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) getWindow();
dataCenterGuideModel.setEntity(returnValue);
// $NON-NLS-1$
UICommand tempVar = new UICommand("Cancel", DataCenterListModel.this);
tempVar.setTitle(ConstantsManager.getInstance().getConstants().configureLaterTitle());
tempVar.setIsDefault(true);
tempVar.setIsCancel(true);
dataCenterGuideModel.getCommands().add(tempVar);
}), (Guid) getGuideContext());
}
use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.
the class DataCenterListModel method remove.
public void remove() {
if (getWindow() != null) {
return;
}
boolean shouldAddressWarnning = false;
ConfirmationModel model = new ConfirmationModel();
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().removeDataCenterTitle());
model.setHelpTag(HelpTag.remove_data_center);
// $NON-NLS-1$
model.setHashName("remove_data_center");
ArrayList<String> list = new ArrayList<>();
for (StoragePool a : getSelectedItems()) {
list.add(a.getName());
// If one of the Data Centers contain Storage Domain, show the warnning.
if (a.getStatus() != StoragePoolStatus.Uninitialized) {
shouldAddressWarnning = true;
}
}
model.setItems(list);
// $NON-NLS-1$
UICommand tempVar = UICommand.createDefaultOkUiCommand("OnRemove", this);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
model.getCommands().add(tempVar2);
if (shouldAddressWarnning) {
model.setNote(ConstantsManager.getInstance().getConstants().removeDataCenterWarnningNote());
}
}
Aggregations