50#include <wx/filedlg.h>
53#include <wx/textdlg.h>
81 void OnHelp( wxCommandEvent& event )
override;
88 void OnIdle( wxIdleEvent& event )
override;
93 const wxString& aName = wxEmptyString );
123 m_initialized( false ),
124 m_helpWindow( nullptr )
137 { wxID_CANCEL,
_(
"Close" ) } } );
145 [&]( wxCommandEvent& )
166 for(
const std::unique_ptr<BOM_GENERATOR_HANDLER>& plugin :
m_generators )
168 wxString
name = plugin->GetName();
169 wxFileName
path( plugin->GetStoredPath() );
176 setting.
command = plugin->GetCommand();
196 auto plugin = std::make_unique<BOM_GENERATOR_HANDLER>( setting.
path );
198 plugin->SetName( setting.
name );
200 if( !setting.
command.IsEmpty() )
201 plugin->SetCommand( setting.
command );
214 if( !
m_generators[ii]->FindFilePath().Exists( wxFILE_EXISTS_REGULAR ) )
216 wxLogTrace(
BOM_TRACE, wxS(
"BOM plugin %s not found" ),
218 name.Append( wxT(
" " ) +
_(
"(file missing)" ) );
220 if( active_plugin_name ==
name )
221 active_plugin_name.Clear();
226 if( active_plugin_name ==
name )
238 auto plugin = std::make_unique<BOM_GENERATOR_HANDLER>( aPath );
240 if( !plugin->IsOk() )
243 if( !aName.IsEmpty() )
245 plugin->SetName( aName );
289 if( !plugin->
FindFilePath().Exists( wxFILE_EXISTS_REGULAR ) )
295 wxString::Format(
_(
"The selected BOM generator script %s could not be found." ),
296 plugin->
GetFile().GetFullPath() );
298 if( !plugin->
GetFile().IsAbsolute() )
300 msg.Append( wxString::Format(
_(
"\n\nSearched:\n\t%s\n\t%s" ),
315 if( plugin->
Options().Index( wxT(
"show_console" ) ) == wxNOT_FOUND )
334 wxString fullfilename = fn.GetFullPath();
383 if( filename.IsEmpty() )
387 wxFileName fn( filename );
388 wxString
name = wxGetTextFromUser(
_(
"Generator nickname:" ),
_(
"Add Generator" ),
389 fn.GetName(),
this );
397 wxMessageBox( wxString::Format(
_(
"Nickname '%s' already in use." ),
name ) );
412 catch(
const std::runtime_error& e )
421 static wxString lastPath;
423 if( lastPath.IsEmpty() )
426 wxString fullFileName = wxFileSelector(
_(
"Generator File" ), lastPath, wxEmptyString,
427 wxEmptyString, wxFileSelectorDefaultWildcardStr,
441 wxString pluginFile = plugin->GetFile().GetFullPath();
443 if( pluginFile.Length() <= 2 )
445 wxMessageBox(
_(
"Generator file name not found." ) );
451 if( !editorname.IsEmpty() )
454 wxMessageBox(
_(
"No text editor selected in KiCad. Please choose one." ) );
504 static constexpr wxChar OPT_SHOW_CONSOLE[] = wxT(
"show_console" );
513 if( plugin->Options().Index( OPT_SHOW_CONSOLE ) == wxNOT_FOUND )
514 plugin->Options().Add( OPT_SHOW_CONSOLE );
518 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.
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.
std::vector< std::unique_ptr< BOM_GENERATOR_HANDLER > > BOM_GENERATOR_ARRAY
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