Symbol library table remapping improvements.
Don't back up schematic files unless the user requests a remap. Back up all files that could be changed by a remap including the schematic file(s), cache library, project file, and rescue library files. Use an HTML control instead of a static text control for improved layout of the user remap prompt. Improve the user prompt in the remap dialog to make it clear that changes will be made to project files.
This commit is contained in:
parent
1d48fd28e3
commit
84e360dd0d
|
@ -28,6 +28,7 @@
|
|||
#include <project.h>
|
||||
#include <confirm.h>
|
||||
#include <reporter.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <wx_html_report_panel.h>
|
||||
|
||||
#include <class_library.h>
|
||||
|
@ -45,6 +46,17 @@
|
|||
DIALOG_SYMBOL_REMAP::DIALOG_SYMBOL_REMAP( SCH_EDIT_FRAME* aParent ) :
|
||||
DIALOG_SYMBOL_REMAP_BASE( aParent )
|
||||
{
|
||||
wxString text;
|
||||
|
||||
text = _( "This schematic currently uses the symbol library list look up method for "
|
||||
"loading schematic symbols. KiCad will attempt to map the existing symbols "
|
||||
"to use the new symbol library table. Remapping will change project files "
|
||||
"and schematics will not be compatible with previous versions of KiCad. "
|
||||
"All files that are changed will be backed up with the .v4 extension should "
|
||||
"you need to revert any changes. If you choose to skip this step, you will "
|
||||
"be responsible for manually remapping the symbols." );
|
||||
|
||||
m_htmlCtrl->AppendToPage( text );
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,6 +64,8 @@ void DIALOG_SYMBOL_REMAP::OnRemapSymbols( wxCommandEvent& aEvent )
|
|||
{
|
||||
wxBusyCursor busy;
|
||||
|
||||
backupProject();
|
||||
|
||||
// The schematic is fully loaded, any legacy library symbols have been rescued. Now
|
||||
// check to see if the schematic has not been converted to the symbol library table
|
||||
// method for looking up symbols.
|
||||
|
@ -263,3 +277,99 @@ bool DIALOG_SYMBOL_REMAP::remapSymbolToLibTable( SCH_COMPONENT* aSymbol )
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_SYMBOL_REMAP::backupProject()
|
||||
{
|
||||
static wxString ext = "v4";
|
||||
|
||||
wxString errorMsg;
|
||||
wxFileName destFileName;
|
||||
SCH_SCREENS schematic;
|
||||
|
||||
// Back up the schematic files.
|
||||
for( SCH_SCREEN* screen = schematic.GetFirst(); screen; screen = schematic.GetNext() )
|
||||
{
|
||||
destFileName = screen->GetFileName();
|
||||
destFileName.SetName( destFileName.GetFullName() );
|
||||
destFileName.SetExt( ext );
|
||||
|
||||
wxLogTrace( "KICAD_TRACE_PATHS", "Backing up file '%s' to file '%s'.",
|
||||
screen->GetFileName(), destFileName.GetFullPath() );
|
||||
|
||||
if( wxFileName::Exists( screen->GetFileName() )
|
||||
&& !wxCopyFile( screen->GetFileName(), destFileName.GetFullPath() ) )
|
||||
{
|
||||
errorMsg += wxPrintf( _( "Failed to back up file '%s'.\n" ), screen->GetFileName() );
|
||||
}
|
||||
}
|
||||
|
||||
// Back up the project file.
|
||||
destFileName = Prj().GetProjectFullName();
|
||||
destFileName.SetName( destFileName.GetFullName() );
|
||||
destFileName.SetExt( ext );
|
||||
|
||||
wxLogTrace( "KICAD_TRACE_PATHS", "Backing up file '%s' to file '%s'.",
|
||||
Prj().GetProjectFullName(), destFileName.GetFullPath() );
|
||||
|
||||
if( wxFileName::Exists( Prj().GetProjectFullName() )
|
||||
&& !wxCopyFile( Prj().GetProjectFullName(), destFileName.GetFullPath() ) )
|
||||
{
|
||||
errorMsg += wxPrintf( _( "Failed to back up file '%s'.\n" ), Prj().GetProjectFullName() );
|
||||
}
|
||||
|
||||
wxFileName srcFileName;
|
||||
|
||||
// Back up the cache library.
|
||||
srcFileName.SetPath( Prj().GetProjectPath() );
|
||||
srcFileName.SetName( Prj().GetProjectName() + "-cache" );
|
||||
srcFileName.SetExt( SchematicLibraryFileExtension );
|
||||
|
||||
destFileName = srcFileName;
|
||||
destFileName.SetName( destFileName.GetFullName() );
|
||||
destFileName.SetExt( ext );
|
||||
|
||||
wxLogTrace( "KICAD_TRACE_PATHS", "Backing up file '%s' to file '%s'.",
|
||||
srcFileName.GetFullPath(), destFileName.GetFullPath() );
|
||||
|
||||
if( srcFileName.Exists()
|
||||
&& !wxCopyFile( srcFileName.GetFullPath(), destFileName.GetFullPath() ) )
|
||||
{
|
||||
errorMsg += wxPrintf( _( "Failed to back up file '%s'.\n" ), srcFileName.GetFullPath() );
|
||||
}
|
||||
|
||||
// Back up the rescue library if it exists.
|
||||
srcFileName.SetName( Prj().GetProjectName() + "-rescue" );
|
||||
destFileName.SetName( srcFileName.GetFullName() );
|
||||
|
||||
wxLogTrace( "KICAD_TRACE_PATHS", "Backing up file '%s' to file '%s'.",
|
||||
srcFileName.GetFullPath(), destFileName.GetFullPath() );
|
||||
|
||||
if( srcFileName.Exists()
|
||||
&& !wxCopyFile( srcFileName.GetFullPath(), destFileName.GetFullPath() ) )
|
||||
{
|
||||
errorMsg += wxPrintf( _( "Failed to back up file '%s'.\n" ), srcFileName.GetFullPath() );
|
||||
}
|
||||
|
||||
// Back up the rescue library document file if it exists.
|
||||
srcFileName.SetName( Prj().GetProjectName() + "-rescue" );
|
||||
srcFileName.SetExt( "dcm" );
|
||||
destFileName.SetName( srcFileName.GetFullName() );
|
||||
|
||||
wxLogTrace( "KICAD_TRACE_PATHS", "Backing up file '%s' to file '%s'.",
|
||||
srcFileName.GetFullPath(), destFileName.GetFullPath() );
|
||||
|
||||
if( srcFileName.Exists()
|
||||
&& !wxCopyFile( srcFileName.GetFullPath(), destFileName.GetFullPath() ) )
|
||||
{
|
||||
errorMsg += wxPrintf( _( "Failed to back up file '%s'.\n" ), srcFileName.GetFullPath() );
|
||||
}
|
||||
|
||||
if( !errorMsg.IsEmpty() )
|
||||
{
|
||||
errorMsg.Trim();
|
||||
DisplayErrorMessage( this, _( "Some of the project files could not be backed up." ),
|
||||
errorMsg );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,18 @@ private:
|
|||
void remapSymbolsToLibTable( REPORTER& aReporter );
|
||||
|
||||
bool remapSymbolToLibTable( SCH_COMPONENT* aSymbol );
|
||||
|
||||
/**
|
||||
* Backup all of the files that could be modified by the remapping with a .v4 file extension
|
||||
* in case something goes wrong.
|
||||
*
|
||||
* Backup the following:
|
||||
* - All schematic (*.sch -> *.sch.v4 ) files.
|
||||
* - The project (*.pro) -> *.pro.v4) file.
|
||||
* - The cache library (*-cache.lib -> *.-cache.lib.v4) file.
|
||||
* - The rescue library (*-rescue.lib -> *.rescue.lib.v4) file.
|
||||
*/
|
||||
void backupProject();
|
||||
};
|
||||
|
||||
#endif // _DIALOG_SYMBOL_REMAP_H_
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Aug 4 2017)
|
||||
// C++ code generated with wxFormBuilder (version Nov 22 2017)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx_html_report_panel.h"
|
||||
|
@ -21,9 +21,8 @@ DIALOG_SYMBOL_REMAP_BASE::DIALOG_SYMBOL_REMAP_BASE( wxWindow* parent, wxWindowID
|
|||
wxBoxSizer* bSizer2;
|
||||
bSizer2 = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_staticText1 = new wxStaticText( this, wxID_ANY, _("This schematic currently uses the symbol library look\nup method for loading schematic symbols. KiCad will\nattempt to map the existing symbols to use the new\nsymbol library table. If you choose to skip\nthis step, you will be responsible for manually assigning\nsymbols."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText1->Wrap( -1 );
|
||||
bSizer2->Add( m_staticText1, 0, wxALL|wxEXPAND, 5 );
|
||||
m_htmlCtrl = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
|
||||
bSizer2->Add( m_htmlCtrl, 4, wxALL|wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bSizer3;
|
||||
bSizer3 = new wxBoxSizer( wxVERTICAL );
|
||||
|
@ -38,7 +37,7 @@ DIALOG_SYMBOL_REMAP_BASE::DIALOG_SYMBOL_REMAP_BASE( wxWindow* parent, wxWindowID
|
|||
bSizer2->Add( bSizer3, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bSizer1->Add( bSizer2, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 );
|
||||
bSizer1->Add( bSizer2, 3, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 );
|
||||
|
||||
wxBoxSizer* bSizer4;
|
||||
bSizer4 = new wxBoxSizer( wxVERTICAL );
|
||||
|
@ -49,7 +48,7 @@ DIALOG_SYMBOL_REMAP_BASE::DIALOG_SYMBOL_REMAP_BASE( wxWindow* parent, wxWindowID
|
|||
bSizer4->Add( m_messagePanel, 1, wxEXPAND | wxALL, 5 );
|
||||
|
||||
|
||||
bSizer1->Add( bSizer4, 1, wxEXPAND, 5 );
|
||||
bSizer1->Add( bSizer4, 5, wxEXPAND, 5 );
|
||||
|
||||
|
||||
this->SetSizer( bSizer1 );
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxLEFT|wxRIGHT|wxTOP</property>
|
||||
<property name="proportion">0</property>
|
||||
<property name="proportion">3</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bSizer2</property>
|
||||
|
@ -105,8 +105,8 @@
|
|||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStaticText" expanded="1">
|
||||
<property name="proportion">4</property>
|
||||
<object class="wxHtmlWindow" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
|
@ -134,7 +134,6 @@
|
|||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">This schematic currently uses the symbol library look
up method for loading schematic symbols. KiCad will
attempt to map the existing symbols to use the new
symbol library table. If you choose to skip
this step, you will be responsible for manually assigning
symbols.</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
|
@ -142,7 +141,7 @@
|
|||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_staticText1</property>
|
||||
<property name="name">m_htmlCtrl</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
|
@ -152,17 +151,19 @@
|
|||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass"></property>
|
||||
<property name="style">wxHW_SCROLLBAR_AUTO</property>
|
||||
<property name="subclass">; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<property name="wrap">-1</property>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnHtmlCellClicked"></event>
|
||||
<event name="OnHtmlCellHover"></event>
|
||||
<event name="OnHtmlLinkClicked"></event>
|
||||
<event name="OnKeyDown"></event>
|
||||
<event name="OnKeyUp"></event>
|
||||
<event name="OnKillFocus"></event>
|
||||
|
@ -377,7 +378,7 @@
|
|||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
<property name="proportion">5</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bSizer4</property>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Aug 4 2017)
|
||||
// C++ code generated with wxFormBuilder (version Nov 22 2017)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __DIALOG_SYMBOL_REMAP_BASE_H__
|
||||
|
@ -11,16 +11,15 @@
|
|||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/intl.h>
|
||||
class DIALOG_SHIM;
|
||||
class WX_HTML_REPORT_PANEL;
|
||||
|
||||
#include "dialog_shim.h"
|
||||
#include <wx/string.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/html/htmlwin.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/panel.h>
|
||||
|
@ -37,7 +36,7 @@ class DIALOG_SYMBOL_REMAP_BASE : public DIALOG_SHIM
|
|||
private:
|
||||
|
||||
protected:
|
||||
wxStaticText* m_staticText1;
|
||||
wxHtmlWindow* m_htmlCtrl;
|
||||
wxButton* m_buttonRemp;
|
||||
wxButton* m_buttonClose;
|
||||
WX_HTML_REPORT_PANEL* m_messagePanel;
|
||||
|
|
|
@ -339,10 +339,6 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
|||
// best remapping results.
|
||||
RescueLegacyProject( false );
|
||||
|
||||
// Make backups of current schematics just in case something goes wrong.
|
||||
for( SCH_SCREEN* screen = schematic.GetFirst(); screen; screen = schematic.GetNext() )
|
||||
SaveEEFile( screen, false, CREATE_BACKUP_FILE );
|
||||
|
||||
DIALOG_SYMBOL_REMAP dlgRemap( this );
|
||||
|
||||
dlgRemap.ShowQuasiModal();
|
||||
|
|
Loading…
Reference in New Issue