32#include <wx/filename.h>
33#include <wx/filedlg.h>
54 wxFileDialog dlg(
this,
_(
"Import Symbol" ),
m_mruPath, wxEmptyString,
55 wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
57 if( dlg.ShowModal() == wxID_CANCEL )
60 wxFileName fn = dlg.GetPath();
62 if( fn.GetExt().IsEmpty() )
70 wxArrayString symbols;
81 msg.Printf(
_(
"Cannot import symbol library '%s'." ), fn.GetFullPath() );
88 msg.Printf(
_(
"Symbol library file '%s' is empty." ), fn.GetFullPath() );
93 wxString symbolName = symbols[0];
100 msg.Printf(
_(
"Symbol %s already exists in library '%s'." ), symbolName, libName );
102 KIDIALOG errorDlg(
this, msg,
_(
"Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
103 errorDlg.SetOKLabel(
_(
"Overwrite" ) );
106 if( errorDlg.
ShowModal() == wxID_CANCEL )
129 fn.SetName( symbol->
GetName().Lower() );
132 wxFileDialog dlg(
this,
_(
"Export Symbol" ),
m_mruPath, fn.GetFullName(),
135 if( dlg.ShowModal() == wxID_CANCEL )
145 if( fn.FileExists() )
153 msg.Printf(
_(
"Error occurred attempting to load symbol library file '%s'." ),
161 msg.Printf(
_(
"Symbol %s already exists in library '%s'." ),
165 KIDIALOG errorDlg(
this, msg,
_(
"Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
166 errorDlg.SetOKLabel(
_(
"Overwrite" ) );
169 if( errorDlg.
ShowModal() == wxID_CANCEL )
174 if( fn.Exists() && !fn.IsDirWritable() )
176 msg.Printf(
_(
"Insufficient permissions to save library '%s'." ),
184 if( !fn.FileExists() )
194 msg.Printf(
_(
"Failed to create symbol library file '%s'." ), fn.GetFullPath() );
196 msg.Printf(
_(
"Error creating symbol library '%s'." ), fn.GetFullName() );
197 SetStatusText( msg );
203 msg.Printf(
_(
"Symbol %s saved to library '%s'." ),
206 SetStatusText( msg );
215 DisplayError(
this,
_(
"Could not open the library file." ) );
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
void DoNotShowCheckbox(wxString file, int line)
Checks the 'do not show again' setting for the dialog.
Define a library symbol object.
wxString GetName() const override
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
virtual void SetName(const wxString &aName)
SYMBOL_LIB_TABLE * SelectSymLibTable(bool aOptional=false)
Display a dialog asking the user to select a symbol library table.
wxString SelectLibraryFromList()
Display a list of loaded libraries and allows the user to select a library.
bool saveSymbolLibTables(bool aGlobal, bool aProject)
Save Symbol Library Tables to disk.
static SCH_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath)
Return a plugin type given a symbol library using the file extension of aLibPath.
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
virtual void EnumerateSymbolLib(wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr)
Populate a list of LIB_SYMBOL alias names contained within the library aLibraryPath.
virtual void SaveSymbol(const wxString &aLibraryPath, const LIB_SYMBOL *aSymbol, const STRING_UTF8_MAP *aProperties=nullptr)
Write aSymbol to an existing library located at aLibraryPath.
virtual LIB_SYMBOL * LoadSymbol(const wxString &aLibraryPath, const wxString &aPartName, const STRING_UTF8_MAP *aProperties=nullptr)
Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this...
virtual void CreateSymbolLib(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr)
Create a new empty symbol library at aLibraryPath.
wxString getTargetLib() const
LIB_SYMBOL_LIBRARY_MANAGER * m_libMgr
void LoadSymbol(const wxString &aLibrary, const wxString &aSymbol, int Unit)
void SyncLibraries(bool aShowProgress, bool aPreloadCancelled=false, const wxString &aForceRefresh=wxEmptyString)
Synchronize the library manager to the symbol library table, and then the symbol tree to the library ...
LIB_SYMBOL * getTargetSymbol() const
Return either the library selected in the symbol tree, if context menu is active or the library that ...
bool LibraryExists(const wxString &aLibrary, bool aCheckEnabled=false) const
Return true if library exists.
bool SymbolExists(const wxString &aAlias, const wxString &aLibrary) const
Return true if symbol with a specific alias exists in library (either original one or buffered).
bool AddLibrary(const wxString &aFilePath, SYMBOL_LIB_TABLE *aTable)
Add an existing library.
bool UpdateSymbol(LIB_SYMBOL *aSymbol, const wxString &aLibrary)
Update the symbol buffer with a new version of the symbol.
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
const std::string KiCadSymbolLibFileExtension
const std::string LegacySymbolLibFileExtension
wxString LegacySymbolLibFileWildcard()
wxString KiCadSymbolLibFileWildcard()
wxString AllSymbolLibFilesWildcard()
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
Definition for symbol library class.
Definition of file extensions used in Kicad.