Class JsonSearchBar

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class JsonSearchBar extends JPanel
A compact search bar that drives text highlighting in the raw pane and match navigation in the tree pane.

Layout

  [ Search: ][______________text field______________][ ▲ ][ ▼ ][ ✕ ][ 3 of 12 ]
 

The bar is placed in the SOUTH slot of the JsonSplitPane below both content panes so it spans the full width and is always visible.

Behaviour

  • Typing in the field immediately highlights all matching spans in the raw pane via JsonRawPane#highlight(String) and filters the tree to show only matching paths via JsonTreePane.search(String).
  • The ▲ / ▼ buttons (and F3 / Shift+F3 key bindings) navigate between raw-pane highlights.
  • The ✕ button clears the query and removes all highlights.
  • The match count label ("3 of 12") is updated after every search by a callback from JsonRawPane.
  • The field background turns a muted red when there are no matches, normal dark when there are matches or the field is empty.

Threading

All callbacks arrive and all mutations happen on the EDT.

See Also:
  • Constructor Details

    • JsonSearchBar

      public JsonSearchBar(JsonRawPane rawPane, JsonTreePane treePane)
      Create a search bar wired to the given raw and tree panes.
      Parameters:
      rawPane - the raw text pane to highlight; must not be null
      treePane - the tree pane to filter; must not be null
  • Method Details

    • clearSearch

      public void clearSearch()
      Clear the search field and remove all highlights.

      Also called by JsonSplitPane when a new file is loaded, so stale highlights from the previous file do not persist.