eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'DataSetView':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: DataSetView


Inheritance:

   Object
   |
   +--GraphicsMedium
      |
      +--DisplaySurface
         |
         +--SimpleView
            |
            +--ScrollableView
               |
               +--DataSetView

Package:
stx:libwidg2
Category:
Views-DataSet
Version:
rev: 1.50 date: 2018/04/18 08:12:48
user: stefan
file: DataSetView.st directory: libwidg2
module: stx stc-classLibrary: libwidg2
Author:
Claus Atzkern

Description:


This class implements a selection list view based on rows and columns.
Instances are wrapping a DSVLabelView and a DSVColumnView.
It allows for the dynamic editing of this information.

This is a replacement for the obsolete TableView.


Related information:

    DataSetColumnSpec
    DataSetColumn
    DSVColumnView

Instance protocol:

accessing
o  columnView

o  ignoreReselect: aBoolean
controls if clicking on an already selected item should
be ignored or should perform the select action again.
By default, these are ignored

o  labelView

change & update
o  update: something with: aParameter from: changedObject

initialization & release
o  initialize
set column area

layout computation
o  recomputeLayouts
columnView realized ifTrue:[

o  scrolledViewLayout: aLayout
invoked by superclasses setLayout method, whenever the scrolled views
layout changes (due to added/removed scrollbars).

o  verticalScrollBarLayout: aLayout
redefined to care for the label view,
which is at the top and NOT scrolled.
It covers the top areay of myself, so we have to make the vertical
scrollbar a little smaller.

queries
o  canTab

o  preferredExtent
return my preferredExtent from the scrolledViews prefExtent
plus the size of the scrollBar
usage example(s):
If I have an explicit preferredExtent..
usage example(s):
If I have a cached preferredExtent value..

o  specClass
returns my spec class


Examples:


example 1: list with valid rows of type Array
  |top scr columns rows bool rdWtSel|

  top  := StandardSystemView new label:'Simple Test'; extent:700@440.
  scr  := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.

  columns := OrderedCollection new.
  rows    := OrderedCollection new.
  bool    := true.
  rdWtSel := #( #at: #at:put: ).

  1 to:1000 do:[:i||n|
      n := i printString.
      rows add:(Array with:('text: ', n) with:('input: ', n) with:bool with:(i==20)).
      bool := bool not.
  ].

  columns add:(DataSetColumnSpec label:'Text'   editorType:#None        selector:rdWtSel).
  columns add:(DataSetColumnSpec label:'Input'  editorType:#InputField  selector:rdWtSel).
  columns add:(DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:rdWtSel).
  columns add:(DataSetColumnSpec label:'Radio'  editorType:#RadioButton selector:rdWtSel).

  scr columnDescriptors:columns.
  scr list:rows.
  top open.
example 2: list with none valid rows; defining #rowIfAbsent: block
  |top scr columns bool rdWtSel|

  top  := StandardSystemView new label:'Row Is Absent'; extent:700@440.
  scr  := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.

  columns := OrderedCollection new.
  bool    := true.
  rdWtSel := #( #at: #at:put: ).

  columns add:(DataSetColumnSpec label:'Text'   editorType:#None        selector:rdWtSel).
  columns add:(DataSetColumnSpec label:'Input'  editorType:#InputField  selector:rdWtSel).
  columns add:(DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:rdWtSel).

  scr rowIfAbsent:[:i|
      bool := bool not.
      Array with:('text: ', i printString) with:('input: ') with:bool
  ].

  scr columnDescriptors:columns.
  scr list:(Array new:1000).
  top open.
example 3: list with valid rows of type Structure
  |top scr clDc rows slct list idx bool|

  top  := StandardSystemView new label:'Editors'; extent:700@440.
  scr  := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.

  clDc := OrderedCollection new.
  rows := OrderedCollection new.
  list := #( 'Text ' 'Field ' 'C-Box ' 'C-List ' true    #( 'foo' 'bar' 'baz' ) ).
  slct := #( #text   #field   #cbox    #clist    #toggle #choices               ).
  idx  := 11.
  bool := true.

  20 timesRepeat:[ |values|
      values := list collect:[:n|
          n isString ifTrue:[n, idx printString]
                    ifFalse:[n == true ifTrue:[bool] ifFalse:[n]]
      ].
      rows add:(Structure newWith:slct values:values).
      bool := bool not.
      idx  := idx + 1.
  ].
  clDc add:( DataSetColumnSpec label:'Text'   editorType:#None        selector:#text ).
  clDc add:( DataSetColumnSpec label:'Text'   editorType:#None        selector:#text ).
  clDc add:( DataSetColumnSpec label:'Field'  editorType:#InputField  selector:#field ).
  clDc add:( DataSetColumnSpec label:'C-Box'  editorType:#ComboBox    selector:#cbox ).
  clDc last choices:#choices.
  clDc add:( DataSetColumnSpec label:'C-List' editorType:#ComboList   selector:#clist ).
  clDc last choices:#choices.
  clDc add:( DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:#toggle ).

  scr has3Dseparators:true.
  scr columnDescriptors:clDc.
  scr list:rows.
  top open.
example 4: table includes a row selector and multiple select is enabled
  |top scr clDc rows slct list idx bool|

  top  := StandardSystemView new label:'Multiple Select'; extent:700@440.
  scr  := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.

  clDc := OrderedCollection new.
  rows := OrderedCollection new.
  list := #( 'Text ' 'Field ' 'C-Box ' 'C-List ' true    #( 'foo' 'bar' 'baz' ) ).
  slct := #( #text   #field   #cbox    #clist    #toggle #choices               ).
  idx  := 11.
  bool := true.

  20 timesRepeat:[ |values|
      values := list collect:[:n|
          n isString ifTrue:[n, idx printString]
                    ifFalse:[n == true ifTrue:[bool] ifFalse:[n]]
      ].
      rows add:(Structure newWith:slct values:values).
      bool := bool not.
      idx  := idx + 1.
  ].
  clDc add:( DataSetColumnSpec rowSelector ).
  clDc add:( DataSetColumnSpec label:'Text'   editorType:#None        selector:#text ).
  clDc add:( DataSetColumnSpec label:'Text'   editorType:#None        selector:#text ).
  clDc add:( DataSetColumnSpec label:'Field'  editorType:#InputField  selector:#field ).
  clDc add:( DataSetColumnSpec label:'C-Box'  editorType:#ComboBox    selector:#cbox ).
  clDc last choices:#choices.
  clDc add:( DataSetColumnSpec label:'C-List' editorType:#ComboList   selector:#clist ).
  clDc last choices:#choices.
  clDc add:( DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:#toggle ).

  scr has3Dseparators:true.
  scr columnDescriptors:clDc.
  scr multipleSelectOk:true.
  scr list:rows.
  top open.
example 5: Images and Layout
  |top scr columns rows colDesc image text|

  text := 'Text'.
  rows := Array new:1000.

  1 to:(rows size) do:[:i|
      rows at:i put:(Array with:('Id: ', i printString) with:text with:text)
  ].

  columns := OrderedCollection new.
  image   := Image fromFile:('xpmBitmaps/misc_tools/box_full.xpm' ).

  colDesc := DataSetColumnSpec label:(LabelAndIcon icon:image string:'Left') selector:#at:.
  colDesc labelAlignment:#left.
  colDesc columnAlignment:#left.
  columns add:colDesc.

  colDesc := DataSetColumnSpec label:(LabelAndIcon icon:image string:'Right') selector:#at:.
  colDesc labelAlignment:#right.
  colDesc columnAlignment:#right.
  columns add:colDesc.

  colDesc := DataSetColumnSpec label:(LabelAndIcon icon:image string:'Center') selector:#at:.
  colDesc labelAlignment:#center.
  colDesc columnAlignment:#center.
  columns add:colDesc.

  columns do:[:el|el labelActionSelector:#dummy].

  top := StandardSystemView new label:'Layout'; extent:500@500.
  scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.
  scr has3Dseparators:true.
  scr columnDescriptors:columns.
  scr list:rows.

  top open
example 6: adding and removing
  |top scr list|

  top  := StandardSystemView new label:'Adding & Removing'; extent:600@440.
  scr  := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.

  scr columnDescriptors:( Array with:(DataSetColumnSpec label:'FOO' selector:#at:)
                                with:(DataSetColumnSpec label:'BAR' selector:#at:)
                                with:(DataSetColumnSpec label:'BAZ' selector:#at:)
                        ).

  scr has3Dseparators:true.
  scr listHolder:(list := List new).
  top openAndWait.

  1 to:32 do:[:i| |pid|
      pid := i printString.
      list add:(Array with:('foo: ', pid) with:('bar: ', pid) with:('baz: ', pid)).
      i even ifTrue:[
          list removeFirst
      ].       
      Delay waitForSeconds:0.1.
  ].


ST/X 7.1.0.0; WebServer 1.663 at exept.de:8081; Wed, 19 Sep 2018 05:01:12 GMT