Search in sources :

Example 1 with AbstractEnumColumn

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

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

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

the class ManageGlusterSwiftPopupView method initEditors.

private void initEditors() {
    swiftStatusEditor = new EntityModelLabelEditor<>(new EnumRenderer<GlusterServiceStatus>());
    // $NON-NLS-1$
    startSwift = new EntityModelRadioButtonEditor("swift_action", Align.RIGHT);
    // $NON-NLS-1$
    stopSwift = new EntityModelRadioButtonEditor("swift_action", Align.RIGHT);
    // $NON-NLS-1$
    restartSwift = new EntityModelRadioButtonEditor("swift_action", Align.RIGHT);
    manageSwiftServerLevel = new EntityModelCheckBoxEditor(Align.RIGHT);
    hostServicesTable = new EntityModelCellTable<>(false, true);
    hostServicesTable.addColumn(new AbstractEntityModelTextColumn<GlusterServerService>() {

        @Override
        public String getText(GlusterServerService entity) {
            return entity.getHostName();
        }
    }, constants.hostGlusterSwift());
    hostServicesTable.addColumn(new AbstractEnumColumn<EntityModel, ServiceType>() {

        @Override
        protected ServiceType getRawValue(EntityModel object) {
            return ((GlusterSwiftServiceModel) object).getEntity().getServiceType();
        }
    }, constants.serviceNameGlusterSwift());
    hostServicesTable.addColumn(new AbstractEnumColumn<EntityModel, GlusterServiceStatus>() {

        @Override
        protected GlusterServiceStatus getRawValue(EntityModel object) {
            return ((GlusterSwiftServiceModel) object).getEntity().getStatus();
        }
    }, constants.serviceStatusGlusterSwift());
    Column<EntityModel, Boolean> startSwiftColumn = new Column<EntityModel, Boolean>(new RadioboxCell(false, true)) {

        @Override
        public Boolean getValue(EntityModel object) {
            GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
            return swiftServiceModel.getStartSwift().getEntity();
        }

        @Override
        public void render(Context context, EntityModel object, SafeHtmlBuilder sb) {
            GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
            if (swiftServiceModel.getStartSwift().getIsChangable()) {
                super.render(context, object, sb);
            }
        }
    };
    startSwiftColumn.setFieldUpdater((index, object, value) -> {
        GlusterSwiftServiceModel swiftModel = (GlusterSwiftServiceModel) object;
        swiftModel.getStartSwift().setEntity(value);
        if (value) {
            swiftModel.getStopSwift().setEntity(false);
            swiftModel.getRestartSwift().setEntity(false);
            hostServicesTable.redraw();
        }
    });
    hostServicesTable.addColumn(startSwiftColumn, constants.startGlusterSwift());
    Column<EntityModel, Boolean> stopSwiftColumn = new Column<EntityModel, Boolean>(new RadioboxCell(false, true)) {

        @Override
        public Boolean getValue(EntityModel object) {
            GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
            return swiftServiceModel.getStopSwift().getEntity();
        }

        @Override
        public void render(Context context, EntityModel object, SafeHtmlBuilder sb) {
            GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
            if (swiftServiceModel.getStopSwift().getIsChangable()) {
                super.render(context, object, sb);
            }
        }
    };
    stopSwiftColumn.setFieldUpdater((index, object, value) -> {
        GlusterSwiftServiceModel swiftModel = (GlusterSwiftServiceModel) object;
        if (swiftModel.getStopSwift().getIsChangable()) {
            swiftModel.getStopSwift().setEntity(value);
            if (value) {
                swiftModel.getStartSwift().setEntity(false);
                swiftModel.getRestartSwift().setEntity(false);
                hostServicesTable.redraw();
            }
        }
    });
    hostServicesTable.addColumn(stopSwiftColumn, constants.stopGlusterSwift());
    Column<EntityModel, Boolean> restartSwiftColumn = new Column<EntityModel, Boolean>(new RadioboxCell(false, true)) {

        @Override
        public Boolean getValue(EntityModel object) {
            GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
            return swiftServiceModel.getRestartSwift().getEntity();
        }

        @Override
        public void render(Context context, EntityModel object, SafeHtmlBuilder sb) {
            GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
            if (swiftServiceModel.getRestartSwift().getIsChangable()) {
                super.render(context, object, sb);
            }
        }
    };
    restartSwiftColumn.setFieldUpdater((index, object, value) -> {
        GlusterSwiftServiceModel swiftModel = (GlusterSwiftServiceModel) object;
        swiftModel.getRestartSwift().setEntity(value);
        if (value) {
            swiftModel.getStartSwift().setEntity(false);
            swiftModel.getStopSwift().setEntity(false);
            hostServicesTable.redraw();
        }
    });
    hostServicesTable.addColumn(restartSwiftColumn, constants.restartGlusterSwift());
}
Also used : Context(com.google.gwt.cell.client.Cell.Context) GlusterServerService(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) RadioboxCell(org.ovirt.engine.ui.common.widget.table.cell.RadioboxCell) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) EnumRenderer(org.ovirt.engine.ui.common.widget.renderer.EnumRenderer) GlusterServiceStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus) AbstractEntityModelTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEntityModelTextColumn) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) Column(com.google.gwt.user.cellview.client.Column) ServiceType(org.ovirt.engine.core.common.businessentities.gluster.ServiceType) EntityModelCheckBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor) GlusterSwiftServiceModel(org.ovirt.engine.ui.uicommonweb.models.clusters.GlusterSwiftServiceModel) EntityModelRadioButtonEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelRadioButtonEditor)

