TreeItem item[] = Utility.createTreeItems( schemaTreeItem[0],
TreeItem item[] = Utility.createTreeItems( schemaTreeItem,
	protected void populateTableList()	{		 // Remove all the existing children of the root Node		if ( rootNode != null )		{			availableDbObjectsTree.removeAll( );			setRootElement( );		}		String namePattern = null;		String[] tableType = null;		cachedSearchTxt = searchTxt.getText();			namePattern = getTailoredSearchText( searchTxt.getText() );		  		String dbtype = getSelectedDbType( );		cachedDbType = dbtype;		if ( dbtype != null )		{			if ( DbType.TABLE_STRING.equalsIgnoreCase( dbtype )					|| DbType.VIEW_STRING.equalsIgnoreCase( dbtype ) )			{				tableType = new String[]{					dbtype				};			}		}	    String catalogName = metaDataProvider.getCatalog();		ArrayList tableList = new ArrayList();		ArrayList targetSchemaList = new ArrayList();				ResultSet tablesRs = null;		ArrayList procedureRs = null;		if (schemaList != null && schemaList.size() > 0)		{			int numberOfSchema = 0;			Preferences preferences = ReportPlugin.getDefault( )					.getPluginPreferences( );			if ( preferences.contains( DateSetPreferencePage.USER_MAX_NUM_OF_SCHEMA ) )			{				numberOfSchema = preferences.getInt( DateSetPreferencePage.USER_MAX_NUM_OF_SCHEMA );			}			else			{				numberOfSchema = DateSetPreferencePage.DEFAULT_MAX_NUM_OF_SCHEMA;				preferences.setValue( DateSetPreferencePage.USER_MAX_NUM_OF_SCHEMA,						numberOfSchema );			}			cachedSchemaComboIndex = schemaCombo.getSelectionIndex();			if ( schemaCombo.getSelectionIndex() == 0)			{				targetSchemaList = schemaList;			}			else			{				targetSchemaList.add( schemaCombo.getItem( schemaCombo.getSelectionIndex() ));				numberOfSchema = 1;			}									// For each schema Get  the List of Tables			int numTables = 0;				for( int i=0; i< targetSchemaList.size() && i < numberOfSchema; i++)			{				int count = 0;				String schemaName = (String)targetSchemaList.get(i);				if( metaDataProvider.isProcedureSupported() )					procedureRs = metaDataProvider.getAllProcedure( catalogName, schemaName, namePattern );				if( !DbType.PROCEDURE_STRING.equalsIgnoreCase(dbtype))					tablesRs = metaDataProvider.getAlltables(catalogName,schemaName,namePattern,tableType);					tableList = new ArrayList();				if( tablesRs == null && procedureRs == null )				{					continue;				}					try				{					// Create the schema Node					ArrayList schema = new ArrayList();					TreeItem schemaTreeItem[] = null;					Image image = tableImage;										if( count == 0 )					{						schema.add(schemaName);						schemaTreeItem = Utility.createTreeItems(rootNode, schema, SWT.NONE, schemaImage);						//expand schema TreeItem						if( schemaTreeItem != null && schemaTreeItem.length > 0)							availableDbObjectsTree.showItem(schemaTreeItem[0]);					}										if ( tablesRs != null )					{						while ( tablesRs.next( ) )						{							// tablesRs.getString("TABLE_NAME") must be called							// before							// tablesRs.getString("TABLE_TYPE"). This is because							// once using JDBC-ODBC-SQLSERVER							// the index of "TABLE_NAME" is higher than that of							// "TABLE_TYPE".And when connection							// is built using JDBC-ODBC-SQLSERVER the							// ResultSet.getString() method, if being called							// use a low index, then called using a high index,							// will result in an exception.							String tableName = tablesRs.getString( "TABLE_NAME" );							String type = tablesRs.getString( "TABLE_TYPE" );							if ( type.equalsIgnoreCase( "SYSTEM TABLE" ) )								continue;							count++;							int dbType = DbObject.TABLE_TYPE;							if ( type.equalsIgnoreCase( "TABLE" ) )							{								image = tableImage;								dbType = DbObject.TABLE_TYPE;							}							else if ( type.equalsIgnoreCase( "VIEW" ) )							{								image = viewImage;								dbType = DbObject.VIEW_TYPE;							}							String fullyQualifiedTableName = tableName;							if ( schemaName != null									&& schemaName.trim( ).length( ) > 0 )							{								fullyQualifiedTableName = schemaName										+ "." + tableName;							}							DbObject dbObject = new DbObject( fullyQualifiedTableName,									tableName,									dbType,									image );							tableList.add( dbObject );							numTables++;						}					}					if ( needToCreateProcedureNode( dbtype, procedureRs ))					{						String fullyQualifiedTableName = "STORED PROCEDURES";						if ( schemaName != null								&& schemaName.trim( ).length( ) > 0 )						{							fullyQualifiedTableName = schemaName + "." + "STORED PROCEDURES";						}						DbObject dbObject = new DbObject( fullyQualifiedTableName,"STORED PROCEDURES", DbObject.PROCEDURE_TYPE, tableImage);						tableList.add( dbObject );					}					if ( schemaTreeItem != null 							&& schemaTreeItem.length > 0 ) 					{						TreeItem item[] = Utility.createTreeItems( schemaTreeItem[0],								tableList,								SWT.NONE,								null );						//expand table TreeItem						if ( expandDbObjectsTree && item != null && item.length > 0 )						{							availableDbObjectsTree.showItem( item[0] );						}					}				}				catch(SQLException e)				{					e.printStackTrace();				}			}		}		else		{			if( metaDataProvider.isProcedureSupported() )				procedureRs = metaDataProvider.getAllProcedure( catalogName, null, namePattern );			if( !DbType.PROCEDURE_STRING.equalsIgnoreCase(dbtype))				tablesRs = metaDataProvider.getAlltables(catalogName,null,namePattern,tableType);						if( tablesRs == null && procedureRs == null )			{				return;			}			try			{				Image image = tableImage;				if ( tablesRs != null )				{					while ( tablesRs.next( ) )					{						String tableName = tablesRs.getString( "TABLE_NAME" );						String type = tablesRs.getString( "TABLE_TYPE" );//$NON-NLS-1$						if ( type.equalsIgnoreCase( "SYSTEM TABLE" ) )							continue;						// String SchemaName =						// tablesRs.getString("TABLE_SCHEM");//$NON-NLS-1$						int dbType = DbObject.TABLE_TYPE;						if ( type.equalsIgnoreCase( "TABLE" ) )						{							image = tableImage;							dbType = DbObject.TABLE_TYPE;						}						else if ( type.equalsIgnoreCase( "VIEW" ) )						{							image = viewImage;							dbType = DbObject.VIEW_TYPE;						}						DbObject dbObject = new DbObject( tableName,								tableName,								dbType,								image );						tableList.add( dbObject );					}				}				if ( needToCreateProcedureNode( dbtype, procedureRs ))				{					String fullyQualifiedTableName = "STORED PROCEDURES";							DbObject dbObject = new DbObject( fullyQualifiedTableName,"STORED PROCEDURES", DbObject.PROCEDURE_TYPE, tableImage);					tableList.add( dbObject );				}				TreeItem item[] = Utility.createTreeItems(rootNode, tableList, SWT.NONE, null);								//expand table TreeItem				if( item != null && item.length > 0)					availableDbObjectsTree.showItem(item[0]);								// Add listener to display the column names when expanded			}			catch(Exception e)			{				e.printStackTrace();			}		}			// Add a listener for fetching columns	   addFetchColumnListener();  	}