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/src/org/openstreetmap/josm/plugins/surveyor
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • 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.