Example 4 with AbstractEnumColumn

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

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

the class RegisterVmPopupView method createEntityTable.

@Override
protected void createEntityTable(RegisterVmModel model) {
    entityTable.addColumn(new AbstractImageResourceColumn<RegisterVmData>() {

        @Override
        public ImageResource getValue(RegisterVmData registerVmData) {
            if (registerVmData.getError() != null) {
                return resources.errorImage();
            }
            if (registerVmData.getWarning() != null) {
                return resources.alertImage();
            }
            return null;
        }

        @Override
        public SafeHtml getTooltip(RegisterVmData registerVmData) {
            String problem;
            if (registerVmData.getError() != null) {
                problem = registerVmData.getError();
            } else {
                problem = registerVmData.getWarning();
            }
            return problem == null ? null : new SafeHtmlBuilder().appendEscapedLines(problem).toSafeHtml();
        }
    }, constants.empty(), // $NON-NLS-1$
    "20px");
    AbstractTextColumn<RegisterVmData> nameColumn = new AbstractTextColumn<RegisterVmData>() {

        @Override
        public String getValue(RegisterVmData registerVmData) {
            return registerVmData.getVm().getName();
        }
    };
    // $NON-NLS-1$
    entityTable.addColumn(nameColumn, constants.nameVm(), "150px");
    AbstractTextColumn<RegisterVmData> originColumn = new AbstractEnumColumn<RegisterVmData, OriginType>() {

        @Override
        protected OriginType getRawValue(RegisterVmData registerVmData) {
            return registerVmData.getVm().getOrigin();
        }
    };
    // $NON-NLS-1$
    entityTable.addColumn(originColumn, constants.originVm(), "100px");
    AbstractTextColumn<RegisterVmData> memoryColumn = new AbstractTextColumn<RegisterVmData>() {

        @Override
        public String getValue(RegisterVmData registerVmData) {
            int size = registerVmData.getVm().getVmMemSizeMb();
            return messages.megabytes(String.valueOf(size));
        }
    };
    // $NON-NLS-1$
    entityTable.addColumn(memoryColumn, constants.memoryVm(), "100px");
    AbstractTextColumn<RegisterVmData> cpuColumn = new AbstractTextColumn<RegisterVmData>() {

        @Override
        public String getValue(RegisterVmData registerVmData) {
            int numOfCpus = registerVmData.getVm().getNumOfCpus();
            return String.valueOf(numOfCpus);
        }
    };
    // $NON-NLS-1$
    entityTable.addColumn(cpuColumn, constants.cpusVm(), "50px");
    AbstractTextColumn<RegisterVmData> archColumn = new AbstractTextColumn<RegisterVmData>() {

        @Override
        public String getValue(RegisterVmData registerVmData) {
            ArchitectureType clusterArch = registerVmData.getVm().getClusterArch();
            return String.valueOf(clusterArch);
        }
    };
    // $NON-NLS-1$
    entityTable.addColumn(archColumn, constants.architectureVm(), "100px");
    AbstractTextColumn<RegisterVmData> diskColumn = new AbstractTextColumn<RegisterVmData>() {

        @Override
        public String getValue(RegisterVmData registerVmData) {
            int numOfDisks = registerVmData.getVm().getDiskMap().size();
            return String.valueOf(numOfDisks);
        }
    };
    // $NON-NLS-1$
    entityTable.addColumn(diskColumn, constants.disksVm(), "50px");
    // $NON-NLS-1$
    entityTable.addColumn(creatReassignMacsColumn(), new ReassignBadMacsHeader(), "150px");
    // $NON-NLS-1$
    entityTable.addColumn(createAllowPartialColumn(), constants.allowPartial(), "95px");
    // $NON-NLS-1$
    entityTable.addColumn(getClusterColumn(), constants.clusterVm(), "150px");
    if (model.isQuotaEnabled()) {
        // $NON-NLS-1$
        entityTable.addColumn(getClusterQuotaColumn(), constants.quotaVm(), "150px");
    }
}
Also used : ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) RegisterVmData(org.ovirt.engine.ui.uicommonweb.models.vms.register.RegisterVmData) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) ImageResource(com.google.gwt.resources.client.ImageResource) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)

Aggregations

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