예제 #1
0
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);
    }
}
예제 #2
0
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(), "    "));
    }
}
예제 #3
0
void PHPWorkspaceView::DoAddFilesToTreeView(const wxTreeItemId& folderId, PHPProject::Ptr_t pProject, PHPFolder::Ptr_t pFolder, const wxArrayString& files)
{
    for(size_t i=0; i<files.GetCount(); ++i) {
        ItemData *itemData = new ItemData(ItemData::Kind_File);
        itemData->SetFile( files.Item(i) );
        itemData->SetProjectName( pProject->GetName() );
        itemData->SetFolderPath( pFolder->GetPathRelativeToProject() );
        
        int imgId = DoGetItemImgIdx(files.Item(i));
        m_treeCtrlView->AppendItem(folderId, wxFileName(files.Item(i)).GetFullName(), imgId, imgId, itemData);
    }
    m_treeCtrlView->SortChildren( folderId );
}
예제 #4
0
wxTreeItemId PHPWorkspaceView::DoGetFolderItem(const wxTreeItemId& projectItem, PHPFolder::Ptr_t pFolder)
{
    wxString curpath, path;
    path = pFolder->GetPathRelativeToProject();

    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)) {
            return wxTreeItemId();
        }
    }
    return parent;
}