Changeset 14248 in josm for trunk/src


Ignore:
Timestamp:
2018-09-13T22:48:54+02:00 (6 years ago)
Author:
Don-vip
Message:

fix #16730 - make sure we try to display popup menus only if their parent is visible on screen

Location:
trunk/src/org/openstreetmap/josm
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/relation/RecentRelationsAction.java

    r14134 r14248  
    159159
    160160        static void launch(Component parent, KeyStroke keystroke) {
    161             Rectangle r = parent.getBounds();
    162             new RecentRelationsPopupMenu(getRecentRelationsOnActiveLayer(), keystroke).show(parent, r.x, r.y + r.height);
     161            if (parent.isShowing()) {
     162                Rectangle r = parent.getBounds();
     163                new RecentRelationsPopupMenu(getRecentRelationsOnActiveLayer(), keystroke).show(parent, r.x, r.y + r.height);
     164            }
    163165        }
    164166    }
  • trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java

    r12643 r14248  
    7272                    ((JMenuItem) c).getAction().actionPerformed(e);
    7373                } else {
    74                     if (source == null) return;
     74                    if (source == null || !source.isShowing()) return;
    7575                    popup.show(source, source.getWidth()/2, source.getHeight()/2);
    7676                }
  • trunk/src/org/openstreetmap/josm/gui/MapFrame.java

    r13832 r14248  
    682682                }));
    683683            }
    684             if (button != null) {
     684            if (button != null && button.isShowing()) {
    685685                Rectangle bounds = button.getBounds();
    686686                menu.show(button, bounds.x + bounds.width, 0);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/layer/LayerVisibilityAction.java

    r14153 r14248  
    3535
    3636import org.openstreetmap.josm.gui.MainApplication;
     37import org.openstreetmap.josm.gui.MainFrame;
    3738import org.openstreetmap.josm.gui.SideButton;
    3839import org.openstreetmap.josm.gui.dialogs.IEnabledStateUpdating;
     
    113114        updateValues();
    114115        if (e.getSource() == sideButton) {
    115             popup.show(sideButton, 0, sideButton.getHeight());
     116            if (sideButton.isShowing()) {
     117                popup.show(sideButton, 0, sideButton.getHeight());
     118            }
    116119        } else {
    117120            // Action can be trigger either by opacity button or by popup menu (in case toggle buttons are hidden).
    118121            // In that case, show it in the middle of screen (because opacityButton is not visible)
    119             popup.show(MainApplication.getMainFrame(),
    120                     MainApplication.getMainFrame().getWidth() / 2,
    121                     (MainApplication.getMainFrame().getHeight() - popup.getHeight()) / 2);
     122            MainFrame mainFrame = MainApplication.getMainFrame();
     123            if (mainFrame.isShowing()) {
     124                popup.show(mainFrame, mainFrame.getWidth() / 2, (mainFrame.getHeight() - popup.getHeight()) / 2);
     125            }
    122126        }
    123127    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java

    r14153 r14248  
    967967                            action.actionPerformed(null);
    968968                            if (SwingUtilities.isRightMouseButton(e)) {
    969                                 new TagPopupMenu(t).show(e.getComponent(), e.getX(), e.getY());
     969                                Component component = e.getComponent();
     970                                if (component.isShowing()) {
     971                                    new TagPopupMenu(t).show(component, e.getX(), e.getY());
     972                                }
    970973                            } else if (e.isShiftDown()) {
    971974                                // add tags on Shift-Click
  • trunk/src/org/openstreetmap/josm/gui/download/UserQueryList.java

    r14146 r14248  
    323323                if (model.getSize() == 0 || index == -1) {
    324324                    list.clearSelection();
    325                     emptySelectionPopup.show(list, e.getX(), e.getY());
     325                    if (list.isShowing()) {
     326                        emptySelectionPopup.show(list, e.getX(), e.getY());
     327                    }
    326328                } else {
    327329                    list.setSelectedIndex(index);
    328330                    list.ensureIndexIsVisible(index);
    329                     elementPopup.show(list, e.getX(), e.getY());
     331                    if (list.isShowing()) {
     332                        elementPopup.show(list, e.getX(), e.getY());
     333                    }
    330334                }
    331335            }
  • trunk/src/org/openstreetmap/josm/gui/history/OpenChangesetPopupMenu.java

    r14119 r14248  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.awt.Container;
    67import java.awt.Rectangle;
    78import java.awt.event.ActionEvent;
     
    4647     */
    4748    public void show(final JComponent parent) {
    48         final Rectangle r = parent.getBounds();
    49         show(parent.getParent(), r.x, r.y + r.height);
     49        Container parentParent = parent.getParent();
     50        if (parentParent.isShowing()) {
     51            final Rectangle r = parent.getBounds();
     52            show(parentParent, r.x, r.y + r.height);
     53        }
    5054    }
    5155
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r14153 r14248  
    55
    66import java.awt.Color;
     7import java.awt.Component;
    78import java.awt.Dimension;
    89import java.awt.Font;
     
    191192            if (!isVisible()) return;
    192193            if (e.getButton() == MouseEvent.BUTTON3) {
    193                 new TileSourceLayerPopup(e.getX(), e.getY()).show(e.getComponent(), e.getX(), e.getY());
     194                Component component = e.getComponent();
     195                if (component.isShowing()) {
     196                    new TileSourceLayerPopup(e.getX(), e.getY()).show(component, e.getX(), e.getY());
     197                }
    194198            } else if (e.getButton() == MouseEvent.BUTTON1) {
    195199                attribution.handleAttribution(e.getPoint(), true);
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AdvancedPreference.java

    r14153 r14248  
    173173        more.addActionListener(new ActionListener() {
    174174            private JPopupMenu menu = buildPopupMenu();
    175             @Override public void actionPerformed(ActionEvent ev) {
    176                 menu.show(more, 0, 0);
     175            @Override
     176            public void actionPerformed(ActionEvent ev) {
     177                if (more.isShowing()) {
     178                    menu.show(more, 0, 0);
     179                }
    177180            }
    178181        });
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetMenu.java

    r14153 r14248  
    106106                    Point p = pointerInfo.getLocation();
    107107                    MainFrame parent = MainApplication.getMainFrame();
    108                     pm.show(parent, p.x-parent.getX(), p.y-parent.getY());
     108                    if (parent.isShowing()) {
     109                        pm.show(parent, p.x-parent.getX(), p.y-parent.getY());
     110                    }
    109111                }
    110112            } catch (SecurityException ex) {
  • trunk/src/org/openstreetmap/josm/gui/util/MultikeyActionsHandler.java

    r14153 r14248  
    2424
    2525import org.openstreetmap.josm.gui.MainApplication;
     26import org.openstreetmap.josm.gui.MainFrame;
    2627import org.openstreetmap.josm.gui.util.MultikeyShortcutAction.MultikeyInfo;
    2728import org.openstreetmap.josm.tools.Shortcut;
     
    101102            }
    102103            layers.addPopupMenuListener(new StatusLinePopupMenuListener());
    103             layers.show(MainApplication.getMainFrame(), Integer.MAX_VALUE, Integer.MAX_VALUE);
    104             layers.setLocation(MainApplication.getMainFrame().getX() + MainApplication.getMainFrame().getWidth() - layers.getWidth(),
    105                                MainApplication.getMainFrame().getY() + MainApplication.getMainFrame().getHeight() - layers.getHeight());
     104            MainFrame mainFrame = MainApplication.getMainFrame();
     105            if (mainFrame.isShowing()) {
     106                layers.show(mainFrame, Integer.MAX_VALUE, Integer.MAX_VALUE);
     107                layers.setLocation(mainFrame.getX() + mainFrame.getWidth() - layers.getWidth(),
     108                                   mainFrame.getY() + mainFrame.getHeight() - layers.getHeight());
     109            }
    106110        }
    107111    }
  • trunk/src/org/openstreetmap/josm/gui/widgets/PopupMenuButton.java

    r13076 r14248  
    144144     */
    145145    public void setPopupMenu(JPopupMenu m) {
    146         this.menu = m;
     146        menu = m;
    147147    }
    148148
    149149    @Override
    150150    public void actionPerformed(ActionEvent e) {
    151         this.menu.show(this, 0, this.getHeight());
     151        if (isShowing()) {
     152            menu.show(this, 0, this.getHeight());
     153        }
    152154    }
    153155
  • trunk/src/org/openstreetmap/josm/gui/widgets/PopupMenuLauncher.java

    r10173 r14248  
    109109    protected void showMenu(MouseEvent evt) {
    110110        if (menu != null && evt != null) {
    111             menu.show(evt.getComponent(), evt.getX(), evt.getY());
     111            Component component = evt.getComponent();
     112            if (component.isShowing()) {
     113                menu.show(component, evt.getX(), evt.getY());
     114            }
    112115        }
    113116    }
Note: See TracChangeset for help on using the changeset viewer.