Ignore:
Timestamp:
2011-02-07T09:35:27+01:00 (13 years ago)
Author:
bastiK
Message:

extended mappaint style dialog

File:
1 edited

Legend:

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

    r3843 r3863  
    22package org.openstreetmap.josm.gui.mappaint;
    33
     4import static org.openstreetmap.josm.tools.I18n.trn;
     5
    46import java.io.File;
     7import java.io.IOException;
     8import java.io.InputStream;
     9import java.util.ArrayList;
     10import java.util.Collection;
     11import java.util.Collections;
     12import java.util.List;
     13
     14import javax.swing.ImageIcon;
    515
    616import org.openstreetmap.josm.data.osm.OsmPrimitive;
    717import org.openstreetmap.josm.gui.preferences.SourceEntry;
     18import org.openstreetmap.josm.tools.ImageProvider;
    819
    920abstract public class StyleSource extends SourceEntry {
    10     public boolean hasError = false;
     21
     22    private List<Throwable> errors = new ArrayList<Throwable>();
    1123    public File zipIcons;
    1224
     
    2234
    2335    abstract public void loadStyleSource();
     36
     37    abstract public InputStream getSourceInputStream() throws IOException;
     38
     39    public void logError(Throwable e) {
     40        errors.add(e);
     41    }
     42
     43    public Collection<Throwable> getErrors() {
     44        return Collections.unmodifiableCollection(errors);
     45    }
     46
     47    protected void clearErrors() {
     48        errors.clear();
     49    }
     50
     51    private ImageIcon pencil = ImageProvider.get("dialogs/mappaint", "pencil");
     52
     53    protected ImageIcon getSourceIcon() {
     54        return pencil;
     55    }
     56
     57    final public ImageIcon getIcon() {
     58        if (getErrors().isEmpty())
     59            return getSourceIcon();
     60        else
     61            return ImageProvider.overlay(getSourceIcon(),
     62                    "dialogs/mappaint/error_small",
     63                    ImageProvider.OverlayPosition.SOUTHEAST);
     64    }
     65
     66    public String getToolTipText() {
     67        if (errors.isEmpty())
     68            return null;
     69        else
     70            return trn("There was an error when loading this style. Select ''Info'' from the right click menu for details.",
     71                    "There were {0} errors when loading this style. Select ''Info'' from the right click menu for details.",
     72                    errors.size(), errors.size());
     73    }
    2474}
Note: See TracChangeset for help on using the changeset viewer.