Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » How to add User Defined Property and Named Expression programmatically?
How to add User Defined Property and Named Expression programmatically? [message #1002521] Fri, 18 January 2013 19:02 Go to next message
Aleksey   is currently offline Aleksey Friend
Messages: 42
Registered: April 2012
we are struggling to find the right code using Design Engine API to add User Defined Property and Named Expressions to an element:
DataItemHandle control = (DataItemHandle) elementFactory.newDataItem("COLUMN1");

control.setProperty("MyProperty", "test");
control.setExpressionProperty("MyExpression", new Expression("\"test\"", ExpressionType.JAVASCRIPT));


Both setProperty() and setExpressionProperty() throw exceptions that the property name is invalid. Looks like you have to add it first - I found addUserPropertyDefn() method for simple properties but even after I add the property:
UserPropertyDefn p = new UserPropertyDefn();
p.setType(new StringPropertyType());

control.setProperty("MyProperty", "test"); throws another exception saying that value type is invalid...

And I cannot find any API method that would allow you to add a NamedExpression as opposed to User Defined Property. Could somebody who knows API help with that?

Re: How to add User Defined Property and Named Expression programmatically? [message #1002572 is a reply to message #1002521] Fri, 18 January 2013 21:25 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Try something like:

MetaDataDictionary dd = MetaDataDictionary.getInstance( );
PropertyType strType = dd.getPropertyType( PropertyType.STRING_TYPE );

UserPropertyDefn newPropDefn = new UserPropertyDefn( );
newPropDefn.setName( "myProp4" ); //$NON-NLS-1$
newPropDefn.setType( strType );

PropertyType expType = dd.getPropertyType( PropertyType.EXPRESSION_TYPE );

UserPropertyDefn newNamedDefn = new UserPropertyDefn( );
newNamedDefn.setName( "myNamedExpression" ); //$NON-NLS-1$
newNamedDefn.setType( expType );
Expression expr = new Expression("\"test\"", ExpressionType.JAVASCRIPT);

// Add one new user-defined property definition

table.addUserPropertyDefn( newPropDefn );
table.addUserPropertyDefn( newNamedDefn );

Previous Topic:How to eliminate the outline of a meter chart?
Next Topic:crosstab dimension drilldown
Goto Forum:

Current Time: Fri Nov 27 17:19:45 GMT 2015

Powered by FUDForum. Page generated in 0.01880 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software