50#include <wx/filedlg.h>
53#include <wx/textdlg.h>
72 m_initialized( false ),
73 m_helpWindow( nullptr )
86 { wxID_CANCEL,
_(
"Close" ) } } );
94 [&]( wxCommandEvent& )
115 for(
const std::unique_ptr<BOM_GENERATOR_HANDLER>& plugin :
m_generators )
117 wxString
name = plugin->GetName();
118 wxFileName
path( plugin->GetStoredPath() );
125 setting.
command = plugin->GetCommand();
145 auto plugin = std::make_unique<BOM_GENERATOR_HANDLER>( setting.
path );
147 plugin->SetName( setting.
name );
149 if( !setting.
command.IsEmpty() )
150 plugin->SetCommand( setting.
command );
163 if( !
m_generators[ii]->FindFilePath().Exists( wxFILE_EXISTS_REGULAR ) )
165 wxLogTrace(
BOM_TRACE, wxS(
"BOM plugin %s not found" ),
167 name.Append( wxT(
" " ) +
_(
"(file missing)" ) );
169 if( active_plugin_name ==
name )
170 active_plugin_name.Clear();
175 if( active_plugin_name ==
name )
187 auto plugin = std::make_unique<BOM_GENERATOR_HANDLER>( aPath );
189 if( !plugin->IsOk() )
192 if( !aName.IsEmpty() )
194 plugin->SetName( aName );
238 if( !plugin->
FindFilePath().Exists( wxFILE_EXISTS_REGULAR ) )
244 wxString::Format(
_(
"The selected BOM generator script %s could not be found." ),
245 plugin->
GetFile().GetFullPath() );
247 if( !plugin->
GetFile().IsAbsolute() )
249 msg.Append( wxString::Format(
_(
"\n\nSearched:\n\t%s\n\t%s" ),
264 if( plugin->
Options().Index( wxT(
"show_console" ) ) == wxNOT_FOUND )
283 wxString fullfilename = fn.GetFullPath();
331 if( filename.IsEmpty() )
335 wxFileName fn( filename );
336 wxString
name = wxGetTextFromUser(
_(
"Generator nickname:" ),
_(
"Add Generator" ),
337 fn.GetName(),
this );
345 wxMessageBox( wxString::Format(
_(
"Nickname '%s' already in use." ),
name ) );
360 catch(
const std::runtime_error& e )
369 static wxString lastPath;
371 if( lastPath.IsEmpty() )
374 wxString fullFileName = wxFileSelector(
_(
"Generator File" ), lastPath, wxEmptyString,
375 wxEmptyString, wxFileSelectorDefaultWildcardStr,
389 wxString pluginFile = plugin->GetFile().GetFullPath();
391 if( pluginFile.Length() <= 2 )
393 wxMessageBox(
_(
"Generator file name not found." ) );
399 if( !editorname.IsEmpty() )
402 wxMessageBox(
_(
"No text editor selected in KiCad. Please choose one." ) );
452 static constexpr wxChar OPT_SHOW_CONSOLE[] = wxT(
"show_console" );
461 if( plugin->Options().Index( OPT_SHOW_CONSOLE ) == wxNOT_FOUND )
462 plugin->Options().Add( OPT_SHOW_CONSOLE );
466 plugin->Options().Remove( OPT_SHOW_CONSOLE );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
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
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...
virtual void ClearMsgPanel()
Clear all messages from the message panel.
static std::vector< BOM_PLUGIN_SETTINGS > DefaultBomPlugins()
void SetDialogSizeInDU(int aWidth, int aHeight)
Set the dialog size, using a "logical" value.
void AddHTML_Text(const wxString &message)
Add HTML text (without any change) to message list.
void ShowModeless()
Show a modeless version of the dialog (without an OK button).
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.
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
EESCHEMA_SETTINGS * eeconfig() const
Schematic editor (Eeschema) main window.
void SetExecFlags(const int aFlags)
Set (adds) specified flags for next execution of external generator of the netlist or bom.
bool ReadyToNetlist(const wxString &aAnnotateMessage)
Check if we are ready to write a netlist file for the current schematic.
bool WriteNetListFile(int aFormat, const wxString &aFullFileName, unsigned aNetlistOptions, REPORTER *aReporter=nullptr)
Create a netlist file.
SCHEMATIC & Schematic() const
void SetNetListerCommand(const wxString &aCommand)
A wrapper for reporting to a wxString object.
const wxString & GetMessages() const
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box 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