use of org.ovirt.engine.core.common.action.ActionParametersBase in project ovirt-engine by oVirt.
the class VmBackupModel method onRemove.
private void onRemove() {
ConfirmationModel model = (ConfirmationModel) getWindow();
if (model.getProgress() != null) {
return;
}
model.startProgress();
AsyncDataProvider.getInstance().getDataCentersByStorageDomain(new AsyncQuery<>(pools -> {
if (pools != null && pools.size() > 0) {
StoragePool pool = pools.get(0);
ArrayList<ActionParametersBase> list = new ArrayList<>();
for (VM vm : getSelectedItems()) {
list.add(new RemoveVmFromImportExportParameters(vm.getId(), getEntity().getId(), pool.getId()));
}
Frontend.getInstance().runMultipleAction(ActionType.RemoveVmFromImportExport, list, result -> {
ConfirmationModel localModel = (ConfirmationModel) result.getState();
localModel.stopProgress();
cancel();
onEntityChanged();
}, getWindow());
}
}), getEntity().getId());
}
use of org.ovirt.engine.core.common.action.ActionParametersBase in project ovirt-engine by oVirt.
the class AttachDiskModel method store.
@Override
public void store(IFrontendActionAsyncCallback callback) {
if (getProgress() != null || !validate()) {
return;
}
ArrayList<ActionType> actionTypes = new ArrayList<>();
ArrayList<ActionParametersBase> paramerterList = new ArrayList<>();
ArrayList<IFrontendActionAsyncCallback> callbacks = new ArrayList<>();
IFrontendActionAsyncCallback onFinishCallback = callback != null ? callback : result -> {
NewDiskModel diskModel = (NewDiskModel) result.getState();
diskModel.stopProgress();
diskModel.cancel();
};
List<EntityModel<DiskModel>> disksToAttach = getSelectedDisks();
for (int i = 0; i < disksToAttach.size(); i++) {
DiskModel disk = disksToAttach.get(i).getEntity();
/*
IDE disks can be activated only when the VM is down.
Other disks can be hot plugged.
*/
boolean activate = false;
if (getIsPlugged().getEntity()) {
activate = disk.getDiskInterface().getSelectedItem() == DiskInterface.IDE ? getVm().getStatus() == VMStatus.Down : true;
}
DiskVmElement dve = new DiskVmElement(disk.getDisk().getId(), getVm().getId());
dve.setBoot(disk.getIsBootable().getEntity());
dve.setDiskInterface(disk.getDiskInterface().getSelectedItem());
dve.setReadOnly(disk.isReadOnly());
AttachDetachVmDiskParameters parameters = new AttachDetachVmDiskParameters(dve, activate);
actionTypes.add(ActionType.AttachDiskToVm);
paramerterList.add(parameters);
callbacks.add(i == disksToAttach.size() - 1 ? onFinishCallback : null);
}
startProgress();
Frontend.getInstance().runMultipleActions(actionTypes, paramerterList, callbacks, null, this);
}
use of org.ovirt.engine.core.common.action.ActionParametersBase in project ovirt-engine by oVirt.
the class UserListModel method onRemove.
public void onRemove() {
List<DbUser> selectedItems = getSelectedItems();
ArrayList<ActionParametersBase> userPrms = new ArrayList<>();
ArrayList<ActionParametersBase> groupPrms = new ArrayList<>();
for (DbUser item : selectedItems) {
if (!item.isGroup()) {
userPrms.add(new IdParameters(item.getId()));
} else {
groupPrms.add(new IdParameters(item.getId()));
}
}
IFrontendMultipleActionAsyncCallback lastCallback = result -> Scheduler.get().scheduleDeferred(() -> {
// Refresh user list.
syncSearch();
cancel();
});
if (getUserOrGroup() == UserOrGroup.User) {
if (userPrms.size() > 0) {
Frontend.getInstance().runMultipleAction(ActionType.RemoveUser, userPrms, lastCallback);
}
} else if (getUserOrGroup() == UserOrGroup.Group) {
if (groupPrms.size() > 0) {
Frontend.getInstance().runMultipleAction(ActionType.RemoveGroup, groupPrms, lastCallback);
}
}
}
use of org.ovirt.engine.core.common.action.ActionParametersBase in project ovirt-engine by oVirt.
the class UserListModel method onAdd.
public void onAdd(final boolean closeWindow) {
AdElementListModel model = (AdElementListModel) getWindow();
if (model.getProgress() != null) {
return;
}
if (model.getSelectedItems() == null) {
cancel();
return;
}
List<EntityModel<DbUser>> selectedItems = new ArrayList<>();
for (EntityModel<DbUser> dbUserEntity : model.getItems()) {
if (dbUserEntity.getIsSelected()) {
selectedItems.add(dbUserEntity);
}
}
List<ActionType> actionsList = new ArrayList<>(selectedItems.size());
List<ActionParametersBase> parametersList = new ArrayList<>(selectedItems.size());
ActionParametersBase parameters = null;
for (EntityModel<DbUser> item : selectedItems) {
if (item.getEntity().isGroup()) {
actionsList.add(ActionType.AddGroup);
DbGroup grp = new DbGroup();
grp.setExternalId(item.getEntity().getExternalId());
grp.setName(item.getEntity().getFirstName());
grp.setNamespace(item.getEntity().getNamespace());
grp.setId(item.getEntity().getId());
grp.setDomain(item.getEntity().getDomain());
parameters = new AddGroupParameters(grp);
} else {
actionsList.add(ActionType.AddUser);
parameters = new AddUserParameters(item.getEntity());
}
parametersList.add(parameters);
}
model.startProgress();
IFrontendActionAsyncCallback lastCallback = result -> {
AdElementListModel localModel = (AdElementListModel) result.getState();
localModel.stopProgress();
// Refresh user list.
syncSearch();
if (closeWindow) {
cancel();
}
};
Collection<EntityModel<DbUser>> currentItems = model.getItems();
List<IFrontendActionAsyncCallback> callbacksList = new ArrayList<>(selectedItems.size());
for (EntityModel<DbUser> user : selectedItems) {
callbacksList.add(nopCallback);
currentItems.remove(user);
}
callbacksList.remove(callbacksList.size() - 1);
callbacksList.add(lastCallback);
// Refresh display
model.setItems(null);
model.setItems(currentItems);
Frontend.getInstance().runMultipleActions(actionsList, parametersList, callbacksList, lastCallback, model);
}
use of org.ovirt.engine.core.common.action.ActionParametersBase in project ovirt-engine by oVirt.
the class UserPermissionListModel method onRemove.
private void onRemove() {
if (getSelectedItems() != null && getSelectedItems().size() > 0) {
ConfirmationModel model = (ConfirmationModel) getWindow();
if (model.getProgress() != null) {
return;
}
ArrayList<ActionParametersBase> list = new ArrayList<>();
for (Object perm : getSelectedItems()) {
PermissionsOperationsParameters tempVar = new PermissionsOperationsParameters();
tempVar.setPermission((Permission) perm);
list.add(tempVar);
}
model.startProgress();
Frontend.getInstance().runMultipleAction(ActionType.RemovePermission, list, result -> {
ConfirmationModel localModel = (ConfirmationModel) result.getState();
localModel.stopProgress();
cancel();
}, model);
} else {
cancel();
}
}
Aggregations