|
26 | 26 | import java.util.Arrays;
|
27 | 27 | import java.util.Collections;
|
28 | 28 | import java.util.List;
|
| 29 | +import java.util.Objects; |
29 | 30 | import org.apache.commons.lang3.Range;
|
30 |
| -import org.apache.log4j.Logger; |
| 31 | +import org.apache.logging.log4j.LogManager; |
| 32 | +import org.apache.logging.log4j.Logger; |
31 | 33 | import org.jdesktop.swingx.decorator.AbstractHighlighter;
|
32 | 34 | import org.jdesktop.swingx.decorator.ComponentAdapter;
|
33 | 35 | import org.jdesktop.swingx.decorator.HighlightPredicate;
|
|
45 | 47 | import org.zaproxy.zap.view.table.HistoryReferencesTableModel;
|
46 | 48 |
|
47 | 49 | public class ExtensionNeonmarker extends ExtensionAdaptor {
|
48 |
| - private static final Logger LOGGER = Logger.getLogger(ExtensionNeonmarker.class); |
| 50 | + private static final Logger LOGGER = LogManager.getLogger(ExtensionNeonmarker.class); |
49 | 51 | private static final Range<Integer> INT_RANGE =
|
50 | 52 | Range.between(Integer.MIN_VALUE, Integer.MAX_VALUE);
|
51 | 53 | public static final String RESOURCE = "/org/zaproxy/zap/extension/neonmarker/resources";
|
@@ -179,17 +181,17 @@ protected void toggleHighlighter(boolean on) {
|
179 | 181 | public boolean addColorMapping(String tag, int color) {
|
180 | 182 | if (isValidTag(tag) && isValidColor(color)) {
|
181 | 183 | Color newColor = new Color(color);
|
182 |
| - getColorMap().add(new ColorMapping(tag, newColor)); |
| 184 | + ColorMapping newMapping = new ColorMapping(tag, newColor); |
| 185 | + if (!getColorMap().contains(newMapping)) { |
| 186 | + getColorMap().add(newMapping); |
| 187 | + } |
183 | 188 | if (!palette.contains(newColor)) {
|
184 | 189 | addToPalette(newColor);
|
185 | 190 | }
|
186 | 191 | getNeonmarkerPanel().refreshDisplay();
|
187 | 192 | return true;
|
188 | 193 | }
|
189 |
| - if (LOGGER.isDebugEnabled()) { |
190 |
| - LOGGER.debug( |
191 |
| - "Either the tag: \"" + tag + "\" or the color: \"" + color + " was invalid."); |
192 |
| - } |
| 194 | + LOGGER.debug("Either the tag: \"{}\" or the color: \"{}\" was invalid.", tag, color); |
193 | 195 | return false;
|
194 | 196 | }
|
195 | 197 |
|
@@ -297,6 +299,26 @@ public Color getColor() {
|
297 | 299 | public void setColor(Color color) {
|
298 | 300 | this.color = color;
|
299 | 301 | }
|
| 302 | + |
| 303 | + @Override |
| 304 | + public int hashCode() { |
| 305 | + return Objects.hash(color, tag); |
| 306 | + } |
| 307 | + |
| 308 | + @Override |
| 309 | + public boolean equals(Object obj) { |
| 310 | + if (this == obj) { |
| 311 | + return true; |
| 312 | + } |
| 313 | + if (obj == null) { |
| 314 | + return false; |
| 315 | + } |
| 316 | + if (getClass() != obj.getClass()) { |
| 317 | + return false; |
| 318 | + } |
| 319 | + ColorMapping other = (ColorMapping) obj; |
| 320 | + return Objects.equals(color, other.color) && Objects.equals(tag, other.tag); |
| 321 | + } |
300 | 322 | }
|
301 | 323 |
|
302 | 324 | @Override
|
|
0 commit comments