Ejemplo n.º 1
0
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;
    }
}
Ejemplo n.º 2
0
void CollectionsPanel::UpdateCollection( CollectionAction action )
{
    SortTreeCtrl* treeCtrl = m_MyCollectionsTreeCtrl;
    wxTreeItemId rootID = treeCtrl->GetRootItem();

    wxTreeItemId item = treeCtrl->GetSelection();
    if( !item || item == rootID )
    {
        return;
    }

    AssetCollectionItemData* baseData = GetItemData( treeCtrl, item );
    if ( !baseData )
    {
        return;
    }

    AssetCollection* collection = baseData->GetCollection<AssetCollection>();
    if ( !collection || collection->IsDynamic() )
    {
        return;
    }

    std::set< Helium::Path > paths;
    m_VaultFrame->GetSelectedPaths( paths );

    if ( !paths.empty() )
    {
        collection->Freeze();
        for ( std::set< Helium::Path >::const_iterator itr = paths.begin(), end = paths.end(); itr != end; ++itr )
        {
            if ( (*itr).IsFile() )
            {
                switch ( action )
                {
                case CollectionActions::Add:
                    collection->AddAsset( *itr );
                    break;
                case CollectionActions::Remove:
                    collection->RemoveAsset( *itr );
                    break;
                default:
                    HELIUM_BREAK();
                    break;
                }
            }
        }
        collection->Thaw();
    }
}
Ejemplo n.º 3
0
void CollectionsPanel::OnImportIntoCollection( wxCommandEvent& event )
{
    SortTreeCtrl* treeCtrl = m_MyCollectionsTreeCtrl;
    wxTreeItemId rootID = treeCtrl->GetRootItem();

    wxTreeItemId item = treeCtrl->GetSelection();
    if( !item || item == rootID )
    {
        return;
    }

    AssetCollectionItemData* baseData = GetItemData( treeCtrl, item );
    if ( !baseData )
    {
        return;
    }

    AssetCollection* collection = baseData->GetCollection<AssetCollection>();
    if ( !collection || collection->IsDynamic() )
    {
        return;
    }

    Helium::FileDialog browserDlg( this, VaultMenu::Label( ID_ImportIntoCollection ), TXT( "" ), TXT( "" ), TXT( "" ),
        Helium::FileDialogStyles::DefaultOpen | Helium::FileDialogStyles::ShowAllFilesFilter | Helium::FileDialogStyles::ExportFile );

    std::vector< tstring > filters;
    AssetCollection::GetFileFilters( filters );
    browserDlg.AddFilters( filters );

    if ( browserDlg.ShowModal() == wxID_OK )
    {
        collection->Freeze();
        m_CollectionManager->ImportIntoStaticCollection( collection, (const wxChar*)browserDlg.GetPath().c_str() );
        collection->Thaw();
    }
}