Search in sources :

Example 6 with EntityModelCellTable

use of org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable 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)

Example 7 with EntityModelCellTable

use of org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable in project ovirt-engine by oVirt.

the class SanStorageLunToTargetList method createRootNode.

@Override
protected TreeItem createRootNode(LunModel rootModel) {
    final EntityModelCellTable<ListModel<LunModel>> table = new EntityModelCellTable<>(multiSelection, (Resources) GWT.create(SanStorageListLunRootResources.class));
    // Create table
    initRootNodeTable(table);
    // Set custom selection column
    AbstractLunSelectionColumn lunSelectionColumn = new AbstractLunSelectionColumn(multiSelection) {

        @Override
        public LunModel getValue(LunModel object) {
            return object;
        }
    };
    // $NON-NLS-1$
    table.setCustomSelectionColumn(lunSelectionColumn, "20px");
    // Add items
    List<LunModel> items = new ArrayList<>();
    items.add(rootModel);
    ListModel<LunModel> listModel = new ListModel<>();
    listModel.setItems(items);
    // Update table
    table.setRowData(items);
    table.asEditor().edit(listModel);
    // $NON-NLS-1$
    table.setWidth("100%");
    // This was the height of the header
    // $NON-NLS-1$
    table.setHeight("26px");
    rootModel.getPropertyChangedEvent().removeListener(lunModelSelectedItemListener);
    rootModel.getPropertyChangedEvent().addListener(lunModelSelectedItemListener, table);
    if (!multiSelection) {
        table.getSelectionModel().addSelectionChangeHandler(event -> {
            SingleSelectionModel SingleSelectionModel = (SingleSelectionModel) event.getSource();
            LunModel selectedLunModel = (LunModel) SingleSelectionModel.getSelectedObject();
            if (selectedLunModel != null) {
                updateSelectedLunWarning(selectedLunModel);
            }
        });
    } else {
        table.getSelectionModel().setSelected(rootModel, rootModel.getIsSelected());
        table.getSelectionModel().addSelectionChangeHandler(event -> model.updateLunWarningForDiscardAfterDelete());
    }
    // Create tree item
    HorizontalPanel panel = new HorizontalPanel();
    panel.add(table);
    // $NON-NLS-1$
    panel.setWidth("100%");
    panel.getElement().getStyle().setTableLayout(TableLayout.FIXED);
    TreeItem item = new TreeItem(table);
    // Display LUNs as grayed-out if needed
    if (rootModel.getIsGrayedOut()) {
        grayOutItem(rootModel.getGrayedOutReasons(), rootModel, table);
    }
    return item;
}
Also used : EntityModelCellTable(org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable) SingleSelectionModel(com.google.gwt.view.client.SingleSelectionModel) TreeItem(com.google.gwt.user.client.ui.TreeItem) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ArrayList(java.util.ArrayList) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) LunModel(org.ovirt.engine.ui.uicommonweb.models.storage.LunModel) AbstractLunSelectionColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLunSelectionColumn)

Example 8 with EntityModelCellTable

use of org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable in project ovirt-engine by oVirt.

the class ChangeQuotaView method updateListHeader.

void updateListHeader(ChangeQuotaModel model) {
    // $NON-NLS-1$
    String width = "100px";
    listHeader = new EntityModelCellTable(false, (Resources) GWT.create(PopupSimpleTableResources.class), true);
    listHeader.addColumn(new EmptyColumn(), constants.elementName(), width);
    listHeader.addColumn(new EmptyColumn(), constants.storageDomainDisk(), width);
    listHeader.addColumn(new EmptyColumn(), constants.currentQuota(), width);
    listHeader.addColumn(new EmptyColumn(), constants.quotaDisk(), width);
    listHeader.setRowData(new ArrayList());
    // $NON-NLS-1$
    listHeader.setWidth("100%");
    listHeaderPanel.setWidget(listHeader);
}
Also used : PopupSimpleTableResources(org.ovirt.engine.ui.common.PopupSimpleTableResources) EntityModelCellTable(org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable) EmptyColumn(org.ovirt.engine.ui.common.widget.table.column.EmptyColumn) ArrayList(java.util.ArrayList) Resources(com.google.gwt.user.cellview.client.DataGrid.Resources) PopupSimpleTableResources(org.ovirt.engine.ui.common.PopupSimpleTableResources)

Aggregations

EntityModelCellTable (org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable)8 ArrayList (java.util.ArrayList)7 ListModel (org.ovirt.engine.ui.uicommonweb.models.ListModel)7 TreeItem (com.google.gwt.user.client.ui.TreeItem)6 SingleSelectionModel (com.google.gwt.view.client.SingleSelectionModel)3 List (java.util.List)3 AbstractLunSelectionColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractLunSelectionColumn)3 EmptyColumn (org.ovirt.engine.ui.common.widget.table.column.EmptyColumn)3 LunModel (org.ovirt.engine.ui.uicommonweb.models.storage.LunModel)3 GWT (com.google.gwt.core.client.GWT)2 Resources (com.google.gwt.user.cellview.client.DataGrid.Resources)2 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)2 AbstractLunRemoveColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractLunRemoveColumn)2 AbstractLunTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractLunTextColumn)2 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)2 SanTargetModel (org.ovirt.engine.ui.uicommonweb.models.storage.SanTargetModel)2 Scheduler (com.google.gwt.core.client.Scheduler)1 TableLayout (com.google.gwt.dom.client.Style.TableLayout)1 EventBus (com.google.gwt.event.shared.EventBus)1 UiBinder (com.google.gwt.uibinder.client.UiBinder)1