35#include <wx/filename.h>
36#include <wx/filedlg.h>
54 wxString fileFiltersStr;
55 wxString allWildcardsStr;
57 for(
const SCH_IO_MGR::SCH_FILE_T&
fileType : SCH_IO_MGR::SCH_FILE_T_vector )
69 if( !fileFiltersStr.IsEmpty() )
70 fileFiltersStr += wxChar(
'|' );
78 fileFiltersStr =
_(
"All supported formats" ) + wxT(
"|" ) + allWildcardsStr + wxT(
"|" )
81 wxFileDialog dlg(
this,
_(
"Import Symbol" ),
m_mruPath, wxEmptyString, fileFiltersStr,
82 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
84 if( dlg.ShowModal() == wxID_CANCEL )
87 wxFileName fn( dlg.GetPath() );
91 wxArrayString symbols;
94 if( piType == SCH_IO_MGR::SCH_FILE_UNKNOWN )
96 msg.Printf(
_(
"Unable to find a reader for '%s'." ), fn.GetFullPath() );
106 pi->EnumerateSymbolLib( symbols, fn.GetFullPath() );
110 msg.Printf(
_(
"Cannot import symbol library '%s'." ), fn.GetFullPath() );
116 msg.Printf(
_(
"Cannot import symbol library '%s'." ), fn.GetFullPath() );
121 if( symbols.empty() )
123 msg.Printf(
_(
"Symbol library file '%s' is empty." ), fn.GetFullPath() );
128 wxString symbolName = symbols[0];
129 LIB_SYMBOL* entry = pi->LoadSymbol( fn.GetFullPath(), symbolName );
135 msg.Printf(
_(
"Symbol %s already exists in library '%s'." ), symbolName, libName );
137 KIDIALOG errorDlg(
this, msg,
_(
"Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
138 errorDlg.SetOKLabel(
_(
"Overwrite" ) );
141 if( errorDlg.
ShowModal() == wxID_CANCEL )
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
virtual void SetName(const wxString &aName)
wxString SelectLibraryFromList()
Display a list of loaded libraries and allows the user to select a library.
static SCH_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath, int aCtl=0)
Return a plugin type given a symbol library using the file extension of aLibPath.
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 ...
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 UpdateSymbol(LIB_SYMBOL *aSymbol, const wxString &aLibrary)
Update the symbol buffer with a new version of the symbol.
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.
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
This file is part of the common library.
MODEL3D_FORMAT_TYPE fileType(const char *aFileName)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
Container that describes file type info.
std::vector< std::string > m_FileExtensions
Filter used for file pickers if m_IsFile is true.
wxString FileFilter() const
Implement a simple wrapper around runtime_error to isolate the errors thrown by the Eagle XML parser.
Definition for symbol library class.
wxString formatWildcardExt(const wxString &aWildcard)
Format wildcard extension to support case sensitive file dialogs.
Definition of file extensions used in Kicad.