Search in sources :

Example 11 with AbstractEnumColumn

use of org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn in project ovirt-engine by oVirt.

the class SubTabHostVmView method initTable.

void initTable() {
    getTable().enableColumnResizing();
    VmStatusColumn<VM> statusIconColumn = new VmStatusColumn<>();
    statusIconColumn.setContextMenuTitle(constants.statusIconVm());
    // $NON-NLS-1$
    getTable().addColumn(statusIconColumn, constants.empty(), "30px");
    AbstractTextColumn<VM> nameColumn = new AbstractLinkColumn<VM>(new FieldUpdater<VM, String>() {

        @Override
        public void update(int index, VM vm, String value) {
            Map<String, String> parameters = new HashMap<>();
            parameters.put(FragmentParams.NAME.getName(), vm.getName());
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.virtualMachineGeneralSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(VM object) {
            return object.getName();
        }
    };
    nameColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameVm(), "160px");
    VmTypeColumn typeColumn = new VmTypeColumn();
    typeColumn.setContextMenuTitle(constants.typeVm());
    // $NON-NLS-1$
    getTable().addColumn(typeColumn, constants.empty(), "60px");
    AbstractTextColumn<VM> clusterColumn = new AbstractTextColumn<VM>() {

        @Override
        public String getValue(VM object) {
            return object.getClusterName();
        }
    };
    clusterColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(clusterColumn, constants.clusterVm(), "160px");
    AbstractTextColumn<VM> ipColumn = new AbstractTextColumn<VM>() {

        @Override
        public String getValue(VM object) {
            return object.getIp();
        }
    };
    ipColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(ipColumn, constants.ipVm(), "200px");
    AbstractTextColumn<VM> fqdnColumn = new AbstractTextColumn<VM>() {

        @Override
        public String getValue(VM object) {
            return object.getFqdn();
        }
    };
    fqdnColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(fqdnColumn, constants.fqdn(), "200px");
    getTable().addColumn(new ColumnResizeTableLineChartProgressBar<VM>(getTable(), new ResourceConsumptionComparator() {

        @Override
        protected Integer extractValue(VM vm) {
            return vm.getUsageMemPercent();
        }
    }) {

        @Override
        protected List<Integer> getProgressValues(VM object) {
            return object.getMemoryUsageHistory();
        }
    }, constants.memoryVm(), // $NON-NLS-1$
    "120px");
    getTable().addColumn(new ColumnResizeTableLineChartProgressBar<VM>(getTable(), new ResourceConsumptionComparator() {

        @Override
        protected Integer extractValue(VM vm) {
            return vm.getUsageCpuPercent();
        }
    }) {

        @Override
        protected List<Integer> getProgressValues(VM object) {
            return object.getCpuUsageHistory();
        }
    }, constants.cpuVm(), // $NON-NLS-1$
    "120px");
    getTable().addColumn(new ColumnResizeTableLineChartProgressBar<VM>(getTable(), new ResourceConsumptionComparator() {

        @Override
        protected Integer extractValue(VM vm) {
            return vm.getUsageNetworkPercent();
        }
    }) {

        @Override
        protected List<Integer> getProgressValues(VM object) {
            return object.getNetworkUsageHistory();
        }
    }, constants.networkVm(), // $NON-NLS-1$
    "120px");
    AbstractTextColumn<VM> statusColumn = new AbstractEnumColumn<VM, VMStatus>() {

        @Override
        protected VMStatus getRawValue(VM object) {
            // check, if the current host is a target for the migration, then override status
            final VDS vds = getDetailModel().getEntity();
            if (object.getStatus().equals(VMStatus.MigratingFrom) && vds != null && vds.getId().equals(object.getMigratingToVds())) {
                return VMStatus.MigratingTo;
            }
            return object.getStatus();
        }
    };
    statusColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(statusColumn, constants.statusVm(), "130px");
    AbstractTextColumn<VM> uptimeColumn = new AbstractUptimeColumn<VM>() {

        @Override
        protected Double getRawValue(VM object) {
            return object.getElapsedTime();
        }
    };
    uptimeColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(uptimeColumn, constants.uptimeVm(), "110px");
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) VmStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VmStatusColumn) AbstractUptimeColumn(org.ovirt.engine.ui.webadmin.widget.table.column.AbstractUptimeColumn) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) VM(org.ovirt.engine.core.common.businessentities.VM) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) List(java.util.List) VmTypeColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VmTypeColumn) HashMap(java.util.HashMap) Map(java.util.Map)

Example 12 with AbstractEnumColumn

use of org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn in project ovirt-engine by oVirt.

the class SubTabTemplateVmView method initTable.

void initTable() {
    getTable().enableColumnResizing();
    VmStatusColumn<VM> statusIconColumn = new VmStatusColumn<>();
    statusIconColumn.setContextMenuTitle(constants.statusIconVm());
    // $NON-NLS-1$
    getTable().addColumn(statusIconColumn, constants.empty(), "30px");
    AbstractTextColumn<VM> nameColumn = new AbstractLinkColumn<VM>(new FieldUpdater<VM, String>() {

        @Override
        public void update(int index, VM vm, String value) {
            Map<String, String> parameters = new HashMap<>();
            parameters.put(FragmentParams.NAME.getName(), vm.getName());
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.virtualMachineGeneralSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(VM object) {
            return object.getName();
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameVm(), "200px");
    VmTypeColumn typeColumn = new VmTypeColumn();
    typeColumn.setContextMenuTitle(constants.typeVm());
    // $NON-NLS-1$
    getTable().addColumn(typeColumn, constants.empty(), "60px");
    AbstractTextColumn<VM> hostColumn = new AbstractTextColumn<VM>() {

        @Override
        public String getValue(VM object) {
            return object.getRunOnVdsName();
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(hostColumn, constants.hostVm(), "200px");
    AbstractTextColumn<VM> ipColumn = new AbstractTextColumn<VM>() {

        @Override
        public String getValue(VM object) {
            return object.getIp();
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(ipColumn, constants.ipVm(), "200px");
    AbstractTextColumn<VM> fqdnColumn = new AbstractTextColumn<VM>() {

        @Override
        public String getValue(VM object) {
            return object.getFqdn();
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(fqdnColumn, constants.fqdn(), "200px");
    AbstractTextColumn<VM> statusColumn = new AbstractEnumColumn<VM, VMStatus>() {

        @Override
        protected VMStatus getRawValue(VM object) {
            return object.getStatus();
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(statusColumn, constants.statusVm(), "200px");
    AbstractTextColumn<VM> uptimeColumn = new AbstractUptimeColumn<VM>() {

        @Override
        protected Double getRawValue(VM object) {
            return object.getElapsedTime();
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(uptimeColumn, constants.uptimeVm(), "200px");
    AbstractTextColumn<VM> consoleConnectedUserColumn = new AbstractTextColumn<VM>() {

        @Override
        public String getValue(VM vm) {
            return StringHelper.isNotNullOrEmpty(vm.getClientIp()) ? vm.getConsoleCurentUserName() : null;
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(consoleConnectedUserColumn, constants.consoleConnectedUserVm(), "200px");
    AbstractTextColumn<VM> loggedInUserColumn = new AbstractTextColumn<VM>() {

        @Override
        public String getValue(VM object) {
            return object.getGuestCurentUserName();
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(loggedInUserColumn, constants.loggedInUserVm(), "200px");
}
Also used : VmStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VmStatusColumn) AbstractUptimeColumn(org.ovirt.engine.ui.webadmin.widget.table.column.AbstractUptimeColumn) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) VM(org.ovirt.engine.core.common.businessentities.VM) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) VmTypeColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VmTypeColumn) HashMap(java.util.HashMap) Map(java.util.Map)

Example 13 with AbstractEnumColumn

use of org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn in project ovirt-engine by oVirt.

the class SubTabPoolVmView method initTable.

void initTable() {
    getTable().showPagingButtons();
    getTable().enableColumnResizing();
    VmStatusColumn<VM> statusIconColumn = new VmStatusColumn<>();
    statusIconColumn.setContextMenuTitle(constants.statusIconVm());
    // $NON-NLS-1$
    getTable().addColumn(statusIconColumn, constants.empty(), "30px");
    AbstractTextColumn<VM> nameColumn = new AbstractLinkColumn<VM>(new FieldUpdater<VM, String>() {

        @Override
        public void update(int index, VM vm, String value) {
            Map<String, String> parameters = new HashMap<>();
            parameters.put(FragmentParams.NAME.getName(), vm.getName());
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.virtualMachineGeneralSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(VM object) {
            return object.getName();
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameVm(), "200px");
    VmTypeColumn typeColumn = new VmTypeColumn();
    typeColumn.setContextMenuTitle(constants.typeVm());
    // $NON-NLS-1$
    getTable().addColumn(typeColumn, constants.empty(), "60px");
    AbstractTextColumn<VM> hostColumn = new AbstractTextColumn<VM>() {

        @Override
        public String getValue(VM object) {
            return object.getRunOnVdsName();
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(hostColumn, constants.hostVm(), "200px");
    AbstractTextColumn<VM> ipColumn = new AbstractTextColumn<VM>() {

        @Override
        public String getValue(VM object) {
            return object.getIp();
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(ipColumn, constants.ipVm(), "200px");
    AbstractTextColumn<VM> fqdnColumn = new AbstractTextColumn<VM>() {

        @Override
        public String getValue(VM object) {
            return object.getFqdn();
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(fqdnColumn, constants.fqdn(), "200px");
    AbstractTextColumn<VM> statusColumn = new AbstractEnumColumn<VM, VMStatus>() {

        @Override
        protected VMStatus getRawValue(VM object) {
            return object.getStatus();
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(statusColumn, constants.statusVm(), "200px");
    AbstractTextColumn<VM> uptimeColumn = new AbstractUptimeColumn<VM>() {

        @Override
        protected Double getRawValue(VM object) {
            return object.getElapsedTime();
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(uptimeColumn, constants.uptimeVm(), "200px");
    AbstractTextColumn<VM> consoleConnectedUserColumn = new AbstractTextColumn<VM>() {

        @Override
        public String getValue(VM vm) {
            return StringHelper.isNotNullOrEmpty(vm.getClientIp()) ? vm.getConsoleCurentUserName() : null;
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(consoleConnectedUserColumn, constants.consoleConnectedUserVm(), "200px");
    AbstractTextColumn<VM> loggedInUserColumn = new AbstractTextColumn<VM>() {

        @Override
        public String getValue(VM object) {
            return object.getGuestCurentUserName();
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(loggedInUserColumn, constants.loggedInUserVm(), "200px");
}
Also used : VmStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VmStatusColumn) AbstractUptimeColumn(org.ovirt.engine.ui.webadmin.widget.table.column.AbstractUptimeColumn) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) VM(org.ovirt.engine.core.common.businessentities.VM) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) VmTypeColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VmTypeColumn) HashMap(java.util.HashMap) Map(java.util.Map)

Example 14 with AbstractEnumColumn

use of org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn in project ovirt-engine by oVirt.

the class MainStorageView method initTable.

void initTable() {
    getTable().enableColumnResizing();
    StorageDomainSharedStatusColumn sharedStatusColumn = new StorageDomainSharedStatusColumn();
    sharedStatusColumn.setContextMenuTitle(constants.sharedStatusStorage());
    // $NON-NLS-1$
    getTable().addColumn(sharedStatusColumn, constants.empty(), "30px");
    StorageDomainAdditionalStatusColumn additionalStatusColumn = new StorageDomainAdditionalStatusColumn();
    additionalStatusColumn.setContextMenuTitle(constants.additionalStatusStorage());
    // $NON-NLS-1$
    getTable().addColumn(additionalStatusColumn, constants.empty(), "60px");
    AbstractTextColumn<StorageDomain> nameColumn = new AbstractLinkColumn<StorageDomain>(new FieldUpdater<StorageDomain, String>() {

        @Override
        public void update(int index, StorageDomain storageDomain, String value) {
            Map<String, String> parameters = new HashMap<>();
            parameters.put(FragmentParams.NAME.getName(), storageDomain.getName());
            // The link was clicked, now fire an event to switch to details.
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.storageGeneralSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(StorageDomain object) {
            return object.getName();
        }
    };
    nameColumn.makeSortable(StorageDomainFieldAutoCompleter.NAME);
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.domainNameStorage(), "150px");
    CommentColumn<StorageDomain> commentColumn = new CommentColumn<>();
    getTable().addColumnWithHtmlHeader(commentColumn, SafeHtmlUtils.fromSafeConstant(constants.commentLabel()), // $NON-NLS-1$
    "75px");
    AbstractTextColumn<StorageDomain> domainTypeColumn = new AbstractEnumColumn<StorageDomain, StorageDomainType>() {

        @Override
        protected StorageDomainType getRawValue(StorageDomain object) {
            return object.getStorageDomainType();
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(domainTypeColumn, constants.domainTypeStorage(), "150px");
    AbstractTextColumn<StorageDomain> storageTypeColumn = new AbstractEnumColumn<StorageDomain, StorageType>() {

        @Override
        protected StorageType getRawValue(StorageDomain object) {
            return object.getStorageType();
        }
    };
    storageTypeColumn.makeSortable(StorageDomainFieldAutoCompleter.TYPE);
    // $NON-NLS-1$
    getTable().addColumn(storageTypeColumn, constants.storageTypeStorage(), "150px");
    AbstractTextColumn<StorageDomain> formatColumn = new AbstractEnumColumn<StorageDomain, StorageFormatType>() {

        @Override
        protected StorageFormatType getRawValue(StorageDomain object) {
            return object.getStorageFormat();
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(formatColumn, constants.formatStorage(), "140px");
    AbstractTextColumn<StorageDomain> crossDataCenterStatusColumn = new AbstractTextColumn<StorageDomain>() {

        @Override
        public String getValue(StorageDomain object) {
            if (object.getStorageDomainType() == StorageDomainType.ISO) {
                return EnumTranslator.getInstance().translate(object.getStorageDomainSharedStatus());
            } else {
                return EnumTranslator.getInstance().translate(object.getStatus());
            }
        }
    };
    crossDataCenterStatusColumn.makeSortable(StorageDomainFieldAutoCompleter.STATUS);
    // $NON-NLS-1$
    getTable().addColumn(crossDataCenterStatusColumn, constants.crossDcStatusStorage(), "210px");
    AbstractStorageSizeColumn<StorageDomain> totalSpaceColumn = new AbstractStorageSizeColumn<StorageDomain>() {

        @Override
        public Long getRawValue(StorageDomain object) {
            Integer totalSpace = object.getTotalDiskSize();
            return totalSpace == null ? null : Long.valueOf(totalSpace);
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(totalSpaceColumn, constants.totalSpaceStorage(), "130px");
    AbstractStorageSizeColumn<StorageDomain> freeSpaceColumn = new AbstractStorageSizeColumn<StorageDomain>() {

        @Override
        public Long getRawValue(StorageDomain object) {
            Integer availableDiskSize = object.getAvailableDiskSize();
            return availableDiskSize == null ? null : Long.valueOf(availableDiskSize);
        }
    };
    freeSpaceColumn.makeSortable(StorageDomainFieldAutoCompleter.SIZE);
    // $NON-NLS-1$
    getTable().addColumn(freeSpaceColumn, constants.freeSpaceStorage(), "130px");
    AbstractTextColumn<StorageDomain> descriptionColumn = new AbstractTextColumn<StorageDomain>() {

        @Override
        public String getValue(StorageDomain object) {
            return object.getDescription();
        }
    };
    descriptionColumn.makeSortable(StorageDomainFieldAutoCompleter.DESCRIPTION);
    // $NON-NLS-1$
    getTable().addColumn(descriptionColumn, constants.domainDescriptionStorage(), "200px");
}
Also used : StorageDomainAdditionalStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.StorageDomainAdditionalStatusColumn) StorageDomainSharedStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.StorageDomainSharedStatusColumn) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) AbstractStorageSizeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractStorageSizeColumn) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) CommentColumn(org.ovirt.engine.ui.webadmin.widget.table.column.CommentColumn) HashMap(java.util.HashMap) Map(java.util.Map)

Example 15 with AbstractEnumColumn

use of org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn in project ovirt-engine by oVirt.

the class ImportVmFromExportDomainPopupView method initMainTable.

protected void initMainTable() {
    this.table = new ListModelObjectCellTable<>();
    table.enableColumnResizing();
    AbstractImageResourceColumn<Object> isProblematicImportVmColumn = new AbstractImageResourceColumn<Object>() {

        @Override
        public ImageResource getValue(Object object) {
            ImportVmData importVmData = (ImportVmData) object;
            if (importVmData.getError() != null || importVmData.isNameExistsInTheSystem()) {
                return resources.errorImage();
            }
            if (importVmData.getWarning() != null) {
                return resources.alertImage();
            }
            return null;
        }

        @Override
        public SafeHtml getTooltip(Object object) {
            ImportVmData importVmData = (ImportVmData) object;
            String problem = null;
            if (importVmData.getError() != null) {
                problem = importVmData.getError();
            } else {
                problem = importVmData.isNameExistsInTheSystem() ? ConstantsManager.getInstance().getConstants().nameMustBeUniqueInvalidReason() : importVmData.getWarning();
            }
            return problem != null ? SafeHtmlUtils.fromSafeConstant(problem) : null;
        }
    };
    // $NON-NLS-1$
    table.addColumn(isProblematicImportVmColumn, constants.empty(), "30px");
    AbstractTextColumn<Object> nameColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            String originalName = ((ImportVmData) object).getName();
            String givenName = ((ImportVmData) object).getVm().getName();
            return originalName.equals(givenName) ? givenName : // $NON-NLS-1$ //$NON-NLS-2$
            givenName + " (" + originalName + ")";
        }
    };
    // $NON-NLS-1$
    table.addColumn(nameColumn, constants.nameVm(), "150px");
    AbstractCheckboxColumn<Object> collapseSnapshotsColumn = new AbstractCheckboxColumn<Object>((index, model, value) -> {
        ((ImportVmData) model).getCollapseSnapshots().setEntity(value);
        customSelectionCellFormatType.setEnabled(value);
        diskTable.asEditor().edit(importModel.getImportDiskListModel());
    }) {

        @Override
        public Boolean getValue(Object model) {
            return ((ImportVmData) model).getCollapseSnapshots().getEntity();
        }

        @Override
        protected boolean canEdit(Object model) {
            return ((ImportVmData) model).getCollapseSnapshots().getIsChangable();
        }

        @Override
        protected String getDisabledMessage(Object model) {
            return ((ImportVmData) model).getCollapseSnapshots().getChangeProhibitionReason();
        }

        @Override
        public SafeHtml getTooltip(Object object) {
            SafeHtml superTooltip = super.getTooltip(object);
            if (superTooltip == null) {
                return SafeHtmlUtils.fromSafeConstant(constants.importAllocationModifiedCollapse());
            }
            return superTooltip;
        }
    };
    // $NON-NLS-1$
    table.addColumn(collapseSnapshotsColumn, constants.collapseSnapshots(), "130px");
    AbstractCheckboxColumn<Object> cloneVMColumn = new AbstractCheckboxColumn<Object>((index, model, value) -> {
        ((ImportVmData) model).getClone().setEntity(value);
        table.asEditor().edit(importModel);
    }) {

        @Override
        public Boolean getValue(Object model) {
            return ((ImportVmData) model).getClone().getEntity();
        }

        @Override
        protected boolean canEdit(Object model) {
            return ((ImportVmData) model).getClone().getIsChangable();
        }

        @Override
        protected String getDisabledMessage(Object model) {
            return ((ImportVmData) model).getClone().getChangeProhibitionReason();
        }
    };
    // $NON-NLS-1$
    table.addColumn(cloneVMColumn, constants.cloneVM(), "50px");
    AbstractTextColumn<Object> originColumn = new AbstractEnumColumn<Object, OriginType>() {

        @Override
        protected OriginType getRawValue(Object object) {
            return ((ImportVmData) object).getVm().getOrigin();
        }
    };
    // $NON-NLS-1$
    table.addColumn(originColumn, constants.originVm(), "100px");
    table.addColumn(new AbstractSafeHtmlColumn<Object>() {

        @Override
        public SafeHtml getValue(Object object) {
            return VmTypeColumn.getRenderedValue(((ImportVmData) object).getVm());
        }
    }, constants.empty(), // $NON-NLS-1$
    "30px");
    AbstractTextColumn<Object> memoryColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return messages.megabytes(String.valueOf(((ImportVmData) object).getVm().getVmMemSizeMb()));
        }
    };
    // $NON-NLS-1$
    table.addColumn(memoryColumn, constants.memoryVm(), "90px");
    AbstractTextColumn<Object> cpuColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return String.valueOf(((ImportVmData) object).getVm().getNumOfCpus());
        }
    };
    // $NON-NLS-1$
    table.addColumn(cpuColumn, constants.cpusVm(), "50px");
    AbstractTextColumn<Object> archColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return String.valueOf(((ImportVmData) object).getVm().getClusterArch());
        }
    };
    // $NON-NLS-1$
    table.addColumn(archColumn, constants.architectureVm(), "100px");
    AbstractTextColumn<Object> diskColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return String.valueOf(((ImportVmData) object).getVm().getDiskMap().size());
        }
    };
    // $NON-NLS-1$
    table.addColumn(diskColumn, constants.disksVm(), "55px");
    isObjectInSystemColumn = new AbstractImageResourceColumn<Object>() {

        @Override
        public ImageResource getValue(Object object) {
            return ((ImportVmData) object).isExistsInSystem() ? resources.logNormalImage() : null;
        }
    };
    // $NON-NLS-1$
    table.addColumn(isObjectInSystemColumn, constants.vmInSetup(), "100px");
    table.getSelectionModel().addSelectionChangeHandler(event -> {
        ImportVmData selectedObject = ((SingleSelectionModel<ImportVmData>) event.getSource()).getSelectedObject();
        customSelectionCellFormatType.setEnabled(selectedObject.getCollapseSnapshots().getEntity());
    });
    ScrollPanel sp = new ScrollPanel();
    sp.add(table);
    splitLayoutPanel.add(sp);
    table.getElement().getStyle().setPosition(Position.RELATIVE);
}
Also used : SingleSelectionModel(com.google.gwt.view.client.SingleSelectionModel) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) ImportVmData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportVmData) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) ImageResource(com.google.gwt.resources.client.ImageResource) AbstractImageResourceColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractImageResourceColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Aggregations

AbstractEnumColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn)26 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)23 HashMap (java.util.HashMap)13 Map (java.util.Map)13 AbstractLinkColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn)13 VM (org.ovirt.engine.core.common.businessentities.VM)6 AbstractUptimeColumn (org.ovirt.engine.ui.webadmin.widget.table.column.AbstractUptimeColumn)6 VmTypeColumn (org.ovirt.engine.ui.webadmin.widget.table.column.VmTypeColumn)6 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)5 NoSelectionModel (com.google.gwt.view.client.NoSelectionModel)4 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)4 AbstractDiskSizeColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractDiskSizeColumn)4 VmStatusColumn (org.ovirt.engine.ui.webadmin.widget.table.column.VmStatusColumn)4 HasCell (com.google.gwt.cell.client.HasCell)3 ImageResource (com.google.gwt.resources.client.ImageResource)3 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)3 ScrollPanel (com.google.gwt.user.client.ui.ScrollPanel)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)3