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.56 date: 2023/08/18 10:41:28
user: matilk
file: DataSetView.st directory: libwidg2
module: stx stc-classLibrary: libwidg2

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.

copyright

COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Instance protocol:

accessing
o  columnView
return the view which shows the columns

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
return the view which shows the top label line (column names)

change & update
o  update: something with: aParameter from: changedObject
(comment from inherited method)
whenever the scrolledView changes its contents, the scroller(s) must
be updated as well

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
(comment from inherited method)
returns true if the widget is tabable

o  computePreferredExtent
return my preferredExtent from the scrolledViews prefExtent
plus the size of the scrollBar

o  specClass
returns my spec class (for UI editor)


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:(DataSetColumn editorType_None)        selector:rdWtSel).
  columns add:(DataSetColumnSpec label:'Input'  editorType:(DataSetColumn editorType_InputField)  selector:rdWtSel).
  columns add:(DataSetColumnSpec label:'Toggle' editorType:(DataSetColumn editorType_CheckToggle) selector:rdWtSel).
  columns add:(DataSetColumnSpec label:'Radio'  editorType:(DataSetColumn 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:(DataSetColumn editorType_None)        selector:rdWtSel).
  columns add:(DataSetColumnSpec label:'Input'  editorType:(DataSetColumn editorType_InputField)  selector:rdWtSel).
  columns add:(DataSetColumnSpec label:'Toggle' editorType:(DataSetColumn 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:(DataSetColumn EditorType_None)        selector:#text ).
  clDc add:( DataSetColumnSpec label:'Text'   editorType:(DataSetColumn EditorType_None)        selector:#text ).
  clDc add:( DataSetColumnSpec label:'Field'  editorType:(DataSetColumn EditorType_InputField)  selector:#field ).
  clDc add:( DataSetColumnSpec label:'C-Box'  editorType:(DataSetColumn EditorType_ComboBox)    selector:#cbox ).
  clDc last choices:#choices.
  clDc add:( DataSetColumnSpec label:'C-List' editorType:(DataSetColumn EditorType_ComboList)   selector:#clist ).
  clDc last choices:#choices.
  clDc add:( DataSetColumnSpec label:'Toggle' editorType:(DataSetColumn 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:(DataSetColumn EditorType_None)        selector:#text ).
  clDc add:( DataSetColumnSpec label:'Text'   editorType:(DataSetColumn EditorType_None)        selector:#text ).
  clDc add:( DataSetColumnSpec label:'Field'  editorType:(DataSetColumn EditorType_InputField)  selector:#field ).
  clDc add:( DataSetColumnSpec label:'C-Box'  editorType:(DataSetColumn EditorType_ComboBox)    selector:#cbox ).
  clDc last choices:#choices.
  clDc add:( DataSetColumnSpec label:'C-List' editorType:(DataSetColumn EditorType_ComboList)   selector:#clist ).
  clDc last choices:#choices.
  clDc add:( DataSetColumnSpec label:'Toggle' editorType:(DataSetColumn 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 openAndWaitUntilVisible.

  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.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sun, 21 Jul 2024 22:52:27 GMT