Changeset 29760 in osm for applications/editors/josm/plugins
- Timestamp:
- 2013-07-17T07:34:37+02:00 (12 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
r29758 r29760 26 26 --> 27 27 <project name="tagging-preset-tester" default="dist" basedir="."> 28 <property name="commit.message" value="[josm_tagging_preset_tester] fix #josm88 79: make all panels active by default and use current selection"/>29 <property name="plugin.main.version" value=" 4980"/>28 <property name="commit.message" value="[josm_tagging_preset_tester] fix #josm8853: use preset seach panel in the plugin instead of the compbobox"/> 29 <property name="plugin.main.version" value="6071"/> 30 30 <property name="josm" location="../../core/dist/josm-custom.jar"/> 31 31 <property name="plugin.dist.dir" value="../../dist"/> -
applications/editors/josm/plugins/tagging-preset-tester/src/org/openstreetmap/josm/plugins/taggingpresettester/TaggingPresetTester.java
r29758 r29760 4 4 5 5 import java.awt.BorderLayout; 6 import java.awt.Dimension; 7 import java.awt.GridBagLayout; 8 import java.awt.GridLayout; 6 9 import java.awt.event.ActionEvent; 7 10 import java.awt.event.ActionListener; … … 9 12 import java.util.Collection; 10 13 import java.util.Collections; 11 import java.util.Vector;12 14 13 15 import javax.swing.BorderFactory; 14 import javax.swing.DefaultComboBoxModel;15 16 import javax.swing.JButton; 16 17 import javax.swing.JComboBox; … … 26 27 import org.openstreetmap.josm.data.osm.Way; 27 28 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 29 import org.openstreetmap.josm.gui.tagging.TaggingPresetReader; 30 import org.openstreetmap.josm.gui.tagging.TaggingPresetSelector; 31 import org.openstreetmap.josm.gui.tagging.TaggingPresetType; 32 import org.openstreetmap.josm.tools.GBC; 28 33 29 34 /** … … 32 37 public class TaggingPresetTester extends JFrame { 33 38 34 private JComboBoxtaggingPresets;39 private TaggingPresetSelector taggingPresets; 35 40 private final String[] args; 36 41 private JPanel taggingPresetPanel = new JPanel(new BorderLayout()); 37 private JPanel panel = new JPanel(new BorderLayout());42 private JPanel panel = new JPanel(new GridBagLayout()); 38 43 39 44 public final void reload() { 40 Vector<TaggingPreset> allPresets = new Vector<TaggingPreset>(TaggingPreset.readAll(Arrays.asList(args), true)); 41 taggingPresets.setModel(new DefaultComboBoxModel(allPresets)); 45 taggingPresets.init(TaggingPresetReader.readAll(Arrays.asList(args), true)); 42 46 } 43 47 44 48 public final void reselect() { 45 49 taggingPresetPanel.removeAll(); 46 TaggingPreset preset = (TaggingPreset)taggingPresets.getSelectedItem();50 TaggingPreset preset = taggingPresets.getSelectedPreset(); 47 51 if (preset == null) 48 52 return; … … 65 69 super(tr("Tagging Preset Tester")); 66 70 this.args = args; 67 taggingPresets = new JComboBox();68 taggingPreset s.setRenderer(new TaggingCellRenderer());71 taggingPresets = new TaggingPresetSelector(); 72 taggingPresetPanel.setPreferredSize(new Dimension(300,500)); 69 73 reload(); 70 74 71 panel.add(taggingPresets, BorderLayout.NORTH);72 panel.add(taggingPresetPanel, BorderLayout.CENTER);73 taggingPresets. addActionListener(new ActionListener(){75 panel.add(taggingPresets, GBC.std(0,0).fill(GBC.BOTH)); 76 panel.add(taggingPresetPanel, GBC.std(1,0).fill(GBC.BOTH)); 77 taggingPresets.setClickListener(new ActionListener(){ 74 78 @Override 75 79 public void actionPerformed(ActionEvent e) { … … 83 87 @Override 84 88 public void actionPerformed(ActionEvent e) { 85 int i= taggingPresets.getSelectedIndex();89 TaggingPreset p = taggingPresets.getSelectedPreset(); 86 90 reload(); 87 if (i < taggingPresets.getItemCount()) { 88 taggingPresets.setSelectedIndex(i); 89 } 91 if (p!=null)taggingPresets.setSelectedPreset(p); 90 92 } 91 93 }); 92 panel.add(b, BorderLayout.SOUTH);94 panel.add(b, GBC.std(0,1).span(2,1).fill(GBC.HORIZONTAL)); 93 95 94 96 setContentPane(panel); 95 setSize( 300,500);97 setSize(600,500); 96 98 } 97 99 … … 108 110 109 111 private Collection<OsmPrimitive> makeFakeSuitablePrimitive(TaggingPreset preset) { 110 if (preset.typeMatches(Collections.singleton(TaggingPreset .PresetType.NODE))) {112 if (preset.typeMatches(Collections.singleton(TaggingPresetType.NODE))) { 111 113 return Collections.<OsmPrimitive>singleton(new Node()); 112 } else if (preset.typeMatches(Collections.singleton(TaggingPreset .PresetType.WAY))) {114 } else if (preset.typeMatches(Collections.singleton(TaggingPresetType.WAY))) { 113 115 return Collections.<OsmPrimitive>singleton(new Way()); 114 } else if (preset.typeMatches(Collections.singleton(TaggingPreset .PresetType.RELATION))) {116 } else if (preset.typeMatches(Collections.singleton(TaggingPresetType.RELATION))) { 115 117 return Collections.<OsmPrimitive>singleton(new Relation()); 116 } else if (preset.typeMatches(Collections.singleton(TaggingPreset .PresetType.CLOSEDWAY))) {118 } else if (preset.typeMatches(Collections.singleton(TaggingPresetType.CLOSEDWAY))) { 117 119 Way w = new Way(); 118 120 w.addNode(new Node(new LatLon(0,0))); -
applications/editors/josm/plugins/tagging-preset-tester/src/org/openstreetmap/josm/plugins/taggingpresettester/TaggingPresetTesterAction.java
r29758 r29760 12 12 import org.openstreetmap.josm.actions.JosmAction; 13 13 import org.openstreetmap.josm.gui.MainMenu; 14 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 14 import org.openstreetmap.josm.gui.tagging.TaggingPresetReader; 15 15 import org.openstreetmap.josm.plugins.PluginInformation; 16 16 import org.openstreetmap.josm.tools.Shortcut; … … 38 38 @Override 39 39 public void actionPerformed(ActionEvent e) { 40 Collection<String> coll = TaggingPreset.getPresetSources(); 40 Collection<String> coll = TaggingPresetReader.getPresetSources(); 41 41 42 42 if (coll.isEmpty()) {
Note:
See TracChangeset
for help on using the changeset viewer.