use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class StorageDataCenterListModel method postAttachInit.
public void postAttachInit(ArrayList<EntityModel> datacenters) {
ListModel<EntityModel> model = new ListModel<>();
model.setHelpTag(HelpTag.attach_storage);
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().attachToDataCenterTitle());
if (getEntity() != null) {
switch(getEntity().getStorageDomainType()) {
case ISO:
setHelpTag(HelpTag.attach_iso_library);
break;
case Data:
setHelpTag(HelpTag.attach_storage);
break;
case ImportExport:
setHelpTag(HelpTag.attach_export_domain);
break;
}
}
if (datacenters.isEmpty()) {
model.setMessage(ConstantsManager.getInstance().getConstants().thereAreNoDataCenterStorageDomainAttachedMsg());
// $NON-NLS-1$
UICommand tempVar = new UICommand("Cancel", this);
tempVar.setTitle(ConstantsManager.getInstance().getConstants().close());
tempVar.setIsDefault(true);
tempVar.setIsCancel(true);
model.getCommands().add(tempVar);
} else {
model.setItems(datacenters);
List<EntityModel> initialSelection = new ArrayList<>();
initialSelection.add(datacenters.get(0));
model.setSelectedItems(initialSelection);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createDefaultOkUiCommand("OnAttach", this);
model.getCommands().add(tempVar2);
// $NON-NLS-1$
UICommand tempVar3 = UICommand.createCancelUiCommand("Cancel", this);
model.getCommands().add(tempVar3);
}
}
use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class StorageDataCenterListModel method addToAttachCandidateDatacenters.
public void addToAttachCandidateDatacenters(StoragePool dataCenter, boolean addDatacenter) {
// Add a new datacenter EntityModel
EntityModel dcEntityModel = new EntityModel();
if (addDatacenter) {
dcEntityModel.setEntity(dataCenter);
}
getattachCandidateDatacenters().add(dcEntityModel);
// If not finished going through the datacenters list - return
if (getattachCandidateDatacenters().size() != getAvailableDataCenters().size()) {
return;
}
// Filter datacenters list
ArrayList<EntityModel> datacenters = new ArrayList<>();
for (EntityModel datacenter : getattachCandidateDatacenters()) {
if (datacenter.getEntity() != null) {
datacenters.add(datacenter);
}
}
postAttachInit(datacenters);
}
use of org.ovirt.engine.ui.uicommonweb.models.EntityModel 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.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class BootSequenceModel method getSequence.
public BootSequence getSequence() {
StringBuilder str = new StringBuilder();
for (EntityModel a : getItems()) {
if (a.getIsChangable()) {
BootSequence bs = (BootSequence) a.getEntity();
str.append(bs.toString());
}
}
// $NON-NLS-1$
return !str.toString().equals("") ? BootSequence.valueOf(str.toString()) : null;
}
use of org.ovirt.engine.ui.uicommonweb.models.EntityModel 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);
}
Aggregations