Search in sources :

Example 11 with AbstractCheckboxColumn

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

the class ImportIscsiStorageView method addTargetsSelectionColumn.

private void addTargetsSelectionColumn() {
    AbstractSelectAllCheckBoxHeader<SanTargetModel> selectAllHeader = new AbstractSelectAllCheckBoxHeader<SanTargetModel>() {

        @Override
        protected void selectionChanged(Boolean value) {
            ListModel listModel = targetsTable.asEditor().flush();
            if (listModel == null || listModel.getItems() == null) {
                return;
            }
            handleSelection(value, listModel, targetsTable.getSelectionModel());
        }

        @Override
        public void handleSelection(Boolean value, ListModel listModel, SelectionModel selectionModel) {
            if (!listModel.getItems().iterator().hasNext()) {
                return;
            }
            ArrayList<SanTargetModel> selectedItems = new ArrayList<>();
            for (SanTargetModel entity : (Iterable<SanTargetModel>) listModel.getItems()) {
                if (!entity.getIsLoggedIn()) {
                    if (value) {
                        selectedItems.add(entity);
                    }
                    selectionModel.setSelected(entity, value);
                }
            }
            listModel.setSelectedItems(selectedItems);
        }

        @Override
        public Boolean getValue() {
            ListModel listModel = targetsTable.asEditor().flush();
            if (listModel == null || listModel.getItems() == null) {
                return false;
            }
            return getCheckValue(listModel.getItems(), targetsTable.getSelectionModel());
        }
    };
    AbstractCheckboxColumn<SanTargetModel> checkColumn = new AbstractCheckboxColumn<SanTargetModel>() {

        @Override
        protected boolean canEdit(SanTargetModel object) {
            return !object.getIsLoggedIn();
        }

        @Override
        public Boolean getValue(SanTargetModel object) {
            return targetsTable.getSelectionModel().isSelected(object) || object.getIsLoggedIn();
        }
    };
    // $NON-NLS-1$
    targetsTable.addColumn(checkColumn, selectAllHeader, "25px");
}
Also used : AbstractSelectAllCheckBoxHeader(org.ovirt.engine.ui.common.widget.table.header.AbstractSelectAllCheckBoxHeader) SanTargetModel(org.ovirt.engine.ui.uicommonweb.models.storage.SanTargetModel) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ArrayList(java.util.ArrayList) SelectionModel(com.google.gwt.view.client.SelectionModel) MultiSelectionModel(com.google.gwt.view.client.MultiSelectionModel) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn)

Aggregations

AbstractCheckboxColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn)11 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)7 ListModel (org.ovirt.engine.ui.uicommonweb.models.ListModel)5 GWT (com.google.gwt.core.client.GWT)4 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)4 UiBinder (com.google.gwt.uibinder.client.UiBinder)4 UiField (com.google.gwt.uibinder.client.UiField)4 ArrayList (java.util.ArrayList)4 EntityModelCellTable (org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable)4 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)4 Context (com.google.gwt.cell.client.Cell.Context)3 EventBus (com.google.gwt.event.shared.EventBus)3 ImageResource (com.google.gwt.resources.client.ImageResource)3 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)3 ScrollPanel (com.google.gwt.user.client.ui.ScrollPanel)3 Inject (com.google.inject.Inject)3 UiCommonEditorDriver (org.ovirt.engine.ui.common.editor.UiCommonEditorDriver)3 WithElementId (org.ovirt.engine.ui.common.idhandler.WithElementId)3 SimpleDialogPanel (org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel)3 ApplicationConstants (org.ovirt.engine.ui.webadmin.ApplicationConstants)3