Changeset 12333 in josm


Ignore:
Timestamp:
2017-06-07T23:56:16+02:00 (7 years ago)
Author:
michael2402
Message:

Fix #14840: Add separation borders to search dialog. Patch by bafonins

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java

    r12279 r12333  
    2929import java.util.function.Predicate;
    3030
    31 import javax.swing.ButtonGroup;
    3231import javax.swing.JCheckBox;
    3332import javax.swing.JLabel;
     
    3736import javax.swing.text.BadLocationException;
    3837import javax.swing.text.JTextComponent;
     38import javax.swing.BorderFactory;
     39import javax.swing.ButtonGroup;
    3940
    4041import org.openstreetmap.josm.Main;
     
    275276        JCheckBox allElements = new JCheckBox(tr("all objects"), initialValues.allElements);
    276277        allElements.setToolTipText(tr("Also include incomplete and deleted objects in search."));
     278        JCheckBox addOnToolbar = new JCheckBox(tr("add toolbar button"), false);
     279
    277280        final JRadioButton standardSearch = new JRadioButton(tr("standard"), !initialValues.regexSearch && !initialValues.mapCSSSearch);
    278281        final JRadioButton regexSearch = new JRadioButton(tr("regular expression"), initialValues.regexSearch);
    279282        final JRadioButton mapCSSSearch = new JRadioButton(tr("MapCSS selector"), initialValues.mapCSSSearch);
    280         final JCheckBox addOnToolbar = new JCheckBox(tr("add toolbar button"), false);
    281283        final ButtonGroup bg2 = new ButtonGroup();
    282284        bg2.add(standardSearch);
     
    284286        bg2.add(mapCSSSearch);
    285287
    286         JPanel top = new JPanel(new GridBagLayout());
     288        JPanel left = new JPanel(new GridBagLayout());
     289
     290        JPanel selectionSettings = new JPanel(new GridBagLayout());
     291        selectionSettings.setBorder(BorderFactory.createTitledBorder(tr("Selection settings")));
     292        selectionSettings.add(replace, GBC.eol());
     293        selectionSettings.add(add, GBC.eol());
     294        selectionSettings.add(remove, GBC.eol());
     295        selectionSettings.add(inSelection, GBC.eop());
     296
     297        JPanel additionalSettings = new JPanel(new GridBagLayout());
     298        additionalSettings.setBorder(BorderFactory.createTitledBorder(tr("Additional settings")));
     299        additionalSettings.add(caseSensitive, GBC.eol());
     300
     301        if (Main.pref.getBoolean("expert", false)) {
     302            additionalSettings.add(allElements, GBC.eol());
     303            additionalSettings.add(addOnToolbar, GBC.eop());
     304
     305            JPanel searchOptions = new JPanel(new GridBagLayout());
     306            searchOptions.setBorder(BorderFactory.createTitledBorder(tr("Search Options")));
     307            searchOptions.add(standardSearch, GBC.eol());
     308            searchOptions.add(regexSearch, GBC.eol());
     309            searchOptions.add(mapCSSSearch, GBC.eol());
     310
     311            left.add(selectionSettings, GBC.eol().fill(GBC.BOTH));
     312            left.add(additionalSettings, GBC.eol().fill(GBC.BOTH));
     313            left.add(searchOptions, GBC.eol().fill(GBC.BOTH));
     314        } else {
     315            left.add(selectionSettings, GBC.eol().fill(GBC.BOTH));
     316            left.add(additionalSettings, GBC.eol().fill(GBC.BOTH));
     317        }
     318
     319        final JPanel right = SearchAction.buildHintsSection(hcbSearchString);
     320        final JPanel top = new JPanel(new GridBagLayout());
    287321        top.add(label, GBC.std().insets(0, 0, 5, 0));
    288322        top.add(hcbSearchString, GBC.eol().fill(GBC.HORIZONTAL));
    289         JPanel left = new JPanel(new GridBagLayout());
    290         left.add(replace, GBC.eol());
    291         left.add(add, GBC.eol());
    292         left.add(remove, GBC.eol());
    293         left.add(inSelection, GBC.eop());
    294         left.add(caseSensitive, GBC.eol());
    295         if (Main.pref.getBoolean("expert", false)) {
    296             left.add(allElements, GBC.eol());
    297             left.add(addOnToolbar, GBC.eop());
    298             left.add(standardSearch, GBC.eol());
    299             left.add(regexSearch, GBC.eol());
    300             left.add(mapCSSSearch, GBC.eol());
    301         }
    302 
    303         final JPanel right;
    304         right = new JPanel(new GridBagLayout());
    305         buildHints(right, hcbSearchString);
    306323
    307324        final JTextComponent editorComponent = hcbSearchString.getEditorComponent();
     
    335352        final JPanel p = new JPanel(new GridBagLayout());
    336353        p.add(top, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 5, 0));
    337         p.add(left, GBC.std().anchor(GBC.NORTH).insets(5, 10, 10, 0));
    338         p.add(right, GBC.eol());
     354        p.add(left, GBC.std().anchor(GBC.NORTH).insets(5, 10, 10, 0).fill(GBC.VERTICAL));
     355        p.add(right, GBC.eol().fill(GBC.BOTH).insets(0, 10, 0, 0));
     356
    339357        ExtendedDialog dialog = new ExtendedDialog(
    340358                Main.parent,
     
    400418    }
    401419
    402     private static void buildHints(JPanel right, HistoryComboBox hcbSearchString) {
    403         right.add(new SearchKeywordRow(hcbSearchString)
    404                 .addTitle(tr("basic examples"))
     420    private static JPanel buildHintsSection(HistoryComboBox hcbSearchString) {
     421        JPanel hintPanel = new JPanel(new GridBagLayout());
     422        hintPanel.setBorder(BorderFactory.createTitledBorder(tr("Search hints")));
     423
     424        hintPanel.add(new SearchKeywordRow(hcbSearchString)
     425                .addTitle(tr("basics"))
    405426                .addKeyword(tr("Baker Street"), null, tr("''Baker'' and ''Street'' in any key"))
    406                 .addKeyword(tr("\"Baker Street\""), "\"\"", tr("''Baker Street'' in any key")),
    407                 GBC.eol());
    408         right.add(new SearchKeywordRow(hcbSearchString)
    409                 .addTitle(tr("basics"))
     427                .addKeyword(tr("\"Baker Street\""), "\"\"", tr("''Baker Street'' in any key"))
    410428                .addKeyword("<i>key</i>:<i>valuefragment</i>", null,
    411429                        tr("''valuefragment'' anywhere in ''key''"), "name:str matches name=Bakerstreet")
    412                 .addKeyword("-<i>key</i>:<i>valuefragment</i>", null, tr("''valuefragment'' nowhere in ''key''"))
     430                .addKeyword("-<i>key</i>:<i>valuefragment</i>", null, tr("''valuefragment'' nowhere in ''key''")),
     431                GBC.eol());
     432        hintPanel.add(new SearchKeywordRow(hcbSearchString)
    413433                .addKeyword("<i>key</i>=<i>value</i>", null, tr("''key'' with exactly ''value''"))
    414434                .addKeyword("<i>key</i>=*", null, tr("''key'' with any value"))
     
    418438                .addKeyword("\"key\"=\"value\"", "\"\"=\"\"",
    419439                        tr("to quote operators.<br>Within quoted strings the <b>\"</b> and <b>\\</b> characters need to be escaped " +
    420                            "by a preceding <b>\\</b> (e.g. <b>\\\"</b> and <b>\\\\</b>)."),
     440                                "by a preceding <b>\\</b> (e.g. <b>\\\"</b> and <b>\\\\</b>)."),
    421441                        "\"addr:street\""),
    422                 GBC.eol());
    423         right.add(new SearchKeywordRow(hcbSearchString)
     442                GBC.eol().anchor(GBC.CENTER));
     443        hintPanel.add(new SearchKeywordRow(hcbSearchString)
    424444                .addTitle(tr("combinators"))
    425445                .addKeyword("<i>expr</i> <i>expr</i>", null, tr("logical and (both expressions have to be satisfied)"))
     
    431451
    432452        if (Main.pref.getBoolean("expert", false)) {
    433             right.add(new SearchKeywordRow(hcbSearchString)
     453            hintPanel.add(new SearchKeywordRow(hcbSearchString)
    434454                .addTitle(tr("objects"))
    435455                .addKeyword("type:node", "type:node ", tr("all nodes"))
     
    439459                .addKeyword("untagged", "untagged ", tr("object without useful tags")),
    440460                GBC.eol());
    441             right.add(new SearchKeywordRow(hcbSearchString)
     461            hintPanel.add(new SearchKeywordRow(hcbSearchString)
    442462                .addTitle(tr("metadata"))
    443463                .addKeyword("user:", "user:", tr("objects changed by user", "user:anonymous"))
     
    449469                        "timestamp:2008/2011-02-04T12"),
    450470                GBC.eol());
    451             right.add(new SearchKeywordRow(hcbSearchString)
     471            hintPanel.add(new SearchKeywordRow(hcbSearchString)
    452472                .addTitle(tr("properties"))
    453473                .addKeyword("nodes:<i>20-</i>", "nodes:", tr("ways with at least 20 nodes, or relations containing at least 20 nodes"))
     
    458478                .addKeyword("waylength:<i>200-</i>", "waylength:", tr("ways with a length of 200 m or more")),
    459479                GBC.eol());
    460             right.add(new SearchKeywordRow(hcbSearchString)
     480            hintPanel.add(new SearchKeywordRow(hcbSearchString)
    461481                .addTitle(tr("state"))
    462482                .addKeyword("modified", "modified ", tr("all modified objects"))
     
    466486                .addKeyword("deleted", "deleted ", tr("all deleted objects (checkbox <b>{0}</b> must be enabled)", tr("all objects"))),
    467487                GBC.eol());
    468             right.add(new SearchKeywordRow(hcbSearchString)
     488            hintPanel.add(new SearchKeywordRow(hcbSearchString)
    469489                .addTitle(tr("related objects"))
    470490                .addKeyword("child <i>expr</i>", "child ", tr("all children of objects matching the expression"), "child building")
     
    477497                        tr("every n-th member of relation and/or every n-th node of way"), "nth%:100 (child waterway)"),
    478498                GBC.eol());
    479             right.add(new SearchKeywordRow(hcbSearchString)
     499            hintPanel.add(new SearchKeywordRow(hcbSearchString)
    480500                .addTitle(tr("view"))
    481501                .addKeyword("inview", "inview ", tr("objects in current view"))
     
    486506                GBC.eol());
    487507        }
     508
     509        return hintPanel;
    488510    }
    489511
     
    605627                    );
    606628                }
    607             } else if (Main.map != null) {
     629            } else {
    608630                Main.map.statusLine.setHelpText(tr("Found {0} matches", foundMatches));
    609631            }
Note: See TracChangeset for help on using the changeset viewer.