void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
{
    wxString        sep = wxFileName().GetPathSeparator();
    wxString        fullFileName = GetFileName();
    wxTreeItemId    id = GetId();

    KICAD_MANAGER_FRAME* frame = prjframe->m_Parent;
    wxASSERT( frame );

    switch( GetType() )
    {
    case TREE_PROJECT:
        break;

    case TREE_DIRECTORY:
        m_parent->Toggle( id );
        break;

    case TREE_SCHEMA:
        if( fullFileName == frame->SchFileName() )
        {
            // the project's schematic is opened using the *.kiface as part of this process.
            // We do not call frame->RunEeschema( fullFileName ),
            // because after the double click, for some reason,
            // the tree project frame is brought to the foreground after Eeschema is called from here.
            // Instead, we post an event, equivalent to click on the eeschema tool in command frame
            wxCommandEvent evt( wxEVT_COMMAND_TOOL_CLICKED, ID_TO_SCH );
            wxPostEvent( frame, evt );
        }
        else
        {
            // schematics not part of the project are opened in a separate process.
            frame->Execute( m_parent, EESCHEMA_EXE, fullFileName );
        }
        break;

    case TREE_LEGACY_PCB:
    case TREE_SEXP_PCB:
        if( fullFileName == frame->PcbFileName() || fullFileName == frame->PcbLegacyFileName() )
        {
            // the project's BOARD is opened using the *.kiface as part of this process.
            // We do not call frame->RunPcbNew( fullFileName ),
            // because after the double click, for some reason,
            // the tree project frame is brought to the foreground after PcbNew is called from here.
            // Instead, we post an event, equivalent to simple click on the pcb editor tool in command frame
            wxCommandEvent evt( wxEVT_COMMAND_TOOL_CLICKED, ID_TO_PCB );
            wxPostEvent( frame, evt );
        }
        else
        {
            // boards not part of the project are opened in a separate process.
            frame->Execute( m_parent, PCBNEW_EXE, fullFileName );
        }
        break;

    case TREE_GERBER:
        frame->Execute( m_parent, GERBVIEW_EXE, fullFileName );
        break;

    case TREE_HTML:
        wxLaunchDefaultBrowser( fullFileName );
        break;

    case TREE_PDF:
        OpenPDF( fullFileName );
        break;

    case TREE_NET:
        // Nothing to do ( can be read only by Pcbnew, or by a text editor)
        break;

    case TREE_TXT:
        {
            wxString editorname = Pgm().GetEditorName();

            if( !editorname.IsEmpty() )
                frame->Execute( m_parent, editorname, fullFileName );
        }
        break;

    case TREE_PAGE_LAYOUT_DESCR:
        frame->Execute( m_parent, PL_EDITOR_EXE, fullFileName );
        break;

    default:
        AddDelimiterString( fullFileName );
        OpenFile( fullFileName );
        break;
    }
}
void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* aTreePrjFrame )
{
    wxString        sep = wxFileName().GetPathSeparator();
    wxString        fullFileName = GetFileName();
    wxTreeItemId    id = GetId();

    KICAD_MANAGER_FRAME* frame = aTreePrjFrame->m_Parent;
    KIWAY&               kiway = frame->Kiway();

    switch( GetType() )
    {
    case TREE_PROJECT:
        // Select a new project if this is not the current project:
        if( id != aTreePrjFrame->m_TreeProject->GetRootItem() )
            frame->LoadProject( fullFileName );
        break;

    case TREE_DIRECTORY:
        m_parent->Toggle( id );
        break;

    case TREE_SCHEMA:
        if( fullFileName == frame->SchFileName() )
        {
            // the project's schematic is opened using the *.kiface as part of this process.
            // We do not call frame->RunEeschema( fullFileName ),
            // because after the double click, for some reason,
            // the tree project frame is brought to the foreground after Eeschema is called from here.
            // Instead, we post an event, equivalent to click on the eeschema tool in command frame
            wxCommandEvent evt( wxEVT_COMMAND_TOOL_CLICKED, ID_TO_SCH );
            wxPostEvent( frame, evt );
        }
        else
        {
            // schematics not part of the project are opened in a separate process.
            frame->Execute( m_parent, EESCHEMA_EXE, fullFileName );
        }
        break;

    case TREE_LEGACY_PCB:
    case TREE_SEXP_PCB:
        if( fullFileName == frame->PcbFileName() || fullFileName == frame->PcbLegacyFileName() )
        {
            // the project's BOARD is opened using the *.kiface as part of this process.
            // We do not call frame->RunPcbNew( fullFileName ),
            // because after the double click, for some reason,
            // the tree project frame is brought to the foreground after PcbNew is called from here.
            // Instead, we post an event, equivalent to simple click on the pcb editor tool in command frame
            wxCommandEvent evt( wxEVT_COMMAND_TOOL_CLICKED, ID_TO_PCB );
            wxPostEvent( frame, evt );
        }
        else
        {
            // boards not part of the project are opened in a separate process.
            frame->Execute( m_parent, PCBNEW_EXE, fullFileName );
        }
        break;

    case TREE_GERBER:
        frame->Execute( m_parent, GERBVIEW_EXE, fullFileName );
        break;

    case TREE_HTML:
        wxLaunchDefaultBrowser( fullFileName );
        break;

    case TREE_PDF:
        OpenPDF( fullFileName );
        break;

    case TREE_NET:
    case TREE_DRILL:
    case TREE_TXT:
    case TREE_REPORT:
        {
            wxString editorname = Pgm().GetEditorName();

            if( !editorname.IsEmpty() )
                frame->Execute( m_parent, editorname, fullFileName );
        }
        break;

    case TREE_PAGE_LAYOUT_DESCR:
        frame->Execute( m_parent, PL_EDITOR_EXE, fullFileName );
        break;

    case TREE_FOOTPRINT_FILE:
        {
            wxCommandEvent dummy;
            frame->OnRunPcbFpEditor( dummy );
            kiway.ExpressMail( FRAME_PCB_MODULE_EDITOR, MAIL_FP_EDIT, fullFileName.ToStdString() );
        }
        break;

    case TREE_SCHEMATIC_LIBFILE:
        {
            wxCommandEvent dummy;
            frame->OnRunSchLibEditor( dummy );
            kiway.ExpressMail( FRAME_SCH_LIB_EDITOR, MAIL_LIB_EDIT, fullFileName.ToStdString() );
        }
        break;

    default:
        AddDelimiterString( fullFileName );
        OpenFile( fullFileName );
        break;
    }
}
void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
{
    wxString        sep = wxFileName().GetPathSeparator();
    wxString        fullFileName = GetFileName();
    wxTreeItemId    id = GetId();

    KICAD_MANAGER_FRAME* frame = (KICAD_MANAGER_FRAME*) Pgm().App().GetTopWindow();

    switch( GetType() )
    {
    case TREE_PROJECT:
        break;

    case TREE_DIRECTORY:
        m_parent->Toggle( id );
        break;

    case TREE_SCHEMA:
        if( fullFileName == frame->SchFileName() )
        {
            // the project's schematic is opened using the *.kiface as part of this process.
            frame->RunEeschema( fullFileName );
        }
        else
        {
            // schematics not part of the project are opened in a separate process.
            frame->Execute( m_parent, EESCHEMA_EXE, fullFileName );
        }
        break;

    case TREE_LEGACY_PCB:
    case TREE_SEXP_PCB:
        if( fullFileName == frame->PcbFileName() || fullFileName == frame->PcbLegacyFileName() )
        {
            // the project's BOARD is opened using the *.kiface as part of this process.
            frame->RunPcbNew( fullFileName );
        }
        else
        {
            // boards not part of the project are opened in a separate process.
            frame->Execute( m_parent, PCBNEW_EXE, fullFileName );
        }
        break;

    case TREE_GERBER:
        frame->Execute( m_parent, GERBVIEW_EXE, fullFileName );
        break;

    case TREE_HTML:
        wxLaunchDefaultBrowser( fullFileName );
        break;

    case TREE_PDF:
        OpenPDF( fullFileName );
        break;

/*  No, use a text editor.  Netlists can only be handled sanely now from within
    eeschema's launcher for the *.kiface, NOT THE EXE which is now gone.
    case TREE_NET:
        frame->Execute( m_parent, CVPCB_EXE, fullFileName );
        break;
*/

    case TREE_TXT:
        {
            wxString editorname = Pgm().GetEditorName();

            if( !editorname.IsEmpty() )
                frame->Execute( m_parent, editorname, fullFileName );
        }
        break;

    case TREE_PAGE_LAYOUT_DESCR:
        frame->Execute( m_parent, PL_EDITOR_EXE, fullFileName );
        break;

    default:
        AddDelimiterString( fullFileName );
        OpenFile( fullFileName );
        break;
    }
}