24#include <wx/aui/auibook.h>
28#include <wx/checkbox.h>
36#include <wx/dcclient.h>
68 int jobBmpColId =
m_jobList->AppendColumn( wxT(
"" ) );
69 int jobNoColId =
m_jobList->AppendColumn(
_(
"No." ) );
70 int jobDescColId =
m_jobList->AppendColumn(
_(
"Job Description" ) );
71 int jobSourceColId =
m_jobList->AppendColumn(
_(
"Source" ) );
72 m_jobList->SetColumnWidth( jobBmpColId, 26 );
73 m_jobList->SetColumnWidth( jobNoColId, GetTextExtent( wxT(
"XXXX" ) ).GetWidth() );
74 m_jobList->SetColumnWidth( jobSourceColId, GetTextExtent( wxT(
"XXXXXX" ) ).GetWidth() );
76 wxImageList* imageList =
new wxImageList( 16, 16,
true, 3 );
77 imageList->Add(
KiBitmapBundle( BITMAPS::ercerr ).GetBitmap( wxSize( 16, 16 ) ) );
78 imageList->Add(
KiBitmapBundle( BITMAPS::checked_ok ).GetBitmap( wxSize( 16, 16 ) ) );
79 m_jobList->SetImageList( imageList, wxIMAGE_LIST_SMALL );
96 m_jobList->SetItem( itemIndex, jobNoColId, wxString::Format(
"%d", num++ ) );
97 m_jobList->SetItem( itemIndex, jobDescColId, job.GetDescription() );
100 wxString source = wxEmptyString;
105 source = wxT(
"PCB" );
107 source = wxT(
"SCH" );
110 m_jobList->SetItem( itemIndex, jobSourceColId, source );
138 int itemIndex =
event.GetIndex();
146 if(
static_cast<size_t>( itemIndex ) < jobs.size() )
148 wxString jobId = jobs[itemIndex].m_id;
190 long style = GetWindowStyleFlag();
191 style &= ~wxBORDER_MASK;
192 style |= wxBORDER_SIMPLE;
193 SetWindowStyleFlag( style );
218 wxCHECK( destination, );
227 wxCHECK( destination, );
254 wxClientDC dc(
this );
255 int width = GetSize().GetWidth();
258 m_pathInfo->SetLabel( wxControl::Ellipsize( msg, dc, wxELLIPSIZE_MIDDLE, width ) );
272 wxFileName fn =
project.GetProjectFullName();
273 wxSetWorkingDirectory( fn.GetPath() );
285 delete progressReporter;
295 wxCHECK( destination, );
304 wxCHECK( destination, );
307 menu.Append( wxID_EDIT,
_(
"Edit Destination Options..." ) );
308 menu.Append( wxID_DELETE,
_(
"Delete Destination" ) );
310 menu.AppendSeparator();
311 menu.Append( wxID_VIEW_DETAILS,
_(
"View Last Run Log..." ) );
313 menu.Enable( wxID_VIEW_DETAILS, destination->
m_lastRunSuccess.has_value() );
321 wxCHECK( destination, );
334 virtual void OnDelete( wxCommandEvent& aEvent )
override
353 switch( aEvent.GetId() )
357 wxCommandEvent
dummy;
364 wxCommandEvent
dummy;
369 case wxID_VIEW_DETAILS:
377 wxFAIL_MSG( wxT(
"Unknown ID in context menu event" ) );
400 wxArrayInt selectedRows =
m_grid->GetSelectedRows();
404 menu.AppendSeparator();
405 menu.Append(
GRIDTRICKS_ID_COPY,
_(
"Copy" ) +
"\tCtrl+C",
_(
"Copy selected cells to clipboard" ) );
413 m_grid->PopupMenu( &menu );
419 wxArrayInt selectedRows =
m_grid->GetSelectedRows();
423 if( selectedRows.size() > 0 )
425 m_grid->SetGridCursor( selectedRows[0], 2 );
426 m_grid->EnableCellEditControl();
431 if( selectedRows.size() > 0 )
436 wxCommandEvent
dummy;
450 int curr_col = aEvent.GetCol();
451 int curr_row = aEvent.GetRow();
480 std::unique_ptr<JOBSET> aJobsFile ) :
482 m_parentBook( aParent ),
484 m_jobsFile(
std::
move( aJobsFile ) )
490 m_jobsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
548 wxString source = wxEmptyString;
553 source = wxT(
"PCB" );
555 source = wxT(
"SCH" );
567 panel->UpdateStatus();
576 tabName = wxS(
"*" ) + tabName;
589 m_outputListSizer->Add( destinationPanel, 0, wxEXPAND, 5 );
600 std::vector<PANEL_DESTINATION*> panels;
605 panels.push_back( panel );
627 bool success =
false;
639 if( job.
m_job->GetType() ==
"special_execute" )
649 else if( job.
m_job->GetType() ==
"special_copyfiles" )
674 int row = aEvent.GetRow();
675 int col = aEvent.GetCol();
687 m_jobsFile->SaveToFile( wxEmptyString,
true );
697 wxArrayString headers;
698 std::vector<wxArrayString> items;
700 headers.Add(
_(
"Job Types" ) );
704 for(
const std::pair<const wxString, JOB_REGISTRY_ENTRY>& entry : jobMap )
706 if( entry.second.deprecated )
710 item.Add( wxGetTranslation( entry.second.title ) );
711 items.emplace_back( item );
723 if( !selectedString.IsEmpty() )
725 for(
const std::pair<const wxString, JOB_REGISTRY_ENTRY>& entry : jobMap )
727 if( entry.second.deprecated )
730 if( wxGetTranslation( entry.second.title ) == selectedString )
732 jobKey = entry.first;
738 if( !jobKey.IsEmpty() )
742 JOB* job = JOB_REGISTRY::CreateInstance<JOB>( jobKey );
768 wxArrayInt selectedRows =
m_jobsGrid->GetSelectedRows();
770 if( selectedRows.empty() )
777 selectedRows.Sort( [](
int* first,
int* second ) {
return *second - *first; } );
779 int select = selectedRows[0];
781 for(
int row : selectedRows )
796 wxArrayString headers;
797 std::vector<wxArrayString> items;
799 headers.Add(
_(
"Destination Types" ) );
804 item.Add( wxGetTranslation( destinationTypeInfo.name ) );
805 items.emplace_back( item );
818 if( wxGetTranslation( destinationTypeInfo.name ) == selectedString )
845 wxFileName fileName =
m_jobsFile->GetFullFilename();
846 wxString msg =
_(
"Save changes to '%s' before closing?" );
851 return m_jobsFile->SaveToFile(wxEmptyString, true);
876 wxFileName boardfn =
project.GetProjectFullName();
877 boardfn.SetExt( FILEEXT::PcbFileExtension );
880 wxEventBlocker blocker(
this );
882 frame->
OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
884 if( !frame->IsVisible() )
899 wxFileName schFn =
project.GetProjectFullName();
902 wxEventBlocker blocker(
this );
906 if( !frame->IsVisible() )
950 if( item < m_jobsGrid->GetNumberRows() - 1 )
979 panel->ClearStatus();
989 wxFileName fn =
project.GetProjectFullName();
990 wxSetWorkingDirectory( fn.GetPath() );
1000 panel->UpdateStatus();
1002 delete progressReporter;
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Class DIALOG_JOBSET_RUN_LOG_BASE.
wxStaticText * m_staticTextOutputName
wxTextCtrl * m_textCtrlOutput
void OnJobListItemSelected(wxListEvent &event) override
DIALOG_JOBSET_RUN_LOG(wxWindow *aParent, JOBSET *aJobsFile, JOBSET_DESTINATION *aDestination)
JOBSET_DESTINATION * m_destination
virtual void OnUpdateUI(wxUpdateUIEvent &event) override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
wxString GetTextSelection(int aColumn=0)
Return the selected text from aColumn in the wxListCtrl in the dialog.
void SetListLabel(const wxString &aLabel)
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
bool m_multiCellEditEnabled
bool m_enableSingleClickEdit
virtual void doPopupSelection(wxCommandEvent &event)
WX_GRID * m_grid
I don't own the grid, but he owns me.
std::vector< JOBSET_DESTINATION > & GetDestinations()
void SetDirty(bool aFlag=true)
std::vector< JOBSET_JOB > GetJobsForDestination(JOBSET_DESTINATION *aDestination)
std::vector< JOBSET_JOB > & GetJobs()
void showPopupMenu(wxMenu &menu, wxGridEvent &aEvent) override
void doPopupSelection(wxCommandEvent &event) override
bool handleDoubleClick(wxGridEvent &aEvent) override
JOBS_GRID_TRICKS(PANEL_JOBSET *aParent, WX_GRID *aGrid)
bool RunJobsAllDestinations(bool aBail=false)
bool RunJobsForDestination(JOBSET_DESTINATION *aDestination, 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.
Class PANEL_DESTINATION_BASE.
wxStaticBitmap * m_statusBitmap
wxButton * m_buttonGenerate
wxStaticText * m_pathInfo
STD_BITMAP_BUTTON * m_buttonProperties
STD_BITMAP_BUTTON * m_buttonDelete
wxStaticBitmap * m_bitmapOutputType
wxStaticText * m_textOutputType
void onMenu(wxCommandEvent &aEvent)
JOBSET_DESTINATION * GetDestination()
void UpdatePathInfo(const wxString &aMsg)
PANEL_DESTINATION(wxWindow *aParent, PANEL_JOBSET *aPanelParent, KICAD_MANAGER_FRAME *aFrame, JOBSET *aFile, JOBSET_DESTINATION *aDestination)
virtual void OnDelete(wxCommandEvent &aEvent) override
virtual void OnLastStatusClick(wxMouseEvent &aEvent) override
virtual void OnGenerate(wxCommandEvent &event) override
void OnRightDown(wxMouseEvent &aEvent) override
KICAD_MANAGER_FRAME * m_frame
void OnProperties(wxCommandEvent &aEvent) override
PANEL_JOBSET * m_panelParent
STD_BITMAP_BUTTON * m_buttonAddDestination
STD_BITMAP_BUTTON * m_buttonDown
wxScrolledWindow * m_destinationList
wxBoxSizer * m_destinationListSizer
STD_BITMAP_BUTTON * m_buttonAddJob
STD_BITMAP_BUTTON * m_buttonDelete
STD_BITMAP_BUTTON * m_buttonUp
wxString GetFilePath() const
virtual void OnSaveButtonClick(wxCommandEvent &aEvent) override
void OnJobButtonDelete(wxCommandEvent &aEvent) override
virtual void OnJobButtonDown(wxCommandEvent &aEvent) override
void EnsurePcbSchFramesOpen()
bool GetCanClose() override
wxAuiNotebook * m_parentBook
void addDestinationPanel(JOBSET_DESTINATION *aDestination)
virtual void OnGenerateAllDestinationsClick(wxCommandEvent &event) override
bool OpenJobOptionsForListItem(size_t aItemIndex)
std::vector< PANEL_DESTINATION * > GetDestinationPanels()
void buildDestinationList()
KICAD_MANAGER_FRAME * m_frame
PANEL_JOBSET(wxAuiNotebook *aParent, KICAD_MANAGER_FRAME *aFrame, std::unique_ptr< JOBSET > aJobsFile)
virtual void OnAddDestinationClick(wxCommandEvent &aEvent) override
virtual void OnAddJobClick(wxCommandEvent &aEvent) override
std::unique_ptr< JOBSET > m_jobsFile
virtual void OnGridCellChange(wxGridEvent &aEvent) override
void RemoveDestination(PANEL_DESTINATION *aPanel)
virtual void OnJobButtonUp(wxCommandEvent &aEvent) override
virtual void OnSizeGrid(wxSizeEvent &aEvent) override
Container for project specific data.
void OverrideMinSize(double aXPct, double aYPct)
Grids that have column sizes automatically set to fill the available width don't want to shrink after...
bool CancelPendingChanges()
void CancelShowEditorOnMouseUp()
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
A wrapper for reporting to a wxString object.
const wxString & GetMessages() const
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
static const std::string KiCadSchematicFileExtension
Some functions to handle hotkeys in KiCad.
KICOMMON_API std::map< JOBSET_DESTINATION_T, JOBSET_DESTINATION_T_INFO > JobsetDestinationTypeInfos
KICOMMON_API wxFont GetSmallInfoFont(wxWindow *aWindow)
KICOMMON_API std::map< JOBSET_DESTINATION_T, JOBSET_DESTINATION_T_INFO > JobsetDestinationTypeInfos
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
std::vector< FAB_LAYER_COLOR > dummy
std::unordered_map< wxString, REPORTER * > m_lastRunReporters
JOBSET_DESTINATION_T m_type
wxString GetPathInfo() const
Transient property, not stored for now.
wxString GetDescription() const
std::optional< bool > m_lastRunSuccess
std::unordered_map< wxString, std::optional< bool > > m_lastRunSuccessMap
std::shared_ptr< JOB > m_job
Definition of file extensions used in Kicad.