2024-07-15 18:20:13 -04:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2024 Mark Roszko <mark.roszko@gmail.com>
|
|
|
|
* Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "panel_jobs.h"
|
|
|
|
#include <wx/aui/auibook.h>
|
|
|
|
#include <jobs/jobset.h>
|
|
|
|
#include <jobs/job_registry.h>
|
|
|
|
#include <eda_list_dialog.h>
|
|
|
|
#include <dialogs/dialog_job_config_base.h>
|
|
|
|
#include <wx/checkbox.h>
|
|
|
|
#include <wx/menu.h>
|
|
|
|
#include <bitmaps.h>
|
|
|
|
#include <i18n_utility.h>
|
|
|
|
#include <jobs_runner.h>
|
|
|
|
#include <widgets/wx_progress_reporters.h>
|
|
|
|
#include <jobs/jobs_output_archive.h>
|
|
|
|
#include <jobs/jobs_output_folder.h>
|
|
|
|
#include <kicad_manager_frame.h>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <wx/dirdlg.h>
|
|
|
|
#include <wx/filedlg.h>
|
|
|
|
#include <wildcards_and_files_ext.h>
|
|
|
|
#include <widgets/std_bitmap_button.h>
|
|
|
|
|
|
|
|
#include <confirm.h>
|
|
|
|
|
2024-10-22 22:29:14 -04:00
|
|
|
#include <jobs/job_special_execute.h>
|
|
|
|
#include <dialogs/dialog_special_execute.h>
|
2024-12-28 21:18:15 -05:00
|
|
|
#include <wx/textdlg.h>
|
2024-10-22 22:29:14 -04:00
|
|
|
|
2024-07-15 18:20:13 -04:00
|
|
|
|
|
|
|
struct JOB_TYPE_INFO
|
|
|
|
{
|
2024-10-01 18:38:41 +02:00
|
|
|
wxString name;
|
|
|
|
BITMAPS bitmap;
|
|
|
|
bool outputPathIsFolder;
|
|
|
|
wxString fileWildcard;
|
2024-07-15 18:20:13 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static std::map<JOBSET_OUTPUT_TYPE, JOB_TYPE_INFO> jobTypeInfos = {
|
|
|
|
{ JOBSET_OUTPUT_TYPE::FOLDER,
|
|
|
|
{ _HKI( "Folder" ), BITMAPS::small_folder, true, "" } },
|
|
|
|
{ JOBSET_OUTPUT_TYPE::ARCHIVE,
|
|
|
|
{ _HKI( "Archive" ), BITMAPS::zip, false, FILEEXT::ZipFileWildcard() } },
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class DIALOG_JOB_OUTPUT : public DIALOG_JOB_OUTPUT_BASE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DIALOG_JOB_OUTPUT( wxWindow* aParent, JOBSET* aJobsFile, JOBSET_OUTPUT* aOutput ) :
|
|
|
|
DIALOG_JOB_OUTPUT_BASE( aParent ), m_jobsFile( aJobsFile ), m_output( aOutput )
|
|
|
|
{
|
|
|
|
SetAffirmativeId( wxID_SAVE );
|
|
|
|
|
2024-10-02 19:14:48 -04:00
|
|
|
// prevent someone from failing to add the type info in the future
|
|
|
|
wxASSERT( jobTypeInfos.contains( m_output->m_type ) );
|
|
|
|
|
2024-12-29 07:16:38 -05:00
|
|
|
SetTitle( wxString::Format( _( "%s Output Options" ), m_output->m_outputHandler->GetDefaultDescription() ) );
|
2024-10-02 19:14:48 -04:00
|
|
|
|
2024-07-15 18:20:13 -04:00
|
|
|
if( m_output->m_type != JOBSET_OUTPUT_TYPE::ARCHIVE )
|
|
|
|
{
|
|
|
|
m_textArchiveFormat->Hide();
|
|
|
|
m_choiceArchiveformat->Hide();
|
|
|
|
}
|
|
|
|
|
2024-12-11 19:57:10 -05:00
|
|
|
m_textCtrlOutputPath->SetValue( m_output->m_outputHandler->GetOutputPath() );
|
2024-07-15 18:20:13 -04:00
|
|
|
m_buttonOutputPath->SetBitmap( KiBitmapBundle( BITMAPS::small_folder ) );
|
2024-12-29 07:16:38 -05:00
|
|
|
m_textCtrlDescription->SetValue( m_output->GetDescription() );
|
2024-07-15 18:20:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual void onOutputPathBrowseClicked(wxCommandEvent& event) override
|
|
|
|
{
|
|
|
|
bool isFolder = false;
|
|
|
|
wxString fileWildcard = "";
|
2024-10-02 19:14:48 -04:00
|
|
|
isFolder = jobTypeInfos[m_output->m_type].outputPathIsFolder;
|
|
|
|
fileWildcard = jobTypeInfos[m_output->m_type].fileWildcard;
|
2024-07-15 18:20:13 -04:00
|
|
|
|
|
|
|
if( isFolder )
|
|
|
|
{
|
|
|
|
wxFileName fn;
|
|
|
|
fn.AssignDir( m_textCtrlOutputPath->GetValue() );
|
|
|
|
fn.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS );
|
|
|
|
wxString currPath = fn.GetFullPath();
|
|
|
|
|
2024-12-11 19:57:10 -05:00
|
|
|
wxDirDialog dirDialog( this, _( "Select output directory" ), currPath,
|
2024-07-15 18:20:13 -04:00
|
|
|
wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
|
|
|
|
|
|
|
|
if( dirDialog.ShowModal() != wxID_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
|
|
|
|
|
|
|
|
m_textCtrlOutputPath->SetValue( dirName.GetFullPath() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-12-11 19:57:10 -05:00
|
|
|
wxFileName fname( m_textCtrlOutputPath->GetValue() );
|
|
|
|
|
|
|
|
wxFileDialog dlg( this, _( "Select output path" ), fname.GetPath(), fname.GetFullName(),
|
2024-07-15 18:20:13 -04:00
|
|
|
fileWildcard,
|
|
|
|
wxFD_OVERWRITE_PROMPT | wxFD_SAVE );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-12-11 19:57:10 -05:00
|
|
|
m_textCtrlOutputPath->SetValue( dlg.GetPath() );
|
2024-07-15 18:20:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TransferDataFromWindow() override
|
|
|
|
{
|
2024-12-20 18:48:57 -05:00
|
|
|
wxString outputPath = m_textCtrlOutputPath->GetValue().Trim().Trim( false );
|
|
|
|
if( outputPath == wxEmptyString )
|
|
|
|
{
|
|
|
|
DisplayErrorMessage( this, _( "Output path cannot be empty" ) );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-07-15 18:20:13 -04:00
|
|
|
wxArrayInt selectedItems;
|
|
|
|
m_listBoxOnly->GetSelections( selectedItems );
|
|
|
|
|
|
|
|
// Update the only job map
|
|
|
|
m_output->m_only.clear();
|
|
|
|
for( int i : selectedItems )
|
|
|
|
{
|
|
|
|
if( m_onlyMap.contains( i ) )
|
|
|
|
{
|
|
|
|
m_output->m_only.emplace_back( m_onlyMap[i] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-12-20 18:48:57 -05:00
|
|
|
m_output->m_outputHandler->SetOutputPath( outputPath );
|
2024-07-15 18:20:13 -04:00
|
|
|
|
|
|
|
if( m_output->m_type == JOBSET_OUTPUT_TYPE::ARCHIVE )
|
|
|
|
{
|
|
|
|
JOBS_OUTPUT_ARCHIVE* archive =
|
|
|
|
static_cast<JOBS_OUTPUT_ARCHIVE*>( m_output->m_outputHandler );
|
|
|
|
|
|
|
|
archive->SetFormat( JOBS_OUTPUT_ARCHIVE::FORMAT::ZIP );
|
|
|
|
}
|
|
|
|
|
2024-12-29 07:16:38 -05:00
|
|
|
m_output->SetDescription( m_textCtrlDescription->GetValue() );
|
2024-07-15 18:20:13 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool TransferDataToWindow() override
|
|
|
|
{
|
|
|
|
wxArrayString arrayStr;
|
|
|
|
std::vector<int> selectedList;
|
|
|
|
|
|
|
|
std::vector<JOBSET_JOB> jobs = m_jobsFile->GetJobs();
|
|
|
|
int i = 0;
|
|
|
|
for( JOBSET_JOB& job : jobs )
|
|
|
|
{
|
2024-12-28 21:18:15 -05:00
|
|
|
arrayStr.Add( job.GetDescription() );
|
2024-07-15 18:20:13 -04:00
|
|
|
|
|
|
|
auto it = std::find_if( m_output->m_only.begin(), m_output->m_only.end(),
|
|
|
|
[&]( const wxString& only )
|
|
|
|
{
|
|
|
|
if( only == job.m_id )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
} );
|
|
|
|
|
|
|
|
if( it != m_output->m_only.end() )
|
|
|
|
{
|
|
|
|
selectedList.emplace_back( i );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_onlyMap.emplace( i, job.m_id );
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2024-12-20 22:40:57 -05:00
|
|
|
if( arrayStr.size() != 0 )
|
2024-07-15 18:20:13 -04:00
|
|
|
{
|
2024-12-20 22:40:57 -05:00
|
|
|
m_listBoxOnly->InsertItems( arrayStr, 0 );
|
|
|
|
|
|
|
|
for( int idx : selectedList )
|
|
|
|
{
|
|
|
|
m_listBoxOnly->SetSelection( idx );
|
|
|
|
}
|
2024-07-15 18:20:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
m_choiceArchiveformat->AppendString( _( "Zip" ) );
|
|
|
|
m_choiceArchiveformat->SetSelection( 0 );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
JOBSET* m_jobsFile;
|
|
|
|
JOBSET_OUTPUT* m_output;
|
|
|
|
std::map<int, wxString> m_onlyMap;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2024-12-16 22:32:22 -05:00
|
|
|
class DIALOG_OUTPUT_RUN_RESULTS : public DIALOG_OUTPUT_RUN_RESULTS_BASE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DIALOG_OUTPUT_RUN_RESULTS( wxWindow* aParent,
|
|
|
|
JOBSET* aJobsFile,
|
|
|
|
JOBSET_OUTPUT* aOutput ) :
|
2024-12-23 23:05:29 -05:00
|
|
|
DIALOG_OUTPUT_RUN_RESULTS_BASE( aParent ),
|
|
|
|
m_jobsFile( aJobsFile ),
|
|
|
|
m_output( aOutput )
|
2024-12-16 22:32:22 -05:00
|
|
|
{
|
|
|
|
m_staticTextOutputName->SetLabel( aOutput->m_outputHandler->GetOutputPath() );
|
|
|
|
|
2024-12-19 16:42:59 -08:00
|
|
|
int jobBmpColId = m_jobList->AppendColumn( wxT( "" ) );
|
2024-12-16 22:32:22 -05:00
|
|
|
int jobNoColId = m_jobList->AppendColumn( _( "No." ) );
|
|
|
|
int jobDescColId = m_jobList->AppendColumn( _( "Job Description" ) );
|
|
|
|
m_jobList->SetColumnWidth( jobBmpColId, wxLIST_AUTOSIZE_USEHEADER );
|
|
|
|
m_jobList->SetColumnWidth( jobNoColId, wxLIST_AUTOSIZE_USEHEADER );
|
|
|
|
m_jobList->SetColumnWidth( jobDescColId, wxLIST_AUTOSIZE_USEHEADER );
|
|
|
|
|
|
|
|
wxImageList* imageList = new wxImageList( 16, 16, true, 3 );
|
|
|
|
imageList->Add( KiBitmapBundle( BITMAPS::ercerr ).GetBitmap( wxSize( 16, 16 ) ) );
|
|
|
|
imageList->Add( KiBitmapBundle( BITMAPS::checked_ok ).GetBitmap( wxSize( 16, 16 ) ) );
|
|
|
|
m_jobList->SetImageList( imageList, wxIMAGE_LIST_SMALL );
|
|
|
|
|
|
|
|
int num = 1;
|
|
|
|
for( auto& job : aJobsFile->GetJobsForOutput( aOutput ) )
|
|
|
|
{
|
|
|
|
int imageIdx = -1;
|
|
|
|
if( aOutput->m_lastRunSuccessMap.contains( job.m_id ) )
|
|
|
|
{
|
|
|
|
if( aOutput->m_lastRunSuccessMap[job.m_id].value() )
|
|
|
|
{
|
|
|
|
imageIdx = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
imageIdx = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
long itemIndex = m_jobList->InsertItem( m_jobList->GetItemCount(), imageIdx );
|
|
|
|
|
|
|
|
m_jobList->SetItem( itemIndex, jobNoColId, wxString::Format( "%d", num++ ) );
|
2024-12-28 21:18:15 -05:00
|
|
|
m_jobList->SetItem( itemIndex, jobDescColId, job.GetDescription() );
|
2024-12-16 22:32:22 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-12-23 23:05:29 -05:00
|
|
|
|
|
|
|
virtual void OnJobListItemSelected( wxListEvent& event ) override
|
|
|
|
{
|
|
|
|
int itemIndex = event.GetIndex();
|
|
|
|
|
|
|
|
std::vector<JOBSET_JOB> jobs = m_jobsFile->GetJobsForOutput( m_output );
|
|
|
|
|
|
|
|
if( itemIndex < jobs.size() )
|
|
|
|
{
|
|
|
|
JOBSET_JOB& job = jobs[itemIndex];
|
|
|
|
if( m_output->m_lastRunReporters.contains( job.m_id ) )
|
|
|
|
{
|
|
|
|
WX_STRING_REPORTER* reporter =
|
|
|
|
static_cast<WX_STRING_REPORTER*>( m_output->m_lastRunReporters[job.m_id] );
|
|
|
|
m_textCtrlOutput->SetValue( reporter->GetMessages() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_textCtrlOutput->SetValue( _( "No output available" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
JOBSET* m_jobsFile;
|
|
|
|
JOBSET_OUTPUT* m_output;
|
2024-12-16 22:32:22 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2024-07-15 18:20:13 -04:00
|
|
|
class PANEL_JOB_OUTPUT : public PANEL_JOB_OUTPUT_BASE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PANEL_JOB_OUTPUT( wxWindow* aParent, PANEL_JOBS* aPanelParent, KICAD_MANAGER_FRAME* aFrame,
|
|
|
|
JOBSET* aFile, JOBSET_OUTPUT* aOutput ) :
|
|
|
|
PANEL_JOB_OUTPUT_BASE( aParent ),
|
|
|
|
m_jobsFile( aFile ),
|
|
|
|
m_output( aOutput ),
|
|
|
|
m_frame( aFrame ),
|
|
|
|
m_panelParent( aPanelParent )
|
|
|
|
{
|
|
|
|
m_buttonOutputRun->SetBitmap( KiBitmapBundle( BITMAPS::sim_run ) );
|
|
|
|
m_buttonOutputOptions->SetBitmap( KiBitmapBundle( BITMAPS::preference ) );
|
|
|
|
|
|
|
|
m_buttonOutputOptions->Connect( wxEVT_MENU,
|
|
|
|
wxCommandEventHandler( PANEL_JOB_OUTPUT::onMenu ), nullptr, this );
|
|
|
|
|
|
|
|
if( jobTypeInfos.contains( aOutput->m_type ) )
|
|
|
|
{
|
|
|
|
JOB_TYPE_INFO& jobTypeInfo = jobTypeInfos[aOutput->m_type];
|
2024-12-29 07:16:38 -05:00
|
|
|
m_textOutputType->SetLabel( aOutput->GetDescription() );
|
2024-07-15 18:20:13 -04:00
|
|
|
m_bitmapOutputType->SetBitmap( KiBitmapBundle( jobTypeInfo.bitmap ) );
|
|
|
|
}
|
2024-12-26 11:24:32 -05:00
|
|
|
|
|
|
|
UpdateStatus();
|
2024-07-15 18:20:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
~PANEL_JOB_OUTPUT()
|
|
|
|
{
|
|
|
|
m_buttonOutputOptions->Disconnect(
|
|
|
|
wxEVT_MENU, wxCommandEventHandler( PANEL_JOB_OUTPUT::onMenu ), nullptr, this );
|
|
|
|
}
|
|
|
|
|
2024-12-16 22:32:22 -05:00
|
|
|
void UpdateStatus()
|
|
|
|
{
|
|
|
|
if( m_output->m_lastRunSuccess.has_value() )
|
|
|
|
{
|
|
|
|
if( m_output->m_lastRunSuccess.value() )
|
|
|
|
{
|
|
|
|
m_statusBitmap->SetBitmap( KiBitmapBundle( BITMAPS::checked_ok ) );
|
|
|
|
m_statusBitmap->Show();
|
|
|
|
m_statusBitmap->SetToolTip( _( "Last run successful" ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_statusBitmap->SetBitmap( KiBitmapBundle( BITMAPS::ercerr ) );
|
|
|
|
m_statusBitmap->Show();
|
|
|
|
m_statusBitmap->SetToolTip( _( "Last run failed" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_statusBitmap->Hide();
|
|
|
|
}
|
2024-12-26 11:24:32 -05:00
|
|
|
|
|
|
|
if( !m_jobsFile->GetJobsForOutput( m_output ).empty() )
|
|
|
|
{
|
|
|
|
m_buttonOutputRun->Enable();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_buttonOutputRun->Disable();
|
|
|
|
}
|
2024-12-16 22:32:22 -05:00
|
|
|
}
|
|
|
|
|
2024-07-15 18:20:13 -04:00
|
|
|
|
|
|
|
virtual void OnOutputRunClick( wxCommandEvent& event ) override
|
|
|
|
{
|
|
|
|
CallAfter(
|
|
|
|
[this]()
|
|
|
|
{
|
|
|
|
PROJECT& project = m_frame->Kiway().Prj();
|
|
|
|
m_panelParent->EnsurePcbSchFramesOpen();
|
|
|
|
|
|
|
|
wxFileName fn = project.GetProjectFullName();
|
|
|
|
wxSetWorkingDirectory( fn.GetPath() );
|
|
|
|
|
2024-12-24 11:44:22 -05:00
|
|
|
JOBS_RUNNER jobRunner( &( m_frame->Kiway() ), m_jobsFile, &project );
|
2024-07-15 18:20:13 -04:00
|
|
|
|
|
|
|
WX_PROGRESS_REPORTER* progressReporter =
|
|
|
|
new WX_PROGRESS_REPORTER( m_frame, _( "Running jobs" ), 1 );
|
|
|
|
|
|
|
|
jobRunner.RunJobsForOutput( m_output );
|
2024-12-16 22:32:22 -05:00
|
|
|
UpdateStatus();
|
2024-07-15 18:20:13 -04:00
|
|
|
|
|
|
|
delete progressReporter;
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
2024-12-16 22:32:22 -05:00
|
|
|
virtual void OnLastStatusClick(wxMouseEvent& event) override
|
|
|
|
{
|
|
|
|
DIALOG_OUTPUT_RUN_RESULTS dialog( m_frame, m_jobsFile, m_output );
|
|
|
|
dialog.ShowModal();
|
|
|
|
}
|
|
|
|
|
2024-07-15 18:20:13 -04:00
|
|
|
virtual void OnOutputOptionsClick( wxCommandEvent& event ) override
|
|
|
|
{
|
|
|
|
wxMenu menu;
|
|
|
|
menu.Append( wxID_EDIT, _( "Edit..." ) );
|
|
|
|
menu.Append( wxID_DELETE, _( "Delete" ) );
|
|
|
|
|
2024-12-16 22:32:22 -05:00
|
|
|
if( m_output->m_lastRunSuccess.has_value() )
|
|
|
|
{
|
|
|
|
menu.AppendSeparator();
|
|
|
|
menu.Append( wxID_VIEW_DETAILS, _( "View last run results..." ) );
|
|
|
|
}
|
|
|
|
|
2024-07-15 18:20:13 -04:00
|
|
|
m_buttonOutputOptions->PopupMenu( &menu );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
void onMenu( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
switch( aEvent.GetId() )
|
|
|
|
{
|
|
|
|
case wxID_EDIT:
|
|
|
|
{
|
|
|
|
DIALOG_JOB_OUTPUT dialog( m_frame, m_jobsFile, m_output );
|
2024-12-29 07:16:38 -05:00
|
|
|
if( dialog.ShowModal() == wxID_SAVE )
|
|
|
|
{
|
|
|
|
m_textOutputType->SetLabel( m_output->GetDescription() );
|
|
|
|
m_jobsFile->SetDirty();
|
|
|
|
m_panelParent->UpdateTitle();
|
|
|
|
}
|
2024-07-15 18:20:13 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxID_DELETE:
|
|
|
|
m_panelParent->RemoveOutput( m_output );
|
|
|
|
break;
|
|
|
|
|
2024-12-16 22:32:22 -05:00
|
|
|
case wxID_VIEW_DETAILS:
|
|
|
|
{
|
|
|
|
DIALOG_OUTPUT_RUN_RESULTS dialog( m_frame, m_jobsFile, m_output );
|
|
|
|
dialog.ShowModal();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2024-07-15 18:20:13 -04:00
|
|
|
default:
|
|
|
|
wxFAIL_MSG( wxT( "Unknown ID in context menu event" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
JOBSET* m_jobsFile;
|
|
|
|
JOBSET_OUTPUT* m_output;
|
|
|
|
KICAD_MANAGER_FRAME* m_frame;
|
|
|
|
PANEL_JOBS* m_panelParent;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
PANEL_JOBS::PANEL_JOBS( wxAuiNotebook* aParent, KICAD_MANAGER_FRAME* aFrame,
|
|
|
|
std::unique_ptr<JOBSET> aJobsFile ) :
|
|
|
|
PANEL_JOBS_BASE( aParent ),
|
|
|
|
m_parentBook( aParent ),
|
|
|
|
m_frame( aFrame ),
|
|
|
|
m_jobsFile( std::move( aJobsFile ) )
|
|
|
|
{
|
|
|
|
int jobNoColId = m_jobList->AppendColumn( _( "No." ) );
|
|
|
|
int jobDescColId = m_jobList->AppendColumn( _( "Job Description" ) );
|
|
|
|
m_jobList->SetColumnWidth( jobNoColId, wxLIST_AUTOSIZE_USEHEADER );
|
|
|
|
m_jobList->SetColumnWidth( jobDescColId, wxLIST_AUTOSIZE_USEHEADER );
|
|
|
|
|
|
|
|
m_buttonAddJob->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
|
|
|
|
m_buttonUp->SetBitmap( KiBitmapBundle( BITMAPS::small_up ) );
|
|
|
|
m_buttonDown->SetBitmap( KiBitmapBundle( BITMAPS::small_down ) );
|
|
|
|
m_buttonOutputAdd->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
|
|
|
|
|
2024-10-03 08:02:21 -04:00
|
|
|
m_jobList->Connect( wxEVT_MENU, wxCommandEventHandler( PANEL_JOBS::onJobListMenu ),
|
|
|
|
nullptr, this );
|
|
|
|
|
2024-07-15 18:20:13 -04:00
|
|
|
rebuildJobList();
|
|
|
|
buildOutputList();
|
2024-11-07 07:25:40 -05:00
|
|
|
|
2024-12-26 11:24:32 -05:00
|
|
|
m_buttonRunAllOutputs->Enable( !m_jobsFile->GetOutputs().empty() && !m_jobsFile->GetJobs().empty() );
|
2024-07-15 18:20:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-10-03 08:02:21 -04:00
|
|
|
PANEL_JOBS::~PANEL_JOBS()
|
|
|
|
{
|
|
|
|
m_jobList->Disconnect( wxEVT_MENU, wxCommandEventHandler( PANEL_JOBS::onJobListMenu ),
|
|
|
|
nullptr, this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-07-15 18:20:13 -04:00
|
|
|
void PANEL_JOBS::RemoveOutput( JOBSET_OUTPUT* aOutput )
|
|
|
|
{
|
|
|
|
auto it = m_outputPanelMap.find( aOutput );
|
|
|
|
if( it != m_outputPanelMap.end() )
|
|
|
|
{
|
|
|
|
PANEL_JOB_OUTPUT* panel = m_outputPanelMap[aOutput];
|
|
|
|
m_outputListSizer->Detach( panel );
|
|
|
|
panel->Destroy();
|
|
|
|
|
|
|
|
m_outputPanelMap.erase( it );
|
|
|
|
|
|
|
|
// ensure the window contents get shifted as needed
|
|
|
|
m_outputList->Layout();
|
|
|
|
Layout();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_jobsFile->RemoveOutput( aOutput );
|
2024-11-07 07:25:40 -05:00
|
|
|
|
|
|
|
m_buttonRunAllOutputs->Enable( !m_jobsFile->GetOutputs().empty() );
|
2024-07-15 18:20:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_JOBS::rebuildJobList()
|
|
|
|
{
|
|
|
|
m_jobList->DeleteAllItems();
|
|
|
|
|
|
|
|
int num = 1;
|
|
|
|
for( auto& job : m_jobsFile->GetJobs() )
|
|
|
|
{
|
|
|
|
long itemIndex =
|
|
|
|
m_jobList->InsertItem( m_jobList->GetItemCount(), wxString::Format( "%d", num++ ) );
|
2024-12-28 21:18:15 -05:00
|
|
|
m_jobList->SetItem( itemIndex, 1, job.GetDescription() );
|
2024-07-15 18:20:13 -04:00
|
|
|
}
|
|
|
|
|
2024-12-29 07:16:38 -05:00
|
|
|
UpdateTitle();
|
2024-12-26 11:24:32 -05:00
|
|
|
|
|
|
|
if( m_jobsFile->GetJobs().empty() )
|
|
|
|
{
|
|
|
|
m_buttonUp->Disable();
|
|
|
|
m_buttonDown->Disable();
|
|
|
|
m_buttonRunAllOutputs->Disable();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_buttonUp->Enable();
|
|
|
|
m_buttonDown->Enable();
|
|
|
|
m_buttonRunAllOutputs->Enable();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure the outputs get their Run-ability status updated
|
|
|
|
for( auto& output : m_jobsFile->GetOutputs() )
|
|
|
|
{
|
|
|
|
if( m_outputPanelMap.contains( &output ) )
|
|
|
|
{
|
|
|
|
PANEL_JOB_OUTPUT* panel = m_outputPanelMap[&output];
|
|
|
|
panel->UpdateStatus();
|
|
|
|
}
|
|
|
|
}
|
2024-07-15 18:20:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-12-29 07:16:38 -05:00
|
|
|
void PANEL_JOBS::UpdateTitle()
|
2024-07-15 18:20:13 -04:00
|
|
|
{
|
|
|
|
wxString tabName = m_jobsFile->GetFullName();
|
|
|
|
if( m_jobsFile->GetDirty() )
|
|
|
|
{
|
|
|
|
tabName = wxS( "*" ) + tabName;
|
|
|
|
}
|
|
|
|
int pageIdx = m_parentBook->FindPage( this );
|
|
|
|
m_parentBook->SetPageText( pageIdx, tabName );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_JOBS::addJobOutputPanel( JOBSET_OUTPUT* aOutput )
|
|
|
|
{
|
|
|
|
PANEL_JOB_OUTPUT* outputPanel =
|
|
|
|
new PANEL_JOB_OUTPUT( m_outputList, this, m_frame, m_jobsFile.get(), aOutput );
|
|
|
|
m_outputListSizer->Add( outputPanel, 0, wxEXPAND | wxALL, 5 );
|
|
|
|
|
|
|
|
m_outputPanelMap[aOutput] = outputPanel;
|
|
|
|
|
|
|
|
m_outputList->Layout();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_JOBS::buildOutputList()
|
|
|
|
{
|
|
|
|
Freeze();
|
|
|
|
m_outputPanelMap.clear();
|
|
|
|
|
|
|
|
for( auto& job : m_jobsFile->GetOutputs() )
|
|
|
|
{
|
|
|
|
addJobOutputPanel( &job );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ensure the window contents get shifted as needed
|
|
|
|
Layout();
|
|
|
|
Thaw();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-10-03 08:02:21 -04:00
|
|
|
void PANEL_JOBS::openJobOptionsForListItem( size_t aItemIndex )
|
2024-07-15 18:20:13 -04:00
|
|
|
{
|
2024-10-03 08:02:21 -04:00
|
|
|
JOBSET_JOB& job = m_jobsFile->GetJobs()[aItemIndex];
|
2024-07-15 18:20:13 -04:00
|
|
|
|
|
|
|
KIWAY::FACE_T iface = JOB_REGISTRY::GetKifaceType( job.m_type );
|
|
|
|
|
2024-10-22 22:29:14 -04:00
|
|
|
if( iface < KIWAY::KIWAY_FACE_COUNT )
|
|
|
|
{
|
|
|
|
EnsurePcbSchFramesOpen();
|
|
|
|
|
2024-12-27 20:15:27 -05:00
|
|
|
bool changes = m_frame->Kiway().ProcessJobConfigDialog( iface, job.m_job.get(), m_frame );
|
|
|
|
if( changes )
|
|
|
|
{
|
|
|
|
m_jobsFile->SetDirty();
|
2024-12-29 07:16:38 -05:00
|
|
|
UpdateTitle();
|
2024-12-27 20:15:27 -05:00
|
|
|
}
|
|
|
|
}
|
2024-10-22 22:29:14 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// special jobs
|
|
|
|
if( job.m_job->GetType() == "special_execute" )
|
|
|
|
{
|
2024-11-09 22:49:54 -05:00
|
|
|
JOB_SPECIAL_EXECUTE* specialJob = static_cast<JOB_SPECIAL_EXECUTE*>( job.m_job.get() );
|
2024-10-22 22:29:14 -04:00
|
|
|
|
|
|
|
DIALOG_SPECIAL_EXECUTE dialog( m_frame, specialJob );
|
|
|
|
dialog.ShowModal();
|
|
|
|
}
|
|
|
|
}
|
2024-07-15 18:20:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-10-03 08:02:21 -04:00
|
|
|
void PANEL_JOBS::OnJobListDoubleClicked( wxListEvent& aEvent )
|
|
|
|
{
|
|
|
|
long item = aEvent.GetIndex();
|
|
|
|
|
|
|
|
openJobOptionsForListItem( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_JOBS::OnJobListItemRightClick( wxListEvent& event )
|
|
|
|
{
|
|
|
|
wxMenu menu;
|
2024-12-28 21:18:15 -05:00
|
|
|
menu.Append( wxID_PROPERTIES, _( "Edit Options" ) );
|
|
|
|
menu.Append( wxID_EDIT, _( "Edit Description" ) );
|
|
|
|
menu.AppendSeparator();
|
2024-10-03 08:02:21 -04:00
|
|
|
menu.Append( wxID_DELETE, _( "Delete" ) );
|
|
|
|
|
|
|
|
m_jobList->PopupMenu( &menu, event.GetPoint() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_JOBS::onJobListMenu( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
switch( aEvent.GetId() )
|
|
|
|
{
|
2024-12-28 21:18:15 -05:00
|
|
|
case wxID_PROPERTIES:
|
2024-10-03 08:02:21 -04:00
|
|
|
{
|
|
|
|
long item = m_jobList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
|
|
|
|
|
|
|
|
if( item == -1 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
openJobOptionsForListItem( item );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2024-12-28 21:18:15 -05:00
|
|
|
case wxID_EDIT:
|
|
|
|
{
|
|
|
|
long item = m_jobList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
|
|
|
|
if( item == -1 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
JOBSET_JOB& job = m_jobsFile->GetJobs()[item];
|
|
|
|
wxString desc = job.GetDescription();
|
2024-12-28 22:53:12 -05:00
|
|
|
|
|
|
|
wxTextEntryDialog descDialog( this, _( "Edit Description" ), _( "Enter new description:" ),
|
|
|
|
desc );
|
|
|
|
|
|
|
|
if( descDialog.ShowModal() == wxID_OK && desc != descDialog.GetValue() )
|
2024-12-28 21:18:15 -05:00
|
|
|
{
|
2024-12-28 22:53:12 -05:00
|
|
|
job.SetDescription( descDialog.GetValue() );
|
2024-12-28 21:18:15 -05:00
|
|
|
|
|
|
|
m_jobsFile->SetDirty();
|
2024-12-29 07:16:38 -05:00
|
|
|
UpdateTitle();
|
2024-12-28 21:18:15 -05:00
|
|
|
|
|
|
|
m_jobList->SetItem( item, 1, job.GetDescription() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
2024-10-03 08:02:21 -04:00
|
|
|
case wxID_DELETE:
|
|
|
|
{
|
|
|
|
long item = m_jobList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
|
|
|
|
|
|
|
|
if( item == -1 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_jobsFile->RemoveJob( item );
|
|
|
|
rebuildJobList();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default: wxFAIL_MSG( wxT( "Unknown ID in context menu event" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-07-15 18:20:13 -04:00
|
|
|
void PANEL_JOBS::OnSaveButtonClick( wxCommandEvent& aEvent )
|
|
|
|
{
|
2024-12-27 20:15:27 -05:00
|
|
|
m_jobsFile->SaveToFile( wxEmptyString, true );
|
2024-12-29 07:16:38 -05:00
|
|
|
UpdateTitle();
|
2024-07-15 18:20:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_JOBS::OnAddJobClick( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
wxArrayString headers;
|
|
|
|
std::vector<wxArrayString> items;
|
|
|
|
|
|
|
|
headers.Add( _( "Job Types" ) );
|
|
|
|
|
|
|
|
const JOB_REGISTRY::REGISTRY_MAP_T& jobMap = JOB_REGISTRY::GetRegistry();
|
|
|
|
|
2024-10-01 18:38:41 +02:00
|
|
|
for( const std::pair<const wxString, JOB_REGISTRY_ENTRY>& entry : jobMap )
|
2024-07-15 18:20:13 -04:00
|
|
|
{
|
|
|
|
wxArrayString item;
|
|
|
|
item.Add( wxGetTranslation( entry.second.title ) );
|
|
|
|
items.emplace_back( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
EDA_LIST_DIALOG dlg( this, _( "Add New Job" ), headers, items );
|
|
|
|
dlg.SetListLabel( _( "Select job type:" ) );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_OK )
|
|
|
|
{
|
|
|
|
wxString selectedString = dlg.GetTextSelection();
|
|
|
|
|
|
|
|
wxString jobKey;
|
|
|
|
if( !selectedString.IsEmpty() )
|
|
|
|
{
|
2024-10-01 18:38:41 +02:00
|
|
|
for( const std::pair<const wxString, JOB_REGISTRY_ENTRY>& entry : jobMap )
|
2024-07-15 18:20:13 -04:00
|
|
|
{
|
|
|
|
if( wxGetTranslation( entry.second.title ) == selectedString )
|
|
|
|
{
|
|
|
|
jobKey = entry.first;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !jobKey.IsEmpty() )
|
|
|
|
{
|
|
|
|
JOB* job = JOB_REGISTRY::CreateInstance<JOB>( jobKey );
|
|
|
|
m_jobsFile->AddNewJob( jobKey, job );
|
|
|
|
|
|
|
|
rebuildJobList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_JOBS::OnAddOutputClick( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
wxArrayString headers;
|
|
|
|
std::vector<wxArrayString> items;
|
|
|
|
|
2024-12-29 07:16:38 -05:00
|
|
|
headers.Add( _( "Output Types" ) );
|
2024-07-15 18:20:13 -04:00
|
|
|
|
2024-12-29 07:16:38 -05:00
|
|
|
for( const std::pair<const JOBSET_OUTPUT_TYPE, JOB_TYPE_INFO>& outputType : jobTypeInfos )
|
2024-07-15 18:20:13 -04:00
|
|
|
{
|
|
|
|
wxArrayString item;
|
2024-12-29 07:16:38 -05:00
|
|
|
item.Add( wxGetTranslation( outputType.second.name ) );
|
2024-07-15 18:20:13 -04:00
|
|
|
items.emplace_back( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
EDA_LIST_DIALOG dlg( this, _( "Add New Output" ), headers, items );
|
|
|
|
dlg.SetListLabel( _( "Select output type:" ) );
|
|
|
|
dlg.HideFilter();
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_OK )
|
|
|
|
{
|
|
|
|
wxString selectedString = dlg.GetTextSelection();
|
|
|
|
|
2024-10-01 18:38:41 +02:00
|
|
|
for( const std::pair<const JOBSET_OUTPUT_TYPE, JOB_TYPE_INFO>& jobType : jobTypeInfos )
|
2024-07-15 18:20:13 -04:00
|
|
|
{
|
|
|
|
if( wxGetTranslation( jobType.second.name ) == selectedString )
|
|
|
|
{
|
2024-12-20 22:39:51 -05:00
|
|
|
JOBSET_OUTPUT* output = m_jobsFile->AddNewJobOutput( jobType.first );
|
2024-07-15 18:20:13 -04:00
|
|
|
|
2024-12-21 16:12:04 -05:00
|
|
|
DIALOG_JOB_OUTPUT dialog( m_frame, m_jobsFile.get(), output );
|
|
|
|
if (dialog.ShowModal() == wxID_SAVE)
|
|
|
|
{
|
|
|
|
Freeze();
|
|
|
|
addJobOutputPanel( output );
|
|
|
|
m_buttonRunAllOutputs->Enable( !m_jobsFile->GetOutputs().empty() );
|
|
|
|
Thaw();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// canceled
|
|
|
|
m_jobsFile->RemoveOutput( output );
|
|
|
|
}
|
2024-07-15 18:20:13 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PANEL_JOBS::GetCanClose()
|
|
|
|
{
|
|
|
|
if( m_jobsFile->GetDirty() )
|
|
|
|
{
|
|
|
|
wxFileName fileName = m_jobsFile->GetFullFilename();
|
|
|
|
wxString msg = _( "Save changes to '%s' before closing?" );
|
|
|
|
|
|
|
|
if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
|
|
|
|
[&]() -> bool
|
|
|
|
{
|
|
|
|
return m_jobsFile->SaveToFile();
|
|
|
|
} ) )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_JOBS::EnsurePcbSchFramesOpen()
|
|
|
|
{
|
|
|
|
PROJECT& project = m_frame->Kiway().Prj();
|
|
|
|
KIWAY_PLAYER* frame = m_frame->Kiway().Player( FRAME_PCB_EDITOR, false );
|
|
|
|
|
|
|
|
if( !frame )
|
|
|
|
{
|
|
|
|
frame = m_frame->Kiway().Player( FRAME_PCB_EDITOR, true );
|
|
|
|
|
|
|
|
// frame can be null if Cvpcb cannot be run. No need to show a warning
|
|
|
|
// Kiway() generates the error messages
|
|
|
|
if( !frame )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxFileName boardfn = project.GetProjectFullName();
|
|
|
|
boardfn.SetExt( FILEEXT::PcbFileExtension );
|
|
|
|
|
2024-12-20 11:22:41 -08:00
|
|
|
// Prevent our window from being closed during the open process
|
|
|
|
wxEventBlocker blocker( this );
|
|
|
|
|
2024-07-15 18:20:13 -04:00
|
|
|
frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
frame = m_frame->Kiway().Player( FRAME_SCH, false );
|
|
|
|
|
|
|
|
if( !frame )
|
|
|
|
{
|
|
|
|
frame = m_frame->Kiway().Player( FRAME_SCH, true );
|
|
|
|
|
|
|
|
// frame can be null if Cvpcb cannot be run. No need to show a warning
|
|
|
|
// Kiway() generates the error messages
|
|
|
|
if( !frame )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxFileName schFn = project.GetProjectFullName();
|
|
|
|
schFn.SetExt( FILEEXT::KiCadSchematicFileExtension );
|
|
|
|
|
2024-12-20 11:22:41 -08:00
|
|
|
wxEventBlocker blocker( this );
|
|
|
|
|
2024-07-15 18:20:13 -04:00
|
|
|
frame->OpenProjectFiles( std::vector<wxString>( 1, schFn.GetFullPath() ) );
|
|
|
|
}
|
2024-10-01 14:11:28 -04:00
|
|
|
}
|
2024-10-02 22:53:43 -04:00
|
|
|
|
|
|
|
|
2024-12-21 12:02:21 -05:00
|
|
|
wxString PANEL_JOBS::GetFilePath() const
|
|
|
|
{
|
|
|
|
return m_jobsFile->GetFullFilename();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-10-02 22:53:43 -04:00
|
|
|
void PANEL_JOBS::OnJobButtonUp( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
long item = m_jobList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
|
|
|
|
|
|
|
|
if( item == -1 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( item == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_jobsFile->MoveJobUp( item );
|
|
|
|
|
|
|
|
rebuildJobList();
|
|
|
|
|
|
|
|
m_jobList->SetItemState( item - 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_JOBS::OnJobButtonDown( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
long item = m_jobList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
|
|
|
|
|
|
|
|
if( item == -1 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( item == m_jobList->GetItemCount() - 1 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_jobsFile->MoveJobDown( item );
|
|
|
|
|
|
|
|
rebuildJobList();
|
|
|
|
|
|
|
|
m_jobList->SetItemState( item + 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
|
2024-11-07 07:25:40 -05:00
|
|
|
}
|
|
|
|
|
2024-12-26 11:24:32 -05:00
|
|
|
|
2024-11-07 07:25:40 -05:00
|
|
|
void PANEL_JOBS::OnRunAllJobsClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// sanity
|
|
|
|
if( m_jobsFile->GetOutputs().empty() )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "No outputs defined" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CallAfter(
|
|
|
|
[this]()
|
|
|
|
{
|
|
|
|
PROJECT& project = m_frame->Kiway().Prj();
|
|
|
|
EnsurePcbSchFramesOpen();
|
|
|
|
|
|
|
|
wxFileName fn = project.GetProjectFullName();
|
|
|
|
wxSetWorkingDirectory( fn.GetPath() );
|
|
|
|
|
2024-12-24 11:44:22 -05:00
|
|
|
JOBS_RUNNER jobRunner( &( m_frame->Kiway() ), m_jobsFile.get(), &project );
|
2024-11-07 07:25:40 -05:00
|
|
|
|
|
|
|
WX_PROGRESS_REPORTER* progressReporter =
|
|
|
|
new WX_PROGRESS_REPORTER( m_frame, _( "Running jobs" ), 1 );
|
|
|
|
|
|
|
|
jobRunner.RunJobsAllOutputs();
|
|
|
|
|
2024-12-16 22:32:22 -05:00
|
|
|
for( auto& output : m_jobsFile->GetOutputs() )
|
|
|
|
{
|
|
|
|
PANEL_JOB_OUTPUT* panel = m_outputPanelMap[&output];
|
|
|
|
panel->UpdateStatus();
|
|
|
|
}
|
|
|
|
|
2024-11-07 07:25:40 -05:00
|
|
|
delete progressReporter;
|
|
|
|
} );
|
2024-10-02 22:53:43 -04:00
|
|
|
}
|