void CollectionsPanel::OnMyCollectionsBeginLabelEdit( wxTreeEvent& event ) { // this just makes the code below more generic in case we want to abstract it later SortTreeCtrl* treeCtrl = m_MyCollectionsTreeCtrl; wxTreeItemId item = event.GetItem(); if ( !item ) { event.Veto(); return; } AssetCollectionItemData* baseData = GetItemData( m_MyCollectionsTreeCtrl, item ); if ( !baseData ) { event.Veto(); return; } AssetCollection* collection = baseData->GetCollection<AssetCollection>(); if ( !collection || !collection->CanRename() ) { event.Veto(); return; } treeCtrl->SetItemText( item, collection->GetName() ); //treeCtrl->EditLabel( item ); event.Skip(); }
void CollectionsPanel::OnMyCollectionsMenu( wxTreeEvent& event ) { SortTreeCtrl* treeCtrl = m_MyCollectionsTreeCtrl; wxTreeItemId item = event.GetItem(); if ( !item ) { return; } wxTreeItemId rootID = treeCtrl->GetRootItem(); if( item != rootID ) { treeCtrl->SelectItem( item ); AssetCollectionItemData* baseData = GetItemData( treeCtrl, item ); if ( !baseData ) { return; } AssetCollection* collection = baseData->GetCollection<AssetCollection>(); if ( collection ) { std::set< Helium::Path > paths; m_VaultFrame->GetSelectedPaths( paths ); wxMenu menu; menu.Append( ID_ShowCollection, VaultMenu::Label( ID_ShowCollection ), VaultMenu::Label( ID_ShowCollection ), wxITEM_NORMAL ); menu.AppendSeparator(); menu.Append( ID_AddToCollection, VaultMenu::Label( ID_AddToCollection ), VaultMenu::Label( ID_AddToCollection ), wxITEM_NORMAL ); menu.Append( ID_RemoveFromCollection, VaultMenu::Label( ID_RemoveFromCollection ), VaultMenu::Label( ID_RemoveFromCollection ), wxITEM_NORMAL ); menu.AppendSeparator(); menu.Append( ID_ImportIntoCollection, VaultMenu::Label( ID_ImportIntoCollection ), VaultMenu::Label( ID_ImportIntoCollection ), wxITEM_NORMAL ); menu.Append( ID_SaveCollection, VaultMenu::Label( ID_SaveCollection ), VaultMenu::Label( ID_SaveCollection ), wxITEM_NORMAL ); menu.AppendSeparator(); menu.Append( ID_RenameCollection, VaultMenu::Label( ID_RenameCollection ), VaultMenu::Label( ID_RenameCollection ), wxITEM_NORMAL ); //menu.Append( ID_CloseCollection, VaultMenu::Label( ID_CloseCollection ), VaultMenu::Label( ID_CloseCollection ), wxITEM_NORMAL ); menu.Append( ID_DeleteCollection, VaultMenu::Label( ID_DeleteCollection ), VaultMenu::Label( ID_DeleteCollection ), wxITEM_NORMAL ); menu.Enable( ID_AddToCollection, !collection->IsDynamic() && !paths.empty() ); menu.Enable( ID_RemoveFromCollection, !collection->IsDynamic() && !paths.empty() ); menu.Enable( ID_ImportIntoCollection, !collection->IsDynamic() ); menu.Enable( ID_SaveCollection, true ); menu.Enable( ID_RenameCollection, collection->CanRename() ); //menu.Enable( ID_CloseCollection, !collection->IsTemporary() ); menu.Enable( ID_DeleteCollection, !collection->IsTemporary() ); // Show the menu PopupMenu( &menu ); } } }
void CollectionsPanel::OnMyCollectionsEndLabelEdit( wxTreeEvent& event ) { // this just makes the code below more generic in case we want to abstract it later SortTreeCtrl* treeCtrl = m_MyCollectionsTreeCtrl; event.Veto(); if( event.IsEditCancelled() ) { return; } wxTreeItemId item = event.GetItem(); if ( !item ) { return; } AssetCollectionItemData* baseData = GetItemData( treeCtrl, item ); if ( !baseData ) { return; } AssetCollection* collection = baseData->GetCollection<AssetCollection>(); if ( !collection || !collection->CanRename() ) { return; } wxString labelValue = event.GetLabel(); labelValue.Trim(true); // trim white-space right labelValue.Trim(false); // trim white-space left if ( labelValue.empty() ) { return; } tstring errors; collection->Freeze(); bool renameResult = m_CollectionManager->RenameCollection( collection, (const wxChar*)labelValue.c_str(), errors ); collection->Thaw(); if ( !renameResult ) { wxMessageBox( errors.c_str(), TXT( "MyCollection Name Already In Use" ), wxCENTER | wxICON_WARNING | wxOK, this ); //treeCtrl->EditLabel( item ); return; } }