void MainFrame::OnDescEdit(wxHtmlLinkEvent& evt) { if (evt.GetLinkInfo().GetHref() == wxT("edit_key")) { OTL::ObjectPtr<Omega::Registry::IKey> ptrKey(m_strSelection.c_str()); EditKeyDescDlg dialog(this,-1,wxT("")); dialog.m_strName = m_strSelection; dialog.m_strDesc = ptrKey->GetDescription().c_wstr(); if (dialog.ShowModal() == wxID_OK) { ptrKey->SetDescription(Omega::string_t(dialog.m_strDesc.wc_str(),Omega::string_t::npos)); SetKeyDescription(m_pTree->GetSelection()); } } else if (evt.GetLinkInfo().GetHref() == wxT("edit_value")) { OTL::ObjectPtr<Omega::Registry::IKey> ptrKey(m_strSelection.c_str()); EditValueDescDlg dialog(this,-1,wxT("")); dialog.m_strName = m_strSelection; dialog.m_strValue = evt.GetLinkInfo().GetTarget(); dialog.m_strDesc = ptrKey->GetValueDescription(Omega::string_t(dialog.m_strValue.wc_str(),Omega::string_t::npos)).c_wstr(); if (dialog.ShowModal() == wxID_OK) { ptrKey->SetValueDescription(Omega::string_t(dialog.m_strValue.wc_str(),Omega::string_t::npos),Omega::string_t(dialog.m_strDesc.wc_str(),Omega::string_t::npos)); SetValueDescription(dialog.m_strValue,dialog.m_strDesc); } } }
bool register_process(const Omega::string_t& strPrefix, const Omega::string_t& strExeName, bool& bSkipped) { bSkipped = false; #if defined(_WIN32) if (access(strExeName.c_str(),0) != 0) { output("[Missing]\n"); bSkipped = true; return true; } #endif Omega::string_t strOid = Omega::TestSuite::OID_TestProcess.ToString(); OTL::ObjectPtr<Omega::Registry::IKey> ptrKey(strPrefix + "/Objects",Omega::Registry::IKey::OpenCreate); OTL::ObjectPtr<Omega::Registry::IKey> ptrSubKey = ptrKey->OpenKey("Test.Process",Omega::Registry::IKey::OpenCreate); ptrSubKey->SetValue("OID",strOid); ptrSubKey = ptrKey->OpenKey("OIDs/" + strOid,Omega::Registry::IKey::OpenCreate); ptrSubKey->SetValue("Application","CoreTests.TestProcess"); ptrKey = OTL::ObjectPtr<Omega::Registry::IKey>(strPrefix + "/Applications",Omega::Registry::IKey::OpenCreate); ptrSubKey = ptrKey->OpenKey("CoreTests.TestProcess/Activation",Omega::Registry::IKey::OpenCreate); ptrSubKey->SetValue("Path",strExeName); return true; }
QScriptValue ModuleProperties::moduleProperties(QScriptContext *context, QScriptEngine *engine, bool oneValue) { if (Q_UNLIKELY(context->argumentCount() < 2)) { return context->throwError(QScriptContext::SyntaxError, Tr::tr("Function moduleProperties() expects 2 arguments")); } const QScriptValue objectWithProperties = context->thisObject(); const QScriptValue typeScriptValue = objectWithProperties.property(typeKey()); if (Q_UNLIKELY(!typeScriptValue.isString())) { return context->throwError(QScriptContext::TypeError, QLatin1String("Internal error: __type not set up")); } const QScriptValue ptrScriptValue = objectWithProperties.property(ptrKey()); if (Q_UNLIKELY(!ptrScriptValue.isNumber())) { return context->throwError(QScriptContext::TypeError, QLatin1String("Internal error: __internalPtr not set up")); } const void *ptr = reinterpret_cast<const void *>(qscriptvalue_cast<quintptr>(ptrScriptValue)); PropertyMapConstPtr properties; const Artifact *artifact = 0; if (typeScriptValue.toString() == productType()) { properties = static_cast<const ResolvedProduct *>(ptr)->moduleProperties; } else if (typeScriptValue.toString() == artifactType()) { artifact = static_cast<const Artifact *>(ptr); properties = artifact->properties; } else { return context->throwError(QScriptContext::TypeError, QLatin1String("Internal error: invalid type")); } ScriptEngine * const qbsEngine = static_cast<ScriptEngine *>(engine); const QString moduleName = context->argument(0).toString(); const QString propertyName = context->argument(1).toString(); QVariant value; if (qbsEngine->isPropertyCacheEnabled()) value = qbsEngine->retrieveFromPropertyCache(moduleName, propertyName, oneValue, properties); if (!value.isValid()) { if (oneValue) value = PropertyFinder().propertyValue(properties->value(), moduleName, propertyName); else value = PropertyFinder().propertyValues(properties->value(), moduleName, propertyName); const Property p(moduleName, propertyName, value); if (artifact) qbsEngine->addPropertyRequestedFromArtifact(artifact, p); else qbsEngine->addPropertyRequestedInScript(p); // Cache the variant value. We must not cache the QScriptValue here, because it's a // reference and the user might change the actual object. if (qbsEngine->isPropertyCacheEnabled()) qbsEngine->addToPropertyCache(moduleName, propertyName, oneValue, properties, value); } return engine->toScriptValue(value); }
void ModuleProperties::init(QScriptValue objectWithProperties, const void *ptr, const QString &type) { QScriptEngine * const engine = objectWithProperties.engine(); objectWithProperties.setProperty(QLatin1String("moduleProperties"), engine->newFunction(ModuleProperties::js_moduleProperties, 2)); objectWithProperties.setProperty(QLatin1String("moduleProperty"), engine->newFunction(ModuleProperties::js_moduleProperty, 2)); objectWithProperties.setProperty(ptrKey(), engine->toScriptValue(quintptr(ptr))); objectWithProperties.setProperty(typeKey(), type); }
bool unregister_library(const Omega::string_t& strPrefix) { OTL::ObjectPtr<Omega::Registry::IKey> ptrKey(strPrefix + "/Objects"); if (ptrKey->IsKey("Test.Library")) ptrKey->DeleteSubKey("Test.Library"); Omega::string_t strOid = Omega::TestSuite::OID_TestLibrary.ToString(); if (ptrKey->IsKey("OIDs/" + strOid)) ptrKey->DeleteSubKey("OIDs/" + strOid); return true; }
void MainFrame::OnClose(wxCloseEvent& WXUNUSED(evt)) { // Set some defaults... try { OTL::ObjectPtr<Omega::Registry::IKey> ptrKey(L"Local User/Applications/OORegEdit/Layout",Omega::Registry::IKey::OpenCreate); wxPoint pt = GetPosition(); ptrKey->SetValue(L"Top",pt.y); ptrKey->SetValue(L"Left",pt.x); wxSize sz = GetSize(); ptrKey->SetValue(L"Height",sz.y); ptrKey->SetValue(L"Width",sz.x); ptrKey->SetValue(L"SplitWidth",m_pSplitter->GetSashPosition()); ptrKey->SetValue(L"SplitWidth2",m_pSplitter2->GetSashPosition()); ptrKey->SetValue(L"ColWidth0",m_pList->GetColumnWidth(0)); ptrKey->SetValue(L"ColWidth1",m_pList->GetColumnWidth(1)); ptrKey->SetValue(L"ColWidth2",m_pList->GetColumnWidth(2)); ptrKey->SetValue(L"FindKeys",m_bKeys ? 1 : 0); ptrKey->SetValue(L"FindValues",m_bValues ? 1 : 0); ptrKey->SetValue(L"FindData",m_bData ? 1 : 0); ptrKey->SetValue(L"MatchAll",m_bMatchAll ? 1 : 0); ptrKey->SetValue(L"IgnoreCase",m_bIgnoreCase? 1 : 0); ptrKey->SetValue(L"Selection",Omega::string_t(m_strSelection.wc_str(),Omega::string_t::npos)); size_t nFiles = m_fileHistory.GetCount(); ptrKey->SetValue(L"Favourites",nFiles); for (;nFiles>0;--nFiles) { wxString strName = m_fileHistory.GetHistoryFile(nFiles-1); Omega::string_t strVal = m_mapMRU[strName] + L"/" + strName.wc_str(); ptrKey->SetValue(Omega::string_t(L"Favourite{0}") % (nFiles-1),strVal); } } catch (Omega::IException* pE) { pE->Release(); } Destroy(); }
bool unregister_process(const Omega::string_t& strPrefix) { OTL::ObjectPtr<Omega::Registry::IKey> ptrKey(strPrefix + "/Objects"); if (ptrKey->IsKey("Test.Process")) ptrKey->DeleteSubKey("Test.Process"); Omega::string_t strOid = Omega::TestSuite::OID_TestProcess.ToString(); if (ptrKey->IsKey("OIDs/" + strOid)) ptrKey->DeleteSubKey("OIDs/" + strOid); ptrKey = OTL::ObjectPtr<Omega::Registry::IKey>(strPrefix + "/Applications",Omega::Registry::IKey::OpenCreate); if (ptrKey->IsKey("CoreTests.TestProcess")) ptrKey->DeleteSubKey("CoreTests.TestProcess"); return true; }
bool register_library(const Omega::string_t& strPrefix, const Omega::string_t& strLibName, bool& bSkipped) { bSkipped = false; #if defined(_WIN32) if (access(strLibName.c_str(),0) != 0) { output("[Missing]\n"); bSkipped = true; return true; } #endif Omega::string_t strOid = Omega::TestSuite::OID_TestLibrary.ToString(); OTL::ObjectPtr<Omega::Registry::IKey> ptrKey(strPrefix + "/Objects",Omega::Registry::IKey::OpenCreate); OTL::ObjectPtr<Omega::Registry::IKey> ptrSubKey = ptrKey->OpenKey("Test.Library",Omega::Registry::IKey::OpenCreate); ptrSubKey->SetValue("OID",strOid); ptrSubKey = ptrKey->OpenKey("OIDs/" + strOid,Omega::Registry::IKey::OpenCreate); ptrSubKey->SetValue("Library",strLibName); return true; }
static bool do_local_library_test(const Omega::string_t& strPrefix) { output(" %-43s ",("'" + strPrefix + "/' registry key").c_str()); // Test the simplest case OTL::ObjectPtr<Omega::TestSuite::ISimpleTest> ptrSimpleTest(Omega::TestSuite::OID_TestLibrary,Omega::Activation::Library); TEST(ptrSimpleTest); interface_tests(ptrSimpleTest); // Test for local activation ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>(Omega::TestSuite::OID_TestLibrary.ToString()); TEST(ptrSimpleTest); interface_tests(ptrSimpleTest); // Test for local activation ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>("Test.Library"); TEST(ptrSimpleTest); interface_tests(ptrSimpleTest); // Test for local activation with '@local' ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>("Test.Library@local"); TEST(ptrSimpleTest); interface_tests(ptrSimpleTest); // Test for local activation with '@local' ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>(Omega::TestSuite::OID_TestLibrary.ToString() + "@local"); TEST(ptrSimpleTest); interface_tests(ptrSimpleTest); // Test redirecting the registration OTL::ObjectPtr<Omega::Registry::IKey> ptrKey("/Local User/Objects",Omega::Registry::IKey::OpenCreate); OTL::ObjectPtr<Omega::Registry::IKey> ptrSubKey = ptrKey->OpenKey("MyLittleTest",Omega::Registry::IKey::OpenCreate); ptrSubKey->SetValue("CurrentVersion","Test.Library"); ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>("MyLittleTest@local"); TEST(ptrSimpleTest); interface_tests(ptrSimpleTest); // Test it has gone ptrKey->DeleteSubKey("MyLittleTest"); try { ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>("MyLittleTest"); } catch (Omega::INotFoundException* pE) { add_success(); pE->Release(); } // Test for surrogate activation ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>(Omega::TestSuite::OID_TestLibrary,Omega::Activation::Process); TEST(ptrSimpleTest); interface_tests(ptrSimpleTest); ptrSimpleTest.Release(); // Test unregistering TEST(unregister_library(strPrefix)); try { ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>("Test.Library"); } catch (Omega::INotFoundException* pE) { add_success(); pE->Release(); } try { ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>(Omega::TestSuite::OID_TestLibrary); } catch (Omega::INotFoundException* pE) { add_success(); pE->Release(); } // Now test the sand-box surrogate activation /* // Register the library TEST(register_library("/System/Sandbox",strLibName,bSkipped)); if (bSkipped) return true; // Test for surrogate activation ptrSimpleTest = OTL::ObjectPtr<Omega::TestSuite::ISimpleTest>(Omega::TestSuite::OID_TestLibrary,Omega::Activation::Sandbox); TEST(ptrSimpleTest); interface_tests(ptrSimpleTest); TEST(unregister_library("/System/Sandbox"));*/ return true; }
void MainFrame::CreateChildWindows(void) { Omega::uint32_t split_width = 100; Omega::uint32_t split_width2 = 100; Omega::uint32_t col_width[3] = { 100, 100, 100 }; Omega::string_t strSelection; try { // get some defaults... OTL::ObjectPtr<Omega::Registry::IKey> ptrKey(L"Local User/Applications/OORegEdit/Layout"); wxPoint ptPos; ptPos.x = ptrKey->GetValue(L"Left").cast<int>(); ptPos.y = ptrKey->GetValue(L"Top").cast<int>(); SetPosition(ptPos); wxSize sz; sz.x = ptrKey->GetValue(L"Width").cast<int>(); sz.y = ptrKey->GetValue(L"Height").cast<int>(); SetSize(sz); split_width = ptrKey->GetValue(L"SplitWidth").cast<Omega::uint32_t>(); split_width2 = ptrKey->GetValue(L"SplitWidth2").cast<Omega::uint32_t>(); col_width[0] = ptrKey->GetValue(L"ColWidth0").cast<Omega::uint32_t>(); col_width[1] = ptrKey->GetValue(L"ColWidth1").cast<Omega::uint32_t>(); col_width[2] = ptrKey->GetValue(L"ColWidth2").cast<Omega::uint32_t>(); strSelection = ptrKey->GetValue(L"Selection").cast<Omega::string_t>(); m_bKeys = ptrKey->GetValue(L"FindKeys").cast<Omega::bool_t>(); m_bValues = ptrKey->GetValue(L"FindValues").cast<Omega::bool_t>(); m_bData = ptrKey->GetValue(L"FindData").cast<Omega::bool_t>(); m_bMatchAll = ptrKey->GetValue(L"MatchAll").cast<Omega::bool_t>(); m_bIgnoreCase = ptrKey->GetValue(L"IgnoreCase").cast<Omega::bool_t>(); for (int nFiles = ptrKey->GetValue(L"Favourites").cast<int>()-1;nFiles>=0;--nFiles) { Omega::string_t val = ptrKey->GetValue(Omega::string_t(L"Favourite{0}") % nFiles).cast<Omega::string_t>(); size_t pos = val.ReverseFind(L'/'); if (pos != Omega::string_t::npos) { wxString strName(val.Mid(pos+1).c_wstr()); m_fileHistory.AddFileToHistory(strName); m_mapMRU.insert(std::map<wxString,Omega::string_t>::value_type(strName,val.Left(pos))); } } } catch (Omega::IException* e) { e->Release(); } // Create the splitter m_pSplitter2 = new wxSplitterWindow(this,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxNO_BORDER | wxSP_LIVE_UPDATE); m_pSplitter2->SetSashGravity(0.90); m_pSplitter2->SetMinimumPaneSize(50); // Create the second splitter m_pSplitter = new wxSplitterWindow(m_pSplitter2,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxNO_BORDER | wxSP_LIVE_UPDATE); m_pSplitter->SetSashGravity(0.25); m_pSplitter->SetMinimumPaneSize(150); // Create the list and tree m_pList = new wxListCtrl(m_pSplitter,ID_LIST,wxPoint(0,0),wxSize(0,0),wxLC_SORT_ASCENDING | wxLC_REPORT | wxLC_NO_SORT_HEADER | wxLC_EDIT_LABELS); m_pTree = new wxTreeCtrl(m_pSplitter,ID_TREE,wxPoint(0,0),wxSize(0,0),wxTR_DEFAULT_STYLE | wxTR_SINGLE | wxTR_EDIT_LABELS); // Load the imagelist wxImageList* pImagelist = new wxImageList(16,16); pImagelist->Add(wxBitmap(imagelist)); m_pList->SetImageList(pImagelist,wxIMAGE_LIST_SMALL); m_pTree->AssignImageList(pImagelist); // Create the description text field #if defined(__WINDOWS__) OSVERSIONINFO os = {0}; os.dwOSVersionInfoSize = sizeof(os); GetVersionEx(&os); if (os.dwMajorVersion >= 6) m_pDescription = new wxHtmlWindow(m_pSplitter2,ID_DESC,wxPoint(0,0),wxSize(0,0),wxBORDER_SIMPLE | wxHW_SCROLLBAR_NEVER); else m_pDescription = new wxHtmlWindow(m_pSplitter2,ID_DESC,wxPoint(0,0),wxSize(0,0),wxBORDER_SUNKEN | wxHW_SCROLLBAR_NEVER); #else m_pDescription = new wxHtmlWindow(m_pSplitter2,ID_DESC,wxPoint(0,0),wxSize(0,0),wxBORDER_SUNKEN | wxHW_SCROLLBAR_NEVER); #endif wxFont ft = m_pTree->GetFont(); m_pDescription->SetFonts(ft.GetFaceName(),wxT("")); m_pDescription->SetBorders(1); m_pSplitter->SplitVertically(m_pTree, m_pList, split_width); m_pSplitter2->SplitHorizontally(m_pSplitter, m_pDescription, split_width2); // Init the list wxListItem itemCol; itemCol.SetText(_("Name")); m_pList->InsertColumn(0,itemCol); m_pList->SetColumnWidth(0, col_width[0]); itemCol.SetText(_("Type")); m_pList->InsertColumn(1,itemCol); m_pList->SetColumnWidth(1, col_width[1]); itemCol.SetText(_("Data")); m_pList->InsertColumn(2,itemCol); m_pList->SetColumnWidth(2, col_width[2]); try { // Open the registry root OTL::ObjectPtr<Omega::Registry::IKey> ptrKey(L""); // Init the tree TreeItemData* pItem = new TreeItemData(ptrKey,5); wxTreeItemId tree_id = m_pTree->AddRoot(_("Local Computer"),0,0,pItem); pItem->Fill(m_pTree,tree_id); m_pTree->Expand(tree_id); SelectItem(strSelection); } catch (Omega::IException* pE) { wxMessageBox(pE->GetDescription().c_wstr(),_("System Error"),wxOK|wxICON_ERROR,this); pE->Release(); } }