Home » Archived » BIRT » How to set dataset programmatically in Chart dialog at
How to set dataset programmatically in Chart dialog at [message #85123] |
Fri, 28 October 2005 02:43  |
Eclipse User |
|
|
|
Originally posted by: jigar.rasalawala.patni.com
Hi All,
How to set dataset programmatically in Chart dialog at runtime?
We have integrated Chart dialog(BIRT Chart customization dialog) in our RCP
application. Our application provides Eclipse based view plug-in to display
generated chart from SWT table.
It also provides facility to customize chart through BIRT built-in chart
customization dialog.
We follow following sequences to invoke chart dialog:
- Generate chart from available SWT table using BIRT API.
- Invoke chart dialog by creating instance of ChartDlg (new
org.eclipse.birt.chart.ui.swt.ChartDlg(chart, iUIServiceProvider, null)).
We are able to display chart dialog with all available UI sheets
successfully, except following UI sheets, where it throws exception, as
dataset is not set for the same.
- Data
- Attributes -> Series
Can anyone help us to resolve the said problem?
We use BIRT 2.0M1 release with IBM Eclipse 3.1.
We would like to thank in advance.
Regards
BIRT users
|
|
|
Re: How to set dataset programmatically in Chart dialog at [message #85430 is a reply to message #85123] |
Fri, 28 October 2005 11:17   |
Eclipse User |
|
|
|
Originally posted by: mpadhye.actuate.com
Hi Jigar,
The Data sheet in the chart builder is closely tied into the
BIRT designer. It will not work outside of BIRT. At the same time, if
you need to specify the data properties for your application, you need
to provide the DataSheet UI for your application.
If you look at the source for the DataSheet, it is not located
with the other sheets in birt.chart.ui.extension. This class is located
instead in the 'org.eclipse.birt.chart.reportitem' plug-in. This plug-in
acts as a separation layer between the chart library and BIRT-specific
code. You will need to use this mechanism to register your own
implementation of the UI for datasets.
If you plan to use BIRT datasets and have access to BIRT report related
structures via the API, you can re-use this class in your own plug-in.
You may look into the 'org.eclipse.birt.chart.reportitem.ui' package for
the implementation as it works in BIRT and modify it for your
environment. Among the things that will need to change in your call, the
third argument in the ChartDlg constructor is a 'context' object that
will differ based on the application context. In BIRT, this context is
actually the ExtendedItemHandle representing the chart. You will need to
pass this into the builder. This context can then be accessed in the
data sheet by overriding the 'setUIServiceProvider()' method...which is
called before the UI is displayed...with the IUIServiceProvider AND
context instances that were passed to the builder.
Hope this helps.
Also, for version 2, we are working on a new revamped and easier to use
builder. This will allow most existing extensions to work without any
change. You can find more information about this at the BIRT wiki:
http://www.eclipse.org/birt/wiki/index.php?n=BPS.BPS15
Finally, I cannot help with the other exception in the Series
attributes sheet without a stack trace or some indication of the error
that occurs. Can you provide a trace that I can look at?
Thanks,
Milind
Jigar Rasalawala wrote:
> Hi All,
>
> How to set dataset programmatically in Chart dialog at runtime?
>
> We have integrated Chart dialog(BIRT Chart customization dialog) in our RCP
> application. Our application provides Eclipse based view plug-in to display
> generated chart from SWT table.
>
> It also provides facility to customize chart through BIRT built-in chart
> customization dialog.
>
> We follow following sequences to invoke chart dialog:
> - Generate chart from available SWT table using BIRT API.
> - Invoke chart dialog by creating instance of ChartDlg (new
> org.eclipse.birt.chart.ui.swt.ChartDlg(chart, iUIServiceProvider, null)).
>
> We are able to display chart dialog with all available UI sheets
> successfully, except following UI sheets, where it throws exception, as
> dataset is not set for the same.
>
> - Data
> - Attributes -> Series
>
> Can anyone help us to resolve the said problem?
>
> We use BIRT 2.0M1 release with IBM Eclipse 3.1.
>
> We would like to thank in advance.
>
> Regards
> BIRT users
>
>
|
|
|
Re: How to set dataset programmatically in Chart dialog at [message #87341 is a reply to message #85430] |
Fri, 04 November 2005 00:57  |
Eclipse User |
|
|
|
Originally posted by: jigar.rasalawala.patni.com
Hi Milind,
Thanks for your valuable answer.
We can now able to access Data/Series sheets with Expression Builder using
following BIRT api.
public static void invokeChartBuilder(){
Collection cTypes = UIExtensionsImpl.instance(
).getUIChartTypeExtensions( );
Iterator iterTypes = cTypes.iterator( );
Chart chart = null;
while ( iterTypes.hasNext( ) ){
IChartType type = (IChartType) iterTypes.next( );
if(type instanceof BarChart){
chart = type.getModel("Side-by-side", Orientation.VERTICAL_LITERAL,
BarChart.TWO_DIMENSION_TYPE, null);
break;
}
}
SessionHandleAdapter session = SessionHandleAdapter.getInstance( );
FileInputStream fin = new FileInputStream("c:\\Empty.rptdesign");
session.init(null, fin);
ReportDesignHandle design = (ReportDesignHandle)
session.getReportDesignHandle();
design.setProperty("units", "in");
DataSetManager.setCurrentInstance( DataSetManager.newInstance( ) );
ElementFactory factory = design.getElementFactory( );
OdaDataSourceHandle dataSourceHandle = createFlatFileDataSource(design,
factory);
OdaDataSetHandle dataSetHandle = createFlatFileDataSet(design, factory);
IBaseDataSetDesign dataSetDesign = ModelDteApiAdapter.getInstance(
).createDataSetDesign( dataSetHandle );
IBaseDataSourceDesign dataSourceDesign = ModelDteApiAdapter.getInstance(
).createDataSourceDesign( dataSourceHandle );
DataEngine dataEngine = DataSetManager.getCurrentInstance().getEngine();
dataEngine.defineDataSource( dataSourceDesign );
dataEngine.defineDataSet( dataSetDesign );
ExtendedItemHandle eih = factory.newExtendedItem(null, "Chart");
IReportItem item = eih.getReportItem();
ChartReportItemImpl crii = ( (ChartReportItemImpl) item );
crii.setProperty("chart.instance", chart);
eih.setDataSet(dataSetHandle);
eih.setProperty("height", "250pt");
eih.setProperty("width", "400pt");
eih.setProperty(ExtendedItemHandle.DATA_SET_PROP, "Data Set");
design.getBody().add(eih);
IReportItemBuilderUI builder = ExtensionPointManager.getInstance( )
.getExtendedElementPoint( eih.getExtensionName( ) )
.getReportItemBuilderUI( );
if ( builder != null ){
if ( builder.open( eih ) == Window.CANCEL ){
System.out.println("Cancel Clicked");
}
}
item = eih.getReportItem();
crii = ( (ChartReportItemImpl) item );
chart = (Chart) crii.getProperty("chart.instance");
graphView.getGraphPaintListener().setChart(chart);
graphView.getGraphCanvas().redraw();
design.saveAs( "c:\\sample.rptdesign" );
System.out.println("File created successfully.");
}
private OdaDataSourceHandle createFlatFileDataSource(ReportDesignHandle
reportDesignHandle, ElementFactory elementFactory) throws
SemanticException {
OdaDataSourceHandle dataSourceHandle =
elementFactory.newOdaDataSource("Data Source",
DesignerConstants.DATA_SOURCE_FLATFILE);
dataSourceHandle.setProperty("HOME", "E:\\TEMP");
dataSourceHandle.setProperty("CHARSET", "UTF-8");
dataSourceHandle.setProperty("INCLTYPELINE", "YES");
reportDesignHandle.getDataSources().add(dataSourceHandle);
return dataSourceHandle;
}
private OdaDataSetHandle createFlatFileDataSet(ReportDesignHandle
reportDesignHandle, ElementFactory elementFactory) throws
SemanticException {
OdaDataSetHandle dataSetHandle = elementFactory.newOdaDataSet("Data Set",
"org.eclipse.birt.report.data.oda.flatfile.dataSet");
dataSetHandle.setDataSource("Data Source");
dataSetHandle.setQueryText("select * from Book1.csv");
reportDesignHandle.getDataSets().add(dataSetHandle);
return dataSetHandle;
}
This code generates proper rptdesign file, which displays proper graph in
preview tab provided by Report Designer.
but when we try to render chart in GraphView at runtime, getting following
exception.
Stacktrace:
java.lang.IllegalArgumentException: Source value can not be null
at
org.eclipse.birt.chart.event.PrimitiveRenderEvent.setSourceO bject(PrimitiveRenderEvent.java:278)
at
org.eclipse.birt.chart.event.EventObjectCache.getEventObject (EventObjectCache.java:97)
at
org.eclipse.birt.chart.factory.RunTimeContext.notifyStructur eChange(RunTimeContext.java:157)
at
org.eclipse.birt.chart.render.AxesRenderer.renderPlot(AxesRe nderer.java:1771)
at
org.eclipse.birt.chart.render.AxesRenderer.render(AxesRender er.java:182)
at org.eclipse.birt.chart.factory.Generator.render(Generator.ja va:543)
at
ibsgraphs.graph.listener.GraphPaintListener.paintControl(Gra phPaintListener.java:119)
at
org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:83)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:867)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:852)
at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:11 53)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3090 )
at org.eclipse.swt.widgets.Display.windowProc(Display.java:3706 )
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:16 56)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2711)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1699)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:367)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:143)
at net.ibs.ui.client.IBSJavaClient.run(IBSJavaClient.java:29)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:226)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:376)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:163)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
at org.eclipse.core.launcher.Main.run(Main.java:973)
at org.eclipse.core.launcher.Main.main(Main.java:948)
After debuging BIRT code, we found that there is some problem with DataSet.
Can you please suggest us whether we are in right direction?
Any comments to resolve above mentioned problem.
Thanks in Advance.
|
|
|
Goto Forum:
Current Time: Thu May 08 18:05:47 EDT 2025
Powered by FUDForum. Page generated in 0.04223 seconds
|