<commit_before>/**
 * 
 */
package org.concord.framework.otrunk.view;

import javax.swing.JComponent;

import org.concord.framework.otrunk.OTChangeEvent;
import org.concord.framework.otrunk.OTChangeListener;
import org.concord.framework.otrunk.OTControllerService;
import org.concord.framework.otrunk.OTObject;

/**
 * @author scott
 *
 */
public abstract class AbstractOTJComponentView 
	extends AbstractOTView
implements OTJComponentView, OTViewEntryAware, OTViewContainerAware
{
	OTJComponentService jComponentService;
	protected OTViewEntry viewConfig;
	protected OTViewContainer viewContainer;
	private boolean reloadOnViewEntryChange = false;
	private MyOTChangeListener otListener;
	private boolean alreadyAddedListener;
	
	public OTJComponentService getJComponentService()
	{
		// Instead of getting the OTJComponentService directly
		// we will get an intermediate object and then use that
		// get the OTJComponentService for this particular view
		if(jComponentService == null){
			OTJComponentServiceFactory serviceFactory = 
				(OTJComponentServiceFactory)getViewService(OTJComponentServiceFactory.class);
			jComponentService = serviceFactory.createOTJComponentService(getViewFactory());
		}
		
		return jComponentService;
	}
	
	public OTControllerService createControllerService()
	{
		OTControllerServiceFactory controllerServiceFactory = 
			(OTControllerServiceFactory) getViewService(OTControllerServiceFactory.class);
		
    	OTControllerService controllerService = controllerServiceFactory.createControllerService();
    	controllerService.addService(OTViewContext.class, viewContext);

    	return controllerService;
	}
	
	public JComponent getChildComponent(OTObject otObject,
			OTViewContainer container)
	{
		OTJComponentService jComponentService = getJComponentService();
		return jComponentService.getComponent(otObject, container);
	}

	public JComponent getChildComponent(OTObject otObject,
			OTViewContainer container, String mode)
	{
		OTJComponentService jComponentService = getJComponentService();
		OTJComponentView view = jComponentService.getObjectView(otObject, container, mode);
		return jComponentService.getComponent(otObject, view);
	}

	public OTJComponentView getComponentView(OTObject otObject,
			OTViewContainer container, String mode)
	{
		OTJComponentService jComponentService = getJComponentService();
		return jComponentService.getObjectView(otObject, container, mode);<commit_msg>AbstractOTJComponent now has a getChildComponent method that can create a view with a view context passed in. It uses a new method in OTJComponentServide to do this.<commit_after>/**
 * 
 */
package org.concord.framework.otrunk.view;

import javax.swing.JComponent;

import org.concord.framework.otrunk.OTChangeEvent;
import org.concord.framework.otrunk.OTChangeListener;
import org.concord.framework.otrunk.OTControllerService;
import org.concord.framework.otrunk.OTObject;

/**
 * @author scott
 *
 */
public abstract class AbstractOTJComponentView 
	extends AbstractOTView
implements OTJComponentView, OTViewEntryAware, OTViewContainerAware
{
	OTJComponentService jComponentService;
	protected OTViewEntry viewConfig;
	protected OTViewContainer viewContainer;
	private boolean reloadOnViewEntryChange = false;
	private MyOTChangeListener otListener;
	private boolean alreadyAddedListener;
	
	public OTJComponentService getJComponentService()
	{
		// Instead of getting the OTJComponentService directly
		// we will get an intermediate object and then use that
		// get the OTJComponentService for this particular view
		if(jComponentService == null){
			OTJComponentServiceFactory serviceFactory = 
				(OTJComponentServiceFactory)getViewService(OTJComponentServiceFactory.class);
			jComponentService = serviceFactory.createOTJComponentService(getViewFactory());
		}
		
		return jComponentService;
	}
	
	public OTControllerService createControllerService()
	{
		OTControllerServiceFactory controllerServiceFactory = 
			(OTControllerServiceFactory) getViewService(OTControllerServiceFactory.class);
		
    	OTControllerService controllerService = controllerServiceFactory.createControllerService();
    	controllerService.addService(OTViewContext.class, viewContext);

    	return controllerService;
	}
	
	public JComponent getChildComponent(OTObject otObject,
			OTViewContainer container)
	{
		OTJComponentService jComponentService = getJComponentService();
		return jComponentService.getComponent(otObject, container);
	}
	
	public JComponent getChildComponent(OTObject otObject,
		OTViewContainer container, String mode)
    {
    	return getChildComponent(otObject, container, mode, null);
    }

	public JComponent getChildComponent(OTObject otObject,
			OTViewContainer container, String mode, OTViewContext viewContext)
	{
		OTJComponentService jComponentService = getJComponentService();
		OTJComponentView view = jComponentService.getObjectView(otObject, container, mode, null, viewContext);
		return jComponentService.getComponent(otObject, view);
	}

	public OTJComponentView getComponentView(OTObject otObject,
			OTViewContainer container, String mode)
	{
		OTJComponentService jComponentService = getJComponentService();
		return jComponentService.getObjectView(otObject, container, mode);
{'fraction_non_alphanumeric': 0.06428843952689813, 'fraction_numerical': 0.0, 'mean_word_length': 6.384507042253521, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2893035', 'n_tokens_mistral': 1476, 'n_tokens_neox': 1358, 'n_words': 318}