[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.birt] Re: ChartWizard exception after creation

Maybe you could make a copy of the chart before serializing it? If the data 
is not too big, and the serialize not too frequent, that should be ok. 
Please enter your comment in the bug, this is an interesting use case.

Thanks,

David

"zero kelvin" <zerokelvin@xxxxxxx> wrote in message 
news:e1lm22$1pg$1@xxxxxxxxxxxxxxxxxxxx
> Thank u for the quick answers.
>
> Actually the bug report makes a different suggestion...
> I only suggested that when serializing the chart, that the runtime data 
> should not be removed from the model, but I didn't mean to serialize it. 
> Thats what I meant with "transient", which, in Java serializing, causes 
> that a variable marked as transient is not serialized.
> I didn't actually mean the runtime data to be serialized because I don't 
> really need it serialized.
>
> Anyway, Im pretty stuck now on how to resolve the issue...
>
> David Michonneau schrieb:
>> There is already a bug that requested that feature (serialized data): 
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=128208
>>
>> Right now, it seems technically a difficult thing to do, but we will 
>> investigate to find a possible solution.
>>
>> Regarding your scenario, I think this is mostly a user interaction issue. 
>> If the user hasn't specified the data correctly (here missing X series), 
>> there is no way to render it, so the question really boils down on how to 
>> inform the user about it.
>>
>> Thanks,
>>
>> David
>>
>> "zero kelvin" <zerokelvin@xxxxxxx> wrote in message 
>> news:443E42A6.5060809@xxxxxxxxxx
>>
>>>I am using the chart wizard standalone.
>>>What I do is open the wizard, then the Runtime series is automatically 
>>>bound to the chart. So I can also show it on a canvas.
>>>But when I serialize the chart, which can happen pretty often in my 
>>>application, then the serializerImpl removes the runtime series from the 
>>>chart.
>>>As I didnt know how to bind that runtime series again, I just took a 
>>>snippet of code from the chartwizard source where it does the data 
>>>binding (using my IDataServiceProvider implementation).
>>>So I can bind the Data again before I am generating the chart output. But 
>>>that binddata does throw an exception if the series definition is 
>>>missing. (see exception below)
>>>Either way, if I would try to use the generator after the chart has been 
>>>serialized, without using my binddata function, I would get a different 
>>>error because the runtime data would be missing.
>>>Isn't it possible to mark the runtime data as "transient" in EMF (so it 
>>>is not serialized) so that when serializing the chart the runtime data 
>>>does not have to be removed? I dont have any clue how EMF works, so sorry 
>>>if the question was stupid.
>>>Thank u for ur suggestions.
>>>
>>>This is my binddata method (and the exception is below):
>>>
>>>-----------------------------------------------------------------------
>>>
>>>// binds the runtime Data to the chart...
>>>// this must be called after serializing/deserializing the model
>>>public void bindData() throws ChartException
>>>{
>>>if ((context.getDataServiceProvider() == null) || (context.getModel() == 
>>>null)) throw new RuntimeException( new ChartException( ChartUIPlugin.ID,
>>>ChartException.DATA_BINDING,"Chart or DataProvider not Specified" ) ); 
>>>//$NON-NLS-1$
>>>
>>>
>>>final List expressions;
>>>final Object[] columnData;
>>>expressions = Generator.instance( ).getRowExpressions( 
>>>context.getModel(), null );
>>>columnData = context.getDataServiceProvider().getDataForColumns( 
>>>(String[]) expressions.toArray( new String[0] ),
>>>-1,
>>>false );
>>>
>>>final Map map = new HashMap( );
>>>for ( int i = 0; i < expressions.size( ); i++ )
>>>{
>>>map.put( expressions.get( i ), columnData[i] );
>>>}
>>>IDataRowExpressionEvaluator evaluator = new 
>>>DataRowExpressionEvaluatorAdapter( ) {
>>>
>>>private int i;
>>>private Object[] column;
>>>
>>>public Object evaluate( String expression )
>>>{
>>>column = (Object[]) map.get( expression );
>>>if ( i >= column.length )
>>>{
>>>throw new RuntimeException( new ChartException( ChartUIPlugin.ID,
>>>ChartException.DATA_SET,
>>>Messages.getString( "ChartUIUtil.Exception.NoValueReturned" ) ) ); 
>>>//$NON-NLS-1$
>>>}
>>>return column[i];
>>>}
>>>
>>>public boolean first( )
>>>{
>>>i = 0;
>>>
>>>if ( map.size( ) > 0 )
>>>{
>>>column = (Object[]) map.values( ).iterator( ).next( );
>>>
>>>if ( column != null && i <= column.length - 1 )
>>>{
>>>return true;
>>>}
>>>}
>>>
>>>return false;
>>>}
>>>
>>>public boolean next( )
>>>{
>>>if ( column != null && i < column.length - 1 )
>>>{
>>>i++;
>>>return true;
>>>}
>>>return false;
>>>}
>>>
>>>public void close( )
>>>{
>>>// no-op
>>>}
>>>};
>>>
>>>RunTimeContext rtcontext = new RunTimeContext( );
>>>rtcontext.setLocale( Locale.getDefault( ) );
>>>Generator.instance().bindData( evaluator, context.getModel(), 
>>>rtcontext );
>>>
>>>}
>>>
>>>
>>>--------------------------------------------------------------------
>>>
>>>The Exception:
>>>
>>>
>>>org.eclipse.birt.chart.exception.ChartException: Found 0 data 
>>>definition(s) associated with the X series expression. Only one X series 
>>>data definition is supported.
>>>at 
>>>org.eclipse.birt.chart.internal.factory.DataProcessor.getRowExpressions(DataProcessor.java:456)
>>>at 
>>>org.eclipse.birt.chart.internal.factory.DataProcessor.getRowExpressions(DataProcessor.java:237)
>>>at 
>>>org.eclipse.birt.chart.factory.Generator.getRowExpressions(Generator.java:489)
>>>at 
>>>de.lmu.semper.sim.ui.editors.SemperChart.bindData(SemperChart.java:199)
>>>at 
>>>de.lmu.semper.sim.ui.editors.ChartViewerSWT.paintControl(ChartViewerSWT.java:89)
>>>at 
>>>org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.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:1153)
>>>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:1656)
>>>at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2711)
>>>at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699)
>>>at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
>>>at 
>>>org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367)
>>>at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
>>>at 
>>>org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103)
>>>at 
>>>org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
>>>at 
>>>org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
>>>at 
>>>org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.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)
>>>
>>>-----------------------------------------------------------------------------
>>>
>>>David Michonneau wrote:
>>>
>>>>Are you using the chart wizard as standalone or in the report designer?
>>>>Normally in the report designer, you get a warning if the chart is
>>>>incomplete before it closes. In that case, it would still use sample
>>>
>>>data in
>>>
>>>>the chart to enable the chart rendering. Can you give an example and the
>>>>exception with its stack trace?
>>>>
>>>>Thanks,
>>>>
>>>>David
>>>>
>>>>"zero kelvin" <zerokelvin@xxxxxxx> wrote in message
>>>>news:e1k6ao$d1l$1@xxxxxxxxxxxxxxxxxxxx
>>>>
>>>>
>>>>>Using the chart wizard it is possible to create charts that are not
>>>>>finished (e.g. missing series definition)
>>>>>This leads to errors in my applications.
>>>>>Does anyone know a way to prevent the wizard from finishing when the
>>>
>>>chart
>>>
>>>>>is not finished?
>>>>>Or is it possible to check if the chart is finished without needing to
>>>>>build it with the generator (which leads to an exception)?
>>>>>thx
>>>>
>>>>
>>>>
>>