source: osm/applications/editors/josm/plugins/public_transport/src/public_transport/WaypointsNameCommand.java@ 23192

Last change on this file since 23192 was 23192, checked in by stoecker, 14 years ago

remove tabs

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