34#include <wx/filename.h> 
   35#include <wx/filedlg.h> 
   44    if( !
m_libMgr->LibraryExists( libName ) )
 
   45        libName = 
SelectLibrary( 
_( 
"Import Symbol" ), 
_( 
"Import symbol to library:" ) );
 
   47    if( !
m_libMgr->LibraryExists( libName ) )
 
   50    wxString fileFiltersStr;
 
   51    wxString allWildcardsStr;
 
   53    for( 
const SCH_IO_MGR::SCH_FILE_T& 
fileType : SCH_IO_MGR::SCH_FILE_T_vector )
 
   65        if( !fileFiltersStr.IsEmpty() )
 
   66            fileFiltersStr += wxChar( 
'|' );
 
   74    fileFiltersStr = 
_( 
"All supported formats" ) + wxT( 
"|" ) + allWildcardsStr + wxT( 
"|" )
 
   77    wxFileDialog dlg( 
this, 
_( 
"Import Symbol" ), 
m_mruPath, wxEmptyString, fileFiltersStr,
 
   78                      wxFD_OPEN | wxFD_FILE_MUST_EXIST );
 
   80    if( dlg.ShowModal() == wxID_CANCEL )
 
   83    wxFileName fn( dlg.GetPath() );
 
   87    wxArrayString symbols;
 
   90    if( piType == SCH_IO_MGR::SCH_FILE_UNKNOWN )
 
   92        msg.Printf( 
_( 
"Unable to find a reader for '%s'." ), fn.GetFullPath() );
 
  102        pi->EnumerateSymbolLib( symbols, fn.GetFullPath() );
 
  106        msg.Printf( 
_( 
"Cannot import symbol library '%s'." ), fn.GetFullPath() );
 
  112        msg.Printf( 
_( 
"Cannot import symbol library '%s'." ), fn.GetFullPath() );
 
  117    if( symbols.empty() )
 
  119        msg.Printf( 
_( 
"Symbol library file '%s' is empty." ), fn.GetFullPath() );
 
  124    wxString symbolName = symbols[0];
 
  125    LIB_SYMBOL* entry = pi->LoadSymbol( fn.GetFullPath(), symbolName );
 
  131        msg.Printf( 
_( 
"Symbol %s already exists in library '%s'." ),
 
  135        KIDIALOG errorDlg( 
this, msg, 
_( 
"Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
 
  136        errorDlg.SetOKLabel( 
_( 
"Overwrite" ) );
 
  139        if( errorDlg.
ShowModal() == wxID_CANCEL )
 
  143    m_libMgr->UpdateSymbol( entry, libName );
 
 
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)
Shows the 'do not show again' checkbox.
 
Define a library symbol object.
 
wxString GetName() const override
 
virtual void SetName(const wxString &aName)
 
wxString SelectLibrary(const wxString &aDialogTitle, const wxString &aListLabel, const std::vector< std::pair< wxString, bool * > > &aExtraCheckboxes={})
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 ...
 
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
 
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box 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.
 
MODEL3D_FORMAT_TYPE fileType(const char *aFileName)
 
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:...
 
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.
 
wxString formatWildcardExt(const wxString &aWildcard)
Format wildcard extension to support case sensitive file dialogs.
 
Definition of file extensions used in Kicad.