1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.validation;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.marktr;
|
---|
5 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
6 |
|
---|
7 | import java.awt.Color;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.data.preferences.NamedColorProperty;
|
---|
10 | import org.openstreetmap.josm.tools.Logging;
|
---|
11 |
|
---|
12 | /** The error severity */
|
---|
13 | public enum Severity {
|
---|
14 | // CHECKSTYLE.OFF: SingleSpaceSeparator
|
---|
15 | /** Error messages */
|
---|
16 | ERROR(1, tr("Errors"), /* ICON(data/) */"error", new NamedColorProperty(marktr("validation error"), Color.RED).get()),
|
---|
17 | /** Warning messages */
|
---|
18 | WARNING(2, tr("Warnings"), /* ICON(data/) */"warning", new NamedColorProperty(marktr("validation warning"), Color.YELLOW).get()),
|
---|
19 | /** Other messages */
|
---|
20 | OTHER(3, tr("Other"), /* ICON(data/) */"other", new NamedColorProperty(marktr("validation other"), Color.CYAN).get());
|
---|
21 | // CHECKSTYLE.ON: SingleSpaceSeparator
|
---|
22 |
|
---|
23 | /** Numeric ordering of the severities, 1 being major, 3 being minor */
|
---|
24 | private final int level;
|
---|
25 |
|
---|
26 | /** Description of the severity code */
|
---|
27 | private final String message;
|
---|
28 |
|
---|
29 | /** Associated icon */
|
---|
30 | private final String icon;
|
---|
31 |
|
---|
32 | /** Associated color */
|
---|
33 | private final Color color;
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * Constructor
|
---|
37 | *
|
---|
38 | * @param level Numeric ordering, 1 being major, 3 being minor
|
---|
39 | * @param message Description
|
---|
40 | * @param icon Associated icon
|
---|
41 | * @param color The color of this severity
|
---|
42 | */
|
---|
43 | Severity(int level, String message, String icon, Color color) {
|
---|
44 | this.level = level;
|
---|
45 | this.message = message;
|
---|
46 | this.icon = icon;
|
---|
47 | this.color = color;
|
---|
48 | }
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * Retrieves all colors once from the preferences to register them
|
---|
52 | */
|
---|
53 | public static void getColors() {
|
---|
54 | for (Severity c : values()) {
|
---|
55 | Logging.debug("{0}", c);
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 | @Override
|
---|
60 | public String toString() {
|
---|
61 | return message;
|
---|
62 | }
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Gets the associated icon
|
---|
66 | * @return the associated icon
|
---|
67 | */
|
---|
68 | public String getIcon() {
|
---|
69 | return icon;
|
---|
70 | }
|
---|
71 |
|
---|
72 | /**
|
---|
73 | * Gets the associated color
|
---|
74 | * @return The associated color
|
---|
75 | */
|
---|
76 | public Color getColor() {
|
---|
77 | return color;
|
---|
78 | }
|
---|
79 |
|
---|
80 | /**
|
---|
81 | * Gets the severity level, 1 being major, 3 being minor
|
---|
82 | * @return The severity level
|
---|
83 | * @since 12667
|
---|
84 | */
|
---|
85 | public int getLevel() {
|
---|
86 | return level;
|
---|
87 | }
|
---|
88 | }
|
---|