Index: trunk/ab5.0/abdev/abdev/ClassTree.cpp
===================================================================
--- trunk/ab5.0/abdev/abdev/ClassTree.cpp	(revision 629)
+++ trunk/ab5.0/abdev/abdev/ClassTree.cpp	(revision 655)
@@ -20,5 +20,5 @@
 	return lpdata%MAX_HASH;
 }
-void CClassTreeView::AddValidItem(HTREEITEM hItem,int iFileNum){
+void CClassTreeView::AddValidItem(HTREEITEM hItem,HTREEITEM hFileTreeItem){
 	//ハッシュ値を取得
 	int key;
@@ -42,5 +42,5 @@
 
 	pth->hItem=hItem;
-	pth->iFileNum=iFileNum;
+	pth->hFileTreeItem = hFileTreeItem;
 	pth->pNextData=0;
 }
@@ -85,5 +85,5 @@
 
 void CClassTreeView::DeleteTreeHash(TREEHASH *pth){
-	if(pth->hItem && (iNowFile==-1 || iNowFile==pth->iFileNum)){
+	if(pth->hItem && (hNowFileTreeItem==(HTREEITEM)-1 || hNowFileTreeItem==pth->hFileTreeItem)){
 		if(pth->pNextData){
 			DeleteTreeHash(pth->pNextData);
@@ -96,5 +96,5 @@
 
 
-HTREEITEM CClassTreeView::insert(HTREEITEM hParentItem,int flag,char *lpszName,int iFileNum){
+HTREEITEM CClassTreeView::insert(HTREEITEM hParentItem,int flag,char *lpszName,HTREEITEM hFileTreeItem){
 	char temporary[255];
 
@@ -110,5 +110,5 @@
 		if(lstrcmp(lpszName,tvItem.pszText)==0){
 			//既に挿入済みの場合
-			AddValidItem(hNextItem,iFileNum);
+			AddValidItem(hNextItem,hFileTreeItem);
 			return hNextItem;
 		}
@@ -158,5 +158,5 @@
 
 	hNextItem=TreeView_InsertItem(hTreeWnd,&tv);
-	AddValidItem(hNextItem,iFileNum);
+	AddValidItem(hNextItem,hFileTreeItem);
 	return hNextItem;
 }
@@ -170,5 +170,5 @@
 	while(bSearchingClasses) Sleep(10);
 
-	iNowFile=-1;
+	this->hNowFileTreeItem = (HTREEITEM)-1;
 
 	int i;
@@ -186,8 +186,8 @@
 	}
 }
-void CClassTreeView::init(HWND hwnd,int iFileNum){
+void CClassTreeView::init(HWND hwnd,HTREEITEM hFileTreeItem){
 	hTreeWnd=hwnd;
 
-	iNowFile=iFileNum;
+	this->hNowFileTreeItem = hFileTreeItem;
 
 	int i;
@@ -203,5 +203,5 @@
 		TVI_ROOT,
 		CTV_ROOT,
-		temporary,-1);
+		temporary,(HTREEITEM)-1);
 }
 void CClassTreeView::InsertGlobalProcedureFolder(void){
@@ -209,16 +209,16 @@
 		hRootFolder,
 		CTV_FOLDER,
-		"グローバル関数",-1);
-}
-
-HTREEITEM CClassTreeView::InsertGlobalProcedure(int flag,char *lpszName,int iFileNum){
+		"グローバル関数",(HTREEITEM)-1);
+}
+
+HTREEITEM CClassTreeView::InsertGlobalProcedure(int flag,char *lpszName,HTREEITEM hFileTreeItem){
 	return pobj_ClassTreeView->insert(
 		hGlobalProcedureFolder,
 		CTV_GLOBAL_PROC,
 		lpszName,
-		iFileNum);
-}
-
-HTREEITEM CClassTreeView::insert_code_item(HTREEITEM hParentItem,int flag,char *lpszName,int iFileNum,char *pBuf,int p){
+		hFileTreeItem);
+}
+
+HTREEITEM CClassTreeView::insert_code_item(HTREEITEM hParentItem,int flag,char *lpszName,HTREEITEM hFileTreeItem,char *pBuf,int p){
 	int i4;
 	i4=NumberOfProcedures;
@@ -226,5 +226,5 @@
 	pProcInfo[i4].name=(char *)HeapAlloc(hHeap,0,lstrlen(lpszName)+1);
 	lstrcpy(pProcInfo[i4].name,lpszName);
-	pProcInfo[i4].FileNum=iFileNum;
+	pProcInfo[i4].hFileTreeItem = hFileTreeItem;
 
 	//コード位置
@@ -237,5 +237,5 @@
 		flag,
 		lpszName,
-		iFileNum);
+		hFileTreeItem);
 
 	pProcInfo[i4].hTreeItem=hTempItem;
