/*******************************************************************************
 * Copyright (c) 2004 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.model.elements;

import org.eclipse.birt.report.model.core.DesignElement;
import org.eclipse.birt.report.model.core.Module;

/**
 * Creates a new template element from a report item or a data set.
 */

public class TemplateFactory
{

	/**
	 * Creates a template element from the given default element.
	 * 
	 * @param module
	 *            the module of the template to insert
	 * @param defaultElement
	 *            the base element
	 * @param name
	 *            name of the created template element
	 * @return the created template element, or <code>null</code> if the
	 *         default element is not a report item or a data set
	 */
	
	public static TemplateElement createTemplate( Module module,
			DesignElement defaultElement, String name )
	{
		assert defaultElement != null;

		if ( defaultElement instanceof ReportItem )
			return new TemplateReportItem( name );
		else if ( defaultElement instanceof DataSet )
		{
			TemplateDataSet template = new TemplateDataSet( name );
			assert module != null;
			module.makeUniqueName( template );
			return template;
		}
		else
		{
			return null;
		}
	}
}

@@ -573,16 +573,74 @@
 ments;%0A%0A
+import org.eclipse.birt.report.model.api.util.StringUtil;%0A
 import o
@@ -1255,17 +1255,16 @@
 et%0A%09 */%0A
-%09
 %0A%09public
@@ -1448,16 +1448,104 @@
 tItem )%0A
+%09%09%7B%0A%09%09%09if ( StringUtil.isBlank( name ) )%0A%09%09%09%09return new TemplateReportItem( );%0A%09%09%09else%0A%09
 %09%09%09retur
@@ -1577,16 +1577,21 @@
  name );
+%0A%0A%09%09%7D
 %0A%09%09else 

Fix 128338 -- trim the empty input name for template element