1 package tim.prune.undo;
\r
3 import tim.prune.I18nManager;
\r
4 import tim.prune.data.DataPoint;
\r
5 import tim.prune.data.Field;
\r
6 import tim.prune.data.TrackInfo;
\r
7 import tim.prune.function.edit.FieldEditList;
\r
10 * Operation to undo the edit of a single point
\r
12 public class UndoEditPoint implements UndoOperation
\r
14 private DataPoint _originalPoint = null;
\r
15 private FieldEditList _undoFieldList = null;
\r
20 * @param inPoint data point
\r
21 * @param inUndoFieldList FieldEditList for undo operation
\r
23 public UndoEditPoint(DataPoint inPoint, FieldEditList inUndoFieldList)
\r
25 _originalPoint = inPoint;
\r
26 _undoFieldList = inUndoFieldList;
\r
31 * @return description of operation including point name if any
\r
33 public String getDescription()
\r
35 String desc = I18nManager.getText("undo.editpoint");
\r
36 String newName = null;
\r
37 if (_undoFieldList.getEdit(0).getField() == Field.WAYPT_NAME)
\r
38 newName = _undoFieldList.getEdit(0).getValue();
\r
39 String pointName = _originalPoint.getWaypointName();
\r
40 if (newName != null && !newName.equals(""))
\r
41 desc = desc + " " + newName;
\r
42 else if (pointName != null && !pointName.equals(""))
\r
43 desc = desc + " " + pointName;
\r
49 * Perform the undo operation on the given Track
\r
50 * @param inTrackInfo TrackInfo object on which to perform the operation
\r
52 public void performUndo(TrackInfo inTrackInfo) throws UndoException
\r
54 // Restore contents of point into track
\r
55 if (!inTrackInfo.getTrack().editPoint(_originalPoint, _undoFieldList, true))
\r
57 // throw exception if failed
\r
58 throw new UndoException(getDescription());
\r