[20791] | 1 | package public_transport;
|
---|
| 2 |
|
---|
| 3 | import org.openstreetmap.josm.Main;
|
---|
| 4 | import org.openstreetmap.josm.command.Command;
|
---|
| 5 | import org.openstreetmap.josm.data.osm.Node;
|
---|
| 6 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
| 7 |
|
---|
| 8 | import java.util.Collection;
|
---|
| 9 | import java.util.Vector;
|
---|
[22048] | 10 | import javax.swing.JLabel;
|
---|
[20791] | 11 |
|
---|
| 12 | public class WaypointsNameCommand extends Command
|
---|
| 13 | {
|
---|
| 14 | private int workingLine = 0;
|
---|
| 15 | private WaypointTableModel waypointTM = null;
|
---|
| 16 | private String oldName = null;
|
---|
| 17 | private String name = null;
|
---|
[20835] | 18 | private String oldShelter = null;
|
---|
| 19 | private String shelter = null;
|
---|
[23192] | 20 |
|
---|
[20835] | 21 | public WaypointsNameCommand
|
---|
| 22 | (WaypointTableModel waypointTM, int workingLine, String name, String shelter)
|
---|
[20791] | 23 | {
|
---|
| 24 | this.waypointTM = waypointTM;
|
---|
| 25 | this.workingLine = workingLine;
|
---|
| 26 | if (waypointTM.nodes.elementAt(workingLine) != null)
|
---|
[20835] | 27 | {
|
---|
[20791] | 28 | oldName = waypointTM.nodes.elementAt(workingLine).get("name");
|
---|
[20835] | 29 | oldShelter = waypointTM.nodes.elementAt(workingLine).get("shelter");
|
---|
| 30 | }
|
---|
[20791] | 31 | this.name = name;
|
---|
[20835] | 32 | this.shelter = shelter;
|
---|
| 33 | if ("".equals(shelter))
|
---|
[20867] | 34 | this.shelter = null;
|
---|
[20791] | 35 | }
|
---|
[23192] | 36 |
|
---|
[20791] | 37 | public boolean executeCommand()
|
---|
| 38 | {
|
---|
| 39 | if (waypointTM.nodes.elementAt(workingLine) != null)
|
---|
| 40 | {
|
---|
| 41 | waypointTM.nodes.elementAt(workingLine).put("name", name);
|
---|
[20835] | 42 | waypointTM.nodes.elementAt(workingLine).put("shelter", shelter);
|
---|
[20839] | 43 | }
|
---|
| 44 | waypointTM.inEvent = true;
|
---|
| 45 | if (name == null)
|
---|
| 46 | waypointTM.setValueAt("", workingLine, 1);
|
---|
| 47 | else
|
---|
[20791] | 48 | waypointTM.setValueAt(name, workingLine, 1);
|
---|
[20839] | 49 | if (shelter == null)
|
---|
| 50 | waypointTM.setValueAt("", workingLine, 2);
|
---|
| 51 | else
|
---|
| 52 | waypointTM.setValueAt(shelter, workingLine, 2);
|
---|
| 53 | waypointTM.inEvent = false;
|
---|
[20791] | 54 | return true;
|
---|
| 55 | }
|
---|
[23192] | 56 |
|
---|
[20791] | 57 | public void undoCommand()
|
---|
| 58 | {
|
---|
| 59 | if (waypointTM.nodes.elementAt(workingLine) != null)
|
---|
| 60 | {
|
---|
| 61 | waypointTM.nodes.elementAt(workingLine).put("name", oldName);
|
---|
[20835] | 62 | waypointTM.nodes.elementAt(workingLine).put("shelter", oldShelter);
|
---|
[20839] | 63 | }
|
---|
| 64 | waypointTM.inEvent = true;
|
---|
| 65 | if (oldName == null)
|
---|
| 66 | waypointTM.setValueAt("", workingLine, 1);
|
---|
| 67 | else
|
---|
[20791] | 68 | waypointTM.setValueAt(oldName, workingLine, 1);
|
---|
[20839] | 69 | if (oldShelter == null)
|
---|
| 70 | waypointTM.setValueAt("", workingLine, 2);
|
---|
| 71 | else
|
---|
| 72 | waypointTM.setValueAt(oldShelter, workingLine, 2);
|
---|
| 73 | waypointTM.inEvent = false;
|
---|
[20791] | 74 | }
|
---|
[23192] | 75 |
|
---|
[20791] | 76 | public void fillModifiedData
|
---|
| 77 | (Collection< OsmPrimitive > modified, Collection< OsmPrimitive > deleted,
|
---|
| 78 | Collection< OsmPrimitive > added)
|
---|
| 79 | {
|
---|
| 80 | }
|
---|
[23192] | 81 |
|
---|
[22048] | 82 | @Override public JLabel getDescription()
|
---|
[20791] | 83 | {
|
---|
[22048] | 84 | return new JLabel("public_transport.Waypoints.EditName");
|
---|
[20791] | 85 | }
|
---|
| 86 | };
|
---|