Search in sources :

Example 1 with NoSelectionModel

use of com.google.gwt.view.client.NoSelectionModel in project ovirt-engine by oVirt.

the class RegisterEntityInfoPanel method initAppsTable.

protected void initAppsTable() {
    appsTable = new EntityModelCellTable<>(false, true);
    AbstractTextColumn<String> appNameColumn = new AbstractTextColumn<String>() {

        @Override
        public String getValue(String appName) {
            return appName;
        }
    };
    appsTable.addColumn(appNameColumn, constants.nameSnapshot());
    appsTable.setRowData(new ArrayList<EntityModel>());
    // $NON-NLS-1$
    appsTable.setWidth("100%");
    appsTable.setSelectionModel(new NoSelectionModel());
    appsTable.setEmptyTableWidget(new NoItemsLabel());
}
Also used : NoItemsLabel(org.ovirt.engine.ui.common.widget.label.NoItemsLabel) NoSelectionModel(com.google.gwt.view.client.NoSelectionModel) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) RegisterEntityModel(org.ovirt.engine.ui.uicommonweb.models.storage.RegisterEntityModel)

Example 2 with NoSelectionModel

use of com.google.gwt.view.client.NoSelectionModel in project ovirt-engine by oVirt.

the class EntityModelCellTable method addCheckBoxColumn.

private void addCheckBoxColumn(boolean hideCheckbox, boolean showSelectAllCheckbox) {
    if (!hideCheckbox) {
        // Add selection column
        Column<EntityModel, Boolean> checkColumn = null;
        if (getSelectionModel() instanceof SingleSelectionModel) {
            checkColumn = new Column<EntityModel, Boolean>(new RadioboxCell(true, false)) {

                @Override
                public Boolean getValue(EntityModel object) {
                    return getSelectionModel().isSelected(object);
                }
            };
            addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant(constants.htmlNonBreakingSpace()));
        } else if (getSelectionModel() instanceof MultiSelectionModel) {
            checkColumn = new Column<EntityModel, Boolean>(new CheckboxCell(true, false)) {

                @Override
                public Boolean getValue(EntityModel object) {
                    return getSelectionModel().isSelected(object);
                }
            };
            if (showSelectAllCheckbox) {
                AbstractSelectAllCheckBoxHeader<EntityModel> selectAllHeader = new AbstractSelectAllCheckBoxHeader<EntityModel>() {

                    @Override
                    protected void selectionChanged(Boolean value) {
                        if (getListModel() == null || getListModel().getItems() == null) {
                            return;
                        }
                        handleSelection(value, getListModel(), getSelectionModel());
                    }

                    @Override
                    public Boolean getValue() {
                        if (getListModel() == null || getListModel().getItems() == null) {
                            return false;
                        }
                        return getCheckValue(getListModel().getItems(), getSelectionModel());
                    }
                };
                addColumn(checkColumn, selectAllHeader);
            } else {
                addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant(constants.htmlNonBreakingSpace()));
            }
        }
        if (checkColumn != null) {
            setColumnWidth(checkColumn, CHECK_COLUMN_WIDTH, Unit.PX);
            selectionColumnPresent = true;
        }
        addCellPreviewHandler(event -> {
            int columnIndex = event.getColumn();
            Cell<?> cell = getColumn(columnIndex).getCell();
            if (cell instanceof EventHandlingCell && ((EventHandlingCell) cell).handlesEvent(event)) {
                return;
            }
            if (BrowserEvents.CLICK.equals(event.getNativeEvent().getType()) && !(getSelectionModel() instanceof NoSelectionModel)) {
                // Let the selection column deal with this
                if (event.getColumn() == 0) {
                    return;
                }
                getSelectionModel().setSelected(event.getValue(), !getSelectionModel().isSelected(event.getValue()));
            }
        });
    }
}
Also used : SingleSelectionModel(com.google.gwt.view.client.SingleSelectionModel) MultiSelectionModel(com.google.gwt.view.client.MultiSelectionModel) NoSelectionModel(com.google.gwt.view.client.NoSelectionModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) RadioboxCell(org.ovirt.engine.ui.common.widget.table.cell.RadioboxCell) AbstractSelectAllCheckBoxHeader(org.ovirt.engine.ui.common.widget.table.header.AbstractSelectAllCheckBoxHeader) Column(com.google.gwt.user.cellview.client.Column) EventHandlingCell(org.ovirt.engine.ui.common.widget.table.cell.EventHandlingCell) CheckboxCell(org.ovirt.engine.ui.common.widget.table.cell.CheckboxCell)

