示例#1
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(), "    "));
    }
}
示例#2
0
void PHPWorkspaceView::OnAddFile(wxCommandEvent& e)
{
    wxTreeItemId folderItem = DoGetSingleSelection();
    CHECK_ITEM_RET(folderItem);

    ItemData* data = DoGetItemData(folderItem);
    CHECK_PTR_RET(data);

    if(!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);

    wxFileDialog dlg(wxTheApp->GetTopWindow(),
                     _("Add file"),
                     pFolder->GetFullPath(pProject->GetFilename().GetPath()),
                     wxT(""),
                     wxT("PHP Files (*.php)|*.php|PHP include files (*.inc)|*.inc|All files (*)|*"),
                     wxFD_FILE_MUST_EXIST | wxFD_OPEN | wxFD_MULTIPLE);
    if(dlg.ShowModal() == wxID_OK) {

        wxArrayString paths;
        dlg.GetPaths(paths);

        if(paths.IsEmpty()) return;

        // if the file is not under the project's tree - do not add it
        // Use the folder taken from the file's full path and the pFolder as the base folder for adding the file
        if(!paths.Item(0).StartsWith(pProject->GetFilename().GetPath())) {
            ::wxMessageBox(_("Can not add file to project. File must be under the project directory tree"),
                           "CodeLite",
                           wxOK | wxCENTER | wxICON_WARNING);
            return;
        }

        DoAddFilesToFolder(paths, pProject, true);
        pProject->Save();
    }
}
示例#3
0
void PHPWorkspaceView::OnNewFile(wxCommandEvent& e)
{
    wxTreeItemId folderId = DoGetSingleSelection();
    ItemData *data = DoGetItemData( folderId );
    if( data->IsFolder() ) {
        PHPProject::Ptr_t pProj = PHPWorkspace::Get()->GetProject(data->GetProjectName());
        CHECK_PTR_RET(pProj);

        PHPFolder::Ptr_t pFolder = pProj->Folder(data->GetFolderPath());
        CHECK_PTR_RET(pFolder);

        NewFileDlg dlg(wxTheApp->GetTopWindow(), pFolder->GetFullPath( pProj->GetFilename().GetPath() ) );
        if(dlg.ShowModal() == wxID_OK) {
            wxFileName filename = dlg.GetPath();
            if( filename.FileExists() ) {
                // A file with this name already exists
                wxMessageBox(_("A file with same name already exists!"), wxT("CodeLite"), wxOK|wxCENTER|wxICON_WARNING);
                return;
            }
            DoAddFileWithContent(folderId, filename, "");
        }
    }
}