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

import java.util.ArrayList;

import org.concord.framework.otrunk.view.OTFrameManager;
import org.concord.framework.otrunk.view.OTJComponentService;
import org.concord.framework.otrunk.view.OTViewContainer;

/**
 * @author scott
 *
 */
public class OTJComponentContainerHelper
{
	private ArrayList<OTViewContainerPanel> viewContainerPanels = 
		new ArrayList<OTViewContainerPanel>();
	private OTFrameManager frameManager;
	private String viewMode;
	private boolean useScrollPane = false;
	private boolean autoRequestFocus = false;
	private OTJComponentService jComponentService;
	private OTViewContainer parentContainer;
	
	public OTJComponentContainerHelper(OTFrameManager frameManager,
	                                   OTJComponentService jComponentService,
	                                   String viewMode)
	{
		this.frameManager = frameManager;
		this.viewMode = viewMode;
		this.jComponentService = jComponentService;		
	}
	                                   
	
	public void removeAllSubViews()
	{
		for(OTViewContainerPanel panel: viewContainerPanels){
			panel.setCurrentObject(null);
		}
		viewContainerPanels.clear();
	}
	
	public OTViewContainerPanel createViewContainerPanel()
	{
		OTViewContainerPanel viewContainerPanel = 
        	new OTViewContainerPanel(frameManager);
		viewContainerPanel.setOTJComponentService(jComponentService);
        viewContainerPanel.setAutoRequestFocus(autoRequestFocus);
        viewContainerPanel.setUseScrollPane(useScrollPane);
        viewContainerPanel.setOpaque(false);
        viewContainerPanel.setViewMode(viewMode);
        viewContainerPanel.setParentContainer(this.parentContainer); 
        viewContainerPanels.add(viewContainerPanel);
        return viewContainerPanel;
	}


	public boolean isAutoRequestFocus()
    {
    	return autoRequestFocus;
    }


	public void setAutoRequestFocus(boolean autoRequestFocus)
    {
    	this.autoRequestFocus = autoRequestFocus;
    }


	public boolean isUseScrollPane()
    {
    	return useScrollPane;
    }


	public void setUseScrollPane(boolean useScrollPane)
    {
    	this.useScrollPane = useScrollPane;
    }


	public String getViewMode()
    {
    	return viewMode;
    }


	public void setViewMode(String viewMode)
    {
    	this.viewMode = viewMode;
    }


	public void setParentContainer(OTViewContainer parentContainer)
    {
	    this.parentContainer = parentContainer;
    }


	public OTViewContainer getParentContainer()
    {
	    return parentContainer;
    }

	
}

@@ -1282,19 +1282,514 @@
 el =
- %0A        %09
+%0A%09%09    createViewContainerPanel(frameManager, jComponentService, autoRequestFocus,%0A%09%09        useScrollPane, viewMode, this.parentContainer);%0A%09%09viewContainerPanels.add(viewContainerPanel);%0A%09%09return viewContainerPanel;%0A%09%7D%0A%0A%09public static OTViewContainerPanel createViewContainerPanel(OTFrameManager frameManager,%0A%09    OTJComponentService jComponentService, boolean autoRequestFocus, boolean useScrollPane,%0A%09    String viewMode, OTViewContainer parentContainer)%0A%09%7B%0A%09%09OTViewContainerPanel viewContainerPanel = 
 new 
@@ -1884,32 +1884,26 @@
 ntService);%0A
-        
+%09%09
 viewContaine
@@ -1948,24 +1948,18 @@
 Focus);%0A
-        
+%09%09
 viewCont
@@ -1998,32 +1998,26 @@
 crollPane);%0A
-        
+%09%09
 viewContaine
@@ -2037,32 +2037,26 @@
 que(false);%0A
-        
+%09%09
 viewContaine
@@ -2085,24 +2085,18 @@
 wMode);%0A
-        
+%09%09
 viewCont
@@ -2125,21 +2125,16 @@
 ntainer(
-this.
 parentCo
@@ -2146,71 +2146,11 @@
 er);
- %0A        viewContainerPanels.add(viewContainerPanel);%0A        
+%0A%09%09
 retu

create a static version of createViewContainerPanel, which may be used by a class that already has the view services required