Ignore:
Timestamp:
2012-05-07T15:05:27+02:00 (12 years ago)
Author:
bastiK
Message:

mapstyles: add automatic reloading of local styles when they have been edited in an extenal editor (based on mtime)

Location:
trunk/src/org/openstreetmap/josm/gui/mappaint
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/LineTextElemStyle.java

    r5217 r5219  
    5050        return text.hashCode();
    5151    }
     52
     53    @Override
     54    public String toString() {
     55        return "LineTextElemStyle{" + super.toString() + "text=" + text + "}";
     56    }
     57
    5258}
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r5054 r5219  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.io.File;
    67import java.io.IOException;
    78import java.io.InputStream;
     
    2122import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
    2223import org.openstreetmap.josm.gui.mappaint.xml.XmlStyleSource;
     24import org.openstreetmap.josm.gui.preferences.SourceEntry;
    2325import org.openstreetmap.josm.gui.preferences.map.MapPaintPreference.MapPaintPrefHelper;
    24 import org.openstreetmap.josm.gui.preferences.SourceEntry;
    2526import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    2627import org.openstreetmap.josm.io.MirroredInputStream;
     
    165166        for (StyleSource source : styles.getStyleSources()) {
    166167            source.loadStyleSource();
    167         }
    168 
     168            if (Main.pref.getBoolean("mappaint.auto_reload_local_styles", true)) {
     169                if (source.isLocal()) {
     170                    File f = new File(source.url);
     171                    source.setLastMTime(f.lastModified());
     172                }
     173            }
     174        }
    169175        fireMapPaintSylesUpdated();
    170176    }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/StyleSource.java

    r4820 r5219  
    2626
    2727    private ImageIcon imageIcon;
     28    private long lastMTime = 0l;
    2829
    2930    /******
     
    3132     * of the source file.
    3233     */
    33    
     34
    3435    public String icon;
    3536
     
    104105        return null;
    105106    }
     107
     108    public long getLastMTime() {
     109        return lastMTime;
     110    }
     111
     112    public void setLastMTime(long lastMTime) {
     113        this.lastMTime = lastMTime;
     114    }
     115
     116
    106117}
Note: See TracChangeset for help on using the changeset viewer.