Skip to content

Commit

Permalink
Applying column configuration and reset to factory should reload table
Browse files Browse the repository at this point in the history
reload table data
  • Loading branch information
ralph-steiner committed Aug 21, 2023
1 parent 0f4b601 commit 25793db
Showing 1 changed file with 41 additions and 55 deletions.
@@ -1,11 +1,12 @@
/*
* Copyright (c) 2010, 2023 BSI Business Systems Integration AG
* Copyright (c) 2010-2023 BSI Business Systems Integration AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v10.html
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
* Contributors:
* BSI Business Systems Integration AG - initial API and implementation
*/
package org.eclipse.scout.rt.client.ui.basic.table.organizer;

Expand Down Expand Up @@ -39,7 +40,6 @@
import org.eclipse.scout.rt.client.ui.basic.table.columns.AbstractStringColumn;
import org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn;
import org.eclipse.scout.rt.client.ui.basic.table.columns.INumberColumn;
import org.eclipse.scout.rt.client.ui.basic.table.customizer.ITableCustomizer;
import org.eclipse.scout.rt.client.ui.basic.table.organizer.OrganizeColumnsForm.MainBox.GroupBox;
import org.eclipse.scout.rt.client.ui.basic.table.organizer.OrganizeColumnsForm.MainBox.GroupBox.ColumnsGroupBox.ColumnsTableField;
import org.eclipse.scout.rt.client.ui.basic.table.organizer.OrganizeColumnsForm.MainBox.GroupBox.ColumnsGroupBox.ColumnsTableField.Table;
Expand Down Expand Up @@ -451,12 +451,10 @@ protected void execAction() {
}
else {
String configName = getConfigNameColumn().getSelectedValue();
applyAll(configName);
getColumnsTableField().reloadTableData();
applyConfig(configName);
}
getTable().deselectAllEnabledRows();
}

}

protected boolean isOnlyCustomConfigsSelected() {
Expand Down Expand Up @@ -746,9 +744,7 @@ protected void execRowsChecked(Collection<? extends ITableRow> rows) {
if (isFormLoading()) {
return;
}
for (ITableRow row : rows) {
setColumnVisible(row, row.isChecked());
}
updateColumnVisibilityAndOrder();
}

@Override
Expand Down Expand Up @@ -1496,12 +1492,6 @@ public void updateColumnVisibilityAndOrder() {
ClientUIPreferences.getInstance().setAllTableColumnPreferences(m_organizedTable);
}

public void setColumnVisible(ITableRow row, Boolean visible) {
getColumnsTableField().getTable().checkRow(row, visible);

updateColumnVisibilityAndOrder();
}

public void moveUp(ITableRow row) {
moveUp(row, row.getRowIndex() - 1);
}
Expand Down Expand Up @@ -1604,55 +1594,51 @@ public void deleteConfig(String config) {
}
}

public void applyAll(String configName) {
applyViewForConfig(configName);
m_organizedTable.getColumnSet().applySortingAndGrouping(configName);
}

public void applyViewForConfig(String configName) {
ClientUIPreferences prefs = ClientUIPreferences.getInstance();
if (isCustomizable()) {
byte[] tableCustomizerData = prefs.getTableCustomizerData(m_organizedTable.getTableCustomizer(), configName);
if (tableCustomizerData != null) {
m_organizedTable.getTableCustomizer().removeAllColumns();
m_organizedTable.getTableCustomizer().setSerializedData(tableCustomizerData);
}
if (m_organizedTable.getReloadHandler() != null) {
m_organizedTable.resetColumnConfiguration();
m_organizedTable.getReloadHandler().reload(IReloadReason.ORGANIZE_COLUMNS);
}
}
for (IColumn<?> col : m_organizedTable.getColumnSet().getColumns()) {
col.setVisible(prefs.getTableColumnVisible(col, col.isInitialVisible(), configName));
col.setWidth(prefs.getTableColumnWidth(col, col.getInitialWidth(), configName));
col.setVisibleColumnIndexHint(prefs.getTableColumnViewIndex(col, col.getInitialSortIndex(), configName));
if (col instanceof INumberColumn) {
((INumberColumn) col).setBackgroundEffect(prefs.getTableColumnBackgroundEffect(col, ((INumberColumn) col).getInitialBackgroundEffect(), configName));
}
public void resetAll() {
m_organizedTable.reset(false);
if (isCustomizable() && m_organizedTable.getReloadHandler() != null) {
m_organizedTable.getReloadHandler().reload(IReloadReason.ORGANIZE_COLUMNS);
}
getColumnsTableField().reloadTableData();
}

public void resetAll() {
m_organizedTable.reset(false);
public void applyConfig(String configName) {
applyConfigImpl(configName);
if (isCustomizable() && m_organizedTable.getReloadHandler() != null) {
m_organizedTable.getReloadHandler().reload(IReloadReason.ORGANIZE_COLUMNS);
}
getColumnsTableField().reloadTableData();
}

public void resetView() {
protected void applyConfigImpl(String configName) {
try {
m_organizedTable.setTableChanging(true);
//
m_organizedTable.resetColumnVisibilities();
m_organizedTable.resetColumnWidths();
m_organizedTable.resetColumnOrder();
ITableCustomizer cst = m_organizedTable.getTableCustomizer();
if (cst != null) {
cst.removeAllColumns();

ClientUIPreferences prefs = ClientUIPreferences.getInstance();
if (isCustomizable()) {
byte[] tableCustomizerData = prefs.getTableCustomizerData(m_organizedTable.getTableCustomizer(), configName);
if (tableCustomizerData != null) {
m_organizedTable.getTableCustomizer().removeAllColumns();
m_organizedTable.getTableCustomizer().setSerializedData(tableCustomizerData);
}
if (m_organizedTable.getReloadHandler() != null) {
m_organizedTable.resetColumnConfiguration();
}
}
for (IColumn<?> col : m_organizedTable.getColumnSet().getColumns()) {
col.setVisible(prefs.getTableColumnVisible(col, col.isInitialVisible(), configName));
col.setWidth(prefs.getTableColumnWidth(col, col.getInitialWidth(), configName));
col.setVisibleColumnIndexHint(prefs.getTableColumnViewIndex(col, col.getInitialSortIndex(), configName));
if (col instanceof INumberColumn) {
((INumberColumn) col).setBackgroundEffect(prefs.getTableColumnBackgroundEffect(col, ((INumberColumn) col).getInitialBackgroundEffect(), configName));
}
}

m_organizedTable.getColumnSet().applySortingAndGrouping(configName);
}
finally {
m_organizedTable.setTableChanging(false);
}
getColumnsTableField().reloadTableData();
}

protected boolean isColumnMovableUp(IColumn<?> column) {
Expand Down

0 comments on commit 25793db

Please sign in to comment.