Example 3 with NoSelectionModel

use of com.google.gwt.view.client.NoSelectionModel in project ovirt-engine by oVirt.

the class VmSnapshotInfoPanel method initNicsTable.

private void initNicsTable() {
    nicsTable = new EntityModelCellTable<>(false, true);
    nicsTable.enableColumnResizing();
    AbstractTextColumn<VmNetworkInterface> nameColumn = new AbstractTextColumn<VmNetworkInterface>() {

        @Override
        public String getValue(VmNetworkInterface object) {
            return object.getName();
        }
    };
    // $NON-NLS-1$
    nicsTable.addColumn(nameColumn, constants.nameInterface(), "80px");
    AbstractTextColumn<VmNetworkInterface> networkNameColumn = new AbstractTextColumn<VmNetworkInterface>() {

        @Override
        public String getValue(VmNetworkInterface object) {
            return object.getNetworkName();
        }
    };
    // $NON-NLS-1$
    nicsTable.addColumn(networkNameColumn, constants.networkNameInterface(), "80px");
    AbstractTextColumn<VmNetworkInterface> profileNameColumn = new AbstractTextColumn<VmNetworkInterface>() {

        @Override
        public String getValue(VmNetworkInterface object) {
            return object.getVnicProfileName();
        }
    };
    // $NON-NLS-1$
    nicsTable.addColumn(profileNameColumn, constants.profileNameInterface(), "80px");
    AbstractTextColumn<VmNetworkInterface> typeColumn = new AbstractEnumColumn<VmNetworkInterface, VmInterfaceType>() {

        @Override
        protected VmInterfaceType getRawValue(VmNetworkInterface object) {
            return VmInterfaceType.forValue(object.getType());
        }
    };
    // $NON-NLS-1$
    nicsTable.addColumn(typeColumn, constants.typeInterface(), "80px");
    AbstractTextColumn<VmNetworkInterface> macColumn = new AbstractTextColumn<VmNetworkInterface>() {

        @Override
        public String getValue(VmNetworkInterface object) {
            return object.getMacAddress();
        }
    };
    // $NON-NLS-1$
    nicsTable.addColumn(macColumn, constants.macInterface(), "80px");
    AbstractTextColumn<VmNetworkInterface> speedColumn = new AbstractTextColumn<VmNetworkInterface>() {

        @Override
        public String getValue(VmNetworkInterface object) {
            if (object.getSpeed() != null) {
                return object.getSpeed().toString();
            } else {
                return null;
            }
        }
    };
    // $NON-NLS-1$
    nicsTable.addColumn(speedColumn, templates.sub(constants.speedInterface(), constants.mbps()), "80px");
    AbstractTextColumn<VmNetworkInterface> rxColumn = new AbstractRxTxRateColumn<VmNetworkInterface>() {

        @Override
        protected Double getRate(VmNetworkInterface object) {
            return object.getStatistics().getReceiveRate();
        }

        @Override
        protected Double getSpeed(VmNetworkInterface object) {
            if (object.getSpeed() != null) {
                return object.getSpeed().doubleValue();
            } else {
                return null;
            }
        }
    };
    // $NON-NLS-1$
    nicsTable.addColumn(rxColumn, templates.sub(constants.rxRate(), constants.mbps()), "80px");
    AbstractTextColumn<VmNetworkInterface> txColumn = new AbstractRxTxRateColumn<VmNetworkInterface>() {

        @Override
        protected Double getRate(VmNetworkInterface object) {
            return object.getStatistics().getTransmitRate();
        }

        @Override
        protected Double getSpeed(VmNetworkInterface object) {
            if (object.getSpeed() != null) {
                return object.getSpeed().doubleValue();
            } else {
                return null;
            }
        }
    };
    // $NON-NLS-1$
    nicsTable.addColumn(txColumn, templates.sub(constants.txRate(), constants.mbps()), "80px");
    AbstractTextColumn<VmNetworkInterface> dropsColumn = new AbstractSumUpColumn<VmNetworkInterface>() {

        @Override
        protected Double[] getRawValue(VmNetworkInterface object) {
            Double receiveDropRate = object != null ? object.getStatistics().getReceiveDropRate() : null;
            Double transmitDropRate = object != null ? object.getStatistics().getTransmitDropRate() : null;
            return new Double[] { receiveDropRate, transmitDropRate };
        }
    };
    // $NON-NLS-1$
    nicsTable.addColumn(dropsColumn, templates.sub(constants.dropsInterface(), constants.pkts()), "80px");
    nicsTable.setRowData(new ArrayList<EntityModel>());
    // $NON-NLS-1$
    nicsTable.setWidth("100%");
    nicsTable.setSelectionModel(new NoSelectionModel());
}
Also used : AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) NoSelectionModel(com.google.gwt.view.client.NoSelectionModel) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) AbstractSumUpColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractSumUpColumn) AbstractRxTxRateColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractRxTxRateColumn)

Example 4 with NoSelectionModel

use of com.google.gwt.view.client.NoSelectionModel in project ovirt-engine by oVirt.

the class GlusterClusterSnapshotConfigureOptionsPopupView method initEditors.

private void initEditors() {
    clusterEditor = new ListModelListBoxEditor<>(new NameRenderer<Cluster>());
    configsTable = new EntityModelCellTable<>(false, true);
    configsTable.setSelectionModel(new NoSelectionModel());
    configsTable.addColumn(new AbstractEntityModelTextColumn<GlusterVolumeSnapshotConfig>() {

        @Override
        public String getText(GlusterVolumeSnapshotConfig object) {
            return object.getParamName();
        }
    }, constants.volumeSnapshotConfigName(), // $NON-NLS-1$
    "200px");
    Column<EntityModel<GlusterVolumeSnapshotConfig>, String> valueColumn = new Column<EntityModel<GlusterVolumeSnapshotConfig>, String>(new TextInputCell()) {

        @Override
        public String getValue(EntityModel<GlusterVolumeSnapshotConfig> object) {
            return object.getEntity().getParamValue();
        }
    };
    // $NON-NLS-1$
    configsTable.addColumn(valueColumn, constants.volumeSnapshotConfigValue(), "100px");
    valueColumn.setFieldUpdater((index, object, value) -> object.getEntity().setParamValue(value));
}
Also used : GlusterVolumeSnapshotConfig(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfig) AbstractEntityModelTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEntityModelTextColumn) Column(com.google.gwt.user.cellview.client.Column) NameRenderer(org.ovirt.engine.ui.common.widget.renderer.NameRenderer) NoSelectionModel(com.google.gwt.view.client.NoSelectionModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) TextInputCell(com.google.gwt.cell.client.TextInputCell)

Example 5 with NoSelectionModel

use of com.google.gwt.view.client.NoSelectionModel in project ovirt-engine by oVirt.

the class GlusterVolumeGeoReplicationSessionConfigPopupView method initConfigTable.

