Changeset 35262 in osm


Ignore:
Timestamp:
2019-12-28T15:13:36+01:00 (5 years ago)
Author:
donvip
Message:

fix #josm17563 - fix icon support, add unit test

Location:
applications/editors/josm/plugins/surveyor
Files:
8 added
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/surveyor/.classpath

    r32680 r35262  
    22<classpath>
    33        <classpathentry kind="src" path="src"/>
     4        <classpathentry kind="src" output="bintest" path="unit">
     5                <attributes>
     6                        <attribute name="test" value="true"/>
     7                </attributes>
     8        </classpathentry>
     9        <classpathentry including="resources/" kind="src" path=""/>
    410        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
    511        <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/>
    612        <classpathentry combineaccessrules="false" kind="src" path="/JOSM-livegps"/>
     13        <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
    714        <classpathentry kind="output" path="bin"/>
    815</classpath>
  • applications/editors/josm/plugins/surveyor/resources/surveyor.xml

    r16957 r35262  
    44  <!-- action class: either fully qualified classnames or if not found,
    55       package at.dallermassl.josm.plugin.surveyor.action is assumed -->
    6   <button label="Tunnel Start" hotkey="T" icon="styles/standard/vehicle/tunnel.png">
     6  <button label="Tunnel Start" hotkey="T" icon="presets/transport/passage/tunnel.svg">
    77    <action class="PlayAudioAction" params="resource://audio/KDE_Window_Iconify.wav"/>
    88    <action class="SetWaypointAction" params="tunnel start"/>
     
    1414    <action class="SetWaypointAction" params="bridge"/>
    1515  </button>
    16   <button label="Village/City" hotkey="V" icon="styles/standard/place.png">
     16  <button label="Village/City" hotkey="V" icon="presets/place/village.svg">
    1717    <action class="PlayAudioAction" params="resource://audio/KDE_Window_Iconify.wav"/>
    1818    <action class="SetWaypointAction" params="village"/>
     
    2222    -->
    2323  </button>
    24   <button label="Parking" hotkey="P" icon="styles/standard/vehicle/parking.png">
     24  <button label="Parking" hotkey="P" icon="presets/vehicle/parking/parking.svg">
    2525    <!--action class="SetNodeAction" params="amenity=parking"/-->
    2626    <action class="PlayAudioAction" params="resource://audio/KDE_Window_Iconify.wav"/>
    2727    <action class="SetWaypointAction" params="Parking"/>
    2828  </button>
    29   <button label="One Way" hotkey="O" icon="presets/oneway.png">
    30     <action class="PlayAudioAction" params="resource://audio/KDE_Window_Iconify.wav"/>
    31     <action class="SetWaypointAction" params="oneway=yes"/>
    32   </button>
    33   <button label="Church" hotkey="C" icon="styles/standard/religion/church.png">
     29  <button label="Church" hotkey="C" icon="presets/religion/church.svg">
    3430    <action class="PlayAudioAction" params="resource://audio/KDE_Window_Iconify.wav"/>
    3531    <action class="SetNodeAction" params="amenity=place_of_worship,denomination=christian"/>
    3632    <action class="SetWaypointAction" params="Church"/>
    3733  </button>
    38   <button label="Fuel Station" hotkey="F" icon="styles/standard/vehicle/fuel.png">
     34  <button label="Fuel Station" hotkey="F" icon="presets/vehicle/fuel.svg">
    3935    <!--action class="SetNodeAction" params="amenity=fuel"/-->
    4036    <action class="PlayAudioAction" params="resource://audio/KDE_Window_Iconify.wav"/>
    4137    <action class="SetWaypointAction" params="Fuel"/>
    4238  </button>
    43   <button label="Hotel" hotkey="H" icon="styles/standard/accommodation/hotel.png">
     39  <button label="Hotel" hotkey="H" icon="presets/accommodation/hotel.svg">
    4440    <action class="PlayAudioAction" params="resource://audio/KDE_Window_Iconify.wav"/>
    4541    <action class="SetWaypointAction" params="Hotel"/>
    4642  </button>
    47   <button label="Restaurant" hotkey="R" icon="styles/standard/food/restaurant.png">
     43  <button label="Restaurant" hotkey="R" icon="presets/food/restaurant.svg">
    4844    <action class="PlayAudioAction" params="resource://audio/KDE_Window_Iconify.wav"/>
    4945    <action class="SetNodeAction" params="amenity=restaurant"/>
    5046    <action class="SetWaypointAction" params="Restaurant"/>
    5147  </button>
    52   <button label="Shopping" hotkey="S" icon="styles/standard/shop.png">
     48  <button label="Shopping" hotkey="S" icon="presets/shop/mall.svg">
    5349    <action class="PlayAudioAction" params="resource://audio/KDE_Window_Iconify.wav"/>
    5450    <action class="SetWaypointAction" params="Info"/>
    5551  </button>
    56   <button label="WC" hotkey="W" icon="styles/standard/vehicle/parking/restarea_toilets.png">
     52  <button label="WC" hotkey="W" icon="presets/service/toilets.svg">
    5753    <action class="PlayAudioAction" params="resource://audio/KDE_Window_Iconify.wav"/>
    5854    <action class="SetWaypointAction" params="Info"/>
    5955  </button>
    60   <button label="Camping" hotkey="Z" icon="styles/standard/accommodation/camping/caravan.png">
     56  <button label="Camping" hotkey="Z" icon="presets/accommodation/caravan.svg">
    6157    <action class="PlayAudioAction" params="resource://audio/KDE_Window_Iconify.wav"/>
    6258    <action class="SetWaypointAction" params="Camping"/>
  • applications/editors/josm/plugins/surveyor/src/org/openstreetmap/josm/plugins/surveyor/ButtonDescription.java

    r35252 r35262  
    175175        String actionName = tr(getLabel()) + " (" + hotkey + ")";
    176176
    177         Icon icon = ImageProvider.getIfAvailable(iconName);
    178         if (icon == null)
    179             icon = ImageProvider.getIfAvailable("markers", iconName);
    180         if (icon == null)
    181             icon = ImageProvider.getIfAvailable("symbols", iconName);
    182         if (icon == null)
    183             icon = ImageProvider.getIfAvailable("nodes", iconName);
     177        Icon icon = null;
     178        if (iconName != null) {
     179            icon = ImageProvider.getIfAvailable(iconName);
     180            if (icon == null)
     181                icon = ImageProvider.getIfAvailable("markers", iconName);
     182            if (icon == null)
     183                icon = ImageProvider.getIfAvailable("symbols", iconName);
     184            if (icon == null)
     185                icon = ImageProvider.getIfAvailable("nodes", iconName);
     186        }
    184187
    185188        MetaAction action = new MetaAction(actionName, icon);
  • applications/editors/josm/plugins/surveyor/src/org/openstreetmap/josm/plugins/surveyor/SurveyorComponent.java

    r34591 r35262  
    6464     */
    6565    public void setColumns(String columnsString) {
    66         System.out.println("setting columns to " +columnsString);
    6766        columns = Integer.parseInt(columnsString);
    6867        buttonPanel.setLayout(new GridLayout(rows, columns));
  • applications/editors/josm/plugins/surveyor/src/org/openstreetmap/josm/plugins/surveyor/SurveyorShowAction.java

    r34591 r35262  
    2323import org.openstreetmap.josm.actions.JosmAction;
    2424import org.openstreetmap.josm.gui.MainApplication;
    25 import org.openstreetmap.josm.plugins.surveyor.util.ResourceLoader;
     25import org.openstreetmap.josm.io.CachedFile;
    2626import org.openstreetmap.josm.spi.preferences.Config;
    2727import org.openstreetmap.josm.tools.Logging;
     
    107107    }
    108108
    109     public SurveyorComponent createComponent() {
     109    public static SurveyorComponent createComponent() {
    110110        String source = Config.getPref().get("surveyor.source");
    111         if (source == null || source.length() == 0) {
     111        if (source == null || source.isEmpty()) {
    112112            source = DEFAULT_SOURCE;
    113113            Config.getPref().put("surveyor.source", DEFAULT_SOURCE);
    114             // <FIXXME date="04.05.2007" author="cdaller">
    115             // TODO copy xml file to .josm directory if it does not exist!
    116             // </FIXXME>
    117114        }
    118         try (InputStream in = ResourceLoader.getInputStream(source)) {
     115        try (CachedFile cf = new CachedFile(source); InputStream in = cf.getInputStream()) {
    119116            return createComponent(in);
    120117        } catch (IOException e) {
     
    134131     * @throws SAXException if the xml could not be read.
    135132     */
    136     public SurveyorComponent createComponent(InputStream in) throws SAXException {
     133    public static SurveyorComponent createComponent(InputStream in) throws SAXException {
    137134        XmlObjectParser parser = new XmlObjectParser();
    138135        parser.mapOnStart("surveyor", SurveyorComponent.class);
     
    146143            Object object = parser.next();
    147144            if (object instanceof SurveyorComponent) {
    148                 //System.out.println("SurveyorComponent " + object);
    149145                surveyorComponent = (SurveyorComponent) object;
    150146            } else if (object instanceof ButtonDescription) {
    151                 //System.out.println("ButtonDescription " + object);
    152147                ((ButtonDescription) object).setActions(actions);
    153148                surveyorComponent.addButton(((ButtonDescription) object));
    154149                actions = new ArrayList<>();
    155150            } else if (object instanceof SurveyorActionDescription) {
    156                 //System.out.println("SurveyorActionDescription " + object);
    157151                actions.add((SurveyorActionDescription) object);
    158152            } else {
  • applications/editors/josm/plugins/surveyor/src/org/openstreetmap/josm/plugins/surveyor/action/PlayAudioAction.java

    r34591 r35262  
    44import java.io.BufferedInputStream;
    55import java.io.IOException;
    6 import java.io.InputStream;
    76
    87import javax.sound.sampled.AudioFormat;
     
    1514
    1615import org.openstreetmap.josm.gui.MainApplication;
     16import org.openstreetmap.josm.io.CachedFile;
    1717import org.openstreetmap.josm.plugins.surveyor.GpsActionEvent;
    18 import org.openstreetmap.josm.plugins.surveyor.util.ResourceLoader;
    1918import org.openstreetmap.josm.tools.Logging;
    2019
     
    3231        // run as a separate thread
    3332        MainApplication.worker.execute(() -> {
    34             try {
    35                 if (audioSource == null) {
    36                     audioSource = getParameters().get(0);
    37                 }
    38                 InputStream in = new BufferedInputStream(ResourceLoader.getInputStream(audioSource));
    39                 AudioInputStream stream = AudioSystem.getAudioInputStream(in);
     33            if (audioSource == null) {
     34                audioSource = getParameters().get(0);
     35            }
     36            try (CachedFile cf = new CachedFile(audioSource)) {
     37                AudioInputStream stream = AudioSystem.getAudioInputStream(new BufferedInputStream(cf.getInputStream()));
    4038
    4139                // At present, ALAW and ULAW encodings must be converted
Note: See TracChangeset for help on using the changeset viewer.