]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/function/compress/DeleteMarkedPointsFunction.java
Version 18, July 2015
[GpsPrune.git] / tim / prune / function / compress / DeleteMarkedPointsFunction.java
1 package tim.prune.function.compress;
2
3 import tim.prune.App;
4 import tim.prune.GenericFunction;
5 import tim.prune.I18nManager;
6 import tim.prune.undo.UndoDeleteMarked;
7
8 /**
9  * Function to delete the marked points in the track
10  */
11 public class DeleteMarkedPointsFunction extends GenericFunction
12 {
13         private boolean _splitSegments = false;
14         private String  _parentFunctionKey = null;
15
16         /** Constructor */
17         public DeleteMarkedPointsFunction(App inApp) {
18                 super(inApp);
19         }
20
21         @Override
22         public String getNameKey() {
23                 return "function.deletemarked";
24         }
25
26         /**
27          * Get notification about parent function
28          * @param inKey parent function name key
29          * @param inSplitSegments true to split segment, false to not
30          */
31         public void setParentFunction(String inKey, boolean inSplitSegments)
32         {
33                 _parentFunctionKey = inKey;
34                 _splitSegments = inSplitSegments;
35         }
36
37         @Override
38         public void begin()
39         {
40                 UndoDeleteMarked undo = new UndoDeleteMarked(_app.getTrackInfo().getTrack());
41                 // call track to do the actual delete//
42                 int numPointsDeleted = _app.getTrackInfo().deleteMarkedPoints(_splitSegments);
43                 // add to undo stack if successful
44                 if (numPointsDeleted > 0)
45                 {
46                         undo.setNumPointsDeleted(numPointsDeleted);
47                         _app.completeFunction(undo, "" + numPointsDeleted + " "
48                                  + (numPointsDeleted==1?I18nManager.getText("confirm.deletepoint.single"):I18nManager.getText("confirm.deletepoint.multi")));
49                 }
50                 else
51                 {
52                         final String titleKey = (_parentFunctionKey == null ? getNameKey() : _parentFunctionKey);
53                         _app.showErrorMessage(titleKey, "dialog.deletemarked.nonefound");
54                 }
55         }
56 }