Changeset 29758 in osm for applications/editors/josm
- Timestamp:
- 2013-07-17T06:51:58+02:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/tagging-preset-tester
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/tagging-preset-tester/build.xml
r29435 r29758 26 26 --> 27 27 <project name="tagging-preset-tester" default="dist" basedir="."> 28 <property name="commit.message" value=" fix shortcuts conflict"/>28 <property name="commit.message" value="[josm_tagging_preset_tester] fix #josm8879: make all panels active by default and use current selection"/> 29 29 <property name="plugin.main.version" value="4980"/> 30 30 <property name="josm" location="../../core/dist/josm-custom.jar"/> -
applications/editors/josm/plugins/tagging-preset-tester/src/org/openstreetmap/josm/plugins/taggingpresettester/TaggingPresetTester.java
r29748 r29758 19 19 import javax.swing.JPanel; 20 20 21 import org.openstreetmap.josm.Main; 22 import org.openstreetmap.josm.data.coor.LatLon; 23 import org.openstreetmap.josm.data.osm.Node; 21 24 import org.openstreetmap.josm.data.osm.OsmPrimitive; 25 import org.openstreetmap.josm.data.osm.Relation; 26 import org.openstreetmap.josm.data.osm.Way; 22 27 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 23 28 … … 32 37 private JPanel panel = new JPanel(new BorderLayout()); 33 38 34 public void reload() {39 public final void reload() { 35 40 Vector<TaggingPreset> allPresets = new Vector<TaggingPreset>(TaggingPreset.readAll(Arrays.asList(args), true)); 36 41 taggingPresets.setModel(new DefaultComboBoxModel(allPresets)); 37 42 } 38 43 39 public void reselect() {44 public final void reselect() { 40 45 taggingPresetPanel.removeAll(); 41 46 TaggingPreset preset = (TaggingPreset)taggingPresets.getSelectedItem(); 42 47 if (preset == null) 43 48 return; 44 Collection<OsmPrimitive> x = Collections.emptySet(); 49 Collection<OsmPrimitive> x; 50 if (Main.main.hasEditLayer()) { 51 x = Main.main.getCurrentDataSet().getSelected(); 52 } else { 53 x = makeFakeSuitablePrimitive(preset); 54 } 45 55 JPanel p = preset.createPanel(x); 46 p.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));47 if (p != null)56 if (p != null) { 57 p.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 48 58 taggingPresetPanel.add(p, BorderLayout.NORTH); 59 } 49 60 panel.validate(); 50 61 panel.repaint(); … … 61 72 panel.add(taggingPresetPanel, BorderLayout.CENTER); 62 73 taggingPresets.addActionListener(new ActionListener(){ 74 @Override 63 75 public void actionPerformed(ActionEvent e) { 64 76 reselect(); … … 69 81 JButton b = new JButton(tr("Reload")); 70 82 b.addActionListener(new ActionListener(){ 83 @Override 71 84 public void actionPerformed(ActionEvent e) { 72 85 int i = taggingPresets.getSelectedIndex(); … … 81 94 setContentPane(panel); 82 95 setSize(300,500); 83 setVisible(true);84 96 } 85 97 … … 94 106 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 95 107 } 108 109 private Collection<OsmPrimitive> makeFakeSuitablePrimitive(TaggingPreset preset) { 110 if (preset.typeMatches(Collections.singleton(TaggingPreset.PresetType.NODE))) { 111 return Collections.<OsmPrimitive>singleton(new Node()); 112 } else if (preset.typeMatches(Collections.singleton(TaggingPreset.PresetType.WAY))) { 113 return Collections.<OsmPrimitive>singleton(new Way()); 114 } else if (preset.typeMatches(Collections.singleton(TaggingPreset.PresetType.RELATION))) { 115 return Collections.<OsmPrimitive>singleton(new Relation()); 116 } else if (preset.typeMatches(Collections.singleton(TaggingPreset.PresetType.CLOSEDWAY))) { 117 Way w = new Way(); 118 w.addNode(new Node(new LatLon(0,0))); 119 w.addNode(new Node(new LatLon(0,1))); 120 w.addNode(new Node(new LatLon(1,1))); 121 w.addNode(new Node(new LatLon(0,0))); 122 return Collections.<OsmPrimitive>singleton(w); 123 } else { 124 return Collections.emptySet(); 125 } 126 } 96 127 } -
applications/editors/josm/plugins/tagging-preset-tester/src/org/openstreetmap/josm/plugins/taggingpresettester/TaggingPresetTesterAction.java
r29748 r29758 36 36 } 37 37 38 @Override 38 39 public void actionPerformed(ActionEvent e) { 39 40 Collection<String> coll = TaggingPreset.getPresetSources(); 40 41 41 if (coll. size() == 0) {42 if (coll.isEmpty()) { 42 43 JOptionPane.showMessageDialog(Main.parent, tr("You have to specify tagging preset sources in the preferences first.")); 43 44 return; … … 46 47 String[] taggingPresetSources = new String [coll.size()]; 47 48 coll.toArray(taggingPresetSources); 48 new TaggingPresetTester(taggingPresetSources) ;49 new TaggingPresetTester(taggingPresetSources).setVisible(true); 49 50 } 50 51 }
Note:
See TracChangeset
for help on using the changeset viewer.