Home » Archived » BIRT » Using BIRT APIs
|
Re: Using BIRT APIs [message #653437 is a reply to message #653220] |
Wed, 09 February 2011 18:31 |
|
Neil,
You need the DE API (Design Engine API). There are a lot of examples on
birt-exchange.org that show how to use it. There is also a webinar on
the de api. You may also want to look at the eclipse page:
http://www.eclipse.org/birt/phoenix/deploy/designEngineAPI.p hp
Jason
On 2/8/2011 4:56 PM, Neil Wang wrote:
> Hi,
>
> I would like to utilize BIRT APIs. Is there a document which lists the
> APIs and what they do? I am looking for APIs to remove columns and rows,
> change text color, change font and preview mainly; however, might need
> more later.
>
> please advise
>
> Neil
|
|
| |
Re: Using BIRT APIs [message #654431 is a reply to message #654293] |
Tue, 15 February 2011 18:01 |
|
Neil,
If you just want to drop a detail row you can use the drop method. I am
attaching a test class that shows how to do various things with the de
api. In the example I insert a detail row using the
RowOperationParameters class. Right before I save the design I drop the
added row.
Jason
package DEAPI;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.model.api.CellHandle;
import org.eclipse.birt.report.model.api.ColumnHandle;
import org.eclipse.birt.report.model.api.DataItemHandle;
import org.eclipse.birt.report.model.api.DesignConfig;
import org.eclipse.birt.report.model.api.ElementFactory;
import org.eclipse.birt.report.model.api.IDesignEngine;
import org.eclipse.birt.report.model.api.IDesignEngineFactory;
import org.eclipse.birt.report.model.api.LabelHandle;
import org.eclipse.birt.report.model.api.ImageHandle;
import org.eclipse.birt.report.model.api.ActionHandle;
import org.eclipse.birt.report.model.api.ReportElementHandle;
import org.eclipse.birt.report.model.api.RowOperationParameters;
import org.eclipse.birt.report.model.api.ScalarParameterHandle;
import org.eclipse.birt.report.model.api.ScriptLibHandle;
import org.eclipse.birt.report.model.api.TextItemHandle;
import org.eclipse.birt.report.model.elements.JointDataSet;
import org.eclipse.birt.report.model.api.OdaDataSetHandle;
import org.eclipse.birt.report.model.api.JointDataSetHandle;
import org.eclipse.birt.report.model.api.JoinConditionHandle;
import org.eclipse.birt.report.model.api.OdaDataSourceHandle;
import org.eclipse.birt.report.model.api.PropertyHandle;
import org.eclipse.birt.report.model.api.ReportDesignHandle;
import org.eclipse.birt.report.model.api.RowHandle;
import org.eclipse.birt.report.model.api.SessionHandle;
import org.eclipse.birt.report.model.api.StructureFactory;
import org.eclipse.birt.report.model.api.TableHandle;
import org.eclipse.birt.report.model.api.activity.SemanticException ;
import org.eclipse.birt.report.model.api.elements.structures.Comput edColumn;
import org.eclipse.birt.report.model.api.PropertyHandle;
import org.eclipse.birt.report.model.elements.ReportItem;
import org.eclipse.birt.report.model.api.elements.structures.Embedd edImage;
import org.eclipse.birt.report.model.elements.Style;
import org.eclipse.birt.report.model.elements.ReportDesign;
import org.eclipse.birt.report.model.api.StyleHandle;
import
org.eclipse.birt.report.model.api.elements.structures.Aggreg ationArgument;
import
org.eclipse.birt.report.model.api.elements.structures.DateTi meFormatValue;
import org.eclipse.birt.report.model.api.elements.structures.Format Value;
import org.eclipse.birt.report.model.api.elements.structures.MapRul e;
import org.eclipse.birt.report.model.api.elements.structures.HideRu le;
import
org.eclipse.birt.report.model.api.elements.structures.Proper tyBinding;
import org.eclipse.birt.report.model.api.elements.structures.TOC;
import org.eclipse.birt.report.model.api.elements.structures.JoinCo ndition;
import org.eclipse.birt.report.model.api.elements.structures.ParamB inding;
import org.eclipse.birt.report.model.api.elements.DesignChoiceConst ants;
import org.eclipse.birt.report.model.api.elements.structures.Highli ghtRule;
import org.eclipse.birt.report.model.elements.interfaces.IJointData SetModel;
import org.eclipse.birt.report.model.api.elements.structures.SortKe y;
import org.eclipse.birt.report.model.api.SortKeyHandle;
import
org.eclipse.birt.report.model.api.elements.structures.Filter Condition;
import org.eclipse.birt.report.model.api.elements.structures.Action ;
import org.eclipse.birt.report.model.api.elements.structures.Includ eScript;
import java.util.Iterator;
import com.ibm.icu.util.ULocale;
/**
* Simple BIRT Design Engine API (DEAPI) demo.
*/
public class StructFactoryTest
{
ReportDesignHandle designHandle = null;
ElementFactory designFactory = null;
StructureFactory structFactory = null;
public static void main( String[] args )
{
try
{
StructFactoryTest de = new StructFactoryTest();
de.buildReport();
}
catch ( IOException e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch ( SemanticException e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
void buildDataSource( ) throws SemanticException
{
OdaDataSourceHandle dsHandle = designFactory.newOdaDataSource(
"Data Source", "org.eclipse.birt.report.data.oda.jdbc" );
dsHandle.setProperty( "odaDriverClass",
"org.eclipse.birt.report.data.oda.sampledb.Driver" );
dsHandle.setProperty( "odaURL", "jdbc:classicmodels:sampledb" );
dsHandle.setProperty( "odaUser", "ClassicModels" );
dsHandle.setProperty( "odaPassword", "" );
PropertyBinding pb = new PropertyBinding();
designHandle.getDataSources( ).add( dsHandle );
long currid = dsHandle.getID();
//pb.setName("odaUser");
//pb.setID(currid);
//pb.setValue("params[\"NewParameter\"].value");
//PropertyHandle ph = designHandle.getPropertyHandle("propertyBindings");
//ph.addItem(pb);
}
void buildDataSet( ) throws SemanticException
{
OdaDataSetHandle dsHandle = designFactory.newOdaDataSet( "ds",
"org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
dsHandle.setDataSource( "Data Source" );
String qry = "Select * from customers";
dsHandle.setQueryText( qry );
addFilterCondition( dsHandle );
designHandle.getDataSets( ).add( dsHandle );
}
void buildDataSet2( ) throws SemanticException
{
OdaDataSetHandle dsHandle = designFactory.newOdaDataSet( "ds2",
"org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
dsHandle.setDataSource( "Data Source" );
String qry = "Select * from orderdetails where ordernumber = ?";
dsHandle.setQueryText( qry );
addFilterCondition( dsHandle );
designHandle.getDataSets( ).add( dsHandle );
}
void buildJointDataSet( ) throws SemanticException
{
OdaDataSetHandle dsHandle1 = designFactory.newOdaDataSet( "ds1",
"org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
dsHandle1.setDataSource( "Data Source" );
String qry1 = "Select * from customers";
dsHandle1.setQueryText( qry1 );
OdaDataSetHandle dsHandle2 = designFactory.newOdaDataSet( "ds2",
"org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
dsHandle2.setDataSource( "Data Source" );
String qry2 = "Select * from orders";
dsHandle2.setQueryText( qry2 );
JointDataSetHandle jds = designFactory.newJointDataSet("test");
designHandle.getDataSets( ).add( dsHandle1 );
designHandle.getDataSets( ).add( dsHandle2 );
jds.addDataSet("ds1");
jds.addDataSet("ds2");
String leftExpression = "dataSetRow[\"CUSTOMERNUMBER\"]";
String rightExpression = "dataSetRow[\"CUSTOMERNUMBER\"]";
JoinCondition condition = StructureFactory.createJoinCondition( );
condition.setJoinType( DesignChoiceConstants.JOIN_TYPE_LEFT_OUT );
condition.setOperator( DesignChoiceConstants.JOIN_OPERATOR_EQALS );
condition.setLeftDataSet( "ds1" ); //$NON-NLS-1$
condition.setRightDataSet( "ds2" ); //$NON-NLS-1$
condition.setLeftExpression( leftExpression ); //$NON-NLS-1$
condition.setRightExpression( rightExpression ); //$NON-NLS-1$
PropertyHandle conditionHandle = jds
.getPropertyHandle( JointDataSet.JOIN_CONDITONS_PROP );
conditionHandle.addItem( condition );
designHandle.getDataSets( ).add( jds );
}
void addMapRule(TableHandle th){
try{
MapRule mr = structFactory.createMapRule();
mr.setTestExpression("row[\"CustomerCreditLimit\"]");
mr.setOperator(DesignChoiceConstants.MAP_OPERATOR_EQ);
mr.setValue1("0");
mr.setDisplay("N/A");
PropertyHandle ph = th.getPropertyHandle(StyleHandle.MAP_RULES_PROP);
ph.addItem(mr);
}catch (Exception e){
e.printStackTrace();
}
}
void addVisRule(ReportElementHandle rh){
try{
HideRule hr = structFactory.createHideRule();
hr.setFormat("pdf");
hr.setExpression("true");
PropertyHandle ph = rh.getPropertyHandle(ReportItem.VISIBILITY_PROP);
ph.addItem(hr);
}catch (Exception e){
e.printStackTrace();
}
}
void addBottomBorder(ReportElementHandle rh){
try{
rh.setProperty(StyleHandle.BORDER_BOTTOM_COLOR_PROP, "#000000");
rh.setProperty(StyleHandle.BORDER_BOTTOM_STYLE_PROP, "solid");
rh.setProperty(StyleHandle.BORDER_BOTTOM_WIDTH_PROP, "2px");
}catch (Exception e){
e.printStackTrace();
}
}
void addHighLightRule(RowHandle th){
try{
HighlightRule hr = structFactory.createHighlightRule();
hr.setOperator(DesignChoiceConstants.MAP_OPERATOR_GT);
hr.setTestExpression("row[\"CustomerCreditLimit\"]");
hr.setValue1("100000");
hr.setProperty(HighlightRule.BACKGROUND_COLOR_MEMBER, "blue");
PropertyHandle ph =
th.getPropertyHandle(StyleHandle.HIGHLIGHT_RULES_PROP);
ph.addItem(hr);
}catch (Exception e){
e.printStackTrace();
}
}
void addSortKey(TableHandle th){
try{
SortKey sk = structFactory.createSortKey();
//sk.setKey("row[\"CustomerName\"]");
sk.setDirection(DesignChoiceConstants.SORT_DIRECTION_ASC);
sk.setKey("if( params[\"srt\"].value){ if( params[\"srt\"].value ==
'a' ){ row[\"CustomerName\"]; }else{ row[\"CustomerCity\"];}}");
PropertyHandle ph = th.getPropertyHandle(TableHandle.SORT_PROP);
ph.addItem(sk);
}catch (Exception e){
e.printStackTrace();
}
}
void modSortKey(TableHandle th){
try{
SortKeyHandle sk;
PropertyHandle ph = th.getPropertyHandle(TableHandle.SORT_PROP);
//get number or iterate
sk = (SortKeyHandle)ph.get(0);
sk.setDirection(DesignChoiceConstants.SORT_DIRECTION_DESC);
}catch (Exception e){
e.printStackTrace();
}
}
void addFilterCondition(OdaDataSetHandle dh){
try{
FilterCondition fc = structFactory.createFilterCond();
fc.setExpr("row[\"COUNTRY\"]");
fc.setOperator(DesignChoiceConstants.MAP_OPERATOR_EQ);
fc.setValue1("'USA'");
dh.addFilter(fc);
}catch (Exception e){
e.printStackTrace();
}
}
void addFilterCondition(TableHandle th){
try{
FilterCondition fc = structFactory.createFilterCond();
fc.setExpr("row[\"CustomerCountry\"]");
fc.setOperator(DesignChoiceConstants.MAP_OPERATOR_EQ);
fc.setValue1("'USA'");
PropertyHandle ph = th.getPropertyHandle(TableHandle.FILTER_PROP);
ph.addItem(fc);
}catch (Exception e){
e.printStackTrace();
}
}
void addHyperlink(LabelHandle lh){
try{
Action ac = structFactory.createAction();
ActionHandle actionHandle = lh.setAction( ac );
//actionHandle.setURI("'http://www.google.com'");
actionHandle.setLinkType(DesignChoiceConstants.ACTION_LINK_T YPE_DRILL_THROUGH);
actionHandle.setReportName("c:/test/xyz.rptdesign");
actionHandle.setTargetFileType("report-design");
actionHandle.setTargetWindow("_blank");
actionHandle.getMember("paramBindings");
ParamBinding pb = structFactory.createParamBinding();
pb.setParamName("order");
pb.setExpression("row[\"ORDERNUMBER\"]");
actionHandle.addParamBinding(pb);
/*
<structure name="action">
<property name="linkType">drill-through</property>
<property name="reportName">detail.rptdesign</property>
<property name="targetWindow">_blank</property>
<property name="targetFileType">report-design</property>
<list-property name="paramBindings">
<structure>
<property name="paramName">order</property>
<expression
name="expression">row["ORDERNUMBER"]</expression>
</structure>
</list-property>
</structure>
*/
}catch (Exception e){
e.printStackTrace();
}
}
void addToc(DataItemHandle dh){
try{
TOC myToc = structFactory.createTOC("row[\"CustomerName\"]");
dh.addTOC(myToc);
}catch (Exception e){
e.printStackTrace();
}
}
void addImage(){
try{
EmbeddedImage image = structFactory.createEmbeddedImage( );
image.setType( DesignChoiceConstants.IMAGE_TYPE_IMAGE_JPEG );
image.setData( load( "logo3.jpg" ) );
image.setName( "mylogo" );
designHandle.addImage( image );
}catch (Exception e){
e.printStackTrace();
}
}
public byte[] load( String fileName ) throws IOException
{
InputStream is = null;
is = new BufferedInputStream( this.getClass( ).getResourceAsStream(
fileName ) );
byte data[] = null;
if ( is != null )
{
try
{
data = new byte[is.available( )];
is.read( data );
}
catch ( IOException e1 )
{
throw e1;
}
}
return data;
}
void addScript(ReportDesignHandle rh){
try{
IncludeScript is = structFactory.createIncludeScript();
is.setFileName("test.js");
//PropertyHandle ph =
rh.getPropertyHandle(ReportDesign.INCLUDE_SCRIPTS_PROP);
//ph.addItem(is);
}catch (Exception e){
e.printStackTrace();
}
}
void buildReport() throws IOException, SemanticException
{
DesignConfig config = new DesignConfig( );
config.setBIRTHome("C:/birt/birt-runtime-2_5_1/birt-runtime-2_5_1/ReportEngine ");
IDesignEngine engine = null;
try{
Platform.startup( config );
IDesignEngineFactory factory = (IDesignEngineFactory) Platform
.createFactoryObject(
IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );
engine = factory.createDesignEngine( config );
}catch( Exception ex){
ex.printStackTrace();
}
SessionHandle session = engine.newSessionHandle( ULocale.ENGLISH ) ;
ReportDesignHandle design = null;
try{
//open a design or a template
designHandle = session.createDesign();
addScript( designHandle);
designFactory = designHandle.getElementFactory( );
//designHandle.findScriptLib("name").setName("test2");
//Iterator iter = designHandle.scriptLibsIterator( );
//((ScriptLibHandle) iter.next()).drop() ;
//designHandle.dropScriptLib( lib );
buildDataSource();
buildDataSet();
buildJointDataSet();
TableHandle table = designFactory.newTableItem( "table", 3 );
table.setWidth( "100%" );
table.setDataSet( designHandle.findDataSet( "ds" ) );
// get first row in group header of group 0 .
//RowOperationParameters parameters1 = new RowOperationParameters( 0, 0,
// 0 );
// get second row in group header of group 0.
//RowOperationParameters parameters2 = new RowOperationParameters( 0, 0,
// 1 );
// get second row in table footer.
//RowOperationParameters parameters3 = new RowOperationParameters( 2, -1,
// 1 );
// get first row in table header.
//RowOperationParameters parameters4 = new RowOperationParameters( 0, -1,
// 0 );
// get second row in table detail which contain row span.
//RowOperationParameters parameters5 = new RowOperationParameters( 2, -1,
// 1 );
// get first row in group header of group 1.
//RowOperationParameters parameters6 = new RowOperationParameters( 0, 1,
// 0 );
//second parm has to be -1 unless you are modifying a group
//third parm specifies the row number
//first parm is the slotid
RowOperationParameters ro = new RowOperationParameters(2, -1, 0);
table.insertRow(ro);
PropertyHandle computedSet = table.getColumnBindings( );
ComputedColumn cs1, cs2, cs3, cs4, cs5;
cs1 = StructureFactory.createComputedColumn();
cs1.setName("CustomerName");
cs1.setExpression("dataSetRow[\"CUSTOMERNAME\"]");
computedSet.addItem(cs1);
cs2 = StructureFactory.createComputedColumn();
cs2.setName("CustomerCity");
cs2.setExpression("dataSetRow[\"CITY\"]");
//cs2.setDataType(dataType)
computedSet.addItem(cs2);
cs3 = StructureFactory.createComputedColumn();
cs3.setName("CustomerCountry");
cs3.setExpression("dataSetRow[\"COUNTRY\"]");
computedSet.addItem(cs3);
cs4 = StructureFactory.createComputedColumn();
cs4.setName("CustomerCreditLimit");
cs4.setExpression("dataSetRow[\"CREDITLIMIT\"]");
computedSet.addItem(cs4);
cs5 = StructureFactory.createComputedColumn();
cs5.setName("CustomerCreditLimitSum");
cs5.setExpression("dataSetRow[\"CREDITLIMIT\"]");
cs5.setAggregateFunction("sum");
//cs5.setFilterExpression(expression)
//All or group name
//cs5.setAggregateOn(aggregateOn)
computedSet.addItem(cs5);
// table header
RowHandle tableheader = (RowHandle) table.getHeader( ).get( 0 );
ColumnHandle ch = (ColumnHandle)table.getColumns().get(0);
ch.setProperty("width", "50%");
ColumnHandle ch2 = (ColumnHandle)table.getColumns().get(1);
ch2.setSuppressDuplicates(true);
LabelHandle label1 = designFactory.newLabel("Label1" );
label1.setOnRender("var x = 3;");
addBottomBorder(label1);
label1.setText("Customer");
CellHandle cell = (CellHandle) tableheader.getCells( ).get( 0 );
cell.getContent( ).add( label1 );
LabelHandle label2 = designFactory.newLabel("Label2" );
label2.setText("City");
cell = (CellHandle) tableheader.getCells( ).get( 1 );
cell.getContent( ).add( label2 );
LabelHandle label3 = designFactory.newLabel("Label3" );
label3.setText("Credit Limit");
cell = (CellHandle) tableheader.getCells( ).get( 2 );
cell.getContent( ).add( label3 );
// table detail (second Detail Row)
RowHandle tabledetail = (RowHandle) table.getDetail( ).get( 1 );
cell = (CellHandle) tabledetail.getCells( ).get( 0 );
DataItemHandle data = designFactory.newDataItem( "data1" );
data.setResultSetColumn("CustomerName");
addToc( data );
cell.getContent( ).add( data );
cell = (CellHandle) tabledetail.getCells( ).get( 1 );
data = designFactory.newDataItem( "data2" );
data.setResultSetColumn("CustomerCity");
cell.getContent( ).add( data );
cell = (CellHandle) tabledetail.getCells( ).get( 2 );
data = designFactory.newDataItem( "data3" );
TextItemHandle tih =designFactory.newTextItem("mytextitem");
//tih.setContentType(contentType);
//tih.setContent(value);
data.setResultSetColumn("CustomerCreditLimit");
cell.getContent( ).add( data );
FormatValue fv = structFactory.newFormatValue();
fv.setPattern("#,##0.00{RoundingMode=HALF_UP}");
fv.setCategory("custom");
data.setProperty("numberFormat", fv);
addHyperlink(label1);
addMapRule(table);
addHighLightRule(tabledetail);
addSortKey(table);
modSortKey(table);
addFilterCondition(table);
addImage();
RowHandle tablefooter = (RowHandle) table.getFooter().get( 0 );
cell = (CellHandle) tablefooter.getCells( ).get( 0 );
ImageHandle image1 = designFactory.newImage( "mylogo" );
image1.setImageName( "mylogo" );
//image1.sets
//addVisRule( image1 );
//cell.getContent( ).add( image1 );
cell = (CellHandle) tablefooter.getCells( ).get( 2 );
data = designFactory.newDataItem( "datasum" );
//FormatValue formatValueToSet = new DateTimeFormatValue( );
//formatValueToSet.setPattern( "dd/mm/yy" );
//formatValueToSet.setCategory("Custom");
//data.setProperty( StyleHandle.DATE_TIME_FORMAT_PROP,
// formatValueToSet );
//has to have a style data.getStyle().setDateTimeFormat("dd/mm/yy");
data.setResultSetColumn("CustomerCreditLimitSum");
cell.getContent( ).add( data );
ScalarParameterHandle sph = designFactory.newScalarParameter("srt");
sph.setIsRequired(false);
//sph.setAllowNull(true);
//sph.setAllowBlank(true);
sph.setValueType(DesignChoiceConstants.PARAM_VALUE_TYPE_STAT IC);
sph.setDataType(DesignChoiceConstants.PARAM_TYPE_STRING);
designHandle.getParameters().add(sph);
//delete the row added earlier:
table.getDetail().get(0).drop();
designHandle.getBody( ).add( table );
// Save the design and close it.
designHandle.saveAs("output/desample/structfactorytest.rptdesign " );
designHandle.close( );
Platform.shutdown();
System.out.println("Finished");
}catch (Exception e){
e.printStackTrace();
}
}
}
On 2/14/2011 6:17 PM, Neil Wang wrote:
> Hi Jason,
>
> I would like to start with removing a row.
> I looked through the APIs in org.eclipse.birt.report.model.api and am
> thinking shiftRow() in TableHandle is the method to use. Of course, I
> could be wrong and also am not sure how to initiate a TableHandle.
> Please advise.
>
> Neil
|
|
| |
Re: Using BIRT APIs [message #658438 is a reply to message #658332] |
Tue, 08 March 2011 14:14 |
|
Neil,
I am somewhat confused on how you have BIRT deployed. If the birt
plugins are already part of your app set the birt home to "" and do not
do a platform startup or shutdown. You should still be able to just call:
> IDesignEngineFactory factory = (IDesignEngineFactory) Platform
> .createFactoryObject(
> IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );
> engine = factory.createDesignEngine( config );
To get the design engine.
Jason
On 3/7/2011 5:58 PM, Neil Wang wrote:
> Hi Jason,
>
> Thank you for your comment.
>
> I gave it a try. I am working on this incrementally and the first thing
> I wanted to achieve is to open an existing template and save it to
> somewhere else. This is what I did:
>
> //========================================================== ======
> ReportDesignHandle designHandle = null;
> ElementFactory designFactory = null;
>
> DesignConfig config = new DesignConfig( );
> config.setBIRTHome("C:/birt/birt-runtime-2_5_1/birt-runtime-2_5_1/ReportEngine
> ");
> IDesignEngine engine = null;
> try{
>
>
> Platform.startup( config );
> IDesignEngineFactory factory = (IDesignEngineFactory) Platform
> .createFactoryObject(
> IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );
> engine = factory.createDesignEngine( config );
>
> }catch( Exception ex){
> ex.printStackTrace();
> }
>
>
> SessionHandle session = engine.newSessionHandle( ULocale.ENGLISH ) ;
>
> ReportDesignHandle design = null;
>
>
>
> try{
> //open a design or a template
> designHandle = session.openDesign("PhysicalModel.rptdesign");
>
> designFactory = designHandle.getElementFactory( );
>
> designHandle.saveAs("structfactorytest.rptdesign");
> designHandle.close( );
> Platform.shutdown();
> System.out.println("Finished");
> }catch (Exception e){
> e.printStackTrace();
> }
> //========================================================== ======
>
> I tried to open structfactorytest.rptdesign and this is what I got
> "Could not open the editor: The editor class could not be instantiated.
> This usually indicates a missing no-arg cstructor or that the editor's
> class name was mistyped in plugin.xml"
>
> There is a long stack trace after the message.
>
> I opened both PhysicalModel.rptdesign and structfactorytest.rptdesign to
> compare them to see what the differences are.
>
> There are two types of differences:
> 1.
> in PhysicalModel.rptdesign
> <property name="queryText"></property>
>
> in the same line of structfactorytest.rptdesign
> <xml-property name="queryText"><![CDATA[]]></xml-property>
>
> 2.
> in PhysicalModel.rptdesign
> <property name="displayName">Name</property>
>
> in the same line of structfactorytest.rptdesign
> <text-property name="displayName">Name</text-property>
>
> I replaced <xml-property name="queryText"><![CDATA[]]></xml-property>
> with <property name="queryText"></property> and <text-property
> name="displayName">Name</text-property> with <property
> name="displayName">Name</property> in structfactorytest.rptdesign. The
> template can be opened without error.
> Also, do I have to do this?
> config.setBIRTHome("C:/birt/birt-runtime-2_5_1/birt-runtime-2_5_1/ReportEngine
> ");
>
> I incorporated BIRT with the product I am working on and the product has
> BIRT features and plugins without the standard file structure that comes
> with BIRT runtime (like the BIRT home file structure)
>
> please advise.
>
> Neil
|
|
| | |
Re: Using BIRT APIs [message #659222 is a reply to message #659087] |
Fri, 11 March 2011 14:55 |
|
Neil
I this thread a posted some code on how to drop a detail row, but it did
not show how to locate the table to begin with. There are a couple ways
to do this. One iterate over the contents of the entire report and
examine each table or two name your tables in the general properties for
the table item and then use:
designHandle.findElement("mytable");
where mytable is the name. Make sure to cast it to a TableHandle. To
drop the table just use
designHandle.findElement("mytable").drop();
Jason
On 3/10/2011 5:41 PM, Neil Wang wrote:
> Hi Jason,
>
> I have an existing template which has many nested tables.
> There are two things I am trying to figure out how to do
> 1. how to open a specific table and remove its rows.
> 2. how to remove a specific table.
>
> I have tried googling for the info but have no luck. please advise.
>
> Neil
|
|
| |
Re: Using BIRT APIs [message #660518 is a reply to message #660508] |
Fri, 18 March 2011 19:00 |
|
drop the cells first like:
TableHandle th = (TableHandle)report.findElement("mytable");
RowHandle header = (RowHandle) th.getHeader( ).get( 0 );
header.getCells().get(0).drop();
RowHandle detail1 = (RowHandle) th.getDetail().get( 0 );
detail1.getCells().get(0).drop();
//RowHandle detail2 = (RowHandle) th.getDetail().get( 1 );
//detail2.getCells().get(0).drop();
//RowHandle detail3 = (RowHandle) th.getDetail().get( 2 );
//detail3.getCells().get(0).drop();
//RowHandle footer = (RowHandle) th.getFooter( ).get( 0 );
//footer.getCells().get(0).drop();
th.getColumns().get(0).drop();
0 is the first column btw.
Jason
On 3/18/2011 1:17 PM, Neil Wang wrote:
> Hi Jason,
>
> Thanks you, it works fine.
>
> I am now trying to remove a column from a table and this is what I did.
>
> TableHandle table = (TableHandle)designHandle.findElement("Column");
> table.getColumns().get(1).drop();
>
> When I tried to open the report design, the
> ArrayIndexOutOfBoundsException occurred. Did I drop it the right way? If
> not, please advise on how I should do it.
>
> thanks,
>
> Neil
|
|
| | |
Re: Using BIRT APIs [message #662812 is a reply to message #662782] |
Fri, 01 April 2011 04:09 |
|
Neil,
1 - If you just want to set the color do
tableheader.setProperty(StyleHandle.BACKGROUND_COLOR_PROP, "Blue");
or
tableheader.setProperty(StyleHandle.BACKGROUND_COLOR_PROP, "#FF8080");
2 - Not sure what you want here. Are you needing the fontFamily changed
use:
tableheader.setProperty( StyleHandle.FONT_WEIGHT_PROP,
DesignChoiceConstants.FONT_WEIGHT_BOLD );
tableheader.setProperty( StyleHandle.FONT_FAMILY_PROP, "Century" );
tableheader.setProperty( StyleHandle.FONT_SIZE_PROP, "12pt" );
3 - Do you mean row height or font size?
tableheader.setProperty(ReportItemHandle.HEIGHT_PROP, "1.2in");
4 - What is the context? The Web Viewer is a plugin and you can call
the WebViewer.display method from a RCP/Eclipse based app.
Jason
On 3/31/2011 6:10 PM, Neil Wang wrote:
> Hi Jason,
>
> I have some questions about how to modify the properties
>
> 1. Change the background color of a row
> This is what I did to change the background of a row:
>
> RowHandle tableheader = (RowHandle) table.getHeader().get(0);
> tableheader.getStyle().getBackgroundColor();
>
> I was looking for setBackgroundColor() but didn't find it. Please let me
> know how I can set the color? I would like to use RGB value to set the
> color.
>
> 2. Change the font of a row of text
> This is what I did to change the font of a row of text:
> tableheader.getStyle().setFontStyle(fontStyle)
>
> The java doc shows this:
> Sets the style of the font. The input value is one of constants defined
> in DesignChoiceConstants:
> - FONT_STYLE_NORMAL
> - FONT_STYLE_ITALIC
> - FONT_STYLE_OBLIQUE
>
> There is a lot of different fonts but I can't find them all. Please let
> me know how I can find them.
>
> 3. Change the size of a row of text
> I tried to find the method but couldn't find it. Please advise.
>
> 4. Is it possible to invoke the preview method programmatically; so
> that, preview can be performed on an existing template?
>
> regards,
>
> Neil
|
|
| |
Re: Using BIRT APIs [message #663278 is a reply to message #663006] |
Mon, 04 April 2011 13:51 |
|
Neil,
I believe this will depend on what fonts are installed on your system.
The viewer plugin is org.eclipse.birt.report.viewer.
Jason
On 4/1/2011 7:24 PM, Neil Wang wrote:
> Hi Jason,
>
> Thank you for the comment.
>
> Do you know where I can find all the available values for
> "StyleHandle.FONT_FAMILY_PROP"?
>
> You have it as "Century" in the example.
> tableheader.setProperty( StyleHandle.FONT_FAMILY_PROP, "Century" );
>
> Also, what I am trying to do with preview is that I am adding a wizard
> to modify existing reports. In the wizard, I would like to have a
> preview button. When clicked, it will bring up a window which shows a
> subset of the report. If the Web Viewer is something I should use, can
> you please let me know which plugin has it?
>
> regards,
>
> Neil
|
|
| |
Re: Using BIRT APIs [message #663650 is a reply to message #663412] |
Wed, 06 April 2011 03:07 |
|
Neil,
Can you try something like:
BrowserManager bmg = BrowserManager.getInstance();
bmg.setAlwaysUseExternal(false);
HashMap myparms = new HashMap();
HashMap emitmap = new HashMap();
myparms.put("SERVLET_NAME_KEY", "frameset");
myparms.put("FORMAT_KEY", "html");
//myparms.put("RESOURCE_FOLDER_KEY", "c:/myresources");
myparms.put("ALLOW_PAGE", "false");
myparms.put("SHOW_PARAMETER_PAGE", "false");
//emitmap.put("Top Count", "6");
//myparms.put("EMITTER_OPTIONS_KEY", emitmap);
//myparms.put("MAX_ROWS_KEY", "500");
//WebViewer.display(rpt, browser, myparms);
//WebViewer.display(reportName, browser, myparms);
WebViewer.display(reportName, myparms);
I have commented out some of the options.
Jason
On 4/4/2011 6:16 PM, Neil Wang wrote:
> Hi Jason,
>
> Thank you for your comment. Is there a doc which explains how to use the
> display() method?
>
> I used this one: public static void display(String report, String
> format, boolean allowPage)
>
> This is how I invoked it: WebViewer.display("C:/report.rptdesign",
> WebViewer.HTML, true);
>
> However, I ran into this exception
>
> java.lang.NullPointerException
> at org.eclipse.birt.report.viewer.utilities.AppServerWrapper.ge
> tPort(AppServerWrapper.java:207)
> at org.eclipse.birt.report.viewer.utilities.WebappAccessor.getP
> ort(WebappAccessor.java:162)
> at org.eclipse.birt.report.viewer.utilities.WebViewer.getBaseUR
> L(WebViewer.java:316)
> at org.eclipse.birt.report.viewer.utilities.WebViewer.createURL
> (WebViewer.java:532)
> at org.eclipse.birt.report.viewer.utilities.WebViewer.createURL
> (WebViewer.java:500)
> at org.eclipse.birt.report.viewer.utilities.WebViewer.display(W
> ebViewer.java:907)
> at org.eclipse.birt.report.viewer.utilities.WebViewer.display(W
> ebViewer.java:881)
>
> please advise,
>
> Neil
|
|
| |
Re: Using BIRT APIs [message #664286 is a reply to message #664214] |
Fri, 08 April 2011 08:46 |
|
Neil,
Use MAX_ROWS_KEY:
HashMap myparms = new HashMap();
HashMap emitmap = new HashMap();
myparms.put("SERVLET_NAME_KEY", "frameset");
myparms.put("FORMAT_KEY", "html");
myparms.put("SHOW_PARAMETER_PAGE", "false");
myparms.put(WebViewer.MAX_ROWS_KEY, "5");
WebViewer.display(reportName, browser, myparms);
Jason
On 4/7/2011 4:55 PM, Neil Wang wrote:
> Hi Jason,
>
> Thank you. It works fine.
> Is there a property I can set to limit the number of rows in the report?
>
> please advise,
>
> Neil
|
|
| |
Re: Using BIRT APIs [message #699462 is a reply to message #666696] |
Thu, 21 July 2011 15:20 |
|
Hi guys i have a big problem
i want to make api with birt but does not work, i tried with the exemple api from Birt and i got the following msg.
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/CoreException
at org.eclipse.birt.core.framework.Platform.createPlatformLauncher(Platform.java:115)
at org.eclipse.birt.core.framework.Platform.startup(Platform.java:74)
at DeDemo.buildReport(DeDemo.java:80)
at DeDemo.main(DeDemo.java:43)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.CoreException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 4 more
can u please helpe
|
|
|
Re: Using BIRT APIs [message #699539 is a reply to message #699462] |
Thu, 21 July 2011 17:52 |
|
What are you using to build the app? Eclipse? Is this a command line
app or a Web app? What version of BIRT are you using?
By the look of the error, it seems that you are missing the
reportengine/lib jars from the classpath.
Jason
On 7/21/2011 11:20 AM, richard wrote:
> Hi guys i have a big problem
>
>
> i want to make api with birt but does not work, i tried with the exemple
> api from Birt and i got the following msg.
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/eclipse/core/runtime/CoreException
> at
> org.eclipse.birt.core.framework.Platform.createPlatformLauncher(Platform.java:115)
>
> at org.eclipse.birt.core.framework.Platform.startup(Platform.java:74)
> at DeDemo.buildReport(DeDemo.java:80)
> at DeDemo.main(DeDemo.java:43)
> Caused by: java.lang.ClassNotFoundException:
> org.eclipse.core.runtime.CoreException
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> ... 4 more
>
> can u please helpe
|
|
| | |
Re: Using BIRT APIs [message #699938 is a reply to message #699709] |
Fri, 22 July 2011 14:56 |
|
Richard,
Did you get this to work?
Jason
On 7/22/2011 3:05 AM, richard wrote:
> i read thar the reportengine/lib jars are already on the new BIrt version
>
>
> thanks
>
>
|
|
| |
Goto Forum:
Current Time: Fri Sep 20 11:20:34 GMT 2024
Powered by FUDForum. Page generated in 0.07144 seconds
|