Changeset 294 in josm
- Timestamp:
- 2007-07-20T17:21:38+02:00 (18 years ago)
- Files:
-
- 3 added
- 3 deleted
- 4 edited
- 3 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/Main.java
r293 r294 52 52 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 53 53 import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener; 54 import org.openstreetmap.josm.gui.preferences. AnnotationPresetPreference;54 import org.openstreetmap.josm.gui.preferences.TaggingPresetPreference; 55 55 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences; 56 56 import org.openstreetmap.josm.plugins.PluginException; … … 192 192 contentPane.getActionMap().put("Help", menu.help); 193 193 194 AnnotationPresetPreference.initialize();194 TaggingPresetPreference.initialize(); 195 195 196 196 toolbar.refreshToolbarControl(); -
src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r290 r294 48 48 import org.openstreetmap.josm.data.osm.OsmPrimitive; 49 49 import org.openstreetmap.josm.gui.MapFrame; 50 import org.openstreetmap.josm.gui. annotation.AnnotationCellRenderer;51 import org.openstreetmap.josm.gui. annotation.AnnotationPreset;52 import org.openstreetmap.josm.gui. annotation.ForwardActionListener;53 import org.openstreetmap.josm.gui. preferences.AnnotationPresetPreference;50 import org.openstreetmap.josm.gui.preferences.TaggingPresetPreference; 51 import org.openstreetmap.josm.gui.tagging.TaggingCellRenderer; 52 import org.openstreetmap.josm.gui.tagging.ForwardActionListener; 53 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 54 54 import org.openstreetmap.josm.tools.AutoCompleteComboBox; 55 55 import org.openstreetmap.josm.tools.GBC; … … 269 269 */ 270 270 private final JTable propertyTable = new JTable(data); 271 public JComboBox annotationPresets = new JComboBox();271 public JComboBox taggingPresets = new JComboBox(); 272 272 273 273 … … 278 278 super(tr("Properties"), "propertiesdialog", tr("Properties for selected objects."), KeyEvent.VK_P, 150); 279 279 280 if ( AnnotationPresetPreference.annotationPresets.size() > 0) {280 if (TaggingPresetPreference.taggingPresets.size() > 0) { 281 281 Vector<ActionListener> allPresets = new Vector<ActionListener>(); 282 for (final AnnotationPreset p :AnnotationPresetPreference.annotationPresets)282 for (final TaggingPreset p : TaggingPresetPreference.taggingPresets) 283 283 allPresets.add(new ForwardActionListener(this, p)); 284 284 285 allPresets.add(0, new ForwardActionListener(this, new AnnotationPreset()));286 annotationPresets.setModel(new DefaultComboBoxModel(allPresets));285 allPresets.add(0, new ForwardActionListener(this, new TaggingPreset())); 286 taggingPresets.setModel(new DefaultComboBoxModel(allPresets)); 287 287 JPanel north = new JPanel(new GridBagLayout()); 288 288 north.add(getComponent(0),GBC.eol().fill(GBC.HORIZONTAL)); 289 north.add( annotationPresets,GBC.eol().fill(GBC.HORIZONTAL));289 north.add(taggingPresets,GBC.eol().fill(GBC.HORIZONTAL)); 290 290 add(north, BorderLayout.NORTH); 291 291 } 292 annotationPresets.addActionListener(new ActionListener(){292 taggingPresets.addActionListener(new ActionListener(){ 293 293 public void actionPerformed(ActionEvent e) { 294 AnnotationPreset preset = ((ForwardActionListener)annotationPresets.getSelectedItem()).preset;294 TaggingPreset preset = ((ForwardActionListener)taggingPresets.getSelectedItem()).preset; 295 295 preset.actionPerformed(e); 296 annotationPresets.setSelectedItem(null);296 taggingPresets.setSelectedItem(null); 297 297 } 298 298 }); 299 annotationPresets.setRenderer(newAnnotationCellRenderer());299 taggingPresets.setRenderer(new TaggingCellRenderer()); 300 300 301 301 data.setColumnIdentifiers(new String[]{tr("Key"),tr("Value")}); -
src/org/openstreetmap/josm/gui/preferences/PluginPreference.java
r287 r294 169 169 proxy.info.name, 170 170 proxy.info.description, 171 PluginInformation.getURLString(proxy.info.file.getPath()))); 171 proxy.info.file == null ? null : PluginInformation.getURLString(proxy.info.file.getPath()))); 172 172 return availablePlugins.values(); 173 173 } -
src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java
r283 r294 103 103 settings.add(new CsvPreference()); 104 104 settings.add(new ProjectionPreference()); 105 settings.add(new AnnotationPresetPreference());105 settings.add(new TaggingPresetPreference()); 106 106 settings.add(new PluginPreference()); 107 107 settings.add(Main.toolbar); -
src/org/openstreetmap/josm/gui/preferences/TaggingPresetPreference.java
r291 r294 19 19 20 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.gui. annotation.AnnotationPreset;21 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 22 22 import org.openstreetmap.josm.tools.GBC; 23 23 24 public class AnnotationPresetPreference implements PreferenceSetting {24 public class TaggingPresetPreference implements PreferenceSetting { 25 25 26 public static Collection< AnnotationPreset>annotationPresets;27 private JList annotationSources;26 public static Collection<TaggingPreset> taggingPresets; 27 private JList taggingPresetSources; 28 28 29 29 public void addGui(final PreferenceDialog gui) { 30 annotationSources = new JList(new DefaultListModel());31 String annos = Main.pref.get(" annotation.sources");30 taggingPresetSources = new JList(new DefaultListModel()); 31 String annos = Main.pref.get("taggingpreset.sources"); 32 32 StringTokenizer st = new StringTokenizer(annos, ";"); 33 33 while (st.hasMoreTokens()) 34 ((DefaultListModel) annotationSources.getModel()).addElement(st.nextToken());34 ((DefaultListModel)taggingPresetSources.getModel()).addElement(st.nextToken()); 35 35 36 36 JButton addAnno = new JButton(tr("Add")); 37 37 addAnno.addActionListener(new ActionListener(){ 38 38 public void actionPerformed(ActionEvent e) { 39 String source = JOptionPane.showInputDialog(Main.parent, tr(" Annotationpreset source"));39 String source = JOptionPane.showInputDialog(Main.parent, tr("Tagging preset source")); 40 40 if (source == null) 41 41 return; 42 ((DefaultListModel) annotationSources.getModel()).addElement(source);42 ((DefaultListModel)taggingPresetSources.getModel()).addElement(source); 43 43 gui.requiresRestart = true; 44 44 } … … 48 48 editAnno.addActionListener(new ActionListener(){ 49 49 public void actionPerformed(ActionEvent e) { 50 if ( annotationSources.getSelectedIndex() == -1)50 if (taggingPresetSources.getSelectedIndex() == -1) 51 51 JOptionPane.showMessageDialog(Main.parent, tr("Please select the row to edit.")); 52 52 else { 53 String source = JOptionPane.showInputDialog(Main.parent, tr(" Annotationpreset source"),annotationSources.getSelectedValue());53 String source = JOptionPane.showInputDialog(Main.parent, tr("Tagging preset source"), taggingPresetSources.getSelectedValue()); 54 54 if (source == null) 55 55 return; 56 ((DefaultListModel) annotationSources.getModel()).setElementAt(source,annotationSources.getSelectedIndex());56 ((DefaultListModel)taggingPresetSources.getModel()).setElementAt(source, taggingPresetSources.getSelectedIndex()); 57 57 gui.requiresRestart = true; 58 58 } … … 63 63 deleteAnno.addActionListener(new ActionListener(){ 64 64 public void actionPerformed(ActionEvent e) { 65 if ( annotationSources.getSelectedIndex() == -1)65 if (taggingPresetSources.getSelectedIndex() == -1) 66 66 JOptionPane.showMessageDialog(Main.parent, tr("Please select the row to delete.")); 67 67 else { 68 ((DefaultListModel) annotationSources.getModel()).remove(annotationSources.getSelectedIndex());68 ((DefaultListModel)taggingPresetSources.getModel()).remove(taggingPresetSources.getSelectedIndex()); 69 69 gui.requiresRestart = true; 70 70 } 71 71 } 72 72 }); 73 annotationSources.setVisibleRowCount(3);73 taggingPresetSources.setVisibleRowCount(3); 74 74 75 annotationSources.setToolTipText(tr("The sources (url or filename) ofannotationpreset definition files. See http://josm.eigenheimstrasse.de/wiki/AnnotationPresets for help."));76 addAnno.setToolTipText(tr("Add a new annotationpreset source to the list."));75 taggingPresetSources.setToolTipText(tr("The sources (url or filename) of tagging preset definition files. See http://josm.eigenheimstrasse.de/wiki/TaggingPresets for help.")); 76 addAnno.setToolTipText(tr("Add a new tagging preset source to the list.")); 77 77 deleteAnno.setToolTipText(tr("Delete the selected source from the list.")); 78 78 79 gui.map.add(new JLabel(tr(" Annotationpreset sources")), GBC.eol().insets(0,5,0,0));80 gui.map.add(new JScrollPane( annotationSources), GBC.eol().fill(GBC.BOTH));79 gui.map.add(new JLabel(tr("Tagging preset sources")), GBC.eol().insets(0,5,0,0)); 80 gui.map.add(new JScrollPane(taggingPresetSources), GBC.eol().fill(GBC.BOTH)); 81 81 JPanel buttonPanel = new JPanel(new GridBagLayout()); 82 82 gui.map.add(buttonPanel, GBC.eol().fill(GBC.HORIZONTAL)); … … 88 88 89 89 public void ok() { 90 if ( annotationSources.getModel().getSize() > 0) {90 if (taggingPresetSources.getModel().getSize() > 0) { 91 91 StringBuilder sb = new StringBuilder(); 92 for (int i = 0; i < annotationSources.getModel().getSize(); ++i)93 sb.append(";"+ annotationSources.getModel().getElementAt(i));94 Main.pref.put(" annotation.sources", sb.toString().substring(1));92 for (int i = 0; i < taggingPresetSources.getModel().getSize(); ++i) 93 sb.append(";"+taggingPresetSources.getModel().getElementAt(i)); 94 Main.pref.put("taggingpreset.sources", sb.toString().substring(1)); 95 95 } else 96 Main.pref.put(" annotation.sources", null);96 Main.pref.put("taggingpreset.sources", null); 97 97 } 98 98 99 99 /** 100 * Initialize the annotationpresets (load and may display error)100 * Initialize the tagging presets (load and may display error) 101 101 */ 102 102 public static void initialize() { 103 annotationPresets =AnnotationPreset.readFromPreferences();103 taggingPresets = TaggingPreset.readFromPreferences(); 104 104 } 105 105 } -
src/org/openstreetmap/josm/gui/tagging/ForwardActionListener.java
r291 r294 1 package org.openstreetmap.josm.gui. annotation;1 package org.openstreetmap.josm.gui.tagging; 2 2 3 3 import java.awt.event.ActionEvent; … … 12 12 */ 13 13 public final class ForwardActionListener implements ActionListener { 14 public final AnnotationPreset preset;14 public final TaggingPreset preset; 15 15 16 16 private final PropertiesDialog propertiesDialog; 17 17 18 public ForwardActionListener(PropertiesDialog propertiesDialog, AnnotationPreset preset) {18 public ForwardActionListener(PropertiesDialog propertiesDialog, TaggingPreset preset) { 19 19 this.propertiesDialog = propertiesDialog; 20 20 this.preset = preset; … … 22 22 23 23 public void actionPerformed(ActionEvent e) { 24 this.propertiesDialog. annotationPresets.setSelectedIndex(0);24 this.propertiesDialog.taggingPresets.setSelectedIndex(0); 25 25 e.setSource(this); 26 26 preset.actionPerformed(e); -
test/unit/org/openstreetmap/josm/gui/tagging/TaggingPresetTest.java
r291 r294 1 package org.openstreetmap.josm.gui. annotation;1 package org.openstreetmap.josm.gui.tagging; 2 2 3 3 import java.io.ByteArrayInputStream; … … 11 11 import junit.framework.TestCase; 12 12 13 import org.openstreetmap.josm.gui.annotation.AnnotationPreset.Check; 14 import org.openstreetmap.josm.gui.annotation.AnnotationPreset.Combo; 15 import org.openstreetmap.josm.gui.annotation.AnnotationPreset.Key; 16 import org.openstreetmap.josm.gui.annotation.AnnotationPreset.Label; 17 import org.openstreetmap.josm.gui.annotation.AnnotationPreset.Text; 13 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 14 import org.openstreetmap.josm.gui.tagging.TaggingPreset.Check; 15 import org.openstreetmap.josm.gui.tagging.TaggingPreset.Combo; 16 import org.openstreetmap.josm.gui.tagging.TaggingPreset.Key; 17 import org.openstreetmap.josm.gui.tagging.TaggingPreset.Label; 18 import org.openstreetmap.josm.gui.tagging.TaggingPreset.Text; 18 19 19 public class AnnotationPresetTest extends TestCase {20 public class TaggingPresetTest extends TestCase { 20 21 21 public void test AnnotationPresetLoads() throws Exception {22 InputStream in = getClass().getResourceAsStream(" annotation-test.xml");23 List< AnnotationPreset> all =AnnotationPreset.readAll(in);22 public void testTaggingPresetLoads() throws Exception { 23 InputStream in = getClass().getResourceAsStream("taggingpreset-test.xml"); 24 List<TaggingPreset> all = TaggingPreset.readAll(in); 24 25 25 26 assertEquals(1, all.size()); 26 AnnotationPreset a = all.get(0);27 TaggingPreset a = all.get(0); 27 28 assertEquals("Highway", a.getValue(Action.NAME)); 28 29 Field dataField = a.getClass().getDeclaredField("data"); … … 60 61 public void testIconLoadsFromClasspath() throws Exception { 61 62 String xml = "<annotations><item icon='logo'></item></annotations>"; 62 List< AnnotationPreset> all =AnnotationPreset.readAll(new ByteArrayInputStream(xml.getBytes()));63 List<TaggingPreset> all = TaggingPreset.readAll(new ByteArrayInputStream(xml.getBytes())); 63 64 64 65 assertEquals(1, all.size());
Note:
See TracChangeset
for help on using the changeset viewer.