Search in sources :

Example 1 with SanTargetModel

use of org.ovirt.engine.ui.uicommonweb.models.storage.SanTargetModel 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)

Example 2 with SanTargetModel

use of org.ovirt.engine.ui.uicommonweb.models.storage.SanTargetModel in project ovirt-engine by oVirt.

the class SanStorageLunToTargetList method createLeafNode.

@SuppressWarnings("unchecked")
@Override
protected TreeItem createLeafNode(ListModel leafModel) {
    if (hideLeaf) {
        return null;
    }
    EntityModelCellTable<ListModel<LunModel>> table = new EntityModelCellTable<>(false, (Resources) GWT.create(SanStorageListTargetTableResources.class), true);
    table.enableColumnResizing();
    table.addColumn(new TextColumn<SanTargetModel>() {

        @Override
        public String getValue(SanTargetModel model) {
            return model.getName();
        }
    }, constants.targetNameSanStorage(), // $NON-NLS-1$
    "500px");
    table.addColumn(new TextColumn<SanTargetModel>() {

        @Override
        public String getValue(SanTargetModel model) {
            return model.getAddress();
        }
    }, constants.addressSanStorage(), // $NON-NLS-1$
    "100px");
    table.addColumn(new TextColumn<SanTargetModel>() {

        @Override
        public String getValue(SanTargetModel model) {
            return model.getPort();
        }
    }, constants.portSanStorage(), // $NON-NLS-1$
    "80px");
    List<SanTargetModel> items = (List<SanTargetModel>) leafModel.getItems();
    if (items.isEmpty()) {
        return null;
    }
    table.setRowData(items);
    Object selectedItem = leafModel.getSelectedItem();
    leafModel.setSelectedItem(null);
    table.asEditor().edit(leafModel);
    leafModel.setSelectedItem(selectedItem);
    // $NON-NLS-1$
    table.setWidth("100%");
    TreeItem item = new TreeItem(table);
    addOpenHandlerToTree(tree, item, table);
    return item;
}
Also used : EntityModelCellTable(org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable) SanTargetModel(org.ovirt.engine.ui.uicommonweb.models.storage.SanTargetModel) TreeItem(com.google.gwt.user.client.ui.TreeItem) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ArrayList (java.util.ArrayList)2 ListModel (org.ovirt.engine.ui.uicommonweb.models.ListModel)2 SanTargetModel (org.ovirt.engine.ui.uicommonweb.models.storage.SanTargetModel)2 TreeItem (com.google.gwt.user.client.ui.TreeItem)1 MultiSelectionModel (com.google.gwt.view.client.MultiSelectionModel)1 SelectionModel (com.google.gwt.view.client.SelectionModel)1 List (java.util.List)1 EntityModelCellTable (org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable)1 AbstractCheckboxColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn)1 AbstractSelectAllCheckBoxHeader (org.ovirt.engine.ui.common.widget.table.header.AbstractSelectAllCheckBoxHeader)1