KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > birt > chart > examples > builder > DefaultDataServiceProviderImpl


1 /***********************************************************************
2  * Copyright (c) 2004 Actuate Corporation.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * Actuate Corporation - initial API and implementation
10  ***********************************************************************/

11
12 package org.eclipse.birt.chart.examples.builder;
13
14 import java.util.ArrayList JavaDoc;
15 import java.util.List JavaDoc;
16
17 import org.eclipse.birt.chart.ui.swt.interfaces.IDataServiceProvider;
18
19 /**
20  * Provides a basic implementation for simulated data service. Used in launcher.
21  *
22  */

23 public class DefaultDataServiceProviderImpl implements IDataServiceProvider
24 {
25
26     private transient String JavaDoc sDataSetName = "Dummy DataSet"; //$NON-NLS-1$
27
private static final int COLUMN_COUNT = 8;
28     private static final int ROW_COUNT = 6;
29
30     /*
31      * (non-Javadoc)
32      *
33      * @see org.eclipse.birt.chart.ui.interfaces.IDataServiceProvider#getAllDataSets()
34      */

35     public String JavaDoc[] getAllDataSets( )
36     {
37         // TODO Auto-generated method stub
38
return new String JavaDoc[]{
39             "Dummy DataSet" //$NON-NLS-1$
40
};
41     }
42
43     /*
44      * (non-Javadoc)
45      *
46      * @see org.eclipse.birt.chart.ui.interfaces.IDataServiceProvider#getCurrentDataSet()
47      */

48     public String JavaDoc getBoundDataSet( )
49     {
50         // TODO Auto-generated method stub
51
return sDataSetName;
52     }
53
54     public String JavaDoc getReportDataSet( )
55     {
56         return null;
57     }
58
59     /*
60      * (non-Javadoc)
61      *
62      * @see org.eclipse.birt.chart.ui.interfaces.IDataServiceProvider#getPreviewHeader(java.lang.String)
63      */

64     public String JavaDoc[] getPreviewHeader( )
65     {
66         String JavaDoc[] columns = new String JavaDoc[COLUMN_COUNT];
67         for ( int i = 0; i < columns.length; i++ )
68         {
69             columns[i] = "DB Col " + ( i + 1 ); //$NON-NLS-1$
70
}
71         return columns;
72     }
73
74     /*
75      * (non-Javadoc)
76      *
77      * @see org.eclipse.birt.chart.ui.interfaces.IDataServiceProvider#getPreviewData(java.lang.String)
78      */

79     public List JavaDoc getPreviewData( )
80     {
81         List JavaDoc list = new ArrayList JavaDoc( );
82         for ( int rowNum = 0; rowNum < ROW_COUNT; rowNum++ )
83         {
84             String JavaDoc[] columns = new String JavaDoc[COLUMN_COUNT];
85             for ( int i = 0; i < columns.length; i++ )
86             {
87                 columns[i] = String.valueOf( ( rowNum + 1 ) * ( i + 1 ) );
88             }
89             list.add( columns );
90         }
91         return list;
92     }
93
94     /*
95      * (non-Javadoc)
96      *
97      * @see org.eclipse.birt.chart.ui.interfaces.IDataServiceProvider#setContext(java.lang.Object)
98      */

99     public void setContext( Object JavaDoc context )
100     {
101         // this.context = context;
102
}
103
104     /*
105      * (non-Javadoc)
106      *
107      * @see org.eclipse.birt.chart.ui.interfaces.IDataServiceProvider#setDataSet(java.lang.String)
108      */

109     public void setDataSet( String JavaDoc datasetName )
110     {
111         // TODO Auto-generated method stub
112
this.sDataSetName = datasetName;
113     }
114
115     /*
116      * (non-Javadoc)
117      *
118      * @see org.eclipse.birt.chart.ui.interfaces.IDataServiceProvider#invoke(java.lang.String)
119      */

120     public int invoke( int command )
121     {
122         return 1;// Window.CANCEL;
123

124     }
125
126     /*
127      * (non-Javadoc)
128      *
129      * @see org.eclipse.birt.chart.ui.interfaces.IDataServiceProvider#getAllStyles()
130      */

131     public String JavaDoc[] getAllStyles( )
132     {
133         return new String JavaDoc[]{};
134     }
135
136     public String JavaDoc[] getAllStyleDisplayNames( )
137     {
138         return getAllStyles( );
139     }
140
141     /*
142      * (non-Javadoc)
143      *
144      * @see org.eclipse.birt.chart.ui.interfaces.IDataServiceProvider#getCurrentStyle()
145      */

146     public String JavaDoc getCurrentStyle( )
147     {
148         return null;
149     }
150
151     /*
152      * (non-Javadoc)
153      *
154      * @see org.eclipse.birt.chart.ui.interfaces.IDataServiceProvider#setStyle(java.lang.String)
155      */

156     public void setStyle( String JavaDoc styleName )
157     {
158         // TODO Auto-generated method stub
159
}
160
161     public Object JavaDoc[] getDataForColumns( String JavaDoc[] sExpressions, int iMaxRecords,
162             boolean byRow )
163     {
164         // Always provide data by column
165
byRow = false;
166         Object JavaDoc[] array = new Object JavaDoc[sExpressions.length];
167         for ( int i = 0; i < sExpressions.length; i++ )// a column
168
{
169             Object JavaDoc[] innerArray = new Object JavaDoc[ROW_COUNT];// a row
170
for ( int j = 0; j < ROW_COUNT; j++ )
171             {
172                 String JavaDoc str = sExpressions[i];
173                 int intStart = str.lastIndexOf( ' ' ) + 1;
174                 int index = Integer.valueOf( str.substring( intStart,
175                         intStart + 1 ) ).intValue( ) - 1;
176                 innerArray[j] = new Integer JavaDoc( ( (String JavaDoc[]) getPreviewData( ).get( j ) )[index] );
177             }
178             array[i] = innerArray;
179         }
180         return array;
181     }
182
183     public void dispose( )
184     {
185         // TODO Auto-generated method stub
186

187     }
188
189     public boolean isLivePreviewEnabled( )
190     {
191         return true;
192     }
193
194     public boolean isInvokingSupported( )
195     {
196         return false;
197     }
198
199     /*
200      * (non-Javadoc)
201      *
202      * @see org.eclipse.birt.chart.ui.swt.interfaces.IDataServiceProvider#commitDataBinding()
203      */

204     public void commitDataBinding( )
205     {
206         // TODO Auto-generated method stub
207

208     }
209
210     /*
211      * (non-Javadoc)
212      *
213      * @see org.eclipse.birt.chart.ui.swt.interfaces.IDataServiceProvider#rollbackDataBinding()
214      */

215     public void rollbackDataBinding( )
216     {
217         // TODO Auto-generated method stub
218

219     }
220
221     /*
222      * (non-Javadoc)
223      *
224      * @see org.eclipse.birt.chart.ui.swt.interfaces.IDataServiceProvider#startDataBinding()
225      */

226     public void startDataBinding( )
227     {
228         // TODO Auto-generated method stub
229

230     }
231
232 }
233
Popular Tags