Ejemplo n.º 1
0
void CModuleNode::ItemExpanding()
{
	IModuleVector modules;
	IAttributeVector attributes;
	m_owner->OnLoading();
	m_module->GetModules(modules);
	if (m_nextExpandShouldBeFast)
	{
		m_module->GetAttributes(attributes, true);
		m_nextExpandShouldBeFast = false;
	}
	else
		m_module->GetAttributes(attributes);
	m_owner->OnLoaded(m_module, attributes);
	WTL::CLockWindowUpdate lock(*GetTreeView());
	for (IModuleVector::iterator itr = modules.begin(); itr != modules.end(); ++itr)
	{
		CModuleNode * newNode = new CModuleNode(m_owner, itr->get());
		newNode->InsertBelow(*GetTreeView(), *this);
		newNode->operator ()(newNode->GetModule());
	}
	for (IAttributeVector::iterator itr = attributes.begin(); itr != attributes.end(); ++itr)
	{
		CAttributeNode * newNode = new CAttributeNode(m_owner, itr->get());
		newNode->InsertBelow(*GetTreeView(), *this);
		newNode->operator ()(newNode->GetAttribute(), false, NULL, false);
	}
}
Ejemplo n.º 2
0
    //  Module short cuts  ---
    unsigned GetAttributes(const TCHAR* module, const IAttributeTypeVector & types, IAttributeVector & attributes, bool noRefresh=false, bool noBroadcast=false) const
    {
        clib::recursive_mutex::scoped_lock proc(m_mutex);
        typedef std::pair<std::_tstring, std::_tstring> CommentEclPair;
        typedef std::map<std::_tstring, CommentEclPair> AttrMap;
        AttrMap attrs;
        std::_tstring attributeLabel;
        std::_tstring attributeComment;
        std::_tstring attributeEcl;

        typedef std::vector<std::_tstring> split_vector_type;
        split_vector_type SplitVec; 
        boost::algorithm::split(SplitVec, m_modFile, boost::algorithm::is_any_of("\r\n"), boost::algorithm::token_compress_on);

        for (split_vector_type::const_iterator itr = SplitVec.begin(); itr != SplitVec.end(); ++itr)
        {
            std::_tstring trimmedLine = *itr;
            boost::algorithm::trim(trimmedLine);
            if (boost::algorithm::istarts_with(trimmedLine, IMPORT_MARKER))
            {
                if (attributeLabel.length() && attributeEcl.length())
                {
                    attrs[attributeLabel] = CommentEclPair(attributeComment, attributeEcl);
                }
                boost::algorithm::ireplace_first(trimmedLine, IMPORT_MARKER, _T(""));
                attributeLabel = trimmedLine;
                attributeComment.clear();
                attributeEcl.clear();
            }
            else if (boost::algorithm::istarts_with(trimmedLine, COMMENT_MARKER))
            {
                boost::algorithm::ireplace_first(trimmedLine, COMMENT_MARKER, _T(""));
                attributeComment += trimmedLine + _T("\r\n");
            }
            else
            {
                attributeEcl += *itr + _T("\r\n");
            }
        }
        if (attributeLabel.length() && attributeEcl.length())
        {
            attrs[attributeLabel] = CommentEclPair(attributeComment, attributeEcl);
        }

        for(AttrMap::iterator itr = attrs.begin(); itr != attrs.end(); ++itr)
        {
            int curPos = 0;
            CModuleHelper moduleHelper(itr->first);
            if (boost::algorithm::iequals(moduleHelper.GetModuleLabel(), module))
            {
                StlLinked<IAttribute> attribute = CreateModFileAttribute(this, module, moduleHelper.GetAttributeLabel(), itr->second.second);
                attributes.push_back(attribute);
            }
        }

        std::sort(attributes.begin(), attributes.end(), IAttributeCompare());
        return attributes.size();
    }
Ejemplo n.º 3
0
//bool CBuilderDlg::DoFileOpen(const CString & sPathName) 
//{
//  Help Alligning with BuilderDlg COmpare
//}
bool CAttributeDlg::DoSave(bool attrOnly)
{
    CWaitCursor wait;
    CString ecl;
    m_view.GetText(ecl);

    CString id = m_attribute->GetID();
    CString user = m_attribute->GetModifiedBy();
    CString module = m_attribute->GetModuleQualifiedLabel();
    CString attributeName = m_attribute->GetLabel();
    IAttributeType* attrType = m_attribute->GetType();

    CBookmarksFrame * pFrame = GetBookmarksFrame();
    if (pFrame)
    {
        pFrame->ParseBookmarksEcl((LPCTSTR)ecl, (LPCTSTR)user, (LPCTSTR)id, (LPCTSTR)module, (LPCTSTR)attributeName, attrType);
    }

    if (m_attribute->SetText(ecl))
    {
        //  Save local item for history  ---
        boost::filesystem::path path;
        GetIConfig(QUERYBUILDER_CFG)->GetEnvironmentFolder(path);
        path /= stringToPath(m_attribute->GetModuleQualifiedLabel());
        boost::filesystem::create_directories(path);
        path /= stringToPath(m_attribute->GetLabel());
        boost::filesystem::create_directories(path);

        CTime t = CTime::GetCurrentTime();
        std::_tstring now = t.FormatGmt(_T("%Y-%m-%dT%H_%M_%SZ.ecl"));
        path /= stringToPath(now);

        CUnicodeFile file;
        file.Create(pathToWString(path).c_str());
        file.Write(ecl);
        file.Close();
        //  ---  ---  ---

        m_view.SetSavePoint();
        IAttributeVector attrs;
        Dali::CEclExceptionVector errors;
        m_attribute->PreProcess(PREPROCESS_SAVE, NULL, attrs, errors);
        SendMessage(CWM_SUBMITDONE, Dali::WUActionCheck, (LPARAM)&errors);
        if (attrs.size())
        {
            if (!m_migrator)
                m_migrator = CreateIMigration(::AttachRepository(), false);
            m_migrator->Stop();
            for(IAttributeVector::const_iterator itr = attrs.begin(); itr != attrs.end(); ++itr)
                m_migrator->AddToRep(m_attribute->GetModule()->GetRootModule(), itr->get()->GetAsHistory(), (boost::_tformat(_T("Preprocessed (%1%) from %2%.")) % PREPROCESS_LABEL[PREPROCESS_SAVE] % m_attribute->GetQualifiedLabel()).str().c_str(), true);
            m_migrator->Start();
            SetTimer(0, 200);
        }
        return true;
    }
    return false;
}
Ejemplo n.º 4
0
 //  Attribute short cuts  ---
 IAttribute * GetAttribute(const TCHAR* module, const TCHAR* label, IAttributeType * type, int version, bool sandbox, bool text, bool placeholder) const
 {
     clib::recursive_mutex::scoped_lock proc(m_mutex);
     IAttributeVector attributes;
     GetAttributes(module, attributes);
     for (IAttributeVector::iterator itr = attributes.begin(); itr != attributes.end(); ++itr)
     {
         if (boost::algorithm::iequals(itr->get()->GetLabel(), label))
         {
             return itr->get();
         }
     }
     return NULL;
 }
Ejemplo n.º 5
0
    bool Save(IAttributeVector & attributes, bool noBroadcast = false)
    {
        clib::recursive_mutex::scoped_lock proc(m_mutex);
        for(IAttributeVector::iterator itr = attributes.begin(); itr != attributes.end(); ++itr)
        {
            std::_tstring newModFile;
            bool inCurrentAttr = false;
            bool alreadyExisted = false;

            typedef std::vector<std::_tstring> split_vector_type;
            split_vector_type SplitVec; 
            boost::algorithm::split(SplitVec, m_modFile, boost::algorithm::is_any_of("\r\n"), boost::algorithm::token_compress_on);

            for (split_vector_type::const_iterator itr2 = SplitVec.begin(); itr2 != SplitVec.end(); ++itr2)
            {
                std::_tstring line = *itr2;
                std::_tstring origline = line;
                if (boost::algorithm::istarts_with(line, IMPORT_MARKER))
                {
                    boost::algorithm::ireplace_first(line, IMPORT_MARKER, _T(""));
                    boost::algorithm::trim(line);
                    inCurrentAttr = boost::algorithm::iequals(line, itr->get()->GetQualifiedLabel());
                    if (inCurrentAttr)
                    {
                        newModFile += (boost::_tformat(_T("%1%%2%\r\n%3%\r\n")) % IMPORT_MARKER % itr->get()->GetQualifiedLabel() % itr->get()->GetText(true, noBroadcast)).str();
                        alreadyExisted = true;
                        continue;
                    }
                }
                if (!inCurrentAttr)
                {
                    newModFile += origline + _T("\r\n");
                }
            }
            if (!alreadyExisted)
                newModFile += (boost::_tformat(_T("%1%%2%\r\n%3%\r\n")) % IMPORT_MARKER % itr->get()->GetQualifiedLabel() % itr->get()->GetText(true, noBroadcast)).str();
            m_modFile = newModFile.c_str();
        }

        CUnicodeFile file;
        if (file.Create(pathToWString(m_path).c_str()))
        {
            file.Write(m_modFile);
            file.Close();
        }

        return true;
    }
Ejemplo n.º 6
0
    bool Delete()
    {
        IModuleVector children;
        GetModules(children);
        for(IModuleVector::iterator itr = children.begin(); itr != children.end(); ++itr)
            itr->get()->Delete();

        IAttributeVector childAttrs;
        GetAttributes(childAttrs, true);
        for(IAttributeVector::iterator itr = childAttrs.begin(); itr != childAttrs.end(); ++itr)
            itr->get()->Refresh(false, NULL, true);

        if (m_repository->DeleteModule(GetQualifiedLabel()))
        {
            DeleteModule(this);
            return true;
        }
        return false;
    }
Ejemplo n.º 7
0
void CMainFrame::OnFindServices()
{
    IAttributeVector repAttrs;
    std::_tstring changedSince;
    m_repositoryDlg.m_repositoryView->m_repRHS->FindAttributes(_T("--SOAP--"), _T(""), _T(""), SEARCHMODE_PLAIN, false, false, false, false, changedSince.c_str(), repAttrs);
    std::_tstring items;
    for (IAttributeVector::const_iterator itr = repAttrs.begin(); itr != repAttrs.end(); ++itr)
    {
        if (boost::algorithm::starts_with(itr->get()->GetQualifiedLabel(), _T("Trash")) ||
                boost::algorithm::starts_with(itr->get()->GetQualifiedLabel(), _T("zz_")))
            continue;
        if (!items.empty())
            items += _T("\r\n");
        items += itr->get()->GetQualifiedLabel();
    }

    repAttrs.clear();
    m_repositoryDlg.m_repositoryView->m_repRHS->FindAttributes(_T("--LIBRARY--"), _T(""), _T(""), SEARCHMODE_PLAIN, false, false, false, false, changedSince.c_str(), repAttrs);
    for (IAttributeVector::const_iterator itr = repAttrs.begin(); itr != repAttrs.end(); ++itr)
    {
        if (boost::algorithm::starts_with(itr->get()->GetQualifiedLabel(), _T("Trash")) ||
                boost::algorithm::starts_with(itr->get()->GetQualifiedLabel(), _T("zz_")))
            continue;
        if (!items.empty())
            items += _T("\r\n");
        items += itr->get()->GetQualifiedLabel();
    }

    m_dependees.SetServices(items);
}