Liking cljdoc? Tell your friends :D

DSUI

A Clojure tool for displaying arbitrary, nested data structures as a read-only, form-based UI. DSUI stands for "Data Structure User Interface".

Clojars Project

Motivation

  1. Being tired of writing UI code.

  2. Avoiding this:
    Data in Cider

  3. And getting this instead:
    Data in DSUI

Usage

Installing the library

Via deps:

{:deps {org.clojars.azel4231/dsui {:mvn/version "0.1.1"}}}

Via lein:

:dependencies [[org.clojars.azel4231/dsui "0.1.1"]]

Via maven:

<dependency>
  <groupId>org.clojars.azel4231</groupId>
  <artifactId>dsui</artifactId>
  <version>0.1.1</version>
</dependency>

Calling the library

(require '[dsui.swing :as d])

Display data as a form-based UI:

(d/dsui any-data)

Show how data conforms to a spec. Useful for specs with choices (via s/or) or labeled values (vis s/cat). If the data does not conform, displays the explanation (explain-data) as a ui:

(d/conform-ui ::any-spec any-data)

Attach dsui to a ref and leave it open:

(defonce state (atom []))
(defonce ui (d/watch-ui state))

Swap new data into the atom to update the watch-ui window (REPL workflow)

(reset! state '[1 2 3 "A" "B" "C" + - * /])

Or just have it display your app's changing app-state.

Basic Features

Displays:

  • maps as forms, nested data structures a tabbed panes
  • sequential data (including vectors, lists and sets) as vertical tabbed panes with (0..n) as a title
  • lists containing only scalar values as JLists
  • Matrices (vector of vectors) as tables
  • Lists of maps, that have the same keyset and contain scalar values only, as tables
  • conformed data (labeled data) returned by specs as vertical tabbed panes with the label as a title. Thus DSUI can be also used to see how things conformed when writing specs

Does not support:

  • a single scalar value

Not suited for:

  • graph-like data
  • large data-sets (generating the UI is currently eager)

How it works

DSUI uses clojure.spec to "parse" an arbitrary data structure. The conformed data is used to generate the swing UI by calling a multimethod that polymorphically creates different types of UI elements.

More detailed explanations can be found here and here

Next Steps

  • Decomplect processing pipeline: move parts that are agnostic of the UI framework into a separate step so they can be reused for other UI frameworks.
  • Migrate to fn-fx

Distant Future

  • Make UI editable (e.g. swap value to an atom)

License

Distributed under the Eclipse Public License, the same as Clojure.

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close