X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Ffunction%2Fcompress%2FDeleteMarkedPointsFunction.java;fp=src%2Ftim%2Fprune%2Ffunction%2Fcompress%2FDeleteMarkedPointsFunction.java;h=a6049070eea16db42e1fcad3f632a573bee1e521;hp=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465 diff --git a/src/tim/prune/function/compress/DeleteMarkedPointsFunction.java b/src/tim/prune/function/compress/DeleteMarkedPointsFunction.java new file mode 100644 index 0000000..a604907 --- /dev/null +++ b/src/tim/prune/function/compress/DeleteMarkedPointsFunction.java @@ -0,0 +1,56 @@ +package tim.prune.function.compress; + +import tim.prune.App; +import tim.prune.GenericFunction; +import tim.prune.I18nManager; +import tim.prune.undo.UndoDeleteMarked; + +/** + * Function to delete the marked points in the track + */ +public class DeleteMarkedPointsFunction extends GenericFunction +{ + private boolean _splitSegments = false; + private String _parentFunctionKey = null; + + /** Constructor */ + public DeleteMarkedPointsFunction(App inApp) { + super(inApp); + } + + @Override + public String getNameKey() { + return "function.deletemarked"; + } + + /** + * Get notification about parent function + * @param inKey parent function name key + * @param inSplitSegments true to split segment, false to not + */ + public void setParentFunction(String inKey, boolean inSplitSegments) + { + _parentFunctionKey = inKey; + _splitSegments = inSplitSegments; + } + + @Override + public void begin() + { + UndoDeleteMarked undo = new UndoDeleteMarked(_app.getTrackInfo().getTrack()); + // call track to do the actual delete// + int numPointsDeleted = _app.getTrackInfo().deleteMarkedPoints(_splitSegments); + // add to undo stack if successful + if (numPointsDeleted > 0) + { + undo.setNumPointsDeleted(numPointsDeleted); + _app.completeFunction(undo, "" + numPointsDeleted + " " + + (numPointsDeleted==1?I18nManager.getText("confirm.deletepoint.single"):I18nManager.getText("confirm.deletepoint.multi"))); + } + else + { + final String titleKey = (_parentFunctionKey == null ? getNameKey() : _parentFunctionKey); + _app.showErrorMessage(titleKey, "dialog.deletemarked.nonefound"); + } + } +}