50#include <wx/filedlg.h>
52#include <wx/textdlg.h>
80 void OnHelp( wxCommandEvent& event )
override;
87 void OnIdle( wxIdleEvent& event )
override;
92 const wxString& aName = wxEmptyString );
122 m_initialized( false ),
123 m_helpWindow( nullptr )
136 { wxID_CANCEL,
_(
"Close" ) } } );
144 [&]( wxCommandEvent& )
165 for(
const std::unique_ptr<BOM_GENERATOR_HANDLER>& plugin :
m_generators )
167 wxString
name = plugin->GetName();
168 wxFileName
path( plugin->GetStoredPath() );
175 setting.
command = plugin->GetCommand();
195 auto plugin = std::make_unique<BOM_GENERATOR_HANDLER>( setting.
path );
197 plugin->SetName( setting.
name );
199 if( !setting.
command.IsEmpty() )
200 plugin->SetCommand( setting.
command );
213 if( !
m_generators[ii]->FindFilePath().Exists( wxFILE_EXISTS_REGULAR ) )
215 wxLogTrace(
BOM_TRACE, wxS(
"BOM plugin %s not found" ),
217 name.Append( wxT(
" " ) +
_(
"(file missing)" ) );
219 if( active_plugin_name ==
name )
220 active_plugin_name.Clear();
225 if( active_plugin_name ==
name )
237 auto plugin = std::make_unique<BOM_GENERATOR_HANDLER>( aPath );
239 if( !plugin->IsOk() )
242 if( !aName.IsEmpty() )
244 plugin->SetName( aName );
288 if( !plugin->
FindFilePath().Exists( wxFILE_EXISTS_REGULAR ) )
294 wxString::Format(
_(
"The selected BOM generator script %s could not be found." ),
295 plugin->
GetFile().GetFullPath() );
297 if( !plugin->
GetFile().IsAbsolute() )
299 msg.Append( wxString::Format(
_(
"\n\nSearched:\n\t%s\n\t%s" ),
314 if( plugin->
Options().Index( wxT(
"show_console" ) ) == wxNOT_FOUND )
333 wxString fullfilename = fn.GetFullPath();
382 if( filename.IsEmpty() )
386 wxFileName fn( filename );
387 wxString
name = wxGetTextFromUser(
_(
"Generator nickname:" ),
_(
"Add Generator" ),
388 fn.GetName(),
this );
396 wxMessageBox( wxString::Format(
_(
"Nickname '%s' already in use." ),
name ) );
411 catch(
const std::runtime_error& e )
420 static wxString lastPath;
422 if( lastPath.IsEmpty() )
425 wxString fullFileName = wxFileSelector(
_(
"Generator File" ), lastPath, wxEmptyString,
426 wxEmptyString, wxFileSelectorDefaultWildcardStr,
440 wxString pluginFile = plugin->GetFile().GetFullPath();
442 if( pluginFile.Length() <= 2 )
444 wxMessageBox(
_(
"Generator file name not found." ) );
448 wxString editorname =
Pgm().GetTextEditor();
450 if( !editorname.IsEmpty() )
453 wxMessageBox(
_(
"No text editor selected in KiCad. Please choose one." ) );
503 static constexpr wxChar OPT_SHOW_CONSOLE[] = wxT(
"show_console" );
512 if( plugin->Options().Index( OPT_SHOW_CONSOLE ) == wxNOT_FOUND )
513 plugin->Options().Add( OPT_SHOW_CONSOLE );
517 plugin->Options().Remove( OPT_SHOW_CONSOLE );
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
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.
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)
Call the executable file aEditorName with the parameter aFileName.
Some functions to handle hotkeys in KiCad.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)
std::vector< BOM_PLUGIN_SETTINGS > plugins