Changeset 29335 in osm for applications/editors/josm/plugins/wikipedia/src/org
- Timestamp:
- 2013-03-03T15:57:12+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaCopyTemplate.java
r29334 r29335 10 10 import org.openstreetmap.josm.Main; 11 11 import org.openstreetmap.josm.actions.JosmAction; 12 import org.openstreetmap.josm.data.Preferences; 13 import org.openstreetmap.josm.data.Preferences.pref; 12 14 import org.openstreetmap.josm.data.osm.Node; 13 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 17 19 public class WikipediaCopyTemplate { 18 20 19 private static final List<CoordCopyTemplate> TEMPLATES = Arrays.asList( 20 new CoordCopyTemplate(tr("Copy {0} template", "{{Coordinate}}"), "wikipedia-coordinate", "{{Coordinate|NS={lat}|EW={lon}|type=landmark|region=}}"), 21 new CoordCopyTemplate(tr("Copy {0} template", "{{Coord}}"), "wikipedia-coord", "{{Coord|{lat}|{lon}}}"), 22 new CoordCopyTemplate(tr("Copy {0} template", "{{Location dec}}"), "wikipedia-location-dec", "{{Location dec|{lat}|{lon}}}"), 23 new CoordCopyTemplate(tr("Copy {0} template", "{{Object location dec}}"), "wikipedia-object-location-dec", "{{Object location dec|{lat}|{lon}}}") 24 ); 21 private static final List<CoordCopyTemplateEntry> DEFAULT_TEMPLATES = Arrays.asList( 22 new CoordCopyTemplateEntry("{{Coordinate}}", "wikipedia-coordinate", "{{Coordinate|NS={lat}|EW={lon}|type=landmark|region=}}"), 23 new CoordCopyTemplateEntry("{{Coord}}", "wikipedia-coord", "{{Coord|{lat}|{lon}}}"), 24 new CoordCopyTemplateEntry("{{Location dec}}", "wikipedia-location-dec", "{{Location dec|{lat}|{lon}}}"), 25 new CoordCopyTemplateEntry("{{Object location dec}}", "wikipedia-object-location-dec", "{{Object location dec|{lat}|{lon}}}") 26 ); 27 28 private static final List<CoordCopyTemplateEntry> TEMPLATE_ENTRIES = 29 Main.pref.getListOfStructs("wikipedia.copytemplates", DEFAULT_TEMPLATES, CoordCopyTemplateEntry.class); 25 30 26 31 public WikipediaCopyTemplate() { 27 32 JosmAction previous = Main.main.menu.copyCoordinates; 28 for (final CoordCopyTemplate t : TEMPLATES) { 33 for (final CoordCopyTemplateEntry templateEntry : TEMPLATE_ENTRIES) { 34 CoordCopyTemplate t = new CoordCopyTemplate(templateEntry); 29 35 final JMenuItem menu = MainMenu.addAfter(Main.main.menu.editMenu, t, false, previous); 30 menu.setToolTipText(tr("Copies the template to the system clipboard instantiated with the coordinates of the first selected node")); 36 menu.setToolTipText(tr("Copies the {0} template to the system clipboard instantiated with the coordinates of the first selected node", templateEntry.name)); 31 37 previous = t; 32 //MainMenu.addAfter(Main.main.menu.editMenu, coord, false, Main.main.menu.copyCoordinates); 38 } 39 } 40 41 /** 42 * Class to hold copy templates for serialization using {@link Preferences}. 43 * Public visibility is needed for reflection used in {@link Preferences#getListOfStructs}. 44 */ 45 public static class CoordCopyTemplateEntry { 46 @pref 47 public String name; 48 @pref 49 public String id; 50 @pref 51 public String pattern; 52 53 public CoordCopyTemplateEntry() { 54 } 55 56 public CoordCopyTemplateEntry(String name, String id, String pattern) { 57 this.name = name; 58 this.id = id; 59 this.pattern = pattern; 33 60 } 34 61 } … … 37 64 38 65 protected final String pattern; 66 67 public CoordCopyTemplate(final CoordCopyTemplateEntry entry) { 68 this(tr("Copy {0} template", entry.name), entry.id, entry.pattern); 69 } 39 70 40 71 public CoordCopyTemplate(String name, String toolbarId, String pattern) {
Note:
See TracChangeset
for help on using the changeset viewer.