⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfrm.cpp

📁 用bcg库编写的java IDE 源码
💻 CPP
📖 第 1 页 / 共 4 页
字号:

	DWORD flags = OFN_HIDEREADONLY;
	CFileDialog dlg(TRUE,NULL,NULL,flags,szFilter);
	CString szpFile;
	if(dlg.DoModal() == IDOK)
	{		
       szpFile = dlg.GetPathName();
	   
	   //close current workspace if one is opened
       if(CVisualJavaApp::m_pCurWorkSpace != NULL)
	   {
           if(CVisualJavaApp::m_pCurWorkSpace->Modified())
		   {
              if(MessageBox("Do you want to save changes to workspace ?","JavaJam",
				  MB_OKCANCEL|MB_ICONQUESTION) == IDOK)
			  {                 
                 CVisualJavaApp::m_pCurWorkSpace->SaveWorkSpc();
				 delete CVisualJavaApp::m_pCurWorkSpace;
				 CVisualJavaApp::m_pCurWorkSpace = NULL;
			  }
			  else
			  {
			     //we will take this to mean, user doesn't want settings saved either.
				 delete CVisualJavaApp::m_pCurWorkSpace;
				 CVisualJavaApp::m_pCurWorkSpace = NULL;
			  }
		   }
		   else//only do this to save settings
           CVisualJavaApp::m_pCurWorkSpace->SaveWorkSpc();
	   } 

	   //extract "Project.xml"
	   int len = szpFile.GetLength();
	   CString strFind;int x = 0;
	   for(int i = len-1; (i>=0&&x<11);i--)
	   {
	      strFind.Insert(0,szpFile[i]);
		  x++;
	   }

	   if(strFind.CompareNoCase("Project.xml") == 0)
	   {
		  //find coresponding workspace in this directory
		   CString szpName = szpFile.Left(i+1);
		   szpName += "Workspace.xml";

		   CFileFind finder;
		   if(finder.FindFile(szpName))
		   {
              finder.FindNextFile();
			  szpName = finder.GetFilePath();
			  CString szpMsg(
			  "A corresponding workspace \'"+szpName+"\' has been found and will be opened instead of\n"+
			  "the specified \'"+szpFile+"\'.\n\n"+
			  "Note: if you wish to create a workspace containing only the specified project, you can do so by creating a blank\n"+
              "workspace with the Workspace tab on the New dialog and then adding the project to the workspace using insert\n"+
			  "Projects into Workspace");
			  //display option message
			   

			   if(MessageBox(szpMsg,"JavaJam",MB_OKCANCEL|MB_ICONQUESTION) == IDOK)
			   {
                  CVisualJavaApp::m_pCurWorkSpace = new CWorkSpace;
	              if(!CVisualJavaApp::m_pCurWorkSpace->OpenWorkSpc(szpName,getFileView()))
				  {
                    //get error from global error handler

				  }				  
			   }
		   }
		   else
		   {
		      //get the path without file name
		      CString szpWkSpcName;
		      for(x = i; (x>=0&&szpFile[x]!='\\');x--)
			        szpWkSpcName.Insert(0,szpFile[x]);

              //create a new workspace and add chosen project
              CVisualJavaApp::m_pCurWorkSpace = new CWorkSpace;			  
			  
			  szpName = szpFile.Left(i+1);			  
			  CVisualJavaApp::m_pCurWorkSpace->CreateOnOpenProject(szpWkSpcName,szpName);			   
              CVisualJavaApp::m_pCurWorkSpace->OpenWorkSpc(szpName+"Workspace.xml",getFileView());
		   }
	   }
	   else
	   {
	      //extract "Workspace.xml"
	      int len = szpFile.GetLength();
	      CString strFind;int x = 0;
	      for(int i = len-1; (i>=0&&x<13);i--)
	      {
	         strFind.Insert(0,szpFile[i]);
		     x++;
	      }
		  if(strFind.CompareNoCase("Workspace.xml") == 0)
          {
open_aw:
	         //else load workspace
             CVisualJavaApp::m_pCurWorkSpace = new CWorkSpace;
	         if(!CVisualJavaApp::m_pCurWorkSpace->OpenWorkSpc(szpFile,getFileView()))
		     {
                //get error from global error handler

		     }
		  }
		  else
		  {
             if(MessageBox("The file you're trying to open doesn't seem to be\na valid workspace. Do you still want to open it?","JavaJam",MB_OKCANCEL|MB_ICONQUESTION|MB_ICONERROR) == IDOK)
                                    goto open_aw;

		  }
	   }
	}
}

