Ticket #19077: 19077.patch

File 19077.patch, 4.4 KB (added by simon04, 6 years ago)
  • resources/data/defaultpresets.xml

    diff --git a/resources/data/defaultpresets.xml b/resources/data/defaultpresets.xml
    index 6d9592a71..9e933a4b7 100644
    a b  
    50245024            <text key="ref" text="Reference" />
    50255025            <reference ref="operator_substance" />
    50265026            <combo key="location" text="Location" values="underground,underwater,overground" values_context="pipeline" />
    5027             <combo key="diameter" text="Diameter (mm)" values="800,1000,1200,1500,1600,1800,2200,2300,2400,2500,2600,2800,3200,3300,3400,3500,4000,4200,4300,4800" />
    5028             <text key="pressure" text="Pressure (bar)" />
     5027            <combo key="diameter" text="Diameter" suffix="mm" values="800,1000" />
     5028            <text key="pressure" text="Pressure" suffix="bar" />
    50295029        </item> <!-- Pipeline -->
    50305030        <item name="Pipeline Valve" icon="presets/misc/valve.svg" type="node" preset_name_label="true">
    50315031            <link wiki="Tag:pipeline=valve" />
  • resources/data/tagging-preset.xsd

    diff --git a/resources/data/tagging-preset.xsd b/resources/data/tagging-preset.xsd
    index 006aa9841..d4db3f96d 100644
    a b  
    173173        <attribute name="key" type="string" use="required" />
    174174        <attribute name="text" type="string" />
    175175        <attribute name="text_context" type="string" />
     176        <attribute name="suffix" type="string" />
    176177        <attribute name="default" type="string" />
    177178        <attribute name="use_last_as_default" type="tns:last_default" />
    178179        <attribute name="auto_increment" type="string" />
     
    205206        <attribute name="key" type="string" use="required" />
    206207        <attribute name="text" type="string" />
    207208        <attribute name="text_context" type="string" />
     209        <attribute name="suffix" type="string" />
    208210        <attribute name="values" type="string" />
    209211        <attribute name="values_from" type="string" />
    210212        <attribute name="values_context" type="string" />
  • src/org/openstreetmap/josm/gui/tagging/presets/items/Combo.java

    diff --git a/src/org/openstreetmap/josm/gui/tagging/presets/items/Combo.java b/src/org/openstreetmap/josm/gui/tagging/presets/items/Combo.java
    index 2c4ca7a24..520faa7ae 100644
    a b  
    1010import javax.swing.AbstractAction;
    1111import javax.swing.JButton;
    1212import javax.swing.JColorChooser;
     13import javax.swing.JLabel;
    1314import javax.swing.JPanel;
    1415
    1516import org.openstreetmap.josm.data.tagging.ac.AutoCompletionPriority;
     
    3435    /** The length of the combo box (number of characters allowed). */
    3536    public short length; // NOSONAR
    3637
     38    public String suffix;
     39
    3740    protected JosmComboBox<PresetListEntry> combobox;
    3841
    3942    /**
    protected void addToPanelAnchor(JPanel p, String def, boolean presetInitiallyMat  
    107110            ActionListener updateColor = ignore -> button.setBackground(getColor());
    108111            updateColor.actionPerformed(null);
    109112            combobox.addActionListener(updateColor);
     113        } else if (suffix != null) {
     114            p.add(combobox, GBC.std().fill(GBC.HORIZONTAL));
     115            p.add(new JLabel(suffix), GBC.eol().insets(3, 0, 0, 0));
    110116        } else {
    111117            p.add(combobox, GBC.eol().fill(GBC.HORIZONTAL));
    112118        }
  • src/org/openstreetmap/josm/gui/tagging/presets/items/Text.java

    diff --git a/src/org/openstreetmap/josm/gui/tagging/presets/items/Text.java b/src/org/openstreetmap/josm/gui/tagging/presets/items/Text.java
    index 143c21ea5..59d7e9327 100644
    a b  
    5757    /** A comma separated list of alternative keys to use for autocompletion. */
    5858    public String alternative_autocomplete_keys; // NOSONAR
    5959
     60    public String suffix;
     61
    6062    private JComponent value;
    6163
    6264    @Override
    public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean preset  
    168170        label.setComponentPopupMenu(getPopupMenu());
    169171        label.setLabelFor(value);
    170172        p.add(label, GBC.std().insets(0, 0, 10, 0));
    171         p.add(value, GBC.eol().fill(GBC.HORIZONTAL));
     173        if (suffix != null) {
     174            p.add(value, GBC.std().fill(GBC.HORIZONTAL));
     175            p.add(new JLabel(suffix), GBC.eol().insets(3, 0, 0, 0));
     176        } else {
     177            p.add(value, GBC.eol().fill(GBC.HORIZONTAL));
     178        }
    172179        value.setToolTipText(getKeyTooltipText());
    173180        return true;
    174181    }