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