Skip to content
Snippets Groups Projects
Commit 796fc9e6 authored by buczekp's avatar buczekp
Browse files

[LMS-1600] dispose sections on detach of sections panel (fixes problem with...

[LMS-1600] dispose sections on detach of sections panel (fixes problem with filters not working after changing visibility of a section)

SVN: 16901
parent 8860a971
No related branches found
No related tags found
No related merge requests found
...@@ -46,13 +46,12 @@ abstract public class DisposableSectionPanel extends SingleSectionPanel ...@@ -46,13 +46,12 @@ abstract public class DisposableSectionPanel extends SingleSectionPanel
} }
@Override @Override
protected void onDetach() protected void disposeComponents()
{ {
if (disposableComponentOrNull != null) if (disposableComponentOrNull != null)
{ {
disposableComponentOrNull.dispose(); disposableComponentOrNull.dispose();
} }
super.onDetach();
} }
@Override @Override
......
...@@ -41,6 +41,13 @@ abstract public class SingleSectionPanel extends ContentPanel ...@@ -41,6 +41,13 @@ abstract public class SingleSectionPanel extends ContentPanel
private boolean isContentVisible = false; 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) public SingleSectionPanel(final String header, IViewContext<?> viewContext)
{ {
this.viewContext = viewContext; this.viewContext = viewContext;
...@@ -82,4 +89,45 @@ abstract public class SingleSectionPanel extends ContentPanel ...@@ -82,4 +89,45 @@ abstract public class SingleSectionPanel extends ContentPanel
isContentVisible = true; 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()
{
}
} }
...@@ -145,11 +145,24 @@ public class SectionsPanel extends ContentPanel ...@@ -145,11 +145,24 @@ public class SectionsPanel extends ContentPanel
refreshLayout(); refreshLayout();
} }
}); });
// sections will be disposed when section panel is removed, not when they are hidden
// (see onDetach())
panel.disableAutoDisposeComponents();
elements.add(element); elements.add(element);
addToToolbar(element.getButton()); addToToolbar(element.getButton());
updateElementVisibility(element); 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 */ /** removes all sections and adds them once again with with refreshed state */
private void refreshLayout() private void refreshLayout()
{ {
......
...@@ -73,7 +73,7 @@ public class DataViewSection extends SingleSectionPanel ...@@ -73,7 +73,7 @@ public class DataViewSection extends SingleSectionPanel
} }
@Override @Override
protected void onDetach() protected void disposeComponents()
{ {
disposeCurrentReport(); disposeCurrentReport();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment