X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Ffunction%2Fedit%2FPointNameEditor.java;h=ca5771d45fe9886c2717127b8e80ef257a47dc8e;hp=53e1f834b962fa8a098a9fc9345934dbdac3003f;hb=b84283f50ae0e2d1db1bdea1be2dac12660768a5;hpb=07a0b0905dba057361e45f09d1a3ac990cd0cb63 diff --git a/src/tim/prune/function/edit/PointNameEditor.java b/src/tim/prune/function/edit/PointNameEditor.java index 53e1f83..ca5771d 100644 --- a/src/tim/prune/function/edit/PointNameEditor.java +++ b/src/tim/prune/function/edit/PointNameEditor.java @@ -206,7 +206,14 @@ public class PointNameEditor extends GenericFunction // Check whether name has really changed if (hasNameChanged()) { - // Make lists for edit and undo, and add the changed field + // If a new name has been added, changing the point + // from trackpoint to waypoint, duplicate it + if (wasNameAdded()) + { + _app.createPoint(_point.clonePoint()); + } + + // make lists for edit and undo, and add the changed field FieldEditList editList = new FieldEditList(); FieldEditList undoList = new FieldEditList(); editList.addEdit(new FieldEdit(Field.WAYPT_NAME, _nameField.getText().trim())); @@ -231,4 +238,17 @@ public class PointNameEditor extends GenericFunction || (!prevNull && newNull) || (!prevNull && !newNull && !prevName.equals(newName)); } + + /** + * Check whether a new name has been added + * @return true if it has indeed + */ + private boolean wasNameAdded() + { + String prevName = _point.getWaypointName(); + String newName = _nameField.getText().trim(); + boolean prevNull = (prevName == null || prevName.equals("")); + boolean newNull = (newName == null || newName.equals("")); + return (prevNull && !newNull); + } }