Alexander Wels has uploaded a new change for review. Change subject: userportal,webadmin: Multi view table columns inconsitent ......................................................................
userportal,webadmin: Multi view table columns inconsitent - since a463914769e87b5fb55999bcd25d56167b8e3d16 columns available in all view would not get removed and would always end up at the front of the grid even if other columns that can disappear were in front of them. This patch fixes that problem. Change-Id: I143894af611f8364da943433e81378690adcb0e8 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1157215 Signed-off-by: Alexander Wels <aw...@redhat.com> --- M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/ColumnResizeCellTable.java 1 file changed, 16 insertions(+), 18 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/46/35146/1 diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/ColumnResizeCellTable.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/ColumnResizeCellTable.java index b751c04..505a4a2 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/ColumnResizeCellTable.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/resize/ColumnResizeCellTable.java @@ -2,7 +2,9 @@ import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.ovirt.engine.ui.common.CommonApplicationTemplates; import org.ovirt.engine.ui.common.system.ClientStorage; @@ -44,6 +46,8 @@ // Prefix for keys used to store widths of individual columns private static final String GRID_COLUMN_WIDTH_PREFIX = "GridColumnWidth"; //$NON-NLS-1$ + //This is 1px instead of 0px as 0 size columns seem to confuse the cell table. + private static final String HIDDEN_WIDTH = "1px"; //$NON-NLS-1$ // Empty, no-width column used with resizable columns feature // that occupies remaining horizontal space within the table @@ -63,6 +67,8 @@ private final List<Column<T, ?>> initializedColumns = new ArrayList<Column<T, ?>>(); private final CommonApplicationTemplates templates = GWT.create(CommonApplicationTemplates.class); + + private final Map<Integer, Boolean> columnVisibleMap = new HashMap<Integer, Boolean>(); public ColumnResizeCellTable() { super(); @@ -228,18 +234,19 @@ * @param width The width of the column. */ public void ensureColumnPresent(Column<T, ?> column, String headerText, boolean present, String width) { - boolean columnPresent = getColumnIndex(column) != -1; - if (present && !columnPresent) { + Integer index = getColumnIndex(column); + boolean columnPresent = index != -1; + if (!columnPresent) { // Add the column if (width == null) { addColumnWithHtmlHeader(column, headerText); } else { addColumnWithHtmlHeader(column, headerText, width); } - } else if (!present && columnPresent) { - // Remove the column - removeColumn(column); + index = getColumnIndex(column); } + columnVisibleMap.put(index, present); + setColumnWidth(column, width); } @Override @@ -251,21 +258,12 @@ } initializedColumns.add(column); } + Integer index = getColumnIndex(column); + if (columnVisibleMap.get(index) != null && !columnVisibleMap.get(index)) { + width = HIDDEN_WIDTH; + } super.setColumnWidth(column, width); - - if (columnResizingEnabled) { - int columnIndex = getColumnIndex(column); - TableElement tableElement = getElement().cast(); - - // Update body and header cell widths - for (TableCellElement cell : getTableBodyCells(tableElement, columnIndex)) { - cell.getStyle().setProperty("width", width); //$NON-NLS-1$ - } - for (TableCellElement cell : getTableHeaderCells(tableElement, columnIndex)) { - cell.getStyle().setProperty("width", width); //$NON-NLS-1$ - } - } } List<TableCellElement> getTableBodyCells(TableElement tableElement, int columnIndex) { -- To view, visit http://gerrit.ovirt.org/35146 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I143894af611f8364da943433e81378690adcb0e8 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alexander Wels <aw...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches