40#include <wx/textdlg.h> 
   46                                      std::vector<LIB_ID>& aHistoryList ) :
 
 
   77        if( IsShownOnScreen() ) 
 
 
  113    wxCHECK_MSG( prjLibs, 
nullptr, wxS( 
"Invalid design block library table." ) );
 
  125            wxString msg = wxString::Format( 
_( 
"Error loading design block %s from library '%s'." ),
 
 
  153    static bool              isGlobal = 
true;
 
  159        return wxEmptyString;
 
  164    wxString libPath = fn.GetFullPath();
 
  175        bool writable = 
false;
 
  180            writable = pi->IsLibraryWritable( libPath );
 
  181            exists   = fn.Exists();
 
  192                wxString msg = wxString::Format( 
_( 
"Library %s is read only." ), libPath );
 
  193                m_frame->ShowInfoBarError( msg );
 
  194                return wxEmptyString;
 
  198                wxString msg = wxString::Format( 
_( 
"Library %s already exists." ), libPath );
 
  199                KIDIALOG dlg( 
m_frame, msg, 
_( 
"Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
 
  200                dlg.SetOKLabel( 
_( 
"Overwrite" ) );
 
  204                    return wxEmptyString;
 
  206                pi->DeleteLibrary( libPath );
 
  210        pi->CreateLibrary( libPath );
 
  215        return wxEmptyString;
 
 
  230    wxFileName fn( aFilename );
 
  231    wxString   libPath = fn.GetFullPath();
 
  232    wxString   libName = fn.GetName();
 
  234    if( libName.IsEmpty() )
 
  238    wxString description = wxGetTextFromUser( 
_( 
"Enter a description for the library:" ), 
_( 
"Library Description" ),
 
  251        libName = fn.GetFullName();
 
  256    std::optional<LIBRARY_TABLE*> optTable =
 
  258    wxCHECK( optTable, 
false );
 
  264    newRow.
SetURI( normalizedPath );
 
  268    table->Save().map_error(
 
  271            wxString msg = wxString::Format( 
_( 
"Error saving library table:\n\n%s" ), aError.
message );
 
  280    LIB_ID libID( libName, wxEmptyString );
 
 
  290    if( aLibName.IsEmpty() )
 
  296    if( !
m_frame->Prj().DesignBlockLibs()->IsDesignBlockLibWritable( aLibName ) )
 
  298        wxString msg = wxString::Format( 
_( 
"Library '%s' is read only." ), aLibName );
 
  299        m_frame->ShowInfoBarError( msg );
 
  304    wxString msg = wxString::Format( 
_( 
"Delete design block library '%s' from disk? This will " 
  305                                        "delete all design blocks within the library." ),
 
  306                                     aLibName.GetData() );
 
  313        m_frame->Prj().DesignBlockLibs()->DeleteLibrary( aLibName );
 
  321    msg.Printf( 
_( 
"Design block library '%s' deleted" ), aLibName.GetData() );
 
 
  338    if( !
m_frame->Prj().DesignBlockLibs()->IsDesignBlockLibWritable( libname ) )
 
  340        wxString msg = wxString::Format( 
_( 
"Library '%s' is read only." ), libname );
 
  341        m_frame->ShowInfoBarError( msg );
 
  346    wxString msg = wxString::Format( 
_( 
"Delete design block '%s' in library '%s' from disk?" ),
 
  347                                     dbname.GetData(), libname.GetData() );
 
  354        m_frame->Prj().DesignBlockLibs()->DeleteDesignBlock( libname, dbname );
 
  362    msg.Printf( 
_( 
"Design block '%s' deleted from library '%s'" ), dbname.GetData(), libname.GetData() );
 
 
  380    if( !
m_frame->Prj().DesignBlockLibs()->IsDesignBlockLibWritable( libname ) )
 
  382        wxString msg = wxString::Format( 
_( 
"Library '%s' is read only." ), libname );
 
  383        m_frame->ShowInfoBarError( msg );
 
  387    std::unique_ptr<DESIGN_BLOCK> designBlock( 
GetDesignBlock( aLibId, 
true, 
true ) );
 
  392    wxString                       originalName = designBlock->GetLibId().GetLibItemName();
 
  398    wxString newName = designBlock->GetLibId().GetLibItemName();
 
  402        if( originalName != newName )
 
  404            if( 
m_frame->Prj().DesignBlockLibs()->DesignBlockExists( libname, newName ) )
 
  410            m_frame->Prj().DesignBlockLibs()->SaveDesignBlock( libname, designBlock.get() );
 
  411            m_frame->Prj().DesignBlockLibs()->DeleteDesignBlock( libname, originalName );
 
  415            m_frame->Prj().DesignBlockLibs()->SaveDesignBlock( libname, designBlock.get() );
 
 
  433    wxString msg = wxString::Format( 
_( 
"Design block '%s' already exists in library '%s'." ),
 
  434                                     newName.GetData(), libname.GetData() );
 
  436    if( 
OKOrCancelDialog( aFrame, 
_( 
"Confirmation" ), msg, 
_( 
"Overwrite existing design block?" ), 
_( 
"Overwrite" ) )
 
 
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
 
@ KICAD_SEXP
S-expression KiCad file format.
 
static const wxString ShowType(DESIGN_BLOCK_FILE_T aFileType)
 
static DESIGN_BLOCK_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath, int aCtl=0)
 
static DESIGN_BLOCK_IO * FindPlugin(DESIGN_BLOCK_FILE_T aFileType)
 
DESIGN_BLOCK * DesignBlockLoadWithOptionalNickname(const LIB_ID &aDesignBlockId, bool aKeepUUID=false)
Load a design block having aDesignBlockId with possibly an empty nickname.
 
bool DeleteDesignBlockLibrary(const wxString &aLibName, bool aConfirm)
 
bool checkOverwrite(wxWindow *aFrame, wxString &libname, wxString &newName)
 
bool DeleteDesignBlockFromLibrary(const LIB_ID &aLibId, bool aConfirm)
 
~DESIGN_BLOCK_PANE() override
 
void SelectLibId(const LIB_ID &aLibId)
 
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
 
DESIGN_BLOCK_PANE(EDA_DRAW_FRAME *aParent, const LIB_ID *aPreselect, std::vector< LIB_ID > &aHistoryList)
 
DESIGN_BLOCK * GetDesignBlock(const LIB_ID &aLibId, bool aUseCacheLib, bool aShowErrorMsg)
Load design block from design block library table.
 
wxString createNewDesignBlockLibrary(const wxString &aDialogTitle)
 
PANEL_DESIGN_BLOCK_CHOOSER * m_chooserPanel
 
bool EditDesignBlockProperties(const LIB_ID &aLibId)
 
virtual void setLabelsAndTooltips()=0
 
wxString CreateNewDesignBlockLibrary(const wxString &aDialogTitle)
Creates a new design block library.
 
virtual void OnLanguageChanged(wxCommandEvent &aEvent)
 
DESIGN_BLOCK * GetSelectedDesignBlock(bool aUseCacheLib, bool aShowErrorMsg)
 
void OnClosed(wxAuiManagerEvent &aEvent)
 
bool AddDesignBlockLibrary(const wxString &aDialogTitle, const wxString &aFilename, LIBRARY_TABLE_SCOPE aScope)
Add an existing library to a library table (presumed to be either the global or project design block ...
 
The base class for create windows for drawing purpose.
 
bool GetUseGlobalTable() const
 
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.
 
std::optional< LIBRARY_TABLE * > Table(LIBRARY_TABLE_TYPE aType, LIBRARY_TABLE_SCOPE aScope)
Retrieves a given table; creating a new empty project table if a valid project is loaded and the give...
 
void LoadGlobalTables(std::initializer_list< LIBRARY_TABLE_TYPE > aTablesToLoad={})
(Re)loads the global library tables in the given list, or all tables if no list is given
 
void ProjectChanged()
Notify all adapters that the project has changed.
 
void SetNickname(const wxString &aNickname)
 
void SetType(const wxString &aType)
 
void SetDescription(const wxString &aDescription)
 
void SetURI(const wxString &aUri)
 
A logical library item identifier and consists of various portions much like a URI.
 
bool IsValid() const
Check if this LID_ID is valid.
 
const UTF8 & GetLibItemName() const
 
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
 
virtual LIBRARY_MANAGER & GetLibraryManager() const
 
WX_PANEL(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
 
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, const wxString &aDetailedMessage, const wxString &aOKLabel, const wxString &aCancelLabel, bool *aApplyToAll)
Display a warning dialog with aMessage and returns the user response.
 
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
 
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.
 
wxString NormalizePath(const wxFileName &aFilePath, const ENV_VAR_MAP *aEnvVars, const wxString &aProjectPath)
Normalize a file path to an environmental variable, if possible.
 
Helper functions to substitute paths with environmental variables.
 
static const std::string KiCadDesignBlockLibPathExtension
 
static wxString KiCadDesignBlockLibPathWildcard()
 
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
 
PGM_BASE & Pgm()
The global program "get" accessor.
 
Definition of file extensions used in Kicad.