Changeset 5185 in josm for trunk/src


Ignore:
Timestamp:
2012-04-15T00:00:33+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #7575 - Non-scrollable menu for Imagery offset

File:
1 edited

Legend:

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

    r4162 r5185  
    1010import java.awt.Font;
    1111import java.awt.Graphics;
     12import java.awt.Toolkit;
    1213import java.awt.event.ActionEvent;
    1314import java.awt.image.BufferedImage;
     
    2324import javax.swing.JMenu;
    2425import javax.swing.JMenuItem;
     26import javax.swing.JPopupMenu;
    2527import javax.swing.JSeparator;
    2628import javax.swing.SwingUtilities;
     
    3436import org.openstreetmap.josm.data.imagery.OffsetBookmark;
    3537import org.openstreetmap.josm.data.preferences.IntegerProperty;
     38import org.openstreetmap.josm.gui.MenuScroller;
    3639import org.openstreetmap.josm.io.imagery.OffsetServer;
    3740import org.openstreetmap.josm.io.imagery.OsmosnimkiOffsetServer;
     
    205208        subMenu.add(new JSeparator());
    206209        boolean hasBookmarks = false;
     210        int menuItemHeight = 0;
    207211        for (OffsetBookmark b : OffsetBookmark.allBookmarks) {
    208212            if (!b.isUsable(this)) {
     
    214218            }
    215219            subMenu.add(item);
     220            menuItemHeight = item.getPreferredSize().height;
    216221            hasBookmarks = true;
     222        }
     223        if (menuItemHeight > 0) {
     224                int scrollcount = (Toolkit.getDefaultToolkit().getScreenSize().height / menuItemHeight) - 1;
     225                if (subMenu instanceof JMenu) {
     226                        MenuScroller.setScrollerFor((JMenu) subMenu, scrollcount);
     227                } else if (subMenu instanceof JPopupMenu) {
     228                        MenuScroller.setScrollerFor((JPopupMenu)subMenu, scrollcount);
     229                }
    217230        }
    218231        return (hasBookmarks || offsetServerSupported) ? subMenu : adjustMenuItem;
Note: See TracChangeset for help on using the changeset viewer.