Commit 0b69ed3a authored by Wayne Stambaugh's avatar Wayne Stambaugh

Fix Eeschema sheet issues. Should close out bug lp:593782

* Refresh canvas when user cancels edits so that the discarded sheet is
  cleared from the schematic.
* Add file name validation to the sheet properties dialog to prevent
  illegal file name characters from being entered into the text control.
* Rename FOOTPRINT_NAME_VALIDATOR to FILE_NAME_CHAR_VALIDATOR for clarity.
parent 27b9d013
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <validators.h> #include <validators.h>
FOOTPRINT_NAME_VALIDATOR::FOOTPRINT_NAME_VALIDATOR( wxString* aValue ) : FILE_NAME_CHAR_VALIDATOR::FILE_NAME_CHAR_VALIDATOR( wxString* aValue ) :
wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue ) wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue )
{ {
// The Windows (DOS) file system forbidden characters already include the forbidden // The Windows (DOS) file system forbidden characters already include the forbidden
......
#include <wx/string.h> #include <wx/string.h>
#include <dialog_sch_sheet_props.h> #include <dialog_sch_sheet_props.h>
#include <validators.h>
DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS( wxWindow* parent ) : DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS( wxWindow* parent ) :
DIALOG_SCH_SHEET_PROPS_BASE( parent ) DIALOG_SCH_SHEET_PROPS_BASE( parent )
{ {
m_textFileName->SetValidator( FILE_NAME_CHAR_VALIDATOR() );
m_textFileName->SetFocus(); m_textFileName->SetFocus();
m_sdbSizer1OK->SetDefault(); m_sdbSizer1OK->SetDefault();
} }
void DIALOG_SCH_SHEET_PROPS::SetFileName( const wxString& aFileName ) void DIALOG_SCH_SHEET_PROPS::SetFileName( const wxString& aFileName )
{ {
// Filenames are stored using unix notation // Filenames are stored using unix notation
...@@ -18,6 +22,7 @@ void DIALOG_SCH_SHEET_PROPS::SetFileName( const wxString& aFileName ) ...@@ -18,6 +22,7 @@ void DIALOG_SCH_SHEET_PROPS::SetFileName( const wxString& aFileName )
m_textFileName->SetValue( fname ); m_textFileName->SetValue( fname );
} }
const wxString DIALOG_SCH_SHEET_PROPS::GetFileName() const wxString DIALOG_SCH_SHEET_PROPS::GetFileName()
{ {
// Filenames are stored using unix notation // Filenames are stored using unix notation
......
...@@ -75,6 +75,10 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC ) ...@@ -75,6 +75,10 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
if( !fileName.IsOk() ) if( !fileName.IsOk() )
{ {
DisplayError( this, _( "File name is not valid!" ) ); DisplayError( this, _( "File name is not valid!" ) );
if( m_canvas )
m_canvas->Refresh();
return false; return false;
} }
...@@ -85,6 +89,10 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC ) ...@@ -85,6 +89,10 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
{ {
DisplayError( this, wxString::Format( _( "A sheet named \"%s\" already exists." ), DisplayError( this, wxString::Format( _( "A sheet named \"%s\" already exists." ),
GetChars( dlg.GetSheetName() ) ) ); GetChars( dlg.GetSheetName() ) ) );
if( m_canvas )
m_canvas->Refresh();
return false; return false;
} }
...@@ -121,7 +129,12 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC ) ...@@ -121,7 +129,12 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
msg += _("\n\nDo you want to create a sheet with the contents of this file?" ); msg += _("\n\nDo you want to create a sheet with the contents of this file?" );
if( !IsOK( this, msg ) ) if( !IsOK( this, msg ) )
{
if( m_canvas )
m_canvas->Refresh();
return false; return false;
}
} }
else // New file. else // New file.
{ {
...@@ -150,12 +163,12 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC ) ...@@ -150,12 +163,12 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
if( useScreen != NULL ) if( useScreen != NULL )
{ {
tmp.Printf( _( "A file named <%s> already exists in the current schematic hierarchy." ), tmp.Printf( _( "A file named <%s> already exists in the current schematic hierarchy." ),
GetChars( newFullFilename ) ); GetChars( newFullFilename ) );
} }
else else
{ {
tmp.Printf( _( "A file named <%s> already exists." ), tmp.Printf( _( "A file named <%s> already exists." ),
GetChars( newFullFilename ) ); GetChars( newFullFilename ) );
} }
msg += tmp; msg += tmp;
......
...@@ -30,16 +30,16 @@ ...@@ -30,16 +30,16 @@
#include <wx/valtext.h> #include <wx/valtext.h>
/** /**
* Class FOOTPRINT_NAME_VALIDATOR * Class FILE_NAME_CHAR_VALIDATOR
* *
* This class provides a custom wxValidator object for limiting the allowable characters when * This class provides a custom wxValidator object for limiting the allowable characters when
* defining footprint names. Since the introduction of the PRETTY footprint library format, * defining footprint names. Since the introduction of the PRETTY footprint library format,
* footprint names cannot have any characters that would prevent file creation on any platform. * footprint names cannot have any characters that would prevent file creation on any platform.
*/ */
class FOOTPRINT_NAME_VALIDATOR : public wxTextValidator class FILE_NAME_CHAR_VALIDATOR : public wxTextValidator
{ {
public: public:
FOOTPRINT_NAME_VALIDATOR( wxString* aValue = NULL ) : FILE_NAME_CHAR_VALIDATOR( wxString* aValue = NULL ) :
wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue ) wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue )
{ {
// The Windows (DOS) file system forbidden characters already include the forbidden // The Windows (DOS) file system forbidden characters already include the forbidden
......
...@@ -64,7 +64,7 @@ DIALOG_MODULE_MODULE_EDITOR::DIALOG_MODULE_MODULE_EDITOR( FOOTPRINT_EDIT_FRAME* ...@@ -64,7 +64,7 @@ DIALOG_MODULE_MODULE_EDITOR::DIALOG_MODULE_MODULE_EDITOR( FOOTPRINT_EDIT_FRAME*
icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) ); icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) );
SetIcon( icon ); SetIcon( icon );
m_FootprintNameCtrl->SetValidator( FOOTPRINT_NAME_VALIDATOR() ); m_FootprintNameCtrl->SetValidator( FILE_NAME_CHAR_VALIDATOR() );
initModeditProperties(); initModeditProperties();
m_sdbSizerStdButtonsOK->SetDefault(); m_sdbSizerStdButtonsOK->SetDefault();
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
......
...@@ -718,7 +718,7 @@ MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName ) ...@@ -718,7 +718,7 @@ MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName )
if( moduleName.IsEmpty() ) if( moduleName.IsEmpty() )
{ {
wxTextEntryDialog dlg( this, FMT_MOD_REF, FMT_MOD_CREATE, moduleName ); wxTextEntryDialog dlg( this, FMT_MOD_REF, FMT_MOD_CREATE, moduleName );
dlg.SetTextValidator( FOOTPRINT_NAME_VALIDATOR( &moduleName ) ); dlg.SetTextValidator( FILE_NAME_CHAR_VALIDATOR( &moduleName ) );
if( dlg.ShowModal() != wxID_OK ) if( dlg.ShowModal() != wxID_OK )
return NULL; //Aborted by user return NULL; //Aborted by user
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment