Ignore:
Timestamp:
2014-06-08T18:36:36+02:00 (10 years ago)
Author:
donvip
Message:

[josm_tageditor] see #josm10110 - fix many problems with plugin

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.
    12package org.openstreetmap.josm.plugins.tageditor;
    23
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/TagEditorDialog.java

    r29854 r30488  
    3030import org.openstreetmap.josm.data.osm.DataSet;
    3131import org.openstreetmap.josm.data.osm.OsmPrimitive;
     32import org.openstreetmap.josm.gui.tagging.TaggingPreset;
    3233import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList;
    3334import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager;
     
    3536import org.openstreetmap.josm.plugins.tageditor.editor.TagEditor;
    3637import org.openstreetmap.josm.plugins.tageditor.editor.TagEditorModel;
    37 import org.openstreetmap.josm.plugins.tageditor.preset.Item;
    3838import org.openstreetmap.josm.plugins.tageditor.preset.ui.IPresetSelectorListener;
    3939import org.openstreetmap.josm.plugins.tageditor.preset.ui.TabularPresetSelector;
     
    4343import org.openstreetmap.josm.tools.ImageProvider;
    4444import org.openstreetmap.josm.tools.WindowGeometry;
     45
    4546/**
    4647 * The dialog for editing name/value-pairs (aka <em>tags</em>) associated with {@link OsmPrimitive}s.
     
    155156        presetSelector.addPresetSelectorListener(
    156157                new IPresetSelectorListener() {
    157                     public void itemSelected(Item item) {
     158                    public void itemSelected(TaggingPreset item) {
    158159                        tagEditor.stopEditing();
    159160                        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.
    12package org.openstreetmap.josm.plugins.tageditor;
    23
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/ac/AutoCompletionContext.java

    r23189 r30488  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.tageditor.ac;
    23
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/ac/AutoCompletionListRenderer.java

    r30110 r30488  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.tageditor.ac;
    23
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/ac/IAutoCompletionListListener.java

    r23189 r30488  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.tageditor.ac;
    23
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/PresetItemListCellRenderer.java

    r29854 r30488  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.tageditor.editor;
    23
     
    1011import javax.swing.UIManager;
    1112
    12 import org.openstreetmap.josm.plugins.tageditor.preset.Item;
     13import org.openstreetmap.josm.gui.tagging.TaggingPreset;
    1314
    14 public class PresetItemListCellRenderer extends JLabel implements ListCellRenderer {
     15public class PresetItemListCellRenderer extends JLabel implements ListCellRenderer<TaggingPreset> {
    1516    //private static final Logger logger = Logger.getLogger(PresetItemListCellRenderer.class.getName());
    1617
    17     public Component getListCellRendererComponent(JList list, Object value,
     18    public Component getListCellRendererComponent(JList<? extends TaggingPreset> list, TaggingPreset item,
    1819            int index, boolean isSelected, boolean cellHasFocus) {
    1920
    20         Item item = (Item)value;
    2121        if (item == null) {
    2222            setText(tr("(none)"));
     
    3131            }
    3232            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());
    3834            setOpaque(true);
    3935            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.
    12package org.openstreetmap.josm.plugins.tageditor.editor;
    23
     
    1415import javax.swing.JPanel;
    1516
    16 import org.openstreetmap.josm.plugins.tageditor.preset.Item;
     17import org.openstreetmap.josm.gui.tagging.TaggingPreset;
    1718
    1819public class PresetManager extends JPanel {
     
    2021    //static private final Logger logger = Logger.getLogger(PresetManager.class.getName());
    2122
    22     private JComboBox presets;
     23    private JComboBox<TaggingPreset> presets;
    2324    private JButton btnRemove;
    2425    private JButton btnHighlight;
     
    3031        // create the combobox to display the list of applied presets
    3132        //
    32         presets = new JComboBox() {
     33        presets = new JComboBox<TaggingPreset>() {
    3334            @Override
    3435            public Dimension getPreferredSize() {
     
    8081
    8182    protected void removeCurrentPreset() {
    82         Item item= (Item)presets.getSelectedItem();
     83        TaggingPreset item= (TaggingPreset)presets.getSelectedItem();
    8384        if (item != null && model !=null) {
    8485            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.
    12package org.openstreetmap.josm.plugins.tageditor.editor;
    23
     
    1617
    1718import org.openstreetmap.josm.gui.tagging.TagTable;
     19import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList;
    1820import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager;
    19 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList;
    2021import org.openstreetmap.josm.plugins.tageditor.ac.IAutoCompletionListListener;
    21 
    2222
    2323/**
     
    103103        tblTagEditor = new TagTable(tagEditorModel);
    104104        tblTagEditor.setTagCellEditor(new TagSpecificationAwareTagCellEditor());
    105         TableCellRenderer renderer = new TableCellRenderer();
     105        TagTableCellRenderer renderer = new TagTableCellRenderer();
    106106        tblTagEditor.getColumnModel().getColumn(0).setCellRenderer(renderer);
    107107        tblTagEditor.getColumnModel().getColumn(1).setCellRenderer(renderer);
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagEditorModel.java

    r29854 r30488  
    1515import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1616import org.openstreetmap.josm.gui.tagging.TagModel;
    17 import org.openstreetmap.josm.plugins.tageditor.preset.Item;
    18 import org.openstreetmap.josm.plugins.tageditor.preset.Tag;
     17import org.openstreetmap.josm.gui.tagging.TaggingPreset;
     18import org.openstreetmap.josm.plugins.tageditor.preset.AdvancedTag;
    1919import org.openstreetmap.josm.plugins.tageditor.tagspec.KeyValuePair;
    2020
    21 /**
    22  *
    23  */
    2421@SuppressWarnings("serial")
    2522public class TagEditorModel extends org.openstreetmap.josm.gui.tagging.TagEditorModel  {
    2623    //static private final Logger logger = Logger.getLogger(TagEditorModel.class.getName());
    2724   
    28     private DefaultComboBoxModel appliedPresets = null;
     25    private DefaultComboBoxModel<TaggingPreset> appliedPresets = null;
    2926
    3027    /**
     
    3330    public TagEditorModel(DefaultListSelectionModel rowSelectionModel, DefaultListSelectionModel colSelectionModel){
    3431        super(rowSelectionModel, colSelectionModel);
    35         appliedPresets = new DefaultComboBoxModel();
     32        appliedPresets = new DefaultComboBoxModel<>();
    3633    }
    3734
     
    4744     *
    4845     */
    49     public void applyPreset(Item item) {
     46    public void applyPreset(TaggingPreset item) {
    5047        if (item == null)
    5148            throw new IllegalArgumentException("argument 'item' must not be null");
     
    6057        // apply the tags proposed by the preset
    6158        //
    62         for(Tag tag : item.getTags()) {
     59        for(AdvancedTag tag : AdvancedTag.forTaggingPreset(item)) {
    6360            if (!tag.isOptional()) {
    6461                if (!includesTag(tag.getKey())) {
     
    103100
    104101
    105     public DefaultComboBoxModel getAppliedPresetsModel() {
     102    public DefaultComboBoxModel<TaggingPreset> getAppliedPresetsModel() {
    106103        return appliedPresets;
    107104    }
    108105
    109     public void removeAppliedPreset(Item item) {
     106    public void removeAppliedPreset(TaggingPreset item) {
    110107        if (item == null)
    111108            return;
    112         for (Tag tag: item.getTags()) {
     109        for (AdvancedTag tag: AdvancedTag.forTaggingPreset(item)) {
    113110            if (tag.getValue() != null) {
    114111                // preset tag with explicit key and explicit value. Remove tag model
     
    116113                //
    117114                TagModel tagModel = get(tag.getKey());
    118                 if (tagModel !=null && tag.getValue().equals(tagModel.getValue())) {
     115                if (tagModel != null && tag.getValue().equals(tagModel.getValue())) {
    119116                    tags.remove(tagModel);
    120117                    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.
    12package org.openstreetmap.josm.plugins.tageditor.editor;
    23
     
    67import org.openstreetmap.josm.gui.tagging.TagCellEditor;
    78import org.openstreetmap.josm.gui.tagging.TagModel;
     9import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionItemPriority;
    810import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionListItem;
    9 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionItemPriority;
    1011import org.openstreetmap.josm.plugins.tageditor.ac.AutoCompletionContext;
    1112import org.openstreetmap.josm.plugins.tageditor.tagspec.TagSpecifications;
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagTableCellRenderer.java

    r30454 r30488  
    1212import javax.swing.UIManager;
    1313import javax.swing.border.EmptyBorder;
     14import javax.swing.table.TableCellRenderer;
    1415
    1516import 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 
     17import org.openstreetmap.josm.gui.tagging.TaggingPreset;
     18import org.openstreetmap.josm.plugins.tageditor.preset.AdvancedTag;
    1919
    2020/**
    2121 * This is the table cell renderer for cells for the table of tags
    2222 * in the tag editor dialog.
    23  *
    24  *
    2523 */
    26 public class TableCellRenderer extends JLabel implements javax.swing.table.TableCellRenderer  {
     24public class TagTableCellRenderer extends JLabel implements TableCellRenderer  {
    2725   
    28     //private static Logger logger = Logger.getLogger(TableCellRenderer.class.getName());
     26    //private static Logger logger = Logger.getLogger(TagTableCellRenderer.class.getName());
    2927    public static final Color BG_COLOR_HIGHLIGHTED = new Color(255,255,204);
    3028       
     
    3230    private Font fontItalic = null;
    3331   
    34     public TableCellRenderer() {
     32    public TagTableCellRenderer() {
    3533        fontStandard = getFont();
    3634        fontItalic = fontStandard.deriveFont(Font.ITALIC);
     
    9088        // no current preset selected?
    9189        //
    92         Item item = (Item)model.getAppliedPresetsModel().getSelectedItem();
     90        TaggingPreset item = (TaggingPreset)model.getAppliedPresetsModel().getSelectedItem();
    9391        if (item == null) {
    9492            return false;
    9593        }
    9694       
    97         for(Tag tag: item.getTags()) {
     95        for(AdvancedTag tag: AdvancedTag.forTaggingPreset(item)) {
    9896            if (tag.getValue() == null) {
    9997                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.
    12package org.openstreetmap.josm.plugins.tageditor.preset;
    23
    3 public class Tag {
    4     private String key;
    5     private String value;
     4import static org.openstreetmap.josm.tools.I18n.tr;
     5import static org.openstreetmap.josm.tools.I18n.trc;
     6
     7import java.util.ArrayList;
     8import java.util.Collection;
     9
     10import org.openstreetmap.josm.data.osm.Tag;
     11import org.openstreetmap.josm.gui.tagging.TaggingPreset;
     12import org.openstreetmap.josm.gui.tagging.TaggingPresetItem;
     13import org.openstreetmap.josm.gui.tagging.TaggingPresetItems.KeyedItem;
     14import org.openstreetmap.josm.gui.tagging.TaggingPresetItems.Optional;
     15
     16public class AdvancedTag extends Tag {
    617    private String displayName;
    718    private boolean optional = false;
    8    
    9     public Tag() {     
     19
     20    public AdvancedTag() {
    1021    }
    1122
    12     public String getKey() {
    13         return key;
     23    public AdvancedTag(String key, String value) {
     24        super(key, value);
    1425    }
    1526
    16     public void setKey(String key) {
    17         this.key = key;
     27    public AdvancedTag(String key) {
     28        super(key);
    1829    }
    1930
    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);
    2633    }
    2734
     
    4148        this.optional = optional;
    4249    }
     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    }
    4380}
  • 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.
    12package org.openstreetmap.josm.plugins.tageditor.preset.ui;
    23
    3 import org.openstreetmap.josm.plugins.tageditor.preset.Item;
     4import org.openstreetmap.josm.gui.tagging.TaggingPreset;
    45
    56public interface IPresetSelectorListener {
    67
    7     public void itemSelected(Item item);
     8    public void itemSelected(TaggingPreset item);
    89}
  • 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.
    12package org.openstreetmap.josm.plugins.tageditor.preset.ui;
    23
     
    910import javax.swing.table.TableCellRenderer;
    1011
    11 import org.openstreetmap.josm.plugins.tageditor.preset.INameIconProvider;
    12 
    13 
     12import org.openstreetmap.josm.gui.tagging.TaggingPreset;
    1413
    1514public class NameIconCellRenderer extends JLabel implements TableCellRenderer {
     
    1716    //private static Logger logger = Logger.getLogger(NameIconCellRenderer.class.getName());
    1817    public static final Color BG_COLOR_SELECTED = new Color(143,170,255);
    19 
    2018
    2119    protected void init() {
     
    3634            setBackground(Color.WHITE);
    3735        }
    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        }
    4141        return this;
    4242    }
  • 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.
    12package org.openstreetmap.josm.plugins.tageditor.preset.ui;
    23
     
    56import javax.swing.table.TableColumnModel;
    67import javax.swing.table.TableModel;
    7 
    88
    99public class PresetsTable extends JTable {
     
    1717        setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    1818        setRowHeight(18); // icon height (=16) + minimal border
    19        
    2019    }
    2120   
     
    4443        }
    4544    }
    46 
    4745}
  • 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.
    12package org.openstreetmap.josm.plugins.tageditor.preset.ui;
    23
     
    67import static org.openstreetmap.josm.tools.I18n.tr;
    78
    8 public class PresetsTableColumnModel extends DefaultTableColumnModel  {
     9public class PresetsTableColumnModel extends DefaultTableColumnModel {
    910
    1011    protected void createColumns() {
     
    2627        col.setCellRenderer(renderer);
    2728        addColumn(col);
    28 
    2929    }
    3030
     
    3232        createColumns();
    3333    }
    34    
    3534}
  • 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.
    12package org.openstreetmap.josm.plugins.tageditor.preset.ui;
    23
    34import java.util.ArrayList;
     5import java.util.Collection;
    46
    57import javax.swing.event.TableModelListener;
    68import javax.swing.table.AbstractTableModel;
    79
    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 
     10import org.openstreetmap.josm.gui.tagging.TaggingPreset;
    1211
    1312public class PresetsTableModel extends AbstractTableModel  {
     
    1615
    1716    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>();
    2119
    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);
    2925    }
    3026
     
    3228    }
    3329
    34     public PresetsTableModel(Presets presets) {
    35         setPresets(presets);
     30    public Collection<TaggingPreset> getPresets() {
     31        return items;
    3632    }
    3733
    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) {
    4535        initModelFromPresets(presets);
    4636        fireTableDataChanged();
     
    7262
    7363    public Object getValueAt(int rowIndex, int columnIndex) {
    74         Item item = visibleItems.get(rowIndex);
     64        TaggingPreset item = visibleItems.get(rowIndex);
    7565        switch(columnIndex) {
    76         case 0: return item.getParent();
     66        case 0: return item.group;
    7767        case 1: return item;
    7868        default: return "unknown";
    79 
    8069        }
    8170    }
     
    10089    }
    10190
    102     public Item getVisibleItem(int idx) {
     91    public TaggingPreset getVisibleItem(int idx) {
    10392        if (idx < 0 || idx >= this.visibleItems.size())
    10493            throw new IndexOutOfBoundsException("index out of bounds. idx=" + idx);
     
    11099            if (filter == null || filter.trim().equals("")) {
    111100                visibleItems.clear();
    112                 for(Item item: items) {
     101                for(TaggingPreset item: items) {
    113102                    visibleItems.add(item);
    114103                }
     
    116105                visibleItems.clear();
    117106                filter = filter.toLowerCase();
    118                 for(Item item: items) {
    119                     if (    (item.getName() != null && item.getName().toLowerCase().trim().startsWith(filter))
    120                             || (item.getParent().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))) {
    121110                        visibleItems.add(item);
    122111                    }
  • 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.
    12package org.openstreetmap.josm.plugins.tageditor.preset.ui;
    23
     
    1516import java.awt.event.MouseEvent;
    1617import java.util.ArrayList;
     18import java.util.Collection;
    1719
    1820import javax.swing.AbstractAction;
     
    3133import javax.swing.event.ListSelectionListener;
    3234
    33 import org.openstreetmap.josm.plugins.tageditor.preset.Item;
    34 import org.openstreetmap.josm.plugins.tageditor.preset.Presets;
    35 
     35import org.openstreetmap.josm.gui.tagging.TaggingPreset;
     36import org.openstreetmap.josm.gui.tagging.TaggingPresets;
    3637
    3738public class TabularPresetSelector extends JPanel {
     
    4243    private JScrollPane scrollPane;
    4344    private JButton btnApply;
    44 
    4545
    4646    protected JPanel buildFilterPanel() {
     
    5151        pnl.add(lbl);
    5252        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"));
    6454        pnl.add(btn);
    6555        btn.addActionListener(
     
    7464    }
    7565
    76 
    77 
    7866    protected JScrollPane buildPresetGrid() {
    7967
     
    11098                int rowNum = presetsTable.getSelectedRow();
    11199                if (rowNum >= 0) {
    112                     Item item = getModel().getVisibleItem(rowNum);
    113                     fireItemSelected(item);
     100                    fireItemSelected(getModel().getVisibleItem(rowNum));
    114101                }
    115102            }
     
    136123                        int row = presetsTable.getSelectedRow();
    137124                        if (row >=0) {
    138                             Item item = getModel().getVisibleItem(row);
    139                             fireItemSelected(item);
     125                            fireItemSelected(getModel().getVisibleItem(row));
    140126                        }
    141127                    }
     
    151137        add(buildControlButtonPanel(), BorderLayout.SOUTH);
    152138
    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
    155140        //
    156141        tfFilter.getDocument().addDocumentListener(
     
    192177        );
    193178
    194 
    195179        // load the set of presets and bind them to the preset table
    196180        //
    197         Presets.initPresets();
    198         bindTo(Presets.getPresets());
     181        bindTo(TaggingPresets.getTaggingPresets());
    199182        presetsTable.getSelectionModel().clearSelection();
    200183        btnApply.setEnabled(false);
    201 
    202     }
    203 
    204     public void bindTo(Presets presets) {
     184    }
     185
     186    public void bindTo(Collection<TaggingPreset> presets) {
    205187        PresetsTableModel model = (PresetsTableModel)presetsTable.getModel();
    206188        model.setPresets(presets);
     
    227209    }
    228210
    229     protected void fireItemSelected(Item item) {
     211    protected void fireItemSelected(TaggingPreset item) {
    230212        synchronized(this.listeners) {
    231213            for(IPresetSelectorListener listener: listeners) {
     
    234216        }
    235217    }
    236 
    237 
    238 
    239218
    240219    private class DoubleClickAdapter extends MouseAdapter {
     
    243222            if (e.getClickCount() == 2) {
    244223                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    }
    251228
    252229    public void filter(String filter) {
     
    271248    }
    272249
    273 
    274250    protected PresetsTableModel getModel() {
    275251        return (PresetsTableModel)presetsTable.getModel();
     
    279255        getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put((KeyStroke)a.getValue(AbstractAction.ACCELERATOR_KEY), a.getValue(AbstractAction.NAME));
    280256        getActionMap().put(a.getValue(AbstractAction.NAME), a);
    281 
    282     }
    283 
     257    }
    284258}
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/KeyValuePair.java

    r23189 r30488  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.tageditor.tagspec;
    23
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/LabelSpecification.java

    r30454 r30488  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.tageditor.tagspec;
    23
    34import org.openstreetmap.josm.plugins.tageditor.ac.AutoCompletionContext;
    45
    5 public class LableSpecification {
     6public class LabelSpecification {
    67
    78    /** the key of the tag */
     
    1617     * constructor
    1718     */
    18     public LableSpecification() {
     19    public LabelSpecification() {
    1920    }
    2021
     
    6667        this.applicableToRelation = applicableToRelation;
    6768    }
    68    
    69 
    70    
    71    
    7269}
  • applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/TagSpecification.java

    r23189 r30488  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.plugins.tageditor.tagspec;
    23
     
    3132    private boolean applicableToRelation = true;
    3233
    33     private ArrayList<LableSpecification> lables = null;
     34    private ArrayList<LabelSpecification> lables = null;
    3435
    3536
     
    3839     */
    3940    public TagSpecification() {
    40         lables = new ArrayList<LableSpecification>();
     41        lables = new ArrayList<LabelSpecification>();
    4142    }
    4243
     
    5859     *   labels are defined
    5960     */
    60     public List<LableSpecification> getLables() {
     61    public List<LabelSpecification> getLables() {
    6162        return lables;
    6263    }
     
    6869     * @exception IllegalArgumentException thrown, if lables is null
    6970     */
    70     public void setLables(List<LableSpecification> lables) throws IllegalArgumentException {
     71    public void setLables(List<LabelSpecification> lables) throws IllegalArgumentException {
    7172        if (lables == null)
    7273            throw new IllegalArgumentException("argument 'lables' must not be null");
    7374        this.lables.clear();
    74         for (LableSpecification l : lables) {
     75        for (LabelSpecification l : lables) {
    7576            this.lables.add(l);
    7677        }
     
    8485     * @exception IllegalArgumentException thrown, if lable is null
    8586     */
    86     public void addLable(LableSpecification lable) throws IllegalArgumentException  {
     87    public void addLable(LabelSpecification lable) throws IllegalArgumentException  {
    8788        if (lable == null)
    8889            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.
    12package org.openstreetmap.josm.plugins.tageditor.tagspec;
    23
     
    2324import org.xml.sax.helpers.XMLReaderFactory;
    2425
    25 
    2626/**
    2727 * This class manages a list of {@link TagSpecification}s.
     
    110110            parser.setErrorHandler(handler);
    111111            parser.setEntityResolver(new ResourceEntityResolver());
    112             parser.setFeature( "http://xml.org/sax/features/validation", true);
     112            parser.setFeature("http://xml.org/sax/features/validation", true);
    113113            parser.setFeature("http://xml.org/sax/features/namespaces", true);
    114114            parser.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
     
    116116
    117117        } 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();
    119120            throw e;
    120121        } finally {
     
    141142        for (TagSpecification spec : tagSpecifications) {
    142143            if (spec.getKey().equals(forKey)) {
    143                 List<LableSpecification> lables = spec.getLables();
    144                 for (LableSpecification l : lables) {
     144                List<LabelSpecification> lables = spec.getLables();
     145                for (LabelSpecification l : lables) {
    145146                    if (!l.isApplicable(context)) {
    146147                        continue;
     
    166167
    167168        for (TagSpecification s : tagSpecifications) {
    168             for (LableSpecification l : s.getLables()) {
     169            for (LabelSpecification l : s.getLables()) {
    169170                entries.add(new KeyValuePair(s.getKey(), l.getValue()));
    170171            }
     
    188189        private TagSpecification currentTagSpecification  = null;
    189190
    190 
    191191        @Override
    192192        public void endDocument() throws SAXException {
     
    194194        }
    195195
    196 
    197 
    198196        @Override
    199197        public void error(SAXParseException e) throws SAXException {
     
    210208            logger.log(Level.FINE,"START");
    211209        }
    212 
    213210
    214211        /**
     
    293290         */
    294291        protected void startElementLabel(Attributes atts) throws SAXException {
    295             LableSpecification ls = new LableSpecification();
     292            LabelSpecification ls = new LabelSpecification();
    296293            for (int i=0; i< atts.getLength(); i++) {
    297294                String name = atts.getQName(i);
     
    349346        @Override
    350347        public void warning(SAXParseException e) throws SAXException {
    351             // TODO Auto-generated method stub
    352348            logger.log(Level.WARNING, "XML parsing warning", e);
    353349        }
    354350    }
    355351
    356     /**
    357      *
    358      *
    359      */
    360352    class ResourceEntityResolver implements EntityResolver {
    361353
    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 {
    369362                throw new SAXException("couldn't load external DTD '" + systemId + "'");
    370         }
    371 
     363            }
     364        }
    372365    }
    373366
  • 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.
    12package org.openstreetmap.josm.plugins.tageditor.tagspec.ui;
    23
  • 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.
    12package org.openstreetmap.josm.plugins.tageditor.tagspec.ui;
    23
  • 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.
    12package org.openstreetmap.josm.plugins.tageditor.tagspec.ui;
    23
     
    4647        pnl.add(lbl);
    4748        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"));
    5950        pnl.add(btn);
    6051        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.
    12package org.openstreetmap.josm.plugins.tageditor.tagspec.ui;
    23
  • 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.
    12package org.openstreetmap.josm.plugins.tageditor.tagspec.ui;
    23
  • 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.
    12package org.openstreetmap.josm.plugins.tageditor.tagspec.ui;
     3
    24import static org.openstreetmap.josm.tools.I18n.tr;
    35
Note: See TracChangeset for help on using the changeset viewer.