Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » 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
ivkina Mising name is currently offline ivkina Mising nameFriend
Messages: 44
Registered: April 2012
Member
hello,
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.setResultSetColumn("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.setName("MyProperty");
p.setType(new StringPropertyType());
control.addUserPropertyDefn(p);

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?

Thanks,
Alexey
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);
newNamedDefn.setDefault(expr);



// Add one new user-defined property definition

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

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


Current Time: Thu Apr 25 09:10:53 GMT 2024

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

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

Back to the top