Search in sources :

Example 41 with ListModel

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;
}
Also used : EntityModelCellTable(org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable) SingleSelectionModel(com.google.gwt.view.client.SingleSelectionModel) TreeItem(com.google.gwt.user.client.ui.TreeItem) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ArrayList(java.util.ArrayList) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) LunModel(org.ovirt.engine.ui.uicommonweb.models.storage.LunModel) AbstractLunSelectionColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLunSelectionColumn)

Example 42 with ListModel

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);
}
Also used : VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ArrayList(java.util.ArrayList) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) DiskByDiskAliasComparator(org.ovirt.engine.core.common.businessentities.comparators.DiskByDiskAliasComparator)

Example 43 with ListModel

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;
}
Also used : ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

ListModel (org.ovirt.engine.ui.uicommonweb.models.ListModel)43 ArrayList (java.util.ArrayList)29 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)19 List (java.util.List)17 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)11 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)11 SearchableListModel (org.ovirt.engine.ui.uicommonweb.models.SearchableListModel)9 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)8 EntityModelCellTable (org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable)8 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)8 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)7 TreeItem (com.google.gwt.user.client.ui.TreeItem)6 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)6 Model (org.ovirt.engine.ui.uicommonweb.models.Model)6 Provider (org.ovirt.engine.core.common.businessentities.Provider)5 QueryType (org.ovirt.engine.core.common.queries.QueryType)5 PropertyChangedEventArgs (org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs)5 Collections (java.util.Collections)4 ApplicationMode (org.ovirt.engine.core.common.mode.ApplicationMode)4 Linq (org.ovirt.engine.ui.uicommonweb.Linq)4