private void initConfigTable() {
    geoReplicationConfigTable = new EntityModelCellTable<>(false, true);
    geoReplicationConfigTable.setSelectionModel(new NoSelectionModel());
    geoReplicationConfigTable.addColumn(new AbstractEntityModelTextColumn<Pair<Boolean, GlusterGeoRepSessionConfiguration>>() {

        @Override
        protected String getText(Pair<Boolean, GlusterGeoRepSessionConfiguration> entity) {
            return entity.getSecond().getKey();
        }
    }, constants.optionKeyVolumeParameter(), // $NON-NLS-1$
    "150px");
    geoReplicationConfigTable.addColumn(new AbstractScrollableTextColumn<EntityModel<Pair<Boolean, GlusterGeoRepSessionConfiguration>>>() {

        @Override
        public String getValue(EntityModel<Pair<Boolean, GlusterGeoRepSessionConfiguration>> object) {
            return object.getEntity().getSecond().getDescription() == null ? constants.notAvailableLabel() : object.getEntity().getSecond().getDescription();
        }
    }, constants.descriptionVolumeParameter(), // $NON-NLS-1$
    "300px");
    geoReplicationConfigTable.addColumn(new GlusterConfigAwareColumn(), constants.optionValueVolumeParameter(), // $NON-NLS-1$
    "200px");
    geoReplicationConfigTable.addColumn(new AbstractCheckboxColumn<EntityModel<Pair<Boolean, GlusterGeoRepSessionConfiguration>>>(true, (index, object, value) -> object.getEntity().setFirst(value)) {

        @Override
        protected boolean canEdit(EntityModel<Pair<Boolean, GlusterGeoRepSessionConfiguration>> object) {
            return true;
        }

        @Override
        public Boolean getValue(EntityModel<Pair<Boolean, GlusterGeoRepSessionConfiguration>> object) {
            return object.getEntity().getFirst();
        }
    }, constants.resetGeoRepSessionConfig());
}
Also used : AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) EventBus(com.google.gwt.event.shared.EventBus) EntityModelCellTable(org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable) AbstractEntityModelTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEntityModelTextColumn) AssetProvider(org.ovirt.engine.ui.webadmin.gin.AssetProvider) ElementIdHandler(org.ovirt.engine.ui.common.idhandler.ElementIdHandler) Inject(com.google.inject.Inject) UiCommonEditorDriver(org.ovirt.engine.ui.common.editor.UiCommonEditorDriver) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) AbstractModelBoundPopupView(org.ovirt.engine.ui.common.view.popup.AbstractModelBoundPopupView) GWT(com.google.gwt.core.client.GWT) GlusterConfigAwareColumn(org.ovirt.engine.ui.common.widget.table.column.GlusterConfigAwareColumn) GlusterVolumeGeoReplicationSessionConfigModel(org.ovirt.engine.ui.uicommonweb.models.gluster.GlusterVolumeGeoReplicationSessionConfigModel) WithElementId(org.ovirt.engine.ui.common.idhandler.WithElementId) GlusterGeoRepSessionConfiguration(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionConfiguration) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) UiBinder(com.google.gwt.uibinder.client.UiBinder) ApplicationConstants(org.ovirt.engine.ui.webadmin.ApplicationConstants) SimpleDialogPanel(org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel) GlusterVolumeGeoReplicationSessionConfigPopupPresenterWidget(org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.GlusterVolumeGeoReplicationSessionConfigPopupPresenterWidget) UiField(com.google.gwt.uibinder.client.UiField) NoSelectionModel(com.google.gwt.view.client.NoSelectionModel) AbstractScrollableTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractScrollableTextColumn) Pair(org.ovirt.engine.core.common.utils.Pair) NoSelectionModel(com.google.gwt.view.client.NoSelectionModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) GlusterGeoRepSessionConfiguration(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionConfiguration) GlusterConfigAwareColumn(org.ovirt.engine.ui.common.widget.table.column.GlusterConfigAwareColumn) Pair(org.ovirt.engine.core.common.utils.Pair)

Aggregations

NoSelectionModel (com.google.gwt.view.client.NoSelectionModel)12 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)12 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)7 Column (com.google.gwt.user.cellview.client.Column)4 NoItemsLabel (org.ovirt.engine.ui.common.widget.label.NoItemsLabel)4 AbstractEnumColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn)4 RegisterEntityModel (org.ovirt.engine.ui.uicommonweb.models.storage.RegisterEntityModel)4 AbstractEntityModelTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractEntityModelTextColumn)3 AbstractFullDateTimeColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractFullDateTimeColumn)3 TextInputCell (com.google.gwt.cell.client.TextInputCell)2 GWT (com.google.gwt.core.client.GWT)2 UiBinder (com.google.gwt.uibinder.client.UiBinder)2 UiField (com.google.gwt.uibinder.client.UiField)2 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)2 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2 UiCommonEditorDriver (org.ovirt.engine.ui.common.editor.UiCommonEditorDriver)2 ElementIdHandler (org.ovirt.engine.ui.common.idhandler.ElementIdHandler)2 EntityModelCellTable (org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable)2 AbstractCheckboxColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn)2 AbstractDiskSizeColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractDiskSizeColumn)2