Search in sources :

Example 1 with AbstractLinkColumn

use of org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn 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 AbstractLinkColumn

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

the class MainVolumeView method initTable.

void initTable(VolumeListModel model) {
    getTable().enableColumnResizing();
    VolumeStatusColumn statusColumn = new VolumeStatusColumn(model.getStartCommand());
    statusColumn.setContextMenuTitle(constants.statusVolume());
    statusColumn.makeSortable(Comparator.comparingInt(g -> GlusterVolumeUtils.getVolumeStatus(g).ordinal()));
    // $NON-NLS-1$
    getTable().addColumn(statusColumn, constants.empty(), "30px");
    AbstractTextColumn<GlusterVolumeEntity> nameColumn = new AbstractLinkColumn<GlusterVolumeEntity>(new FieldUpdater<GlusterVolumeEntity, String>() {

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

        @Override
        public String getValue(GlusterVolumeEntity object) {
            return object.getName();
        }
    };
    nameColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameVolume(), "150px");
    AbstractTextColumn<GlusterVolumeEntity> clusterColumn = new AbstractTextColumn<GlusterVolumeEntity>() {

        @Override
        public String getValue(GlusterVolumeEntity object) {
            return object.getClusterName();
        }
    };
    clusterColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(clusterColumn, constants.clusterVolume(), "150px");
    AbstractTextColumn<GlusterVolumeEntity> volumeTypeColumn = new AbstractEnumColumn<GlusterVolumeEntity, GlusterVolumeType>() {

        @Override
        protected GlusterVolumeType getRawValue(GlusterVolumeEntity object) {
            return object.getVolumeType();
        }
    };
    volumeTypeColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(volumeTypeColumn, constants.volumeTypeVolume(), "150px");
    // $NON-NLS-1$
    getTable().addColumn(new VolumeBrickStatusColumn(), constants.bricksStatusVolume(), "150px");
    // $NON-NLS-1$
    getTable().addColumn(new VolumeInfoColumn(), constants.volumeInfoVolume(), "100px");
    MenuCell<GlusterTaskSupport> rebalanceMenuCell = getRebalanceActivityMenu();
    MenuCell<GlusterTaskSupport> removeBricksMenuCell = getRemoveBrickActivityMenu();
    List<HasCell<GlusterTaskSupport, ?>> list = new ArrayList<>();
    list.add(new VolumeActivityStatusColumn<>());
    list.add(new Column<GlusterTaskSupport, GlusterTaskSupport>(new VolumeActivitySeperatorCell<GlusterTaskSupport>()) {

        @Override
        public GlusterTaskSupport getValue(GlusterTaskSupport object) {
            return object;
        }
    });
    list.add(new Column<GlusterTaskSupport, GlusterTaskSupport>(rebalanceMenuCell) {

        @Override
        public GlusterTaskSupport getValue(GlusterTaskSupport object) {
            return object;
        }
    });
    list.add(new Column<GlusterTaskSupport, GlusterTaskSupport>(removeBricksMenuCell) {

        @Override
        public GlusterTaskSupport getValue(GlusterTaskSupport object) {
            return object;
        }
    });
    List<HasCell<GlusterTaskSupport, ?>> compositeList = new ArrayList<>();
    compositeList.add(new Column<GlusterTaskSupport, GlusterTaskSupport>(new VolumeTaskWaitingCell<>()) {

        @Override
        public GlusterTaskSupport getValue(GlusterTaskSupport object) {
            return object;
        }
    });
    compositeList.add(new Column<GlusterTaskSupport, GlusterTaskSupport>(new VolumeActivityCompositeCell<>(list)) {

        @Override
        public GlusterTaskSupport getValue(GlusterTaskSupport object) {
            return object;
        }
    });
    Column<GlusterVolumeEntity, GlusterVolumeEntity> capacityColumn = new Column<GlusterVolumeEntity, GlusterVolumeEntity>(new VolumeCapacityCell()) {

        @Override
        public GlusterVolumeEntity getValue(GlusterVolumeEntity object) {
            return object;
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(capacityColumn, constants.volumeCapacity(), "100px");
    getTable().addColumn(new VolumeActivityColumn<GlusterVolumeEntity>(new VolumeActivityCompositeCell<GlusterTaskSupport>(compositeList)), constants.activitiesOnVolume(), // $NON-NLS-1$
    "100px");
    AbstractTextColumn<GlusterVolumeEntity> snapshotCountColumn = new AbstractTextColumn<GlusterVolumeEntity>() {

        @Override
        public String getValue(GlusterVolumeEntity object) {
            return object.getSnapshotsCount().toString();
        }
    };
    snapshotCountColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(snapshotCountColumn, constants.noOfSnapshotsLabel(), "100px");
}
Also used : GlusterTaskType(org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskType) GlusterTaskSupport(org.ovirt.engine.core.common.businessentities.gluster.GlusterTaskSupport) MenuCell(org.ovirt.engine.ui.webadmin.widget.table.cell.MenuCell) AssetProvider(org.ovirt.engine.ui.webadmin.gin.AssetProvider) Inject(com.google.inject.Inject) HashMap(java.util.HashMap) GlusterVolumeType(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType) GWT(com.google.gwt.core.client.GWT) ArrayList(java.util.ArrayList) MainVolumePresenter(org.ovirt.engine.ui.webadmin.section.main.presenter.MainVolumePresenter) ApplicationConstants(org.ovirt.engine.ui.webadmin.ApplicationConstants) Map(java.util.Map) FragmentParams(org.ovirt.engine.ui.common.presenter.FragmentParams) VolumeListModel(org.ovirt.engine.ui.uicommonweb.models.volumes.VolumeListModel) VolumeTaskWaitingCell(org.ovirt.engine.ui.webadmin.widget.table.cell.VolumeTaskWaitingCell) HasCell(com.google.gwt.cell.client.HasCell) GlusterVolumeUtils(org.ovirt.engine.ui.frontend.utils.GlusterVolumeUtils) WebAdminButtonDefinition(org.ovirt.engine.ui.webadmin.widget.action.WebAdminButtonDefinition) VolumeInfoColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VolumeInfoColumn) ElementIdHandler(org.ovirt.engine.ui.common.idhandler.ElementIdHandler) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) VolumeActivitySeperatorCell(org.ovirt.engine.ui.webadmin.widget.table.cell.VolumeActivitySeperatorCell) VolumeBrickStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VolumeBrickStatusColumn) VolumeStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VolumeStatusColumn) VolumeActivityColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VolumeActivityColumn) VolumeCapacityCell(org.ovirt.engine.ui.webadmin.widget.table.cell.VolumeCapacityCell) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) MainModelProvider(org.ovirt.engine.ui.common.uicommon.model.MainModelProvider) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) VolumeActivityCompositeCell(org.ovirt.engine.ui.webadmin.widget.table.cell.VolumeActivityCompositeCell) VolumeActivityStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VolumeActivityStatusColumn) List(java.util.List) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) Column(com.google.gwt.user.cellview.client.Column) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) Comparator(java.util.Comparator) GlusterTaskSupport(org.ovirt.engine.core.common.businessentities.gluster.GlusterTaskSupport) VolumeInfoColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VolumeInfoColumn) VolumeTaskWaitingCell(org.ovirt.engine.ui.webadmin.widget.table.cell.VolumeTaskWaitingCell) 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) VolumeInfoColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VolumeInfoColumn) VolumeBrickStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VolumeBrickStatusColumn) VolumeStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VolumeStatusColumn) VolumeActivityColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VolumeActivityColumn) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) VolumeActivityStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VolumeActivityStatusColumn) Column(com.google.gwt.user.cellview.client.Column) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) VolumeCapacityCell(org.ovirt.engine.ui.webadmin.widget.table.cell.VolumeCapacityCell) VolumeActivityCompositeCell(org.ovirt.engine.ui.webadmin.widget.table.cell.VolumeActivityCompositeCell) VolumeBrickStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VolumeBrickStatusColumn) VolumeStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VolumeStatusColumn) VolumeActivitySeperatorCell(org.ovirt.engine.ui.webadmin.widget.table.cell.VolumeActivitySeperatorCell) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with AbstractLinkColumn

