Пример #1
0
void CppCheckPlugin::OnCheckProjectItem(wxCommandEvent& e)
{
    if ( m_cppcheckProcess ) {
        wxLogMessage(_("CppCheckPlugin: CppCheck is currently busy please wait for it to complete the current check"));
        return;
    }

    ProjectPtr proj = FindSelectedProject();
    if ( !proj ) {
        return;
    }

    // retrieve complete list of source files of the workspace
    std::vector< wxFileName > tmpfiles;
    proj->GetFiles(tmpfiles, true);

    // only C/C++ files
    for (size_t i=0; i< tmpfiles.size(); i++) {
        if (FileExtManager::GetType(tmpfiles.at(i).GetFullPath()) == FileExtManager::TypeSourceC ||
            FileExtManager::GetType(tmpfiles.at(i).GetFullPath()) == FileExtManager::TypeSourceCpp) {
            m_filelist.Add(tmpfiles.at(i).GetFullPath());
        }
    }
        
    DoStartTest(proj);
}
Пример #2
0
OpenResourceDialog::OpenResourceDialog( wxWindow* parent, IManager *manager, const wxString &type, bool allowChangeType )
		: OpenResourceDialogBase( parent )
		, m_manager(manager)
		, m_type(type)
		, m_needRefresh(false)
{
	
	m_timer = new wxTimer(this, XRCID("OR_TIMER"));
	m_timer->Start(500);
	
	m_listOptions->InsertColumn(0, wxT(""));
	m_listOptions->InsertColumn(1, wxT(""));
	m_listOptions->InsertColumn(2, wxT(""));
	
	m_listOptions->SetColumnWidth(0, 150);
	m_listOptions->SetColumnWidth(1, 300);
	m_listOptions->SetColumnWidth(2, 300);
	
	m_textCtrlResourceName->SetFocus();
	SetLabel(wxString::Format(wxT("Open %s"), m_type.c_str()));

	WindowAttrManager::Load(this, wxT("OpenResourceDialog"), m_manager->GetConfigTool());
	SimpleLongValue l;
	l.SetValue(m_checkBoxUsePartialMatching->IsChecked() ? 1 : 0);
	m_manager->GetConfigTool()->ReadObject(wxT("OpenResourceAllowsPartialMatch"), &l);
	m_checkBoxUsePartialMatching->SetValue(l.GetValue() == 1);

	m_choiceResourceType->SetStringSelection(m_type);

	if (!allowChangeType)
		m_choiceResourceType->Enable(false);

	//load all files from the workspace
	if ( m_manager->IsWorkspaceOpen() ) {
		wxArrayString projects;
		m_manager->GetSolution()->GetProjectList( projects );

		for ( size_t i=0; i<projects.GetCount(); i++ ) {
			std::vector<wxFileName> fileNames;
			wxString errmsg;
			ProjectPtr p = m_manager->GetSolution()->FindProjectByName(projects.Item(i), errmsg);

			if ( p ) {
				p->GetFiles(fileNames, true);

				//convert std::vector to wxArrayString
				for ( std::vector<wxFileName>::iterator it = fileNames.begin(); it != fileNames.end(); it ++ ) {
					m_files.Add ( ( *it ).GetFullPath() );
				}
			}
		}
	}
	
	m_listOptions->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( OpenResourceDialog::OnItemActivated ), NULL, this );
	m_listOptions->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( OpenResourceDialog::OnItemSelected ), NULL, this );
}
Пример #3
0
void Copyright::OnBatchInsertCopyrights(wxCommandEvent& e)
{
    // pop up the projects selection dialog
    if(m_mgr->IsWorkspaceOpen() == false) {
        wxMessageBox(_("Batch insert requires a workspace to be opened"), _("CodeLite"), wxICON_WARNING | wxOK);
        return;
    }

    if(!m_mgr->SaveAll()) return;

    // read configuration
    CopyrightsConfigData data;
    m_mgr->GetConfigTool()->ReadObject(wxT("CopyrightsConfig"), &data);

    wxString content;
    if(!Validate(content)) {
        return;
    }

    CopyrightsProjectSelDlg dlg(m_mgr->GetTheApp()->GetTopWindow(), m_mgr->GetWorkspace());
    if(dlg.ShowModal() == wxID_OK) {
        wxArrayString projects;
        dlg.GetProjects(projects);

        // expand constants
        wxString err_msg;
        std::vector<wxFileName> files;
        std::vector<wxFileName> filtered_files;
        // loop over the project and collect list of files to work with
        for(size_t i = 0; i < projects.size(); i++) {
            ProjectPtr p = m_mgr->GetWorkspace()->FindProjectByName(projects.Item(i), err_msg);
            if(p) {
                p->GetFiles(files, true);
            }
        }

        wxString mask(data.GetFileMasking());
        mask.Replace(wxT("*."), wxEmptyString);
        mask = mask.Trim().Trim(false);

        wxArrayString exts = wxStringTokenize(mask, wxT(";"));

        // filter out non-matching files (according to masking)
        for(size_t i = 0; i < files.size(); i++) {
            if(exts.Index(files.at(i).GetExt(), false) != wxNOT_FOUND) {
                // valid file
                filtered_files.push_back(files.at(i));
            }
        }

        if(filtered_files.empty() == false) {
            MassUpdate(filtered_files, content);
        }
    }
}
Пример #4
0
void Copyright::OnProjectInsertCopyrights(wxCommandEvent& e)
{
    // pop up the projects selection dialog
    if(m_mgr->IsWorkspaceOpen() == false) {
        wxMessageBox(_("Batch insert requires a workspace to be opened"), _("CodeLite"), wxICON_WARNING | wxOK);
        return;
    }

    if(!m_mgr->SaveAll()) return;

    // read configuration
    CopyrightsConfigData data;
    m_mgr->GetConfigTool()->ReadObject(wxT("CopyrightsConfig"), &data);

    wxString content;
    if(!Validate(content)) {
        return;
    }

    // get the project to work on
    TreeItemInfo info = m_mgr->GetSelectedTreeItemInfo(TreeFileView);
    wxString project_name = info.m_text;

    wxString err_msg;
    std::vector<wxFileName> files;
    std::vector<wxFileName> filtered_files;
    // loop over the project and collect list of files to work with
    ProjectPtr p = m_mgr->GetWorkspace()->FindProjectByName(project_name, err_msg);
    if(!p) {
        return;
    }

    p->GetFiles(files, true);

    // filter non matched files
    wxString mask(data.GetFileMasking());
    mask.Replace(wxT("*."), wxEmptyString);
    mask = mask.Trim().Trim(false);

    wxArrayString exts = wxStringTokenize(mask, wxT(";"));

    // filter out non-matching files (according to masking)
    for(size_t i = 0; i < files.size(); i++) {
        if(exts.Index(files.at(i).GetExt(), false) != wxNOT_FOUND) {
            // valid file
            filtered_files.push_back(files.at(i));
        }
    }

    // update files
    if(filtered_files.empty() == false) {
        MassUpdate(filtered_files, content);
    }
}
Пример #5
0
void clCxxWorkspace::GetProjectFiles(const wxString& projectName, wxArrayString& files) const
{
    ProjectPtr p = GetProject(projectName.IsEmpty() ? GetActiveProjectName() : projectName);
    CHECK_PTR_RET(p);

    wxStringSet_t setFiles;
    p->GetFiles(setFiles);

    // Convert the set wxArrayString
    std::for_each(setFiles.begin(), setFiles.end(), [&](const wxString& file) { files.Add(file); });
}
Пример #6
0
void NewProjectWizard::OnFinish(wxWizardEvent& event)
{
    wxFileName fn(m_stxtFullFileName->GetLabel());

    // Ensure that the target folder exists
    fn.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);

    // make sure that there is no conflict in files between the template project and the selected path
    if(m_projectData.m_srcProject) {
        ProjectPtr p = m_projectData.m_srcProject;
        wxString base_dir(fn.GetPath());
        std::vector<wxFileName> files;
        p->GetFiles(files);

        for(size_t i = 0; i < files.size(); ++i) {
            wxFileName f = files.at(i);
            wxString new_file = base_dir + wxT("/") + f.GetFullName();

            if(wxFileName::FileExists(new_file)) {
                // this file already - notify the user
                wxString msg;
                msg << _("The File '") << f.GetFullName() << _("' already exists at the target directory '") << base_dir
                    << wxT("'\n");
                msg << _("Please select a different project path\n");
                msg << _("The file '") << f.GetFullName() << _("' is part of the template project [") << p->GetName()
                    << wxT("]");
                wxMessageBox(msg, _("CodeLite"), wxOK | wxICON_HAND);
                event.Veto();
                return;
            }
        }
    }

    m_projectData.m_name = m_txtProjName->GetValue();
    m_projectData.m_path = fn.GetPath();
    m_projectData.m_cmpType = m_choiceCompiler->GetStringSelection();
    m_projectData.m_debuggerType = m_choiceDebugger->GetStringSelection();
    m_projectData.m_builderName = m_choiceBuildSystem->GetStringSelection();
    event.Skip();
}
Пример #7
0
void CppCheckPlugin::OnCheckWorkspaceItem(wxCommandEvent& e)
{
    if ( m_cppcheckProcess ) {
        wxLogMessage(_("CppCheckPlugin: CppCheck is currently busy please wait for it to complete the current check"));
        return;
    }

    if ( !m_mgr->GetWorkspace() || !m_mgr->IsWorkspaceOpen() ) {
        return;
    }

    TreeItemInfo item = m_mgr->GetSelectedTreeItemInfo(TreeFileView);
    if ( item.m_itemType == ProjectItem::TypeWorkspace ) {

        // retrieve complete list of source files of the workspace
        wxArrayString projects;
        wxString      err_msg;
        std::vector< wxFileName > tmpfiles;
        m_mgr->GetWorkspace()->GetProjectList(projects);

        for (size_t i=0; i< projects.GetCount(); i++) {
            ProjectPtr proj = m_mgr->GetWorkspace()->FindProjectByName(projects.Item(i), err_msg);
            if ( proj ) {
                proj->GetFiles(tmpfiles, true);
            }
        }

        // only C/C++ files
        for (size_t i=0; i< tmpfiles.size(); i++ ) {
            if (FileExtManager::GetType( tmpfiles.at(i).GetFullPath() ) == FileExtManager::TypeSourceC ||
                FileExtManager::GetType( tmpfiles.at(i).GetFullPath() ) == FileExtManager::TypeSourceCpp) {
                m_filelist.Add( tmpfiles.at(i).GetFullPath() );
            }
        }
    }
    DoStartTest();
}
Пример #8
0
wxString Cscope::DoCreateListFile(bool force)
{
    // get the scope
    CScopeConfData settings;
    m_mgr->GetConfigTool()->ReadObject(wxT("CscopeSettings"), &settings);

    // create temporary file and save the file there
    wxString privateFolder = clCxxWorkspaceST::Get()->GetPrivateFolder();
    wxFileName list_file(privateFolder, "cscope_file.list");
    if(force || settings.GetRebuildOption() || !list_file.FileExists()) {
        wxArrayString projects;
        m_mgr->GetWorkspace()->GetProjectList(projects);
        wxString err_msg;
        std::vector<wxFileName> files;
        std::vector<wxFileName> tmpfiles;
        m_cscopeWin->SetMessage(_("Creating file list..."), 5);

        if(settings.GetScanScope() == SCOPE_ENTIRE_WORKSPACE) {
            for(size_t i = 0; i < projects.GetCount(); i++) {
                ProjectPtr proj = m_mgr->GetWorkspace()->FindProjectByName(projects.Item(i), err_msg);
                if(proj) {
                    proj->GetFiles(tmpfiles, true);
                }
            }
        } else {
            // SCOPE_ACTIVE_PROJECT
            wxString projName = m_mgr->GetWorkspace()->GetActiveProjectName();
            ProjectPtr proj = m_mgr->GetWorkspace()->FindProjectByName(projName, err_msg);
            if(proj) {
                proj->GetFiles(tmpfiles, true);
            }
        }

        // iterate over the files and convert them to be relative path
        // Also remove any .exe files (one of which managed to crash cscope),
        // and files without an ext, which may be binaries and are unlikely to be .c or .h files in disguise; and .xpm
        // and .png too
        for(size_t i = 0; i < tmpfiles.size(); i++) {
            wxString ext = tmpfiles.at(i).GetExt();
            if(ext == wxT("exe") || ext == wxT("") || ext == wxT("xpm") || ext == wxT("png")) {
                continue;
            }
            tmpfiles.at(i).MakeRelativeTo(privateFolder);
            files.push_back(tmpfiles.at(i));
        }

        // create temporary file and save the file there
        wxFFile file(list_file.GetFullPath(), wxT("w+b"));
        if(!file.IsOpened()) {
            wxLogMessage(wxT("Failed to open temporary file ") + list_file.GetFullPath());
            return wxEmptyString;
        }

        // write the content of the files into the tempfile
        wxString content;
        for(size_t i = 0; i < files.size(); i++) {
            wxFileName fn(files.at(i));
            content << fn.GetFullPath() << wxT("\n");
        }

        file.Write(content);
        file.Flush();
        file.Close();
    }

    return list_file.GetFullPath();
}
Пример #9
0
wxString Cscope::DoCreateListFile(bool force)
{
	// get the scope
	CScopeConfData settings;
	m_mgr->GetConfigTool()->ReadObject(wxT("CscopeSettings"), &settings);

	//create temporary file and save the file there
	wxString wspPath = m_mgr->GetSolution()->GetSolutionFileName().GetPath(wxPATH_GET_VOLUME|wxPATH_GET_SEPARATOR);
	wxString list_file( wspPath );
	list_file << wxT("cscope_file.list");

	if (force || settings.GetRebuildOption() || !::wxFileExists(list_file))
	{
		wxArrayString projects;
		m_mgr->GetSolution()->GetProjectList(projects);
		wxString err_msg;
		std::vector< wxFileName > files;
		std::vector< wxFileName > tmpfiles;
		m_cscopeWin->SetMessage(wxT("Creating file list..."), 5);

		if (settings.GetScanScope() == SCOPE_ENTIRE_WORKSPACE) {
			for (size_t i=0; i< projects.GetCount(); i++) {
				ProjectPtr proj = m_mgr->GetSolution()->FindProjectByName(projects.Item(i), err_msg);
				if ( proj ) {
					proj->GetFiles(tmpfiles, true);
				}
			}
		} else {
			// SCOPE_ACTIVE_PROJECT
			wxString projName = m_mgr->GetSolution()->GetActiveProjectName();
			ProjectPtr proj = m_mgr->GetSolution()->FindProjectByName(projName, err_msg);
			if ( proj ) {
				proj->GetFiles(tmpfiles, true);
			}
		}

		//iterate over the files and convert them to be relative path
		for (size_t i=0; i< tmpfiles.size(); i++ ) {
			tmpfiles.at(i).MakeRelativeTo(wspPath);
			files.push_back(tmpfiles.at(i));
		}

		//create temporary file and save the file there
		wxFFile file(list_file, wxT("w+b"));
		if (!file.IsOpened()) {
			wxLogMessage(wxT("Failed to open temporary file ") + list_file);
			return wxEmptyString;
		}

		//write the content of the files into the tempfile
		wxString content;
		for (size_t i=0; i< files.size(); i++) {
			wxFileName fn(files.at(i));
			content << fn.GetFullPath() << wxT("\n");
		}

		file.Write( content );
		file.Flush();
		file.Close();
	}

	return list_file;
}
Пример #10
0
void NewProjectWizard::OnPageChanging(wxWizardEvent& event)
{
    if(event.GetDirection()) {
        wxDataViewItem sel = m_dataviewTemplates->GetSelection();
        NewProjectClientData* cd = dynamic_cast<NewProjectClientData*>(m_dataviewTemplatesModel->GetClientObject(sel));

        if(event.GetPage() == m_wizardPageTemplate) {
            // -------------------------------------------------------
            // Switching from the Templates page
            // -------------------------------------------------------
            if(!CheckProjectTemplate()) {
                event.Veto();
                return;
            }

            // Test to see if the selected project allows enabling the 'Create under separate folder'
            if(cd && !cd->IsCanUseSeparateFolder()) {
                m_cbSeparateDir->SetValue(false);
                m_cbSeparateDir->Enable(false);
            } else {
                m_cbSeparateDir->Enable(true);
            }

            m_txtProjName->SetFocus(); // This should have happened in the base-class ctor, but in practice it doesn't

        } else if(event.GetPage() == m_wizardPageDetails) {
            // -------------------------------------------------------
            // Switching from the Name/Path page
            // -------------------------------------------------------
            if(!CheckProjectName() || !CheckProjectPath()) {
                event.Veto();
                return;
            }
        } else if(event.GetPage() == m_wizardPageToolchain) {
            wxFileName fn(m_stxtFullFileName->GetLabel());

            // make sure that there is no conflict in files between the template project and the selected path
            if(m_projectData.m_srcProject) {
                ProjectPtr p = m_projectData.m_srcProject;
                wxString base_dir(fn.GetPath());
                std::vector<wxFileName> files;
                p->GetFiles(files);

                for(size_t i = 0; i < files.size(); ++i) {
                    wxFileName f = files.at(i);
                    wxString new_file = base_dir + wxT("/") + f.GetFullName();

                    if(wxFileName::FileExists(new_file)) {
                        // this file already - notify the user
                        wxString msg;
                        msg << _("The File '") << f.GetFullName() << _("' already exists at the target directory '")
                            << base_dir << wxT("'\n");
                        msg << _("Please select a different project path\n");
                        msg << _("The file '") << f.GetFullName() << _("' is part of the template project [")
                            << p->GetName() << wxT("]");
                        wxMessageBox(msg, _("CodeLite"), wxOK | wxICON_HAND);
                        event.Veto();
                        return;
                    }
                }
            }
        }
    }
    event.Skip();
}
OpenResourceDialog::OpenResourceDialog(wxWindow* parent, IManager* manager, const wxString& initialSelection)
    : OpenResourceDialogBase(parent)
    , m_manager(manager)
    , m_needRefresh(false)
{
    Hide();
    BitmapLoader* bmpLoader = m_manager->GetStdIcons();

    m_tagImgMap[wxT("class")] = bmpLoader->LoadBitmap(wxT("cc/16/class"));
    m_tagImgMap[wxT("struct")] = bmpLoader->LoadBitmap(wxT("cc/16/struct"));
    m_tagImgMap[wxT("namespace")] = bmpLoader->LoadBitmap(wxT("cc/16/namespace"));
    m_tagImgMap[wxT("typedef")] = bmpLoader->LoadBitmap(wxT("cc/16/typedef"));
    m_tagImgMap[wxT("member_private")] = bmpLoader->LoadBitmap(wxT("cc/16/member_private"));
    m_tagImgMap[wxT("member_public")] = bmpLoader->LoadBitmap(wxT("cc/16/member_public"));
    m_tagImgMap[wxT("member_protected")] = bmpLoader->LoadBitmap(wxT("cc/16/member_protected"));
    m_tagImgMap[wxT("function_private")] = bmpLoader->LoadBitmap(wxT("cc/16/function_private"));
    m_tagImgMap[wxT("function_public")] = bmpLoader->LoadBitmap(wxT("cc/16/function_public"));
    m_tagImgMap[wxT("function_protected")] = bmpLoader->LoadBitmap(wxT("cc/16/function_protected"));
    m_tagImgMap[wxT("enum")] = bmpLoader->LoadBitmap(wxT("cc/16/enum"));
    m_tagImgMap[wxT("enumerator")] = bmpLoader->LoadBitmap(wxT("cc/16/enumerator"));
    m_tagImgMap[wxT("cpp")] = bmpLoader->LoadBitmap(wxT("mime/16/cpp"));
    m_tagImgMap[wxT("h")] = bmpLoader->LoadBitmap(wxT("mime/16/h"));
    m_tagImgMap[wxT("text")] = bmpLoader->LoadBitmap(wxT("mime/16/text"));
    m_tagImgMap[wxT("c")] = bmpLoader->LoadBitmap(wxT("mime/16/c"));
    m_tagImgMap[wxT("wxfb")] = bmpLoader->LoadBitmap(wxT("mime/16/wxfb"));
    m_tagImgMap[wxT("wxcp")] = bmpLoader->LoadBitmap(wxT("mime/16/wxcp"));

    m_timer = new wxTimer(this, XRCID("OR_TIMER"));

    m_textCtrlResourceName->SetFocus();
    SetLabel(_("Open resource..."));

    SetMinClientSize(wxSize(600, 400));
    GetSizer()->Fit(this);

    SetName("OpenResourceDialog");
    WindowAttrManager::Load(this);

    // load all files from the workspace
    if(m_manager->IsWorkspaceOpen()) {
        wxArrayString projects;
        m_manager->GetWorkspace()->GetProjectList(projects);

        for(size_t i = 0; i < projects.GetCount(); i++) {
            std::vector<wxFileName> fileNames;
            wxString errmsg;
            ProjectPtr p = m_manager->GetWorkspace()->FindProjectByName(projects.Item(i), errmsg);

            if(p) {
                p->GetFiles(fileNames, true);

                // convert std::vector to wxArrayString
                for(std::vector<wxFileName>::iterator it = fileNames.begin(); it != fileNames.end(); it++) {
                    wxString name = it->GetFullName().MakeLower();
                    m_files.insert(std::make_pair(name, it->GetFullPath()));
                }
            }
        }
    }

    // Set the initial selection
    // We use here 'SetValue' so an event will get fired and update the control
    if(!initialSelection.IsEmpty()) {
        m_textCtrlResourceName->SetValue(initialSelection);
        m_textCtrlResourceName->SelectAll();
    }

    m_dataview->GetColumn(0)->SetWidth(400);
    m_dataview->GetColumn(1)->SetWidth(60);
    m_dataview->GetColumn(2)->SetWidth(500);

    bool showFiles = clConfig::Get().Read("OpenResourceDialog/ShowFiles", true);
    bool showSymbols = clConfig::Get().Read("OpenResourceDialog/ShowSymbols", true);
    m_checkBoxFiles->SetValue(showFiles);
    m_checkBoxShowSymbols->SetValue(showSymbols);
    CentreOnParent();
}
Пример #12
0
void NewProjectWizard::OnPageChanging(wxWizardEvent& event)
{
    if(event.GetDirection()) {
        wxDataViewItem sel = m_dataviewTemplates->GetSelection();
        NewProjectClientData* cd = dynamic_cast<NewProjectClientData*>(m_dataviewTemplatesModel->GetClientObject(sel));

        if(event.GetPage() == m_wizardPageTemplate) {
            // -------------------------------------------------------
            // Switching from the Templates page
            // -------------------------------------------------------
            if(!CheckProjectTemplate()) {
                event.Veto();
                return;
            }

            // Test to see if the selected project allows enabling the 'Create under separate folder'
            if(cd && !cd->IsCanUseSeparateFolder()) {
                m_cbSeparateDir->SetValue(false);
                m_cbSeparateDir->Enable(false);
            } else {
                m_cbSeparateDir->Enable(true);
            }

            m_txtProjName->SetFocus(); // This should have happened in the base-class ctor, but in practice it doesn't

        } else if(event.GetPage() == m_wizardPageDetails) {
            // -------------------------------------------------------
            // Switching from the Name/Path page
            // -------------------------------------------------------
            if(!CheckProjectName() || !CheckProjectPath()) {
                event.Veto();
                return;
            }
        } else if(event.GetPage() == m_wizardPageToolchain) {
            wxFileName fn(m_stxtFullFileName->GetLabel());

            // make sure that there is no conflict in files between the template project and the selected path
            if(m_projectData.m_srcProject) {
                ProjectPtr p = m_projectData.m_srcProject;
                wxString base_dir(fn.GetPath());
                std::vector<wxFileName> files;
                p->GetFiles(files);

                for(size_t i = 0; i < files.size(); ++i) {
                    wxFileName f = files.at(i);
                    wxString new_file = base_dir + wxT("/") + f.GetFullName();

                    if(wxFileName::FileExists(new_file)) {
                        // this file already - notify the user
                        wxString msg;
                        msg << _("The File '") << f.GetFullName() << _("' already exists at the target directory '")
                            << base_dir << wxT("'\n");
                        msg << _("Please select a different project path\n");
                        msg << _("The file '") << f.GetFullName() << _("' is part of the template project [")
                            << p->GetName() << wxT("]");
                        wxMessageBox(msg, _("CodeLite"), wxOK | wxICON_HAND);
                        event.Veto();
                        return;
                    }
                }
            }
        }

        // Try to offer a sensible toolchain/debugger combination as default
        if(!m_selectionMade) {
            wxString defaultDebugger;
            if(cd && cd->GetTemplate().Lower().Contains("php")) {
                for(size_t n = 0; n < m_choiceCompiler->GetCount(); ++n) {
                    if(m_choiceCompiler->GetString(n).Lower().Contains("php")) {
                        m_choiceCompiler->SetSelection(n);
                        break;
                    }
                }
                defaultDebugger = "XDebug";

            } else {
                // If it's not a PHP project we can't be sure of anything except we don't want php tools; so select the
                // first that isn't
                for(size_t n = 0; n < m_choiceCompiler->GetCount(); ++n) {
                    if(!m_choiceCompiler->GetString(n).Lower().Contains("php")) {
                        m_choiceCompiler->SetSelection(n);
                        break;
                    }
                }
#if defined(__WXMAC__)
                defaultDebugger = "LLDB Debugger";
#else
                defaultDebugger = "GNU gdb debugger";
#endif
            }

            int index = m_choiceDebugger->FindString(defaultDebugger);
            if(index != wxNOT_FOUND) {
                m_choiceDebugger->SetSelection(index);
            }
        }
    }
    event.Skip();
}
Пример #13
0
OpenResourceDialog::OpenResourceDialog(wxWindow* parent, IManager* manager, const wxString& initialSelection)
    : OpenResourceDialogBase(parent)
    , m_manager(manager)
    , m_needRefresh(false)
    , m_lineNumber(wxNOT_FOUND)
{
    Hide();
    BitmapLoader* bmpLoader = m_manager->GetStdIcons();

    m_tagImgMap[wxT("class")] = bmpLoader->LoadBitmap(wxT("cc/16/class"));
    m_tagImgMap[wxT("struct")] = bmpLoader->LoadBitmap(wxT("cc/16/struct"));
    m_tagImgMap[wxT("namespace")] = bmpLoader->LoadBitmap(wxT("cc/16/namespace"));
    m_tagImgMap[wxT("typedef")] = bmpLoader->LoadBitmap(wxT("cc/16/typedef"));
    m_tagImgMap[wxT("member_private")] = bmpLoader->LoadBitmap(wxT("cc/16/member_private"));
    m_tagImgMap[wxT("member_public")] = bmpLoader->LoadBitmap(wxT("cc/16/member_public"));
    m_tagImgMap[wxT("member_protected")] = bmpLoader->LoadBitmap(wxT("cc/16/member_protected"));
    m_tagImgMap[wxT("function_private")] = bmpLoader->LoadBitmap(wxT("cc/16/function_private"));
    m_tagImgMap[wxT("function_public")] = bmpLoader->LoadBitmap(wxT("cc/16/function_public"));
    m_tagImgMap[wxT("function_protected")] = bmpLoader->LoadBitmap(wxT("cc/16/function_protected"));
    m_tagImgMap[wxT("enum")] = bmpLoader->LoadBitmap(wxT("cc/16/enum"));
    m_tagImgMap[wxT("cenum")] = bmpLoader->LoadBitmap(wxT("cc/16/enum"));
    m_tagImgMap[wxT("enumerator")] = bmpLoader->LoadBitmap(wxT("cc/16/enumerator"));
    m_tagImgMap[wxT("cpp")] = bmpLoader->LoadBitmap(wxT("mime-cpp"));
    m_tagImgMap[wxT("h")] = bmpLoader->LoadBitmap(wxT("mime-h"));
    m_tagImgMap[wxT("text")] = bmpLoader->LoadBitmap(wxT("mime-txt"));
    m_tagImgMap[wxT("c")] = bmpLoader->LoadBitmap(wxT("mime-c"));
    m_tagImgMap[wxT("wxfb")] = bmpLoader->LoadBitmap(wxT("blocks"));
    m_tagImgMap[wxT("wxcp")] = bmpLoader->LoadBitmap(wxT("blocks"));

    m_timer = new wxTimer(this, XRCID("OR_TIMER"));

    m_textCtrlResourceName->SetFocus();
    SetLabel(_("Open resource..."));

    SetMinClientSize(wxSize(600, 400));
    GetSizer()->Fit(this);

    SetName("OpenResourceDialog");
    WindowAttrManager::Load(this);

    // load all files from the workspace
    if(m_manager->IsWorkspaceOpen()) {
        wxArrayString projects;
        m_manager->GetWorkspace()->GetProjectList(projects);

        for(size_t i = 0; i < projects.GetCount(); i++) {
            ProjectPtr p = m_manager->GetWorkspace()->GetProject(projects.Item(i));
            if(p) {
                const Project::FilesMap_t& files = p->GetFiles();
                // convert std::vector to wxArrayString
                std::for_each(files.begin(), files.end(), [&](const Project::FilesMap_t::value_type& vt) {
                    wxFileName fn(vt.second->GetFilename());
                    m_files.insert(std::make_pair(fn.GetFullName(), fn.GetFullPath()));
                });
            }
        }
    }

    wxString lastStringTyped = clConfig::Get().Read("OpenResourceDialog/SearchString", wxString());
    // Set the initial selection
    // We use here 'SetValue' so an event will get fired and update the control
    if(!initialSelection.IsEmpty()) {
        m_textCtrlResourceName->SetValue(initialSelection);
        m_textCtrlResourceName->SelectAll();
    } else if(!lastStringTyped.IsEmpty()) {
        m_textCtrlResourceName->SetValue(lastStringTyped);
        m_textCtrlResourceName->SelectAll();
    }

    m_dataview->GetColumn(0)->SetWidth(400);
    m_dataview->GetColumn(1)->SetWidth(60);
    m_dataview->GetColumn(2)->SetWidth(500);

    bool showFiles = clConfig::Get().Read("OpenResourceDialog/ShowFiles", true);
    bool showSymbols = clConfig::Get().Read("OpenResourceDialog/ShowSymbols", true);
    m_checkBoxFiles->SetValue(showFiles);
    m_checkBoxShowSymbols->SetValue(showSymbols);
    CentreOnParent();
}
Пример #14
0
wxString MacroManager::DoExpand(
    const wxString& expression, IManager* manager, const wxString& project, bool applyEnv, const wxString& confToBuild)
{
    wxString expandedString(expression);
    clCxxWorkspace* workspace = clCxxWorkspaceST::Get();

    if(!manager) {
        manager = clGetManager();
    }

    size_t retries = 0;
    wxString dummyname, dummfullname;
    while((retries < 5) && FindVariable(expandedString, dummyname, dummyname)) {
        ++retries;
        DollarEscaper de(expandedString);
        if(workspace) {
            expandedString.Replace(wxT("$(WorkspaceName)"), workspace->GetName());
            ProjectPtr proj = workspace->GetProject(project);
            if(proj) {
                wxString prjBuildWd;
                wxString prjRunWd;

                wxString project_name(proj->GetName());

                // make sure that the project name does not contain any spaces
                project_name.Replace(wxT(" "), wxT("_"));

                BuildConfigPtr bldConf = workspace->GetProjBuildConf(proj->GetName(), confToBuild);
                if(bldConf) {
                    bool isCustom = bldConf->IsCustomBuild();
                    expandedString.Replace(wxT("$(ProjectOutputFile)"), bldConf->GetOutputFileName());
                    // An alias
                    expandedString.Replace(wxT("$(OutputFile)"), bldConf->GetOutputFileName());

                    // When custom build project, use the working directory set in the
                    // custom build tab, otherwise use the project file's path
                    prjBuildWd = isCustom ? bldConf->GetCustomBuildWorkingDir() : proj->GetFileName().GetPath();
                    prjRunWd = bldConf->GetWorkingDirectory();
                }

                expandedString.Replace(wxT("$(ProjectWorkingDirectory)"), prjBuildWd);
                expandedString.Replace(wxT("$(ProjectRunWorkingDirectory)"), prjRunWd);
                expandedString.Replace(wxT("$(ProjectPath)"), proj->GetFileName().GetPath());
                expandedString.Replace(wxT("$(WorkspacePath)"), workspace->GetWorkspaceFileName().GetPath());
                expandedString.Replace(wxT("$(ProjectName)"), project_name);

                if(bldConf) {
                    expandedString.Replace(wxT("$(IntermediateDirectory)"), bldConf->GetIntermediateDirectory());
                    expandedString.Replace(wxT("$(ConfigurationName)"), bldConf->GetName());
                    expandedString.Replace(wxT("$(OutDir)"), bldConf->GetIntermediateDirectory());
                }

                if(expandedString.Find(wxT("$(ProjectFiles)")) != wxNOT_FOUND)
                    expandedString.Replace(wxT("$(ProjectFiles)"), proj->GetFiles());

                if(expandedString.Find(wxT("$(ProjectFilesAbs)")) != wxNOT_FOUND)
                    expandedString.Replace(wxT("$(ProjectFilesAbs)"), proj->GetFiles(true));
            }
        }

        if(manager) {
            IEditor* editor = manager->GetActiveEditor();
            if(editor) {
                wxFileName fn(editor->GetFileName());

                expandedString.Replace(wxT("$(CurrentFileName)"), fn.GetName());

                wxString fpath(fn.GetPath());
                fpath.Replace(wxT("\\"), wxT("/"));
                expandedString.Replace(wxT("$(CurrentFilePath)"), fpath);
                expandedString.Replace(wxT("$(CurrentFileExt)"), fn.GetExt());
                expandedString.Replace(wxT("$(CurrentFileFullName)"), fn.GetFullName());

                wxString ffullpath(fn.GetFullPath());
                ffullpath.Replace(wxT("\\"), wxT("/"));
                expandedString.Replace(wxT("$(CurrentFileFullPath)"), ffullpath);
                expandedString.Replace(wxT("$(CurrentSelection)"), editor->GetSelection());
                if(expandedString.Find(wxT("$(CurrentSelectionRange)")) != wxNOT_FOUND) {
                    int start = editor->GetSelectionStart(), end = editor->GetSelectionEnd();

                    wxString output = wxString::Format(wxT("%i:%i"), start, end);
                    expandedString.Replace(wxT("$(CurrentSelectionRange)"), output);
                }
            }
        }

        // exapand common macros
        wxDateTime now = wxDateTime::Now();
        expandedString.Replace(wxT("$(User)"), wxGetUserName());
        expandedString.Replace(wxT("$(Date)"), now.FormatDate());

        if(manager && applyEnv) {
            expandedString.Replace(wxT("$(CodeLitePath)"), manager->GetInstallDirectory());

            // Apply the environment and expand the variables
            EnvSetter es(NULL, NULL, project, confToBuild);
            expandedString = manager->GetEnv()->ExpandVariables(expandedString, false);
        }
    }
    return expandedString;
}