Esempio n. 1
0
CscopeTab::CscopeTab( wxWindow* parent, IManager *mgr )
    : CscopeTabBase( parent )
    , m_table(NULL)
    , m_mgr(mgr)
{
    m_bitmaps = clGetManager()->GetStdIcons()->MakeStandardMimeMap();

    CScopeConfData data;
    m_mgr->GetConfigTool()->ReadObject(wxT("CscopeSettings"), &data);

    const wxString SearchScope[] = { wxTRANSLATE("Entire Workspace"), wxTRANSLATE("Active Project") };
    m_stringManager.AddStrings(sizeof(SearchScope)/sizeof(wxString), SearchScope, data.GetScanScope(), m_choiceSearchScope);

    wxFont defFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
    m_font = wxFont( defFont.GetPointSize(), wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);

    m_checkBoxUpdateDb->SetValue(data.GetRebuildOption());
    m_checkBoxRevertedIndex->SetValue(data.GetBuildRevertedIndexOption());
    SetMessage(_("Ready"), 0);

    Clear(); // To make the Clear button UpdateUI work initially
    EventNotifier::Get()->Connect(wxEVT_CL_THEME_CHANGED, wxCommandEventHandler(CscopeTab::OnThemeChanged), NULL, this);
}
Esempio n. 2
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();
}
Esempio n. 3
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;
}