1 11 12 package org.eclipse.birt.chart.examples.builder; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 import org.eclipse.birt.chart.ui.swt.interfaces.IDataServiceProvider; 18 19 23 public class DefaultDataServiceProviderImpl implements IDataServiceProvider 24 { 25 26 private transient String sDataSetName = "Dummy DataSet"; private static final int COLUMN_COUNT = 8; 28 private static final int ROW_COUNT = 6; 29 30 35 public String [] getAllDataSets( ) 36 { 37 return new String []{ 39 "Dummy DataSet" }; 41 } 42 43 48 public String getBoundDataSet( ) 49 { 50 return sDataSetName; 52 } 53 54 public String getReportDataSet( ) 55 { 56 return null; 57 } 58 59 64 public String [] getPreviewHeader( ) 65 { 66 String [] columns = new String [COLUMN_COUNT]; 67 for ( int i = 0; i < columns.length; i++ ) 68 { 69 columns[i] = "DB Col " + ( i + 1 ); } 71 return columns; 72 } 73 74 79 public List getPreviewData( ) 80 { 81 List list = new ArrayList ( ); 82 for ( int rowNum = 0; rowNum < ROW_COUNT; rowNum++ ) 83 { 84 String [] columns = new String [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 99 public void setContext( Object context ) 100 { 101 } 103 104 109 public void setDataSet( String datasetName ) 110 { 111 this.sDataSetName = datasetName; 113 } 114 115 120 public int invoke( int command ) 121 { 122 return 1; 124 } 125 126 131 public String [] getAllStyles( ) 132 { 133 return new String []{}; 134 } 135 136 public String [] getAllStyleDisplayNames( ) 137 { 138 return getAllStyles( ); 139 } 140 141 146 public String getCurrentStyle( ) 147 { 148 return null; 149 } 150 151 156 public void setStyle( String styleName ) 157 { 158 } 160 161 public Object [] getDataForColumns( String [] sExpressions, int iMaxRecords, 162 boolean byRow ) 163 { 164 byRow = false; 166 Object [] array = new Object [sExpressions.length]; 167 for ( int i = 0; i < sExpressions.length; i++ ) { 169 Object [] innerArray = new Object [ROW_COUNT]; for ( int j = 0; j < ROW_COUNT; j++ ) 171 { 172 String 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 ( ( (String []) getPreviewData( ).get( j ) )[index] ); 177 } 178 array[i] = innerArray; 179 } 180 return array; 181 } 182 183 public void dispose( ) 184 { 185 187 } 188 189 public boolean isLivePreviewEnabled( ) 190 { 191 return true; 192 } 193 194 public boolean isInvokingSupported( ) 195 { 196 return false; 197 } 198 199 204 public void commitDataBinding( ) 205 { 206 208 } 209 210 215 public void rollbackDataBinding( ) 216 { 217 219 } 220 221 226 public void startDataBinding( ) 227 { 228 230 } 231 232 } 233 | Popular Tags |