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.
This commit is contained in:
Wayne Stambaugh 2014-08-24 18:49:31 -04:00
parent 27b9d013fd
commit 0b69ed3a5c
6 changed files with 26 additions and 8 deletions

View File

@ -31,7 +31,7 @@
#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 )
{
// The Windows (DOS) file system forbidden characters already include the forbidden

View File

@ -1,13 +1,17 @@
#include <wx/string.h>
#include <dialog_sch_sheet_props.h>
#include <validators.h>
DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS( wxWindow* parent ) :
DIALOG_SCH_SHEET_PROPS_BASE( parent )
{
m_textFileName->SetValidator( FILE_NAME_CHAR_VALIDATOR() );
m_textFileName->SetFocus();
m_sdbSizer1OK->SetDefault();
}
void DIALOG_SCH_SHEET_PROPS::SetFileName( const wxString& aFileName )
{
// Filenames are stored using unix notation
@ -18,6 +22,7 @@ void DIALOG_SCH_SHEET_PROPS::SetFileName( const wxString& aFileName )
m_textFileName->SetValue( fname );
}
const wxString DIALOG_SCH_SHEET_PROPS::GetFileName()
{
// Filenames are stored using unix notation

View File

@ -75,6 +75,10 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
if( !fileName.IsOk() )
{
DisplayError( this, _( "File name is not valid!" ) );
if( m_canvas )
m_canvas->Refresh();
return false;
}
@ -85,6 +89,10 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
{
DisplayError( this, wxString::Format( _( "A sheet named \"%s\" already exists." ),
GetChars( dlg.GetSheetName() ) ) );
if( m_canvas )
m_canvas->Refresh();
return false;
}
@ -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?" );
if( !IsOK( this, msg ) )
{
if( m_canvas )
m_canvas->Refresh();
return false;
}
}
else // New file.
{
@ -150,12 +163,12 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
if( useScreen != NULL )
{
tmp.Printf( _( "A file named <%s> already exists in the current schematic hierarchy." ),
GetChars( newFullFilename ) );
GetChars( newFullFilename ) );
}
else
{
tmp.Printf( _( "A file named <%s> already exists." ),
GetChars( newFullFilename ) );
GetChars( newFullFilename ) );
}
msg += tmp;

View File

@ -30,16 +30,16 @@
#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
* 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.
*/
class FOOTPRINT_NAME_VALIDATOR : public wxTextValidator
class FILE_NAME_CHAR_VALIDATOR : public wxTextValidator
{
public:
FOOTPRINT_NAME_VALIDATOR( wxString* aValue = NULL ) :
FILE_NAME_CHAR_VALIDATOR( wxString* aValue = NULL ) :
wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue )
{
// The Windows (DOS) file system forbidden characters already include the forbidden

View File

@ -64,7 +64,7 @@ DIALOG_MODULE_MODULE_EDITOR::DIALOG_MODULE_MODULE_EDITOR( FOOTPRINT_EDIT_FRAME*
icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) );
SetIcon( icon );
m_FootprintNameCtrl->SetValidator( FOOTPRINT_NAME_VALIDATOR() );
m_FootprintNameCtrl->SetValidator( FILE_NAME_CHAR_VALIDATOR() );
initModeditProperties();
m_sdbSizerStdButtonsOK->SetDefault();
GetSizer()->SetSizeHints( this );

View File

@ -718,7 +718,7 @@ MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName )
if( moduleName.IsEmpty() )
{
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 )
return NULL; //Aborted by user