Changeset 11996 in josm


Ignore:
Timestamp:
2017-04-24T21:35:09+02:00 (7 years ago)
Author:
Don-vip
Message:

fix #13809 - run GUI operations of NotificationManager.processQueue in EDT

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/NotificationManager.java

    r11396 r11996  
    4040import org.openstreetmap.josm.gui.help.HelpBrowser;
    4141import org.openstreetmap.josm.gui.help.HelpUtil;
     42import org.openstreetmap.josm.gui.util.GuiHelper;
    4243import org.openstreetmap.josm.tools.ImageProvider;
    4344
     
    103104        if (currentNotification == null) return;
    104105
    105         currentNotificationPanel = new NotificationPanel(currentNotification, new FreezeMouseListener(), e -> this.stopHideTimer());
    106         currentNotificationPanel.validate();
    107 
    108         int margin = 5;
    109         JFrame parentWindow = (JFrame) Main.parent;
    110         Dimension size = currentNotificationPanel.getPreferredSize();
    111         if (parentWindow != null) {
    112             int x;
    113             int y;
    114             if (Main.isDisplayingMapView() && Main.map.mapView.getHeight() > 0) {
    115                 MapView mv = Main.map.mapView;
    116                 Point mapViewPos = SwingUtilities.convertPoint(mv.getParent(), mv.getX(), mv.getY(), Main.parent);
    117                 x = mapViewPos.x + margin;
    118                 y = mapViewPos.y + mv.getHeight() - Main.map.statusLine.getHeight() - size.height - margin;
    119             } else {
    120                 x = margin;
    121                 y = parentWindow.getHeight() - Main.toolbar.control.getSize().height - size.height - margin;
    122             }
    123             parentWindow.getLayeredPane().add(currentNotificationPanel, JLayeredPane.POPUP_LAYER, 0);
    124 
    125             currentNotificationPanel.setLocation(x, y);
    126         }
    127         currentNotificationPanel.setSize(size);
    128 
    129         currentNotificationPanel.setVisible(true);
     106        GuiHelper.runInEDTAndWait(() -> {
     107            currentNotificationPanel = new NotificationPanel(currentNotification, new FreezeMouseListener(), e -> this.stopHideTimer());
     108            currentNotificationPanel.validate();
     109
     110            int margin = 5;
     111            JFrame parentWindow = (JFrame) Main.parent;
     112            Dimension size = currentNotificationPanel.getPreferredSize();
     113            if (parentWindow != null) {
     114                int x;
     115                int y;
     116                if (Main.isDisplayingMapView() && Main.map.mapView.getHeight() > 0) {
     117                    MapView mv = Main.map.mapView;
     118                    Point mapViewPos = SwingUtilities.convertPoint(mv.getParent(), mv.getX(), mv.getY(), Main.parent);
     119                    x = mapViewPos.x + margin;
     120                    y = mapViewPos.y + mv.getHeight() - Main.map.statusLine.getHeight() - size.height - margin;
     121                } else {
     122                    x = margin;
     123                    y = parentWindow.getHeight() - Main.toolbar.control.getSize().height - size.height - margin;
     124                }
     125                parentWindow.getLayeredPane().add(currentNotificationPanel, JLayeredPane.POPUP_LAYER, 0);
     126
     127                currentNotificationPanel.setLocation(x, y);
     128            }
     129            currentNotificationPanel.setSize(size);
     130            currentNotificationPanel.setVisible(true);
     131        });
    130132
    131133        running = true;
Note: See TracChangeset for help on using the changeset viewer.