Changeset 6198 in josm


Ignore:
Timestamp:
2013-08-27T00:45:00+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #9019, fix #9020 - add new item_separator element in presets + update doc (modified patch by skyper)

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/data/defaultpresets.xml

    r6197 r6198  
    1919                 see http://josm.openstreetmap.de/wiki/NameTemplate
    2020
     21group: a group of items (same syntax as "item")
     22
    2123link: link to the relating map features website
    2224  href: the URL
     
    2426label: simple static text label
    2527  text: the text to display
     28
     29space: empty line
     30
     31optional: optional tags, short for "label" plus "space"
     32  text: the text to display (defaults to "Optional Attributes:")
     33
     34separator: separator line in menus
     35
     36item_separator: horizontal separator line between items (in window)
    2637
    2738key: fixed key/value pair to be set
  • trunk/data/tagging-preset.xsd

    r6190 r6198  
    8585            <element name="checkgroup" type="tns:checkgroup" />
    8686                        <element name="check" type="tns:check" />
     87                        <element name="item_separator" type="tns:separator" />
    8788                </choice>
    8889        </group>
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItem.java

    r6074 r6198  
    55import java.util.List;
    66import java.util.Map;
     7
    78import javax.swing.JPanel;
     9
    810import org.openstreetmap.josm.Main;
    911import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    3032    }
    3133
     34    /**
     35     * Called by {@link TaggingPreset#createPanel} during tagging preset panel creation.
     36     * All components defining this tagging preset item must be added to given panel.
     37     * @param p The panel where components must be added
     38     * @param sel The related selected OSM primitives
     39     * @return {@code true} if this item adds semantic tagging elements, {@code false} otherwise.
     40     */
    3241    abstract boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel);
    3342
     43    /**
     44     * Adds the new tags to apply to selected OSM primitives when the preset holding this item is applied.
     45     * @param changedTags The list of changed tags to modify if needed
     46     */
    3447    abstract void addCommands(List<Tag> changedTags);
    3548
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java

    r6190 r6198  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.tagging;
     3
     4import static org.openstreetmap.josm.tools.I18n.tr;
     5import static org.openstreetmap.josm.tools.I18n.trc;
    36
    47import java.awt.Component;
     
    3437import javax.swing.JPanel;
    3538import javax.swing.JScrollPane;
     39import javax.swing.JSeparator;
    3640import javax.swing.JToggleButton;
    3741import javax.swing.ListCellRenderer;
    3842import javax.swing.ListModel;
    3943
    40 import org.xml.sax.SAXException;
    4144import org.openstreetmap.josm.Main;
    4245import org.openstreetmap.josm.actions.search.SearchCompiler;
     
    5154import org.openstreetmap.josm.gui.widgets.JosmComboBox;
    5255import org.openstreetmap.josm.gui.widgets.JosmTextField;
     56import org.openstreetmap.josm.tools.GBC;
    5357import org.openstreetmap.josm.tools.ImageProvider;
    5458import org.openstreetmap.josm.tools.UrlLabel;
    5559import org.openstreetmap.josm.tools.Utils;
    56 import org.openstreetmap.josm.tools.GBC;
    57 
    58 import static org.openstreetmap.josm.tools.I18n.tr;
    59 import static org.openstreetmap.josm.tools.I18n.trc;
     60import org.xml.sax.SAXException;
    6061
    6162/**
     
    444445    }
    445446
     447    /**
     448     * Class used to represent a {@link JSeparator} inside tagging preset window.
     449     * @since 6198
     450     */
     451    public static class ItemSeparator extends TaggingPresetItem {
     452
     453        @Override
     454        public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
     455            p.add(new JSeparator(), GBC.eol().fill(GBC.HORIZONTAL).insets(0, 5, 0, 5));
     456            return false;
     457        }
     458
     459        @Override
     460        public void addCommands(List<Tag> changedTags) {
     461        }
     462
     463        @Override
     464        public String toString() {
     465            return "ItemSeparator";
     466        }
     467    }
    446468
    447469    public static abstract class KeyedItem extends TaggingPresetItem {
     
    703725        boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
    704726            Integer cols = new Integer(columns);
    705             int rows = (int) Math.ceil((double)checks.size()/cols.doubleValue());
     727            int rows = (int) Math.ceil(checks.size()/cols.doubleValue());
    706728            JPanel panel = new JPanel(new GridLayout(rows, cols));
    707729           
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetReader.java

    r6148 r6198  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.tagging;
     3
     4import static org.openstreetmap.josm.tools.I18n.tr;
    35
    46import java.io.BufferedReader;
     
    1517import javax.swing.JOptionPane;
    1618
    17 import org.xml.sax.SAXException;
    1819import org.openstreetmap.josm.Main;
    1920import org.openstreetmap.josm.gui.preferences.SourceEntry;
     
    2223import org.openstreetmap.josm.tools.Utils;
    2324import org.openstreetmap.josm.tools.XmlObjectParser;
    24 
    25 import static org.openstreetmap.josm.tools.I18n.tr;
     25import org.xml.sax.SAXException;
    2626
    2727/**
     
    6767        parser.map("key", TaggingPresetItems.Key.class);
    6868        parser.map("list_entry", TaggingPresetItems.PresetListEntry.class);
     69        parser.map("item_separator", TaggingPresetItems.ItemSeparator.class);
    6970       
    7071        LinkedList<TaggingPreset> all = new LinkedList<TaggingPreset>();
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetSeparator.java

    r6074 r6198  
    22package org.openstreetmap.josm.gui.tagging;
    33
     4/**
     5 * Class used to represent a {@link javax.swing.JSeparator} inside tagging preset menu.
     6 * @since 895
     7 */
    48public class TaggingPresetSeparator extends TaggingPreset {
    59    @Override
Note: See TracChangeset for help on using the changeset viewer.