/**
 * Appcelerator Titanium Mobile
 * Copyright (c) 2009-2012 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the Apache Public License
 * Please see the LICENSE included with this distribution for details.
 */
package ti.modules.titanium.ui.widget.tabgroup;

import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.proxy.TiWindowProxy;
import org.appcelerator.titanium.view.TiUIView;

import ti.modules.titanium.ui.TabProxy;
import ti.modules.titanium.ui.ViewProxy;
import android.view.View;


public abstract class TiUIAbstractTab extends TiUIView {
	private TiUIView contentView;

	public TiUIAbstractTab(TabProxy proxy) {
		super(proxy);
		proxy.setView(this);
	}

	/**
	 * Called when the selection of this tab has changed.
	 *
	 * @param selected true if the tab is now selected or false if it was unselected.
	 */
	public void onSelectionChange(boolean selected) { }

	/**
	 * Returns the content view for this tab.
	 *
	 * @return the content view or null if the tab is empty
	 */
	public View getContentView() {
		if (contentView == null) {
			TiWindowProxy windowProxy = getWindowProxy();
			if (windowProxy == null) {
				return null;
			}

			ViewProxy contentViewProxy = new ViewProxy();
			contentViewProxy.setActivity(windowProxy.getActivity());
			contentView = contentViewProxy.getOrCreateView();

			// Allow the window to fill the content view with its children.
			windowProxy.getKrollObject().setWindow(contentViewProxy);
		}

		return contentView.getNativeView();
	}

	private TiWindowProxy getWindowProxy() {
		Object windowProxy = proxy.getProperty(TiC.PROPERTY_WINDOW);
		if (windowProxy instanceof TiWindowProxy) {
			return (TiWindowProxy) windowProxy;
		}

		return null;
	}

}

@@ -280,16 +280,64 @@
 group;%0A%0A
+import org.appcelerator.titanium.TiApplication;%0A
 import o
@@ -546,24 +546,55 @@
 .ViewProxy;%0A
+import android.graphics.Color;%0A
 import andro
@@ -1247,27 +1247,223 @@
 ) %7B%0A%09%09%09%09
-return null
+// If no window is provided use an empty view.%0A%09%09%09%09View emptyContent = new View(TiApplication.getInstance().getApplicationContext());%0A%09%09%09%09emptyContent.setBackgroundColor(Color.BLACK);%0A%09%09%09%09return emptyContent
 ;%0A%09%09%09%7D%0A%0A

Use empty view when no tab window is set.