diff --git a/eeschema/dialogs/dialog_edit_component_in_lib.cpp b/eeschema/dialogs/dialog_edit_component_in_lib.cpp index 04f8fea865..ede0af8818 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_lib.cpp @@ -66,7 +66,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg() { m_AliasLocation = -1; - LIB_PART* component = m_Parent->GetCurPart(); + LIB_PART* component = m_Parent->GetCurPart(); if( component == NULL ) { @@ -74,7 +74,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg() return; } - wxString title; + wxString title, staticText; bool isRoot = m_Parent->GetAliasName().CmpNoCase( component->GetName() ) == 0; if( !isRoot ) @@ -82,6 +82,9 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg() title.Printf( _( "Properties for %s (alias of %s)" ), GetChars( m_Parent->GetAliasName() ), GetChars( component->GetName() ) ); + + staticText.Printf( _( "Alias List of %s" ), GetChars( component->GetName() ) ); + m_staticTextAlias->SetLabelText( staticText ); } else title.Printf( _( "Properties for %s" ), GetChars( component->GetName() ) ); @@ -90,17 +93,12 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg() InitPanelDoc(); InitBasicPanel(); - if( isRoot && component->GetAliasCount() == 1 ) - m_ButtonDeleteAllAlias->Enable( false ); - - /* Place list of alias names in listbox */ + // The component's alias list contains all names (including the root). The UI list + // contains only aliases, so exclude the root. m_PartAliasListCtrl->Append( component->GetAliasNames( false ) ); - if( component->GetAliasCount() <= 1 ) - { - m_ButtonDeleteAllAlias->Enable( false ); - m_ButtonDeleteOneAlias->Enable( false ); - } + // Note: disabling the delete buttons gives us no opportunity to tell the user + // why they're disabled. Leave them enabled and bring up an error message instead. /* Read the Footprint Filter list */ m_FootprintFilterListBox->Append( component->GetFootprints() ); @@ -124,11 +122,10 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnCancelClick( wxCommandEvent& event ) } - void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc() { LIB_ALIAS* alias; - LIB_PART* component = m_Parent->GetCurPart(); + LIB_PART* component = m_Parent->GetCurPart(); if( component == NULL ) return; @@ -154,7 +151,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc() */ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel() { - LIB_PART* component = m_Parent->GetCurPart(); + LIB_PART* component = m_Parent->GetCurPart(); if( m_Parent->GetShowDeMorgan() ) m_AsConvertButt->SetValue( true ); @@ -193,7 +190,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) { /* Update the doc, keyword and doc filename strings */ LIB_ALIAS* alias; - LIB_PART* component = m_Parent->GetCurPart(); + LIB_PART* component = m_Parent->GetCurPart(); if( component == NULL ) { @@ -213,7 +210,11 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event ) alias->SetKeyWords( m_KeywordsCtrl->GetValue() ); alias->SetDocFileName( m_DocfileCtrl->GetValue() ); - component->SetAliases( m_PartAliasListCtrl->GetStrings() ); + // The UI list contains only aliases (ie: not the root's name), while the component's + // alias list contains all names (including the root). + wxArrayString aliases = m_PartAliasListCtrl->GetStrings(); + aliases.Add( component->GetName() ); + component->SetAliases( aliases ); int unitCount = m_SelNumberOfUnits->GetValue(); ChangeNbUnitsPerPackage( unitCount ); @@ -294,21 +295,17 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::CopyDocFromRootToAlias( wxCommandEvent& e void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllAliasOfPart( wxCommandEvent& event ) { + if( m_PartAliasListCtrl->GetCount() == 0 ) + return; + if( m_PartAliasListCtrl->FindString( m_Parent->GetAliasName() ) != wxNOT_FOUND ) { - wxString msg; - msg.Printf( _( "Alias \"%s\" cannot be removed while it is being edited!" ), - GetChars( m_Parent->GetAliasName() ) ); - DisplayError( this, msg ); + DisplayErrorMessage( this, _( "Delete All can be done only when editing the main symbol." ) ); return; } if( IsOK( this, _( "Remove all aliases from list?" ) ) ) - { m_PartAliasListCtrl->Clear(); - m_ButtonDeleteAllAlias->Enable( false ); - m_ButtonDeleteOneAlias->Enable( false ); - } } @@ -339,9 +336,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& event ) if( m_PartAliasListCtrl->FindString( aliasname ) != wxNOT_FOUND ) { wxString msg; - msg.Printf( _( "Alias or component name \"%s\" already in use." ), - GetChars( aliasname ) ); - DisplayError( this, msg ); + msg.Printf( _( "Alias \"%s\" already exists." ), GetChars( aliasname ) ); + DisplayInfoMessage( this, msg ); return; } @@ -349,16 +345,11 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& event ) { wxString msg; msg.Printf( _( "Symbol name \"%s\" already exists in library \"%s\"." ), aliasname, library ); - DisplayError( this, msg ); + DisplayErrorMessage( this, msg ); return; } m_PartAliasListCtrl->Append( aliasname ); - - if( m_Parent->GetAliasName().CmpNoCase( component->GetName() ) == 0 ) - m_ButtonDeleteAllAlias->Enable( true ); - - m_ButtonDeleteOneAlias->Enable( true ); } @@ -379,16 +370,6 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAliasOfPart( wxCommandEvent& event } m_PartAliasListCtrl->Delete( m_PartAliasListCtrl->GetSelection() ); - LIB_PART* component = m_Parent->GetCurPart(); - - if( component ) - component->RemoveAlias( aliasname ); - - if( m_PartAliasListCtrl->IsEmpty() ) - { - m_ButtonDeleteAllAlias->Enable( false ); - m_ButtonDeleteOneAlias->Enable( false ); - } } diff --git a/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp b/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp index af3a100b83..134a3d9f83 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_lib_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 22 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -196,7 +196,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx m_PanelAlias->SetSizer( bSizerMainPanelAlias ); m_PanelAlias->Layout(); bSizerMainPanelAlias->Fit( m_PanelAlias ); - m_NoteBook->AddPage( m_PanelAlias, _("Alias"), false ); + m_NoteBook->AddPage( m_PanelAlias, _("Aliases"), false ); m_PanelFootprintFilter = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bPanelFpFilterBoxSizer; bPanelFpFilterBoxSizer = new wxBoxSizer( wxHORIZONTAL ); diff --git a/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp b/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp index a3638a3ed5..9648f10a1a 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp +++ b/eeschema/dialogs/dialog_edit_component_in_lib_base.fbp @@ -2147,7 +2147,7 @@ - Alias + Aliases 0 1 diff --git a/eeschema/dialogs/dialog_edit_component_in_lib_base.h b/eeschema/dialogs/dialog_edit_component_in_lib_base.h index 8eb0b6c1e8..2b3884b7ab 100644 --- a/eeschema/dialogs/dialog_edit_component_in_lib_base.h +++ b/eeschema/dialogs/dialog_edit_component_in_lib_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 22 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE!