Example #1
0
xmlNode* RheiaConfigurationManager::AddRootChildren( const wxString& path, const wxString& property, const wxString& propertyValue )
{
    xmlNode *ret;
    xmlNode* child = m_root->children;

    while ( child != NULL )
    {
        wxString ChildName = RheiaC2U( (const char*) child->name );

        if ( ChildName.IsSameAs( path ) )
        {
            xmlAttr *prop = xmlHasProp( child , rxU2C( property ) );
            if ( prop )
            {
                wxString propVal = RheiaXmlManager::RheiaNodeGetContent( prop->children );
                if ( propVal.IsSameAs( propertyValue) )
                    return child;

            }
        }

        child = child->next;
    }

    ret = xmlNewNode( NULL , rxU2C( path ) );
    xmlNewProp( ret , rxU2C( property ), rxU2C( propertyValue ) );
    ret = xmlAddChild( m_root , ret );
    return ret;
}
Example #2
0
void RheiaConfigurationManager::Write(const wxString& path,  const RheiaStringStringMap& as)
{
    wxString key(path);
    xmlNode* node;
    node = RheiaXmlManager::Get()->AssertPath(key,m_root);
    xmlNode* e = RheiaXmlManager::Get()->GetUniqElement( node , key );

    /* First check if the node exist */
    xmlNode *child = e->children;
    while ( child != NULL )
    {
        wxString ChildName = RheiaC2U( (const char *) child->name );
        xmlNode* sub = child->next;
        if ( ChildName.IsSameAs( wxT("variable") ) )
        {
            xmlReplaceNode( child , NULL );
            child = NULL;
        }
        child = sub;
    }

    RheiaStringStringMap::const_iterator it = as.begin();
    for( ; it != as.end() ; ++it )
    {
        child = xmlNewNode( NULL , (const xmlChar*) "variable" );
        xmlNewChild(child , NULL , (const xmlChar*) "name" , rxU2C(it->first) );
        xmlNewChild(child , NULL , (const xmlChar*) "value" , rxU2C(it->second) );
        xmlAddChild( e , child );
    }
}
Example #3
0
bool RheiaPackageManagedFile::DoWriteToNode( xmlNode* parent )
{
    xmlNode* child = parent->children;

    while( child != NULL )
    {
        wxString cname = RheiaC2U( (const char*) child->name );
        xmlNode* sub = child->next;

        if( cname.IsSameAs( wxT("name") ) || cname.IsSameAs( wxT("path") ) || cname.IsSameAs( wxT("remove") ) )
        {
            xmlReplaceNode(child , NULL);
        }

        child = sub;
    }

    wxString rem = (m_remove ? wxT("true") : wxT("false"));
    xmlNewChild( parent , NULL , (const xmlChar*) "name" , rxU2C(m_name) );
    xmlNewChild( parent , NULL , (const xmlChar*) "path" , rxU2C(m_path) );
    xmlNewChild( parent , NULL , (const xmlChar*) "type" , rxU2C(m_type) );
    xmlNewChild( parent , NULL , (const xmlChar*) "remove" , rxU2C(rem) );

    return true;
}
Example #4
0
void RheiaConfigurationManager::ReadPerspective( const wxString& path, wxAuiManager *LayoutManager, const wxString& pName )
{
    /* First get the node in which to write the plugin */
    wxString key(path + wxT("/perspectives"));
    xmlNode* node;
    node = RheiaXmlManager::Get()->AssertPath(key,m_root);
    xmlNode* e = RheiaXmlManager::Get()->GetUniqElement( node , key );

    xmlNode *child = e->children;

    while ( child != NULL )
    {
        wxString ChildName = RheiaC2U( (const char*) child->name );

        if ( ChildName.IsSameAs( ConfigManagerPaths::Perspective ) )
        {
            wxString pname = RheiaC2U( (const char*) xmlGetProp( child ,
                                       rxU2C(ConfigManagerPaths::LayoutAttributes::LayoutName) ) ) ;

            if ( pname.IsSameAs( pName ) )
            {
                wxString perspective = LayoutManager->SavePerspective();
                wxString path = wxT("/perspective_string");
                perspective = RheiaXmlManager::Get()->Read( path , child, perspective );
                LayoutManager->LoadPerspective( perspective );
                return;
            }
        }
        child = child->next;
    }
}
Example #5
0
void RheiaConfigurationManager::WritePerspective( const wxString& path, const wxString& pName, const wxString& pValue, bool overwrite_existing )
{
    /* First get the node in which to write the plugin */
    wxString key(path + wxT("/perspectives"));
    xmlNode* node;
    node = RheiaXmlManager::Get()->AssertPath(key,m_root);
    xmlNode* e = RheiaXmlManager::Get()->GetUniqElement( node , key );

    xmlNode *child = e->children;

    while ( child != NULL )
    {
        wxString ChildName = RheiaC2U( (const char*) child->name );

        if ( ChildName.IsSameAs( ConfigManagerPaths::Perspective ) )
        {
            wxString pname = RheiaC2U( (const char*) xmlGetProp( child ,
                                       rxU2C(ConfigManagerPaths::LayoutAttributes::LayoutName) ) ) ;

            if ( pname.IsSameAs( pName ) )
            {
                if ( overwrite_existing )
                {
                    xmlReplaceNode( child , NULL );
                    break;
                }
                else
                    return;
            }
        }
        child = child->next;
    }

    child = xmlNewNode( NULL , rxU2C(ConfigManagerPaths::Perspective ) );
    xmlNewProp( child , rxU2C(ConfigManagerPaths::LayoutAttributes::LayoutName ) ,
                rxU2C(pName ));

    xmlAddChild( e , child );

    wxString perspective = pValue;
    key = wxT("/perspective_string");
    RheiaXmlManager::Get()->Write( key , perspective , child );
}
Example #6
0
wxArrayString RheiaConfigurationManager::ListRootChildrenNames(const wxString& path, const wxString& property)
{
    wxArrayString ret;
    xmlNode* child = m_root->children;

    while ( child != NULL )
    {
        wxString ChildName = RheiaC2U( (const char*) child->name );

        if ( ChildName.IsSameAs( path ) )
        {
            xmlAttr *prop = xmlHasProp( child , rxU2C( property ) );
            if ( prop )
            {
                wxString propValue = RheiaXmlManager::RheiaNodeGetContent( prop->children );
                ret.Add( propValue );
            }
        }

        child = child->next;
    }
    return ret;
}