Search in sources :

Example 6 with AbstractTextColumn

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

the class ErrataTableView method initErrataGrid.

/**
 * Setup the columns in the errata grid. This configuration is also used in MainEngineErrataView.
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void initErrataGrid(HasColumns grid, boolean isEngineErrataView, final PlaceTransitionHandler transitionHandler) {
    grid.enableColumnResizing();
    AbstractIconTypeColumn<Erratum> errataTypeColumn = new AbstractIconTypeColumn<Erratum>() {

        @Override
        public IconType getValue(Erratum erratum) {
            if (erratum.getType() == ErrataType.BUGFIX) {
                getCell().setColor(SafeHtmlUtils.fromTrustedString(ErrataType.BUGFIX.getColor()));
                return IconType.BUG;
            } else if (erratum.getType() == ErrataType.ENHANCEMENT) {
                getCell().setColor(SafeHtmlUtils.fromTrustedString(ErrataType.ENHANCEMENT.getColor()));
                return IconType.PLUS_SQUARE;
            } else if (erratum.getType() == ErrataType.SECURITY) {
                getCell().setColor(SafeHtmlUtils.fromTrustedString(ErrataType.SECURITY.getColor()));
                return IconType.WARNING;
            }
            return null;
        }
    };
    errataTypeColumn.makeSortable(new ErrataTypeComparator());
    // $NON-NLS-1$ //$NON-NLS-2$
    grid.addColumn(errataTypeColumn, "", "30px");
    AbstractTextColumn errataTypeTextColumn = new AbstractTextColumn<Erratum>() {

        @Override
        public String getValue(Erratum erratum) {
            if (erratum.getType() == ErrataType.BUGFIX) {
                return constants.bug();
            } else if (erratum.getType() == ErrataType.ENHANCEMENT) {
                return constants.enhancement();
            } else if (erratum.getType() == ErrataType.SECURITY) {
                return constants.security();
            }
            return constants.unknown();
        }
    };
    errataTypeTextColumn.makeSortable();
    // $NON-NLS-1$
    grid.addColumn(errataTypeTextColumn, constants.errataType(), "150px");
    AbstractTextColumn<Erratum> errataSeverityColumn = new AbstractTextColumn<Erratum>() {

        @Override
        public String getValue(Erratum erratum) {
            if (erratum.getSeverity() == ErrataSeverity.CRITICAL) {
                return constants.critical();
            } else if (erratum.getSeverity() == ErrataSeverity.IMPORTANT) {
                return constants.important();
            } else if (erratum.getSeverity() == ErrataSeverity.MODERATE) {
                return constants.moderate();
            }
            return constants.unknown();
        }
    };
    errataSeverityColumn.makeSortable();
    // $NON-NLS-1$
    grid.addColumn(errataSeverityColumn, constants.errataSeverity(), "150px");
    AbstractFullDateTimeColumn<Erratum> dateIssuedColumn = new AbstractFullDateTimeColumn<Erratum>(false) {

        @Override
        protected Date getRawValue(Erratum erratum) {
            return erratum.getIssued();
        }
    };
    dateIssuedColumn.makeSortable();
    // $NON-NLS-1$
    grid.addColumn(dateIssuedColumn, constants.errataDateIssued(), "100px");
    AbstractTextColumn<Erratum> errataIdColumn;
    if (!isEngineErrataView) {
        errataIdColumn = new AbstractTextColumn<Erratum>() {

            @Override
            public String getValue(Erratum erratum) {
                return erratum.getId();
            }
        };
    } else {
        errataIdColumn = new AbstractLinkColumn<Erratum>(new FieldUpdater<Erratum, String>() {

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

            @Override
            public String getValue(Erratum erratum) {
                return erratum.getId();
            }
        };
    }
    errataIdColumn.makeSortable();
    // $NON-NLS-1$
    grid.addColumn(errataIdColumn, constants.errataId(), "115px");
    AbstractTextColumn<Erratum> titleColumn = new AbstractTextColumn<Erratum>() {

        @Override
        public String getValue(Erratum erratum) {
            return erratum.getTitle();
        }
    };
    titleColumn.makeSortable();
    // $NON-NLS-1$
    grid.addColumn(titleColumn, constants.errataTitle(), "290px");
}
Also used : FieldUpdater(com.google.gwt.cell.client.FieldUpdater) HashMap(java.util.HashMap) AbstractFullDateTimeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractFullDateTimeColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) Erratum(org.ovirt.engine.core.common.businessentities.Erratum) AbstractIconTypeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractIconTypeColumn)

Example 7 with AbstractTextColumn

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

the class MainQuotaView method initTable.

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

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

        @Override
        public String getValue(Quota object) {
            // $NON-NLS-1$
            return object.getQuotaName() == null ? "" : object.getQuotaName();
        }
    };
    nameColumn.makeSortable(QuotaConditionFieldAutoCompleter.NAME);
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameQuota(), "120px");
    AbstractTextColumn<Quota> dataCenterColumn = new AbstractTextColumn<Quota>() {

        @Override
        public String getValue(Quota object) {
            return object.getStoragePoolName() == null ? "" : object.getStoragePoolName();
        }
    };
    dataCenterColumn.makeSortable(QuotaConditionFieldAutoCompleter.STORAGEPOOLNAME);
    // $NON-NLS-1$
    getTable().addColumn(dataCenterColumn, constants.dcQuota(), "120px");
    AbstractTextColumn<Quota> descriptionColumn = new AbstractTextColumn<Quota>() {

        @Override
        public String getValue(Quota object) {
            // $NON-NLS-1$
            return object.getDescription() == null ? "" : object.getDescription();
        }
    };
    descriptionColumn.makeSortable(QuotaConditionFieldAutoCompleter.DESCRIPTION);
    // $NON-NLS-1$
    getTable().addColumn(descriptionColumn, constants.descriptionQuota(), "120px");
    getTable().addColumn(new AbstractQuotaPercentColumn<Quota>() {

        @Override
        protected Integer getProgressValue(Quota object) {
            int value;
            long allocated = 0;
            long used = 0;
            if (object.getGlobalQuotaCluster() != null) {
                allocated = object.getGlobalQuotaCluster().getMemSizeMB();
                used = object.getGlobalQuotaCluster().getMemSizeMBUsage();
            } else {
                for (QuotaCluster quotaCluster : object.getQuotaClusters()) {
                    if (!QuotaCluster.UNLIMITED_MEM.equals(quotaCluster.getMemSizeMB())) {
                        allocated += quotaCluster.getMemSizeMB() != null ? quotaCluster.getMemSizeMB() : 0;
                        used += quotaCluster.getMemSizeMBUsage();
                    } else {
                        allocated = QuotaCluster.UNLIMITED_MEM;
                        break;
                    }
                }
            }
            if (allocated == 0) {
                return 0;
            }
            value = (int) (((double) used / allocated) * 100);
            return allocated < 0 ? -1 : value > 100 ? 100 : value;
        }
    }, constants.usedMemoryQuota(), // $NON-NLS-1$
    "145px");
    getTable().addColumn(new AbstractTextColumn<Quota>() {

        @Override
        public String getValue(Quota object) {
            int value;
            long allocated = 0;
            long used = 0;
            if (object.getGlobalQuotaCluster() != null) {
                allocated = object.getGlobalQuotaCluster().getMemSizeMB();
                used = object.getGlobalQuotaCluster().getMemSizeMBUsage();
            } else {
                for (QuotaCluster quotaCluster : object.getQuotaClusters()) {
                    if (!QuotaCluster.UNLIMITED_MEM.equals(quotaCluster.getMemSizeMB())) {
                        allocated += quotaCluster.getMemSizeMB() != null ? quotaCluster.getMemSizeMB() : 0;
                        used += quotaCluster.getMemSizeMBUsage();
                    } else {
                        allocated = QuotaCluster.UNLIMITED_MEM;
                        break;
                    }
                }
            }
            value = (int) (allocated - used);
            String returnVal;
            if (allocated < 0) {
                returnVal = constants.unlimited();
            } else if (value <= 0) {
                // $NON-NLS-1$
                returnVal = messages.megabytes("0");
            } else if (value <= 5 * 1024) {
                returnVal = messages.megabytes(String.valueOf(value));
            } else {
                returnVal = messages.gibibytes(decimalFormat.format((double) value / 1024));
            }
            return returnVal;
        }
    }, constants.freeMemory(), // $NON-NLS-1$
    "100px");
    getTable().addColumn(new AbstractQuotaPercentColumn<Quota>() {

        @Override
        protected Integer getProgressValue(Quota object) {
            int value;
            int allocated = 0;
            int used = 0;
            if (object.getGlobalQuotaCluster() != null) {
                allocated = object.getGlobalQuotaCluster().getVirtualCpu() != null ? object.getGlobalQuotaCluster().getVirtualCpu() : 0;
                used = object.getGlobalQuotaCluster().getVirtualCpuUsage();
            } else {
                for (QuotaCluster quotaCluster : object.getQuotaClusters()) {
                    if (!QuotaCluster.UNLIMITED_VCPU.equals(quotaCluster.getVirtualCpu())) {
                        allocated += quotaCluster.getVirtualCpu();
                        used += quotaCluster.getVirtualCpuUsage();
                    } else {
                        allocated = QuotaCluster.UNLIMITED_VCPU;
                        break;
                    }
                }
            }
            if (allocated == 0) {
                return 0;
            }
            value = (int) (((double) used / allocated) * 100);
            return allocated < 0 ? -1 : value > 100 ? 100 : value;
        }
    }, constants.runningCpuQuota(), // $NON-NLS-1$
    "135px");
    getTable().addColumn(new AbstractTextColumn<Quota>() {

        @Override
        public String getValue(Quota object) {
            int value;
            int allocated = 0;
            int used = 0;
            if (object.getGlobalQuotaCluster() != null) {
                allocated = object.getGlobalQuotaCluster().getVirtualCpu() != null ? object.getGlobalQuotaCluster().getVirtualCpu() : 0;
                used = object.getGlobalQuotaCluster().getVirtualCpuUsage();
            } else {
                for (QuotaCluster quotaCluster : object.getQuotaClusters()) {
                    if (!QuotaCluster.UNLIMITED_VCPU.equals(quotaCluster.getVirtualCpu())) {
                        allocated += quotaCluster.getVirtualCpu();
                        used += quotaCluster.getVirtualCpuUsage();
                    } else {
                        allocated = QuotaCluster.UNLIMITED_VCPU;
                        break;
                    }
                }
            }
            value = allocated - used;
            String returnVal;
            if (allocated < 0) {
                returnVal = constants.unlimited();
            } else if (value <= 0) {
                // $NON-NLS-1$
                returnVal = "0";
            } else {
                // $NON-NLS-1$
                returnVal = value + "";
            }
            return returnVal;
        }
    }, constants.freeVcpu(), // $NON-NLS-1$
    "100px");
    getTable().addColumn(new AbstractQuotaPercentColumn<Quota>() {

        @Override
        protected Integer getProgressValue(Quota object) {
            int value;
            double allocated = 0;
            double used = 0;
            if (object.getGlobalQuotaStorage() != null) {
                allocated = object.getGlobalQuotaStorage().getStorageSizeGB();
                used = object.getGlobalQuotaStorage().getStorageSizeGBUsage();
            } else {
                for (QuotaStorage quotaStorage : object.getQuotaStorages()) {
                    if (!QuotaStorage.UNLIMITED.equals(quotaStorage.getStorageSizeGB())) {
                        allocated += quotaStorage.getStorageSizeGB();
                        used += quotaStorage.getStorageSizeGBUsage();
                    } else {
                        allocated = QuotaStorage.UNLIMITED;
                        break;
                    }
                }
            }
            if (allocated == 0) {
                return 0;
            }
            value = (int) ((used / allocated) * 100);
            return allocated < 0 ? -1 : value > 100 ? 100 : value;
        }
    }, constants.usedStorageQuota(), // $NON-NLS-1$
    "155px");
    getTable().addColumn(new AbstractTextColumn<Quota>() {

        @Override
        public String getValue(Quota object) {
            double value;
            double allocated = 0;
            double used = 0;
            if (object.getGlobalQuotaStorage() != null) {
                allocated = object.getGlobalQuotaStorage().getStorageSizeGB();
                used = object.getGlobalQuotaStorage().getStorageSizeGBUsage();
            } else {
                for (QuotaStorage quotaStorage : object.getQuotaStorages()) {
                    if (!QuotaStorage.UNLIMITED.equals(quotaStorage.getStorageSizeGB())) {
                        allocated += quotaStorage.getStorageSizeGB();
                        used += quotaStorage.getStorageSizeGBUsage();
                    } else {
                        allocated = QuotaStorage.UNLIMITED;
                        break;
                    }
                }
            }
            value = allocated - used;
            String returnVal;
            if (allocated < 0) {
                returnVal = constants.unlimited();
            } else if (value <= 0) {
                // $NON-NLS-1$
                returnVal = messages.gibibytes("0");
            } else {
                returnVal = diskSizeRenderer.render(value);
            }
            return returnVal;
        }
    }, constants.freeStorage(), // $NON-NLS-1$
    "100px");
}
Also used : QuotaDcStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.QuotaDcStatusColumn) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) QuotaStorage(org.ovirt.engine.core.common.businessentities.QuotaStorage) Quota(org.ovirt.engine.core.common.businessentities.Quota) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with AbstractTextColumn

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

the class ImportTemplatePopupView method initMainTable.

@Override
protected void initMainTable() {
    this.table = new ListModelObjectCellTable<>();
    AbstractCheckboxColumn<Object> cloneTemplateColumn = new AbstractCheckboxColumn<Object>((index, model, value) -> {
        ((ImportTemplateData) model).getClone().setEntity(value);
        table.asEditor().edit(importModel);
    }) {

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

        @Override
        protected boolean canEdit(Object model) {
            return ((ImportTemplateData) model).getClone().getIsChangable();
        }
    };
    // $NON-NLS-1$
    table.addColumn(cloneTemplateColumn, constants.cloneVM(), "50px");
    AbstractTextColumn<Object> nameColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return ((ImportTemplateData) object).getTemplate().getName();
        }
    };
    // $NON-NLS-1$
    table.addColumn(nameColumn, constants.nameTemplate(), "150px");
    AbstractTextColumn<Object> versionNameColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            VmTemplate template = ((ImportTemplateData) object).getTemplate();
            if (template.isBaseTemplate()) {
                // $NON-NLS-1$
                return "";
            }
            return // $NON-NLS-1$
            StringFormat.format(// $NON-NLS-1$
            "%s (%s)", // $NON-NLS-1$
            template.getTemplateVersionName() != null ? template.getTemplateVersionName() : "", template.getTemplateVersionNumber());
        }
    };
    // $NON-NLS-1$
    table.addColumn(versionNameColumn, constants.versionTemplate(), "150px");
    AbstractTextColumn<Object> originColumn = new AbstractEnumColumn<Object, OriginType>() {

        @Override
        protected OriginType getRawValue(Object object) {
            return ((ImportTemplateData) object).getTemplate().getOrigin();
        }
    };
    // $NON-NLS-1$
    table.addColumn(originColumn, constants.originTemplate(), "100px");
    AbstractTextColumn<Object> memoryColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return messages.megabytes(String.valueOf(((ImportTemplateData) object).getTemplate().getMemSizeMb()));
        }
    };
    // $NON-NLS-1$
    table.addColumn(memoryColumn, constants.memoryTemplate(), "100px");
    AbstractTextColumn<Object> cpuColumn = new AbstractTextColumn<Object>() {

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

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

        @Override
        public String getValue(Object object) {
            return String.valueOf(((ImportTemplateData) object).getTemplate().getDiskList().size());
        }
    };
    // $NON-NLS-1$
    table.addColumn(diskColumn, constants.disksTemplate(), "50px");
    isObjectInSystemColumn = new AbstractImageResourceColumn<Object>() {

        @Override
        public ImageResource getValue(Object object) {
            return ((ImportTemplateData) object).isExistsInSystem() ? resources.logNormalImage() : null;
        }
    };
    // $NON-NLS-1$
    table.addColumn(isObjectInSystemColumn, constants.templateInSetup(), "60px");
    ScrollPanel sp = new ScrollPanel();
    sp.add(table);
    splitLayoutPanel.add(sp);
    table.getElement().getStyle().setPosition(Position.RELATIVE);
}
Also used : AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) ImportTemplateData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportTemplateData) ImageResource(com.google.gwt.resources.client.ImageResource) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 9 with AbstractTextColumn

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

the class ImportVmFromExportDomainPopupView method initDiskTable.

private void initDiskTable() {
    diskTable = new ListModelObjectCellTable<>();
    diskTable.enableColumnResizing();
    AbstractTextColumn<DiskImage> aliasColumn = new AbstractTextColumn<DiskImage>() {

        @Override
        public String getValue(DiskImage object) {
            return object.getDiskAlias();
        }
    };
    // $NON-NLS-1$
    diskTable.addColumn(aliasColumn, constants.aliasDisk(), "100px");
    AbstractImageResourceColumn<DiskImage> bootableDiskColumn = new AbstractImageResourceColumn<DiskImage>() {

        @Override
        public ImageResource getValue(DiskImage object) {
            return object.getDiskVmElements().iterator().next().isBoot() ? getDefaultImage() : null;
        }

        @Override
        public ImageResource getDefaultImage() {
            return resources.bootableDiskIcon();
        }

        @Override
        public SafeHtml getTooltip(DiskImage object) {
            if (object.getDiskVmElements().iterator().next().isBoot()) {
                return SafeHtmlUtils.fromSafeConstant(constants.bootableDisk());
            }
            return null;
        }
    };
    diskTable.addColumn(bootableDiskColumn, new ImageResourceHeader(DisksViewColumns.bootableDiskColumn.getDefaultImage(), SafeHtmlUtils.fromSafeConstant(constants.bootableDisk())), // $NON-NLS-1$
    "30px");
    AbstractDiskSizeColumn<DiskImage> sizeColumn = new AbstractDiskSizeColumn<DiskImage>() {

        @Override
        protected Long getRawValue(DiskImage object) {
            return object.getSize();
        }
    };
    // $NON-NLS-1$
    diskTable.addColumn(sizeColumn, constants.provisionedSizeDisk(), "130px");
    AbstractDiskSizeColumn<DiskImage> actualSizeColumn = new AbstractDiskSizeColumn<DiskImage>() {

        @Override
        protected Long getRawValue(DiskImage object) {
            return object.getActualSizeInBytes();
        }
    };
    // $NON-NLS-1$
    diskTable.addColumn(actualSizeColumn, constants.sizeDisk(), "130px");
    AbstractTextColumn<DiskImage> dateCreatedColumn = new AbstractFullDateTimeColumn<DiskImage>() {

        @Override
        protected Date getRawValue(DiskImage object) {
            return object.getCreationDate();
        }
    };
    // $NON-NLS-1$
    diskTable.addColumn(dateCreatedColumn, constants.dateCreatedInterface(), "120px");
    diskTable.setSelectionModel(new NoSelectionModel<DiskImage>());
    addAllocationColumn();
    diskTable.getElement().getStyle().setPosition(Position.RELATIVE);
}
Also used : AbstractDiskSizeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractDiskSizeColumn) AbstractFullDateTimeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractFullDateTimeColumn) ImageResourceHeader(org.ovirt.engine.ui.common.widget.table.header.ImageResourceHeader) AbstractImageResourceColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractImageResourceColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 10 with AbstractTextColumn

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

the class ManagePolicyUnitPopupView method initTable.

private void initTable() {
    policyUnitTable = new ListModelObjectCellTable<>();
    policyUnitTable.enableColumnResizing();
    policyUnitTableContainer.add(policyUnitTable);
    policyUnitTable.addColumn(new AbstractImageResourceColumn<PolicyUnit>() {

        @Override
        public ImageResource getValue(PolicyUnit object) {
            if (object.isInternal()) {
                return resources.lockImage();
            }
            return resources.exteranlPolicyUnitImage();
        }

        @Override
        public SafeHtml getTooltip(PolicyUnit object) {
            String tooltipContent = null;
            if (object.isInternal()) {
                tooltipContent = constants.internalPolicyUnit();
            } else {
                tooltipContent = constants.externalPolicyUnit();
            }
            return SafeHtmlUtils.fromSafeConstant(tooltipContent);
        }
    }, constants.empty(), // $NON-NLS-1$
    "20px");
    policyUnitTable.addColumn(new AbstractTextColumn<PolicyUnit>() {

        @Override
        public String getValue(PolicyUnit object) {
            return object.getName();
        }
    }, constants.policyUnitName(), // $NON-NLS-1$
    "180px");
    policyUnitTable.addColumn(new AbstractTextColumn<PolicyUnit>() {

        @Override
        public String getValue(PolicyUnit object) {
            return EnumTranslator.getInstance().translate(object.getPolicyUnitType());
        }
    }, constants.policyUnitType(), // $NON-NLS-1$
    "100px");
    policyUnitTable.addColumn(new AbstractTextColumn<PolicyUnit>() {

        @Override
        public String getValue(PolicyUnit object) {
            return object.isEnabled() ? constants.enabledPolicyUnit() : constants.disabledPolicyUnit();
        }
    }, constants.policyUnitEnabledStatus(), // $NON-NLS-1$
    "75px");
    Column<PolicyUnit, String> removeButtonColumn = new Column<PolicyUnit, String>(new NullableButtonCell()) {

        @Override
        public String getValue(PolicyUnit object) {
            if (!object.isEnabled()) {
                return constants.removePolicyUnit();
            }
            return null;
        }
    };
    // $NON-NLS-1$
    policyUnitTable.addColumn(removeButtonColumn, constants.removePolicyUnit(), "80px");
    removeButtonColumn.setFieldUpdater((index, object, value) -> model.remove(object));
}
Also used : NullableButtonCell(org.ovirt.engine.ui.webadmin.widget.table.cell.NullableButtonCell) ImageResource(com.google.gwt.resources.client.ImageResource) AbstractImageResourceColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractImageResourceColumn) Column(com.google.gwt.user.cellview.client.Column) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) PolicyUnit(org.ovirt.engine.core.common.scheduling.PolicyUnit)

Aggregations

AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)57 AbstractEnumColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn)23 HashMap (java.util.HashMap)15 Map (java.util.Map)14 AbstractLinkColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn)14 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)10 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)9 AbstractDiskSizeColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractDiskSizeColumn)9 ImageResource (com.google.gwt.resources.client.ImageResource)8 NoSelectionModel (com.google.gwt.view.client.NoSelectionModel)7 AbstractCheckboxColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn)7 Column (com.google.gwt.user.cellview.client.Column)6 ArrayList (java.util.ArrayList)6 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)6 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)6 NoItemsLabel (org.ovirt.engine.ui.common.widget.label.NoItemsLabel)6 AbstractFullDateTimeColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractFullDateTimeColumn)6 List (java.util.List)5 GWT (com.google.gwt.core.client.GWT)4 VM (org.ovirt.engine.core.common.businessentities.VM)4