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; 010import org.openstreetmap.josm.data.preferences.ColorProperty; 011 012/** The error severity */ 013public enum Severity { 014 // CHECKSTYLE.OFF: SingleSpaceSeparator 015 /** Error messages */ 016 ERROR(tr("Errors"), /* ICON(data/) */"error", new ColorProperty(marktr("validation error"), Color.RED).get()), 017 /** Warning messages */ 018 WARNING(tr("Warnings"), /* ICON(data/) */"warning", new ColorProperty(marktr("validation warning"), Color.YELLOW).get()), 019 /** Other messages */ 020 OTHER(tr("Other"), /* ICON(data/) */"other", new ColorProperty(marktr("validation other"), Color.CYAN).get()); 021 // CHECKSTYLE.ON: SingleSpaceSeparator 022 023 /** Description of the severity code */ 024 private final String message; 025 026 /** Associated icon */ 027 private final String icon; 028 029 /** Associated color */ 030 private final Color color; 031 032 /** 033 * Constructor 034 * 035 * @param message Description 036 * @param icon Associated icon 037 * @param color The color of this severity 038 */ 039 Severity(String message, String icon, Color color) { 040 this.message = message; 041 this.icon = icon; 042 this.color = color; 043 } 044 045 public static void getColors() { 046 for (Severity c : values()) { 047 if (Main.isDebugEnabled()) { 048 Main.debug(c.toString()); 049 } 050 } 051 } 052 053 @Override 054 public String toString() { 055 return message; 056 } 057 058 /** 059 * Gets the associated icon 060 * @return the associated icon 061 */ 062 public String getIcon() { 063 return icon; 064 } 065 066 /** 067 * Gets the associated color 068 * @return The associated color 069 */ 070 public Color getColor() { 071 return color; 072 } 073}