use of org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn 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 4 with AbstractLinkColumn

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

the class SubTabClusterNetworkView method initTable.

private void initTable() {
    getTable().enableColumnResizing();
    NetworkStatusColumn statusIconColumn = new NetworkStatusColumn();
    statusIconColumn.setContextMenuTitle(constants.statusIconNetwork());
    // $NON-NLS-1$ //$NON-NLS-2$
    getTable().addColumn(statusIconColumn, "", "20px");
    AbstractTextColumn<Network> nameColumn = new AbstractLinkColumn<Network>(new FieldUpdater<Network, String>() {

        @Override
        public void update(int index, Network network, String value) {
            Map<String, String> parameters = new HashMap<>();
            parameters.put(FragmentParams.NAME.getName(), network.getName());
            parameters.put(FragmentParams.DATACENTER.getName(), getModelProvider().getMainModel().getSelectedItem().getStoragePoolName());
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.networkGeneralSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(Network object) {
            return object.getName();
        }
    };
    nameColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameNetwork(), "400px");
    AbstractTextColumn<Network> statusColumn = new AbstractEnumColumn<Network, NetworkStatus>() {

        @Override
        public NetworkStatus getRawValue(Network object) {
            return object.getCluster().getStatus();
        }
    };
    statusColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(statusColumn, constants.statusNetwork(), "100px");
    // $NON-NLS-1$
    getTable().addColumn(createNetRoleColumn(), constants.roleNetwork(), "90px");
    AbstractTextColumn<Network> descColumn = new AbstractTextColumn<Network>() {

        @Override
        public String getValue(Network object) {
            return object.getDescription();
        }
    };
    descColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(descColumn, constants.descriptionNetwork(), "400px");
}
Also used : AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) NetworkStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.NetworkStatusColumn) Network(org.ovirt.engine.core.common.businessentities.network.Network) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 5 with AbstractLinkColumn

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

