- Timestamp:
- 2017-09-07T00:41:30+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r12760 r12766 8 8 import java.awt.Dimension; 9 9 import java.awt.GraphicsEnvironment; 10 import java.awt.GridBagLayout; 10 11 import java.awt.event.KeyEvent; 11 12 import java.io.File; … … 48 49 import javax.swing.InputMap; 49 50 import javax.swing.JComponent; 51 import javax.swing.JLabel; 50 52 import javax.swing.JOptionPane; 53 import javax.swing.JPanel; 51 54 import javax.swing.KeyStroke; 52 55 import javax.swing.LookAndFeel; … … 80 83 import org.openstreetmap.josm.data.osm.DataSet; 81 84 import org.openstreetmap.josm.data.osm.OsmPrimitive; 85 import org.openstreetmap.josm.data.osm.UserInfo; 82 86 import org.openstreetmap.josm.data.osm.search.SearchMode; 83 87 import org.openstreetmap.josm.data.validation.OsmValidator; … … 107 111 import org.openstreetmap.josm.gui.util.RedirectInputMap; 108 112 import org.openstreetmap.josm.gui.util.WindowGeometry; 113 import org.openstreetmap.josm.gui.widgets.UrlLabel; 109 114 import org.openstreetmap.josm.io.CertificateAmendment; 110 115 import org.openstreetmap.josm.io.DefaultProxySelector; … … 122 127 import org.openstreetmap.josm.plugins.PluginInformation; 123 128 import org.openstreetmap.josm.tools.FontsManager; 129 import org.openstreetmap.josm.tools.GBC; 124 130 import org.openstreetmap.josm.tools.HttpClient; 125 131 import org.openstreetmap.josm.tools.I18n; … … 968 974 969 975 static void setupCallbacks() { 976 MessageNotifier.setNotifierCallback(MainApplication::notifyNewMessages); 970 977 DeleteCommand.setDeletionCallback(DeleteAction.defaultDeletionCallback); 971 978 } … … 1307 1314 } 1308 1315 } 1316 1317 static void notifyNewMessages(UserInfo userInfo) { 1318 GuiHelper.runInEDT(() -> { 1319 JPanel panel = new JPanel(new GridBagLayout()); 1320 panel.add(new JLabel(trn("You have {0} unread message.", "You have {0} unread messages.", 1321 userInfo.getUnreadMessages(), userInfo.getUnreadMessages())), 1322 GBC.eol()); 1323 panel.add(new UrlLabel(Main.getBaseUserUrl() + '/' + userInfo.getDisplayName() + "/inbox", 1324 tr("Click here to see your inbox.")), GBC.eol()); 1325 panel.setOpaque(false); 1326 new Notification().setContent(panel) 1327 .setIcon(JOptionPane.INFORMATION_MESSAGE) 1328 .setDuration(Notification.TIME_LONG) 1329 .show(); 1330 }); 1331 } 1309 1332 } -
trunk/src/org/openstreetmap/josm/io/MessageNotifier.java
r12743 r12766 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.trn;6 5 7 import java.awt.GridBagLayout;8 6 import java.net.Authenticator.RequestorType; 9 7 import java.util.concurrent.Executors; … … 12 10 import java.util.concurrent.TimeUnit; 13 11 14 import javax.swing.JLabel;15 import javax.swing.JOptionPane;16 import javax.swing.JPanel;17 18 12 import org.openstreetmap.josm.Main; 19 13 import org.openstreetmap.josm.data.UserIdentityManager; … … 21 15 import org.openstreetmap.josm.data.preferences.BooleanProperty; 22 16 import org.openstreetmap.josm.data.preferences.IntegerProperty; 23 import org.openstreetmap.josm.gui.Notification;24 17 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 25 import org.openstreetmap.josm.gui.util.GuiHelper;26 import org.openstreetmap.josm.gui.widgets.UrlLabel;27 18 import org.openstreetmap.josm.io.auth.CredentialsAgentException; 28 19 import org.openstreetmap.josm.io.auth.CredentialsAgentResponse; 29 20 import org.openstreetmap.josm.io.auth.CredentialsManager; 30 21 import org.openstreetmap.josm.io.auth.JosmPreferencesCredentialAgent; 31 import org.openstreetmap.josm.tools.GBC;32 22 import org.openstreetmap.josm.tools.Logging; 33 23 import org.openstreetmap.josm.tools.Utils; … … 41 31 private MessageNotifier() { 42 32 // Hide default constructor for utils classes 33 } 34 35 /** 36 * Called when new new messages are detected. 37 * @since xxx 38 */ 39 @FunctionalInterface 40 public interface NotifierCallback { 41 /** 42 * Perform the actual notification of new messages. 43 * @param userInfo the new user information, that includes the number of unread messages 44 */ 45 void notifyNewMessages(UserInfo userInfo); 46 } 47 48 private static NotifierCallback callback; 49 50 /** 51 * Sets the {@link NotifierCallback} responsible of notifying the user when new messages are received. 52 * @param notifierCallback the new {@code NotifierCallback} 53 */ 54 public static void setNotifierCallback(NotifierCallback notifierCallback) { 55 callback = notifierCallback; 43 56 } 44 57 … … 71 84 final int unread = userInfo.getUnreadMessages(); 72 85 if (unread > 0 && unread != lastUnreadCount) { 73 GuiHelper.runInEDT(() -> { 74 JPanel panel = new JPanel(new GridBagLayout()); 75 panel.add(new JLabel(trn("You have {0} unread message.", "You have {0} unread messages.", unread, unread)), 76 GBC.eol()); 77 panel.add(new UrlLabel(Main.getBaseUserUrl() + '/' + userInfo.getDisplayName() + "/inbox", 78 tr("Click here to see your inbox.")), GBC.eol()); 79 panel.setOpaque(false); 80 new Notification().setContent(panel) 81 .setIcon(JOptionPane.INFORMATION_MESSAGE) 82 .setDuration(Notification.TIME_LONG) 83 .show(); 84 }); 86 callback.notifyNewMessages(userInfo); 85 87 lastUnreadCount = unread; 86 88 } -
trunk/src/org/openstreetmap/josm/tools/Logging.java
r12765 r12766 283 283 } 284 284 285 286 285 private static void logPrivate(Level level, String pattern, Object... args) { 287 286 logPrivate(level, () -> MessageFormat.format(pattern, args));
Note:
See TracChangeset
for help on using the changeset viewer.