for (int i = 0; i < outerReportControllerHolder.getComponentCount(); i++)
{
final Component maybeSplitPane = outerReportControllerHolder.getComponent(i);
if (maybeSplitPane instanceof JSplitPane)
{
final JSplitPane splitPane = (JSplitPane) maybeSplitPane;
reportControllerSliderSize = splitPane.getDividerLocation();
break;
}
}
if (newReportController == null)
{
if (reportControllerComponent != null)
{
// thats relatively easy.
outerReportControllerHolder.removeAll();
outerReportControllerHolder.add(toolbarHolder, BorderLayout.NORTH);
outerReportControllerHolder.add(reportPaneScrollPane, BorderLayout.CENTER);
reportControllerComponent = null;
reportControllerInner = false;
reportControllerLocation = null;
}
}
else
{
final JComponent rcp = newReportController.getControlPanel();
if (rcp == null)
{
if (reportControllerComponent != null)
{
outerReportControllerHolder.removeAll();
outerReportControllerHolder.add(toolbarHolder, BorderLayout.NORTH);
outerReportControllerHolder.add(reportPaneScrollPane, BorderLayout.CENTER);
reportControllerComponent = null;
reportControllerInner = false;
reportControllerLocation = null;
}
}
else if (reportControllerComponent != rcp ||
reportControllerInner != newReportController.isInnerComponent() ||
ObjectUtilities.equal(reportControllerLocation, newReportController.getControllerLocation()) == false)
{
// if either the controller component or its position (inner vs outer)
// and border-position has changed, then refresh ..
this.reportControllerLocation = newReportController.getControllerLocation();
this.reportControllerInner = newReportController.isInnerComponent();
this.reportControllerComponent = newReportController.getControlPanel();
outerReportControllerHolder.removeAll();
if (reportControllerInner)
{
final JSplitPane innerHolder = new JSplitPane();
innerHolder.setOpaque(false);
if (BorderLayout.SOUTH.equals(reportControllerLocation))
{
innerHolder.setOrientation(JSplitPane.VERTICAL_SPLIT);
innerHolder.setTopComponent(reportPaneScrollPane);
innerHolder.setBottomComponent(reportControllerComponent);
}
else if (BorderLayout.EAST.equals(reportControllerLocation))
{
innerHolder.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
innerHolder.setLeftComponent(reportPaneScrollPane);
innerHolder.setRightComponent(reportControllerComponent);
}
else if (BorderLayout.WEST.equals(reportControllerLocation))
{
innerHolder.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
innerHolder.setRightComponent(reportPaneScrollPane);
innerHolder.setLeftComponent(reportControllerComponent);
}
else // if (BorderLayout.NORTH.equals(reportControllerLocation))
{
innerHolder.setOrientation(JSplitPane.VERTICAL_SPLIT);
innerHolder.setBottomComponent(reportPaneScrollPane);
innerHolder.setTopComponent(reportControllerComponent);
}
if (reportControllerSliderSize > 0)
{
innerHolder.setDividerLocation(reportControllerSliderSize);
}
outerReportControllerHolder.add(toolbarHolder, BorderLayout.NORTH);
outerReportControllerHolder.add(innerHolder, BorderLayout.CENTER);
}
else
{
final JPanel reportPaneHolder = new JPanel();
reportPaneHolder.setOpaque(false);
reportPaneHolder.setLayout(new BorderLayout());
reportPaneHolder.add(toolbarHolder, BorderLayout.NORTH);
reportPaneHolder.add(reportPaneScrollPane, BorderLayout.CENTER);
final JSplitPane innerHolder = new JSplitPane();
if (BorderLayout.SOUTH.equals(reportControllerLocation))
{
innerHolder.setOrientation(JSplitPane.VERTICAL_SPLIT);
innerHolder.setTopComponent(reportPaneHolder);
innerHolder.setBottomComponent(reportControllerComponent);
}
else if (BorderLayout.EAST.equals(reportControllerLocation))
{
innerHolder.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
innerHolder.setLeftComponent(reportPaneHolder);
innerHolder.setRightComponent(reportControllerComponent);
}
else if (BorderLayout.WEST.equals(reportControllerLocation))
{
innerHolder.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
innerHolder.setRightComponent(reportPaneHolder);
innerHolder.setLeftComponent(reportControllerComponent);
}
else // if (BorderLayout.NORTH.equals(reportControllerLocation))
{
innerHolder.setOrientation(JSplitPane.VERTICAL_SPLIT);
innerHolder.setBottomComponent(reportPaneHolder);
innerHolder.setTopComponent(reportControllerComponent);
}
if (reportControllerSliderSize > 0)
{
innerHolder.setDividerLocation(reportControllerSliderSize);
}
outerReportControllerHolder.add(innerHolder, BorderLayout.CENTER);
}
}
}