if ( slotID == Module.COMPONENT_SLOT )
if ( slotID == IModuleModel.COMPONENT_SLOT )
	private void doReplace( DesignElement oldElement, DesignElement newElement,			int slotID, boolean unresolveReference ) throws SemanticException	{		assert newElement.getContainer( ) == null;		// Ensure that the new element can be put into the container.		ElementDefn metaData = (ElementDefn) element.getDefn( );		if ( !metaData.isContainer( ) )			throw new ContentException( element, slotID,					ContentException.DESIGN_EXCEPTION_NOT_CONTAINER );		SlotDefn slotInfo = (SlotDefn) metaData.getSlot( slotID );		if ( slotInfo == null )			throw new ContentException( element, slotID,					ContentException.DESIGN_EXCEPTION_SLOT_NOT_FOUND );		if ( !slotInfo.canContain( newElement ) )			throw new ContentException( element, slotID, newElement,					ContentException.DESIGN_EXCEPTION_WRONG_TYPE );		// This element is already the content of the element to add.		if ( element.isContentOf( newElement ) )			throw new ContentException( element, slotID, newElement,					ContentException.DESIGN_EXCEPTION_RECURSIVE );		if ( slotID == Module.COMPONENT_SLOT )		{			if ( StringUtil.isBlank( newElement.getName( ) ) )				throw new ContentException( element, slotID, newElement,						ContentException.DESIGN_EXCEPTION_CONTENT_NAME_REQUIRED );		}		// do some checks about the element to be replaced		ContainerSlot slot = element.getSlot( slotID );		if ( !slot.contains( oldElement ) )			throw new ContentException( element, slotID, oldElement,					ContentException.DESIGN_EXCEPTION_CONTENT_NOT_FOUND );		// do all checks about the transformation state		if ( oldElement instanceof TemplateElement )		{			if ( !oldElement.canDrop( )					|| !oldElement.isTemplateParameterValue( module )					|| !newElement.getDefn( ).isKindOf(							( (TemplateElement) oldElement ).getDefaultElement(									module ).getDefn( ) ) )				throw new TemplateException(						oldElement,						TemplateException.DESIGN_EXCEPTION_REVERT_TO_TEMPLATE_FORBIDDEN );		}		else		{			if ( !oldElement.canTransformToTemplate( module )					|| !( newElement instanceof TemplateElement ) )				throw new ContentException(						element,						slotID,						ContentException.DESIGN_EXCEPTION_TEMPLATE_TRANSFORM_FORBIDDEN );		}		// if the old element is in component slot of report design and it has		// children, then the operation is forbidden.		if ( hasDescendents( oldElement, slotID ) )		{			throw new ContentException( oldElement, slotID,					ContentException.DESIGN_EXCEPTION_HAS_DESCENDENTS );		}		// Prepare the transaction.		ContentReplaceRecord replaceRecord = new TemplateTransformRecord(				module, element, slotID, oldElement, newElement );		ActivityStack stack = getActivityStack( );		stack.startFilterEventTrans( replaceRecord.getLabel( ) );		try		{			doDelectAction( oldElement, unresolveReference );			// do some checks about the template issues			TemplateCommand cmd = new TemplateCommand( module, element );			cmd.checkAdd( newElement, slotID );			// Remove the element itself.			stack.execute( replaceRecord );			addElementNames( newElement );		}		catch ( ContentException e )		{			stack.rollback( );			throw e;		}		catch ( NameException e )		{			stack.rollback( );			throw e;		}		catch ( SemanticException e )		{			stack.rollback( );			throw e;		}		stack.commit( );	}