file Create dynamically properties into a stereotype

2 weeks 9 hours ago #6530 by joset
Hi,

I'm trying to create properties inside a stereotype but cant manage to make it work. Below my code that is not running:

public PropertyDefinition createStereotypeProperty ( Stereotype st, String propName, PropertyType propType )
{
if ( st == null ) return ( null );
if ( isNullOrEmptyString ( propName ) ) return ( null );
if ( propType == null ) return ( null );
if ( getStereotypeProperty( st, propName ) != null ) return ( null );
IModelingSession ms = getModelingSession();
ITransaction t = ms.createTransaction("transaction");
IUmlModel um = ms.getModel();

PropertyTableDefinition ptd = st.getDefinedTable();
if ( ptd == null )
{
ptd = ( PropertyTableDefinition ) um.createElement(PropertyTableDefinition.MQNAME );
st.setDefinedTable ( ptd );
}
PropertyDefinition pd = ( PropertyDefinition ) um.createElement( PropertyDefinition.MQNAME );
pd.setName( "Nom" );
pd.setBaseType ( PropertyBaseType.STRING );
ptd.getOwned().add( 0, pd );

t.commit ();
t.close ();
}

Please Log in or Create an account to join the conversation.

Moderators: tmachmaab
Time to create page: 0.032 seconds
^ Back to Top