/**
 * 
 */
package org.concord.otrunk.view;

import javax.swing.JComponent;

import org.concord.framework.otrunk.OTObject;
import org.concord.framework.otrunk.view.AbstractOTJComponentView;
import org.concord.framework.otrunk.view.OTViewEntry;

/**
 * @author scott
 *
 */
public abstract class AbstractOTJComponentContainerView extends AbstractOTJComponentView
{
	private OTJComponentContainerHelper containerHelper;
	protected String myMode;

	/**
	 * @see org.concord.framework.otrunk.view.OTJComponentView#viewClosed()
	 */
	public void viewClosed()
	{
		super.viewClosed();
		removeAllSubViews();
	}
	
	public void setMode(String mode){
		myMode = mode;
	}
	
	public String getMode(){
		return myMode;
	}

	protected OTViewContainerPanel createViewContainerPanel()
    {
	    return getContainerHelper().createViewContainerPanel();
    }

	public JComponent createSubViewComponent(OTObject otObject)
	{
		return createSubViewComponent(otObject, false);
	}
	
	public JComponent createSubViewComponent(OTObject otObject, boolean useScrollPane)
	{
		return createSubViewComponent(otObject, useScrollPane, null);
	}
	
	public JComponent createSubViewComponent(OTObject otObject, boolean useScrollPane, 
		OTViewEntry viewEntry)
	{
		OTViewContainerPanel otObjectPanel = createViewContainerPanel();
		otObjectPanel.setUseScrollPane(useScrollPane);
		
		// The OTViewContainerPanel automatically handles the OTViewChild object
		otObjectPanel.setCurrentObject(otObject, viewEntry);
		
		// set parent of new viewcontainer to this viewcontainer
		otObjectPanel.setParentContainer(viewContainer);
		return otObjectPanel;
	}
	
	protected void removeAllSubViews()
    {
		if(containerHelper != null){
			containerHelper.removeAllSubViews();
		}
    }

	protected OTJComponentContainerHelper getContainerHelper()
	{
		if(containerHelper == null){
			containerHelper = new OTJComponentContainerHelper(getFrameManager(),
					getJComponentService(), getMode());

		}
		return containerHelper;
	}

	protected void setSubViewAutoRequestFocus(boolean autoRequestFocus)
    {
		getContainerHelper().setAutoRequestFocus(autoRequestFocus);
    }

	protected void setSubViewUseScrollPane(boolean useScrollPane)
    {
		getContainerHelper().setUseScrollPane(useScrollPane);
    }

	protected void setSubViewMode(String viewMode)
    {
		getContainerHelper().setViewMode(viewMode);
    }
}

@@ -1226,16 +1226,242 @@
 try)%0A%09%7B%0A
+%09%09return createSubViewComponent(otObject, useScrollPane, viewEntry, false);%0A%09%7D%0A%09%0A%09public JComponent createSubViewComponent(OTObject otObject, boolean useScrollPane, %0A%09%09%09OTViewEntry viewEntry, boolean isTopLevelContainer)%0A%09%09%7B%0A%09
 %09%09OTView
@@ -1519,16 +1519,17 @@
 anel();%0A
+%09
 %09%09otObje
@@ -1567,25 +1567,87 @@
 ollPane);%0A%09%09
-%0A
+%09otObjectPanel.setTopLevelContainer(isTopLevelContainer);%0A%09%09%09%0A%09
 %09%09// The OTV
@@ -1711,16 +1711,17 @@
 bject%0A%09%09
+%09
 otObject
@@ -1767,19 +1767,21 @@
 try);%0A%09%09
+%09
 %0A%09%09
+%09
 // set p
@@ -1829,16 +1829,17 @@
 ntainer%0A
+%09
 %09%09otObje
@@ -1883,16 +1883,17 @@
 ner);%0A%09%09
+%09
 return o
@@ -1906,16 +1906,17 @@
 tPanel;%0A
+%09
 %09%7D%0A%09%0A%09pr

Add a createSubViewComponent method that allows containerPanel to be top level