⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 configtooldoc.cpp

📁 ecos实时嵌入式操作系统
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    }    else        return FALSE;    return TRUE;}bool ecConfigToolDoc::OnOpenDocument(const wxString& filename){    wxGetApp().GetSettings().m_lastFilename = filename;    wxBusyCursor cursor;    bool rc=FALSE; // Assume the worst    CdlInterpreter NewCdlInterp = NULL;    CdlConfiguration NewCdlConfig = NULL;    // We have to open the repository or m_CdlPkgData and co. won't be set    if (!OpenRepository())        return FALSE;    wxString str;    str.Printf(_("Opening save file %s"), (const wxChar*) filename);    wxGetApp().SetStatusText(str);    EnableCallbacks(FALSE);    try    {        NewCdlInterp = CdlInterpreterBody::make ();        NewCdlConfig = CdlConfigurationBody::load ((const wxChar*) filename, m_CdlPkgData, NewCdlInterp, &CdlLoadErrorHandler, &CdlLoadWarningHandler);        rc = TRUE;    }    catch (CdlStringException exception)    {        wxString msg;        msg.Printf(_("Error opening eCos configuration:\n\n%s"), exception.get_message ().c_str ());        wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);    }    catch (...)    {        wxString msg;        msg.Printf(_("Error opening eCos configuration"));        wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);    }    if (rc)    {        rc=FALSE;        // check the new configuration        wxASSERT (NewCdlConfig->check_this (cyg_extreme));        // switch to the new configuration        delete m_CdlConfig;        delete m_CdlInterp;        m_CdlInterp = NewCdlInterp;        m_CdlConfig = NewCdlConfig;        //SetPathName (lpszPathName, TRUE); // called to ensure that MLTDir() will work in this function        AddAllItems (); // must precede NewMemoryLayout() [CurrentLinkerScript() calls Find()]        // load the memory layout from the build tree        // TODO        NewMemoryLayout (MLTDir ());        UpdateFailingRuleCount();        SetFilename(filename);	// UpdateBuildInfo(); // Don't create directories on opening file        rc = TRUE;        ecConfigToolHint hint(NULL, ecFilenameChanged);        UpdateAllViews (NULL, & hint);    }    // re-enable the transaction callback    EnableCallbacks(TRUE);    SetDocumentSaved(TRUE); // Necessary or it will pop up the Save As dialog    wxGetApp().SetStatusText(wxEmptyString, FALSE);    return rc;}void ecConfigToolDoc::AddAllItems(){    ecConfigTreeCtrl* treeCtrl = wxGetApp().GetMainFrame()->GetTreeCtrl();    // Ensure there's no dangling pointer    wxGetApp().GetMainFrame()->GetPropertyListWindow()->Fill(NULL);    treeCtrl->DeleteAllItems();    m_strMemoryLayoutFolder = wxT("");    m_strLinkerScriptFolder = wxT("");    // Add the root item    ecConfigItem* item = NULL;    wxTreeItemId rootId = treeCtrl->AddRoot(_(""), -1, -1, new ecTreeItemData(item = new ecConfigItem(NULL, _("Configuration"), ecContainer)));    item->SetTreeItem(rootId);    item->UpdateTreeItem(* treeCtrl);    item->SetDescription(_("The root node for all configurable items"));    m_items.Append(item);    AddContents(m_CdlConfig, item);    treeCtrl->Expand(rootId);    // check that exactly one radio button in each group is enabled    CheckRadios ();    // update the rules (conflicts) view    UpdateFailingRuleCount ();    if( ! wxGetApp().GetMainFrame() || ! wxGetApp().GetMainFrame()->GetConflictsWindow() ||        ! wxGetApp().GetMainFrame()->GetConflictsWindow()->IsShown())    {        // log all conflicts        //	LogConflicts (m_CdlConfig->get_structural_conflicts ()); // relating to package availability - ignore for now        LogConflicts (m_CdlConfig->get_all_conflicts ());    }    wxGetApp().GetTreeCtrl()->SelectItem(wxGetApp().GetTreeCtrl()->GetRootItem());    //ecConfigToolHint hint(item, ecValueChanged);    ecConfigToolHint hint(NULL, ecSelChanged);    UpdateAllViews (NULL, & hint);    if(GetItems().Number()>0){        wxGetApp().GetTreeCtrl()->Expand(rootId);    }    wxGetApp().GetTreeCtrl()->SetFocus();}void ecConfigToolDoc::AddContents (const CdlContainer container, ecConfigItem *pParent){    // determine the container contents    const std::vector<CdlNode>& contents = container->get_contents ();    std::vector<CdlNode>::const_iterator node_i;    for (node_i = contents.begin (); node_i != contents.end (); node_i++)    {        const CdlNode node = * node_i;        const CdlPackage pkg = dynamic_cast<CdlPackage> (node);        const CdlComponent comp = dynamic_cast<CdlComponent> (node);        const CdlOption opt = dynamic_cast<CdlOption> (node);        const CdlContainer contnr = dynamic_cast<CdlContainer> (node);        // if the node in the container is a package, component or option        // then it is visible and should be added to the tree        if  (0 != pkg) // the node is a package        {            ecConfigItem * pItem = AddItem (pkg, pParent); // add the package            AddContents (pkg, pItem); // add the package contents        }        else if (0 != comp) // the node is a component        {            ecConfigItem * pItem = AddItem (comp, pParent); // add the component            AddContents (comp, pItem); // add the component contents        }        else if (0 != opt) // the node is an option            AddItem (opt, pParent); // add the option        else if (0 != contnr) // if the node is a container            AddContents (contnr, pParent); // add the container contents        // ignore nodes of any other class    }}ecConfigItem * ecConfigToolDoc::AddItem (const CdlUserVisible vitem, ecConfigItem * pParent){    ecConfigItem * pItem = new ecConfigItem (pParent, vitem);    m_items.Append(pItem);    if (vitem->get_name () == "CYGHWR_MEMORY_LAYOUT")    {        wxASSERT (m_strMemoryLayoutFolder.IsEmpty ());        m_strMemoryLayoutFolder = vitem->get_owner ()->get_directory().c_str ();#ifdef __WXMSW__        m_strMemoryLayoutFolder.Replace(wxT("/"),wxT("\\"));#endif        //TRACE (_T("Found memory layout folder: %s\n"), m_strMemoryLayoutFolder);    }    if (vitem->get_name () == "CYGBLD_LINKER_SCRIPT")    {        wxASSERT (m_strLinkerScriptFolder.IsEmpty ());        m_strLinkerScriptFolder = vitem->get_owner ()->get_directory().c_str ();#ifdef __WXMSW__        m_strLinkerScriptFolder.Replace(wxT("/"),wxT("\\"));#endif        //TRACE (_T("Found linker script folder: %s\n"), m_strLinkerScriptFolder);        // the CDL hardware template name will eventually become the target name,        // but for now we must deduce the target name from the linker script file name        const CdlValuable valuable = dynamic_cast<CdlValuable> (vitem);        ecFileName strLinkerScript (m_strPackagesDir, m_strLinkerScriptFolder, wxString (valuable->get_value ().c_str ()));#ifdef __WXMSW__        strLinkerScript.Replace (wxT("/"), wxT("\\"));#endif        if(!strLinkerScript.Exists ()){            wxString msg;            msg.Printf(wxT("%s does not exist\n"), (const wxChar*) strLinkerScript);            wxGetApp().Log(msg);        }        //TRACE (_T("Target '%s' selected\n"), strLinkerScript.Tail ().Root (), pItem->Macro());    }    //TRACE(_T("Created new item from cdl: "));    //pItem->DumpItem();    return pItem;}void ecConfigToolDoc::CheckRadios(){    int nItem;    for(nItem=0; nItem < GetItems().Number() ; nItem++)    {        ecConfigItem *pItem=(ecConfigItem*) GetItems()[nItem];        if(pItem->HasRadio () && pItem==pItem->FirstRadio())        {            wxString strMsg;            ecConfigItem *pFirstSet=NULL;            ecConfigItem *pSibItem;            for ( pSibItem=pItem; pSibItem; pSibItem = pSibItem->NextRadio() )            {                if(pSibItem->IsEnabled ())                {                    if(pFirstSet)                    {                        strMsg += wxT(" ");                        strMsg += pSibItem->GetMacro ();                    } else                    {                        pFirstSet = pSibItem;                    }                }            }            if ( !strMsg.IsEmpty() )            {                wxString msg2;                msg2.Printf(_("%s, multiple radio buttons are set: %s%s"),                    (const wxChar*) pItem->GetMacro(), (const wxChar*) pFirstSet->GetMacro(), (const wxChar*) strMsg);                wxGetApp().Log(msg2);            } else if ( !pFirstSet )            {                wxString msg2;                msg2.Printf(_("%s, no radio buttons are set"), (const wxChar*) pItem->GetMacro());                wxGetApp().Log(msg2);            }        }    }}// Find the ecConfigItem referencing the given CdlValuableecConfigItem * ecConfigToolDoc::Find (CdlValuable v){    int nItem;    for (nItem=0 ; nItem < m_items.Number() ; nItem++)    {        ecConfigItem *pItem = (ecConfigItem*) m_items[nItem];        if( v == pItem->GetCdlValuable() )        {            return pItem;        }    }    return NULL;}ecConfigItem * ecConfigToolDoc::Find(const wxString & strWhat, ecWhereType where){    int nItem;    for (nItem=0 ; nItem < m_items.Number() ; nItem++)    {        ecConfigItem *pItem = (ecConfigItem*) m_items[nItem];        if (pItem->StringValue(where) == strWhat)        {            return pItem;        }    }    return NULL;}// a trivial CDL load error handlervoid ecConfigToolDoc::CdlLoadErrorHandler (std::string message){    wxGetApp().Log(message.c_str());};// a trivial CDL load warning handlervoid ecConfigToolDoc::CdlLoadWarningHandler (std::string message){    wxGetApp().Log(message.c_str());};// a trivial CDL parse error handlervoid ecConfigToolDoc::CdlParseErrorHandler (std::string message){    wxGetApp().Log(message.c_str());};// a trivial CDL parse warning handlervoid ecConfigToolDoc::CdlParseWarningHandler (std::string message){    wxGetApp().Log(message.c_str());};void ecConfigToolDoc::CloseRepository(){    if(m_bRepositoryOpen){        // delete the libCDL objects with the document        EnableCallbacks(FALSE); // first disable the transaction handler        delete m_CdlConfig; m_CdlConfig = NULL;        delete m_CdlInterp; m_CdlInterp = NULL;        delete m_CdlPkgData; m_CdlPkgData = NULL;        m_bRepositoryOpen=FALSE;    }}bool ecConfigToolDoc::OpenRepository(const wxString& pszRepository /* = wxEmptyString */, bool bPromptInitially/* =FALSE */){    ecMainFrame* mainFrame = wxGetApp().GetMainFrame();    if(!m_bRepositoryOpen)    {        UpdateFailingRuleCount();        ecFileName strNewRepository;        while(!m_bRepositoryOpen)        {            if(bPromptInitially)            {                ecChooseRepositoryDialog dlg(wxGetApp().GetTopWindow());                if(wxID_CANCEL==dlg.ShowModal()){                    wxGetApp().SetStatusText(wxEmptyString);                    return FALSE;                }#ifdef __WXMSW__                // Ensure display gets updated                ::UpdateWindow((HWND) mainFrame->GetHWND());                //wxYield();#endif                strNewRepository=dlg.GetFolder();            } else            {                // Use what came in as parameter or what was found in registry                if (!pszRepository.IsEmpty())                    strNewRepository = pszRepository;                else                    strNewRepository = m_strRepository;                bPromptInitially=TRUE;            }            wxString str;            if (strNewRepository.IsEmpty())                str.Printf(_("Opening repository..."));            else                str.Printf(_("Opening repository %s..."), (const wxChar*) strNewRepository);            wxGetApp().SetStatusText(str);            CdlPackagesDatabase NewCdlPkgData = NULL;            CdlInterpreter      NewCdlInterp  = NULL;            CdlConfiguration    NewCdlConfig  = NULL;            wxString strNewPackagesDir;            EnableCallbacks(FALSE); // disable transaction callbacks until the config tree is regenerated

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -