]> gitweb.fperrin.net Git - GpsPrune.git/commitdiff
Merge branch 'start-with-editable-map' into fp-integration
authorFrédéric Perrin <fred@fperrin.net>
Sat, 30 Nov 2019 20:50:19 +0000 (20:50 +0000)
committerFrédéric Perrin <fred@fperrin.net>
Sat, 30 Nov 2019 20:50:19 +0000 (20:50 +0000)
.gitignore [new file with mode: 0644]
buildtools/build.sh [changed mode: 0644->0755]
src/tim/prune/function/edit/PointEditor.java
src/tim/prune/function/edit/PointNameEditor.java
src/tim/prune/gui/DisplayUtils.java
src/tim/prune/gui/map/MapCanvas.java

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..8e9e794
--- /dev/null
@@ -0,0 +1,2 @@
+*.class
+*.jar
old mode 100644 (file)
new mode 100755 (executable)
index b38e2ce..c7fcf3d
@@ -1,3 +1,4 @@
+set -e
 # Build script
 # Version number
 PRUNENAME=gpsprune_19.2
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);
+       }
 }
index 53e1f834b962fa8a098a9fc9345934dbdac3003f..9e6e343dc1357e3f0b9c753b4fd514cb21f20e1e 100644 (file)
@@ -206,7 +206,11 @@ 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
+                       _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 +235,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);
+       }
 }
index 25640d8e5072bfc2e70acfc3e26c7de208a494e3..2300296760fa1febfeb8f2dc59d393ca35bb639a 100644 (file)
@@ -36,7 +36,8 @@ public abstract class DisplayUtils
                if (inNumSecs < 86400L) return "" + (inNumSecs / 60 / 60) + I18nManager.getText("display.range.time.hours")
                        + " " + ((inNumSecs / 60) % 60) + I18nManager.getText("display.range.time.mins");
                if (inNumSecs < 432000L) return "" + (inNumSecs / 86400L) + I18nManager.getText("display.range.time.days")
-                       + " " + (inNumSecs / 60 / 60) % 24 + I18nManager.getText("display.range.time.hours");
+                       + " " + (inNumSecs / 60 / 60) % 24 + I18nManager.getText("display.range.time.hours")
+                       + " " + ((inNumSecs / 60) % 60) + I18nManager.getText("display.range.time.mins");
                if (inNumSecs < 86400000L) return "" + (inNumSecs / 86400L) + I18nManager.getText("display.range.time.days");
                return "big";
        }
index 8297e019db986117d3c213ca58294fbee49536ec..ad38d8182700cf49a1d5055f66bbb4ec8b56a20e 100644 (file)
@@ -92,7 +92,7 @@ public class MapCanvas extends JPanel implements MouseListener, MouseMotionListe
        WpIconDefinition _waypointIconDefinition = null;
 
        /** Constant for click sensitivity when selecting nearest point */
-       private static final int CLICK_SENSITIVITY = 10;
+       private static final int CLICK_SENSITIVITY = 30;
        /** Constant for pan distance from key presses */
        private static final int PAN_DISTANCE = 20;
        /** Constant for pan distance from autopan */