本文整理汇总了C++中phpproject::Ptr_t类的典型用法代码示例。如果您正苦于以下问题:C++ Ptr_t类的具体用法?C++ Ptr_t怎么用?C++ Ptr_t使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Ptr_t类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ItemData
wxTreeItemId
PHPWorkspaceView::EnsureFolderExists(const wxTreeItemId& projectItem, const wxString& path, const wxString& project)
{
PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(project);
wxASSERT_MSG(pProject, wxString::Format("Could not locate project %s", project));
int imgId = m_mgr->GetStdIcons()->GetMimeImageId(FileExtManager::TypeFolder);
wxString curpath;
wxTreeItemId parent = projectItem;
wxArrayString parts = ::wxStringTokenize(path, "/", wxTOKEN_STRTOK);
for(size_t i = 0; i < parts.GetCount(); ++i) {
if(!curpath.IsEmpty()) {
curpath << "/";
}
curpath << parts.Item(i);
if(!HasFolderWithName(parent, parts.Item(i), parent)) {
ItemData* itemData = new ItemData(ItemData::Kind_Folder);
itemData->SetFolderPath(curpath);
itemData->SetProjectName(project);
itemData->SetFolderName(parts.Item(i));
parent =
m_treeCtrlView->AppendItem(parent,
parts.Item(i) == "." ? pProject->GetFilename().GetPath() : parts.Item(i),
imgId,
imgId,
itemData);
}
}
m_treeCtrlView->SortChildren(projectItem);
return parent;
}
示例2: DoAddFolderFiles
void PHPWorkspaceView::DoAddFolderFiles(const wxString& project,
const wxString& folder,
const wxTreeItemId& folderTreeItemId,
wxStringSet_t* filesAdded)
{
PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(project);
CHECK_PTR_RET(pProject);
PHPFolder::Ptr_t pFolder = pProject->Folder(folder);
CHECK_PTR_RET(pFolder);
wxArrayString files;
pFolder->GetFiles(files, pProject->GetFilename().GetPath());
files.Sort();
for(size_t i = 0; i < files.GetCount(); ++i) {
wxFileName fn(files.Item(i));
// create the user data
ItemData* itemData = new ItemData(ItemData::Kind_File);
itemData->SetFile(fn.GetFullPath());
itemData->SetFolderPath(folder);
itemData->SetProjectName(project);
int imgId = DoGetItemImgIdx(fn.GetFullName());
m_treeCtrlView->AppendItem(folderTreeItemId, fn.GetFullName(), imgId, imgId, itemData);
if(filesAdded) {
filesAdded->insert(fn.GetFullPath());
}
}
}
示例3: OnNewFolder
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);
}
示例4: GetProjectFiles
void PHPWorkspace::GetProjectFiles(const wxString& projectName, wxArrayString& files) const
{
PHPProject::Ptr_t p = GetProject(projectName.IsEmpty() ? GetActiveProjectName() : projectName);
CHECK_PTR_RET(p);
p->GetFilesArray(files);
}
示例5: DoAddFilesToFolder
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);
}
}
示例6: OnProjectSyncEnd
void PHPWorkspace::OnProjectSyncEnd(clCommandEvent& event)
{
const wxString& name = event.GetString();
if(m_inSyncProjects.count(name) == 0) {
clWARNING() << "PHPWorkspace::OnProjectSyncEnd: unable to find project '" << name << "' in the workspace..."
<< clEndl;
return;
}
clDEBUG() << "PHPWorkspace::OnProjectSyncEnd: project" << name << "completed sync" << clEndl;
m_inSyncProjects.erase(name);
// Load the project
PHPProject::Ptr_t pProj = GetProject(name);
CHECK_PTR_RET(pProj);
// Update the project files
pProj->SetFiles(event.GetStrings());
if(m_inSyncProjects.empty()) {
clDEBUG() << "PHPWorkspace::OnProjectSyncEnd: all projects completed sync" << clEndl;
if(m_projectSyncOwner) {
clCommandEvent endEvent(wxEVT_PHP_WORKSPACE_FILES_SYNC_END);
m_projectSyncOwner->AddPendingEvent(endEvent);
}
}
}
示例7: FromJSON
void PHPWorkspace::FromJSON(const JSONElement& e)
{
m_projects.clear();
if(e.hasNamedObject("projects")) {
PHPProject::Ptr_t firstProject;
JSONElement projects = e.namedObject("projects");
int count = projects.arraySize();
for(int i = 0; i < count; ++i) {
PHPProject::Ptr_t p(new PHPProject());
wxString project_file = projects.arrayItem(i).toString();
wxFileName fnProject(project_file);
fnProject.MakeAbsolute(m_workspaceFile.GetPath());
p->Load(fnProject);
m_projects.insert(std::make_pair(p->GetName(), p));
if(!firstProject) {
firstProject = p;
}
}
PHPProject::Ptr_t activeProject = GetActiveProject();
if(!activeProject && firstProject) {
// No active project found, mark the first project as active
activeProject = firstProject;
SetProjectActive(firstProject->GetName());
}
if(activeProject) {
// Notify about active project been set
clProjectSettingsEvent evt(wxEVT_ACTIVE_PROJECT_CHANGED);
evt.SetProjectName(activeProject->GetName());
evt.SetFileName(activeProject->GetFilename().GetFullPath());
EventNotifier::Get()->AddPendingEvent(evt);
}
}
}
示例8: ExpandRequire
wxString PHPCodeCompletion::ExpandRequire(const wxFileName& curfile, const wxString& require)
{
PHPScanner_t scanner = ::phpLexerNew("<?php " + require);
if(!scanner) return "";
wxString outFile;
phpLexerToken token;
while(::phpLexerNext(scanner, token)) {
if(token.IsAnyComment()) continue;
switch(token.type) {
case kPHP_T_REQUIRE:
case kPHP_T_REQUIRE_ONCE:
break;
case kPHP_T_CONSTANT_ENCAPSED_STRING: {
wxString str = token.text;
str.Trim().Trim(false);
// strip the " or ' from the string
str.Remove(0, 1).RemoveLast();
outFile << str;
break;
}
case kPHP_T_FILE:
outFile << curfile.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
break;
case kPHP_T_DIR:
outFile << curfile.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
break;
}
}
wxFileName fileName(outFile);
if(fileName.IsOk() && fileName.IsRelative()) {
wxArrayString paths;
paths.Add(curfile.GetPath());
// Relative path, we try to resolve it by looking at the include path give to us
PHPProject::Ptr_t proj = PHPWorkspace::Get()->GetActiveProject();
if(proj) {
wxArrayString incpaths = proj->GetSettings().GetIncludePathAsArray();
paths.insert(paths.end(), incpaths.begin(), incpaths.end());
}
for(size_t i = 0; i < paths.GetCount(); ++i) {
wxFileName tmpFile = fileName;
if(tmpFile.MakeAbsolute(paths.Item(i))) {
wxString fullpath = tmpFile.GetFullPath();
if(wxFileName::Exists(fullpath)) {
fileName = tmpFile;
break;
}
}
}
}
if(fileName.IsOk()) {
fileName.Normalize();
outFile = fileName.GetFullPath();
}
::phpLexerDestroy(&scanner);
return outFile;
}
示例9: DoAddFolder
void PHPWorkspaceView::DoAddFolder(const wxTreeItemId& parent, PHPFolder::Ptr_t folder, PHPProject::Ptr_t project)
{
// add the folder itself
ItemData* itemData = new ItemData(ItemData::Kind_Folder);
itemData->SetFolderPath(folder->GetPathRelativeToProject());
itemData->SetProjectName(project->GetName());
itemData->SetFolderName(folder->GetName()); // display name
wxTreeItemId folderItem = EnsureFolderExists(
DoGetProjectItem(project->GetName()), folder->GetPathRelativeToProject(), project->GetName());
// Get list of folders
const PHPFolder::List_t& children = folder->GetChildren();
PHPFolder::List_t::const_iterator iter = children.begin();
for(; iter != children.end(); ++iter) {
DoAddFolder(folderItem, *iter, project);
}
wxArrayString folderFiles;
folder->GetFiles(folderFiles, project->GetFilename().GetPath(), 0);
// Add the files
for(size_t i = 0; i < folderFiles.GetCount(); ++i) {
ItemData* itemData = new ItemData(ItemData::Kind_File);
itemData->SetFile(folderFiles.Item(i));
itemData->SetProjectName(project->GetName());
itemData->SetFolderPath(folder->GetPathRelativeToProject());
int imgId = DoGetItemImgIdx(folderFiles.Item(i));
m_treeCtrlView->AppendItem(folderItem, wxFileName(folderFiles.Item(i)).GetFullName(), imgId, imgId, itemData);
}
}
示例10: GetProjectFileName
wxFileName PHPWorkspace::GetProjectFileName(const wxString& projectName) const
{
PHPProject::Ptr_t p = GetProject(projectName);
if(!p) {
return wxFileName();
}
return p->GetFilename();
}
示例11: DelFile
void PHPWorkspace::DelFile(const wxString& project, const wxString& filename)
{
PHPProject::Ptr_t proj = GetProject(project);
CHECK_PTR_RET(proj);
wxArrayString files;
files.Add(filename);
proj->FilesDeleted(files, true);
}
示例12: OnImportFiles
void PHPWorkspaceView::OnImportFiles(wxCommandEvent& e)
{
ImportFilesDlg dlg(wxTheApp->GetTopWindow());
if(dlg.ShowModal() == wxID_OK) {
PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(DoGetSelectedProject());
CHECK_PTR_RET(pProject);
pProject->ImportDirectory(dlg.GetPath(), dlg.GetFileSpec(), dlg.GetIsRecursive());
LoadWorkspace();
}
}
示例13: DeleteProject
void PHPWorkspace::DeleteProject(const wxString& project)
{
PHPProject::Ptr_t p = GetProject(project);
CHECK_PTR_RET(p);
m_projects.erase(project);
if(p->IsActive() && !m_projects.empty()) {
// we are removing the active project, select a new project to be the active
PHPProject::Ptr_t newActiveProject = m_projects.begin()->second;
newActiveProject->SetIsActive(true);
newActiveProject->Save();
}
Save(); // save the workspace
}
示例14: OnGetActiveProjectFiles
void PhpPlugin::OnGetActiveProjectFiles(wxCommandEvent& e)
{
if(PHPWorkspace::Get()->IsOpen()) {
wxArrayString* pfiles = (wxArrayString*)e.GetClientData();
if(pfiles) {
wxString activeProjectName = PHPWorkspace::Get()->GetActiveProjectName();
PHPProject::Ptr_t proj = PHPWorkspace::Get()->GetProject(activeProjectName);
CHECK_PTR_RET(proj);
proj->GetFiles(*pfiles);
}
} else {
e.Skip();
}
}
示例15: MapRemoteFileToLocalFile
wxString MapRemoteFileToLocalFile(const wxString& remoteFile)
{
// Check that a workspace is opened
if(!PHPWorkspace::Get()->IsOpen()) return remoteFile;
// Sanity
PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetActiveProject();
if(!pProject) return remoteFile;
// Map filename file attribute returned by xdebug to local filename
wxString filename = remoteFile;
// Remote the "file://" from the file path
filename.StartsWith(FILE_SCHEME, &filename);
CL_DEBUG("filename => %s", filename);
// On Windows, the file is returned like (after removing the file://)
// /C:/Http/htdocs/file.php - remote the leading "/"
wxRegEx reMSWPrefix("/[a-zA-Z]{1}:/");
if(reMSWPrefix.IsValid() && reMSWPrefix.Matches(filename)) {
// Windows file
CL_DEBUG("filename => %s", filename);
filename.Remove(0, 1);
}
// Remove URI encoding ("%20"=>" " etc)
DecodeFileName(filename);
CL_DEBUG("filename => %s", filename);
// First check if the remote file exists locally
if(wxFileName(filename).Exists()) {
return wxFileName(filename).GetFullPath();
}
// Use the active project file mapping
const PHPProjectSettingsData& settings = pProject->GetSettings();
const JSONElement::wxStringMap_t& mapping = settings.GetFileMapping();
JSONElement::wxStringMap_t::const_iterator iter = mapping.begin();
for(; iter != mapping.end(); ++iter) {
const wxString& localFolder = iter->first;
const wxString& remoteFolder = iter->second;
if(filename.StartsWith(remoteFolder)) {
filename.Replace(remoteFolder, localFolder);
return wxFileName(filename).GetFullPath();
}
}
// No matching was found
return remoteFile;
}