Changeset 30488 in osm for applications/editors/josm
- Timestamp:
- 2014-06-08T18:36:36+02:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/tageditor
- Files:
-
- 6 deleted
- 26 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/LaunchAction.java
r30363 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor; 2 3 -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/TagEditorDialog.java
r29854 r30488 30 30 import org.openstreetmap.josm.data.osm.DataSet; 31 31 import org.openstreetmap.josm.data.osm.OsmPrimitive; 32 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 32 33 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList; 33 34 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager; … … 35 36 import org.openstreetmap.josm.plugins.tageditor.editor.TagEditor; 36 37 import org.openstreetmap.josm.plugins.tageditor.editor.TagEditorModel; 37 import org.openstreetmap.josm.plugins.tageditor.preset.Item;38 38 import org.openstreetmap.josm.plugins.tageditor.preset.ui.IPresetSelectorListener; 39 39 import org.openstreetmap.josm.plugins.tageditor.preset.ui.TabularPresetSelector; … … 43 43 import org.openstreetmap.josm.tools.ImageProvider; 44 44 import org.openstreetmap.josm.tools.WindowGeometry; 45 45 46 /** 46 47 * The dialog for editing name/value-pairs (aka <em>tags</em>) associated with {@link OsmPrimitive}s. … … 155 156 presetSelector.addPresetSelectorListener( 156 157 new IPresetSelectorListener() { 157 public void itemSelected( Itemitem) {158 public void itemSelected(TaggingPreset item) { 158 159 tagEditor.stopEditing(); 159 160 tagEditor.getModel().applyPreset(item); -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/TagEditorPlugin.java
r23189 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor; 2 3 -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/ac/AutoCompletionContext.java
r23189 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.ac; 2 3 -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/ac/AutoCompletionListRenderer.java
r30110 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.ac; 2 3 -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/ac/IAutoCompletionListListener.java
r23189 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.ac; 2 3 -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/PresetItemListCellRenderer.java
r29854 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.editor; 2 3 … … 10 11 import javax.swing.UIManager; 11 12 12 import org.openstreetmap.josm. plugins.tageditor.preset.Item;13 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 13 14 14 public class PresetItemListCellRenderer extends JLabel implements ListCellRenderer {15 public class PresetItemListCellRenderer extends JLabel implements ListCellRenderer<TaggingPreset> { 15 16 //private static final Logger logger = Logger.getLogger(PresetItemListCellRenderer.class.getName()); 16 17 17 public Component getListCellRendererComponent(JList list, Object value,18 public Component getListCellRendererComponent(JList<? extends TaggingPreset> list, TaggingPreset item, 18 19 int index, boolean isSelected, boolean cellHasFocus) { 19 20 20 Item item = (Item)value;21 21 if (item == null) { 22 22 setText(tr("(none)")); … … 31 31 } 32 32 setIcon(item.getIcon()); 33 StringBuilder sb = new StringBuilder(); 34 sb.append(item.getParent().getName()) 35 .append("/") 36 .append(item.getName()); 37 setText(sb.toString()); 33 setText(item.getName()); 38 34 setOpaque(true); 39 35 setFont(UIManager.getFont("Table.font")); -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/PresetManager.java
r29854 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.editor; 2 3 … … 14 15 import javax.swing.JPanel; 15 16 16 import org.openstreetmap.josm. plugins.tageditor.preset.Item;17 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 17 18 18 19 public class PresetManager extends JPanel { … … 20 21 //static private final Logger logger = Logger.getLogger(PresetManager.class.getName()); 21 22 22 private JComboBox presets;23 private JComboBox<TaggingPreset> presets; 23 24 private JButton btnRemove; 24 25 private JButton btnHighlight; … … 30 31 // create the combobox to display the list of applied presets 31 32 // 32 presets = new JComboBox () {33 presets = new JComboBox<TaggingPreset>() { 33 34 @Override 34 35 public Dimension getPreferredSize() { … … 80 81 81 82 protected void removeCurrentPreset() { 82 Item item= (Item)presets.getSelectedItem();83 TaggingPreset item= (TaggingPreset)presets.getSelectedItem(); 83 84 if (item != null && model !=null) { 84 85 model.removeAppliedPreset(item); -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagEditor.java
r23189 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.editor; 2 3 … … 16 17 17 18 import org.openstreetmap.josm.gui.tagging.TagTable; 19 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList; 18 20 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager; 19 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList;20 21 import org.openstreetmap.josm.plugins.tageditor.ac.IAutoCompletionListListener; 21 22 22 23 23 /** … … 103 103 tblTagEditor = new TagTable(tagEditorModel); 104 104 tblTagEditor.setTagCellEditor(new TagSpecificationAwareTagCellEditor()); 105 Ta bleCellRenderer renderer = newTableCellRenderer();105 TagTableCellRenderer renderer = new TagTableCellRenderer(); 106 106 tblTagEditor.getColumnModel().getColumn(0).setCellRenderer(renderer); 107 107 tblTagEditor.getColumnModel().getColumn(1).setCellRenderer(renderer); -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagEditorModel.java
r29854 r30488 15 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 16 16 import org.openstreetmap.josm.gui.tagging.TagModel; 17 import org.openstreetmap.josm. plugins.tageditor.preset.Item;18 import org.openstreetmap.josm.plugins.tageditor.preset. Tag;17 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 18 import org.openstreetmap.josm.plugins.tageditor.preset.AdvancedTag; 19 19 import org.openstreetmap.josm.plugins.tageditor.tagspec.KeyValuePair; 20 20 21 /**22 *23 */24 21 @SuppressWarnings("serial") 25 22 public class TagEditorModel extends org.openstreetmap.josm.gui.tagging.TagEditorModel { 26 23 //static private final Logger logger = Logger.getLogger(TagEditorModel.class.getName()); 27 24 28 private DefaultComboBoxModel appliedPresets = null;25 private DefaultComboBoxModel<TaggingPreset> appliedPresets = null; 29 26 30 27 /** … … 33 30 public TagEditorModel(DefaultListSelectionModel rowSelectionModel, DefaultListSelectionModel colSelectionModel){ 34 31 super(rowSelectionModel, colSelectionModel); 35 appliedPresets = new DefaultComboBoxModel ();32 appliedPresets = new DefaultComboBoxModel<>(); 36 33 } 37 34 … … 47 44 * 48 45 */ 49 public void applyPreset( Itemitem) {46 public void applyPreset(TaggingPreset item) { 50 47 if (item == null) 51 48 throw new IllegalArgumentException("argument 'item' must not be null"); … … 60 57 // apply the tags proposed by the preset 61 58 // 62 for( Tag tag : item.getTags()) {59 for(AdvancedTag tag : AdvancedTag.forTaggingPreset(item)) { 63 60 if (!tag.isOptional()) { 64 61 if (!includesTag(tag.getKey())) { … … 103 100 104 101 105 public DefaultComboBoxModel getAppliedPresetsModel() {102 public DefaultComboBoxModel<TaggingPreset> getAppliedPresetsModel() { 106 103 return appliedPresets; 107 104 } 108 105 109 public void removeAppliedPreset( Itemitem) {106 public void removeAppliedPreset(TaggingPreset item) { 110 107 if (item == null) 111 108 return; 112 for ( Tag tag: item.getTags()) {109 for (AdvancedTag tag: AdvancedTag.forTaggingPreset(item)) { 113 110 if (tag.getValue() != null) { 114 111 // preset tag with explicit key and explicit value. Remove tag model … … 116 113 // 117 114 TagModel tagModel = get(tag.getKey()); 118 if (tagModel != null && tag.getValue().equals(tagModel.getValue())) {115 if (tagModel != null && tag.getValue().equals(tagModel.getValue())) { 119 116 tags.remove(tagModel); 120 117 setDirty(true); -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagSpecificationAwareTagCellEditor.java
r30110 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.editor; 2 3 … … 6 7 import org.openstreetmap.josm.gui.tagging.TagCellEditor; 7 8 import org.openstreetmap.josm.gui.tagging.TagModel; 9 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionItemPriority; 8 10 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionListItem; 9 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionItemPriority;10 11 import org.openstreetmap.josm.plugins.tageditor.ac.AutoCompletionContext; 11 12 import org.openstreetmap.josm.plugins.tageditor.tagspec.TagSpecifications; -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagTableCellRenderer.java
r30454 r30488 12 12 import javax.swing.UIManager; 13 13 import javax.swing.border.EmptyBorder; 14 import javax.swing.table.TableCellRenderer; 14 15 15 16 import org.openstreetmap.josm.gui.tagging.TagModel; 16 import org.openstreetmap.josm.plugins.tageditor.preset.Item; 17 import org.openstreetmap.josm.plugins.tageditor.preset.Tag; 18 17 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 18 import org.openstreetmap.josm.plugins.tageditor.preset.AdvancedTag; 19 19 20 20 /** 21 21 * This is the table cell renderer for cells for the table of tags 22 22 * in the tag editor dialog. 23 *24 *25 23 */ 26 public class Ta bleCellRenderer extends JLabel implements javax.swing.table.TableCellRenderer {24 public class TagTableCellRenderer extends JLabel implements TableCellRenderer { 27 25 28 //private static Logger logger = Logger.getLogger(Ta bleCellRenderer.class.getName());26 //private static Logger logger = Logger.getLogger(TagTableCellRenderer.class.getName()); 29 27 public static final Color BG_COLOR_HIGHLIGHTED = new Color(255,255,204); 30 28 … … 32 30 private Font fontItalic = null; 33 31 34 public Ta bleCellRenderer() {32 public TagTableCellRenderer() { 35 33 fontStandard = getFont(); 36 34 fontItalic = fontStandard.deriveFont(Font.ITALIC); … … 90 88 // no current preset selected? 91 89 // 92 Item item = (Item)model.getAppliedPresetsModel().getSelectedItem();90 TaggingPreset item = (TaggingPreset)model.getAppliedPresetsModel().getSelectedItem(); 93 91 if (item == null) { 94 92 return false; 95 93 } 96 94 97 for( Tag tag: item.getTags()) {95 for(AdvancedTag tag: AdvancedTag.forTaggingPreset(item)) { 98 96 if (tag.getValue() == null) { 99 97 if (tagModel.getName().equals(tag.getKey())) { -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/AdvancedTag.java
r30454 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.preset; 2 3 3 public class Tag { 4 private String key; 5 private String value; 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.trc; 6 7 import java.util.ArrayList; 8 import java.util.Collection; 9 10 import org.openstreetmap.josm.data.osm.Tag; 11 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 12 import org.openstreetmap.josm.gui.tagging.TaggingPresetItem; 13 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems.KeyedItem; 14 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems.Optional; 15 16 public class AdvancedTag extends Tag { 6 17 private String displayName; 7 18 private boolean optional = false; 8 9 public Tag() {19 20 public AdvancedTag() { 10 21 } 11 22 12 public String getKey() {13 return key;23 public AdvancedTag(String key, String value) { 24 super(key, value); 14 25 } 15 26 16 public void setKey(String key) {17 this.key = key;27 public AdvancedTag(String key) { 28 super(key); 18 29 } 19 30 20 public String getValue() { 21 return value; 22 } 23 24 public void setValue(String value) { 25 this.value = value; 31 public AdvancedTag(Tag tag) { 32 super(tag); 26 33 } 27 34 … … 41 48 this.optional = optional; 42 49 } 50 51 public static Collection<AdvancedTag> forTaggingPreset(TaggingPreset preset) { 52 Collection<AdvancedTag> result = new ArrayList<>(); 53 boolean isOptional = false; 54 for (TaggingPresetItem item : preset.data) { 55 if (item instanceof KeyedItem) { 56 KeyedItem ki = (KeyedItem)item; 57 for (String value : ki.getValues()) { 58 AdvancedTag tag = new AdvancedTag(ki.key, value); 59 tag.setOptional(isOptional); 60 if (ki.text != null) { 61 if (ki.text_context != null) { 62 tag.setDisplayName(trc(ki.text_context, ki.text)); 63 } else { 64 tag.setDisplayName(tr(ki.text)); 65 } 66 } 67 result.add(tag); 68 } 69 } else if (item instanceof Optional) { 70 isOptional = true; 71 } 72 // TODO optional stuff is not perfect: all items found after an optional item will be considered as optional 73 // even if they are outside the <optional> element. 74 // We can't easily access this information. The plugin previously reimplemented a lot of JOSM code to determine that. 75 // This duplicated code has been stripped off. It's not really important as optional items are almost always 76 // located at the end of an item. 77 } 78 return result; 79 } 43 80 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/ui/IPresetSelectorListener.java
r23189 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.preset.ui; 2 3 3 import org.openstreetmap.josm. plugins.tageditor.preset.Item;4 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 4 5 5 6 public interface IPresetSelectorListener { 6 7 7 public void itemSelected( Itemitem);8 public void itemSelected(TaggingPreset item); 8 9 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/ui/NameIconCellRenderer.java
r29854 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.preset.ui; 2 3 … … 9 10 import javax.swing.table.TableCellRenderer; 10 11 11 import org.openstreetmap.josm.plugins.tageditor.preset.INameIconProvider; 12 13 12 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 14 13 15 14 public class NameIconCellRenderer extends JLabel implements TableCellRenderer { … … 17 16 //private static Logger logger = Logger.getLogger(NameIconCellRenderer.class.getName()); 18 17 public static final Color BG_COLOR_SELECTED = new Color(143,170,255); 19 20 18 21 19 protected void init() { … … 36 34 setBackground(Color.WHITE); 37 35 } 38 INameIconProvider provider = (INameIconProvider) value; 39 setText(provider.getName()); 40 setIcon(provider.getIcon()); 36 TaggingPreset provider = (TaggingPreset) value; 37 if (provider != null) { 38 setText(provider.getName()); 39 setIcon(provider.getIcon()); 40 } 41 41 return this; 42 42 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/ui/PresetsTable.java
r23189 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.preset.ui; 2 3 … … 5 6 import javax.swing.table.TableColumnModel; 6 7 import javax.swing.table.TableModel; 7 8 8 9 9 public class PresetsTable extends JTable { … … 17 17 setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 18 18 setRowHeight(18); // icon height (=16) + minimal border 19 20 19 } 21 20 … … 44 43 } 45 44 } 46 47 45 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/ui/PresetsTableColumnModel.java
r23189 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.preset.ui; 2 3 … … 6 7 import static org.openstreetmap.josm.tools.I18n.tr; 7 8 8 public class PresetsTableColumnModel extends DefaultTableColumnModel 9 public class PresetsTableColumnModel extends DefaultTableColumnModel { 9 10 10 11 protected void createColumns() { … … 26 27 col.setCellRenderer(renderer); 27 28 addColumn(col); 28 29 29 } 30 30 … … 32 32 createColumns(); 33 33 } 34 35 34 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/ui/PresetsTableModel.java
r29854 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.preset.ui; 2 3 3 4 import java.util.ArrayList; 5 import java.util.Collection; 4 6 5 7 import javax.swing.event.TableModelListener; 6 8 import javax.swing.table.AbstractTableModel; 7 9 8 import org.openstreetmap.josm.plugins.tageditor.preset.Group; 9 import org.openstreetmap.josm.plugins.tageditor.preset.Item; 10 import org.openstreetmap.josm.plugins.tageditor.preset.Presets; 11 10 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 12 11 13 12 public class PresetsTableModel extends AbstractTableModel { … … 16 15 17 16 private final ArrayList<TableModelListener> listeners = new ArrayList<TableModelListener>(); 18 private final ArrayList<Item> items = new ArrayList<Item>(); 19 private final ArrayList<Item> visibleItems = new ArrayList<Item>(); 20 private Presets presets = null; 17 private final ArrayList<TaggingPreset> items = new ArrayList<TaggingPreset>(); 18 private final ArrayList<TaggingPreset> visibleItems = new ArrayList<TaggingPreset>(); 21 19 22 protected void initModelFromPresets(Presets presets) { 23 for(Group group: presets.getGroups()) { 24 for(Item item: group.getItems()) { 25 items.add(item); 26 visibleItems.add(item); 27 } 28 } 20 protected void initModelFromPresets(Collection<TaggingPreset> presets) { 21 items.clear(); 22 visibleItems.clear(); 23 items.addAll(presets); 24 visibleItems.addAll(presets); 29 25 } 30 26 … … 32 28 } 33 29 34 public PresetsTableModel(Presets presets) {35 setPresets(presets);30 public Collection<TaggingPreset> getPresets() { 31 return items; 36 32 } 37 33 38 39 public Presets getPresets() { 40 return presets; 41 } 42 43 public void setPresets(Presets presets) { 44 this.presets = presets; 34 public void setPresets(Collection<TaggingPreset> presets) { 45 35 initModelFromPresets(presets); 46 36 fireTableDataChanged(); … … 72 62 73 63 public Object getValueAt(int rowIndex, int columnIndex) { 74 Itemitem = visibleItems.get(rowIndex);64 TaggingPreset item = visibleItems.get(rowIndex); 75 65 switch(columnIndex) { 76 case 0: return item.g etParent();66 case 0: return item.group; 77 67 case 1: return item; 78 68 default: return "unknown"; 79 80 69 } 81 70 } … … 100 89 } 101 90 102 public ItemgetVisibleItem(int idx) {91 public TaggingPreset getVisibleItem(int idx) { 103 92 if (idx < 0 || idx >= this.visibleItems.size()) 104 93 throw new IndexOutOfBoundsException("index out of bounds. idx=" + idx); … … 110 99 if (filter == null || filter.trim().equals("")) { 111 100 visibleItems.clear(); 112 for( Itemitem: items) {101 for(TaggingPreset item: items) { 113 102 visibleItems.add(item); 114 103 } … … 116 105 visibleItems.clear(); 117 106 filter = filter.toLowerCase(); 118 for( Itemitem: items) {119 if ( (item.getName() != null && item.getName().toLowerCase().trim().startsWith(filter))120 || (item.g etParent().getName() != null && item.getParent().getName().toLowerCase().trim().startsWith(filter))) {107 for(TaggingPreset item: items) { 108 if ((item.getName() != null && item.getName().toLowerCase().trim().contains(filter)) 109 || (item.group != null && item.group.getName() != null && item.group.getName().toLowerCase().trim().contains(filter))) { 121 110 visibleItems.add(item); 122 111 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/ui/TabularPresetSelector.java
r23189 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.preset.ui; 2 3 … … 15 16 import java.awt.event.MouseEvent; 16 17 import java.util.ArrayList; 18 import java.util.Collection; 17 19 18 20 import javax.swing.AbstractAction; … … 31 33 import javax.swing.event.ListSelectionListener; 32 34 33 import org.openstreetmap.josm.plugins.tageditor.preset.Item; 34 import org.openstreetmap.josm.plugins.tageditor.preset.Presets; 35 35 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 36 import org.openstreetmap.josm.gui.tagging.TaggingPresets; 36 37 37 38 public class TabularPresetSelector extends JPanel { … … 42 43 private JScrollPane scrollPane; 43 44 private JButton btnApply; 44 45 45 46 46 protected JPanel buildFilterPanel() { … … 51 51 pnl.add(lbl); 52 52 pnl.add(tfFilter,BorderLayout.CENTER); 53 JButton btn = new JButton(tr("Filter")); 54 pnl.add(btn); 55 btn.addActionListener( 56 new ActionListener() { 57 public void actionPerformed(ActionEvent e) { 58 filter(tfFilter.getText()); 59 } 60 61 } 62 ); 63 btn = new JButton(tr("Clear")); 53 JButton btn = new JButton(tr("Clear")); 64 54 pnl.add(btn); 65 55 btn.addActionListener( … … 74 64 } 75 65 76 77 78 66 protected JScrollPane buildPresetGrid() { 79 67 … … 110 98 int rowNum = presetsTable.getSelectedRow(); 111 99 if (rowNum >= 0) { 112 Item item = getModel().getVisibleItem(rowNum); 113 fireItemSelected(item); 100 fireItemSelected(getModel().getVisibleItem(rowNum)); 114 101 } 115 102 } … … 136 123 int row = presetsTable.getSelectedRow(); 137 124 if (row >=0) { 138 Item item = getModel().getVisibleItem(row); 139 fireItemSelected(item); 125 fireItemSelected(getModel().getVisibleItem(row)); 140 126 } 141 127 } … … 151 137 add(buildControlButtonPanel(), BorderLayout.SOUTH); 152 138 153 // wire the text field for filter expressions to the prests 154 // table 139 // wire the text field for filter expressions to the preset table 155 140 // 156 141 tfFilter.getDocument().addDocumentListener( … … 192 177 ); 193 178 194 195 179 // load the set of presets and bind them to the preset table 196 180 // 197 Presets.initPresets(); 198 bindTo(Presets.getPresets()); 181 bindTo(TaggingPresets.getTaggingPresets()); 199 182 presetsTable.getSelectionModel().clearSelection(); 200 183 btnApply.setEnabled(false); 201 202 } 203 204 public void bindTo(Presets presets) { 184 } 185 186 public void bindTo(Collection<TaggingPreset> presets) { 205 187 PresetsTableModel model = (PresetsTableModel)presetsTable.getModel(); 206 188 model.setPresets(presets); … … 227 209 } 228 210 229 protected void fireItemSelected( Itemitem) {211 protected void fireItemSelected(TaggingPreset item) { 230 212 synchronized(this.listeners) { 231 213 for(IPresetSelectorListener listener: listeners) { … … 234 216 } 235 217 } 236 237 238 239 218 240 219 private class DoubleClickAdapter extends MouseAdapter { … … 243 222 if (e.getClickCount() == 2) { 244 223 int rowNum = presetsTable.rowAtPoint(e.getPoint()); 245 Item item = getModel().getVisibleItem(rowNum); 246 fireItemSelected(item); 247 } 248 } 249 } 250 224 fireItemSelected(getModel().getVisibleItem(rowNum)); 225 } 226 } 227 } 251 228 252 229 public void filter(String filter) { … … 271 248 } 272 249 273 274 250 protected PresetsTableModel getModel() { 275 251 return (PresetsTableModel)presetsTable.getModel(); … … 279 255 getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put((KeyStroke)a.getValue(AbstractAction.ACCELERATOR_KEY), a.getValue(AbstractAction.NAME)); 280 256 getActionMap().put(a.getValue(AbstractAction.NAME), a); 281 282 } 283 257 } 284 258 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/KeyValuePair.java
r23189 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.tagspec; 2 3 -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/LabelSpecification.java
r30454 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.tagspec; 2 3 3 4 import org.openstreetmap.josm.plugins.tageditor.ac.AutoCompletionContext; 4 5 5 public class Lab leSpecification {6 public class LabelSpecification { 6 7 7 8 /** the key of the tag */ … … 16 17 * constructor 17 18 */ 18 public Lab leSpecification() {19 public LabelSpecification() { 19 20 } 20 21 … … 66 67 this.applicableToRelation = applicableToRelation; 67 68 } 68 69 70 71 72 69 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/TagSpecification.java
r23189 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.tagspec; 2 3 … … 31 32 private boolean applicableToRelation = true; 32 33 33 private ArrayList<Lab leSpecification> lables = null;34 private ArrayList<LabelSpecification> lables = null; 34 35 35 36 … … 38 39 */ 39 40 public TagSpecification() { 40 lables = new ArrayList<Lab leSpecification>();41 lables = new ArrayList<LabelSpecification>(); 41 42 } 42 43 … … 58 59 * labels are defined 59 60 */ 60 public List<Lab leSpecification> getLables() {61 public List<LabelSpecification> getLables() { 61 62 return lables; 62 63 } … … 68 69 * @exception IllegalArgumentException thrown, if lables is null 69 70 */ 70 public void setLables(List<Lab leSpecification> lables) throws IllegalArgumentException {71 public void setLables(List<LabelSpecification> lables) throws IllegalArgumentException { 71 72 if (lables == null) 72 73 throw new IllegalArgumentException("argument 'lables' must not be null"); 73 74 this.lables.clear(); 74 for (Lab leSpecification l : lables) {75 for (LabelSpecification l : lables) { 75 76 this.lables.add(l); 76 77 } … … 84 85 * @exception IllegalArgumentException thrown, if lable is null 85 86 */ 86 public void addLable(Lab leSpecification lable) throws IllegalArgumentException {87 public void addLable(LabelSpecification lable) throws IllegalArgumentException { 87 88 if (lable == null) 88 89 throw new IllegalArgumentException("argument 'lable' must not be null"); -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/TagSpecifications.java
r30110 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.tagspec; 2 3 … … 23 24 import org.xml.sax.helpers.XMLReaderFactory; 24 25 25 26 26 /** 27 27 * This class manages a list of {@link TagSpecification}s. … … 110 110 parser.setErrorHandler(handler); 111 111 parser.setEntityResolver(new ResourceEntityResolver()); 112 parser.setFeature( 112 parser.setFeature("http://xml.org/sax/features/validation", true); 113 113 parser.setFeature("http://xml.org/sax/features/namespaces", true); 114 114 parser.setFeature("http://xml.org/sax/features/namespace-prefixes", true); … … 116 116 117 117 } catch (Exception e) { 118 logger.log(Level.SEVERE, "failed to load tag specificatoin file", e); 118 logger.log(Level.SEVERE, "failed to load tag specification file", e); 119 e.getCause().printStackTrace(); 119 120 throw e; 120 121 } finally { … … 141 142 for (TagSpecification spec : tagSpecifications) { 142 143 if (spec.getKey().equals(forKey)) { 143 List<Lab leSpecification> lables = spec.getLables();144 for (Lab leSpecification l : lables) {144 List<LabelSpecification> lables = spec.getLables(); 145 for (LabelSpecification l : lables) { 145 146 if (!l.isApplicable(context)) { 146 147 continue; … … 166 167 167 168 for (TagSpecification s : tagSpecifications) { 168 for (Lab leSpecification l : s.getLables()) {169 for (LabelSpecification l : s.getLables()) { 169 170 entries.add(new KeyValuePair(s.getKey(), l.getValue())); 170 171 } … … 188 189 private TagSpecification currentTagSpecification = null; 189 190 190 191 191 @Override 192 192 public void endDocument() throws SAXException { … … 194 194 } 195 195 196 197 198 196 @Override 199 197 public void error(SAXParseException e) throws SAXException { … … 210 208 logger.log(Level.FINE,"START"); 211 209 } 212 213 210 214 211 /** … … 293 290 */ 294 291 protected void startElementLabel(Attributes atts) throws SAXException { 295 Lab leSpecification ls = new LableSpecification();292 LabelSpecification ls = new LabelSpecification(); 296 293 for (int i=0; i< atts.getLength(); i++) { 297 294 String name = atts.getQName(i); … … 349 346 @Override 350 347 public void warning(SAXParseException e) throws SAXException { 351 // TODO Auto-generated method stub352 348 logger.log(Level.WARNING, "XML parsing warning", e); 353 349 } 354 350 } 355 351 356 /**357 *358 *359 */360 352 class ResourceEntityResolver implements EntityResolver { 361 353 362 public InputSource resolveEntity(String publicId, String systemId) 363 throws SAXException, IOException { 364 if (systemId != null && systemId.endsWith(DTD)) 365 return new InputSource( 366 TagSpecifications.class.getResourceAsStream(DTD) 367 ); 368 else 354 public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { 355 if (systemId != null && systemId.endsWith(DTD)) { 356 InputStream stream = TagSpecifications.class.getResourceAsStream("/resources/"+DTD); 357 if (stream == null) { 358 logger.log(Level.WARNING, "Unable to find DTD: "+DTD); 359 } 360 return stream != null ? new InputSource(stream) : null; 361 } else { 369 362 throw new SAXException("couldn't load external DTD '" + systemId + "'"); 370 }371 363 } 364 } 372 365 } 373 366 -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/ITagSelectorListener.java
r23189 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.tagspec.ui; 2 3 -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/KeyValueCellRenderer.java
r29854 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.tagspec.ui; 2 3 -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/TabularTagSelector.java
r23189 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.tagspec.ui; 2 3 … … 46 47 pnl.add(lbl); 47 48 pnl.add(tfFilter,BorderLayout.CENTER); 48 JButton btn = new JButton(tr("Filter")); 49 pnl.add(btn); 50 btn.addActionListener( 51 new ActionListener() { 52 public void actionPerformed(ActionEvent e) { 53 filter(tfFilter.getText()); 54 } 55 56 } 57 ); 58 btn = new JButton(tr("Clear")); 49 JButton btn = new JButton(tr("Clear")); 59 50 pnl.add(btn); 60 51 btn.addActionListener( -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/TagsTable.java
r23189 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.tagspec.ui; 2 3 -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/TagsTableColumnModel.java
r23189 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.tagspec.ui; 2 3 -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/TagsTableModel.java
r23189 r30488 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.tageditor.tagspec.ui; 3 2 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5
Note:
See TracChangeset
for help on using the changeset viewer.