Class JsonView

All Implemented Interfaces:
IFeedbackProvider, IFileDropHandler, ComponentListener, FocusListener, MouseListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants

public class JsonView extends BaseView
A container-less demo view that displays a JSON file as both colorized raw text and a collapsible tree, side by side in a split pane.

Usage

Open a file programmatically via loadFile(File), or simply drag a .json file onto the view — drop support is enabled in the constructor via BaseView.enableFileDrop(java.util.function.Predicate).

Layout

The view is container-less (no IContainer): it follows the same pattern as LogView and adds its content component — a JsonSplitPane — directly to the frame's BorderLayout.CENTER.

Threading

File I/O and JSON parsing are performed on a background thread inside JsonSplitPane.loadFile(File). The EDT is never blocked regardless of file size.

See Also:
  • Constructor Details

    • JsonView

      public JsonView()
      Create a JsonView with default dimensions, initially hidden.
    • JsonView

      public JsonView(int width, int height, boolean visible)
      Create a JsonView with explicit dimensions and visibility.

      Construction follows the LogView pattern: properties are passed to BaseView, then the content panel is added to BorderLayout.CENTER. File drop support is activated last so the view frame — the drop surface for container-less views — is already in the Swing hierarchy.

      Parameters:
      width - initial frame width in pixels
      height - initial frame height in pixels
      visible - true to make the view visible immediately
  • Method Details

    • loadFile

      public void loadFile(File file)
      Load and display the given JSON file.

      Delegates to JsonSplitPane.loadFile(File), which performs I/O and parsing on a background thread and updates both panes on the EDT when done.

      Parameters:
      file - the JSON file to display; must not be null
    • filesDropped

      public void filesDropped(List<File> files)
      Handle a JSON file dropped onto this view.

      Only the first file is used. The filter set in the constructor (.json extension) has already been applied by FileDropHandler, so no second check is needed here.

      Specified by:
      filesDropped in interface IFileDropHandler
      Overrides:
      filesDropped in class BaseView
      Parameters:
      files - the accepted dropped files; never null, never empty
    • getViewInfo

      public AbstractViewInfo getViewInfo()
      Override to supply structured information for the info dialog. The default returns null (no info available).

      Returns a JsonViewInfo describing the view's purpose, supported file types, and keyboard shortcuts.

      Overrides:
      getViewInfo in class BaseView
      Returns:
      view info, or null