API for seesaw.table - Seesaw


Full namespace name: seesaw.table

Overview





Public Variables and Functions



clear!

function
Usage: (clear! target)
Clear all rows from a table model or JTable. 

Returns target.


column-count

function
Usage: (column-count target)
Return number of columns in a table model or JTable.


insert-at!

function
Usage: (insert-at! target row value)
       (insert-at! target row value & more)
Inserts one or more rows into a table. The arguments are one or more row-index/value
pairs where value is either a map or a vector with the right number of columns. Each
row index indicates the position before which the new row will be inserted. All indices
are relative to the starting state of the table, i.e. they shouldn't take any shifting
of rows that takes place during the insert. The indices *must* be in ascending sorted
order!!

Returns target.

Examples:

  ; Insert a row at the front of the table
  (insert-at! 0 {:name "Agent Cooper" :likes "Cherry pie and coffee"})

  ; Insert two rows, one at the front, one before row 3
  (insert-at! 0 {:name "Agent Cooper" :likes "Cherry pie and coffee"}
              3 {:name "Big Ed"       :likes "Norma"})



remove-at!

function
Usage: (remove-at! target row)
       (remove-at! target row & more)
Remove one or more rows from a table or table model by index. Args are a list of row indices at
the start of the operation. The indices *must* be in ascending sorted order!

Returns target.

Examples:

  ; Remove first row
  (remove-at! t 0)

  ; Remove first and third row
  (remove-at! t 0 3)


row-count

function
Usage: (row-count target)
Return number of rows in a table model or JTable.


table-model

function
Usage: (table-model & {:keys [columns rows], :as opts})
Creates a TableModel from column and row data. Takes two options:

  :columns - a list of keys, or maps. If a key, then (name key) is used
             as the column name. If a map, it must be in the form
             {:key key :text text} where text is used as the column name
             and key is use to index the row data.
             The order establishes the order of the columns in the table.

  :rows - a sequence of maps or vectors, possibly mixed. If a map, must contain
          row data indexed by keys in :columns. Any additional keys will
          be remembered and retrievable with (value-at). If a vector, data 
          is indexed by position in the vector.

Example:
  
  (table-model :columns [:name 
                         {:key :age :text "Age"}]
               :rows [ ["Jim" 65]
                       {:age 75 :name "Doris"}])

  This creates a two column table model with columns "name" and "Age"
  and two rows. 

See:
  (seesaw.core/table)
  http://download.oracle.com/javase/6/docs/api/javax/swing/table/TableModel.html


update-at!

function
Usage: (update-at! target row value)
       (update-at! target row value & more)
Update a row in a table model or JTable. Accepts an arbitrary number of row/value
pairs where row is an integer row index and value is a map or vector of values
just like the :rows property of (table-model).

Notes:

  Any non-column keys, i.e. keys that weren't present in the original column
  spec when the table-model was constructed will be remembered and retrievable
  later with (value-at).

Examples:

  ; Given a table created with column keys :a and :b, update row 3 and 5
  (update-at! t 3 ["Col0 Value" "Col1 Value"]
                5 { :a "A value" "B value" })

See:
  (seesaw.core/table)
  (seesaw.table/table-model)
  http://download.oracle.com/javase/6/docs/api/javax/swing/table/TableModel.html


value-at

function
Usage: (value-at target rows)
Retrieve one or more rows from a table or table model. target is a JTable or TableModel.
rows is either a single integer row index, or a sequence of row indices. In the first case
a single map of row values is returns. Otherwise, returns a sequence of maps.

Notes:

If target was not created with (table-model), the returned map(s) are indexed
by column name.

Any non-column keys passed to (update-at!) or the initial rows of (table-model)
are *remembered* and returned in the map.

Examples:

  ; Retrieve row 3
  (value-at t 3)

  ; Retrieve rows 1, 3, and 5
  (value-at t [1 3 5])

  ; Print values of selected rows
  (listen t :selection
    (fn [e]
      (println (value-at t (selection {:multi? true} t)))))
See:
  (seesaw.core/table)
  (seesaw.table/table-model)
  http://download.oracle.com/javase/6/docs/api/javax/swing/table/TableModel.html
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.