Martin Betak has uploaded a new change for review. Change subject: frontend: Add missing columns to HostDevice subtabs ......................................................................
frontend: Add missing columns to HostDevice subtabs Added missing columns and fixed column sizes of host device table in VM and Host sub tabs to make it consistent with AddVmHostDevicePopupView. Also since in VM and Host sub tabs is always displayed the same information, extracted the commonalities to HostDeviceModelBaseTable. Change-Id: I484d0607bb27118058bef08c628c8a3bc8587fc9 Signed-off-by: Martin Betak <mbe...@redhat.com> --- M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/vm/AddVmHostDevicePopupView.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/vm/HostDeviceColumnHelper.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/HostDeviceModelBaseTable.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/HostDeviceModelTable.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostDeviceView.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/virtualMachine/VmHostDeviceModelTable.java 6 files changed, 143 insertions(+), 143 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/30/41830/1 diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/vm/AddVmHostDevicePopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/vm/AddVmHostDevicePopupView.java index ceea8e8..20db0d8 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/vm/AddVmHostDevicePopupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/vm/AddVmHostDevicePopupView.java @@ -19,9 +19,7 @@ import org.ovirt.engine.ui.uicommonweb.models.EntityModel; import org.ovirt.engine.ui.uicommonweb.models.ListModel; import org.ovirt.engine.ui.uicommonweb.models.vms.hostdev.AddVmHostDevicesModel; -import org.ovirt.engine.ui.uicompat.external.StringUtils; import org.ovirt.engine.ui.webadmin.ApplicationConstants; -import org.ovirt.engine.ui.webadmin.ApplicationMessages; import org.ovirt.engine.ui.webadmin.gin.AssetProvider; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.hostdev.AddVmHostDevicePopupPresenterWidget; @@ -58,7 +56,6 @@ EntityModelCellTable<ListModel<EntityModel<HostDeviceView>>> selectedHostDevices; private static final ApplicationConstants constants = AssetProvider.getConstants(); - private static final ApplicationMessages messages = AssetProvider.getMessages(); @Inject public AddVmHostDevicePopupView(EventBus eventBus, Driver driver, ViewUiBinder uiBinder, ViewIdHandler idHandler) { @@ -98,7 +95,7 @@ addHostDeviceColumn(hostDeviceTable, constants.product(), "350px", new AbstractTextColumn<EntityModel<HostDeviceView>>() { //$NON-NLS-1$ @Override public String getValue(EntityModel<HostDeviceView> hostDevice) { - return renderNameId( + return HostDeviceColumnHelper.renderNameId( hostDevice.getEntity().getProductName(), hostDevice.getEntity().getProductId()); } @@ -107,7 +104,7 @@ addHostDeviceColumn(hostDeviceTable, constants.vendor(), "200px", new AbstractTextColumn<EntityModel<HostDeviceView>>() { //$NON-NLS-1$ @Override public String getValue(EntityModel<HostDeviceView> hostDevice) { - return renderNameId( + return HostDeviceColumnHelper.renderNameId( hostDevice.getEntity().getVendorName(), hostDevice.getEntity().getVendorId()); } @@ -123,24 +120,16 @@ addHostDeviceColumn(hostDeviceTable, constants.attachedToVms(), "150px", new AbstractTextColumn<EntityModel<HostDeviceView>>() { //$NON-NLS-1$ @Override public String getValue(EntityModel<HostDeviceView> hostDevice) { - return StringUtils.join(hostDevice.getEntity().getAttachedVmNames(), ", "); //$NON-NLS-1$ + return HostDeviceColumnHelper.renderVmNamesList(hostDevice.getEntity().getAttachedVmNames()); } }); addHostDeviceColumn(hostDeviceTable, constants.iommuGroup(), "150px", new AbstractTextColumn<EntityModel<HostDeviceView>>() { //$NON-NLS-1$ @Override public String getValue(EntityModel<HostDeviceView> hostDevice) { - return hostDevice.getEntity().getIommuGroup() == null ? constants.notAvailableLabel() : hostDevice.getEntity().getIommuGroup().toString(); + return HostDeviceColumnHelper.renderIommuGroup(hostDevice.getEntity().getIommuGroup()); } }); - } - - private String renderNameId(String name, String id) { - if (StringUtils.isEmpty(name)) { - return id; - } - // we assume that VDSM will never report name != null && id == null - return messages.nameId(name, id); } private void addHostDeviceColumn(EntityModelCellTable<ListModel<EntityModel<HostDeviceView>>> hostDeviceTable, diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/vm/HostDeviceColumnHelper.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/vm/HostDeviceColumnHelper.java new file mode 100644 index 0000000..9953540 --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/vm/HostDeviceColumnHelper.java @@ -0,0 +1,30 @@ +package org.ovirt.engine.ui.webadmin.section.main.view.popup.vm; + +import org.ovirt.engine.ui.uicompat.external.StringUtils; +import org.ovirt.engine.ui.webadmin.ApplicationConstants; +import org.ovirt.engine.ui.webadmin.ApplicationMessages; +import org.ovirt.engine.ui.webadmin.gin.AssetProvider; + +import java.util.List; + +public final class HostDeviceColumnHelper { + + private static final ApplicationConstants constants = AssetProvider.getConstants(); + private static final ApplicationMessages messages = AssetProvider.getMessages(); + + public static String renderNameId(String name, String id) { + if (StringUtils.isEmpty(name)) { + return id; + } + // we assume that VDSM will never report name != null && id == null + return messages.nameId(name, id); + } + + public static String renderVmNamesList(List<String> names) { + return StringUtils.join(names, ", "); //$NON-NLS-1$ + } + + public static String renderIommuGroup(Integer group) { + return group == null ? constants.notAvailableLabel() : group.toString(); + } +} diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/HostDeviceModelBaseTable.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/HostDeviceModelBaseTable.java new file mode 100644 index 0000000..cd7066e --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/HostDeviceModelBaseTable.java @@ -0,0 +1,75 @@ +package org.ovirt.engine.ui.webadmin.section.main.view.tab.host; + +import com.google.gwt.event.shared.EventBus; +import org.ovirt.engine.core.common.businessentities.HostDeviceView; +import org.ovirt.engine.ui.common.system.ClientStorage; +import org.ovirt.engine.ui.common.uicommon.model.SearchableTableModelProvider; +import org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn; +import org.ovirt.engine.ui.common.widget.uicommon.AbstractModelBoundTableWidget; +import org.ovirt.engine.ui.uicommonweb.models.vms.hostdev.HostDeviceListModelBase; +import org.ovirt.engine.ui.webadmin.ApplicationConstants; +import org.ovirt.engine.ui.webadmin.gin.AssetProvider; +import org.ovirt.engine.ui.webadmin.section.main.view.popup.vm.HostDeviceColumnHelper; + +public abstract class HostDeviceModelBaseTable<M extends HostDeviceListModelBase<?>> extends AbstractModelBoundTableWidget<HostDeviceView, M> { + + protected static final ApplicationConstants constants = AssetProvider.getConstants(); + + public HostDeviceModelBaseTable(SearchableTableModelProvider<HostDeviceView, M> modelProvider, EventBus eventBus, ClientStorage clientStorage) { + super(modelProvider, eventBus, clientStorage, false); + } + + @Override + public void initTable() { + + getTable().enableColumnResizing(); + + addColumn(constants.deviceName(), "200px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ + @Override + public String getValue(HostDeviceView object) { + return object.getDeviceName(); + } + }); + addColumn(constants.capability(), "130px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ + @Override + public String getValue(HostDeviceView object) { + return object.getCapability(); + } + }); + addColumn(constants.product(), "350px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ + @Override + public String getValue(HostDeviceView object) { + return HostDeviceColumnHelper.renderNameId(object.getProductName(), object.getProductId()); + } + }); + addColumn(constants.vendor(), "200px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ + @Override + public String getValue(HostDeviceView object) { + return HostDeviceColumnHelper.renderNameId(object.getVendorName(), object.getVendorId()); + } + }); + addColumn(constants.currentlyUsedByVm(), "150px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ + @Override + public String getValue(HostDeviceView object) { + return object.getRunningVmName(); + } + }); + addColumn(constants.attachedToVms(), "150px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ + @Override + public String getValue(HostDeviceView object) { + return HostDeviceColumnHelper.renderVmNamesList(object.getAttachedVmNames()); + } + }); + addColumn(constants.iommuGroup(), "150px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ + @Override + public String getValue(HostDeviceView object) { + return HostDeviceColumnHelper.renderIommuGroup(object.getIommuGroup()); + } + }); + } + + private void addColumn(String header, String width, AbstractTextColumn<HostDeviceView> column) { + column.makeSortable(); + getTable().addColumn(column, header, width); + } +} diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/HostDeviceModelTable.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/HostDeviceModelTable.java new file mode 100644 index 0000000..56de835 --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/HostDeviceModelTable.java @@ -0,0 +1,16 @@ +package org.ovirt.engine.ui.webadmin.section.main.view.tab.host; + +import com.google.gwt.event.shared.EventBus; +import org.ovirt.engine.core.common.businessentities.HostDeviceView; +import org.ovirt.engine.ui.common.system.ClientStorage; +import org.ovirt.engine.ui.common.uicommon.model.SearchableTableModelProvider; +import org.ovirt.engine.ui.uicommonweb.models.vms.hostdev.HostDeviceListModel; + +public class HostDeviceModelTable extends HostDeviceModelBaseTable<HostDeviceListModel> { + + public HostDeviceModelTable( + SearchableTableModelProvider<HostDeviceView, HostDeviceListModel> modelProvider, + EventBus eventBus, ClientStorage clientStorage) { + super(modelProvider, eventBus, clientStorage); + } +} diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostDeviceView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostDeviceView.java index da9475f..65353b0 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostDeviceView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostDeviceView.java @@ -1,90 +1,33 @@ package org.ovirt.engine.ui.webadmin.section.main.view.tab.host; import com.google.gwt.core.client.GWT; +import com.google.gwt.event.shared.EventBus; import com.google.inject.Inject; import org.ovirt.engine.core.common.businessentities.HostDeviceView; import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.ui.common.idhandler.ElementIdHandler; +import org.ovirt.engine.ui.common.system.ClientStorage; import org.ovirt.engine.ui.common.uicommon.model.SearchableDetailModelProvider; -import org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn; +import org.ovirt.engine.ui.common.view.AbstractSubTabTableWidgetView; import org.ovirt.engine.ui.uicommonweb.models.hosts.HostListModel; import org.ovirt.engine.ui.uicommonweb.models.vms.hostdev.HostDeviceListModel; -import org.ovirt.engine.ui.webadmin.ApplicationConstants; -import org.ovirt.engine.ui.webadmin.gin.AssetProvider; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.host.SubTabHostDevicePresenter; -import org.ovirt.engine.ui.webadmin.section.main.view.AbstractSubTabTableView; public class SubTabHostDeviceView - extends AbstractSubTabTableView<VDS, HostDeviceView, HostListModel<Void>, HostDeviceListModel> + extends AbstractSubTabTableWidgetView<VDS, HostDeviceView, HostListModel<Void>, HostDeviceListModel> implements SubTabHostDevicePresenter.ViewDef { interface ViewIdHandler extends ElementIdHandler<SubTabHostDeviceView> { ViewIdHandler idHandler = GWT.create(ViewIdHandler.class); } - private final static ApplicationConstants constants = AssetProvider.getConstants(); - @Inject - public SubTabHostDeviceView(SearchableDetailModelProvider<HostDeviceView, HostListModel<Void>, HostDeviceListModel> modelProvider) { - super(modelProvider); - initTable(); - initWidget(getTable()); - } - - public void initTable() { - getTable().enableColumnResizing(); - - addColumn(constants.deviceName(), "350px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ - @Override - public String getValue(HostDeviceView object) { - return object.getDeviceName(); - } - }); - addColumn(constants.iommuGroup(), "100px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ - @Override - public String getValue(HostDeviceView object) { - return object.getIommuGroup() == null ? constants.notAvailableLabel() : object.getIommuGroup().toString(); - } - }); - addColumn(constants.capability(), "100px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ - @Override - public String getValue(HostDeviceView object) { - return object.getCapability(); - } - }); - addColumn(constants.product(), "350px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ - @Override - public String getValue(HostDeviceView object) { - return object.getProductName(); - } - }); - addColumn(constants.productId(), "150px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ - @Override - public String getValue(HostDeviceView object) { - return object.getProductId(); - } - }); - addColumn(constants.vendorName(), "150px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ - @Override - public String getValue(HostDeviceView object) { - return object.getVendorName(); - } - }); - addColumn(constants.vendorId(), "150px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ - @Override - public String getValue(HostDeviceView object) { - return object.getVendorId(); - } - }); - } - - private void addColumn(String header, String width, AbstractTextColumn<HostDeviceView> column) { - column.makeSortable(); - getTable().addColumn(column, header, width); - } - - @Override - protected void generateIds() { + public SubTabHostDeviceView( + SearchableDetailModelProvider<HostDeviceView, HostListModel<Void>, HostDeviceListModel> modelProvider, + EventBus eventBus, ClientStorage clientStorage) { + super(new HostDeviceModelTable(modelProvider, eventBus, clientStorage)); ViewIdHandler.idHandler.generateAndSetIds(this); + initTable(); + initWidget(getModelBoundTableWidget()); } } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/virtualMachine/VmHostDeviceModelTable.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/virtualMachine/VmHostDeviceModelTable.java index 0fb84c2..8bf390d 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/virtualMachine/VmHostDeviceModelTable.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/virtualMachine/VmHostDeviceModelTable.java @@ -1,29 +1,26 @@ package org.ovirt.engine.ui.webadmin.section.main.view.tab.virtualMachine; import com.google.gwt.event.shared.EventBus; -import com.google.inject.Inject; import org.ovirt.engine.core.common.businessentities.HostDeviceView; import org.ovirt.engine.ui.common.system.ClientStorage; import org.ovirt.engine.ui.common.uicommon.model.SearchableTableModelProvider; import org.ovirt.engine.ui.common.widget.action.UiCommandButtonDefinition; -import org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn; -import org.ovirt.engine.ui.common.widget.uicommon.AbstractModelBoundTableWidget; import org.ovirt.engine.ui.uicommonweb.UICommand; import org.ovirt.engine.ui.uicommonweb.models.vms.hostdev.VmHostDeviceListModel; -import org.ovirt.engine.ui.webadmin.ApplicationConstants; -import org.ovirt.engine.ui.webadmin.gin.AssetProvider; +import org.ovirt.engine.ui.webadmin.section.main.view.tab.host.HostDeviceModelBaseTable; -public class VmHostDeviceModelTable extends AbstractModelBoundTableWidget<HostDeviceView, VmHostDeviceListModel> { +public class VmHostDeviceModelTable extends HostDeviceModelBaseTable<VmHostDeviceListModel> { - private static final ApplicationConstants constants = AssetProvider.getConstants(); - - @Inject - public VmHostDeviceModelTable(SearchableTableModelProvider<HostDeviceView, VmHostDeviceListModel> modelProvider, EventBus eventBus, ClientStorage clientStorage) { - super(modelProvider, eventBus, clientStorage, false); + public VmHostDeviceModelTable( + SearchableTableModelProvider<HostDeviceView, VmHostDeviceListModel> modelProvider, + EventBus eventBus, ClientStorage clientStorage) { + super(modelProvider, eventBus, clientStorage); } @Override public void initTable() { + super.initTable(); + getTable().addActionButton(new UiCommandButtonDefinition<HostDeviceView>(getEventBus(), constants.addVmHostDevice()) { @Override protected UICommand resolveCommand() { @@ -42,55 +39,5 @@ return getModel().getRepinHostCommand(); } }); - - getTable().enableColumnResizing(); - - addColumn(constants.deviceName(), "150px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ - @Override - public String getValue(HostDeviceView object) { - return object.getDeviceName(); - } - }); - addColumn(constants.iommuGroup(), "150px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ - @Override - public String getValue(HostDeviceView object) { - return object.getIommuGroup() == null ? constants.notAvailableLabel() : object.getIommuGroup().toString(); - } - }); - addColumn(constants.capability(), "130px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ - @Override - public String getValue(HostDeviceView object) { - return object.getCapability(); - } - }); - addColumn(constants.productName(), "150px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ - @Override - public String getValue(HostDeviceView object) { - return object.getProductName(); - } - }); - addColumn(constants.productId(), "150px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ - @Override - public String getValue(HostDeviceView object) { - return object.getProductId(); - } - }); - addColumn(constants.vendorName(), "150px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ - @Override - public String getValue(HostDeviceView object) { - return object.getVendorName(); - } - }); - addColumn(constants.vendorId(), "150px", new AbstractTextColumn<HostDeviceView>() { //$NON-NLS-1$ - @Override - public String getValue(HostDeviceView object) { - return object.getVendorId(); - } - }); - } - - private void addColumn(String header, String width, AbstractTextColumn<HostDeviceView> column) { - column.makeSortable(); - getTable().addColumn(column, header, width); } } -- To view, visit https://gerrit.ovirt.org/41830 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I484d0607bb27118058bef08c628c8a3bc8587fc9 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Martin Betak <mbe...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches