22#include <wx/aui/auibook.h>
27#include <wx/checkbox.h>
39#include <wx/filedlg.h>
72 SetAffirmativeId( wxID_SAVE );
92 bool isFolder =
false;
93 wxString fileWildcard =
"";
102 wxString currPath = fn.GetFullPath();
104 wxDirDialog dirDialog(
this,
_(
"Select output directory" ), currPath,
105 wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
107 if( dirDialog.ShowModal() != wxID_OK )
110 wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
118 wxFileDialog dlg(
this,
_(
"Select output path" ), fname.GetPath(), fname.GetFullName(),
120 wxFD_OVERWRITE_PROMPT | wxFD_SAVE );
122 if( dlg.ShowModal() != wxID_OK )
135 if( outputPath == wxEmptyString )
141 wxArrayInt selectedItems;
146 for(
int i : selectedItems )
171 wxArrayString arrayStr;
172 std::vector<int> selectedList;
178 arrayStr.Add( job.m_job->GetDescription() );
181 [&](
const wxString& only )
183 if( only == job.m_id )
191 selectedList.emplace_back( i );
198 if( arrayStr.size() != 0 )
202 for(
int idx : selectedList )
232 int jobBmpColId =
m_jobList->AppendColumn( wxT(
"" ) );
233 int jobNoColId =
m_jobList->AppendColumn(
_(
"No." ) );
234 int jobDescColId =
m_jobList->AppendColumn(
_(
"Job Description" ) );
235 m_jobList->SetColumnWidth( jobBmpColId, wxLIST_AUTOSIZE_USEHEADER );
236 m_jobList->SetColumnWidth( jobNoColId, wxLIST_AUTOSIZE_USEHEADER );
237 m_jobList->SetColumnWidth( jobDescColId, wxLIST_AUTOSIZE_USEHEADER );
239 wxImageList* imageList =
new wxImageList( 16, 16,
true, 3 );
240 imageList->Add(
KiBitmapBundle( BITMAPS::ercerr ).GetBitmap( wxSize( 16, 16 ) ) );
241 imageList->Add(
KiBitmapBundle( BITMAPS::checked_ok ).GetBitmap( wxSize( 16, 16 ) ) );
242 m_jobList->SetImageList( imageList, wxIMAGE_LIST_SMALL );
262 m_jobList->SetItem( itemIndex, jobNoColId, wxString::Format(
"%d", num++ ) );
263 m_jobList->SetItem( itemIndex, jobDescColId, job.m_job->GetDescription() );
334 wxFileName fn =
project.GetProjectFullName();
335 wxSetWorkingDirectory( fn.GetPath() );
345 delete progressReporter;
358 menu.Append( wxID_EDIT,
_(
"Edit..." ) );
359 menu.Append( wxID_DELETE,
_(
"Delete" ) );
363 menu.AppendSeparator();
364 menu.Append( wxID_VIEW_DETAILS,
_(
"View last run results..." ) );
374 switch( aEvent.GetId() )
388 case wxID_VIEW_DETAILS:
396 wxFAIL_MSG( wxT(
"Unknown ID in context menu event" ) );
408 std::unique_ptr<JOBSET> aJobsFile ) :
410 m_parentBook( aParent ),
412 m_jobsFile(
std::
move( aJobsFile ) )
414 int jobNoColId =
m_jobList->AppendColumn(
_(
"No." ) );
415 int jobDescColId =
m_jobList->AppendColumn(
_(
"Job Description" ) );
416 m_jobList->SetColumnWidth( jobNoColId, wxLIST_AUTOSIZE_USEHEADER );
417 m_jobList->SetColumnWidth( jobDescColId, wxLIST_AUTOSIZE_USEHEADER );
472 m_jobList->SetItem( itemIndex, 1, job.m_job->GetDescription() );
484 tabName = wxS(
"*" ) + tabName;
534 if( job.
m_job->GetType() ==
"special_execute" )
547 long item = aEvent.GetIndex();
556 menu.Append( wxID_EDIT,
_(
"Edit..." ) );
557 menu.Append( wxID_DELETE,
_(
"Delete" ) );
559 m_jobList->PopupMenu( &menu, event.GetPoint() );
565 switch( aEvent.GetId() )
569 long item =
m_jobList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
580 long item =
m_jobList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
590 default: wxFAIL_MSG( wxT(
"Unknown ID in context menu event" ) );
604 wxArrayString headers;
605 std::vector<wxArrayString> items;
607 headers.Add(
_(
"Job Types" ) );
611 for(
const std::pair<const wxString, JOB_REGISTRY_ENTRY>& entry : jobMap )
614 item.Add( wxGetTranslation( entry.second.title ) );
615 items.emplace_back( item );
626 if( !selectedString.IsEmpty() )
628 for(
const std::pair<const wxString, JOB_REGISTRY_ENTRY>& entry : jobMap )
630 if( wxGetTranslation( entry.second.title ) == selectedString )
632 jobKey = entry.first;
638 if( !jobKey.IsEmpty() )
640 JOB* job = JOB_REGISTRY::CreateInstance<JOB>( jobKey );
651 wxArrayString headers;
652 std::vector<wxArrayString> items;
654 headers.Add(
_(
"Job Types" ) );
656 for(
const std::pair<const JOBSET_OUTPUT_TYPE, JOB_TYPE_INFO>& jobType :
jobTypeInfos )
659 item.Add( wxGetTranslation( jobType.second.name ) );
660 items.emplace_back( item );
671 for(
const std::pair<const JOBSET_OUTPUT_TYPE, JOB_TYPE_INFO>& jobType :
jobTypeInfos )
673 if( wxGetTranslation( jobType.second.name ) == selectedString )
700 wxFileName fileName =
m_jobsFile->GetFullFilename();
701 wxString msg =
_(
"Save changes to '%s' before closing?" );
706 return m_jobsFile->SaveToFile();
731 wxFileName boardfn =
project.GetProjectFullName();
732 boardfn.SetExt( FILEEXT::PcbFileExtension );
735 wxEventBlocker blocker(
this );
737 frame->
OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
751 wxFileName schFn =
project.GetProjectFullName();
754 wxEventBlocker blocker(
this );
769 long item =
m_jobList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
781 m_jobList->SetItemState( item - 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
787 long item =
m_jobList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
792 if( item ==
m_jobList->GetItemCount() - 1 )
799 m_jobList->SetItemState( item + 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
817 wxFileName fn =
project.GetProjectFullName();
818 wxSetWorkingDirectory( fn.GetPath() );
827 for(
auto& output :
m_jobsFile->GetOutputs() )
833 delete progressReporter;
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
BITMAPS
A list of all bitmap identifiers.
Class DIALOG_JOB_OUTPUT_BASE.
wxStaticText * m_textArchiveFormat
STD_BITMAP_BUTTON * m_buttonOutputPath
wxListBox * m_listBoxOnly
wxChoice * m_choiceArchiveformat
wxTextCtrl * m_textCtrlOutputPath
bool TransferDataFromWindow() override
DIALOG_JOB_OUTPUT(wxWindow *aParent, JOBSET *aJobsFile, JOBSET_OUTPUT *aOutput)
bool TransferDataToWindow() override
std::map< int, wxString > m_onlyMap
virtual void onOutputPathBrowseClicked(wxCommandEvent &event) override
Class DIALOG_OUTPUT_RUN_RESULTS_BASE.
wxStaticText * m_staticTextOutputName
DIALOG_OUTPUT_RUN_RESULTS(wxWindow *aParent, JOBSET *aJobsFile, JOBSET_OUTPUT *aOutput)
wxString GetTextSelection(int aColumn=0)
Return the selected text from aColumn in the wxListCtrl in the dialog.
void SetListLabel(const wxString &aLabel)
std::vector< JOBSET_JOB > GetJobsForOutput(JOBSET_OUTPUT *aOutput)
std::vector< JOBSET_JOB > & GetJobs()
void SetFormat(FORMAT format)
wxString GetOutputPath() const
void SetOutputPath(const wxString &aPath)
bool RunJobsForOutput(JOBSET_OUTPUT *aOutput, bool aBail=false)
bool RunJobsAllOutputs(bool aBail=false)
static const REGISTRY_MAP_T & GetRegistry()
std::unordered_map< wxString, JOB_REGISTRY_ENTRY > REGISTRY_MAP_T
static KIWAY::FACE_T GetKifaceType(const wxString &aName)
An simple container class that lets us dispatch output jobs to kifaces.
The main KiCad project manager frame.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Open a project or set of files given by aFileList.
bool ProcessJobConfigDialog(KIWAY::FACE_T aFace, JOB *aJob, wxWindow *aWindow)
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
FACE_T
Known KIFACE implementations.
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
wxBitmapButton * m_buttonUp
wxBitmapButton * m_buttonAddJob
wxButton * m_buttonRunAllOutputs
wxBoxSizer * m_outputListSizer
wxBitmapButton * m_buttonOutputAdd
wxScrolledWindow * m_outputList
wxBitmapButton * m_buttonDown
wxString GetFilePath() const
virtual void OnAddOutputClick(wxCommandEvent &aEvent) override
virtual void OnJobListItemRightClick(wxListEvent &event) override
std::unique_ptr< JOBSET > m_jobsFile
void openJobOptionsForListItem(size_t aItemIndex)
std::unordered_map< JOBSET_OUTPUT *, PANEL_JOB_OUTPUT * > m_outputPanelMap
wxAuiNotebook * m_parentBook
PANEL_JOBS(wxAuiNotebook *aParent, KICAD_MANAGER_FRAME *aFrame, std::unique_ptr< JOBSET > aJobsFile)
virtual void OnAddJobClick(wxCommandEvent &aEvent) override
void RemoveOutput(JOBSET_OUTPUT *aOutput)
void addJobOutputPanel(JOBSET_OUTPUT *aOutput)
void onJobListMenu(wxCommandEvent &aEvent)
virtual void OnJobButtonUp(wxCommandEvent &aEvent) override
virtual void OnJobButtonDown(wxCommandEvent &aEvent) override
virtual void OnRunAllJobsClick(wxCommandEvent &event) override
bool GetCanClose() override
void EnsurePcbSchFramesOpen()
virtual void OnSaveButtonClick(wxCommandEvent &aEvent) override
KICAD_MANAGER_FRAME * m_frame
virtual void OnJobListDoubleClicked(wxListEvent &aEvent) override
Class PANEL_JOB_OUTPUT_BASE.
wxBitmapButton * m_buttonOutputRun
wxStaticBitmap * m_statusBitmap
wxStaticBitmap * m_bitmapOutputType
wxBitmapButton * m_buttonOutputOptions
wxStaticText * m_textOutputType
virtual void OnLastStatusClick(wxMouseEvent &event) override
virtual void OnOutputRunClick(wxCommandEvent &event) override
KICAD_MANAGER_FRAME * m_frame
void onMenu(wxCommandEvent &aEvent)
PANEL_JOBS * m_panelParent
virtual void OnOutputOptionsClick(wxCommandEvent &event) override
PANEL_JOB_OUTPUT(wxWindow *aParent, PANEL_JOBS *aPanelParent, KICAD_MANAGER_FRAME *aFrame, JOBSET *aFile, JOBSET_OUTPUT *aOutput)
Container for project specific data.
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
static const std::string KiCadSchematicFileExtension
static wxString ZipFileWildcard()
Some functions to handle hotkeys in KiCad.
static std::map< JOBSET_OUTPUT_TYPE, JOB_TYPE_INFO > jobTypeInfos
std::shared_ptr< JOB > m_job
std::vector< wxString > m_only
Transient property, not stored for now.
JOBS_OUTPUT_HANDLER * m_outputHandler
std::unordered_map< wxString, std::optional< bool > > m_lastRunSuccessMap
std::optional< bool > m_lastRunSuccess
JOBSET_OUTPUT_TYPE m_type
Definition of file extensions used in Kicad.
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().