void CMainFrame::OnUpdateFileOpenworkspace(CCmdUI* pCmdUI) 
{
   pCmdUI->Enable();	
}

void CMainFrame::OnFileSaveworkspace() 
{
  CVisualJavaApp::m_pCurWorkSpace->SaveWorkSpc();	
}

void CMainFrame::OnUpdateFileSaveworkspace(CCmdUI* pCmdUI) 
{
   pCmdUI->Enable(CVisualJavaApp::m_pCurWorkSpace != NULL);	
}

void CMainFrame::OnFileCloseworkspace() 
{
  //close workspace
  if(CVisualJavaApp::m_pCurWorkSpace != NULL)
  {
      if(CVisualJavaApp::m_pCurWorkSpace->Modified())
	  {
		  CString szpName = CVisualJavaApp::m_pCurWorkSpace->getName();
        int nId = MessageBox("You have made changes to the \'"+szpName+"\' workspace"+
			(CString)" and/or one or more of the projects it contains."+
			(CString)"Do you want\n to save your changes?","JavaJam",
		   MB_YESNOCANCEL|MB_ICONQUESTION);
		if(nId == IDYES)
		{		   
	       CVisualJavaApp::m_pCurWorkSpace->SaveWorkSpc();
		}
        //savesettings
	  }else CVisualJavaApp::m_pCurWorkSpace->SaveWorkSpc();
      delete CVisualJavaApp::m_pCurWorkSpace;
   }
   getFileView()->DeleteAllItems();
  CVisualJavaApp::m_pCurWorkSpace = NULL;
}

void CMainFrame::OnUpdateFileCloseworkspace(CCmdUI* pCmdUI) 
{
   pCmdUI->Enable(CVisualJavaApp::m_pCurWorkSpace != NULL);		
}

void CMainFrame::OnEditGoto() 
{
	/*
  int nFirst =-1;
  int nLast  =-1;
  int nThis  =-1;
  m_wndWorkSpcBar.GetRowInfo(nFirst,nLast,nThis);
  CString str;
  str.Format("%d",nThis);
  MessageBox("Pos:"+str,NULL,MB_OK);	*/
}

void CMainFrame::OnUpdateEditGoto(CCmdUI* pCmdUI) 
{
	pCmdUI->Enable();
}
/*****************************************************************************/
/****************************************************************************/


void CMainFrame::OnWorkspcAddNewProject() 
{

}

void CMainFrame::OnUpdateWorkspcAddNewProject(CCmdUI* pCmdUI) 
{
  pCmdUI->Enable();
}

void CMainFrame::OnWorkspcDockingView() 
{
	
}

