46#include <wx/filedlg.h>
49#include <wx/textdlg.h>
82 { wxID_CANCEL,
_(
"Close" ) } } );
90 [&]( wxCommandEvent& )
111 for(
const std::unique_ptr<BOM_GENERATOR_HANDLER>& plugin :
m_generators )
113 wxString
name = plugin->GetName();
114 wxFileName
path( plugin->GetStoredPath() );
121 setting.
command = plugin->GetCommand();
141 auto plugin = std::make_unique<BOM_GENERATOR_HANDLER>( setting.
path );
143 plugin->SetName( setting.
name );
145 if( !setting.
command.IsEmpty() )
146 plugin->SetCommand( setting.
command );
159 if( !
m_generators[ii]->FindFilePath().Exists( wxFILE_EXISTS_REGULAR ) )
161 wxLogTrace(
BOM_TRACE, wxS(
"BOM plugin %s not found" ),
163 name.Append( wxT(
" " ) +
_(
"(file missing)" ) );
165 if( active_plugin_name ==
name )
166 active_plugin_name.Clear();
171 if( active_plugin_name ==
name )
183 auto plugin = std::make_unique<BOM_GENERATOR_HANDLER>( aPath );
185 if( !plugin->IsOk() )
188 if( !aName.IsEmpty() )
190 plugin->SetName( aName );
234 if( !plugin->
FindFilePath().Exists( wxFILE_EXISTS_REGULAR ) )
240 wxString::Format(
_(
"The selected BOM generator script %s could not be found." ),
241 plugin->
GetFile().GetFullPath() );
243 if( !plugin->
GetFile().IsAbsolute() )
245 msg.Append( wxString::Format(
_(
"\n\nSearched:\n\t%s\n\t%s" ),
260 if( plugin->
Options().Index( wxT(
"show_console" ) ) == wxNOT_FOUND )
275 wxFileName fn =
m_parent->Schematic().GetFileName();
279 wxString fullfilename = fn.GetFullPath();
287 m_parent->SetExecFlags( wxEXEC_SHOW_CONSOLE );
292 if(
m_parent->ReadyToNetlist(
_(
"Generating BOM requires a fully annotated schematic." ) ) )
328 if( filename.IsEmpty() )
332 wxFileName fn( filename );
333 wxString
name = wxGetTextFromUser(
_(
"Generator nickname:" ),
_(
"Add Generator" ),
334 fn.GetName(),
this );
342 wxMessageBox( wxString::Format(
_(
"Nickname '%s' already in use." ),
name ) );
357 catch(
const std::runtime_error& e )
366 static wxString lastPath;
368 if( lastPath.IsEmpty() )
371 wxString fullFileName = wxFileSelector(
_(
"Generator File" ), lastPath, wxEmptyString,
372 wxEmptyString, wxFileSelectorDefaultWildcardStr,
386 wxString pluginFile = plugin->GetFile().GetFullPath();
388 if( pluginFile.Length() <= 2 )
390 wxMessageBox(
_(
"Generator file name not found." ) );
396 if( !editorname.IsEmpty() )
399 wxMessageBox(
_(
"No text editor selected in KiCad. Please choose one." ) );
449 static constexpr wxChar OPT_SHOW_CONSOLE[] = wxT(
"show_console" );
458 if( plugin->Options().Index( OPT_SHOW_CONSOLE ) == wxNOT_FOUND )
459 plugin->Options().Add( OPT_SHOW_CONSOLE );
463 plugin->Options().Remove( OPT_SHOW_CONSOLE );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Bill of material output generator.
const wxString & GetInfo() const
Return plugin description stored in the plugin header file (if available).
const wxFileName & GetFile() const
Return the file name of the plugin.
bool IsOk()
Return true if the plugin is ready to work, i.e.
wxArrayString & Options()
Accessor to array of options.
const wxString & GetName() const
Return the customisable plugin name.
wxFileName FindFilePath() const
Returns the calculated path to the plugin: if the path is already absolute and exists,...
const wxString & GetCommand() const
Return the command to execute the plugin.
STD_BITMAP_BUTTON * m_buttonEdit
wxTextCtrl * m_textCtrlName
STD_BITMAP_BUTTON * m_buttonAddGenerator
STD_BITMAP_BUTTON * m_buttonDelGenerator
DIALOG_BOM_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Bill of Materials"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxCheckBox * m_checkBoxShowConsole
wxTextCtrl * m_textCtrlCommand
wxListBox * m_lbGenerators
void OnEditGenerator(wxCommandEvent &event) override
SCH_EDIT_FRAME * m_parent
void OnRemoveGenerator(wxCommandEvent &event) override
void installGeneratorsList()
BOM_GENERATOR_HANDLER * selectedGenerator()
bool pluginExists(const wxString &aName)
BOM_GENERATOR_HANDLER * addGenerator(const wxString &aPath, const wxString &aName=wxEmptyString)
void OnIdle(wxIdleEvent &event) override
void OnHelp(wxCommandEvent &event) override
void OnCommandLineEdited(wxCommandEvent &event) override
wxString chooseGenerator()
void OnGeneratorSelected(wxCommandEvent &event) override
void OnNameEdited(wxCommandEvent &event) override
void OnRunGenerator(wxCommandEvent &event) override
HTML_MESSAGE_BOX * m_helpWindow
void OnShowConsoleChanged(wxCommandEvent &event) override
BOM_GENERATOR_ARRAY m_generators
DIALOG_BOM(SCH_EDIT_FRAME *parent)
void OnAddGenerator(wxCommandEvent &event) override
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
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...
static std::vector< BOM_PLUGIN_SETTINGS > DefaultBomPlugins()
static wxString GetUserPluginsPath()
Gets the user path for plugins.
static wxString GetStockPluginsPath()
Gets the stock (install) plugins path.
virtual const wxString & GetTextEditor(bool aCanShowFileChooser=true)
Return the path to the preferred text editor application.
Schematic editor (Eeschema) main window.
A wrapper for reporting to a wxString object.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
int InvokeDialogCreateBOM(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BOM and return whatever DIALOG_BOM::ShowModal() returns.
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback, bool aFileForKicad)
Call the executable file aEditorName with the parameter aFileName.
Some functions to handle hotkeys in KiCad.
PGM_BASE & Pgm()
The global program "get" accessor.
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)
std::vector< BOM_PLUGIN_SETTINGS > plugins
IbisParser parser & reporter