- Timestamp:
- 2020-04-15T23:29:36+02:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/Notification.java
r12846 r16313 4 4 import java.awt.Color; 5 5 import java.awt.Component; 6 import java.util.Objects; 6 7 7 8 import javax.swing.Icon; … … 9 10 import javax.swing.JOptionPane; 10 11 import javax.swing.UIManager; 12 import javax.swing.text.JTextComponent; 11 13 12 14 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; … … 211 213 NotificationManager.getInstance().showNotification(this); 212 214 } 215 216 private Object getContentTextOrComponent() { 217 return content instanceof JTextComponent ? ((JTextComponent) content).getText() : content; 218 } 219 220 @Override 221 public boolean equals(Object o) { 222 if (this == o) return true; 223 if (o == null || getClass() != o.getClass()) return false; 224 Notification that = (Notification) o; 225 System.out.println(getContentTextOrComponent().getClass()); 226 return duration == that.duration 227 && Objects.equals(getContentTextOrComponent(), that.getContentTextOrComponent()) 228 && Objects.equals(helpTopic, that.helpTopic); 229 } 230 231 @Override 232 public int hashCode() { 233 return Objects.hash(getContentTextOrComponent(), duration, helpTopic); 234 } 235 236 @Override 237 public String toString() { 238 return "Notification{" + 239 "content=" + getContentTextOrComponent() + 240 ", duration=" + duration + 241 ", helpTopic='" + helpTopic + '\'' + 242 '}'; 243 } 213 244 } -
trunk/src/org/openstreetmap/josm/gui/NotificationManager.java
r14153 r16313 21 21 import java.awt.event.MouseListener; 22 22 import java.awt.geom.RoundRectangle2D; 23 import java.util.Deque; 23 24 import java.util.LinkedList; 24 import java.util. Queue;25 import java.util.Objects; 25 26 26 27 import javax.swing.AbstractAction; … … 41 42 import org.openstreetmap.josm.gui.util.GuiHelper; 42 43 import org.openstreetmap.josm.tools.ImageProvider; 44 import org.openstreetmap.josm.tools.Logging; 43 45 44 46 /** … … 63 65 private Notification currentNotification; 64 66 private NotificationPanel currentNotificationPanel; 65 private final Queue<Notification> queue;67 private final Deque<Notification> queue; 66 68 67 69 private static IntegerProperty pauseTime = new IntegerProperty("notification-default-pause-time-ms", 300); // milliseconds … … 86 88 87 89 /** 88 * Show the given notification 90 * Show the given notification (unless a duplicate notification is being shown at the moment or at the end of the queue) 89 91 * @param note The note to show. 90 92 * @see Notification#show() … … 92 94 public void showNotification(Notification note) { 93 95 synchronized (queue) { 96 if (Objects.equals(note, currentNotification) || Objects.equals(note, queue.peekLast())) { 97 Logging.debug("Dropping duplicate notification {0}", note); 98 return; 99 } 94 100 queue.add(note); 95 101 processQueue();
Note:
See TracChangeset
for help on using the changeset viewer.