use of org.ovirt.engine.ui.uicommonweb.models.ListModel in project ovirt-engine by oVirt.
the class SanStorageLunToTargetList method createRootNode.
@Override
protected TreeItem createRootNode(LunModel rootModel) {
final EntityModelCellTable<ListModel<LunModel>> table = new EntityModelCellTable<>(multiSelection, (Resources) GWT.create(SanStorageListLunRootResources.class));
// Create table
initRootNodeTable(table);
// Set custom selection column
AbstractLunSelectionColumn lunSelectionColumn = new AbstractLunSelectionColumn(multiSelection) {
@Override
public LunModel getValue(LunModel object) {
return object;
}
};
// $NON-NLS-1$
table.setCustomSelectionColumn(lunSelectionColumn, "20px");
// Add items
List<LunModel> items = new ArrayList<>();
items.add(rootModel);
ListModel<LunModel> listModel = new ListModel<>();
listModel.setItems(items);
// Update table
table.setRowData(items);
table.asEditor().edit(listModel);
// $NON-NLS-1$
table.setWidth("100%");
// This was the height of the header
// $NON-NLS-1$
table.setHeight("26px");
rootModel.getPropertyChangedEvent().removeListener(lunModelSelectedItemListener);
rootModel.getPropertyChangedEvent().addListener(lunModelSelectedItemListener, table);
if (!multiSelection) {
table.getSelectionModel().addSelectionChangeHandler(event -> {
SingleSelectionModel SingleSelectionModel = (SingleSelectionModel) event.getSource();
LunModel selectedLunModel = (LunModel) SingleSelectionModel.getSelectedObject();
if (selectedLunModel != null) {
updateSelectedLunWarning(selectedLunModel);
}
});
} else {
table.getSelectionModel().setSelected(rootModel, rootModel.getIsSelected());
table.getSelectionModel().addSelectionChangeHandler(event -> model.updateLunWarningForDiscardAfterDelete());
}
// Create tree item
HorizontalPanel panel = new HorizontalPanel();
panel.add(table);
// $NON-NLS-1$
panel.setWidth("100%");
panel.getElement().getStyle().setTableLayout(TableLayout.FIXED);
TreeItem item = new TreeItem(table);
// Display LUNs as grayed-out if needed
if (rootModel.getIsGrayedOut()) {
grayOutItem(rootModel.getGrayedOutReasons(), rootModel, table);
}
return item;
}
use of org.ovirt.engine.ui.uicommonweb.models.ListModel in project ovirt-engine by oVirt.
the class NewTemplateVmModelBehavior method initDisks.
private void initDisks(ArrayList<Disk> disks) {
Collections.sort(disks, new DiskByDiskAliasComparator());
ArrayList<DiskModel> list = new ArrayList<>();
for (Disk disk : disks) {
DiskModel diskModel = new DiskModel();
switch(disk.getDiskStorageType()) {
case IMAGE:
DiskImage diskImage = (DiskImage) disk;
diskModel.setSize(new EntityModel<>((int) diskImage.getSizeInGigabytes()));
ListModel volumes = new ListModel();
volumes.setItems(diskImage.getVolumeType() == VolumeType.Preallocated ? new ArrayList<>(Arrays.asList(new VolumeType[] { VolumeType.Preallocated })) : AsyncDataProvider.getInstance().getVolumeTypeList(), diskImage.getVolumeType());
diskModel.setVolumeType(volumes);
diskModel.getAlias().setEntity(diskImage.getDiskAlias());
break;
case CINDER:
CinderDisk cinderDisk = (CinderDisk) disk;
diskModel.setSize(new EntityModel<>((int) cinderDisk.getSizeInGigabytes()));
ListModel volumeTypes = new ListModel();
volumeTypes.setItems(new ArrayList<>(Arrays.asList(cinderDisk.getVolumeType())), cinderDisk.getVolumeType());
diskModel.setVolumeType(volumeTypes);
diskModel.getAlias().setEntity(cinderDisk.getDiskAlias());
diskModel.getVolumeFormat().setIsChangeable(false);
break;
}
diskModel.setDisk(disk);
list.add(diskModel);
diskModel.getVolumeFormat().setIsAvailable(true);
}
getModel().setDisks(list);
}
use of org.ovirt.engine.ui.uicommonweb.models.ListModel in project ovirt-engine by oVirt.
the class SnapshotDetailModel method getEntityListModel.
public ListModel getEntityListModel() {
ListModel listModel = new ListModel();
ArrayList arrayList = new ArrayList();
for (Object object : (List) getEntity()) {
EntityModel entityModel = new EntityModel();
entityModel.setEntity(object);
arrayList.add(entityModel);
}
listModel.setItems(arrayList);
return listModel;
}
Aggregations