From c07af2ec4030a489402d1c135d1abd3d093a7daf Mon Sep 17 00:00:00 2001 From: buczekp <buczekp> Date: Mon, 8 Mar 2010 17:11:19 +0000 Subject: [PATCH] [LMS-1403] removed unnecessary recreation & relayout of grid with filters SVN: 15069 --- .../ui/grid/AbstractBrowserGrid.java | 21 ++++++++----------- .../ui/grid/AbstractEntityBrowserGrid.java | 5 +++-- .../grid/CustomColumnsMetadataProvider.java | 10 ++++----- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java index ff105ec57f9..ac17125a88c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java @@ -265,7 +265,7 @@ public abstract class AbstractBrowserGrid<T/* Entity */, M extends BaseEntityMod // - hidden paging toolbar contentPanel.syncSize(); // - no 'overflow' button when some buttons don't fit into pagingToolbar - pagingToolbar.syncSize(); // doesn't solve the problem with resize of the window + pagingToolbar.syncSize(); } }); columnListener = new ColumnListener<T, M>(grid); @@ -1008,12 +1008,13 @@ public abstract class AbstractBrowserGrid<T/* Entity */, M extends BaseEntityMod ColumnDefsAndConfigs<T> defsAndConfigs = createColumnsDefinition(); // add custom columns List<GridCustomColumnInfo> customColumnsMetadata = - customColumnsMetadataProvider.tryGetCustomColumnsMetadata(); - List<IColumnDefinitionUI<T>> customColumnsDefs = - createCustomColumnDefinitions(customColumnsMetadata); - defsAndConfigs.addColumns(customColumnsDefs); - if (customColumnsMetadata != null) + customColumnsMetadataProvider.getCustomColumnsMetadata(); + if (customColumnsMetadata.size() > 0) { + List<IColumnDefinitionUI<T>> customColumnsDefs = + createCustomColumnDefinitions(customColumnsMetadata); + defsAndConfigs.addColumns(customColumnsDefs); + RealNumberRenderer renderer = new RealNumberRenderer(viewContext.getDisplaySettingsManager() .getRealNumberFormatingParameters()); @@ -1033,14 +1034,10 @@ public abstract class AbstractBrowserGrid<T/* Entity */, M extends BaseEntityMod } private static <T> List<IColumnDefinitionUI<T>> createCustomColumnDefinitions( - List<GridCustomColumnInfo> customColumnsMetadataOrNull) + List<GridCustomColumnInfo> customColumnsMetadata) { List<IColumnDefinitionUI<T>> defs = new ArrayList<IColumnDefinitionUI<T>>(); - if (customColumnsMetadataOrNull == null) - { - return defs; - } - for (GridCustomColumnInfo columnMetadata : customColumnsMetadataOrNull) + for (GridCustomColumnInfo columnMetadata : customColumnsMetadata) { IColumnDefinitionUI<T> colDef = new GridCustomColumnDefinition<T>(columnMetadata); defs.add(colDef); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractEntityBrowserGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractEntityBrowserGrid.java index 515ff0933e1..8ce76a428a7 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractEntityBrowserGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractEntityBrowserGrid.java @@ -165,13 +165,14 @@ public abstract class AbstractEntityBrowserGrid<T extends IEntityPropertiesHolde Boolean refreshColumnsNeeded = updateCriteria(); if (refreshColumnsNeeded != null && refreshColumnsNeeded.booleanValue()) { + // TODO layout of grid with filters is invoked second time here super.recreateColumnModelAndRefreshColumnsWithFilters(); } } /** - * Updates criteria, returns null if bew criteria are not yet known, otherwise a boolean which - * tells if columns definition changed. + * Updates criteria, returns null if criteria are not yet known, otherwise a boolean which tells + * if columns definition changed. */ private Boolean updateCriteria() { diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/CustomColumnsMetadataProvider.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/CustomColumnsMetadataProvider.java index 08d37cb175e..bec78ec498a 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/CustomColumnsMetadataProvider.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/CustomColumnsMetadataProvider.java @@ -16,6 +16,7 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid; +import java.util.ArrayList; import java.util.List; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.GridCustomColumnInfo; @@ -28,7 +29,8 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.dto.GridCustomColumnIn class CustomColumnsMetadataProvider { // what custom columns are present in the grid. Used to build column definitions. - private List<GridCustomColumnInfo> customColumnsMetadata; + private List<GridCustomColumnInfo> customColumnsMetadata = + new ArrayList<GridCustomColumnInfo>(); // has the last setter call changed the matadata? private boolean hasChanged; @@ -41,16 +43,14 @@ class CustomColumnsMetadataProvider return result; } - public List<GridCustomColumnInfo> tryGetCustomColumnsMetadata() + public List<GridCustomColumnInfo> getCustomColumnsMetadata() { return customColumnsMetadata; } public void setCustomColumnsMetadata(List<GridCustomColumnInfo> customColumnsMetadata) { - this.hasChanged = - (this.customColumnsMetadata == null && customColumnsMetadata != null) - || this.customColumnsMetadata.equals(customColumnsMetadata) == false; + this.hasChanged = this.customColumnsMetadata.equals(customColumnsMetadata) == false; this.customColumnsMetadata = customColumnsMetadata; } } -- GitLab