void wxGxContentView::OnEndLabelEdit(wxListEvent& event)
{
    //event.Skip();
    if ( event.GetLabel().IsEmpty() )
    {
        event.Veto();
		return;
    }

	LPITEMDATA pItemData = (LPITEMDATA)event.GetData();
	if(pItemData == NULL)
	{
		event.Veto();
		return;
	}

    wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(pItemData->nObjectID);
	IGxObjectEdit* pObjEdit =  dynamic_cast<IGxObjectEdit*>(pGxObject);
	if(pObjEdit == NULL)
	{
		event.Veto();
		return;
	}
	if(pObjEdit->Rename(event.GetLabel()))
	{
    	m_pCatalog->ObjectChanged(pGxObject->GetId());
	}
    else
    {
		event.Veto();
		wxMessageBox(_("Rename failed!"), _("Error"), wxICON_ERROR | wxOK );

        SORTDATA sortdata = { m_bSortAsc, m_currentSortCol };
        SortItems(GxObjectCVCompareFunction, (long)&sortdata);
        SetColumnImage(m_currentSortCol, m_bSortAsc ? 0 : 1);

		return;
    }
}
Beispiel #2
0
void wxGxTreeView::OnEndLabelEdit(wxTreeEvent& event)
{
    if ( event.GetLabel().IsEmpty() )
    {        
        event.Veto();
		return;
    }

	wxTreeItemId item = event.GetItem();
	if(!item.IsOk())
	{
		event.Veto();
		return;
	}
	wxGxTreeItemData* pData = (wxGxTreeItemData*)GetItemData(event.GetItem());
	if(pData == NULL)
	{
		event.Veto();
		return;
	}
    
    wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(pData->m_nObjectID);
	IGxObjectEdit* pObjEdit =  dynamic_cast<IGxObjectEdit*>(pGxObject);
	if(pObjEdit == NULL)
	{
		event.Veto();
		return;
	}

	if(!pObjEdit->Rename(event.GetLabel()))
	{
		event.Veto();
		wxMessageBox(_("Rename error!"), _("Error"), wxICON_ERROR | wxOK );
		return;
	}

	m_pCatalog->ObjectChanged(pGxObject->GetId());
}