the class SubTabStorageDataCenterView method initTable.

void initTable() {
    getTable().enableColumnResizing();
    StorageDomainStatusColumn statusColumn = new StorageDomainStatusColumn();
    statusColumn.setContextMenuTitle(constants.statusStorageDc());
    // $NON-NLS-1$
    getTable().addColumn(statusColumn, constants.empty(), "30px");
    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.getStoragePoolName());
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.dataCenterStorageSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(StorageDomain object) {
            return object.getStoragePoolName();
        }
    };
    nameColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameDc(), "600px");
    AbstractTextColumn<StorageDomain> domainStatusColumn = new AbstractEnumColumn<StorageDomain, StorageDomainStatus>() {

        @Override
        protected StorageDomainStatus getRawValue(StorageDomain object) {
            return object.getStatus();
        }
    };
    domainStatusColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(domainStatusColumn, constants.domainStatusInDcStorageDc(), "300px");
}
Also used : AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) StorageDomainStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.StorageDomainStatusColumn) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

HashMap (java.util.HashMap)16 Map (java.util.Map)16 AbstractLinkColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn)16 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)14 AbstractEnumColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn)13 VM (org.ovirt.engine.core.common.businessentities.VM)5 AbstractUptimeColumn (org.ovirt.engine.ui.webadmin.widget.table.column.AbstractUptimeColumn)5 VmStatusColumn (org.ovirt.engine.ui.webadmin.widget.table.column.VmStatusColumn)5 VmTypeColumn (org.ovirt.engine.ui.webadmin.widget.table.column.VmTypeColumn)5 CommentColumn (org.ovirt.engine.ui.webadmin.widget.table.column.CommentColumn)4 HasCell (com.google.gwt.cell.client.HasCell)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 LinkedHashMap (java.util.LinkedHashMap)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 StatusCompositeCell (org.ovirt.engine.ui.common.widget.table.cell.StatusCompositeCell)2 AbstractColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractColumn)2 HostStatusColumn (org.ovirt.engine.ui.webadmin.widget.table.column.HostStatusColumn)2