Ticket #6187: bettersearch.patch

File bettersearch.patch, 3.8 KB (added by bilbo, 11 years ago)

Patch to improve search GUI

  • src/org/openstreetmap/josm/actions/search/SearchAction.java

     
    135135        }
    136136        // -- prepare the combo box with the search expressions
    137137        //
    138         JLabel label = new JLabel( initialValues instanceof Filter ? tr("Please enter a filter string.") : tr("Please enter a search string."));
     138        JLabel label = new JLabel( initialValues instanceof Filter ? tr("Filter string:") : tr("Search string:"));
    139139        final HistoryComboBox hcbSearchString = new HistoryComboBox();
    140140        hcbSearchString.setText(initialValues.text);
    141141        hcbSearchString.getEditor().selectAll();
     
    164164        allElements.setToolTipText(tr("Also include incomplete and deleted objects in search."));
    165165        final JCheckBox regexSearch   = new JCheckBox(tr("regular expression"), initialValues.regexSearch);
    166166
     167        JPanel top = new JPanel(new GridBagLayout());
     168        top.add(label, GBC.std());
     169        top.add(hcbSearchString, GBC.eol().fill(GBC.HORIZONTAL));
    167170        JPanel left = new JPanel(new GridBagLayout());
    168         left.add(label, GBC.eop());
    169         left.add(hcbSearchString, GBC.eop().fill(GBC.HORIZONTAL));
    170171        left.add(replace, GBC.eol());
    171172        left.add(add, GBC.eol());
    172173        left.add(remove, GBC.eol());
     
    211212        description.setFont(description.getFont().deriveFont(Font.PLAIN));
    212213        right.add(description);
    213214
    214         final JPanel p = new JPanel();
    215         p.add(left);
    216         p.add(right);
     215        final JPanel p = new JPanel(new GridBagLayout());
     216        p.add(top, GBC.eol().fill(GBC.HORIZONTAL));
     217        p.add(left, GBC.std());
     218        p.add(right, GBC.eol());
    217219        ExtendedDialog dialog = new ExtendedDialog(
    218220                Main.parent,
    219221                initialValues instanceof Filter ? tr("Filter") : tr("Search"),
  • src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java

     
    22package org.openstreetmap.josm.gui.tagging.ac;
    33
    44import java.awt.Component;
     5import java.awt.Dimension;
     6import java.awt.Toolkit;
    57import java.awt.event.FocusEvent;
    68import java.awt.event.FocusListener;
    79import java.util.Collection;
     
    144146                    }
    145147                }
    146148        );
     149        int maxsize=Math.max(getMaximumRowCount(),java.awt.Toolkit.getDefaultToolkit().getScreenSize().height/getPreferredSize().height);
     150        setMaximumRowCount(maxsize);
    147151    }
    148152
    149153    /**
     
    253257            return this;
    254258        }
    255259    }
     260
     261
     262
    256263}
  • src/org/openstreetmap/josm/gui/widgets/HistoryComboBox.java

     
    66import javax.swing.text.JTextComponent;
    77
    88import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingComboBox;
     9import org.openstreetmap.josm.Main;
    910
    1011public class HistoryComboBox extends AutoCompletingComboBox {
    1112    private ComboBoxHistory model;
    1213
     14    public static final int DEFAULT_SEARCH_HISTORY_SIZE = 15;
     15
    1316    public HistoryComboBox() {
    14         setModel(model = new ComboBoxHistory(15));
     17        int maxsize = Main.pref.getInteger("search.history-size", DEFAULT_SEARCH_HISTORY_SIZE);
     18        setModel(model = new ComboBoxHistory(maxsize));
    1519        setEditable(true);
    1620    }
    1721