001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.data.validation;
003
004import static org.openstreetmap.josm.tools.I18n.marktr;
005import static org.openstreetmap.josm.tools.I18n.tr;
006
007import java.awt.Color;
008
009import org.openstreetmap.josm.Main;
010
011/** The error severity */
012public enum Severity {
013    /** Error messages */
014    ERROR(tr("Errors"), /* ICON(data/) */"error",       Main.pref.getColor(marktr("validation error"), Color.RED)),
015    /** Warning messages */
016    WARNING(tr("Warnings"), /* ICON(data/) */"warning", Main.pref.getColor(marktr("validation warning"), Color.YELLOW)),
017    /** Other messages */
018    OTHER(tr("Other"), /* ICON(data/) */"other",        Main.pref.getColor(marktr("validation other"), Color.CYAN));
019
020    /** Description of the severity code */
021    private final String message;
022
023    /** Associated icon */
024    private final String icon;
025
026    /** Associated color */
027    private final Color color;
028
029    /**
030     * Constructor
031     *
032     * @param message Description
033     * @param icon Associated icon
034     * @param color The color of this severity
035     */
036    Severity(String message, String icon, Color color) {
037        this.message = message;
038        this.icon = icon;
039        this.color = color;
040    }
041
042    public static void getColors() {
043        for (Severity c : values()) {
044            if (Main.isDebugEnabled()) {
045                Main.debug(c.toString());
046            }
047        }
048    }
049
050    @Override
051    public String toString() {
052        return message;
053    }
054
055    /**
056     * Gets the associated icon
057     * @return the associated icon
058     */
059    public String getIcon() {
060        return icon;
061    }
062
063    /**
064     * Gets the associated color
065     * @return The associated color
066     */
067    public Color getColor() {
068        return color;
069    }
070}