39#include <wx/textdlg.h>
45 std::vector<LIB_ID>& aHistoryList ) :
76 if( IsShownOnScreen() )
112 wxCHECK_MSG( prjLibs,
nullptr, wxS(
"Invalid design block library table." ) );
124 wxString msg = wxString::Format(
_(
"Error loading design block %s from library '%s'." ),
152 bool isGlobal =
false;
158 return wxEmptyString;
167 wxString libPath = fn.GetFullPath();
173 bool writable =
false;
178 writable = pi->IsLibraryWritable( libPath );
179 exists = fn.Exists();
190 wxString msg = wxString::Format(
_(
"Library %s is read only." ), libPath );
192 return wxEmptyString;
196 wxString msg = wxString::Format(
_(
"Library %s already exists." ), libPath );
197 KIDIALOG dlg(
m_frame, msg,
_(
"Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
198 dlg.SetOKLabel(
_(
"Overwrite" ) );
202 return wxEmptyString;
204 pi->DeleteLibrary( libPath );
208 pi->CreateLibrary( libPath );
213 return wxEmptyString;
226 wxFileName fn( aFilename );
227 wxString libPath = fn.GetFullPath();
228 wxString libName = fn.GetName();
230 if( libName.IsEmpty() )
234 wxString description = wxGetTextFromUser(
_(
"Enter a description for the library:" ),
_(
"Library Description" ),
247 libName = fn.GetFullName();
255 wxEmptyString, description );
269 LIB_ID libID( libName, wxEmptyString );
279 if( aLibName.IsEmpty() )
287 wxString msg = wxString::Format(
_(
"Library '%s' is read only." ), aLibName );
293 wxString msg = wxString::Format(
_(
"Delete design block library '%s' from disk? This will "
294 "delete all design blocks within the library." ),
295 aLibName.GetData() );
310 msg.Printf(
_(
"Design block library '%s' deleted" ), aLibName.GetData() );
329 wxString msg = wxString::Format(
_(
"Library '%s' is read only." ), libname );
335 wxString msg = wxString::Format(
_(
"Delete design block '%s' in library '%s' from disk?" ),
336 dbname.GetData(), libname.GetData() );
351 msg.Printf(
_(
"Design block '%s' deleted from library '%s'" ), dbname.GetData(), libname.GetData() );
371 wxString msg = wxString::Format(
_(
"Library '%s' is read only." ), libname );
376 std::unique_ptr<DESIGN_BLOCK> designBlock(
GetDesignBlock( aLibId,
true,
true ) );
381 wxString originalName = designBlock->GetLibId().GetLibItemName();
387 wxString newName = designBlock->GetLibId().GetLibItemName();
391 if( originalName != newName )
420 wxString msg = wxString::Format(
_(
"Design block '%s' already exists in library '%s'." ),
421 newName.GetData(), libname.GetData() );
423 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)
Hold a record identifying a library accessed by the appropriate design block library #PLUGIN object i...
void DesignBlockLibDelete(const wxString &aNickname)
static wxString GetGlobalTableFileName()
bool IsDesignBlockLibWritable(const wxString &aNickname)
Return true if the library given by aNickname is writable.
void DesignBlockDelete(const wxString &aNickname, const wxString &aDesignBlockName)
Delete the aDesignBlockName from the library given by aNickname.
SAVE_T DesignBlockSave(const wxString &aNickname, const DESIGN_BLOCK *aDesignBlock, bool aOverwrite=true)
Write aDesignBlock to an existing library given by aNickname.
DESIGN_BLOCK * DesignBlockLoadWithOptionalNickname(const LIB_ID &aDesignBlockId, bool aKeepUUID=false)
Load a design block having aDesignBlockId with possibly an empty nickname.
bool DesignBlockExists(const wxString &aNickname, const wxString &aDesignBlockName)
Indicates whether or not the given design block already exists in the given library.
static DESIGN_BLOCK_LIB_TABLE & GetGlobalLibTable()
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)
bool AddDesignBlockLibrary(const wxString &aDialogTitle, const wxString &aFilename, DESIGN_BLOCK_LIB_TABLE *aTable)
Add an existing library to a library table (presumed to be either the global or project design block ...
DESIGN_BLOCK * GetSelectedDesignBlock(bool aUseCacheLib, bool aShowErrorMsg)
void OnClosed(wxAuiManagerEvent &aEvent)
virtual APP_SETTINGS_BASE * config() const
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
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...
The base class for create windows for drawing purpose.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
bool LibraryFileBrowser(const wxString &aTitle, bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory, FILEDLG_HOOK_NEW_LIBRARY *aFileDlgHook=nullptr)
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.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
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.
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
LIB_ID GetSelectedLibId(int *aUnit=nullptr) const
To be called after this dialog returns from ShowModal().
void ShowChangedLanguage()
void RefreshLibs(bool aProgress=false)
void SelectLibId(const LIB_ID &aLibId)
virtual const wxString DesignBlockLibTblName() const
Return the path and file name of this projects design block library table.
virtual DESIGN_BLOCK_LIB_TABLE * DesignBlockLibs()
Return the table of design block libraries.
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.
This file is part of the common library.
PGM_BASE & Pgm()
The global program "get" accessor.
Definition of file extensions used in Kicad.