void CMainFrame::OnUpdateWorkspcDockingView(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnWorkspcHide() 
{
	
}

void CMainFrame::OnUpdateWorkspcHide(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnWorkspcInsertProjInto() 
{
	static char BASED_CODE szFilter[]=
		"JavaJam Project Files (*.dsp)|*.dsp| All Files (*.*)|*.*||";

	DWORD flags = OFN_CREATEPROMPT|OFN_ALLOWMULTISELECT;
	CFileDialog dlg(TRUE,NULL,NULL,flags,szFilter);

	CString szpFile;
	if(dlg.DoModal() == IDOK)
	{		
       szpFile = dlg.GetPathName();
       ASSERT(CVisualJavaApp::m_pCurWorkSpace != NULL);

	   //extract "Project.xml"
	   int len = szpFile.GetLength();
	   CString strFind;int x = 0;
	   for(int i = len-1; (i>=0&&x<11);i--)
	   {
	      strFind.Insert(0,szpFile[i]);
		  x++;
	   }

      
       CString szpExt = dlg.GetFileExt();
	   if(strFind.Compare("Project.xml") == 0)
	   {
		  CVisualJavaApp::m_pCurWorkSpace->
		  AddProject("",szpFile,getFileView());
	   }
	   else
	   {
          MessageBox(szpFile+'\n'+(CString)"The specified file has been identified as"+
			 (CString)" a JavaJam workspace file and couldn't be inserted as a \n project"+
			 (CString)" into the current workspace","JavaJame",MB_OK|MB_ICONEXCLAMATION);
	   }
	}	
}

void CMainFrame::OnUpdateWorkspcInsertProjInto(CCmdUI* pCmdUI) 
{
  //pCmdUI->Enable(CVisualJavaApp::m_pCurWorkSpace != NULL);	
}

void CMainFrame::OnWorkspcProp() 
{
	
}

void CMainFrame::OnUpdateWorkspcProp(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnProjectBuild() 
{
	
}

void CMainFrame::OnUpdateProjectBuild(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnProjectBuildSel() 
{
	
}

void CMainFrame::OnUpdateProjectBuildSel(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnProjectClean() 
{
	
}

void CMainFrame::OnUpdateProjectClean(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnProjectDependencies() 
{
	
}

void CMainFrame::OnUpdateProjectDependencies(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnProjectDockingView() 
{
	
}

void CMainFrame::OnUpdateProjectDockingView(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnProjectExportMakefile() 
{
	
}

void CMainFrame::OnUpdateProjectExportMakefile(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnProjectHide() 
{
	
}

void CMainFrame::OnUpdateProjectHide(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnProjectInsertProjectIntoWorkspace() 
{
	
}

void CMainFrame::OnUpdateProjectInsertProjectIntoWorkspace(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnProjectNewFolder() 
{
  HTREEITEM hParent  = getFileView()->GetSelectedItem();
  CString szpProject = getFileView()->GetItemText(hParent);

  CNewFolderDlg dlg;
  if(dlg.DoModal() == IDOK)
  {
	CVisualJavaApp::m_pCurWorkSpace->NewFolder(dlg.m_szpFolderName,dlg.m_szpExts,
		                                                             szpProject);
  }
}

void CMainFrame::OnUpdateProjectNewFolder(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnProjectProp() 
{
	
}

void CMainFrame::OnUpdateProjectProp(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnProjectSetAsActive() 
{
	
}

void CMainFrame::OnUpdateProjectSetAsActive(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnProjectSettings() 
{
	
}

void CMainFrame::OnUpdateProjectSettings(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnProjectUnload() 
{
	
}

void CMainFrame::OnUpdateProjectUnload(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnFolderNew() 
{

}

void CMainFrame::OnUpdateFolderNew(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnFolderHide() 
{
	
}

void CMainFrame::OnUpdateFolderHide(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnFolderDockingView() 
{
	
}

void CMainFrame::OnUpdateFolderDockingView(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnFolderAddFiles() 
{
    HTREEITEM hItem    =  getFileView()->GetSelectedItem();
	CString szpFolder  =  getFileView()->GetItemText(hItem);
    HTREEITEM hParent  =  getFileView()->GetParentItem(hItem);
    CString szpProject =  getFileView()->GetItemText(hParent);

	
	CProject* pProject = CVisualJavaApp::m_pCurWorkSpace->getProject(szpProject);
	static char BASED_CODE szFilter[]="JavaJam WorkSpace Files (*.xml)|*.xml| All Files (*.*)|*.*||";
	DWORD flags = OFN_CREATEPROMPT|OFN_ALLOWMULTISELECT;
	CFileOpenDlgEx open(TRUE,NULL,NULL,flags,szFilter);
    CWorkSpcItem* pItem = (CWorkSpcItem*)getFileView()->GetItemData(hItem);
	CStringList nList;
	if(pItem->m_nItemType == W_FILE_FOLDER)
	{
	  open.HideReadOnly("Selected files will be inserted into folder title \'"+szpFolder+"\'");
	  if(open.DoModal() == IDOK)
	  {
        for(POSITION nPos = open.GetStartPosition(); nPos != NULL;)
		{
           CString szpPath = open.GetNextPathName(nPos);
		   nList.AddTail(szpPath);
		}
		CVisualJavaApp::m_pCurWorkSpace->AddFiles(&nList,szpFolder,szpProject);
	  }
	}
	else
	MessageBox("Please Select a file folder or create a new folder for the files you want to add","JavaJam",
		MB_OK|MB_ICONASTERISK);  
}

void CMainFrame::OnUpdateFolderAddFiles(CCmdUI* pCmdUI) 
{
	
}

void CMainFrame::OnFolderProp() 
{
	
}

void CMainFrame::OnUpdateFolderProp(CCmdUI* pCmdUI) 
{
	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -