]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - src/tim/prune/function/edit/PointEditor.java
Duplicate point before converting it to waypoint
[GpsPrune.git] / src / tim / prune / function / edit / PointEditor.java
index c66201b8d6f48ebcdf56105daa126077d0b85486..546a65e57e4cec6cf19be1ba0c477d598a7aeb4d 100644 (file)
@@ -307,10 +307,23 @@ public class PointEditor
                        if (_model.getChanged(i))
                        {
                                Field field = fieldList.getField(i);
+                               if (field == field.WAYPT_NAME) {
+                                       if (wasNameAdded(_model.getValue(i))) {
+                                               _app.createPoint(_point.clonePoint());
+                                       }
+                               }
                                editList.addEdit(new FieldEdit(field, _model.getValue(i)));
                                undoList.addEdit(new FieldEdit(field, _point.getFieldValue(field)));
                        }
                }
                _app.completePointEdit(editList, undoList);
        }
+
+       private boolean wasNameAdded(String newName)
+       {
+               String prevName = _point.getWaypointName();
+               boolean prevNull = (prevName == null || prevName.equals(""));
+               boolean newNull = (newName == null || newName.equals(""));
+               return (prevNull && !newNull);
+       }
 }