This repository was archived by the owner on Sep 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -220,13 +220,33 @@ public void saveCurrentRecord() {
220220
221221 public void updateListings () {
222222 int index = masterListModel .indexOf (selectedRecord .createListing ());
223- Listing l = masterListModel .get (index );
224- if (l .getFirstName () != null && l .getLastName () != null && (!l .getFirstName ().equals (selectedRecord .get ("First Name" ).getData ()) || !l .getLastName ().equals (selectedRecord .get ("Last Name" ).getData ()))) {
223+ if (nameChanged ()){
225224 masterListModel .remove (index );
226225 addListing (selectedRecord .createListing ());
227226 }
228227 }
229228
229+ public boolean nameChanged (){
230+ int index = masterListModel .indexOf (selectedRecord .createListing ());
231+ Listing l = masterListModel .get (index );
232+ if (!stringsEqual (l .getFirstName (), selectedRecord .get ("First Name" ).getData ())){
233+ return true ;
234+ }else if (!stringsEqual (l .getLastName (), selectedRecord .get ("Last Name" ).getData ())){
235+ return true ;
236+ }
237+ return false ;
238+ }
239+
240+ public boolean stringsEqual (String a , String b ){
241+ if (b == null && a == null ){
242+ return true ;
243+ }else if (b == null || a == null ){
244+ return false ;
245+ }else {
246+ return a .equals (b );
247+ }
248+ }
249+
230250 public void updateRecordData () {
231251 clearRecordData ();
232252 selectedRecord = databaseWrapper .getRecord (((Listing ) recordItemList .getSelectedValue ()).getID ());
You can’t perform that action at this time.
0 commit comments