@@ -246,9 +246,9 @@
 }
 
-void CClassTreeView::InsertClassFolder(char *lpszName,int iFileNum,char *pBuf,int p){
-	hNowClassFolder=insert_code_item(hRootFolder,CTV_CLASS,lpszName,iFileNum,pBuf,p);
-}
-void CClassTreeView::InsertClassMember(int flag,char *lpszName,int iFileNum,char *pBuf,int p){
-	insert_code_item(hNowClassFolder,flag,lpszName,iFileNum,pBuf,p);
+void CClassTreeView::InsertClassFolder(char *lpszName,HTREEITEM hFileTreeItem,char *pBuf,int p){
+	hNowClassFolder=insert_code_item(hRootFolder,CTV_CLASS,lpszName,hFileTreeItem,pBuf,p);
+}
+void CClassTreeView::InsertClassMember(int flag,char *lpszName,HTREEITEM hFileTreeItem,char *pBuf,int p){
+	insert_code_item(hNowClassFolder,flag,lpszName,hFileTreeItem,pBuf,p);
 }
 
@@ -258,5 +258,5 @@
 
 
-void AnalysisClass(char *pBuf,int *p,int iFileNum){
+void AnalysisClass(char *pBuf,int *p,HTREEITEM hFileTreeItem){
 	int i2;
 	i2=*p;
@@ -272,5 +272,5 @@
 	pobj_ClassTreeView->InsertClassFolder(
 		pobj_ClassInfo->ClassName,
-		iFileNum,
+		hFileTreeItem,
 		pBuf,
 		i2);
@@ -307,5 +307,5 @@
 			}
 		}
-		pobj_ClassTreeView->InsertClassMember(flag,pobj_ClassInfo->pMemberInfo[i].pName,iFileNum,pBuf,pobj_ClassInfo->pMemberInfo[i].code_pos);
+		pobj_ClassTreeView->InsertClassMember(flag,pobj_ClassInfo->pMemberInfo[i].pName,hFileTreeItem,pBuf,pobj_ClassInfo->pMemberInfo[i].code_pos);
 	}
 
@@ -316,5 +316,5 @@
 
 
-void SetClassTreeFromOneFile_Buf( char *pBuf, int iFileNum ){
+void SetClassTreeFromOneFile_Buf( char *pBuf, HTREEITEM hFileTreeItem ){
 	int i2,i3,i4;
 	char temporary[GENERAL_SIZE];
@@ -345,5 +345,5 @@
 				// クラスの解析
 				/////////////////////////////
-				AnalysisClass(pBuf,&i4,iFileNum);
+				AnalysisClass(pBuf,&i4,hFileTreeItem);
 
 				i2=i4-1;
@@ -384,5 +384,5 @@
 				pobj_ClassTreeView->pProcInfo[i4].name=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
 				lstrcpy(pobj_ClassTreeView->pProcInfo[i4].name,temporary);
-				pobj_ClassTreeView->pProcInfo[i4].FileNum=iFileNum;
+				pobj_ClassTreeView->pProcInfo[i4].hFileTreeItem = hFileTreeItem;
 
 				//定義行の選択範囲
@@ -433,5 +433,5 @@
 					CTV_GLOBAL_PROC,
 					pobj_ClassTreeView->pProcInfo[i4].name,
-					iFileNum);
+					hFileTreeItem);
 				pobj_ClassTreeView->pProcInfo[i4].hTreeItem=hTempItem;
 
@@ -443,5 +443,5 @@
 	}
 }
-void SetClassTreeFromOneFile(char *lpszFilePath,int iFileNum){
+void SetClassTreeFromOneFile( const ActiveBasic::PM::FM::File &file){
 	int WndNum;
 	HWND hChild=GetWindow(hClient,GW_CHILD);
@@ -451,5 +451,5 @@
 		{
 			if(IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType)){
-				if(lstrcmpi(MdiInfo[WndNum]->path.c_str(),lpszFilePath)==0) break;
+				if(lstrcmpi(MdiInfo[WndNum]->path.c_str(),file.GetFullPath().c_str())==0) break;
 			}
 			hChild=GetNextWindow(hChild,GW_HWNDNEXT);
@@ -464,22 +464,32 @@
 	else{
 		//開かれていない場合
-		pBuf=ReadBuffer(lpszFilePath);
+		pBuf=ReadBuffer(file.GetFullPath());
 		if(!pBuf) pBuf=(char *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,1);
 	}
 
-	SetClassTreeFromOneFile_Buf( pBuf, iFileNum );
+	SetClassTreeFromOneFile_Buf( pBuf, file.GetTreeItemHandle() );
 
 	if(!hChild) HeapDefaultFree(pBuf);
 }
-
-void SetProcedureTreeData(void *temp_iFileNum){
-	int i;
-	char temporary[MAX_PATH];
+void SetClassTreeFromAllFile( ActiveBasic::PM::FM::Folder &folder )
+{
+	BOOST_FOREACH( ActiveBasic::PM::FM::Folder &childFolder, folder.folders )
+	{
+		SetClassTreeFromAllFile( childFolder );
+	}
+
+	BOOST_FOREACH( ActiveBasic::PM::FM::File &file, folder.files )
+	{
+		SetClassTreeFromOneFile( file );
+	}
+}
+
+void SetProcedureTreeData(void *temp_hFileTreeItem)
+{
 	BOOL bExpand;
 	TVITEM tvItem;
 	SCROLLINFO si;
 
-	int iFileNum;
-	iFileNum=(int)temp_iFileNum;
+	HTREEITEM hFileTreeItem = (HTREEITEM)temp_hFileTreeItem;
 
 	if(bSearchingClasses){
@@ -504,6 +514,6 @@
 
 		//プロシージャ情報のメモリを解放
-		for(i=0;i<pobj_ClassTreeView->NumberOfProcedures;i++){
-			if(iFileNum==-1 || iFileNum==pobj_ClassTreeView->pProcInfo[i].FileNum){
+		for(int i=0;i<pobj_ClassTreeView->NumberOfProcedures;i++){
+			if(hFileTreeItem==(HTREEITEM)-1 || hFileTreeItem==pobj_ClassTreeView->pProcInfo[i].hFileTreeItem){
 				HeapDefaultFree(pobj_ClassTreeView->pProcInfo[i].name);
 			}
@@ -539,5 +549,5 @@
 
 
-	pobj_ClassTreeView->init(hProcedureTreeView,iFileNum);
+	pobj_ClassTreeView->init(hProcedureTreeView,hFileTreeItem);
 
 	//ルートフォルダ
@@ -553,11 +563,9 @@
 	if( projectInfo.IsOpened() ){
 		// プロジェクトが開かれているとき
-		if(iFileNum==-1){
+		if(hFileTreeItem==(HTREEITEM)-1){
+			boost::mutex::scoped_lock lock( projectInfo.fileSystem.mutex );
+
 			//プロジェクトのすべてのファイルを解析
-			for(i=0;i<projectInfo.pobj_DBFileInfo->iNum;i++){
-				projectInfo.pobj_DBFileInfo->ppobj_FileInfo[i]->GetFullPath(temporary);
-
-				SetClassTreeFromOneFile(temporary,i);
-			}
+			SetClassTreeFromAllFile( projectInfo.fileSystem.root );
 
 			//不要になったアイテムを除去
@@ -569,7 +577,5 @@
 			/////////////////////////////////
 
-			projectInfo.pobj_DBFileInfo->ppobj_FileInfo[iFileNum]->GetFullPath(temporary);
-
-			SetClassTreeFromOneFile(temporary,iFileNum);
+			SetClassTreeFromOneFile( projectInfo.fileSystem.root.FindFile( hFileTreeItem ) );
 		}
 	}
@@ -580,5 +586,5 @@
 		int WndNum=GetWndNum(hChild);
 		char *pBuf=MdiInfo[WndNum]->pMdiTextEdit->buffer;
-		SetClassTreeFromOneFile_Buf( pBuf, -1 );
+		SetClassTreeFromOneFile_Buf( pBuf, (HTREEITEM)-1 );
 
 	}
@@ -601,5 +607,5 @@
 	if(bRetrySearchingClasses){
 		bRetrySearchingClasses=0;
-		ResetClassTree(iFileNum);
+		ResetClassTree(hFileTreeItem);
 	}
 
@@ -617,5 +623,5 @@
 	_endthread();
 }
-void ResetClassTree(int iFileNum){
-	_beginthread(SetProcedureTreeData,0,(void *)iFileNum);
-}
+void ResetClassTree(HTREEITEM hFileTreeItem){
+	_beginthread(SetProcedureTreeData,0,(void *)hFileTreeItem);
+}
