MetaDataDictionary dd = MetaDataDictionary.getInstance( ); ExtensionElementDefn extDefn = (ExtensionElementDefn) dd .getExtension( extensionName ); if ( extDefn == null ) return null;  if ( !( extDefn instanceof PeerExtensionElementDefn ) ) throw new IllegalOperationException( "Only report item extension can be created through this method." );  String defaultName = name;  if ( module instanceof Library && StringUtil.isBlank( defaultName ) ) { PeerExtensionElementDefn peerDefn = (PeerExtensionElementDefn) extDefn; IReportItemFactory peerFactory = peerDefn.getReportItemFactory( );  assert peerFactory != null;  IMessages msgs = peerFactory.getMessages( ); if ( msgs == null ) throw new IllegalArgumentException( "The name parameter must not be empty since report item extension doesn't provides default extension element name." );  String extensionDefaultName = msgs.getMessage( (String) extDefn .getDisplayNameKey( ), ThreadResources.getLocale( ) );  if ( extensionDefaultName == null ) throw new IllegalArgumentException( "The name parameter must not be empty since report item extension doesn't provides default extension element name." );  defaultName = ModelMessages .getMessage( MessageConstants.NAME_PREFIX_NEW_MESSAGE );  defaultName = defaultName + extensionDefaultName; }  ExtendedItem element = new ExtendedItem( defaultName ); element.setProperty( ExtendedItem.EXTENSION_NAME_PROP, extensionName ); module.makeUniqueName( element ); ExtendedItemHandle handle = element.handle( module );
	public ExtendedItemHandle newExtendedItem( String name, String extensionName )	{		MetaDataDictionary dd = MetaDataDictionary.getInstance( );		ExtensionElementDefn extDefn = (ExtensionElementDefn) dd				.getExtension( extensionName );		if ( extDefn == null )			return null;		if ( !( extDefn instanceof PeerExtensionElementDefn ) )			throw new IllegalOperationException(					"Only report item extension can be created through this method." ); //$NON-NLS-1$		String defaultName = name;		if ( module instanceof Library && StringUtil.isBlank( defaultName ) )		{			PeerExtensionElementDefn peerDefn = (PeerExtensionElementDefn) extDefn;			IReportItemFactory peerFactory = peerDefn.getReportItemFactory( );			assert peerFactory != null;			IMessages msgs = peerFactory.getMessages( );			if ( msgs == null )				throw new IllegalArgumentException(						"The name parameter must not be empty since report item extension doesn't provides default extension element name." ); //$NON-NLS-1$			String extensionDefaultName = msgs.getMessage( (String) extDefn					.getDisplayNameKey( ), ThreadResources.getLocale( ) );			if ( extensionDefaultName == null )				throw new IllegalArgumentException(						"The name parameter must not be empty since report item extension doesn't provides default extension element name." ); //$NON-NLS-1$			defaultName = ModelMessages					.getMessage( MessageConstants.NAME_PREFIX_NEW_MESSAGE );			defaultName = defaultName + extensionDefaultName;		}		ExtendedItem element = new ExtendedItem( defaultName );		element.setProperty( ExtendedItem.EXTENSION_NAME_PROP, extensionName );		module.makeUniqueName( element );		ExtendedItemHandle handle = element.handle( module );		try		{			handle.loadExtendedElement( );		}		catch ( ExtendedElementException e )		{			// It's impossible to fail when deserializing.			assert false;		}		return handle;	}