void PHPWorkspaceView::DoAddFilesToFolder(const wxArrayString& paths, PHPProject::Ptr_t pProject, bool notify) { if(paths.IsEmpty()) return; CHECK_PTR_RET(pProject); wxString folder_path = PHPFolder::GetFolderPathFromFileFullPath(paths.Item(0), pProject->GetFilename().GetPath()); wxTreeItemId folderItem = EnsureFolderExists(DoGetProjectItem(pProject->GetName()), folder_path, pProject->GetName()); PHPFolder::Ptr_t pFolder = pProject->AddFolder(folder_path); CHECK_PTR_RET(pFolder); wxArrayString newPaths; for(size_t i = 0; i < paths.GetCount(); i++) { if(pFolder->AddFile(paths.Item(i))) { newPaths.Add(paths.Item(i)); } } if(newPaths.IsEmpty()) return; if(notify) { DoAddFilesToTreeView(folderItem, pProject, pFolder, newPaths); // Notify the plugins clCommandEvent evtFilesAdded(wxEVT_PROJ_FILE_ADDED); evtFilesAdded.SetStrings(newPaths); EventNotifier::Get()->AddPendingEvent(evtFilesAdded); } }
void PHPWorkspaceView::OnNewClass(wxCommandEvent& e) { wxTreeItemId folderId = DoGetSingleSelection(); ItemData* data = DoGetItemData(folderId); if(!data || !data->IsFolder()) { return; } PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(data->GetProjectName()); CHECK_PTR_RET(pProject); PHPFolder::Ptr_t pFolder = pProject->Folder(data->GetFolderPath()); CHECK_PTR_RET(pFolder); NewPHPClass dlg(wxTheApp->GetTopWindow(), pFolder->GetFullPath(pProject->GetFilename().GetPath(), false)); if(dlg.ShowModal() == wxID_OK) { PHPClassDetails pcd = dlg.GetDetails(); pFolder = pProject->AddFolder(PHPFolder::GetFolderPathFromFileFullPath(pcd.GetFilepath().GetFullPath(), pProject->GetFilename().GetPath())); CHECK_PTR_RET(pFolder); folderId = EnsureFolderExists( DoGetProjectItem(pProject->GetName()), pFolder->GetPathRelativeToProject(), pProject->GetName()); DoAddFileWithContent( folderId, pcd.GetFilepath(), pcd.ToString(EditorConfigST::Get()->GetOptions()->GetEOLAsString(), " ")); } }
void PHPWorkspaceView::OnNewFolder(wxCommandEvent& e) { wxUnusedVar(e); wxString name = wxGetTextFromUser(_("New Folder Name:"), _("New Folder")); if(name.IsEmpty()) return; wxString project = DoGetSelectedProject(); if(project.IsEmpty()) return; wxTreeItemId parent = m_treeCtrlView->GetSelection(); CHECK_ITEM_RET(parent); ItemData* itemData = DoGetItemData(parent); CHECK_PTR_RET(itemData); if(!itemData->IsFolder() && !itemData->IsProject()) return; PHPProject::Ptr_t proj = PHPWorkspace::Get()->GetProject(project); CHECK_PTR_RET(proj); wxString folder; if(itemData->IsFolder()) { folder << itemData->GetFolderPath() << "/" << name; } else { folder << name; } PHPFolder::Ptr_t pFolder = proj->AddFolder(folder); proj->Save(); // Update the UI DoAddFolder(parent, pFolder, proj); }