void wxRxObjectContainer::SendChildren(const wxGxObjectList &Children, long nSourceId, int nClientId)
{
    wxGISNetworkService* pNetSrv = GetNetworkService();
    wxCHECK_RET(pNetSrv, wxT("wxGISNetworkService pointer is null"));

    wxNetMessage msgout(enumGISNetCmdCmd, enumGISCmdGetChildren, enumGISPriorityHighest, nSourceId);
    wxXmlNode* pRootNode = msgout.GetXMLRoot();
    wxXmlNode* pChildrenNode = new wxXmlNode(pRootNode, wxXML_ELEMENT_NODE, wxT("children"));
    wxGxObjectList::const_iterator iter;
    for(iter = Children.begin(); iter != Children.end(); ++iter)
    {
        wxGxObject *pGxObject = *iter;
        wxRxObject *pRxObject = dynamic_cast<wxRxObject*>(pGxObject);
        if(pGxObject && pRxObject)
        {
            wxXmlNode *pNode = new wxXmlNode(pChildrenNode, wxXML_ELEMENT_NODE, wxT("child"));
            pNode->AddAttribute(wxT("class"), pRxObject->GetClassName()); 
            pNode->AddAttribute(wxT("id"), wxString::Format(wxT("%d"), pGxObject->GetId())); 
            pNode->AddAttribute(wxT("name"), pGxObject->GetName() ); 
            pNode->AddAttribute(wxT("path"), wxString(pGxObject->GetPath(), wxConvUTF8) ); 

            wxXmlNode* pDecNode = pRxObject->GetXmlDescription();
            if(pDecNode)
                pNode->AddChild(pDecNode);
        }
    }
    pNetSrv->SendNetMessage(msgout, nClientId);
}
示例#2
0
void wxGxTreeViewBase::OnItemExpanding(wxTreeEvent& event)
{
	wxTreeItemId item = event.GetItem();

	if(!item.IsOk())
		return;

	wxGxTreeItemData* pData = (wxGxTreeItemData*)GetItemData(item);
	if(pData != NULL)
	{
        wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(pData->m_nObjectID);
		wxGxObjectContainer* pGxObjectContainer = wxDynamicCast(pGxObject, wxGxObjectContainer);
		if(pGxObjectContainer != NULL)
		{
			wxBusyCursor wait;
			if(pGxObjectContainer->HasChildren() && pGxObjectContainer->AreChildrenViewable())
			{
				if(pData->m_bExpandedOnce == false)
				{
					const wxGxObjectList ObjectList = pGxObjectContainer->GetChildren();
                    wxGxObjectList::const_iterator iter;
                    for (iter = ObjectList.begin(); iter != ObjectList.end(); ++iter)
                    {
                        wxGxObject *current = *iter;
						AddTreeItem(current, item);//false
                        m_pCatalog->ObjectAdded(current->GetId());
                    }
					pData->m_bExpandedOnce = true;
                    SetItemHasChildren(item, GetChildrenCount(item, false) > 0);
                    SortChildren(item);
					return;                    
                }
				else
					return;
			}
			else
			{
				SetItemHasChildren(item, false);
				return;
			}
		}
	}
	SetItemHasChildren(item, false);
}