Search in sources :

Example 1 with CommentColumn

use of org.ovirt.engine.ui.webadmin.widget.table.column.CommentColumn in project ovirt-engine by oVirt.

the class MainVirtualMachineView method initTable.

void initTable() {
    getTable().enableColumnResizing();
    VmStatusColumn<VM> statusIconColumn = new VmStatusColumn<>();
    statusIconColumn.setContextMenuTitle(constants.statusIconVm());
    statusIconColumn.makeSortable(VmConditionFieldAutoCompleter.STATUS);
    // $NON-NLS-1$
    getTable().addColumn(statusIconColumn, constants.empty(), "35px");
    VmTypeColumn typeColumn = new VmTypeColumn();
    typeColumn.setContextMenuTitle(constants.typeVm());
    typeColumn.makeSortable(VmConditionFieldAutoCompleter.TYPE);
    // $NON-NLS-1$
    getTable().addColumn(typeColumn, constants.empty(), "60px");
    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());
            // The link was clicked, now fire an event to switch to details.
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.virtualMachineGeneralSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(VM object) {
            return object.getName();
        }
    };
    nameColumn.makeSortable(VmConditionFieldAutoCompleter.NAME);
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameVm(), "120px");
    CommentColumn<VM> commentColumn = new CommentColumn<>();
    getTable().addColumnWithHtmlHeader(commentColumn, SafeHtmlUtils.fromSafeConstant(constants.commentLabel()), // $NON-NLS-1$
    "75px");
    AbstractTextColumn<VM> hostColumn = 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.getRunOnVdsName());
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.hostGeneralSubTabPlace, parameters);
        }
    }) {

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

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

        @Override
        public String getValue(VM object) {
            return object.getFqdn();
        }
    };
    fqdnColumn.makeSortable(VmConditionFieldAutoCompleter.FQDN);
    // $NON-NLS-1$
    getTable().addColumn(fqdnColumn, constants.fqdn(), "120px");
    AbstractTextColumn<VM> clusterColumn = 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.getClusterName());
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.clusterGeneralSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(VM object) {
            return object.getClusterName();
        }
    };
    clusterColumn.makeSortable(VmConditionFieldAutoCompleter.CLUSTER);
    // $NON-NLS-1$
    getTable().addColumn(clusterColumn, constants.clusterVm(), "120px");
    AbstractTextColumn<VM> dcColumn = 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.getStoragePoolName());
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.dataCenterStorageSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(VM object) {
            return object.getStoragePoolName();
        }
    };
    dcColumn.makeSortable(VmConditionFieldAutoCompleter.DATACENTER);
    // $NON-NLS-1$
    getTable().addColumn(dcColumn, constants.dcVm(), "120px");
    getTable().addColumn(new ColumnResizeTableLineChartProgressBar<VM>(getTable(), VmConditionFieldAutoCompleter.MEM_USAGE) {

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

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

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

        @Override
        protected UnitVmModel.GraphicsTypes getRawValue(VM vm) {
            if ((vm.getStatus() == VMStatus.Down) || (vm.getStatus() == VMStatus.ImageLocked)) {
                return UnitVmModel.GraphicsTypes.NONE;
            }
            Map<GraphicsType, GraphicsInfo> graphicsInfos = vm.getGraphicsInfos();
            return UnitVmModel.GraphicsTypes.fromGraphicsTypes(graphicsInfos.keySet());
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(graphicsColumn, constants.graphicsVm(), "70px");
    AbstractTextColumn<VM> statusColumn = new AbstractEnumColumn<VM, VMStatus>() {

        @Override
        public VMStatus getRawValue(VM object) {
            return object.getStatus();
        }

        @Override
        public String getValue(VM vm) {
            if (vm.getStatus() == VMStatus.MigratingFrom) {
                // will be rendered by progress column
                return null;
            }
            if (vm.getBackgroundOperationDescription() != null) {
                // will be rendered by progress column
                return null;
            }
            return super.getValue(vm);
        }
    };
    MigrationProgressColumn migrationProgressColumn = new MigrationProgressColumn();
    ImportProgressColumn importProgressColumn = new ImportProgressColumn();
    ReasonColumn<VM> reasonColumn = new ReasonColumn<VM>() {

        @Override
        protected String getReason(VM value) {
            return value.getStopReason();
        }
    };
    List<HasCell<VM, ?>> list = new ArrayList<>();
    list.add(statusColumn);
    list.add(reasonColumn);
    list.add(migrationProgressColumn);
    list.add(importProgressColumn);
    Cell<VM> compositeCell = new StatusCompositeCell<>(list);
    AbstractColumn<VM, VM> statusTextColumn = new AbstractColumn<VM, VM>(compositeCell) {

        @Override
        public VM getValue(VM object) {
            return object;
        }

        @Override
        public SafeHtml getTooltip(VM value) {
            String stopReason = value.getStopReason();
            if (stopReason != null && !stopReason.trim().isEmpty()) {
                return SafeHtmlUtils.fromString(stopReason);
            }
            return null;
        }
    };
    statusTextColumn.makeSortable(VmConditionFieldAutoCompleter.STATUS);
    // $NON-NLS-1$
    getTable().addColumn(statusTextColumn, constants.statusVm(), "120px");
    AbstractTextColumn<VM> uptimeColumn = new AbstractUptimeColumn<VM>() {

        @Override
        public Double getRawValue(VM object) {
            return object.getElapsedTime();
        }
    };
    uptimeColumn.makeSortable(VmConditionFieldAutoCompleter.UPTIME);
    // $NON-NLS-1$
    getTable().addColumn(uptimeColumn, constants.uptimeVm(), "100px");
    AbstractTextColumn<VM> descriptionColumn = new AbstractTextColumn<VM>() {

        @Override
        public String getValue(VM object) {
            return object.getDescription();
        }
    };
    descriptionColumn.makeSortable(VmConditionFieldAutoCompleter.DESCRIPTION);
    // $NON-NLS-1$
    getTable().addColumn(descriptionColumn, constants.description(), "150px");
}
Also used : HasCell(com.google.gwt.cell.client.HasCell) ArrayList(java.util.ArrayList) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo) VmStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VmStatusColumn) AbstractUptimeColumn(org.ovirt.engine.ui.webadmin.widget.table.column.AbstractUptimeColumn) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ArrayList(java.util.ArrayList) List(java.util.List) VmTypeColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VmTypeColumn) CommentColumn(org.ovirt.engine.ui.webadmin.widget.table.column.CommentColumn) ImportProgressColumn(org.ovirt.engine.ui.webadmin.widget.table.column.ImportProgressColumn) MigrationProgressColumn(org.ovirt.engine.ui.webadmin.widget.table.column.MigrationProgressColumn) AbstractColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractColumn) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) VM(org.ovirt.engine.core.common.businessentities.VM) StatusCompositeCell(org.ovirt.engine.ui.common.widget.table.cell.StatusCompositeCell) ReasonColumn(org.ovirt.engine.ui.webadmin.widget.table.column.ReasonColumn) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with CommentColumn

