Changeset 4056 in josm


Ignore:
Timestamp:
2011-04-23T00:32:55+02:00 (13 years ago)
Author:
framm
Message:

allow a new "rows" attribute for multi select objects which can be used to set the desired
number of rows (=height of the multi-select).

File:
1 edited

Legend:

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

    r4050 r4056  
    683683        public boolean use_last_as_default = false;
    684684        public boolean required = false;
     685        public long rows = -1;
    685686
    686687        private List<String> short_description_list;
     
    752753
    753754            list = new ConcatenatingJList(delimiter, lhm.values().toArray());
    754             list.setCellRenderer(new PresetListCellRenderer());
     755            PresetListCellRenderer renderer = new PresetListCellRenderer();
     756            list.setCellRenderer(renderer);
    755757
    756758            if (usage.hasUniqueValue() && !usage.unused()) {
     
    776778            }
    777779            p.add(new JLabel(locale_text+":"), GBC.std().insets(0,0,10,0));
    778             p.add(new JScrollPane(list), GBC.eol().fill(GBC.HORIZONTAL));
     780            JScrollPane sp = new JScrollPane(list);
     781            // if a number of rows has been specified in the preset,
     782            // modify preferred height of scroll pane to match that row count.
     783            if (rows != -1)
     784            {
     785                double height = renderer.getListCellRendererComponent(list,
     786                    new PresetListEntry("x"), 0, false, false).getPreferredSize().getHeight() * rows;
     787                sp.setPreferredSize(new Dimension((int) sp.getPreferredSize().getWidth(), (int) height));
     788            }
     789            p.add(sp, GBC.eol().fill(GBC.HORIZONTAL));
    779790            return true;
    780791        }
Note: See TracChangeset for help on using the changeset viewer.