Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
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
}
void PHPProjectSettingsDlg::Save()
{
    PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(m_projectName);
    CHECK_PTR_RET(pProject);

    PHPProjectSettingsData& data = pProject->GetSettings();

    // General settings
    data.SetRunAs(m_choicebook1->GetSelection() == 0 ? PHPProjectSettingsData::kRunAsCLI :
                  PHPProjectSettingsData::kRunAsWebsite);
    data.SetPhpExe(m_filePickerPHPExe->GetPath());
    data.SetIndexFile(m_filePickerIndex->GetPath());
    data.SetArgs(m_textCtrlProgramArgs->GetValue());
    data.SetWorkingDirectory(m_dirPickerWorkingDirectory->GetPath());
    data.SetIncludePath(m_textCtrlPHPIncludePath->GetValue());
    data.SetPauseWhenExeTerminates(m_checkBoxPauseWhenExecutionEnds->IsChecked());
    data.SetPhpIniFile(m_filePickerPhpIni->GetPath());
    data.SetProjectURL(m_textCtrlWebSiteURL->GetValue());
    data.SetUseSystemBrowser(m_checkBoxSystemBrowser->IsChecked());

    // Code Completion settings
    data.SetCcIncludePath(m_textCtrlCCIncludePath->GetValue());

    // Save the file mapping
    JSONElement::wxStringMap_t mapping;
    int itemCount = m_dvListCtrlFileMapping->GetItemCount();
    for(int i = 0; i < itemCount; ++i) {
        wxVariant source, target;
        m_dvListCtrlFileMapping->GetValue(source, i, 0);
        m_dvListCtrlFileMapping->GetValue(target, i, 1);
        mapping.insert(std::make_pair(source.GetString(), target.GetString()));
    }
    data.SetFileMapping(mapping);

    wxString fileExts = m_pgPropFileTypes->GetValue().GetString();
    fileExts.Replace(",", ";");
    pProject->SetImportFileSpec(fileExts);

    wxString excludeDirs = m_pgPropExcludeFolders->GetValue().GetString();
    excludeDirs.Replace(",", ";");
    pProject->SetExcludeFolders(excludeDirs);

    // Save the project content
    pProject->Save();
    SetDirty(false);
}
Exemplo n.º 4
0
void PHPWorkspaceView::OnRenameFile(wxCommandEvent& e)
{
    wxTreeItemId item = DoGetSingleSelection();
    CHECK_ITEM_RET(item);

    ItemData *data = DoGetItemData(item);
    CHECK_PTR_RET(data);
    CHECK_ID_FILE(data);

    wxFileName old_file_name = data->GetFile();
    wxString new_name = ::wxGetTextFromUser(_("New file name:"), _("Rename file"), old_file_name.GetFullName() );
    if ( new_name.IsEmpty() )
        return;

    if ( new_name == old_file_name.GetFullName() )
        return;

    // Check to see if we got a file with the old path opened
    bool reopenFile = false;
    IEditor *editor = m_mgr->FindEditor(old_file_name.GetFullPath());
    if ( editor ) {
        m_mgr->ClosePage( editor->GetFileName().GetFullName() );
        reopenFile = true;
        editor = NULL;
    }

    PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(DoGetSelectedProject());
    CHECK_PTR_RET(pProject);

    if ( pProject->RenameFile(old_file_name.GetFullPath(), new_name) ) {
        // Locate the folder
        pProject->Save();
        m_treeCtrlView->SetItemText(item, new_name);
        // Update the item data
        old_file_name.SetFullName(new_name);
        data->SetFile( old_file_name.GetFullPath() );
        
        // Open the file if it was opened earlier
        // old_file_name now contains the new full path to the new file
        if ( reopenFile ) {
            m_mgr->OpenFile( old_file_name.GetFullPath() );
        }
    }
}
Exemplo n.º 5
0
void PHPWorkspaceView::OnMakeIndexPHP(wxCommandEvent& e)
{
    e.Skip();
    wxTreeItemId item = DoGetSingleSelection();
    CHECK_ITEM_RET(item);

    ItemData* itemData = DoGetItemData(item);
    CHECK_PTR_RET(itemData);
    CHECK_ID_FILE(itemData);

    wxString projectName = itemData->GetProjectName();
    if(projectName.IsEmpty()) return;
    PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(projectName);
    CHECK_PTR_RET(pProject);

    PHPProjectSettingsData& settings = pProject->GetSettings();
    settings.SetIndexFile(itemData->GetFile());
    pProject->Save();
}
Exemplo n.º 6
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();
    }
}
Exemplo n.º 7
0
void PHPWorkspaceView::OnDeleteFolder(wxCommandEvent& e)
{
    wxTreeItemId folderItem = DoGetSingleSelection();
    if(!IsFolderItem(folderItem)) return;

    ItemData* data = DoGetItemData(folderItem);
    wxString folder = data->GetFolderPath();
    wxString project = DoGetSelectedProject();
    if(folder.IsEmpty() || project.IsEmpty()) return;

    wxString msg = wxString() << _("Are you sure you want to delete folder '") << folder
                              << ("'?\nNote: selecting 'Yes' will NOT remove any file from the file system");
    if(wxMessageBox(msg, wxT("CodeLite"), wxYES_NO | wxCANCEL | wxICON_QUESTION | wxCENTER) != wxYES) return;

    PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(project);
    CHECK_PTR_RET(pProject);
    pProject->DeleteFolder(folder);
    pProject->Save();

    // Update the UI
    m_treeCtrlView->Delete(folderItem);
}