From 796fc9e6ec0efe2358bf68cbad55f7859e097c81 Mon Sep 17 00:00:00 2001 From: buczekp <buczekp> Date: Tue, 6 Jul 2010 16:47:50 +0000 Subject: [PATCH] [LMS-1600] dispose sections on detach of sections panel (fixes problem with filters not working after changing visibility of a section) SVN: 16901 --- .../application/DisposableSectionPanel.java | 3 +- .../application/SingleSectionPanel.java | 48 +++++++++++++++++++ .../application/ui/widget/SectionsPanel.java | 13 +++++ .../application/dataset/DataViewSection.java | 2 +- 4 files changed, 63 insertions(+), 3 deletions(-) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/DisposableSectionPanel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/DisposableSectionPanel.java index c64dafe8351..b7983d86357 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/DisposableSectionPanel.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/DisposableSectionPanel.java @@ -46,13 +46,12 @@ abstract public class DisposableSectionPanel extends SingleSectionPanel } @Override - protected void onDetach() + protected void disposeComponents() { if (disposableComponentOrNull != null) { disposableComponentOrNull.dispose(); } - super.onDetach(); } @Override diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/SingleSectionPanel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/SingleSectionPanel.java index 2179dee3c9e..7f720857ebe 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/SingleSectionPanel.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/SingleSectionPanel.java @@ -41,6 +41,13 @@ abstract public class SingleSectionPanel extends ContentPanel private boolean isContentVisible = false; + /** + * whether additional components created for this section (e.g. browsers) should be automatically + * disposed (for sections that can temporarily removed from container as in + * {@link SectionsPanel} it should be turned off until detach from the container) + */ + private boolean autoDisposeComponents = true; + public SingleSectionPanel(final String header, IViewContext<?> viewContext) { this.viewContext = viewContext; @@ -82,4 +89,45 @@ abstract public class SingleSectionPanel extends ContentPanel isContentVisible = true; } } + + public boolean isContentVisible() + { + return isContentVisible; + } + + public void enableAutoDisposeComponents() + { + setAutoDisposeComponents(true); + } + + public void disableAutoDisposeComponents() + { + setAutoDisposeComponents(false); + } + + protected boolean isAutoDisposeComponents() + { + return autoDisposeComponents; + } + + private void setAutoDisposeComponents(boolean autoDisposeComponent) + { + this.autoDisposeComponents = autoDisposeComponent; + } + + @Override + protected void onDetach() + { + if (isAutoDisposeComponents()) + { + disposeComponents(); + } + super.onDetach(); + } + + /** disposes components created for the section (by default does nothing) */ + protected void disposeComponents() + { + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/SectionsPanel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/SectionsPanel.java index b1ed415dfa2..a1b955aa17c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/SectionsPanel.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/SectionsPanel.java @@ -145,11 +145,24 @@ public class SectionsPanel extends ContentPanel refreshLayout(); } }); + // sections will be disposed when section panel is removed, not when they are hidden + // (see onDetach()) + panel.disableAutoDisposeComponents(); elements.add(element); addToToolbar(element.getButton()); updateElementVisibility(element); } + @Override + protected void onDetach() + { + for (SectionElement el : elements) + { + el.getPanel().enableAutoDisposeComponents(); + } + super.onDetach(); + } + /** removes all sections and adds them once again with with refreshed state */ private void refreshLayout() { diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/dataset/DataViewSection.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/dataset/DataViewSection.java index a53c1d790e8..8f26cb4d6e7 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/dataset/DataViewSection.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/dataset/DataViewSection.java @@ -73,7 +73,7 @@ public class DataViewSection extends SingleSectionPanel } @Override - protected void onDetach() + protected void disposeComponents() { disposeCurrentReport(); } -- GitLab