use of org.ovirt.engine.ui.webadmin.widget.table.column.CommentColumn 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 3 with CommentColumn

use of org.ovirt.engine.ui.webadmin.widget.table.column.CommentColumn in project ovirt-engine by oVirt.

the class MainClusterView method initTable.

void initTable() {
    getTable().enableColumnResizing();
    AbstractTextColumn<Cluster> nameColumn = new AbstractLinkColumn<Cluster>(new FieldUpdater<Cluster, String>() {

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

        @Override
        public String getValue(Cluster object) {
            return object.getName();
        }
    };
    nameColumn.makeSortable(ClusterConditionFieldAutoCompleter.NAME);
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameCluster(), "150px");
    ClusterAdditionalStatusColumn additionalStatusColumn = new ClusterAdditionalStatusColumn();
    additionalStatusColumn.setContextMenuTitle(constants.additionalStatusCluster());
    // $NON-NLS-1$
    getTable().addColumn(additionalStatusColumn, constants.empty(), "30px");
    CommentColumn<Cluster> commentColumn = new CommentColumn<>();
    getTable().addColumnWithHtmlHeader(commentColumn, SafeHtmlUtils.fromSafeConstant(constants.commentLabel()), // $NON-NLS-1$
    "75px");
    if (ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly) {
        AbstractTextColumn<Cluster> dataCenterColumn = new AbstractTextColumn<Cluster>() {

            @Override
            public String getValue(Cluster object) {
                return object.getStoragePoolName();
            }
        };
        // $NON-NLS-1$
        getTable().addColumn(dataCenterColumn, constants.dcCluster(), "150px");
    }
    AbstractTextColumn<Cluster> versionColumn = new AbstractTextColumn<Cluster>() {

        @Override
        public String getValue(Cluster object) {
            return object.getCompatibilityVersion().getValue();
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(versionColumn, constants.comptVersCluster(), "150px");
    AbstractTextColumn<Cluster> descColumn = new AbstractTextColumn<Cluster>() {

        @Override
        public String getValue(Cluster object) {
            return object.getDescription();
        }
    };
    descColumn.makeSortable(ClusterConditionFieldAutoCompleter.DESCRIPTION);
    // $NON-NLS-1$
    getTable().addColumn(descColumn, constants.descriptionCluster(), "300px");
    if (ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly) {
        AbstractTextColumn<Cluster> cpuTypeColumn = new AbstractTextColumn<Cluster>() {

            @Override
            public String getValue(Cluster object) {
                return object.getCpuName();
            }
        };
        // $NON-NLS-1$
        getTable().addColumn(cpuTypeColumn, constants.cpuTypeCluster(), "150px");
    }
    AbstractTextColumn<Cluster> hostCountColumn = new AbstractTextColumn<Cluster>() {

        @Override
        public String getValue(Cluster object) {
            if (object.getClusterHostsAndVms() == null) {
                // $NON-NLS-1$
                return "";
            }
            // $NON-NLS-1$
            return object.getClusterHostsAndVms().getHosts() + "";
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(hostCountColumn, constants.hostCount(), "150px");
    AbstractTextColumn<Cluster> vmCountColumn = new AbstractTextColumn<Cluster>() {

        @Override
        public String getValue(Cluster object) {
            if (object.getClusterHostsAndVms() == null) {
                // $NON-NLS-1$
                return "";
            }
            // $NON-NLS-1$
            return object.getClusterHostsAndVms().getVms() + "";
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(vmCountColumn, constants.vmCount(), "150px");
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ClusterAdditionalStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.ClusterAdditionalStatusColumn) CommentColumn(org.ovirt.engine.ui.webadmin.widget.table.column.CommentColumn) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with CommentColumn

use of org.ovirt.engine.ui.webadmin.widget.table.column.CommentColumn in project ovirt-engine by oVirt.

the class MainDataCenterView method initTable.

void initTable() {
    getTable().enableColumnResizing();
    DcStatusColumn statusIconColumn = new DcStatusColumn();
    statusIconColumn.setContextMenuTitle(constants.statusIconDc());
    // $NON-NLS-1$
    getTable().addColumn(statusIconColumn, constants.empty(), "30px");
    DcAdditionalStatusColumn additionalStatusColumn = new DcAdditionalStatusColumn();
    additionalStatusColumn.setContextMenuTitle(constants.additionalStatusDataCenter());
    // $NON-NLS-1$
    getTable().addColumn(additionalStatusColumn, constants.empty(), "30px");
    AbstractTextColumn<StoragePool> nameColumn = new AbstractLinkColumn<StoragePool>(new FieldUpdater<StoragePool, String>() {

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

        @Override
        public String getValue(StoragePool object) {
            return object.getName();
        }
    };
    nameColumn.makeSortable(StoragePoolFieldAutoCompleter.NAME);
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameDc(), "150px");
    CommentColumn<StoragePool> commentColumn = new CommentColumn<>();
    getTable().addColumnWithHtmlHeader(commentColumn, SafeHtmlUtils.fromSafeConstant(constants.commentLabel()), // $NON-NLS-1$
    "75px");
    AbstractTextColumn<StoragePool> storageTypeColumn = new AbstractBooleanColumn<StoragePool>(constants.storageTypeLocal(), constants.storageTypeShared()) {

        @Override
        protected Boolean getRawValue(StoragePool object) {
            return object.isLocal();
        }
    };
    storageTypeColumn.makeSortable(StoragePoolFieldAutoCompleter.LOCAL);
    // $NON-NLS-1$
    getTable().addColumn(storageTypeColumn, constants.storgeTypeDc(), "150px");
    AbstractTextColumn<StoragePool> statusColumn = new AbstractEnumColumn<StoragePool, StoragePoolStatus>() {

        @Override
        public StoragePoolStatus getRawValue(StoragePool object) {
            return object.getStatus();
        }
    };
    statusColumn.makeSortable(StoragePoolFieldAutoCompleter.STATUS);
    // $NON-NLS-1$
    getTable().addColumn(statusColumn, constants.statusDc(), "150px");
    AbstractTextColumn<StoragePool> versionColumn = new AbstractTextColumn<StoragePool>() {

        @Override
        public String getValue(StoragePool object) {
            return object.getCompatibilityVersion().getValue();
        }
    };
    versionColumn.makeSortable(StoragePoolFieldAutoCompleter.COMPATIBILITY_VERSION);
    // $NON-NLS-1$
    getTable().addColumn(versionColumn, constants.comptVersDc(), "150px");
    AbstractTextColumn<StoragePool> descColumn = new AbstractTextColumn<StoragePool>() {

        @Override
        public String getValue(StoragePool object) {
            return object.getdescription();
        }
    };
    descColumn.makeSortable(StoragePoolFieldAutoCompleter.DESCRIPTION);
    // $NON-NLS-1$
    getTable().addColumn(descColumn, constants.descriptionDc(), "300px");
}
Also used : DcAdditionalStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.DcAdditionalStatusColumn) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) AbstractBooleanColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractBooleanColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) DcStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.DcStatusColumn) CommentColumn(org.ovirt.engine.ui.webadmin.widget.table.column.CommentColumn) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with CommentColumn

use of org.ovirt.engine.ui.webadmin.widget.table.column.CommentColumn in project ovirt-engine by oVirt.

the class MainHostView method initTable.

void initTable() {
    getTable().enableColumnResizing();
    HostStatusColumn<VDS> statusIconColumn = new HostStatusColumn<>();
    statusIconColumn.setContextMenuTitle(constants.statusIconHost());
    // $NON-NLS-1$
    getTable().addColumn(statusIconColumn, constants.empty(), "35px");
    HostAdditionalStatusColumn additionalStatusColumn = new HostAdditionalStatusColumn();
    additionalStatusColumn.setContextMenuTitle(constants.additionalStatusHost());
    // $NON-NLS-1$
    getTable().addColumn(additionalStatusColumn, constants.empty(), "60px");
    AbstractTextColumn<VDS> nameColumn = new AbstractLinkColumn<VDS>(new FieldUpdater<VDS, String>() {

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

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

        @Override
        public String getValue(VDS object) {
            return object.getHostName();
        }
    };
    hostColumn.makeSortable(VdsConditionFieldAutoCompleter.ADDRESS);
    // $NON-NLS-1$
    getTable().addColumn(hostColumn, constants.ipHost(), "150px");
    AbstractTextColumn<VDS> clusterColumn = new AbstractLinkColumn<VDS>(new FieldUpdater<VDS, String>() {

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

        @Override
        public String getValue(VDS object) {
            return object.getClusterName();
        }
    };
    clusterColumn.makeSortable(VdsConditionFieldAutoCompleter.CLUSTER);
    // $NON-NLS-1$
    getTable().addColumn(clusterColumn, constants.clusterHost(), "150px");
    if (ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly) {
        AbstractTextColumn<VDS> dcColumn = new AbstractLinkColumn<VDS>(new FieldUpdater<VDS, String>() {

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

            @Override
            public String getValue(VDS object) {
                return object.getStoragePoolName();
            }
        };
        dcColumn.makeSortable(VdsConditionFieldAutoCompleter.DATACENTER);
        // $NON-NLS-1$
        getTable().addColumn(dcColumn, constants.dcHost(), "150px");
    }
    AbstractTextColumn<VDS> statusColumn = new AbstractEnumColumn<VDS, VDSStatus>() {

        @Override
        public VDSStatus getRawValue(VDS object) {
            return object.getStatus();
        }
    };
    ReasonColumn<VDS> reasonColumn = new ReasonColumn<VDS>() {

        @Override
        protected String getReason(VDS value) {
            return value.getMaintenanceReason();
        }
    };
    List<HasCell<VDS, ?>> list = new ArrayList<>();
    list.add(statusColumn);
    list.add(reasonColumn);
    Cell<VDS> compositeCell = new StatusCompositeCell<>(list);
    AbstractColumn<VDS, VDS> statusTextColumn = new AbstractColumn<VDS, VDS>(compositeCell) {

        @Override
        public VDS getValue(VDS object) {
            return object;
        }

        @Override
        public SafeHtml getTooltip(VDS value) {
            String maintenanceReason = value.getMaintenanceReason();
            if (maintenanceReason != null && !maintenanceReason.trim().isEmpty()) {
                return SafeHtmlUtils.fromString(maintenanceReason);
            }
            return null;
        }
    };
    statusTextColumn.makeSortable(VdsConditionFieldAutoCompleter.STATUS);
    // $NON-NLS-1$
    getTable().addColumn(statusTextColumn, constants.statusHost(), "100px");
    if (ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly) {
        VmCountColumn vmCountColumn = new VmCountColumn();
        vmCountColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
        vmCountColumn.makeSortable(VdsConditionFieldAutoCompleter.ACTIVE_VMS);
        // $NON-NLS-1$
        getTable().addColumn(vmCountColumn, constants.vmsCount(), "110px");
    }
    AbstractPercentColumn<VDS> memColumn = new AbstractPercentColumn<VDS>() {

        @Override
        public Integer getProgressValue(VDS object) {
            return object.getUsageMemPercent();
        }
    };
    memColumn.makeSortable(VdsConditionFieldAutoCompleter.MEM_USAGE);
    // $NON-NLS-1$
    getTable().addColumn(memColumn, constants.memoryHost(), "80px");
    AbstractPercentColumn<VDS> cpuColumn = new AbstractPercentColumn<VDS>() {

        @Override
        public Integer getProgressValue(VDS object) {
            return object.getUsageCpuPercent();
        }
    };
    cpuColumn.makeSortable(VdsConditionFieldAutoCompleter.CPU_USAGE);
    // $NON-NLS-1$
    getTable().addColumn(cpuColumn, constants.cpuHost(), "80px");
    AbstractPercentColumn<VDS> netColumn = new AbstractPercentColumn<VDS>() {

        @Override
        public Integer getProgressValue(VDS object) {
            return object.getUsageNetworkPercent();
        }
    };
    netColumn.makeSortable(VdsConditionFieldAutoCompleter.NETWORK_USAGE);
    // $NON-NLS-1$
    getTable().addColumn(netColumn, constants.networkHost(), "80px");
    if (ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly) {
        AbstractTextColumn<VDS> spmColumn = new AbstractTextColumn<VDS>() {

            @Override
            public String getValue(VDS object) {
                int value = object.getVdsSpmPriority();
                int lowValue = defaultSpmPriority / 2;
                int highValue = defaultSpmPriority + (maxSpmPriority - defaultSpmPriority) / 2;
                if (object.getSpmStatus() != VdsSpmStatus.None) {
                    return object.getSpmStatus().name();
                }
                if (value == -1) {
                    return constants.spmNeverText();
                } else if (value == lowValue) {
                    return constants.spmLowText();
                } else if (value == defaultSpmPriority) {
                    return constants.spmNormalText();
                } else if (value == highValue) {
                    return constants.spmHighText();
                }
                return constants.spmCustomText();
            }
        };
        // $NON-NLS-1$
        getTable().addColumn(spmColumn, constants.spmPriorityHost(), "100px");
    }
}
Also used : HasCell(com.google.gwt.cell.client.HasCell) ArrayList(java.util.ArrayList) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) 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) HostStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.HostStatusColumn) VDS(org.ovirt.engine.core.common.businessentities.VDS) HostAdditionalStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.HostAdditionalStatusColumn) AbstractPercentColumn(org.ovirt.engine.ui.webadmin.widget.table.column.AbstractPercentColumn) AbstractColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractColumn) VmCountColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VmCountColumn) StatusCompositeCell(org.ovirt.engine.ui.common.widget.table.cell.StatusCompositeCell) ReasonColumn(org.ovirt.engine.ui.webadmin.widget.table.column.ReasonColumn) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

HashMap (java.util.HashMap)5 Map (java.util.Map)5 AbstractLinkColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn)5 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)5 CommentColumn (org.ovirt.engine.ui.webadmin.widget.table.column.CommentColumn)5 AbstractEnumColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn)4 HasCell (com.google.gwt.cell.client.HasCell)2 ArrayList (java.util.ArrayList)2 StatusCompositeCell (org.ovirt.engine.ui.common.widget.table.cell.StatusCompositeCell)2 AbstractColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractColumn)2 ReasonColumn (org.ovirt.engine.ui.webadmin.widget.table.column.ReasonColumn)2 List (java.util.List)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 GraphicsInfo (org.ovirt.engine.core.common.businessentities.GraphicsInfo)1 GraphicsType (org.ovirt.engine.core.common.businessentities.GraphicsType)1 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 AbstractBooleanColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractBooleanColumn)1