use of org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel in project ovirt-engine by oVirt.
the class DataCenterStorageListModel method onAttach.
public void onAttach() {
ListModel<EntityModel<StorageDomain>> model = (ListModel<EntityModel<StorageDomain>>) getWindow();
List<StorageDomain> selectedDataStorageDomains = new ArrayList<>();
if (getEntity() == null) {
cancel();
return;
}
selectedStorageDomains = new ArrayList<>();
for (EntityModel<StorageDomain> a : model.getItems()) {
if (a.getIsSelected()) {
StorageDomain storageDomain = a.getEntity();
selectedStorageDomains.add(storageDomain);
if (storageDomain.getStorageDomainType() == StorageDomainType.Data) {
selectedDataStorageDomains.add(storageDomain);
}
}
}
if (selectedStorageDomains.isEmpty()) {
cancel();
return;
}
AsyncDataProvider.getInstance().getStorageDomainsWithAttachedStoragePoolGuid(new AsyncQuery<>(attachedStorageDomains -> {
if (!attachedStorageDomains.isEmpty()) {
ConfirmationModel confirmationModel = new ConfirmationModel();
setWindow(null);
setWindow(confirmationModel);
List<String> stoageDomainNames = attachedStorageDomains.stream().map(StorageDomainStatic::getStorageName).collect(Collectors.toList());
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", DataCenterStorageListModel.this);
onApprove.setTitle(ConstantsManager.getInstance().getConstants().ok());
onApprove.setIsDefault(true);
confirmationModel.getCommands().add(onApprove);
// $NON-NLS-1$
UICommand cancel = new UICommand("Cancel", DataCenterStorageListModel.this);
cancel.setTitle(ConstantsManager.getInstance().getConstants().cancel());
cancel.setIsCancel(true);
confirmationModel.getCommands().add(cancel);
} else {
executeAttachStorageDomains();
}
}), getEntity(), selectedDataStorageDomains);
}
use of org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel in project ovirt-engine by oVirt.
the class DataCenterStorageListModel method detach.
public void detach() {
if (getWindow() != null) {
return;
}
ConfirmationModel model = new ConfirmationModel();
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().detachStorageTitle());
model.setHelpTag(HelpTag.detach_storage);
// $NON-NLS-1$
model.setHashName("detach_storage");
model.setMessage(ConstantsManager.getInstance().getConstants().areYouSureYouWantDetachFollowingStoragesMsg());
List<String> list = new ArrayList<>();
boolean shouldAddressWarnning = false;
for (StorageDomain item : getSelectedItems()) {
list.add(item.getStorageName());
if (item.getStorageDomainType().isDataDomain()) {
shouldAddressWarnning = true;
break;
}
}
model.setItems(list);
if (containsLocalStorage(model)) {
shouldAddressWarnning = false;
model.getForce().setIsAvailable(true);
model.getForce().setIsChangeable(true);
model.setForceLabel(ConstantsManager.getInstance().getConstants().storageRemovePopupFormatLabel());
model.setNote(ConstantsManager.getInstance().getMessages().detachNote(getLocalStoragesFormattedString()));
}
if (shouldAddressWarnning) {
model.setNote(ConstantsManager.getInstance().getConstants().detachWarnningNote());
}
// $NON-NLS-1$
UICommand tempVar = UICommand.createDefaultOkUiCommand("OnDetach", this);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
model.getCommands().add(tempVar2);
}
use of org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel in project ovirt-engine by oVirt.
the class DataCenterStorageListModel method onDetach.
public void onDetach() {
final ConfirmationModel confirmModel = (ConfirmationModel) getWindow();
if (confirmModel.getProgress() != null) {
return;
}
if (!confirmModel.validate()) {
return;
}
// A list of 'detach' action parameters
setDetachParams(new ArrayList<>());
// A list of 'remove' action parameters
setRemoveParams(new ArrayList<>());
String localStorgaeDC = null;
for (StorageDomain a : getSelectedItems()) {
// For local storage - remove; otherwise - detach
if (a.getStorageType() == StorageType.LOCALFS && a.getStorageDomainType() != StorageDomainType.ISO) {
getRemoveParams().add(new RemoveStorageDomainParameters(a.getId()));
localStorgaeDC = a.getStoragePoolName();
} else {
getDetachParams().add(new DetachStorageDomainFromPoolParameters(a.getId(), getEntity().getId()));
}
}
confirmModel.startProgress();
if (getRemoveParams().size() > 0) {
AsyncDataProvider.getInstance().getLocalStorageHost(new AsyncQuery<>(locaVds -> {
for (ActionParametersBase item : getRemoveParams()) {
((RemoveStorageDomainParameters) item).setVdsId(locaVds != null ? locaVds.getId() : null);
((RemoveStorageDomainParameters) item).setDoFormat(confirmModel.getForce().getEntity());
}
postDetach(getWindow());
}), localStorgaeDC);
} else {
postDetach(confirmModel);
}
}
use of org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel in project ovirt-engine by oVirt.
the class DataCenterStorageListModel method onMaintenance.
public void onMaintenance() {
final ConfirmationModel confirmationModel = (ConfirmationModel) getWindow();
List<ActionParametersBase> pb = getSelectedItems().stream().map(sd -> new DeactivateStorageDomainWithOvfUpdateParameters(sd.getId(), getEntity().getId(), confirmationModel.getForce().getEntity())).collect(Collectors.toList());
confirmationModel.startProgress();
Frontend.getInstance().runMultipleAction(ActionType.DeactivateStorageDomainWithOvfUpdate, pb, result -> {
confirmationModel.stopProgress();
setWindow(null);
});
}
use of org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel in project ovirt-engine by oVirt.
the class VolumeBrickListModel method onRemoveBricks.
private void onRemoveBricks() {
if (getWindow() == null) {
return;
}
RemoveBrickModel model = (RemoveBrickModel) getWindow();
if (model.getProgress() != null) {
return;
}
if (getSelectedItems() == null || getSelectedItems().isEmpty()) {
return;
}
GlusterVolumeEntity volumeEntity = getEntity();
GlusterVolumeRemoveBricksParameters parameter = new GlusterVolumeRemoveBricksParameters(volumeEntity.getId(), getSelectedItems());
if (volumeEntity.getVolumeType() == GlusterVolumeType.REPLICATE) {
parameter.setReplicaCount(volumeEntity.getReplicaCount() - 1);
} else if (volumeEntity.getVolumeType() == GlusterVolumeType.DISTRIBUTED_REPLICATE) {
if (model.isReduceReplica()) {
parameter.setReplicaCount(volumeEntity.getReplicaCount() - 1);
} else {
parameter.setReplicaCount(volumeEntity.getReplicaCount());
}
}
model.startProgress();
boolean isMigrate = model.getMigrateData().getEntity();
Frontend.getInstance().runAction(isMigrate ? ActionType.StartRemoveGlusterVolumeBricks : ActionType.GlusterVolumeRemoveBricks, parameter, result -> {
ConfirmationModel localModel = (ConfirmationModel) result.getState();
localModel.stopProgress();
setWindow(null);
}, model);
}
Aggregations